1 # #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger, Accounting
9 # Copyright (c) 1998-2003
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
32 #======================================================================
40 require "$form->{path}/io.pl";
41 require "$form->{path}/arap.pl";
48 $lxdebug->enter_sub();
50 if ($form->{type} eq 'purchase_order') {
51 $form->{title} = $locale->text('Add Purchase Order');
52 $form->{vc} = 'vendor';
54 if ($form->{type} eq 'sales_order') {
55 $form->{title} = $locale->text('Add Sales Order');
56 $form->{vc} = 'customer';
58 if ($form->{type} eq 'request_quotation') {
59 $form->{title} = $locale->text('Add Request for Quotation');
60 $form->{vc} = 'vendor';
62 if ($form->{type} eq 'sales_quotation') {
63 $form->{title} = $locale->text('Add Quotation');
64 $form->{vc} = 'customer';
68 "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&password=$form->{password}"
69 unless $form->{callback};
75 $lxdebug->leave_sub();
79 $lxdebug->enter_sub();
81 # editing without stuff to edit? try adding it first
82 if ($form->{rowcount}) {
83 map { $id++ if $form->{"id_$_"} } (1 .. $form->{rowcount});
87 undef $form->{rowcount};
98 if ($form->{print_and_save}) {
99 $form->{action} = "print";
100 $form->{resubmit} = 1;
101 $language_id = $form->{language_id};
102 $printer_id = $form->{printer_id};
105 if ($form->{type} eq 'purchase_order') {
106 $form->{title} = $locale->text('Edit Purchase Order');
107 $form->{heading} = $locale->text('Purchase Order');
108 $form->{vc} = 'vendor';
110 if ($form->{type} eq 'sales_order') {
111 $form->{title} = $locale->text('Edit Sales Order');
112 $form->{heading} = $locale->text('Sales Order');
113 $form->{vc} = 'customer';
115 if ($form->{type} eq 'request_quotation') {
116 $form->{title} = $locale->text('Edit Request for Quotation');
117 $form->{heading} = $locale->text('Request for Quotation');
118 $form->{vc} = 'vendor';
120 if ($form->{type} eq 'sales_quotation') {
121 $form->{title} = $locale->text('Edit Quotation');
122 $form->{heading} = $locale->text('Quotation');
123 $form->{vc} = 'customer';
128 if ($form->{print_and_save}) {
129 $form->{language_id} = $language_id;
130 $form->{printer_id} = $printer_id;
134 $lxdebug->leave_sub();
138 $lxdebug->enter_sub();
140 # get customer/vendor
141 $form->all_vc(\%myconfig, $form->{vc},
142 ($form->{vc} eq 'customer') ? "AR" : "AP");
144 # retrieve order/quotation
145 $form->{webdav} = $webdav;
147 $form->{jscalendar} = $jscalendar;
149 OE->retrieve(\%myconfig, \%$form);
151 if ($form->{payment_id}) {
152 $payment_id = $form->{payment_id};
154 if ($form->{language_id}) {
155 $language_id = $form->{language_id};
157 if ($form->{taxzone_id}) {
158 $taxzone_id = $form->{taxzone_id};
162 # if multiple rowcounts (== collective order) then check if the
163 # there were more than one customer (in that case OE::retrieve removes
164 # the content from the field)
165 if ( $form->{rowcount}
166 && $form->{type} eq 'sales_order'
167 && defined $form->{customer}
168 && $form->{customer} eq '') {
170 # $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
173 'Collective Orders only work for orders from one customer!')
177 $taxincluded = $form->{taxincluded};
178 $form->{shipto} = 1 if $form->{id};
180 if ($form->{"all_$form->{vc}"}) {
181 unless ($form->{"$form->{vc}_id"}) {
182 $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
186 $cp_id = $form->{cp_id};
187 $intnotes = $form->{intnotes};
189 # get customer / vendor
190 if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/) {
191 IR->get_vendor(\%myconfig, \%$form);
193 #quote all_vendor Bug 133
194 foreach $ref (@{ $form->{all_vendor} }) {
195 $ref->{name} = $form->quote($ref->{name});
199 if ($form->{type} =~ /(sales|ship)_(order|quotation)/) {
200 IS->get_customer(\%myconfig, \%$form);
202 #quote all_vendor Bug 133
203 foreach $ref (@{ $form->{all_customer} }) {
204 $ref->{name} = $form->quote($ref->{name});
208 $form->{cp_id} = $cp_id;
210 $form->{payment_id} = $payment_id;
213 $form->{language_id} = $language_id;
216 $form->{taxzone_id} = $taxzone_id;
218 $form->{intnotes} = $intnotes;
219 ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
220 $form->{"old$form->{vc}"} =
221 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
223 # build the popup menus
224 if (@{ $form->{"all_$form->{vc}"} }) {
225 $form->{ $form->{vc} } =
226 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
227 map { $form->{"select$form->{vc}"} .= "<option>$_->{name}--$_->{id}\n" }
228 (@{ $form->{"all_$form->{vc}"} });
232 @curr = split /:/, $form->{currencies};
234 $form->{defaultcurrency} = $curr[0];
235 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
237 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
239 $form->{taxincluded} = $taxincluded if ($form->{id});
242 if (@{ $form->{all_departments} }) {
243 $form->{selectdepartment} = "<option>\n";
244 $form->{department} = "$form->{department}--$form->{department_id}";
247 $form->{selectdepartment} .=
248 "<option>$_->{description}--$_->{id}\n"
249 } (@{ $form->{all_departments} });
252 $form->{employee} = "$form->{employee}--$form->{employee_id}";
255 if (@{ $form->{all_employees} }) {
256 $form->{selectemployee} = "";
257 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
258 (@{ $form->{all_employees} });
262 $form->{forex} = $form->{exchangerate};
264 $lxdebug->leave_sub();
268 $lxdebug->enter_sub();
269 $form->{format} = "pdf";
270 $form->{media} = "screen";
271 $form->{formname} = $form->{type} unless $form->{formname};
273 map { $form->{$_} =~ s/\"/"/g }
274 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
276 foreach $ref (@{ $form->{form_details} }) {
277 $form->{rowcount} = ++$i;
279 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
281 for my $i (1 .. $form->{rowcount}) {
283 $form->{"discount_$i"} =
284 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
286 $form->{"discount_$i"} =
287 $form->format_amount(\%myconfig, $form->{"discount_$i"});
289 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
291 $decimalplaces = ($dec > 2) ? $dec : 2;
293 # copy reqdate from deliverydate for invoice -> order conversion
294 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
295 unless $form->{"reqdate_$i"};
297 $form->{"sellprice_$i"} =
298 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
301 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
302 $dec_qty = length $dec_qty;
304 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
306 map { $form->{"${_}_$i"} =~ s/\"/"/g }
307 qw(partnumber description unit);
310 $lxdebug->leave_sub();
314 $lxdebug->enter_sub();
316 $checkedopen = ($form->{closed}) ? "" : "checked";
317 $checkedclosed = ($form->{closed}) ? "checked" : "";
319 # use JavaScript Calendar or not
320 $form->{jsscript} = $form->{jscalendar};
323 $payment = qq|<option value=""></option>|;
324 foreach $item (@{ $form->{payment_terms} }) {
325 if ($form->{payment_id} eq $item->{id}) {
326 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
328 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
331 if ($form->{jsscript}) {
333 # with JavaScript Calendar
335 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
336 <td><input type=button name=transdate id="trigger1" value=|
337 . $locale->text('button') . qq|></td>
340 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
341 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
342 . $locale->text('button') . qq|></td>
347 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
348 "reqdate", "BL", "trigger2");
352 # without JavaScript Calendar
354 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
356 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
362 <td colspan=2 align=center>
365 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
366 . $locale->text('Open') . qq|</th>
367 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
368 . $locale->text('Closed') . qq|</th>
376 # set option selected
377 foreach $item ($form->{vc}, currency, department, employee) {
378 $form->{"select$item"} =~ s/ selected//;
379 $form->{"select$item"} =~
380 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
383 #quote select[customer|vendor] Bug 133
384 $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
387 if ($form->{all_contacts}) {
389 $form->{selectcontact} = "<option></option>";
390 foreach $item (@{ $form->{all_contacts} }) {
391 my $department = ($item->{cp_abteilung}) ? "--$item->{cp_abteilung}" : "";
392 if ($form->{cp_id} == $item->{cp_id}) {
393 $form->{selectcontact} .=
394 "<option value=$item->{cp_id} selected>$item->{cp_name}$department</option>";
396 $form->{selectcontact} .= "<option value=$item->{cp_id}>$item->{cp_name}$department</option>";
400 $form->{selectcontact} =~ s/ selected//g;
401 if ($form->{cp_id} ne "") {
402 $form->{selectcontact} =~ s/value=$form->{cp_id}/value=$form->{cp_id} selected/;
407 if (@{ $form->{SHIPTO} }) {
408 $form->{selectshipto} = "<option value=0></option>";
409 foreach $item (@{ $form->{SHIPTO} }) {
410 if ($item->{id} == $form->{shipto_id}) {
411 $form->{selectshipto} .=
412 "<option value=$item->{id} selected>$item->{shiptoname}</option>";
414 $form->{selectshipto} .=
415 "<option value=$item->{id}>$item->{shiptoname}</option>";
420 $form->{selectshipto} =~ s/ selected//g;
421 if ($form->{shipto_id} ne "") {
422 $form->{selectshipto} =~ s/value=$form->{shipto_id}/value=$form->{shipto_id} selected/;
427 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
428 <td><select name=shipto_id>$form->{selectshipto}</select></td>
429 <input type=hidden name=selectshipto value="$form->{selectshipto}">|;
434 $form->{exchangerate} =
435 $form->format_amount(\%myconfig, $form->{exchangerate});
437 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
443 $form->{creditlimit} =
444 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
445 $form->{creditremaining} =
446 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
449 ($form->{selectcontact})
450 ? qq|<select name=cp_id>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
451 : qq|<input name=contact value="$form->{contact}" size=35>|;
454 <input type=hidden name=forex value=$form->{forex}>
457 if ($form->{currency} ne $form->{defaultcurrency}) {
458 if ($form->{forex}) {
461 . $locale->text('Exchangerate')
462 . qq|</th><td>$form->{exchangerate}</td>
463 <input type=hidden name=exchangerate value=$form->{exchangerate}>
468 . $locale->text('Exchangerate')
469 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
473 $vclabel = ucfirst $form->{vc};
474 $vclabel = $locale->text($vclabel);
478 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
479 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
480 . $locale->text('days') . qq|</td>
484 if ($form->{business}) {
487 <th align=right>| . $locale->text('Business') . qq|</th>
488 <td>$form->{business}</td>
489 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
491 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
497 if ($form->{max_dunning_level}) {
503 <th align=right>| . $locale->text('Max. Dunning Level') . qq|:</th>
504 <td><b>$form->{max_dunning_level}</b></td>
505 <th align=right>| . $locale->text('Dunning Amount') . qq|:</th>
507 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
516 if (@{ $form->{TAXZONE} }) {
517 $form->{selecttaxzone} = "";
518 foreach $item (@{ $form->{TAXZONE} }) {
519 if ($item->{id} == $form->{taxzone_id}) {
520 $form->{selecttaxzone} .=
521 "<option value=$item->{id} selected>$item->{description}</option>";
523 $form->{selecttaxzone} .=
524 "<option value=$item->{id}>$item->{description}</option>";
529 $form->{selecttaxzone} =~ s/ selected//g;
530 if ($form->{taxzone_id} ne "") {
531 $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/;
535 if ($form->{rowcount} >0) {
536 $form->{selecttaxzone} =~ /<option value=\d+ selected>.*?<\/option>/;
537 $form->{selecttaxzone} = $&;
543 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
544 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
545 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
549 if ($form->{type} !~ /_quotation$/) {
552 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
553 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
556 <th width=70% align=right nowrap>|
557 . $locale->text('Quotation Number') . qq|</th>
558 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
561 <th width=70% align=right nowrap>|
562 . $locale->text('Customer Order Number') . qq|</th>
563 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
566 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
571 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
576 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
578 $creditremaining = qq|
584 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
585 <td>$form->{creditlimit}</td>
587 <th nowrap>| . $locale->text('Remaining') . qq|</th>
588 <td class="plus$n">$form->{creditremaining}</td>
597 ($form->{type} eq 'sales_quotation')
598 ? $locale->text('Valid until')
599 : $locale->text('Required by');
600 if ($form->{type} eq 'sales_quotation') {
603 <th width=70% align=right nowrap>|
604 . $locale->text('Quotation Number') . qq|</th>
605 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
606 <input type=hidden name=ordnumber value="$form->{ordnumber}">
612 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
613 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
614 <input type=hidden name=ordnumber value="$form->{ordnumber}">
623 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
627 <th align=right nowrap=true>$reqlabel</th>
631 $creditremaining = qq| <tr>
638 ($form->{"select$form->{vc}"})
639 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
640 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
644 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
645 <td colspan=3><select name=department>$form->{selectdepartment}</select>
646 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
649 | if $form->{selectdepartment};
652 <input type=hidden name=employee value="$form->{employee}">
655 if ($form->{type} eq 'sales_order') {
656 if ($form->{selectemployee}) {
658 <input type=hidden name=customer_klass value=$form->{customer_klass}>
660 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
661 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
662 <input type=hidden name=selectemployee value="$form->{selectemployee}">
669 <input type=hidden name=customer_klass value=$form->{customer_klass}>
671 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
672 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
673 <input type=hidden name=selectemployee value="$form->{selectemployee}">
678 if ($form->{resubmit} && ($form->{format} eq "html")) {
680 qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
681 } elsif ($form->{resubmit}) {
682 $onload = qq|document.oe.submit()|;
687 $credittext = $locale->text('Credit Limit exceeded!!!');
688 if ($creditwarning) {
689 $onload = qq|alert('$credittext')|;
695 <body onLoad="$onload">
697 <form method=post name=oe action=$form->{script}>
698 <script type="text/javascript" src="js/common.js"></script>
699 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
700 <script type="text/javascript" src="js/vendor_selection.js"></script>
701 <script type="text/javascript" src="js/calculate_qty.js"></script>
703 <input type=hidden name=id value=$form->{id}>
704 <input type=hidden name=action value=$form->{action}>
706 <input type=hidden name=type value=$form->{type}>
707 <input type=hidden name=formname value=$form->{formname}>
708 <input type=hidden name=media value=$form->{media}>
709 <input type=hidden name=format value=$form->{format}>
710 <input type=hidden name=proforma value=$form->{proforma}>
712 <input type=hidden name=queued value="$form->{queued}">
713 <input type=hidden name=printed value="$form->{printed}">
714 <input type=hidden name=emailed value="$form->{emailed}">
716 <input type=hidden name=vc value=$form->{vc}>
718 <input type=hidden name=title value="$form->{title}">
720 <input type=hidden name=discount value=$form->{discount}>
721 <input type=hidden name=creditlimit value=$form->{creditlimit}>
722 <input type=hidden name=creditremaining value=$form->{creditremaining}>
724 <input type=hidden name=tradediscount value=$form->{tradediscount}>
725 <input type=hidden name=business value=$form->{business}>
726 <input type=hidden name=webdav value=$webdav>
730 <th class=listtop>$form->{title}</th>
740 <th align=right>$vclabel</th>
741 <td colspan=3>$vc</td>
742 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
743 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
744 <th align=richt nowrap>|
745 . $locale->text('Contact Person') . qq|</th>
746 <td colspan=3>$contact</td>
754 <th align=right>| . $locale->text('Currency') . qq|</th>
755 <td><select name=currency>$form->{selectcurrency}</select></td>
756 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
757 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
761 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
762 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
765 <th align=right>| . $locale->text('Ship via') . qq|</th>
766 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
773 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
775 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
776 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
780 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
782 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
783 # <input size=45 id=vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
805 <!-- shipto are in hidden variables -->
807 <input type=hidden name=shiptoname value="$form->{shiptoname}">
808 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
809 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
810 <input type=hidden name=shiptocity value="$form->{shiptocity}">
811 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
812 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
813 <input type=hidden name=shiptophone value="$form->{shiptophone}">
814 <input type=hidden name=shiptofax value="$form->{shiptofax}">
815 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
817 <!-- email variables -->
818 <input type=hidden name=message value="$form->{message}">
819 <input type=hidden name=email value="$form->{email}">
820 <input type=hidden name=subject value="$form->{subject}">
821 <input type=hidden name=cc value="$form->{cc}">
822 <input type=hidden name=bcc value="$form->{bcc}">
824 <input type=hidden name=taxpart value="$form->{taxpart}">
825 <input type=hidden name=taxservice value="$form->{taxservice}">
827 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
830 foreach $item (split / /, $form->{taxaccounts}) {
832 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
833 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
836 $lxdebug->leave_sub();
840 $lxdebug->enter_sub();
842 $form->{invtotal} = $form->{invsubtotal};
844 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
847 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
850 $rows = ($rows > $introws) ? $rows : $introws;
852 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
854 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
856 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
859 if ($form->{taxaccounts}) {
861 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
862 . $locale->text('Tax Included') . qq|</b><br><br>
866 if (!$form->{taxincluded}) {
868 foreach $item (split / /, $form->{taxaccounts}) {
869 if ($form->{"${item}_base"}) {
870 $form->{invtotal} += $form->{"${item}_total"} =
872 $form->{"${item}_base"} * $form->{"${item}_rate"},
874 $form->{"${item}_total"} =
875 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
879 <th align=right>$form->{"${item}_description"}</th>
880 <td align=right>$form->{"${item}_total"}</td>
886 $form->{invsubtotal} =
887 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
891 <th align=right>| . $locale->text('Subtotal') . qq|</th>
892 <td align=right>$form->{invsubtotal}</td>
898 if ($form->{taxincluded}) {
899 foreach $item (split / /, $form->{taxaccounts}) {
900 if ($form->{"${item}_base"}) {
901 $form->{"${item}_total"} =
903 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
904 (1 + $form->{"${item}_rate"})
907 $form->{"${item}_netto"} =
909 ($form->{"${item}_base"} - $form->{"${item}_total"}),
911 $form->{"${item}_total"} =
912 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
913 $form->{"${item}_netto"} =
914 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
918 <th align=right>Enthaltene $form->{"${item}_description"}</th>
919 <td align=right>$form->{"${item}_total"}</td>
922 <th align=right>Nettobetrag</th>
923 <td align=right>$form->{"${item}_netto"}</td>
931 $form->{oldinvtotal} = $form->{invtotal};
933 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
943 <th align=left>| . $locale->text('Notes') . qq|</th>
944 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
950 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
951 <td><select name=payment_id tabindex=24>$payment
955 <td align=right width=100%>
961 <th align=right>| . $locale->text('Total') . qq|</th>
962 <td align=right>$form->{invtotal}</td>
970 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
971 <input type=hidden name=oldtotalpaid value=$totalpaid>
973 <td><hr size=3 noshade></td>
981 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
984 <td align=left width=30%><b>Dateiname</b></td>
985 <td align=left width=70%><b>Webdavlink</b></td>
987 foreach $file (keys %{ $form->{WEBDAV} }) {
990 <td align=left>$file</td>
991 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
999 <td><hr size=3 noshade></td>
1006 <input type=hidden name=jscalendar value=$form->{jscalendar}>
1019 Bearbeiten des $form->{heading}<br>
1020 <input class=submit type=submit name=action value="|
1021 . $locale->text('Update') . qq|">
1022 <input class=submit type=submit name=action value="|
1023 . $locale->text('Ship to') . qq|">
1024 <input class=submit type=submit name=action value="|
1025 . $locale->text('Print') . qq|">
1026 <input class=submit type=submit name=action value="|
1027 . $locale->text('E-mail') . qq|">
1028 <input class=submit type=submit name=action value="|
1029 . $locale->text('Save') . qq|">
1030 <input class=submit type=submit name=action value="|
1031 . $locale->text('Save and Close') . qq|">
1034 if (($form->{id})) {
1036 <br>Workflow $form->{heading}<br>
1037 <input class=submit type=submit name=action value="|
1038 . $locale->text('Save as new') . qq|">
1039 <input class=submit type=submit name=action value="|
1040 . $locale->text('Delete') . qq|">|;
1041 if (($form->{type} =~ /sales_quotation$/)) {
1043 <input class=submit type=submit name=action value="|
1044 . $locale->text('Sales Order') . qq|">|;
1046 if ($form->{type} =~ /request_quotation$/) {
1048 <input class=submit type=submit name=action value="|
1049 . $locale->text('Purchase Order') . qq|">|;
1053 <input class=submit type=submit name=action value="|
1054 . $locale->text('Invoice') . qq|">
1058 if ($form->{type} =~ /sales_order$/) {
1060 <br>$form->{heading} als neue Vorlage verwenden für<br>
1061 <input class=submit type=submit name=action value="|
1062 . $locale->text('Purchase Order') . qq|">
1063 <input class=submit type=submit name=action value="|
1064 . $locale->text('Quotation') . qq|">
1067 } elsif ($form->{type} =~ /purchase_order$/) {
1069 <br>$form->{heading} als neue Vorlage verwenden für<br>
1070 <input class=submit type=submit name=action value="|
1071 . $locale->text('Sales Order') . qq|">
1072 <input class=submit type=submit name=action value="|
1073 . $locale->text('Quotation') . qq|">
1078 <br>$form->{heading} als neue Vorlage verwenden für<br>
1079 <input class=submit type=submit name=action value="|
1080 . $locale->text('Order') . qq|">
1083 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount} && !$form->{proforma}) {
1085 <br>Workflow $form->{heading}<br>
1086 <input class=submit type=submit name=action value="|
1087 . $locale->text('Save as new') . qq|">
1088 <input class=submit type=submit name=action value="|
1089 . $locale->text('Invoice') . qq|">
1093 if ($form->{menubar}) {
1094 require "$form->{path}/menu.pl";
1100 <input type=hidden name=rowcount value=$form->{rowcount}>
1102 <input name=callback type=hidden value="$form->{callback}">
1104 <input type=hidden name=path value=$form->{path}>
1105 <input type=hidden name=login value=$form->{login}>
1106 <input type=hidden name=password value=$form->{password}>
1113 $lxdebug->leave_sub();
1117 $lxdebug->enter_sub();
1119 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1120 qw(exchangerate creditlimit creditremaining);
1121 $form->{update} = 1;
1123 &check_name($form->{vc});
1128 $buysell = 'sell' if ($form->{vc} eq 'vendor');
1129 $form->{exchangerate} = $exchangerate
1133 $form->check_exchangerate(
1134 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1138 $i = $form->{rowcount};
1140 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1142 if ( ($form->{"partnumber_$i"} eq "")
1143 && ($form->{"description_$i"} eq "")
1144 && ($form->{"partsgroup_$i"} eq "")) {
1146 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1151 $form->{"selected_unit_$i"} = $form->{"unit_$i"};
1153 if ( $form->{type} eq 'purchase_order'
1154 || $form->{type} eq 'request_quotation') {
1155 IR->retrieve_item(\%myconfig, \%$form);
1157 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1158 IS->retrieve_item(\%myconfig, \%$form);
1161 my $rows = scalar @{ $form->{item_list} };
1163 $form->{"discount_$i"} =
1164 $form->format_amount(\%myconfig, $form->{discount} * 100);
1167 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1176 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1177 if ($form->{"not_discountable_$i"}) {
1178 $form->{"discount_$i"} = 0;
1180 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1181 qw(partnumber description unit);
1182 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1183 keys %{ $form->{item_list}[0] };
1184 if ($form->{"part_payment_id_$i"} ne "") {
1185 $form->{payment_id} = $form->{"part_payment_id_$i"};
1188 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1190 ($dec) = ($s =~ /\.(\d+)/);
1192 $decimalplaces = ($dec > 2) ? $dec : 2;
1195 $form->{"sellprice_$i"} = $sellprice;
1198 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1200 # if there is an exchange rate adjust sellprice
1201 $form->{"sellprice_$i"} /= $exchangerate;
1205 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1206 (1 - $form->{"discount_$i"} / 100);
1207 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1208 map { $form->{"${_}_base"} += $amount }
1209 (split / /, $form->{"taxaccounts_$i"});
1210 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1211 split / /, $form->{taxaccounts}
1212 if !$form->{taxincluded};
1214 $form->{creditremaining} -= $amount;
1216 $form->{"sellprice_$i"} =
1217 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1220 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1222 # get pricegroups for parts
1223 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1225 # build up html code for prices_$i
1226 &set_pricegroup($i);
1233 # ok, so this is a new part
1234 # ask if it is a part or service item
1236 if ( $form->{"partsgroup_$i"}
1237 && ($form->{"partsnumber_$i"} eq "")
1238 && ($form->{"description_$i"} eq "")) {
1239 $form->{rowcount}--;
1240 $form->{"discount_$i"} = "";
1244 $form->{"id_$i"} = 0;
1245 $form->{"unit_$i"} = $locale->text('ea');
1253 $lxdebug->leave_sub();
1257 $lxdebug->enter_sub();
1259 if ($form->{type} eq 'purchase_order') {
1260 $form->{title} = $locale->text('Purchase Orders');
1261 $form->{vc} = 'vendor';
1262 $ordlabel = $locale->text('Order Number');
1263 $ordnumber = 'ordnumber';
1264 $employee = $locale->text('Employee');
1266 if ($form->{type} eq 'request_quotation') {
1267 $form->{title} = $locale->text('Request for Quotations');
1268 $form->{vc} = 'vendor';
1269 $ordlabel = $locale->text('RFQ Number');
1270 $ordnumber = 'quonumber';
1271 $employee = $locale->text('Employee');
1273 if ($form->{type} eq 'receive_order') {
1274 $form->{title} = $locale->text('Receive Merchandise');
1275 $form->{vc} = 'vendor';
1276 $ordlabel = $locale->text('Order Number');
1277 $ordnumber = 'ordnumber';
1278 $employee = $locale->text('Employee');
1280 if ($form->{type} eq 'sales_order') {
1281 $form->{title} = $locale->text('Sales Orders');
1282 $form->{vc} = 'customer';
1283 $ordlabel = $locale->text('Order Number');
1284 $ordnumber = 'ordnumber';
1285 $employee = $locale->text('Salesperson');
1287 if ($form->{type} eq 'ship_order') {
1288 $form->{title} = $locale->text('Ship Merchandise');
1289 $form->{vc} = 'customer';
1290 $ordlabel = $locale->text('Order Number');
1291 $ordnumber = 'ordnumber';
1292 $employee = $locale->text('Salesperson');
1296 if ($form->{type} eq 'sales_quotation') {
1297 $form->{title} = $locale->text('Quotations');
1298 $form->{vc} = 'customer';
1299 $ordlabel = $locale->text('Quotation Number');
1300 $ordnumber = 'quonumber';
1301 $employee = $locale->text('Employee');
1304 if ($form->{type} =~ /(ship|receive)_order/) {
1305 OE->get_warehouses(\%myconfig, \%$form);
1308 if (@{ $form->{all_warehouses} }) {
1309 $form->{selectwarehouse} = "<option>\n";
1310 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1313 $form->{selectwarehouse} .=
1314 "<option>$_->{description}--$_->{id}\n"
1315 } (@{ $form->{all_warehouses} });
1319 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1320 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1321 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1328 # setup vendor / customer selection
1329 $form->all_vc(\%myconfig, $form->{vc},
1330 ($form->{vc} eq 'customer') ? "AR" : "AP");
1332 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1333 @{ $form->{"all_$form->{vc}"} };
1335 $vclabel = ucfirst $form->{vc};
1336 $vclabel = $locale->text($vclabel);
1338 # $locale->text('Vendor')
1339 # $locale->text('Customer')
1343 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1344 : qq|<input name=$form->{vc} size=35>|;
1347 if (@{ $form->{all_departments} }) {
1348 $form->{selectdepartment} = "<option>\n";
1351 $form->{selectdepartment} .=
1352 "<option>$_->{description}--$_->{id}\n"
1353 } (@{ $form->{all_departments} });
1358 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1359 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1361 | if $form->{selectdepartment};
1363 if ($form->{type} !~ /(ship_order|receive_order)/) {
1366 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1367 . $locale->text('Open') . qq|</td>
1368 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1369 . $locale->text('Closed') . qq|</td>
1375 <input type=hidden name="open" value=1>
1379 # use JavaScript Calendar or not
1380 $form->{jsscript} = $jscalendar;
1382 if ($form->{jsscript}) {
1384 # with JavaScript Calendar
1386 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1387 <input type=button name=transdatefrom id="trigger3" value=|
1388 . $locale->text('button') . qq|></td>
1391 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1392 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1393 . $locale->text('button') . qq|></td>
1398 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1399 "transdateto", "BL", "trigger4");
1402 # without JavaScript Calendar
1404 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1406 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1414 <form method=post action=$form->{script}>
1418 <th class=listtop>$form->{title}</th>
1420 <tr height="5"></tr>
1425 <th align=right>$vclabel</th>
1426 <td colspan=3>$vc</td>
1431 <th align=right>$ordlabel</th>
1432 <td colspan=3><input name="$ordnumber" size=20></td>
1435 <th align=right>| . $locale->text('From') . qq|</th>
1437 <th align=right>| . $locale->text('Bis') . qq|</th>
1440 <input type=hidden name=sort value=transdate>
1442 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1447 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1448 | . $locale->text('ID') . qq|</td>
1449 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1450 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1451 . $locale->text('Date') . qq|</td>
1452 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1453 . $locale->text('Required by') . qq|</td>
1456 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1457 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1458 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1459 . $locale->text('Ship via') . qq|</td>
1462 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1463 . $locale->text('Amount') . qq|</td>
1464 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1465 . $locale->text('Tax') . qq|</td>
1466 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1467 . $locale->text('Total') . qq|</td>
1470 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1471 . $locale->text('Subtotal') . qq|</td>
1479 <tr><td colspan=4><hr size=3 noshade></td></tr>
1485 <input type=hidden name=nextsub value=orders>
1486 <input type=hidden name=path value=$form->{path}>
1487 <input type=hidden name=login value=$form->{login}>
1488 <input type=hidden name=password value=$form->{password}>
1489 <input type=hidden name=vc value=$form->{vc}>
1490 <input type=hidden name=type value=$form->{type}>
1492 <input class=submit type=submit name=action value="|
1493 . $locale->text('Continue') . qq|">
1500 $lxdebug->leave_sub();
1504 $lxdebug->enter_sub();
1506 # split vendor / customer
1507 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1508 split(/--/, $form->{ $form->{vc} });
1510 OE->transactions(\%myconfig, \%$form);
1512 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1514 $number = $form->escape($form->{$ordnumber});
1515 $name = $form->escape($form->{ $form->{vc} });
1516 $department = $form->escape($form->{department});
1517 $warehouse = $form->escape($form->{warehouse});
1521 "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}&$ordnumber=$number&$form->{vc}=$name&department=$department&warehouse=$warehouse";
1523 # construct callback
1524 $number = $form->escape($form->{$ordnumber}, 1);
1525 $name = $form->escape($form->{ $form->{vc} }, 1);
1526 $department = $form->escape($form->{department}, 1);
1527 $warehouse = $form->escape($form->{warehouse}, 1);
1530 "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}&$ordnumber=$number&$form->{vc}=$name&department=$department&warehouse=$warehouse";
1533 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1534 "name", "netamount", "tax", "amount",
1535 "curr", "employee", "shipvia", "open",
1538 $form->{l_open} = $form->{l_closed} = "Y"
1539 if ($form->{open} && $form->{closed});
1541 foreach $item (@columns) {
1542 if ($form->{"l_$item"} eq "Y") {
1543 push @column_index, $item;
1545 # add column to href and callback
1546 $callback .= "&l_$item=Y";
1547 $href .= "&l_$item=Y";
1551 # only show checkboxes if gotten here via sales_order form.
1552 if ($form->{type} =~ /sales_order/) {
1553 unshift @column_index, "ids";
1556 if ($form->{l_subtotal} eq 'Y') {
1557 $callback .= "&l_subtotal=Y";
1558 $href .= "&l_subtotal=Y";
1561 if ($form->{vc} eq 'vendor') {
1562 if ($form->{type} eq 'receive_order') {
1563 $form->{title} = $locale->text('Receive Merchandise');
1564 } elsif ($form->{type} eq 'purchase_order') {
1565 $form->{title} = $locale->text('Purchase Orders');
1567 $form->{title} = $locale->text('Request for Quotations');
1569 $name = $locale->text('Vendor');
1570 $employee = $locale->text('Employee');
1572 if ($form->{vc} eq 'customer') {
1573 if ($form->{type} eq 'sales_order') {
1574 $form->{title} = $locale->text('Sales Orders');
1575 $employee = $locale->text('Salesperson');
1576 } elsif ($form->{type} eq 'ship_order') {
1577 $form->{title} = $locale->text('Ship Merchandise');
1578 $employee = $locale->text('Salesperson');
1580 $form->{title} = $locale->text('Quotations');
1581 $employee = $locale->text('Employee');
1583 $name = $locale->text('Customer');
1586 $column_header{id} =
1587 qq|<th><a class=listheading href=$href&sort=id>|
1588 . $locale->text('ID')
1590 $column_header{transdate} =
1591 qq|<th><a class=listheading href=$href&sort=transdate>|
1592 . $locale->text('Date')
1594 $column_header{reqdate} =
1595 qq|<th><a class=listheading href=$href&sort=reqdate>|
1596 . $locale->text('Required by')
1598 $column_header{ordnumber} =
1599 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1600 . $locale->text('Order')
1602 $column_header{quonumber} =
1603 qq|<th><a class=listheading href=$href&sort=quonumber>|
1604 . $locale->text('Quotation')
1606 $column_header{name} =
1607 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1608 $column_header{netamount} =
1609 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1610 $column_header{tax} =
1611 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1612 $column_header{amount} =
1613 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1614 $column_header{curr} =
1615 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1616 $column_header{shipvia} =
1617 qq|<th><a class=listheading href=$href&sort=shipvia>|
1618 . $locale->text('Ship via')
1620 $column_header{open} =
1621 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1622 $column_header{closed} =
1623 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1625 $column_header{employee} =
1626 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1628 $column_header{ids} = qq|<th></th>|;
1630 if ($form->{ $form->{vc} }) {
1631 $option = $locale->text(ucfirst $form->{vc});
1632 $option .= " : $form->{$form->{vc}}";
1634 if ($form->{warehouse}) {
1635 ($warehouse) = split /--/, $form->{warehouse};
1636 $option .= "\n<br>" if ($option);
1637 $option .= $locale->text('Warehouse');
1638 $option .= " : $warehouse";
1640 if ($form->{department}) {
1641 $option .= "\n<br>" if ($option);
1642 ($department) = split /--/, $form->{department};
1643 $option .= $locale->text('Department') . " : $department";
1645 if ($form->{transdatefrom}) {
1647 . $locale->text('From') . " "
1648 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1650 if ($form->{transdateto}) {
1652 . $locale->text('Bis') . " "
1653 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1655 if ($form->{open}) {
1656 $option .= "\n<br>" if ($option);
1657 $option .= $locale->text('Open');
1659 if ($form->{closed}) {
1660 $option .= "\n<br>" if ($option);
1661 $option .= $locale->text('Closed');
1669 <form method="post" action="oe.pl">
1672 <th class=listtop>$form->{title}</th>
1674 <tr height="5"></tr>
1681 <tr class=listheading>|;
1683 map { print "\n$column_header{$_}" } @column_index;
1689 # add sort and escape callback
1690 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1692 if (@{ $form->{OE} }) {
1693 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1697 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1699 $warehouse = $form->escape($form->{warehouse});
1701 foreach $oe (@{ $form->{OE} }) {
1702 $form->{rowcount} = ++$j;
1704 if ($form->{l_subtotal} eq 'Y') {
1705 if ($sameitem ne $oe->{ $form->{sort} }) {
1707 $sameitem = $oe->{ $form->{sort} };
1711 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1713 $column_data{netamount} =
1715 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1717 $column_data{tax} = "<td align=right>"
1718 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1721 $column_data{amount} =
1723 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1725 $totalnetamount += $oe->{netamount};
1726 $totalamount += $oe->{amount};
1728 $subtotalnetamount += $oe->{netamount};
1729 $subtotalamount += $oe->{amount};
1732 qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1733 $column_data{id} = "<td>$oe->{id}</td>";
1734 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1735 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1737 $column_data{$ordnumber} =
1738 "<td><a href=oe.pl?path=$form->{path}&action=$action&type=$form->{type}&id=$oe->{id}&warehouse=$warehouse&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&callback=$callback_escaped>$oe->{$ordnumber}</a></td>";
1739 $column_data{name} = "<td>$oe->{name}</td>";
1741 $column_data{employee} = "<td>$oe->{employee} </td>";
1742 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1744 if ($oe->{closed}) {
1745 $column_data{closed} = "<td align=center>X</td>";
1746 $column_data{open} = "<td> </td>";
1748 $column_data{closed} = "<td> </td>";
1749 $column_data{open} = "<td align=center>X</td>";
1755 <tr class=listrow$i>";
1757 map { print "\n$column_data{$_}" } @column_index;
1765 if ($form->{l_subtotal} eq 'Y') {
1771 <tr class=listtotal>|;
1773 map { $column_data{$_} = "<td> </td>" } @column_index;
1775 $column_data{netamount} =
1776 "<th class=listtotal align=right>"
1777 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1778 $column_data{tax} = "<th class=listtotal align=right>"
1779 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1782 $column_data{amount} =
1783 "<th class=listtotal align=right>"
1784 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1786 map { print "\n$column_data{$_}" } @column_index;
1794 <td><hr size=3 noshade></td>
1798 # multiple invoice edit button only if gotten there via sales_order form.
1800 if ($form->{type} =~ /sales_order/) {
1802 <input type="hidden" name="path" value="$form->{path}">
1803 <input class"submit" type="submit" name="action" value="|
1804 . $locale->text('Continue') . qq|">
1805 <input type="hidden" name="nextsub" value="edit">
1806 <input type="hidden" name="type" value="$form->{type}">
1807 <input type="hidden" name="warehouse" value="$warehouse">
1808 <input type="hidden" name="vc" value="$form->{vc}">
1809 <input type="hidden" name="login" value="$form->{login}">
1810 <input type="hidden" name="password" value="$form->{password}">
1811 <input type="hidden" name="callback" value="$callback">
1812 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1819 <form method=post action=$form->{script}>
1821 <input name=callback type=hidden value="$form->{callback}">
1823 <input type=hidden name=type value=$form->{type}>
1824 <input type=hidden name=vc value=$form->{vc}>
1826 <input type=hidden name=path value=$form->{path}>
1827 <input type=hidden name=login value=$form->{login}>
1828 <input type=hidden name=password value=$form->{password}>
1831 if ($form->{type} !~ /(ship|receive)_order/) {
1833 <input class=submit type=submit name=action value="|
1834 . $locale->text('Add') . qq|">|;
1837 if ($form->{menubar}) {
1838 require "$form->{path}/menu.pl";
1849 $lxdebug->leave_sub();
1853 $lxdebug->enter_sub();
1855 map { $column_data{$_} = "<td> </td>" } @column_index;
1857 $column_data{netamount} =
1858 "<th class=listsubtotal align=right>"
1859 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1861 $column_data{tax} = "<td class=listsubtotal align=right>"
1862 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1865 $column_data{amount} =
1866 "<th class=listsubtotal align=right>"
1867 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1869 $subtotalnetamount = 0;
1870 $subtotalamount = 0;
1873 <tr class=listsubtotal>
1876 map { print "\n$column_data{$_}" } @column_index;
1882 $lxdebug->leave_sub();
1885 sub save_and_close {
1886 $lxdebug->enter_sub();
1888 if ($form->{type} =~ /_order$/) {
1889 $form->isblank("transdate", $locale->text('Order Date missing!'));
1891 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1894 $msg = ucfirst $form->{vc};
1895 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1897 # $locale->text('Customer missing!');
1898 # $locale->text('Vendor missing!');
1900 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1901 if ($form->{currency} ne $form->{defaultcurrency});
1905 # if the name changed get new values
1906 if (&check_name($form->{vc})) {
1911 $form->{id} = 0 if $form->{saveasnew};
1913 # this is for the internal notes section for the [email] Subject
1914 if ($form->{type} =~ /_order$/) {
1915 if ($form->{type} eq 'sales_order') {
1916 $form->{label} = $locale->text('Sales Order');
1918 $numberfld = "sonumber";
1919 $ordnumber = "ordnumber";
1921 $form->{label} = $locale->text('Purchase Order');
1923 $numberfld = "ponumber";
1924 $ordnumber = "ordnumber";
1927 $err = $locale->text('Cannot save order!');
1930 if ($form->{type} eq 'sales_quotation') {
1931 $form->{label} = $locale->text('Quotation');
1933 $numberfld = "sqnumber";
1934 $ordnumber = "quonumber";
1936 $form->{label} = $locale->text('Request for Quotation');
1938 $numberfld = "rfqnumber";
1939 $ordnumber = "quonumber";
1942 $err = $locale->text('Cannot save quotation!');
1946 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
1947 unless $form->{$ordnumber};
1950 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1951 if (OE->save(\%myconfig, \%$form));
1954 $lxdebug->leave_sub();
1958 $lxdebug->enter_sub();
1960 if ($form->{type} =~ /_order$/) {
1961 $form->isblank("transdate", $locale->text('Order Date missing!'));
1963 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1966 $msg = ucfirst $form->{vc};
1967 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1969 # $locale->text('Customer missing!');
1970 # $locale->text('Vendor missing!');
1972 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1973 if ($form->{currency} ne $form->{defaultcurrency});
1977 # if the name changed get new values
1978 if (&check_name($form->{vc})) {
1983 $form->{id} = 0 if $form->{saveasnew};
1985 # this is for the internal notes section for the [email] Subject
1986 if ($form->{type} =~ /_order$/) {
1987 if ($form->{type} eq 'sales_order') {
1988 $form->{label} = $locale->text('Sales Order');
1990 $numberfld = "sonumber";
1991 $ordnumber = "ordnumber";
1993 $form->{label} = $locale->text('Purchase Order');
1995 $numberfld = "ponumber";
1996 $ordnumber = "ordnumber";
1999 $err = $locale->text('Cannot save order!');
2002 if ($form->{type} eq 'sales_quotation') {
2003 $form->{label} = $locale->text('Quotation');
2005 $numberfld = "sqnumber";
2006 $ordnumber = "quonumber";
2008 $form->{label} = $locale->text('Request for Quotation');
2010 $numberfld = "rfqnumber";
2011 $ordnumber = "quonumber";
2014 $err = $locale->text('Cannot save quotation!');
2018 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
2019 unless $form->{$ordnumber};
2022 OE->save(\%myconfig, \%$form);
2023 $form->{simple_save} = 1;
2024 if(!$form->{print_and_save}) {
2028 $lxdebug->leave_sub();
2032 $lxdebug->enter_sub();
2036 if ($form->{type} =~ /_order$/) {
2037 $msg = $locale->text('Are you sure you want to delete Order Number');
2038 $ordnumber = 'ordnumber';
2040 $msg = $locale->text('Are you sure you want to delete Quotation Number');
2041 $ordnumber = 'quonumber';
2047 <form method=post action=$form->{script}>
2050 # delete action variable
2051 map { delete $form->{$_} } qw(action header);
2053 foreach $key (keys %$form) {
2054 $form->{$key} =~ s/\"/"/g;
2055 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2059 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
2061 <h4>$msg $form->{$ordnumber}</h4>
2063 <input name=action class=submit type=submit value="|
2064 . $locale->text('Yes') . qq|">
2071 $lxdebug->leave_sub();
2075 $lxdebug->enter_sub();
2077 if ($form->{type} =~ /_order$/) {
2078 $msg = $locale->text('Order deleted!');
2079 $err = $locale->text('Cannot delete order!');
2081 $msg = $locale->text('Quotation deleted!');
2082 $err = $locale->text('Cannot delete quotation!');
2085 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
2088 $lxdebug->leave_sub();
2092 $lxdebug->enter_sub();
2094 if ($form->{type} =~ /_order$/) {
2096 # these checks only apply if the items don't bring their own ordnumbers/transdates.
2097 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
2098 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
2099 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2101 $form->isblank("transdate", $locale->text('Order Date missing!'))
2102 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2105 # also copy deliverydate from the order
2106 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
2108 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
2109 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2110 $form->{ordnumber} = "";
2113 # if the name changed get new values
2114 if (&check_name($form->{vc})) {
2119 $form->{cp_id} *= 1;
2121 if ( $form->{type} =~ /_order/
2122 && $form->{currency} ne $form->{defaultcurrency}) {
2124 # check if we need a new exchangerate
2125 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
2127 $orddate = $form->current_date(\%myconfig);
2129 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
2132 if (!$exchangerate) {
2133 &backorder_exchangerate($orddate, $buysell);
2138 # close orders/quotations
2139 $form->{closed} = 1;
2141 # save order if one ordnumber has been given
2142 # if not it's most likely a collective order, which can't be saved back
2143 # so they just have to be closed
2144 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
2145 OE->save(\%myconfig, \%$form);
2147 OE->close_orders(\%myconfig, \%$form);
2150 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
2152 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2155 $form->{closed} = 0;
2156 $form->{rowcount}--;
2157 $form->{shipto} = 1;
2159 if ($form->{type} =~ /_order$/) {
2160 $form->{exchangerate} = $exchangerate;
2164 if ( $form->{type} eq 'purchase_order'
2165 || $form->{type} eq 'request_quotation') {
2166 $form->{title} = $locale->text('Add Vendor Invoice');
2167 $form->{script} = 'ir.pl';
2171 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
2172 $form->{title} = $locale->text('Add Sales Invoice');
2173 $form->{script} = 'is.pl';
2178 # bo creates the id, reset it
2179 map { delete $form->{$_} }
2180 qw(id subject message cc bcc printed emailed queued);
2181 $form->{ $form->{vc} } =~ s/--.*//g;
2182 $form->{type} = "invoice";
2185 $locale = new Locale "$myconfig{countrycode}", "$script";
2187 require "$form->{path}/$form->{script}";
2189 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
2191 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2192 qw(creditlimit creditremaining);
2194 $currency = $form->{currency};
2197 $form->{currency} = $currency;
2198 $form->{exchangerate} = "";
2199 $form->{forex} = "";
2200 $form->{exchangerate} = $exchangerate
2204 $form->check_exchangerate(
2205 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
2208 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
2213 for $i (1 .. $form->{rowcount}) {
2214 $form->{"discount_$i"} =
2215 $form->format_amount(\%myconfig, $form->{"discount_$i"});
2217 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
2219 $decimalplaces = ($dec > 2) ? $dec : 2;
2221 # copy delivery date from reqdate for order -> invoice conversion
2222 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
2223 unless $form->{"deliverydate_$i"};
2225 $form->{"sellprice_$i"} =
2226 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
2229 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
2230 $dec_qty = length $dec_qty;
2232 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
2234 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2235 qw(partnumber description unit);
2241 $lxdebug->leave_sub();
2244 sub backorder_exchangerate {
2245 $lxdebug->enter_sub();
2246 my ($orddate, $buysell) = @_;
2253 <form method=post action=$form->{script}>
2256 # delete action variable
2257 map { delete $form->{$_} } qw(action header exchangerate);
2259 foreach $key (keys %$form) {
2260 $form->{$key} =~ s/\"/"/g;
2261 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2264 $form->{title} = $locale->text('Add Exchangerate');
2268 <input type=hidden name=path value=$form->{path}>
2269 <input type=hidden name=login value=$form->{login}>
2270 <input type=hidden name=password value=$form->{password}>
2272 <input type=hidden name=exchangeratedate value=$orddate>
2273 <input type=hidden name=buysell value=$buysell>
2276 <tr><th class=listtop>$form->{title}</th></tr>
2277 <tr height="5"></tr>
2282 <th align=right>| . $locale->text('Currency') . qq|</th>
2283 <td>$form->{currency}</td>
2286 <th align=right>| . $locale->text('Date') . qq|</th>
2290 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2291 <td><input name=exchangerate size=11></td>
2301 <input type=hidden name=nextsub value=save_exchangerate>
2303 <input name=action class=submit type=submit value="|
2304 . $locale->text('Continue') . qq|">
2312 $lxdebug->leave_sub();
2315 sub save_exchangerate {
2316 $lxdebug->enter_sub();
2318 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2319 $form->{exchangerate} =
2320 $form->parse_amount(\%myconfig, $form->{exchangerate});
2321 $form->save_exchangerate(\%myconfig, $form->{currency},
2322 $form->{exchangeratedate},
2323 $form->{exchangerate}, $form->{buysell});
2327 $lxdebug->leave_sub();
2330 sub create_backorder {
2331 $lxdebug->enter_sub();
2333 $form->{shipped} = 1;
2335 # figure out if we need to create a backorder
2336 # items aren't saved if qty != 0
2338 for $i (1 .. $form->{rowcount}) {
2339 $totalqty += $qty = $form->{"qty_$i"};
2340 $totalship += $ship = $form->{"ship_$i"};
2342 $form->{"qty_$i"} = $qty - $ship;
2345 if ($totalship == 0) {
2346 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2347 $form->{ordtotal} = 0;
2348 $form->{shipped} = 0;
2352 if ($totalqty == $totalship) {
2353 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2354 $form->{ordtotal} = 0;
2359 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2362 for $i (1 .. $form->{rowcount}) {
2364 $form->{"${_}_$i"} =
2365 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2366 } qw(sellprice discount);
2369 OE->save(\%myconfig, \%$form);
2371 # rebuild rows for invoice
2375 for $i (1 .. $form->{rowcount}) {
2376 $form->{"qty_$i"} = $form->{"ship_$i"};
2378 if ($form->{"qty_$i"}) {
2381 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2386 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2387 $form->{rowcount} = $count;
2389 $lxdebug->leave_sub();
2393 $lxdebug->enter_sub();
2395 $form->{saveasnew} = 1;
2396 $form->{closed} = 0;
2397 map { delete $form->{$_} } qw(printed emailed queued ordnumber quonumber);
2401 $lxdebug->leave_sub();
2404 sub purchase_order {
2405 $lxdebug->enter_sub();
2407 if ( $form->{type} eq 'sales_quotation'
2408 || $form->{type} eq 'request_quotation') {
2409 $form->{closed} = 1;
2410 OE->save(\%myconfig, \%$form);
2413 $form->{cp_id} *= 1;
2415 $form->{title} = $locale->text('Add Purchase Order');
2416 $form->{vc} = "vendor";
2417 $form->{type} = "purchase_order";
2421 $lxdebug->leave_sub();
2425 $lxdebug->enter_sub();
2427 if ( $form->{type} eq 'sales_quotation'
2428 || $form->{type} eq 'request_quotation') {
2429 $form->{closed} = 1;
2430 OE->save(\%myconfig, \%$form);
2433 $form->{cp_id} *= 1;
2435 $form->{title} = $locale->text('Add Sales Order');
2436 $form->{vc} = "customer";
2437 $form->{type} = "sales_order";
2441 $lxdebug->leave_sub();
2445 $lxdebug->enter_sub();
2447 $form->{transdate} = $form->current_date(\%myconfig);
2448 delete $form->{duedate};
2450 $form->{closed} = 0;
2453 map { delete $form->{$_} }
2454 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2461 for $i (1 .. $form->{rowcount} - 1) {
2462 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2463 qw(partnumber description unit);
2466 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2467 qw(creditlimit creditremaining);
2471 $lxdebug->leave_sub();
2475 $lxdebug->enter_sub();
2481 OE->get_warehouses(\%myconfig, \%$form);
2484 if (@{ $form->{all_warehouses} }) {
2485 $form->{selectwarehouse} = "<option>\n";
2487 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2488 (@{ $form->{all_warehouses} });
2490 if ($form->{warehouse}) {
2491 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2495 $form->{shippingdate} = $form->current_date(\%myconfig);
2496 $form->{"$form->{vc}"} =~ s/--.*//;
2501 foreach $key (keys %$form) {
2502 if ($key =~ /_1$/) {
2508 for $i (1 .. $form->{rowcount}) {
2510 # undo formatting from prepare_order
2512 $form->{"${_}_$i"} =
2513 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2515 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2517 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2518 $form->{"ship_$i"} = "";
2519 $form->{"serialnumber_$i"} = "";
2524 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2529 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2530 $form->{rowcount} = $count;
2532 &display_ship_receive;
2534 $lxdebug->leave_sub();
2537 sub display_ship_receive {
2538 $lxdebug->enter_sub();
2540 $vclabel = ucfirst $form->{vc};
2541 $vclabel = $locale->text($vclabel);
2543 $form->{rowcount}++;
2545 if ($form->{vc} eq 'customer') {
2546 $form->{title} = $locale->text('Ship Merchandise');
2547 $shipped = $locale->text('Shipping Date');
2549 $form->{title} = $locale->text('Receive Merchandise');
2550 $shipped = $locale->text('Date Received');
2553 # set option selected
2554 foreach $item (warehouse, employee) {
2555 $form->{"select$item"} =~ s/ selected//;
2556 $form->{"select$item"} =~
2557 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2562 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2563 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2564 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2566 | if $form->{selectwarehouse};
2570 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2571 <td><select name=employee>$form->{selectemployee}</select></td>
2572 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2581 <form method=post action=$form->{script}>
2583 <input type=hidden name=id value=$form->{id}>
2585 <input type=hidden name=display_form value=display_ship_receive>
2587 <input type=hidden name=type value=$form->{type}>
2588 <input type=hidden name=media value=$form->{media}>
2589 <input type=hidden name=format value=$form->{format}>
2591 <input type=hidden name=queued value="$form->{queued}">
2592 <input type=hidden name=printed value="$form->{printed}">
2593 <input type=hidden name=emailed value="$form->{emailed}">
2595 <input type=hidden name=vc value=$form->{vc}>
2599 <th class=listtop>$form->{title}</th>
2601 <tr height="5"></tr>
2604 <table width="100%">
2609 <th align=right>$vclabel</th>
2610 <td colspan=3>$form->{$form->{vc}}</td>
2611 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2612 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2616 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2618 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2621 <th align=right>| . $locale->text('Ship via') . qq|</th>
2623 <input name=shipvia size=35 value="$form->{shipvia}">
2632 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2633 <td>$form->{ordnumber}</td>
2634 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2637 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2638 <td>$form->{transdate}</td>
2639 <input type=hidden name=transdate value=$form->{transdate}>
2642 <th align=right nowrap>$shipped</th>
2643 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2652 <!-- shipto are in hidden variables -->
2654 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2655 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2656 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2657 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2658 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2659 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2660 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2661 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2662 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2664 <!-- email variables -->
2665 <input type=hidden name=message value="$form->{message}">
2666 <input type=hidden name=email value="$form->{email}">
2667 <input type=hidden name=subject value="$form->{subject}">
2668 <input type=hidden name=cc value="$form->{cc}">
2669 <input type=hidden name=bcc value="$form->{bcc}">
2674 (partnumber, description, qty, ship, unit, bin, serialnumber);
2676 if ($form->{type} eq "ship_order") {
2677 $column_data{ship} =
2678 qq|<th class=listheading align=center width="auto">|
2679 . $locale->text('Ship')
2682 if ($form->{type} eq "receive_order") {
2683 $column_data{ship} =
2684 qq|<th class=listheading align=center width="auto">|
2685 . $locale->text('Recd')
2689 my $colspan = $#column_index + 1;
2691 $column_data{partnumber} =
2692 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2693 $column_data{description} =
2694 qq|<th class=listheading nowrap>|
2695 . $locale->text('Description')
2698 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2699 $column_data{unit} =
2700 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2702 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2703 $column_data{serialnumber} =
2704 qq|<th class=listheading nowrap>|
2705 . $locale->text('Serial No.')
2712 <tr class=listheading>|;
2714 map { print "\n$column_data{$_}" } @column_index;
2720 for $i (1 .. $form->{rowcount} - 1) {
2723 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2725 # convert " to "
2726 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2727 qw(partnumber description unit bin serialnumber);
2729 $description = $form->{"description_$i"};
2730 $description =~ s/\n/<br>/g;
2732 $column_data{partnumber} =
2733 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2734 $column_data{description} =
2735 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2737 qq|<td align=right>|
2738 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2739 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2740 $column_data{ship} =
2741 qq|<td align=right><input name="ship_$i" size=5 value=|
2742 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2744 $column_data{unit} =
2745 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2747 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2749 $column_data{serialnumber} =
2750 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2755 map { print "\n$column_data{$_}" } @column_index;
2760 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2761 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2762 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2763 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2774 <td><hr size=3 noshade></td>
2780 $form->{copies} = 1;
2789 <input class=submit type=submit name=action value="|
2790 . $locale->text('Update') . qq|">
2791 <input class=submit type=submit name=action value="|
2792 . $locale->text('Print') . qq|">
2795 if ($form->{type} eq 'ship_order') {
2797 <input class=submit type=submit name=action value="|
2798 . $locale->text('Ship to') . qq|">
2799 <input class=submit type=submit name=action value="|
2800 . $locale->text('E-mail') . qq|">
2806 <input class=submit type=submit name=action value="|
2807 . $locale->text('Done') . qq|">
2810 if ($form->{menubar}) {
2811 require "$form->{path}/menu.pl";
2817 <input type=hidden name=rowcount value=$form->{rowcount}>
2819 <input name=callback type=hidden value="$callback">
2821 <input type=hidden name=path value=$form->{path}>
2822 <input type=hidden name=login value=$form->{login}>
2823 <input type=hidden name=password value=$form->{password}>
2831 $lxdebug->leave_sub();
2835 $lxdebug->enter_sub();
2837 if ($form->{type} eq 'ship_order') {
2838 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2840 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2845 $total += $form->{"ship_$_"} =
2846 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2847 } (1 .. $form->{rowcount} - 1);
2849 $form->error($locale->text('Nothing entered!')) unless $total;
2851 $form->redirect($locale->text('Inventory saved!'))
2852 if OE->save_inventory(\%myconfig, \%$form);
2853 $form->error($locale->text('Could not save!'));
2855 $lxdebug->leave_sub();
2858 sub search_transfer {
2859 $lxdebug->enter_sub();
2861 OE->get_warehouses(\%myconfig, \%$form);
2864 if (@{ $form->{all_warehouses} }) {
2865 $form->{selectwarehouse} = "<option>\n";
2866 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2868 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2869 (@{ $form->{all_warehouses} });
2871 $form->error($locale->text('Nothing to transfer!'));
2874 $form->{title} = $locale->text('Transfer Inventory');
2881 <form method=post action=$form->{script}>
2885 <th class=listtop>$form->{title}</th>
2887 <tr height="5"></tr>
2892 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2893 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2896 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2897 <td><input name=partnumber size=20></td>
2900 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2901 <td><input name=description size=40></td>
2904 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2905 <td><input name=partsgroup size=20></td>
2911 <td><hr size=3 noshade></td>
2916 <input type=hidden name=sort value=partnumber>
2917 <input type=hidden name=nextsub value=list_transfer>
2919 <input type=hidden name=path value=$form->{path}>
2920 <input type=hidden name=login value=$form->{login}>
2921 <input type=hidden name=password value=$form->{password}>
2923 <input class=submit type=submit name=action value="|
2924 . $locale->text('Continue') . qq|">
2931 $lxdebug->leave_sub();
2935 $lxdebug->enter_sub();
2937 OE->get_inventory(\%myconfig, \%$form);
2939 $partnumber = $form->escape($form->{partnumber});
2940 $warehouse = $form->escape($form->{warehouse});
2941 $description = $form->escape($form->{description});
2942 $partsgroup = $form->escape($form->{partsgroup});
2946 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2948 # construct callback
2949 $partnumber = $form->escape($form->{partnumber}, 1);
2950 $warehouse = $form->escape($form->{warehouse}, 1);
2951 $description = $form->escape($form->{description}, 1);
2952 $partsgroup = $form->escape($form->{partsgroup}, 1);
2955 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2958 $form->sort_columns(
2959 qw(partnumber description partsgroup make model warehouse qty transfer));
2961 $column_header{partnumber} =
2962 qq|<th><a class=listheading href=$href&sort=partnumber>|
2963 . $locale->text('Part Number')
2965 $column_header{description} =
2966 qq|<th><a class=listheading href=$href&sort=description>|
2967 . $locale->text('Description')
2969 $column_header{partsgroup} =
2970 qq|<th><a class=listheading href=$href&sort=partsgroup>|
2971 . $locale->text('Group')
2973 $column_header{warehouse} =
2974 qq|<th><a class=listheading href=$href&sort=warehouse>|
2975 . $locale->text('From')
2977 $column_header{qty} =
2978 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
2979 $column_header{transfer} =
2980 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
2982 $option = $locale->text('Transfer to');
2984 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
2986 if ($form->{warehouse}) {
2987 $option .= " : $warehouse";
2989 if ($form->{partnumber}) {
2990 $option .= "\n<br>" if ($option);
2991 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
2993 if ($form->{description}) {
2994 $option .= "\n<br>" if ($option);
2995 $option .= $locale->text('Description') . " : $form->{description}";
2997 if ($form->{partsgroup}) {
2998 $option .= "\n<br>" if ($option);
2999 $option .= $locale->text('Group') . " : $form->{partsgroup}";
3002 $form->{title} = $locale->text('Transfer Inventory');
3009 <form method=post action=$form->{script}>
3011 <input type=hidden name=warehouse_id value=$warehouse_id>
3015 <th class=listtop>$form->{title}</th>
3017 <tr height="5"></tr>
3024 <tr class=listheading>|;
3026 map { print "\n$column_header{$_}" } @column_index;
3032 if (@{ $form->{all_inventory} }) {
3033 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
3037 foreach $ref (@{ $form->{all_inventory} }) {
3041 $column_data{partnumber} =
3042 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
3043 $column_data{description} = "<td>$ref->{description} </td>";
3044 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
3045 $column_data{warehouse} =
3046 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
3048 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
3049 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
3051 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
3056 <tr class=listrow$j>";
3058 map { print "\n$column_data{$_}" } @column_index;
3072 <td><hr size=3 noshade></td>
3078 <input name=callback type=hidden value="$callback">
3080 <input type=hidden name=rowcount value=$i>
3082 <input type=hidden name=path value=$form->{path}>
3083 <input type=hidden name=login value=$form->{login}>
3084 <input type=hidden name=password value=$form->{password}>
3086 <input class=submit type=submit name=action value="|
3087 . $locale->text('Transfer') . qq|">|;
3089 if ($form->{menubar}) {
3090 require "$form->{path}/menu.pl";
3101 $lxdebug->leave_sub();
3105 $lxdebug->enter_sub();
3107 $form->redirect($locale->text('Inventory transferred!'))
3108 if OE->transfer(\%myconfig, \%$form);
3109 $form->error($locale->text('Could not transfer Inventory!'));
3111 $lxdebug->leave_sub();