NG auth: autocreate records for external users, RT#21563
[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                 '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>