Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / misc / order_pkg.html
1 <& /elements/header-popup.html, $quotationnum ? mt('Add package to quotation')
2                                               : mt('Order new package')
3 &>
4
5 <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
6 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
7 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
8 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
9
10 <SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
11
12 <& /elements/error.html &>
13
14 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
15
16 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main ? $cust_main->custnum : '' %>">
17 <INPUT TYPE="hidden" NAME="prospectnum" VALUE="<% $prospect_main ? $prospect_main->prospectnum : '' %>">
18 <INPUT TYPE="hidden" NAME="qualnum" VALUE="<% scalar($cgi->param('qualnum')) |h %>">
19 <INPUT TYPE="hidden" NAME="quotationnum" VALUE="<% $quotationnum %>">
20 % if ( $svcpart ) {
21     <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
22 % }
23
24 <% ntable("#cccccc", 2) %>
25 % if ( $part_pkg ) {
26     <INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $part_pkg->pkgpart %>">
27     <TR>
28       <TH ALIGN="right"><% mt('Package') |h %></TH>
29       <TD COLSPAN=6><% $part_pkg->pkg_comment |h %></TD>
30     </TR>
31 % } else {
32     <& /elements/tr-select-cust-part_pkg.html,
33                  'curr_value'    => $pkgpart,
34                  'classnum'      => -1,
35                  'cust_main'     => $cust_main,
36                  'prospect_main' => $prospect_main,
37     &>
38 % }
39
40 % if ( $conf->exists('invoice-unitprice') ) {
41     <TR>
42       <TH ALIGN="right"><% mt('Quantity') |h %> </TD>
43       <TD>
44         <INPUT TYPE="text" NAME="quantity" SIZE=4 VALUE="<% $quantity %>">
45       </TD>
46     </TR>
47 % } else {
48     <INPUT TYPE="hidden" NAME="quantity" VALUE="1">
49 % }
50
51 <TR>
52   <TH ALIGN="right"><% mt('Start date') |h %> </TD>
53   <TD COLSPAN=6>
54     <& /elements/input-date-field.html,{
55                 'name'      => 'start_date',
56                 'format'    => $date_format,
57                 'value'     => $start_date,
58                 'noinit'    => 1,
59               } &>
60     <FONT SIZE=-1>(<% mt('leave blank to start immediately') |h %>)</FONT>
61   </TD>
62 </TR>
63
64 % if ( $cust_main && $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
65 %   my $what = lc(FS::payby->shortname($cust_main->payby));
66     <TR>
67       <TH ALIGN="right"><% mt("Disable automatic $what charge") |h %> </TH>
68       <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
69     </TR>
70 % }
71
72 % if ( $curuser->access_right('Discount customer package') ) {
73   <& /elements/tr-select-discount.html,
74                'element_etc' => 'DISABLED',
75                'colspan'     => 7,
76                'cgi'         => $cgi,
77   &>
78 % }
79
80 % if ( $curuser->access_right('Waive setup fee') ) {
81     <TR>
82       <TH ALIGN="right"><% mt('Waive setup fee') |h %> </TH>
83       <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="waive_setup" VALUE="Y"></TD>
84     </TR>
85 % }
86
87 % if ( $conf->exists('pkg_referral') ) {
88   <& /elements/tr-select-part_referral.html,
89                'curr_value'    => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum,
90                'disable_empty' => 1,
91                'multiple'      => $conf->exists('pkg_referral-multiple'),
92                'colspan'       => 7,
93   &>
94 % }
95
96 % if ( $cgi->param('lock_locationnum') ) {
97
98     <INPUT TYPE  = "hidden"
99            NAME  = "locationnum"
100            ID    = "locationnum"
101            VALUE = "<% scalar($cgi->param('lock_locationnum')) |h %>"
102     >
103
104 % } else {
105
106     <& /elements/tr-select-cust_location.html,
107                  'cgi'           => $cgi,
108                  'cust_main'     => $cust_main,
109                  'prospect_main' => $prospect_main,
110     &>
111
112 % }
113
114 <TR>
115   <TH ALIGN="right"><% mt('Contract end date') |h %> </TD>
116   <TD COLSPAN=6>
117     <& /elements/input-date-field.html,{
118                 'name'      => 'contract_end',
119                 'format'    => $date_format,
120                 'value'     => '',
121                 'noinit'    => 1,
122                 } &>
123   </TD>
124 </TR>
125
126 </TABLE>
127
128 % unless ( $cgi->param('lock_locationnum') ) {
129
130   <& /elements/standardize_locations.html,
131                 'form'       => "OrderPkgForm",
132                 'onlyship'   => 1,
133                 'no_company' => 1,
134                 'callback'   => 'document.OrderPkgForm.submit();',
135   &>
136
137 % }
138
139 <BR>
140 % my $onclick = $cgi->param('lock_locationnum')
141 %                 ? 'document.OrderPkgForm.submit()'
142 %                 : 'standardize_new_location()';
143 <INPUT NAME    = "submitButton"
144        TYPE    = "button"
145        VALUE   = "<% mt("Order Package") |h %>"
146        onClick = "this.disabled=true; <% $onclick %>;"
147        <% $pkgpart ? '' : 'DISABLED' %>
148 >
149
150 </FORM>
151 </BODY>
152 </HTML>
153 <%init>
154
155 my $curuser = $FS::CurrentUser::CurrentUser;
156
157 die "access denied"
158   unless $curuser->access_right('Order customer package');
159
160 my $conf = new FS::Conf;
161 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
162
163 my $cust_main = '';
164 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
165   my $custnum = $1;
166   $cust_main = qsearchs({
167     'table'     => 'cust_main',
168     'hashref'   => { 'custnum' => $custnum },
169     'extra_sql' => ' AND '. $curuser->agentnums_sql,
170   });
171 }
172
173 my $prospect_main = '';
174 if ( $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
175   my $prospectnum = $1;
176   $prospect_main = qsearchs({
177     'table'     => 'prospect_main',
178     'hashref'   => { 'prospectnum' => $prospectnum },
179     'extra_sql' => ' AND '. $curuser->agentnums_sql,
180   });
181 }
182
183 my $quotationnum = '';
184 if ( $cgi->param('quotationnum') =~ /^(\d+)$/ ) {
185   $quotationnum = $1;
186 }
187
188 die 'no custnum or prospectnum' unless $cust_main || $prospect_main;
189
190 my $part_pkg = '';
191 if ( $cgi->param('lock_pkgpart') ) {
192   $part_pkg = qsearchs({
193     'table'     => 'part_pkg',
194     'hashref'   => { 'pkgpart' => scalar($cgi->param('lock_pkgpart')) },
195     'extra_sql' => ' AND '. FS::part_pkg->agent_pkgs_sql(
196                               $cust_main ? $cust_main->agent
197                                          : $prospect_main->agent
198                             ),
199   })
200     or die "unknown pkgpart ". $cgi->param('lock_pkgpart');
201 }
202
203 my $pkgpart = $part_pkg ? $part_pkg->pkgpart : scalar($cgi->param('pkgpart'));
204
205 my $quantity = 1;
206 if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
207   $quantity = $1;
208 }
209
210 my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
211 my $start_date = '';
212 if( ! $conf->exists('order_pkg-no_start_date') && $cust_main ) {
213   $start_date = $cust_main->next_bill_date;
214   $start_date = $start_date ? time2str($format, $start_date) : '';
215 }
216
217 my $svcpart = scalar($cgi->param('svcpart'));
218
219 </%init>