summaryrefslogtreecommitdiff
path: root/httemplate/elements/one_time_charge_link.html
blob: 3a0f9b1a0f2dfbdf0ce4c6c5474a1d785ba6428b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<%doc>

Example:

  <& /elements/one_time_charge_link.html,

     #one of these is required (except when form_only is true)
     'custnum'     => $custnum,
     'prospectnum' => $prospectnum,

     'no_form'   => 0,
     'form_only' => 0,
  &>

</%doc>
%
% unless ( $opt{form_only} ) {
%
<SCRIPT TYPE="text/javascript">

function taxproductmagic(which) {

  var str = '';
  var elements = which.form.elements;
  for (var i = 0; i<elements.length; i++) {

    if (elements[i].name == 'taxproductnum'){
      document.getElementById('taxproductnum').value = elements[i].value;
      continue;
    }
    if (elements[i].name == 'taxproductnum_description'){
      continue;
    }

    if (str.length){str += ';';}

    var value = '';
    if ( elements[i].type == 'checkbox' || elements[i].type == 'radio' ) {
      if ( elements[i].checked == true ) {
        value = elements[i].value;
      //} else {
      //  value = '';
      }
    } else {
      value = elements[i].value;
    }
    str += elements[i].name + '=' + escape(value);

  }
  document.getElementById('charge_storage').value = str;
  cClick();
  overlib( OLiframeContent('<% $p %>/browse/part_pkg_taxproduct.cgi?_type=select&id=taxproductnum&onclick=taxproductquickchargemagic&taxproductnum='+document.getElementById('taxproductnum').value, 1000, 400, 'tax_product_popup'), CAPTION, 'Select product', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK);
}

function taxproductquickchargemagic() {
  var str = document.getElementById('charge_storage').value;
  if (str.length){str += ';';}
  str += 'magic=taxproductnum;taxproductnum=';
  str += escape(document.getElementById('taxproductnum').value);
  cClick();
  overlib( OLiframeContent('<% $p %>/edit/quick-charge.html?'+str, 545, 336, 'One-time charge'), CAPTION, 'One-time charge', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '#333399', CGCOLOR, '#333399', CLOSETEXT, <% mt('Close') |js_string %>);

}

function taxoverridemagic(which) {
  var str = '';
  var elements = which.ownerDocument.QuickChargeForm.elements;
  for (var i = 0; i<elements.length; i++) {
    if (elements[i].name == 'tax_override'){
      document.getElementById('tax_override').value = elements[i].value;
      continue;
    }
    if (str.length){str += ';';}
    str += elements[i].name + '=' + escape(elements[i].value);
  }
  document.getElementById('charge_storage').value = str;
  cClick();
  overlib( OLiframeContent('<% $p %>/edit/part_pkg_taxoverride.html?element_name=tax_override;onclick=taxoverridequickchargemagic;selected='+document.getElementById('tax_override').value, 1100, 600, 'tax_product_popup'), CAPTION, 'Edit product tax overrides', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK);
}

function taxoverridequickchargemagic() {
  var str = document.getElementById('charge_storage').value;
  if (str.length){str += ';';}
  str += 'magic=taxoverride;tax_override=';
  str += document.getElementById('tax_override').value;
  cClick();
  overlib( OLiframeContent('<% $p %>/edit/quick-charge.html?'+str, 545, 336, 'One-time charge'), CAPTION, 'One-time charge', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '#333399', CGCOLOR, '#333399', CLOSETEXT, <% mt('Close') |js_string %>);

}

</SCRIPT>
% }
%
% unless ( $opt{no_form} ) {
<FORM NAME='quickcharge' STYLE="margin:0; padding:0; display:inline">
% for (qw(
%   taxproductnum tax_override charge_storage taxproductnum_description
% )) {
    <INPUT NAME="<% $_ %>" ID="<% $_ %>" TYPE="hidden">
% }
</FORM>
% }
%
% unless ( $opt{form_only} ) {
<& /elements/popup_link.html,
     'action'      => $p. 'edit/quick-charge.html?'. $query,
     'label'       => emt('One-time charge'),
     'actionlabel' => emt('One-time charge'),
     'color'       => '#333399',
     'width'       => 763,
     'height'      => 460, #more for more room for lines of add'l description?
&>
% }
%
<%init>

my %opt = @_;

my $query = $opt{custnum} ? 'custnum='.$opt{custnum}
                          : 'prospectnum='.$opt{prospectnum};
$query .= ';quotationnum='.$opt{quotationnum} if $opt{quotationnum};

</%init>