quotations, RT#16996
[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 % }
48
49 <TR>
50   <TH ALIGN="right"><% mt('Start date') |h %> </TD>
51   <TD COLSPAN=6>
52     <& /elements/input-date-field.html,{
53                 'name'      => 'start_date',
54                 'format'    => $date_format,
55                 'value'     => $start_date,
56                 'noinit'    => 1,
57               } &>
58     <FONT SIZE=-1>(<% mt('leave blank to start immediately') |h %>)</FONT>
59   </TD>
60 </TR>
61
62 % if ( $cust_main && $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
63 %   my $what = lc(FS::payby->shortname($cust_main->payby));
64     <TR>
65       <TH ALIGN="right"><% mt("Disable automatic $what charge") |h %> </TH>
66       <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
67     </TR>
68 % }
69
70 % if ( $curuser->access_right('Discount customer package') ) {
71   <& /elements/tr-select-discount.html,
72                'element_etc' => 'DISABLED',
73                'colspan'     => 7,
74                'cgi'         => $cgi,
75   &>
76 % }
77
78 % if ( $curuser->access_right('Waive setup fee') ) {
79     <TR>
80       <TH ALIGN="right"><% mt('Waive setup fee') |h %> </TH>
81       <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="waive_setup" VALUE="Y"></TD>
82     </TR>
83 % }
84
85 % if ( $conf->exists('pkg_referral') ) {
86   <& /elements/tr-select-part_referral.html,
87                'curr_value'    => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum,
88                'disable_empty' => 1,
89                'multiple'      => $conf->exists('pkg_referral-multiple'),
90                'colspan'       => 7,
91   &>
92 % }
93
94 % if ( $cgi->param('lock_locationnum') ) {
95
96     <INPUT TYPE  = "hidden"
97            NAME  = "locationnum"
98            ID    = "locationnum"
99            VALUE = "<% scalar($cgi->param('lock_locationnum')) |h %>"
100     >
101
102 % } else {
103
104     <& /elements/tr-select-cust_location.html,
105                  'cgi'           => $cgi,
106                  'cust_main'     => $cust_main,
107                  'prospect_main' => $prospect_main,
108     &>
109
110 % }
111
112 <TR>
113   <TH ALIGN="right"><% mt('Contract end date') |h %> </TD>
114   <TD COLSPAN=6>
115     <& /elements/input-date-field.html,{
116                 'name'      => 'contract_end',
117                 'format'    => $date_format,
118                 'value'     => '',
119                 'noinit'    => 1,
120                 } &>
121   </TD>
122 </TR>
123
124 </TABLE>
125
126 % unless ( $cgi->param('lock_locationnum') ) {
127
128   <& /elements/standardize_locations.html,
129                 'form'       => "OrderPkgForm",
130                 'onlyship'   => 1,
131                 'no_company' => 1,
132                 'callback'   => 'document.OrderPkgForm.submit();',
133   &>
134
135 % }
136
137 <BR>
138 % my $onclick = $cgi->param('lock_locationnum')
139 %                 ? 'document.OrderPkgForm.submit()'
140 %                 : 'standardize_new_location()';
141 <INPUT NAME    = "submitButton"
142        TYPE    = "button"
143        VALUE   = "<% mt("Order Package") |h %>"
144        onClick = "this.disabled=true; <% $onclick %>;"
145        <% $pkgpart ? '' : 'DISABLED' %>
146 >
147
148 </FORM>
149 </BODY>
150 </HTML>
151 <%init>
152
153 my $curuser = $FS::CurrentUser::CurrentUser;
154
155 die "access denied"
156   unless $curuser->access_right('Order customer package');
157
158 my $conf = new FS::Conf;
159 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
160
161 my $cust_main = '';
162 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
163   my $custnum = $1;
164   $cust_main = qsearchs({
165     'table'     => 'cust_main',
166     'hashref'   => { 'custnum' => $custnum },
167     'extra_sql' => ' AND '. $curuser->agentnums_sql,
168   });
169 }
170
171 my $prospect_main = '';
172 if ( $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
173   my $prospectnum = $1;
174   $prospect_main = qsearchs({
175     'table'     => 'prospect_main',
176     'hashref'   => { 'prospectnum' => $prospectnum },
177     'extra_sql' => ' AND '. $curuser->agentnums_sql,
178   });
179 }
180
181 my $quotationnum = '';
182 if ( $cgi->param('quotationnum') =~ /^(\d+)$/ ) {
183   $quotationnum = $1;
184 }
185
186 die 'no custnum or prospectnum' unless $cust_main || $prospect_main;
187
188 my $part_pkg = '';
189 if ( $cgi->param('lock_pkgpart') ) {
190   $part_pkg = qsearchs({
191     'table'     => 'part_pkg',
192     'hashref'   => { 'pkgpart' => scalar($cgi->param('lock_pkgpart')) },
193     'extra_sql' => ' AND '. FS::part_pkg->agent_pkgs_sql(
194                               $cust_main ? $cust_main->agent
195                                          : $prospect_main->agent
196                             ),
197   })
198     or die "unknown pkgpart ". $cgi->param('lock_pkgpart');
199 }
200
201 my $pkgpart = $part_pkg ? $part_pkg->pkgpart : scalar($cgi->param('pkgpart'));
202
203 my $quantity = 1;
204 if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
205   $quantity = $1;
206 }
207
208 my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
209 my $start_date = '';
210 if( ! $conf->exists('order_pkg-no_start_date') && $cust_main ) {
211   $start_date = $cust_main->next_bill_date;
212   $start_date = $start_date ? time2str($format, $start_date) : '';
213 }
214
215 my $svcpart = scalar($cgi->param('svcpart'));
216
217 </%init>