1 <% include( 'elements/edit.html',
3 { field => 'vendornum',
4 type => 'select-table',
5 name_col => 'vendorname',
9 { field => 'vendor_order_id',
12 { field => 'confirmed',
15 { field => 'received',
18 { field => 'submitted',
21 { field => 'stock_or_customer',
23 options => [ 'Stock', 'Customer', ],
24 onchange => 'stockcust_changed',
25 curr_value_callback => $stock_or_customer,
28 type => 'search-cust_main',
30 { type => 'tablebreak-tr-title',
31 value => 'Order Items',
33 { 'field' => 'orderitemnum',
34 'type' => 'did_order_item',
35 'o2m_table' => 'did_order_item',
37 'm2_error_callback' => $m2_error_callback,
41 'ordernum' => 'Order',
42 'vendornum' => 'Vendor',
43 'vendor_order_id' => 'Vendor Order #',
45 'confirmed' => 'Confirmation Date',
46 'orderitemnum' => 'Item',
48 'viewall_dir' => 'browse',
49 'table' => 'did_order',
50 'name' => 'Bulk DID Order',
51 'field_callback' => $field_callback,
52 'html_bottom' => $javascript,
53 'body_etc' => 'onLoad="stockcust_changed()"',
59 unless $FS::CurrentUser::CurrentUser->access_right('Import');
61 my $field_callback = sub {
62 my ($cgi, $object, $field_hashref ) = @_;
63 if ($object->ordernum) {
64 $field_hashref->{type} = 'text'
65 if $field_hashref->{field} eq 'vendor_order_id';
66 $field_hashref->{type} = 'input-date-field'
67 if $field_hashref->{field} eq 'confirmed';
71 my $m2_error_callback = sub {
72 my($cgi, $object) = @_;
74 #process_o2m fields in process/did_order.html
75 my @fields = qw( msanum npa latanum ratecenternum state quantity );
76 my @gfields = ( '', map "_$_", @fields );
79 if ( /^orderitemnum(\d+)$/ ) {
81 if ( grep $cgi->param("orderitemnum$num$_"), @gfields ) {
82 my $x = new FS::did_order_item {
83 'orderitemnum' => scalar($cgi->param("orderitemnum$num")),
84 map { $_ => scalar($cgi->param("orderitemnum${num}_$_")) } @fields,
97 my $stock_or_customer = sub{
98 my($cgi,$object,$field) = @_;
99 return 'Customer' if $object->custnum;
103 my $javascript = <<END;
104 <SCRIPT TYPE="text/javascript">
105 function stockcust_changed() {
106 var f = document.edit_topform;
107 var custnum = f.custnum;
108 var custnum_search = f.custnum_search;
109 var custnum_select = f.custnum_select;
110 if ( f.stock_or_customer_Stock.checked ) {
111 custnum_search.disabled = true;
112 custnum_select.disabled = true;
115 else if ( f.stock_or_customer_Customer.checked ) {
116 custnum_search.disabled = false;
117 custnum_select.disabled = false;
121 /* o2m or something else is broken, can't put this in the actual
122 component because random JS and other crap is rendered
123 onto the final output page */
124 function ratecenter_changed(rc) {
125 var idbase = rc.id.substring(0,rc.id.indexOf('_'));
126 var div = document.getElementById(idbase+'_rc_div');
127 var input = document.getElementById(idbase+'_rc_new');
128 if(rc.options[rc.selectedIndex].value == '0') {
129 div.style.display = 'inline';
132 div.style.display = 'none';