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