- print qq|
-<body>
-
-<form method="post" action="oe.pl">
-<table width=100%>
- <tr>
- <th class=listtop>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <td>$option</td>
- </tr>
- <tr>
- <td>
- <table width=100%>
- <tr class=listheading>|;
-
- map { print "\n$column_header{$_}" } @column_index;
-
- print qq|
- </tr>
-|;
-
- # add sort and escape callback
- $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
-
- if (@{ $form->{OE} }) {
- $sameitem = $form->{OE}->[0]->{ $form->{sort} };
- }
-
- $action = "edit";
- $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
-
- $warehouse = $form->escape($form->{warehouse});
-
- foreach $oe (@{ $form->{OE} }) {
- $form->{rowcount} = ++$j;
-
- if ($form->{l_subtotal} eq 'Y') {
- if ($sameitem ne $oe->{ $form->{sort} }) {
- &subtotal;
- $sameitem = $oe->{ $form->{sort} };
- }
- }
-
- map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
-
- $column_data{netamount} =
- "<td align=right>"
- . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
- . "</td>";
- $column_data{tax} = "<td align=right>"
- . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
- 2, " ")
- . "</td>";
- $column_data{amount} =
- "<td align=right>"
- . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
-
- $totalnetamount += $oe->{netamount};
- $totalamount += $oe->{amount};
-
- $subtotalnetamount += $oe->{netamount};
- $subtotalamount += $oe->{amount};
-
- $column_data{ids} =
- qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
- $column_data{id} = "<td>$oe->{id}</td>";
- $column_data{transdate} = "<td>$oe->{transdate} </td>";
- $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
-
- $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}&password=$form->{password}&callback=$callback_escaped>$oe->{$ordnumber}</a></td>";
- $column_data{name} = "<td>$oe->{name}</td>";
-
- $column_data{employee} = "<td>$oe->{employee} </td>";
- $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
-
- if ($oe->{closed}) {
- $column_data{closed} = "<td align=center>X</td>";
- $column_data{open} = "<td> </td>";
- } else {
- $column_data{closed} = "<td> </td>";
- $column_data{open} = "<td align=center>X</td>";
- }
-
- $i++;
- $i %= 2;
- print "
- <tr class=listrow$i>";
-
- map { print "\n$column_data{$_}" } @column_index;
-
- print qq|
- </tr>
-|;
-
- }
-
- if ($form->{l_subtotal} eq 'Y') {
- &subtotal;
- }
-
- # print totals
- print qq|
- <tr class=listtotal>|;
-
- map { $column_data{$_} = "<td> </td>" } @column_index;
-
- $column_data{netamount} =
- "<th class=listtotal align=right>"
- . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
- $column_data{tax} = "<th class=listtotal align=right>"
- . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
- 2, " ")
- . "</th>";
- $column_data{amount} =
- "<th class=listtotal align=right>"
- . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
-
- map { print "\n$column_data{$_}" } @column_index;
-
- print qq|
- </tr>
- </td>
- </table>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>|;
-
- # multiple invoice edit button only if gotten there via sales_order form.
-
- if ($form->{type} =~ /sales_order/) {
- print qq|
- <input type="hidden" name="path" value="$form->{path}">
- <input class"submit" type="submit" name="action" value="|
- . $locale->text('Continue') . qq|">
- <input type="hidden" name="nextsub" value="edit">
- <input type="hidden" name="type" value="$form->{type}">
- <input type="hidden" name="warehouse" value="$warehouse">
- <input type="hidden" name="vc" value="$form->{vc}">
- <input type="hidden" name="login" value="$form->{login}">
- <input type="hidden" name="password" value="$form->{password}">
- <input type="hidden" name="callback" value="$callback">
- <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
- }
-
- print qq|
-</form>
-
-<br>
-<form method=post action=$form->{script}>
-
-<input name=callback type=hidden value="$form->{callback}">
-
-<input type=hidden name=type value=$form->{type}>
-<input type=hidden name=vc value=$form->{vc}>
-
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
-|;
-
- if ($form->{type} !~ /(ship|receive)_order/) {
- print qq|
-<input class=submit type=submit name=action value="|
- . $locale->text('Add') . qq|">|;
- }
-
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|
-</form>
-
-</body>
-</html>
-|;
-
- $lxdebug->leave_sub();
-}
-
-sub subtotal {
- $lxdebug->enter_sub();
-
- map { $column_data{$_} = "<td> </td>" } @column_index;
-
- $column_data{netamount} =
- "<th class=listsubtotal align=right>"
- . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
- . "</th>";
- $column_data{tax} = "<td class=listsubtotal align=right>"
- . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
- 2, " ")
- . "</th>";
- $column_data{amount} =
- "<th class=listsubtotal align=right>"
- . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
-
- $subtotalnetamount = 0;
- $subtotalamount = 0;
-
- print "
- <tr class=listsubtotal>
-";
-
- map { print "\n$column_data{$_}" } @column_index;
-
- print qq|
- </tr>
-|;
-
- $lxdebug->leave_sub();
-}
-
-sub save_and_close {
- $lxdebug->enter_sub();
-
- if ($form->{type} =~ /_order$/) {
- $form->isblank("transdate", $locale->text('Order Date missing!'));
- } else {
- $form->isblank("transdate", $locale->text('Quotation Date missing!'));
- }
-
- $msg = ucfirst $form->{vc};
- $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
-
- # $locale->text('Customer missing!');
- # $locale->text('Vendor missing!');
-
- $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
- if ($form->{currency} ne $form->{defaultcurrency});
-
- &validate_items;
-
- # if the name changed get new values
- if (&check_name($form->{vc})) {
- &update;
- exit;
- }
-
- $form->{id} = 0 if $form->{saveasnew};
-
- # this is for the internal notes section for the [email] Subject
- if ($form->{type} =~ /_order$/) {
- if ($form->{type} eq 'sales_order') {
- $form->{label} = $locale->text('Sales Order');
-
- $numberfld = "sonumber";
- $ordnumber = "ordnumber";
- } else {
- $form->{label} = $locale->text('Purchase Order');
-
- $numberfld = "ponumber";
- $ordnumber = "ordnumber";
- }
-
- $err = $locale->text('Cannot save order!');
-
- } else {
- if ($form->{type} eq 'sales_quotation') {
- $form->{label} = $locale->text('Quotation');
-
- $numberfld = "sqnumber";
- $ordnumber = "quonumber";
- } else {
- $form->{label} = $locale->text('Request for Quotation');
-
- $numberfld = "rfqnumber";
- $ordnumber = "quonumber";
- }
-
- $err = $locale->text('Cannot save quotation!');
-
- }
-
- # get new number in sequence if no number is given or if saveasnew was requested
- if (!$form->{$ordnumber} || $form->{saveasnew}) {
- $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
- }
-
- relink_accounts();
-
- $form->redirect(
- $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
- if (OE->save(\%myconfig, \%$form));
- $form->error($err);
-
- $lxdebug->leave_sub();
-}
-
-sub save {
- $lxdebug->enter_sub();
-
- if ($form->{type} =~ /_order$/) {
- $form->isblank("transdate", $locale->text('Order Date missing!'));
- } else {
- $form->isblank("transdate", $locale->text('Quotation Date missing!'));
- }
-
- $msg = ucfirst $form->{vc};
- $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
-
- # $locale->text('Customer missing!');
- # $locale->text('Vendor missing!');
-
- $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
- if ($form->{currency} ne $form->{defaultcurrency});
-
- &validate_items;
-
- # if the name changed get new values
- if (&check_name($form->{vc})) {
- &update;
- exit;
- }
-
- $form->{id} = 0 if $form->{saveasnew};
-
- # this is for the internal notes section for the [email] Subject
- if ($form->{type} =~ /_order$/) {
- if ($form->{type} eq 'sales_order') {
- $form->{label} = $locale->text('Sales Order');
-
- $numberfld = "sonumber";
- $ordnumber = "ordnumber";
- } else {
- $form->{label} = $locale->text('Purchase Order');
-
- $numberfld = "ponumber";
- $ordnumber = "ordnumber";
- }
-
- $err = $locale->text('Cannot save order!');