stray closing /TABLE in the no-ticket case
[freeside.git] / httemplate / elements / did_order_item.html
1 % unless ( $opt{'js_only'} ) {
2
3   <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
4
5   <TABLE>
6     <TR>
7 %     my $value = '';
8
9 %     $value = $item->get('quantity');
10       <TD>
11           <INPUT TYPE  = "text"
12                  NAME  = "<%$name%>_quantity"
13                  ID    = "<%$id%>_quantity"
14                  SIZE  = "3"
15                  VALUE = "<% scalar($cgi->param($name."_quantity"))
16                              || $value |h %>"
17                  <% $onchange %>
18           >
19           <BR><FONT SIZE="-1">Quantity</FONT>
20       </TD>
21       
22 %     $value = $item->get('npa');
23       <TD>
24           <INPUT TYPE  = "text"
25                  NAME  = "<%$name%>_npa"
26                  ID    = "<%$id%>_npa"
27                  SIZE  = "3"
28                  VALUE = "<% scalar($cgi->param($name."_npa"))
29                              || $value |h %>"
30                  <% $onchange %>
31           >
32           <BR><FONT SIZE="-1">NPA</FONT>
33       </TD>
34
35 %     $value = $item->get('ratecenternum');
36       <TD>
37         <% include('/elements/select-table.html',
38                          'name_col'      => 'description',
39                          'table'         => 'rate_center',
40                          'disable_empty' => 0,
41                          'empty_label'   => ' ',
42                          'field'         => "${name}_ratecenternum",
43                          'id'            => "${id}_ratecenternum",
44                          'curr_value'    => scalar($cgi->param("${name}_ratecenternum"))
45                                              || $value,
46                          'post_options'  => [ 0 => 'Add new...' ],
47                          onchange        => 'ratecenter_changed',
48                   )
49          %>
50         <BR><FONT SIZE="-1">Rate Center</FONT>
51         <div style="display:none; font-size: 80%" id="<%$id%>_rc_div">
52              - add new: <INPUT TYPE  = "text"
53                  NAME  = "<%$name%>_rc_new"
54                  ID    = "<%$id%>_rc_new">
55         </div>
56       </TD>
57
58 %     $value = $item->get('msanum');
59       <TD>
60         <% include('/elements/select-table.html',
61                          'name_col'      => 'description',
62                          'table'         => 'msa',
63                          'disable_empty' => 0,
64                          'empty_label'   => ' ',
65                          'field'         => "${name}_msanum",
66                          'curr_value'    => scalar($cgi->param("${name}_msanum"))
67                                              || $value,
68                    )
69          %>
70         <BR><FONT SIZE="-1">MSA</FONT>
71       </TD>
72
73 %     $value = $item->get('latanum');
74       <TD><% include('/elements/select-table.html',
75                          'name_col'      => 'description',
76                          'table'         => 'lata',
77                          'disable_empty' => 0,
78                          'empty_label'   => ' ',
79                          'label_showkey' => 1,
80                          'field'         => "${name}_latanum",
81                          'curr_value'    => scalar($cgi->param("${name}_latanum"))
82                                              || $value,
83                      )
84             %>
85         <BR><FONT SIZE="-1">LATA #</FONT>
86       </TD>
87
88 %     $value = $item->get('state');
89       <TD><% include('/elements/select-state.html',
90                          'disable_empty' => 0,
91                          'empty_label'   => ' ',
92                          'country'       => 'US',
93                          'prefix'        => "${name}_",
94                          'state'         => scalar($cgi->param("${name}_state"))
95                                             || $value,
96                      )
97             %>
98           <BR><FONT SIZE="-1">State</FONT>
99       </TD>
100
101 %     $value = $item->get('custnum');
102       <TD><INPUT TYPE  = "text"
103                  NAME  = "<%$name%>_custnum"
104                  ID    = "<%$id%>_custnum"
105                  SIZE  = "7"
106                  VALUE = "<% scalar($cgi->param($name."_custnum"))
107                              || $value |h %>"
108                  <% $onchange %>
109           >
110           <BR><FONT SIZE="-1">Customer #</FONT>
111       </TD>
112
113     </TR>
114   </TABLE>
115
116 % }
117 <%init>
118
119 my( %opt ) = @_;
120
121 my $name = $opt{'element_name'} || $opt{'field'} || 'orderitemnum';
122 my $id = $opt{'id'} || 'orderitemnum';
123
124 my $curr_value = $opt{'curr_value'} || $opt{'value'};
125
126 my $onchange = '';
127 if ( $opt{'onchange'} ) {
128   $onchange = $opt{'onchange'};
129   $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
130   $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack.  all onchange
131                                         #callbacks should act the same
132  $onchange = 'onChange="'. $onchange. '"';
133 }
134
135 my $item;
136 if ( $curr_value ) {
137   $item = qsearchs('did_order_item', { 'orderitemnum' => $curr_value } );
138 } else {
139   $item = new FS::did_order_item {};
140 }
141
142 </%init>