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