1 #=====================================================================
2 # SQL-Ledger, Accounting
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #======================================================================
27 #======================================================================
35 require "$form->{path}/arap.pl";
36 require "$form->{path}/io.pl";
45 if ($form->{type} eq 'purchase_order') {
46 $form->{title} = $locale->text('Add Purchase Order');
47 $form->{vc} = 'vendor';
49 if ($form->{type} eq 'sales_order') {
50 $form->{title} = $locale->text('Add Sales Order');
51 $form->{vc} = 'customer';
53 if ($form->{type} eq 'request_quotation') {
54 $form->{title} = $locale->text('Add Request for Quotation');
55 $form->{vc} = 'vendor';
57 if ($form->{type} eq 'sales_quotation') {
58 $form->{title} = $locale->text('Add Quotation');
59 $form->{vc} = 'customer';
62 $form->{callback} = "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&sessionid=$form->{sessionid}" unless $form->{callback};
73 if ($form->{type} =~ /(purchase_order|bin_list)/) {
74 $form->{title} = $locale->text('Edit Purchase Order');
75 $form->{vc} = 'vendor';
76 $form->{type} = 'purchase_order';
78 if ($form->{type} =~ /((sales|work)_order|(packing|pick)_list)/) {
79 $form->{title} = $locale->text('Edit Sales Order');
80 $form->{vc} = 'customer';
81 $form->{type} = 'sales_order';
83 if ($form->{type} eq 'request_quotation') {
84 $form->{title} = $locale->text('Edit Request for Quotation');
85 $form->{vc} = 'vendor';
87 if ($form->{type} eq 'sales_quotation') {
88 $form->{title} = $locale->text('Edit Quotation');
89 $form->{vc} = 'customer';
102 # get customer/vendor
103 $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
105 $form->get_partsgroup(\%myconfig);
106 if (@{ $form->{all_partsgroup} }) {
107 $form->{selectpartsgroup} = "<option>\n";
108 map { $form->{selectpartsgroup} .= qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n| } @{ $form->{all_partsgroup} };
111 # retrieve order/quotation
112 OE->retrieve(\%myconfig, \%$form);
115 @curr = split /:/, $form->{currencies};
117 $form->{defaultcurrency} = $curr[0];
118 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
120 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
122 $form->{oldlanguage_code} = $form->{language_code};
124 $form->get_partsgroup(\%myconfig, { language_code => $form->{language_code} });
126 if (@{ $form->{all_partsgroup} }) {
127 $form->{selectpartsgroup} = "<option>\n";
128 foreach $ref (@ { $form->{all_partsgroup} }) {
129 if ($ref->{translation}) {
130 $form->{selectpartsgroup} .= qq|<option value="$ref->{partsgroup}--$ref->{id}">$ref->{translation}\n|;
132 $form->{selectpartsgroup} .= qq|<option value="$ref->{partsgroup}--$ref->{id}">$ref->{partsgroup}\n|;
137 if (@{ $form->{all_projects} }) {
138 $form->{selectprojectnumber} = "<option>\n";
139 map { $form->{selectprojectnumber} .= qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n| } @{ $form->{all_projects} };
142 $form->{shipto} = 1 if $form->{id};
144 if (@{ $form->{"all_$form->{vc}"} }) {
145 unless ($form->{"$form->{vc}_id"}) {
146 $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
150 # get customer / vendor
151 if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/ ) {
152 IR->get_vendor(\%myconfig, \%$form);
154 if ($form->{type} =~ /(sales|ship)_(order|quotation)/) {
155 IS->get_customer(\%myconfig, \%$form);
158 ($form->{$form->{vc}}) = split /--/, $form->{$form->{vc}};
159 $form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
161 # build selection list
162 if (@{ $form->{"all_$form->{vc}"} }) {
163 $form->{$form->{vc}} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
164 map { $form->{"select$form->{vc}"} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| } (@{ $form->{"all_$form->{vc}"} });
168 if (@{ $form->{all_departments} }) {
169 $form->{selectdepartment} = "<option>\n";
170 $form->{department} = "$form->{department}--$form->{department_id}";
172 map { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_departments} });
175 $form->{employee} = "$form->{employee}--$form->{employee_id}";
178 if (@{ $form->{all_employees} }) {
179 $form->{selectemployee} = "";
180 map { $form->{selectemployee} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| } (@{ $form->{all_employees} });
183 if (@{ $form->{all_languages} }) {
184 $form->{selectlanguage} = "<option>\n";
185 map { $form->{selectlanguage} .= qq|<option value="$_->{code}">$_->{description}\n| } @{ $form->{all_languages} };
189 $form->{forex} = $form->{exchangerate};
196 $form->{format} = "postscript" if $myconfig{printer};
197 $form->{media} = $myconfig{printer};
198 $form->{formname} = $form->{type};
199 $form->{oldcurrency} = $form->{currency};
203 map { $form->{$_} = $form->quote($form->{$_}) } qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptoaddress1 shiptoaddress2 shiptocity shiptostate shiptozipcode shiptocountry shiptocontact);
205 foreach $ref (@{ $form->{form_details} } ) {
207 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{ $ref };
209 $form->{"projectnumber_$i"} = qq|$ref->{projectnumber}--$ref->{project_id}|;
210 $form->{"partsgroup_$i"} = qq|$ref->{partsgroup}--$ref->{partsgroup_id}|;
212 $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
214 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
216 $decimalplaces = ($dec > 2) ? $dec : 2;
218 $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
219 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
220 $form->{"oldqty_$i"} = $form->{"qty_$i"};
222 map { $form->{"${_}_$i"} = $form->quote($form->{"${_}_$i"}) } qw(partnumber sku description unit);
223 $form->{rowcount} = $i;
227 if ($form->{type} eq 'sales_quotation') {
228 $form->{readonly} = 1 if $myconfig{acs} =~ /Quotations--Quotation/;
230 if ($form->{type} eq 'request_quotation') {
231 $form->{readonly} = 1 if $myconfig{acs} =~ /Quotations--RFQ/;
233 if ($form->{type} eq 'sales_order') {
234 $form->{readonly} = 1 if $myconfig{acs} =~ /Order Entry--Sales Order/;
236 if ($form->{type} eq 'purchase_order') {
237 $form->{readonly} = 1 if $myconfig{acs} =~ /Order Entry--Purchase Order/;
245 $checkedopen = ($form->{closed}) ? "" : "checked";
246 $checkedclosed = ($form->{closed}) ? "checked" : "";
251 <th nowrap align=right><input name=closed type=radio class=radio value=0 $checkedopen> |.$locale->text('Open').qq|</th>
252 <th nowrap align=left><input name=closed type=radio class=radio value=1 $checkedclosed> |.$locale->text('Closed').qq|</th>
257 # set option selected
258 $form->{selectcurrency} =~ s/ selected//;
259 $form->{selectcurrency} =~ s/option>\Q$form->{currency}\E/option selected>$form->{currency}/;
261 foreach $item ($form->{vc}, department, employee) {
262 $form->{"select$item"} = $form->unescape($form->{"select$item"});
263 $form->{"select$item"} =~ s/ selected//;
264 $form->{"select$item"} =~ s/(<option value="\Q$form->{$item}\E")/$1 selected/;
268 $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
271 <input type=hidden name=forex value=$form->{forex}>
274 if ($form->{currency} ne $form->{defaultcurrency}) {
275 if ($form->{forex}) {
276 $exchangerate .= qq|<th align=right>|.$locale->text('Exchange Rate').qq|</th><td>$form->{exchangerate}</td>
277 <input type=hidden name=exchangerate value=$form->{exchangerate}>
280 $exchangerate .= qq|<th align=right>|.$locale->text('Exchange Rate').qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
285 $vclabel = ucfirst $form->{vc};
286 $vclabel = $locale->text($vclabel);
290 <th align=right nowrap>|.$locale->text('Terms').qq|</th>
291 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |.$locale->text('days').qq|</td>
296 if ($form->{business}) {
299 <th align=right>|.$locale->text('Business').qq|</th>
300 <td>$form->{business}</td>
301 <th align=right>|.$locale->text('Trade Discount').qq|</th>
302 <td>|.$form->format_amount(\%myconfig, $form->{tradediscount} * 100).qq| %</td>
307 if ($form->{type} !~ /_quotation$/) {
310 <th width=70% align=right nowrap>|.$locale->text('Order Number').qq|</th>
311 <td><input name=ordnumber size=20 value="$form->{ordnumber}"></td>
312 <input type=hidden name=quonumber value="$form->{quonumber}">
315 <th align=right nowrap>|.$locale->text('Order Date').qq|</th>
316 <td><input name=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
319 <th align=right nowrap=true>|.$locale->text('Required by').qq|</th>
320 <td><input name=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
324 $n = ($form->{creditremaining} < 0) ? "0" : "1";
326 $creditremaining = qq|
332 <th nowrap>|.$locale->text('Credit Limit').qq|</th>
333 <td>|.$form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0").qq|</td>
335 <th nowrap>|.$locale->text('Remaining').qq|</th>
336 <td class="plus$n" nowrap>|.$form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0").qq|</td>
343 $reqlabel = ($form->{type} eq 'sales_quotation') ? $locale->text('Valid until') : $locale->text('Required by');
344 if ($form->{type} eq 'sales_quotation') {
347 <th width=70% align=right nowrap>|.$locale->text('Quotation Number').qq|</th>
348 <td><input name=quonumber size=20 value="$form->{quonumber}"></td>
349 <input type=hidden name=ordnumber value="$form->{ordnumber}">
355 <th width=70% align=right nowrap>|.$locale->text('RFQ Number').qq|</th>
356 <td><input name=quonumber size=20 value="$form->{quonumber}"></td>
357 <input type=hidden name=ordnumber value="$form->{ordnumber}">
367 <th align=right nowrap>|.$locale->text('Quotation Date').qq|</th>
368 <td><input name=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
371 <th align=right nowrap=true>$reqlabel</th>
372 <td><input name=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
378 if ($form->{"select$form->{vc}"}) {
379 $vc = qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>
380 <input type=hidden name="select$form->{vc}" value="|
381 .$form->escape($form->{"select$form->{vc}"},1).qq|">|;
383 $vc = qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
388 <th align="right" nowrap>|.$locale->text('Department').qq|</th>
389 <td colspan=3><select name=department>$form->{selectdepartment}</select>
390 <input type=hidden name=selectdepartment value="|
391 .$form->escape($form->{selectdepartment},1).qq|">
394 | if $form->{selectdepartment};
397 <input type=hidden name=employee value="$form->{employee}">
400 if ($form->{type} eq 'sales_order') {
401 if ($form->{selectemployee}) {
404 <th align=right nowrap>|.$locale->text('Salesperson').qq|</th>
405 <td><select name=employee>$form->{selectemployee}</select></td>
406 <input type=hidden name=selectemployee value="|.
407 $form->escape($form->{selectemployee},1).qq|"
414 <th align=right nowrap>|.$locale->text('Employee').qq|</th>
415 <td><select name=employee>$form->{selectemployee}</select></td>
416 <input type=hidden name=selectemployee value="|.
417 $form->escape($form->{selectemployee},1).qq|"
428 <form method=post action="$form->{script}#end">
430 <input type=hidden name=id value=$form->{id}>
432 <input type=hidden name=type value=$form->{type}>
433 <input type=hidden name=formname value=$form->{formname}>
434 <input type=hidden name=media value=$form->{media}>
435 <input type=hidden name=format value=$form->{format}>
437 <input type=hidden name=queued value="$form->{queued}">
438 <input type=hidden name=printed value="$form->{printed}">
439 <input type=hidden name=emailed value="$form->{emailed}">
441 <input type=hidden name=vc value=$form->{vc}>
443 <input type=hidden name=title value="$form->{title}">
445 <input type=hidden name=discount value=$form->{discount}>
446 <input type=hidden name=creditlimit value=$form->{creditlimit}>
447 <input type=hidden name=creditremaining value=$form->{creditremaining}>
449 <input type=hidden name=tradediscount value=$form->{tradediscount}>
450 <input type=hidden name=business value="$form->{business}">
455 <th class=listtop>$form->{title}</th>
465 <th align=right>$vclabel</th>
466 <td colspan=3>$vc</td>
467 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
468 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
474 <th align=right>|.$locale->text('Currency').qq|</th>
475 <td><select name=currency>$form->{selectcurrency}</select></td>
476 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
477 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
481 <th align=right>|.$locale->text('Shipping Point').qq|</th>
482 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
485 <th align=right>|.$locale->text('Ship via').qq|</th>
486 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
503 <!-- shipto are in hidden variables -->
505 <input type=hidden name=shiptoname value="$form->{shiptoname}">
506 <input type=hidden name=shiptoaddress1 value="$form->{shiptoaddress1}">
507 <input type=hidden name=shiptoaddress2 value="$form->{shiptoaddress2}">
508 <input type=hidden name=shiptocity value="$form->{shiptocity}">
509 <input type=hidden name=shiptostate value="$form->{shiptostate}">
510 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
511 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
512 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
513 <input type=hidden name=shiptophone value="$form->{shiptophone}">
514 <input type=hidden name=shiptofax value="$form->{shiptofax}">
515 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
517 <!-- email variables -->
518 <input type=hidden name=message value="$form->{message}">
519 <input type=hidden name=email value="$form->{email}">
520 <input type=hidden name=subject value="$form->{subject}">
521 <input type=hidden name=cc value="$form->{cc}">
522 <input type=hidden name=bcc value="$form->{bcc}">
524 <input type=hidden name=taxpart value="$form->{taxpart}">
525 <input type=hidden name=taxservice value="$form->{taxservice}">
527 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
530 foreach $item (split / /, $form->{taxaccounts}) {
532 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
533 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
542 $form->{invtotal} = $form->{invsubtotal};
544 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
547 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
550 $rows = ($rows > $introws) ? $rows : $introws;
551 $notes = qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
552 $intnotes = qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
555 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
558 if ($form->{taxaccounts}) {
563 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
564 <th align=left>|.$locale->text('Tax Included').qq|</th>
569 if (!$form->{taxincluded}) {
571 foreach $item (split / /, $form->{taxaccounts}) {
572 if ($form->{"${item}_base"}) {
573 $form->{invtotal} += $form->{"${item}_total"} = $form->round_amount($form->{"${item}_base"} * $form->{"${item}_rate"}, 2);
574 $form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
578 <th align=right>$form->{"${item}_description"}</th>
579 <td align=right>$form->{"${item}_total"}</td>
585 $form->{invsubtotal} = $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
589 <th align=right>|.$locale->text('Subtotal').qq|</th>
590 <td align=right>$form->{invsubtotal}</td>
596 $form->{oldinvtotal} = $form->{invtotal};
597 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
608 <th align=left>|.$locale->text('Notes').qq|</th>
609 <th align=left>|.$locale->text('Internal Notes').qq|</th>
622 <th align=right>|.$locale->text('Total').qq|</th>
623 <td align=right>$form->{invtotal}</td>
632 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
633 <input type=hidden name=oldtotalpaid value=$totalpaid>
635 <td><hr size=3 noshade></td>
651 if (! $form->{readonly}) {
653 <input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
654 <input class=submit type=submit name=action value="|.$locale->text('Ship to').qq|">
655 <input class=submit type=submit name=action value="|.$locale->text('Print').qq|">
656 <input class=submit type=submit name=action value="|.$locale->text('E-mail').qq|">
657 <input class=submit type=submit name=action value="|.$locale->text('Save').qq|">
662 <input class=submit type=submit name=action value="|.$locale->text('Print and Save').qq|">|;
667 <input class=submit type=submit name=action value="|.$locale->text('Save as new').qq|">
668 <input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">|;
670 if ($form->{type} =~ /sales_/) {
671 if ($myconfig{acs} !~ /AP--Sales Invoice/) {
673 <input class=submit type=submit name=action value="|.$locale->text('Sales Invoice').qq|">
677 if ($myconfig{acs} !~ /AR--Vendor Invoice/) {
679 <input class=submit type=submit name=action value="|.$locale->text('Vendor Invoice').qq|">
684 if ($form->{type} eq 'sales_order') {
685 if ($myconfig{acs} !~ /Quotations--RFQ/) {
687 <input class=submit type=submit name=action value="|.$locale->text('Quotation').qq|">
692 if ($form->{type} eq 'purchase_order') {
693 if ($myconfig{acs} !~ /Quotations--RFQ/) {
695 <input class=submit type=submit name=action value="|.$locale->text('RFQ').qq|">
700 if ($form->{type} eq 'sales_quotation') {
701 if ($myconfig{acs} !~ /Order Entry--Sales Order/) {
703 <input class=submit type=submit name=action value="|.$locale->text('Sales Order').qq|">
708 if ($myconfig{acs} !~ /Order Entry--Purchase Order/) {
709 if ($form->{type} eq 'request_quotation') {
711 <input class=submit type=submit name=action value="|.$locale->text('Purchase Order').qq|">
718 if ($form->{menubar}) {
719 require "$form->{path}/menu.pl";
725 <input type=hidden name=rowcount value=$form->{rowcount}>
727 <input name=callback type=hidden value="$form->{callback}">
729 <input type=hidden name=path value=$form->{path}>
730 <input type=hidden name=login value=$form->{login}>
731 <input type=hidden name=sessionid value=$form->{sessionid}>
746 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate);
748 &check_name($form->{vc});
752 $buysell = 'sell' if ($form->{vc} eq 'vendor');
753 $form->{exchangerate} = $exchangerate if ($form->{forex} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, $buysell)));
755 my $i = $form->{rowcount};
756 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
758 foreach $item (qw(partsgroup projectnumber)) {
759 $form->{"select$item"} = $form->unescape($form->{"select$item"}) if $form->{"select$item"};
762 if (($form->{"partnumber_$i"} eq "") && ($form->{"description_$i"} eq "") && ($form->{"partsgroup_$i"} eq "")) {
764 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
769 if ($form->{type} eq 'purchase_order' || $form->{type} eq 'request_quotation') {
770 IR->retrieve_item(\%myconfig, \%$form);
772 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
773 IS->retrieve_item(\%myconfig, \%$form);
776 $rows = scalar @{ $form->{item_list} };
778 $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{discount} * 100);
781 $form->{"qty_$i"} = 1;
782 if ($form->{type} !~ /_quotation/) {
783 $form->{"reqdate_$i"} = $form->{reqdate} unless $form->{"reqdate_$i"};
793 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
795 map { $form->{item_list}[$i]{$_} = $form->quote($form->{item_list}[$i]{$_}) } qw(partnumber description unit);
796 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
798 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
800 ($dec) = ($s =~ /\.(\d+)/);
802 $decimalplaces = ($dec > 2) ? $dec : 2;
805 $form->{"sellprice_$i"} = $sellprice;
807 # if there is an exchange rate adjust prices
808 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
809 $form->{"sellprice_$i"} /= $exchangerate;
812 map { $form->{"${_}_$i"} /= $exchangerate } qw(listprice lastcost);
814 $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100);
815 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
816 map { $form->{"${_}_base"} += $amount } (split / /, $form->{"taxaccounts_$i"});
817 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{taxaccounts} if !$form->{taxincluded};
819 $form->{creditremaining} -= $amount;
821 map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice lastcost);
823 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
829 # ok, so this is a new part
830 # ask if it is a part or service item
832 if ($form->{"partsgroup_$i"} && ($form->{"partsnumber_$i"} eq "") && ($form->{"description_$i"} eq "")) {
834 $form->{"discount_$i"} = "";
838 $form->{"id_$i"} = 0;
839 $form->{"unit_$i"} = $locale->text('ea');
840 $form->{"reqdate_$i"} = $form->{reqdate} if $form->{type} !~ /_quotation/;
854 if ($form->{type} eq 'purchase_order') {
855 $form->{title} = $locale->text('Purchase Orders');
856 $form->{vc} = 'vendor';
857 $ordlabel = $locale->text('Order Number');
858 $ordnumber = 'ordnumber';
859 $employee = $locale->text('Employee');
861 if ($form->{type} eq 'request_quotation') {
862 $form->{title} = $locale->text('Request for Quotations');
863 $form->{vc} = 'vendor';
864 $ordlabel = $locale->text('RFQ Number');
865 $ordnumber = 'quonumber';
866 $employee = $locale->text('Employee');
868 if ($form->{type} eq 'receive_order') {
869 $form->{title} = $locale->text('Receive Merchandise');
870 $form->{vc} = 'vendor';
871 $ordlabel = $locale->text('Order Number');
872 $ordnumber = 'ordnumber';
873 $employee = $locale->text('Employee');
875 if ($form->{type} eq 'sales_order') {
876 $form->{title} = $locale->text('Sales Orders');
877 $form->{vc} = 'customer';
878 $ordlabel = $locale->text('Order Number');
879 $ordnumber = 'ordnumber';
880 $employee = $locale->text('Salesperson');
882 if ($form->{type} eq 'ship_order') {
883 $form->{title} = $locale->text('Ship Merchandise');
884 $form->{vc} = 'customer';
885 $ordlabel = $locale->text('Order Number');
886 $ordnumber = 'ordnumber';
887 $employee = $locale->text('Salesperson');
891 if ($form->{type} eq 'sales_quotation') {
892 $form->{title} = $locale->text('Quotations');
893 $form->{vc} = 'customer';
894 $ordlabel = $locale->text('Quotation Number');
895 $ordnumber = 'quonumber';
896 $employee = $locale->text('Employee');
900 <td><input name="l_manager" class=checkbox type=checkbox value=Y> |.$locale->text('Manager').qq|</td>|;
902 if ($form->{type} =~ /(ship|receive)_order/) {
903 OE->get_warehouses(\%myconfig, \%$form);
908 if (@{ $form->{all_warehouses} }) {
909 $form->{selectwarehouse} = "<option>\n";
910 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
912 map { $form->{selectwarehouse} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_warehouses} });
916 <th align=right>|.$locale->text('Warehouse').qq|</th>
917 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
918 <input type=hidden name=selectwarehouse value="|.
919 $form->escape($form->{selectwarehouse},1).qq|">
926 # setup vendor / customer selection
927 $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
929 map { $vc .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| } @{ $form->{"all_$form->{vc}"} };
931 $vclabel = ucfirst $form->{vc};
932 $vclabel = $locale->text($vclabel);
934 # $locale->text('Vendor')
935 # $locale->text('Customer')
937 $vc = ($vc) ? qq|<select name=$form->{vc}><option>\n$vc</select>| : qq|<input name=$form->{vc} size=35>|;
940 if (@{ $form->{all_departments} }) {
941 $form->{selectdepartment} = "<option>\n";
943 map { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_departments} });
948 <th align=right nowrap>|.$locale->text('Department').qq|</th>
949 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
951 | if $form->{selectdepartment};
953 if ($form->{type} !~ /(ship|receive)_order/) {
956 <td><input name="open" class=checkbox type=checkbox value=1 checked> |.$locale->text('Open').qq|</td>
957 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |.$locale->text('Closed').qq|</td>
963 <input type=hidden name="open" value=1>
969 $form->{selectaccountingyear} = "<option>\n";
970 map { $form->{selectaccountingyear} .= qq|<option>$_\n| } @{ $form->{all_years} };
971 $form->{selectaccountingmonth} = "<option>\n";
972 map { $form->{selectaccountingmonth} .= qq|<option value=$_>|.$locale->text($form->{all_month}{$_}).qq|\n| } sort keys %{ $form->{all_month} };
976 <th align=right>|.$locale->text('Period').qq|</th>
978 <select name=month>$form->{selectaccountingmonth}</select>
979 <select name=year>$form->{selectaccountingyear}</select>
980 <input name=interval class=radio type=radio value=0 checked>|.$locale->text('Current').qq|
981 <input name=interval class=radio type=radio value=1>|.$locale->text('Month').qq|
982 <input name=interval class=radio type=radio value=3>|.$locale->text('Quarter').qq|
983 <input name=interval class=radio type=radio value=12>|.$locale->text('Year').qq|
994 <form method=post action=$form->{script}>
998 <th class=listtop>$form->{title}</th>
1000 <tr height="5"></tr>
1005 <th align=right>$vclabel</th>
1006 <td colspan=3>$vc</td>
1011 <th align=right>$ordlabel</th>
1012 <td colspan=3><input name="$ordnumber" size=20></td>
1015 <th align=right>|.$locale->text('Ship via').qq|</th>
1016 <td colspan=3><input name="shipvia" size=40></td>
1019 <th align=right>|.$locale->text('From').qq|</th>
1020 <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
1021 <th align=right>|.$locale->text('To').qq|</th>
1022 <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
1024 <input type=hidden name=sort value=transdate>
1027 <th align=right>|.$locale->text('Include in Report').qq|</th>
1032 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1033 |.$locale->text('ID').qq|</td>
1034 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1035 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |.$locale->text('Date').qq|</td>
1036 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |.$locale->text('Required by').qq|</td>
1039 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1040 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1042 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |.$locale->text('Ship via').qq|</td>
1045 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |.$locale->text('Amount').qq|</td>
1046 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |.$locale->text('Tax').qq|</td>
1047 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |.$locale->text('Total').qq|</td>
1048 <td><input name="l_curr" class=checkbox type=checkbox value=Y checked> |.$locale->text('Currency').qq|</td>
1051 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |.$locale->text('Subtotal').qq|</td>
1059 <tr><td colspan=4><hr size=3 noshade></td></tr>
1063 <input type=hidden name=nextsub value=transactions>
1065 <input type=hidden name=path value=$form->{path}>
1066 <input type=hidden name=login value=$form->{login}>
1067 <input type=hidden name=sessionid value=$form->{sessionid}>
1069 <input type=hidden name=vc value=$form->{vc}>
1070 <input type=hidden name=type value=$form->{type}>
1072 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
1084 # split vendor / customer
1085 ($form->{$form->{vc}}, $form->{"$form->{vc}_id"}) = split(/--/, $form->{$form->{vc}});
1087 $ordnumber = ($form->{type} =~ /_order/) ? 'ordnumber' : 'quonumber';
1089 OE->transactions(\%myconfig, \%$form);
1091 $number = $form->escape($form->{$ordnumber});
1092 $name = $form->escape($form->{$form->{vc}});
1093 $department = $form->escape($form->{department});
1094 $warehouse = $form->escape($form->{warehouse});
1095 $shipvia = $form->escape($form->{shipvia});
1098 $href = qq|$form->{script}?oldsort=$form->{oldsort}&direction=$form->{direction}&path=$form->{path}&action=transactions&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&sessionid=$form->{sessionid}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}&$ordnumber=$number&$form->{vc}=$name--$form->{"$form->{vc}_id"}&department=$department&warehouse=$warehouse&shipvia=$shipvia|;
1100 # construct callback
1101 $number = $form->escape($form->{$ordnumber},1);
1102 $name = $form->escape($form->{$form->{vc}},1);
1103 $department = $form->escape($form->{department},1);
1104 $warehouse = $form->escape($form->{warehouse},1);
1105 $shipvia = $form->escape($form->{shipvia},1);
1108 $form->sort_order();
1110 $callback = qq|$form->{script}?oldsort=$form->{oldsort}&direction=$form->{direction}&path=$form->{path}&action=transactions&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&sessionid=$form->{sessionid}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}&$ordnumber=$number&$form->{vc}=$name--$form->{"$form->{vc}_id"}&department=$department&warehouse=$warehouse&shipvia=$shipvia|;
1112 @columns = $form->sort_columns("transdate", "reqdate", "id", "$ordnumber", "name", "netamount", "tax", "amount", "curr", "employee", "manager", "shipvia", "open", "closed");
1114 $form->{l_open} = $form->{l_closed} = "Y" if ($form->{open} && $form->{closed}) ;
1116 foreach $item (@columns) {
1117 if ($form->{"l_$item"} eq "Y") {
1118 push @column_index, $item;
1120 if ($form->{l_curr} && $item =~ /(amount|tax)/) {
1121 push @column_index, "fx_$item";
1124 # add column to href and callback
1125 $callback .= "&l_$item=Y";
1126 $href .= "&l_$item=Y";
1130 if ($form->{l_subtotal} eq 'Y') {
1131 $callback .= "&l_subtotal=Y";
1132 $href .= "&l_subtotal=Y";
1137 if ($form->{vc} eq 'vendor') {
1138 if ($form->{type} eq 'receive_order') {
1139 $form->{title} = $locale->text('Receive Merchandise');
1140 } elsif ($form->{type} eq 'purchase_order') {
1141 $form->{title} = $locale->text('Purchase Orders');
1143 if ($myconfig{acs} !~ /Order Entry--Order Entry/) {
1144 $button{'Order Entry--Purchase Order'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Purchase Order').qq|"> |;
1145 $button{'Order Entry--Sales Order'}{order} = $i++;
1149 $form->{title} = $locale->text('Request for Quotations');
1151 if ($myconfig{acs} !~ /Quotations--Quotations/) {
1152 $button{'Quotations--RFQ'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('RFQ ').qq|"> |;
1153 $button{'Quotations--RFQ'}{order} = $i++;
1157 $name = $locale->text('Vendor');
1158 $employee = $locale->text('Employee');
1160 if ($form->{vc} eq 'customer') {
1161 if ($form->{type} eq 'sales_order') {
1162 $form->{title} = $locale->text('Sales Orders');
1163 $employee = $locale->text('Salesperson');
1165 if ($myconfig{acs} !~ /Order Entry--Order Entry/) {
1166 $button{'Order Entry--Sales Order'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Sales Order').qq|"> |;
1167 $button{'Order Entry--Sales Order'}{order} = $i++;
1170 } elsif ($form->{type} eq 'ship_order') {
1171 $form->{title} = $locale->text('Ship Merchandise');
1172 $employee = $locale->text('Salesperson');
1174 $form->{title} = $locale->text('Quotations');
1175 $employee = $locale->text('Employee');
1177 if ($myconfig{acs} !~ /Quotations--Quotations/) {
1178 $button{'Quotations--Quotation'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Quotation ').qq|"> |;
1179 $button{'Quotations--Quotation'}{order} = $i++;
1183 $name = $locale->text('Customer');
1186 foreach $item (split /;/, $myconfig{acs}) {
1187 delete $button{$item};
1190 $column_header{id} = qq|<th><a class=listheading href=$href&sort=id>|.$locale->text('ID').qq|</a></th>|;
1191 $column_header{transdate} = qq|<th><a class=listheading href=$href&sort=transdate>|.$locale->text('Date').qq|</a></th>|;
1192 $column_header{reqdate} = qq|<th><a class=listheading href=$href&sort=reqdate>|.$locale->text('Required by').qq|</a></th>|;
1193 $column_header{ordnumber} = qq|<th><a class=listheading href=$href&sort=ordnumber>|.$locale->text('Order').qq|</a></th>|;
1194 $column_header{quonumber} = qq|<th><a class=listheading href=$href&sort=quonumber>|.$locale->text('Quotation').qq|</a></th>|;
1195 $column_header{name} = qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1196 $column_header{netamount} = qq|<th class=listheading>|.$locale->text('Amount').qq|</th>|;
1197 $column_header{tax} = qq|<th class=listheading>|.$locale->text('Tax').qq|</th>|;
1198 $column_header{amount} = qq|<th class=listheading>|.$locale->text('Total').qq|</th>|;
1199 $column_header{curr} = qq|<th><a class=listheading href=$href&sort=curr>|.$locale->text('Curr').qq|</a></th>|;
1200 $column_header{shipvia} = qq|<th><a class=listheading href=$href&sort=shipvia>|.$locale->text('Ship via').qq|</a></th>|;
1201 $column_header{open} = qq|<th class=listheading>|.$locale->text('O').qq|</th>|;
1202 $column_header{closed} = qq|<th class=listheading>|.$locale->text('C').qq|</th>|;
1204 $column_header{employee} = qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1205 $column_header{manager} = qq|<th><a class=listheading href=$href&sort=manager>|.$locale->text('Manager').qq|</a></th>|;
1207 map { $column_header{"fx_$_"} = "<th> </th>" } qw(amount tax netamount);
1209 if ($form->{$form->{vc}}) {
1210 $option = $locale->text(ucfirst $form->{vc});
1211 $option .= " : $form->{$form->{vc}}";
1213 if ($form->{warehouse}) {
1214 ($warehouse) = split /--/, $form->{warehouse};
1215 $option .= "\n<br>" if ($option);
1216 $option .= $locale->text('Warehouse');
1217 $option .= " : $warehouse";
1219 if ($form->{department}) {
1220 $option .= "\n<br>" if ($option);
1221 ($department) = split /--/, $form->{department};
1222 $option .= $locale->text('Department')." : $department";
1224 if ($form->{transdatefrom}) {
1225 $option .= "\n<br>".$locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
1227 if ($form->{transdateto}) {
1228 $option .= "\n<br>".$locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1);
1230 if ($form->{open}) {
1231 $option .= "\n<br>" if ($option);
1232 $option .= $locale->text('Open');
1234 if ($form->{closed}) {
1235 $option .= "\n<br>" if ($option);
1236 $option .= $locale->text('Closed');
1246 <th class=listtop>$form->{title}</th>
1248 <tr height="5"></tr>
1255 <tr class=listheading>|;
1257 map { print "\n$column_header{$_}" } @column_index;
1263 # add sort and escape callback
1264 $callback .= "&sort=$form->{sort}";
1265 $form->{callback} = $callback;
1266 $callback = $form->escape($callback);
1269 $direction = ($form->{direction} eq 'ASC') ? "ASC" : "DESC";
1270 $href =~ s/&direction=(\w+)&/&direction=$direction&/;
1272 if (@{ $form->{OE} }) {
1273 $sameitem = $form->{OE}->[0]->{$form->{sort}};
1277 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1279 $warehouse = $form->escape($form->{warehouse});
1281 foreach $oe (@{ $form->{OE} }) {
1283 if ($form->{l_subtotal} eq 'Y') {
1284 if ($sameitem ne $oe->{$form->{sort}}) {
1286 $sameitem = $oe->{$form->{sort}};
1290 if ($form->{l_curr}) {
1291 map { $oe->{"fx_$_"} = $oe->{$_} } (qw(netamount amount));
1292 $oe->{fx_tax} = $oe->{fx_amount} - $oe->{fx_netamount};
1293 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1295 map { $column_data{"fx_$_"} = "<td align=right>".$form->format_amount(\%myconfig, $oe->{"fx_$_"}, 2, " ")."</td>" } qw(netamount amount);
1296 $column_data{fx_tax} = "<td align=right>".$form->format_amount(\%myconfig, $oe->{fx_amount} - $oe->{fx_netamount}, 2, " ")."</td>";
1298 $totalfxnetamount += $oe->{fx_netamount};
1299 $totalfxamount += $oe->{fx_amount};
1301 $subtotalfxnetamount += $oe->{fx_netamount};
1302 $subtotalfxamount += $oe->{fx_amount};
1305 map { $column_data{$_} = "<td align=right>".$form->format_amount(\%myconfig, $oe->{$_}, 2, " ")."</td>" } qw(netamount amount);
1306 $column_data{tax} = "<td align=right>".$form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount}, 2, " ")."</td>";
1308 $totalnetamount += $oe->{netamount};
1309 $totalamount += $oe->{amount};
1311 $subtotalnetamount += $oe->{netamount};
1312 $subtotalamount += $oe->{amount};
1315 $column_data{id} = "<td>$oe->{id}</td>";
1316 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1317 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1319 $column_data{$ordnumber} = "<td><a href=oe.pl?path=$form->{path}&action=$action&type=$form->{type}&id=$oe->{id}&warehouse=$warehouse&vc=$form->{vc}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$oe->{$ordnumber}</a></td>";
1321 $name = $form->escape($oe->{name});
1322 $column_data{name} = qq|<td><a href=$href&$form->{vc}=$name--$oe->{"$form->{vc}_id"}&sort=$form->{sort}>$oe->{name}</a></td>|;
1324 map { $column_data{$_} = "<td>$oe->{$_} </td>" } qw(employee manager shipvia curr);
1326 if ($oe->{closed}) {
1327 $column_data{closed} = "<td align=center>*</td>";
1328 $column_data{open} = "<td> </td>";
1330 $column_data{closed} = "<td> </td>";
1331 $column_data{open} = "<td align=center>*</td>";
1336 <tr class=listrow$i>";
1338 map { print "\n$column_data{$_}" } @column_index;
1346 if ($form->{l_subtotal} eq 'Y') {
1352 <tr class=listtotal>|;
1354 map { $column_data{$_} = "<td> </td>" } @column_index;
1356 $column_data{netamount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalnetamount, 2, " ")."</th>";
1357 $column_data{tax} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount - $totalnetamount, 2, " ")."</th>";
1358 $column_data{amount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount, 2, " ")."</th>";
1360 if ($form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal}) {
1361 $column_data{fx_netamount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxnetamount, 2, " ")."</th>";
1362 $column_data{fx_tax} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount - $totalfxnetamount, 2, " ")."</th>";
1363 $column_data{fx_amount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount, 2, " ")."</th>";
1366 map { print "\n$column_data{$_}" } @column_index;
1374 <td><hr size=3 noshade></td>
1379 <form method=post action=$form->{script}>
1381 <input name=callback type=hidden value="$form->{callback}">
1383 <input type=hidden name=type value=$form->{type}>
1385 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
1386 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
1387 <input type=hidden name=vc value=$form->{vc}>
1389 <input type=hidden name=path value=$form->{path}>
1390 <input type=hidden name=login value=$form->{login}>
1391 <input type=hidden name=sessionid value=$form->{sessionid}>
1394 if ($form->{type} !~ /(ship|receive)_order/) {
1395 foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
1396 print $item->{code};
1400 if ($form->{menubar}) {
1401 require "$form->{path}/menu.pl";
1418 map { $column_data{$_} = "<td> </td>" } @column_index;
1420 $column_data{netamount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")."</th>";
1421 $column_data{tax} = "<td class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount, 2, " ")."</th>";
1422 $column_data{amount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount, 2, " ")."</th>";
1424 if ($form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal}) {
1425 $column_data{fx_netamount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxnetamount, 2, " ")."</th>";
1426 $column_data{fx_tax} = "<td class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxamount - $subtotalfxnetamount, 2, " ")."</th>";
1427 $column_data{fx_amount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxamount, 2, " ")."</th>";
1430 $subtotalnetamount = 0;
1431 $subtotalamount = 0;
1433 $subtotalfxnetamount = 0;
1434 $subtotalfxamount = 0;
1437 <tr class=listsubtotal>
1440 map { print "\n$column_data{$_}" } @column_index;
1451 if ($form->{type} =~ /_order$/) {
1452 $form->isblank("transdate", $locale->text('Order Date missing!'));
1454 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1457 $msg = ucfirst $form->{vc};
1458 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1460 # $locale->text('Customer missing!');
1461 # $locale->text('Vendor missing!');
1463 $form->isblank("exchangerate", $locale->text('Exchange rate missing!')) if ($form->{currency} ne $form->{defaultcurrency});
1467 # if the name changed get new values
1468 if (&check_name($form->{vc})) {
1474 # this is for the internal notes section for the [email] Subject
1475 if ($form->{type} =~ /_order$/) {
1476 if ($form->{type} eq 'sales_order') {
1477 $form->{label} = $locale->text('Sales Order');
1479 $numberfld = "sonumber";
1480 $ordnumber = "ordnumber";
1482 $form->{label} = $locale->text('Purchase Order');
1484 $numberfld = "ponumber";
1485 $ordnumber = "ordnumber";
1488 $err = $locale->text('Cannot save order!');
1491 if ($form->{type} eq 'sales_quotation') {
1492 $form->{label} = $locale->text('Quotation');
1494 $numberfld = "sqnumber";
1495 $ordnumber = "quonumber";
1497 $form->{label} = $locale->text('Request for Quotation');
1499 $numberfld = "rfqnumber";
1500 $ordnumber = "quonumber";
1503 $err = $locale->text('Cannot save quotation!');
1508 $form->{id} = 0 if $form->{saveasnew};
1510 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld) unless $form->{$ordnumber};
1512 $form->redirect($locale->text('Order saved!')) if (OE->save(\%myconfig, \%$form));
1518 sub print_and_save {
1520 $form->error($locale->text('Select postscript or PDF!')) if $form->{format} !~ /(postscript|pdf)/;
1521 $form->error($locale->text('Select Printer or Queue!')) if $form->{media} eq 'screen';
1523 $old_form = new Form;
1524 $form->{display_form} = "save";
1525 map { $old_form->{$_} = $form->{$_} } keys %$form;
1526 $old_form->{rowcount}++;
1528 &print_form($old_form);
1537 if ($form->{type} =~ /_order$/) {
1538 $msg = $locale->text('Are you sure you want to delete Order Number');
1539 $ordnumber = 'ordnumber';
1541 $msg = $locale->text('Are you sure you want to delete Quotation Number');
1542 $ordnumber = 'quonumber';
1548 <form method=post action=$form->{script}>
1551 # delete action variable
1552 map { delete $form->{$_} } qw(action header);
1557 <h2 class=confirm>|.$locale->text('Confirm!').qq|</h2>
1559 <h4>$msg $form->{$ordnumber}</h4>
1561 <input name=action class=submit type=submit value="|.$locale->text('Yes').qq|">
1575 if ($form->{type} =~ /_order$/) {
1576 $msg = $locale->text('Order deleted!');
1577 $err = $locale->text('Cannot delete order!');
1579 $msg = $locale->text('Quotation deleted!');
1580 $err = $locale->text('Cannot delete quotation!');
1583 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
1589 sub vendor_invoice { &invoice };
1590 sub sales_invoice { &invoice };
1594 if ($form->{type} =~ /_order$/) {
1595 $form->isblank("ordnumber", $locale->text('Order Number missing!'));
1596 $form->isblank("transdate", $locale->text('Order Date missing!'));
1599 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
1600 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1601 $form->{ordnumber} = "";
1604 # if the name changed get new values
1605 if (&check_name($form->{vc})) {
1611 if ($form->{type} =~ /_order/ && $form->{currency} ne $form->{defaultcurrency}) {
1612 # check if we need a new exchangerate
1613 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
1615 $orddate = $form->current_date(\%myconfig);
1616 $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate, $buysell);
1618 if (!$exchangerate) {
1619 &backorder_exchangerate($orddate, $buysell);
1625 # close orders/quotations
1626 $form->{closed} = 1;
1628 OE->save(\%myconfig, \%$form);
1630 $form->{transdate} = $form->current_date(\%myconfig);
1631 $form->{duedate} = $form->current_date(\%myconfig, $form->{transdate}, $form->{terms} * 1);
1634 $form->{closed} = 0;
1635 $form->{rowcount}--;
1636 $form->{shipto} = 1;
1639 if ($form->{type} =~ /_order$/) {
1640 $form->{exchangerate} = $exchangerate;
1645 if ($form->{type} eq 'purchase_order' || $form->{type} eq 'request_quotation') {
1646 $form->{title} = $locale->text('Add Vendor Invoice');
1647 $form->{script} = 'ir.pl';
1651 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1652 $form->{title} = $locale->text('Add Sales Invoice');
1653 $form->{script} = 'is.pl';
1658 map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued);
1659 $form->{$form->{vc}} =~ s/--.*//g;
1660 $form->{type} = "invoice";
1663 $locale = new Locale "$myconfig{countrycode}", "$script";
1665 require "$form->{path}/$form->{script}";
1667 # customized scripts
1668 if (-f "$form->{path}/custom_$form->{script}") {
1669 eval { require "$form->{path}/custom_$form->{script}"; };
1672 # customized scripts for login
1673 if (-f "$form->{path}/$form->{login}_$form->{script}") {
1674 eval { require "$form->{path}/$form->{login}_$form->{script}"; };
1677 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1678 map { $temp{$_} = $form->{$_} } qw(currency oldcurrency employee department intnotes notes);
1682 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1686 map { $form->{$_} = $temp{$_} } keys %temp;
1688 $form->{exchangerate} = "";
1689 $form->{forex} = "";
1690 $form->{exchangerate} = $exchangerate if ($form->{forex} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, $buysell)));
1692 for $i (1 .. $form->{rowcount}) {
1693 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"};
1694 map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}) } qw(qty sellprice discount);
1697 map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued audittrail);
1705 sub backorder_exchangerate {
1706 my ($orddate, $buysell) = @_;
1713 <form method=post action=$form->{script}>
1716 # delete action variable
1717 map { delete $form->{$_} } qw(action header exchangerate);
1721 $form->{title} = $locale->text('Add Exchange Rate');
1725 <input type=hidden name=path value=$form->{path}>
1726 <input type=hidden name=login value=$form->{login}>
1727 <input type=hidden name=sessionid value=$form->{sessionid}>
1729 <input type=hidden name=exchangeratedate value=$orddate>
1730 <input type=hidden name=buysell value=$buysell>
1733 <tr><th class=listtop>$form->{title}</th></tr>
1734 <tr height="5"></tr>
1739 <th align=right>|.$locale->text('Currency').qq|</th>
1740 <td>$form->{currency}</td>
1743 <th align=right>|.$locale->text('Date').qq|</th>
1747 <th align=right>|.$locale->text('Exchange Rate').qq|</th>
1748 <td><input name=exchangerate size=11></td>
1758 <input type=hidden name=nextsub value=save_exchangerate>
1760 <input name=action class=submit type=submit value="|.$locale->text('Continue').qq|">
1772 sub save_exchangerate {
1774 $form->isblank("exchangerate", $locale->text('Exchange rate missing!'));
1775 $form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate});
1776 $form->save_exchangerate(\%myconfig, $form->{currency}, $form->{exchangeratedate}, $form->{exchangerate}, $form->{buysell});
1783 sub create_backorder {
1785 $form->{shipped} = 1;
1787 # figure out if we need to create a backorder
1788 # items aren't saved if qty != 0
1791 for $i (1 .. $form->{rowcount}) {
1792 ($dec) = ($form->{"qty_$i"} =~ /\.(\d+)/);
1794 $dec1 = ($dec > $dec1) ? $dec : $dec1;
1796 ($dec) = ($form->{"ship_$i"} =~ /\.(\d+)/);
1798 $dec2 = ($dec > $dec2) ? $dec : $dec2;
1800 $totalqty += $qty = $form->{"qty_$i"};
1801 $totalship += $ship = $form->{"ship_$i"};
1803 $form->{"qty_$i"} = $qty - $ship;
1806 $totalqty = $form->round_amount($totalqty, $dec1);
1807 $totalship = $form->round_amount($totalship, $dec2);
1809 if ($totalship == 0) {
1810 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
1811 $form->{ordtotal} = 0;
1812 $form->{shipped} = 0;
1816 if ($totalqty == $totalship) {
1817 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
1818 $form->{ordtotal} = 0;
1822 @flds = qw(partnumber sku description qty oldqty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup reqdate pricematrix);
1824 for $i (1 .. $form->{rowcount}) {
1825 map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}) } qw(qty sellprice discount);
1827 $form->{"oldship_$i"} = $form->{"ship_$i"};
1828 $form->{"ship_$i"} = 0;
1832 map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued audittrail);
1834 OE->save(\%myconfig, \%$form);
1836 # rebuild rows for invoice
1840 for $i (1 .. $form->{rowcount}) {
1841 $form->{"qty_$i"} = $form->{"oldship_$i"};
1842 $form->{"oldqty_$i"} = $form->{"qty_$i"};
1844 $form->{"orderitems_id_$i"} = "";
1846 if ($form->{"qty_$i"}) {
1849 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1854 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
1855 $form->{rowcount} = $count;
1863 $form->{saveasnew} = 1;
1864 $form->{closed} = 0;
1865 map { delete $form->{$_} } qw(printed emailed queued);
1878 OE->get_warehouses(\%myconfig, \%$form);
1881 if (@{ $form->{all_warehouses} }) {
1882 $form->{selectwarehouse} = "<option>\n";
1884 map { $form->{selectwarehouse} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_warehouses} });
1886 if ($form->{warehouse}) {
1887 $form->{selectwarehouse} = qq|<option value="$form->{warehouse}">|;
1888 $form->{warehouse} =~ s/--.*//;
1889 $form->{selectwarehouse} .= $form->{warehouse};
1893 $form->{shippingdate} = $form->current_date(\%myconfig);
1894 $form->{"$form->{vc}"} =~ s/--.*//;
1895 $form->{"old$form->{vc}"} = qq|$form->{"$form->{vc}"}--$form->{"$form->{vc}_id"}|;
1900 foreach $key (keys %$form) {
1901 if ($key =~ /_1$/) {
1907 for $i (1 .. $form->{rowcount}) {
1908 # undo formatting from prepare_order
1909 map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(qty ship);
1910 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
1911 if (abs($n) > 0 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
1912 $form->{"ship_$i"} = "";
1913 $form->{"serialnumber_$i"} = "";
1918 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1923 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
1924 $form->{rowcount} = $count;
1926 &display_ship_receive;
1931 sub display_ship_receive {
1933 $vclabel = ucfirst $form->{vc};
1934 $vclabel = $locale->text($vclabel);
1936 $form->{rowcount}++;
1938 if ($form->{vc} eq 'customer') {
1939 $form->{title} = $locale->text('Ship Merchandise');
1940 $shipped = $locale->text('Shipping Date');
1942 $form->{title} = $locale->text('Receive Merchandise');
1943 $shipped = $locale->text('Date Received');
1946 # set option selected
1947 foreach $item (warehouse, employee) {
1948 $form->{"select$item"} = $form->unescape($form->{"select$item"});
1949 $form->{"select$item"} =~ s/ selected//;
1950 $form->{"select$item"} =~ s/(<option value="\Q$form->{$item}\E")/$1 selected/;
1956 <th align=right>|.$locale->text('Warehouse').qq|</th>
1957 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
1958 <input type=hidden name=selectwarehouse value="|.
1959 $form->escape($form->{selectwarehouse},1).qq|">
1961 | if $form->{selectwarehouse};
1965 <th align=right nowrap>|.$locale->text('Contact').qq|</th>
1966 <td><select name=employee>$form->{selectemployee}</select></td>
1967 <input type=hidden name=selectemployee value="|.
1968 $form->escape($form->{selectemployee},1).qq|">
1978 <form method=post action=$form->{script}>
1980 <input type=hidden name=id value=$form->{id}>
1982 <input type=hidden name=display_form value=display_ship_receive>
1984 <input type=hidden name=type value=$form->{type}>
1985 <input type=hidden name=media value=$form->{media}>
1986 <input type=hidden name=format value=$form->{format}>
1988 <input type=hidden name=queued value="$form->{queued}">
1989 <input type=hidden name=printed value="$form->{printed}">
1990 <input type=hidden name=emailed value="$form->{emailed}">
1992 <input type=hidden name=vc value=$form->{vc}>
1993 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
1997 <th class=listtop>$form->{title}</th>
1999 <tr height="5"></tr>
2002 <table width="100%">
2007 <th align=right>$vclabel</th>
2008 <td colspan=3>$form->{$form->{vc}}</td>
2009 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2010 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2014 <th align=right>|.$locale->text('Shipping Point').qq|</th>
2016 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2019 <th align=right>|.$locale->text('Ship via').qq|</th>
2021 <input name=shipvia size=35 value="$form->{shipvia}">
2030 <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
2031 <td>$form->{ordnumber}</td>
2032 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2035 <th align=right nowrap>|.$locale->text('Order Date').qq|</th>
2036 <td>$form->{transdate}</td>
2037 <input type=hidden name=transdate value=$form->{transdate}>
2040 <th align=right nowrap>$shipped</th>
2041 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2050 <!-- shipto are in hidden variables -->
2052 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2053 <input type=hidden name=shiptoaddress1 value="$form->{shiptoaddress1}">
2054 <input type=hidden name=shiptoaddress2 value="$form->{shiptoaddress2}">
2055 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2056 <input type=hidden name=shiptostate value="$form->{shiptostate}">
2057 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2058 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2059 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2060 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2061 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2062 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2064 <!-- email variables -->
2065 <input type=hidden name=message value="$form->{message}">
2066 <input type=hidden name=email value="$form->{email}">
2067 <input type=hidden name=subject value="$form->{subject}">
2068 <input type=hidden name=cc value="$form->{cc}">
2069 <input type=hidden name=bcc value="$form->{bcc}">
2073 @column_index = qw(partnumber);
2075 if ($form->{type} eq "ship_order") {
2076 $column_data{ship} = qq|<th class=listheading>|.$locale->text('Ship').qq|</th>|;
2078 if ($form->{type} eq "receive_order") {
2079 $column_data{ship} = qq|<th class=listheading>|.$locale->text('Recd').qq|</th>|;
2080 $column_data{sku} = qq|<th class=listheading>|.$locale->text('SKU').qq|</th>|;
2081 push @column_index, "sku";
2083 push @column_index, qw(description qty ship unit bin serialnumber);
2085 my $colspan = $#column_index + 1;
2087 $column_data{partnumber} = qq|<th class=listheading nowrap>|.$locale->text('Number').qq|</th>|;
2088 $column_data{description} = qq|<th class=listheading nowrap>|.$locale->text('Description').qq|</th>|;
2089 $column_data{qty} = qq|<th class=listheading nowrap>|.$locale->text('Qty').qq|</th>|;
2090 $column_data{unit} = qq|<th class=listheading nowrap>|.$locale->text('Unit').qq|</th>|;
2091 $column_data{bin} = qq|<th class=listheading nowrap>|.$locale->text('Bin').qq|</th>|;
2092 $column_data{serialnumber} = qq|<th class=listheading nowrap>|.$locale->text('Serial No.').qq|</th>|;
2098 <tr class=listheading>|;
2100 map { print "\n$column_data{$_}" } @column_index;
2107 for $i (1 .. $form->{rowcount} - 1) {
2110 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2112 map { $form->{"${_}_$i"} = $form->quote($form->{"${_}_$i"}) } qw(partnumber sku description unit bin serialnumber);
2114 $description = $form->{"description_$i"};
2115 $description =~ s/
\r/<br>/g;
2117 $column_data{partnumber} = qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2118 $column_data{sku} = qq|<td>$form->{"sku_$i"}<input type=hidden name="sku_$i" value="$form->{"sku_$i"}"></td>|;
2119 $column_data{description} = qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2120 $column_data{qty} = qq|<td align=right>|.$form->format_amount(\%myconfig, $form->{"qty_$i"}).qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2121 $column_data{ship} = qq|<td align=right><input name="ship_$i" size=5 value=|.$form->format_amount(\%myconfig, $form->{"ship_$i"}).qq|></td>|;
2122 $column_data{unit} = qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2123 $column_data{bin} = qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2125 $column_data{serialnumber} = qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2130 map { print "\n$column_data{$_}" } @column_index;
2135 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2136 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2137 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2138 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2149 <td><hr size=3 noshade></td>
2155 $form->{copies} = 1;
2164 <input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
2165 <input class=submit type=submit name=action value="|.$locale->text('Print').qq|">
2168 if ($form->{type} eq 'ship_order') {
2170 <input class=submit type=submit name=action value="|.$locale->text('Ship to').qq|">
2171 <input class=submit type=submit name=action value="|.$locale->text('E-mail').qq|">
2177 <input class=submit type=submit name=action value="|.$locale->text('Done').qq|">
2180 if ($form->{menubar}) {
2181 require "$form->{path}/menu.pl";
2187 <input type=hidden name=rowcount value=$form->{rowcount}>
2189 <input name=callback type=hidden value="$form->{callback}">
2191 <input type=hidden name=path value=$form->{path}>
2192 <input type=hidden name=login value=$form->{login}>
2193 <input type=hidden name=sessionid value=$form->{sessionid}>
2207 if ($form->{type} eq 'ship_order') {
2208 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2210 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2214 map { $total += $form->{"ship_$_"} = $form->parse_amount(\%myconfig, $form->{"ship_$_"}) } (1 .. $form->{rowcount} - 1);
2216 $form->error($locale->text('Nothing entered!')) unless $total;
2218 $form->redirect($locale->text('Inventory saved!')) if OE->save_inventory(\%myconfig, \%$form);
2219 $form->error($locale->text('Could not save!'));
2224 sub search_transfer {
2226 OE->get_warehouses(\%myconfig, \%$form);
2229 if (@{ $form->{all_warehouses} }) {
2230 $form->{selectwarehouse} = "<option>\n";
2231 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2233 map { $form->{selectwarehouse} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_warehouses} });
2235 $form->error($locale->text('Nothing to transfer!'));
2238 $form->get_partsgroup(\%myconfig, { all => 0, searchitems => 'part'});
2239 if (@{ $form->{all_partsgroup} }) {
2240 $form->{selectpartsgroup} = "<option>\n";
2241 map { $form->{selectpartsgroup} .= qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n| } @{ $form->{all_partsgroup} };
2244 $form->{title} = $locale->text('Transfer Inventory');
2251 <form method=post action=$form->{script}>
2255 <th class=listtop>$form->{title}</th>
2257 <tr height="5"></tr>
2262 <th align=right nowrap>|.$locale->text('Transfer to').qq|</th>
2263 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2266 <th align="right" nowrap="true">|.$locale->text('Part Number').qq|</th>
2267 <td><input name=partnumber size=20></td>
2270 <th align="right" nowrap="true">|.$locale->text('Description').qq|</th>
2271 <td><input name=description size=40></td>
2274 <th align=right nowrap>|.$locale->text('Group').qq|</th>
2275 <td><select name=partsgroup><select>$form->{selectpartsgroup}</select></td>
2281 <td><hr size=3 noshade></td>
2286 <input type=hidden name=sort value=partnumber>
2287 <input type=hidden name=nextsub value=list_transfer>
2289 <input type=hidden name=path value=$form->{path}>
2290 <input type=hidden name=login value=$form->{login}>
2291 <input type=hidden name=sessionid value=$form->{sessionid}>
2293 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
2305 OE->get_inventory(\%myconfig, \%$form);
2307 $partnumber = $form->escape($form->{partnumber});
2308 $warehouse = $form->escape($form->{warehouse});
2309 $description = $form->escape($form->{description});
2310 $partsgroup = $form->escape($form->{partsgroup});
2313 $href = "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&sessionid=$form->{sessionid}";
2315 # construct callback
2316 $partnumber = $form->escape($form->{partnumber},1);
2317 $warehouse = $form->escape($form->{warehouse},1);
2318 $description = $form->escape($form->{description},1);
2319 $partsgroup = $form->escape($form->{partsgroup},1);
2321 $callback = "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&sessionid=$form->{sessionid}";
2323 @column_index = $form->sort_columns(qw(partnumber description partsgroup make model warehouse qty transfer));
2326 $column_header{partnumber} = qq|<th><a class=listheading href=$href&sort=partnumber>|.$locale->text('Part Number').qq|</a></th>|;
2327 $column_header{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|;
2328 $column_header{partsgroup} = qq|<th><a class=listheading href=$href&sort=partsgroup>|.$locale->text('Group').qq|</a></th>|;
2329 $column_header{warehouse} = qq|<th><a class=listheading href=$href&sort=warehouse>|.$locale->text('From').qq|</a></th>|;
2330 $column_header{qty} = qq|<th class=listheading>|.$locale->text('Qty').qq|</a></th>|;
2331 $column_header{transfer} = qq|<th class=listheading>|.$locale->text('Transfer').qq|</a></th>|;
2334 $option = $locale->text('Transfer to');
2336 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
2338 if ($form->{warehouse}) {
2339 $option .= " : $warehouse";
2341 if ($form->{partnumber}) {
2342 $option .= "\n<br>" if ($option);
2343 $option .= $locale->text('Part Number')." : $form->{partnumber}";
2345 if ($form->{description}) {
2346 $option .= "\n<br>" if ($option);
2347 $option .= $locale->text('Description')." : $form->{description}";
2349 if ($form->{partsgroup}) {
2350 ($partsgroup) = split /--/, $form->{partsgroup};
2351 $option .= "\n<br>" if ($option);
2352 $option .= $locale->text('Group')." : $partsgroup";
2355 $form->{title} = $locale->text('Transfer Inventory');
2362 <form method=post action=$form->{script}>
2364 <input type=hidden name=warehouse_id value=$warehouse_id>
2368 <th class=listtop>$form->{title}</th>
2370 <tr height="5"></tr>
2377 <tr class=listheading>|;
2379 map { print "\n$column_header{$_}" } @column_index;
2386 if (@{ $form->{all_inventory} }) {
2387 $sameitem = $form->{all_inventory}->[0]->{$form->{sort}};
2391 foreach $ref (@{ $form->{all_inventory} }) {
2395 $column_data{partnumber} = qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
2396 $column_data{description} = "<td>$ref->{description} </td>";
2397 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
2398 $column_data{warehouse} = qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
2399 $column_data{qty} = qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|.$form->format_amount(\%myconfig, $ref->{qty}).qq|</td>|;
2400 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
2404 <tr class=listrow$j>";
2406 map { print "\n$column_data{$_}" } @column_index;
2420 <td><hr size=3 noshade></td>
2426 <input name=callback type=hidden value="$callback">
2428 <input type=hidden name=rowcount value=$i>
2430 <input type=hidden name=path value=$form->{path}>
2431 <input type=hidden name=login value=$form->{login}>
2432 <input type=hidden name=sessionid value=$form->{sessionid}>
2434 <input class=submit type=submit name=action value="|.$locale->text('Transfer').qq|">|;
2436 if ($form->{menubar}) {
2437 require "$form->{path}/menu.pl";
2454 $form->redirect($locale->text('Inventory transferred!')) if OE->transfer(\%myconfig, \%$form);
2455 $form->error($locale->text('Could not transfer Inventory!'));
2461 sub quotation_ { &add };
2467 $form->error($locale->text('Order processed!'));