summaryrefslogtreecommitdiff
path: root/httemplate/elements/did_order_item.html
blob: d1f90f33898c720d2e75fa5ed28aee285dfba4fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
% unless ( $opt{'js_only'} ) {

  <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">

  <TABLE>
    <TR>
%     my $value = '';

%     $value = $item->get('quantity');
      <TD>
          <INPUT TYPE  = "text"
                 NAME  = "<%$name%>_quantity"
                 ID    = "<%$id%>_quantity"
                 SIZE  = "3"
                 VALUE = "<% scalar($cgi->param($name."_quantity"))
                             || $value |h %>"
                 <% $onchange %>
          >
          <BR><FONT SIZE="-1">Quantity</FONT>
      </TD>
      
%     $value = $item->get('npa');
      <TD>
          <INPUT TYPE  = "text"
                 NAME  = "<%$name%>_npa"
                 ID    = "<%$id%>_npa"
                 SIZE  = "3"
                 VALUE = "<% scalar($cgi->param($name."_npa"))
                             || $value |h %>"
                 <% $onchange %>
          >
          <BR><FONT SIZE="-1">NPA</FONT>
      </TD>

%     $value = $item->get('ratecenternum');
      <TD>
        <% include('/elements/select-table.html',
                         'name_col'      => 'description',
                         'table'         => 'rate_center',
                         'disable_empty' => 0,
                         'empty_label'   => ' ',
                         'field'         => "${name}_ratecenternum",
                         'id'            => "${id}_ratecenternum",
                         'curr_value'    => scalar($cgi->param("${name}_ratecenternum"))
                                             || $value,
                         'post_options'  => [ 0 => 'Add new...' ],
                         onchange        => 'ratecenter_changed',
                  )
         %>
        <BR><FONT SIZE="-1">Rate Center</FONT>
        <div style="display:none; font-size: 80%" id="<%$id%>_rc_div">
             - add new: <INPUT TYPE  = "text"
                 NAME  = "<%$name%>_rc_new"
                 ID    = "<%$id%>_rc_new">
        </div>
      </TD>

%     $value = $item->get('msanum');
      <TD>
        <% include('/elements/select-table.html',
                         'name_col'      => 'description',
                         'table'         => 'msa',
                         'disable_empty' => 0,
                         'empty_label'   => ' ',
                         'field'         => "${name}_msanum",
                         'curr_value'    => scalar($cgi->param("${name}_msanum"))
                                             || $value,
                   )
         %>
        <BR><FONT SIZE="-1">MSA</FONT>
      </TD>

%     $value = $item->get('latanum');
      <TD><% include('/elements/select-table.html',
                         'name_col'      => 'description',
                         'table'         => 'lata',
                         'disable_empty' => 0,
                         'empty_label'   => ' ',
                         'label_showkey' => 1,
                         'field'         => "${name}_latanum",
                         'curr_value'    => scalar($cgi->param("${name}_latanum"))
                                             || $value,
                     )
            %>
        <BR><FONT SIZE="-1">LATA #</FONT>
      </TD>

%     $value = $item->get('state');
      <TD><% include('/elements/select-state.html',
                         'disable_empty' => 0,
                         'empty_label'   => ' ',
                         'country'       => 'US',
                         'prefix'        => "${name}_",
                         'state'         => scalar($cgi->param("${name}_state"))
                                            || $value,
                     )
            %>
          <BR><FONT SIZE="-1">State</FONT>
      </TD>

%     $value = $item->get('custnum');
      <TD><INPUT TYPE  = "text"
                 NAME  = "<%$name%>_custnum"
                 ID    = "<%$id%>_custnum"
                 SIZE  = "7"
                 VALUE = "<% scalar($cgi->param($name."_custnum"))
                             || $value |h %>"
                 <% $onchange %>
          >
          <BR><FONT SIZE="-1">Customer #</FONT>
      </TD>

    </TR>
  </TABLE>

% }
<%init>

my( %opt ) = @_;

my $name = $opt{'element_name'} || $opt{'field'} || 'orderitemnum';
my $id = $opt{'id'} || 'orderitemnum';

my $curr_value = $opt{'curr_value'} || $opt{'value'};

my $onchange = '';
if ( $opt{'onchange'} ) {
  $onchange = $opt{'onchange'};
  $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
  $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack.  all onchange
                                        #callbacks should act the same
 $onchange = 'onChange="'. $onchange. '"';
}

my $item;
if ( $curr_value ) {
  $item = qsearchs('did_order_item', { 'orderitemnum' => $curr_value } );
} else {
  $item = new FS::did_order_item {};
}

</%init>