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