-<!-- shipto are in hidden variables -->
-
-<input type=hidden name=shiptoname value="$form->{shiptoname}">
-<input type=hidden name=shiptostreet value="$form->{shiptostreet}">
-<input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
-<input type=hidden name=shiptocity value="$form->{shiptocity}">
-<input type=hidden name=shiptocountry value="$form->{shiptocountry}">
-<input type=hidden name=shiptocontact value="$form->{shiptocontact}">
-<input type=hidden name=shiptophone value="$form->{shiptophone}">
-<input type=hidden name=shiptofax value="$form->{shiptofax}">
-<input type=hidden name=shiptoemail value="$form->{shiptoemail}">
-
-<!-- email variables -->
-<input type=hidden name=message value="$form->{message}">
-<input type=hidden name=email value="$form->{email}">
-<input type=hidden name=subject value="$form->{subject}">
-<input type=hidden name=cc value="$form->{cc}">
-<input type=hidden name=bcc value="$form->{bcc}">
-
-<input type=hidden name=taxpart value="$form->{taxpart}">
-<input type=hidden name=taxservice value="$form->{taxservice}">
-
-<input type=hidden name=taxaccounts value="$form->{taxaccounts}">
-|;
-
- foreach $item (split / /, $form->{taxaccounts}) {
- print qq|
-<input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
-<input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
-|;
- }
- $lxdebug->leave_sub();
-}
-
-sub form_footer {
- $lxdebug->enter_sub();
-
- $form->{invtotal} = $form->{invsubtotal};
-
- if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
- $rows = 2;
- }
- if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
- $introws = 2;
- }
- $rows = ($rows > $introws) ? $rows : $introws;
- $notes =
- qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
- $intnotes =
- qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
-
- $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
-
- $taxincluded = "";
- if ($form->{taxaccounts}) {
- $taxincluded = qq|
- <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
- . $locale->text('Tax Included') . qq|</b><br><br>
-|;
- }
-
- if (!$form->{taxincluded}) {
-
- foreach $item (split / /, $form->{taxaccounts}) {
- if ($form->{"${item}_base"}) {
- $form->{invtotal} += $form->{"${item}_total"} =
- $form->round_amount(
- $form->{"${item}_base"} * $form->{"${item}_rate"},
- 2);
- $form->{"${item}_total"} =
- $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
-
- $tax .= qq|
- <tr>
- <th align=right>$form->{"${item}_description"}</th>
- <td align=right>$form->{"${item}_total"}</td>
- </tr>
-|;
- }
- }
-
- $form->{invsubtotal} =
- $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
-
- $subtotal = qq|
- <tr>
- <th align=right>| . $locale->text('Subtotal') . qq|</th>
- <td align=right>$form->{invsubtotal}</td>
- </tr>
-|;
-
- }
-
- if ($form->{taxincluded}) {
- foreach $item (split / /, $form->{taxaccounts}) {
- if ($form->{"${item}_base"}) {
- $form->{"${item}_total"} =
- $form->round_amount(
- ($form->{"${item}_base"} * $form->{"${item}_rate"} /
- (1 + $form->{"${item}_rate"})
- ),
- 2);
- $form->{"${item}_netto"} =
- $form->round_amount(
- ($form->{"${item}_base"} - $form->{"${item}_total"}),
- 2);
- $form->{"${item}_total"} =
- $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
- $form->{"${item}_netto"} =
- $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
-
- $tax .= qq|
- <tr>
- <th align=right>Enthaltene $form->{"${item}_description"}</th>
- <td align=right>$form->{"${item}_total"}</td>
- </tr>
- <tr>
- <th align=right>Nettobetrag</th>
- <td align=right>$form->{"${item}_netto"}</td>
- </tr>
-|;
- }
- }
-
- }
-
- $form->{oldinvtotal} = $form->{invtotal};
- $form->{invtotal} =
- $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
-
- print qq|
- <tr>
- <td>
- <table width=100%>
- <tr valign=bottom>
- <td>
- <table>
- <tr>
- <th align=left>| . $locale->text('Notes') . qq|</th>
- <th align=left>| . $locale->text('Internal Notes') . qq|</th>
- </tr>
- <tr valign=top>
- <td>$notes</td>
- <td>$intnotes</td>
- </tr>
- <th align=right>| . $locale->text('Payment Terms') . qq|</th>
- <td><select name=payment_id tabindex=24>$payment
- </select></td>
- </table>
- </td>
- <td align=right width=100%>
- $taxincluded
- <table width=100%>
- $subtotal
- $tax
- <tr>
- <th align=right>| . $locale->text('Total') . qq|</th>
- <td align=right>$form->{invtotal}</td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
-<input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
-<input type=hidden name=oldtotalpaid value=$totalpaid>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-|;
-
- if ($webdav) {
- $webdav_list = qq|
-
- <tr>
- <th class=listtop align=left>Dokumente im Webdav-Repository</th>
- </tr>
- <table width=100%>
- <td align=left width=30%><b>Dateiname</b></td>
- <td align=left width=70%><b>Webdavlink</b></td>
-|;
- foreach $file (keys %{ $form->{WEBDAV} }) {
- $webdav_list .= qq|
- <tr>
- <td align=left>$file</td>
- <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
- </tr>
-|;
- }
- $webdav_list .= qq|
- </table>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-|;
-
- print $webdav_list;
- }
- print qq|
-<input type=hidden name=jscalendar value=$form->{jscalendar}>
-|;
- print qq|
- <tr>
- <td>
-|;
- &print_options;
-
- print qq|
- </td>
- </tr>
-</table>
-
-| . $locale->text("Edit the $form->{type}") . qq|<br>
-<input class=submit type=submit name=action value="|
- . $locale->text('Update') . qq|">
-<input class=submit type=submit name=action value="|
- . $locale->text('Ship to') . qq|">
-<input class=submit type=submit name=action value="|
- . $locale->text('Print') . qq|">
-<input class=submit type=submit name=action value="|
- . $locale->text('E-mail') . qq|">
-<input class=submit type=submit name=action value="|
- . $locale->text('Save') . qq|">
-<input class=submit type=submit name=action value="|
- . $locale->text('Save and Close') . qq|">
-|;
-
- if (($form->{id})) {
- print qq|
-<br>| . $locale->text("Workflow $form->{type}") . qq|<br>
-<input class=submit type=submit name=action value="|
- . $locale->text('Save as new') . qq|">
-<input class=submit type=submit name=action value="|
- . $locale->text('Delete') . qq|">|;
- if (($form->{type} =~ /sales_quotation$/)) {
- print qq|
-<input class=submit type=submit name=action value="|
- . $locale->text('Sales Order') . qq|">|;
- }
- if ($form->{type} =~ /request_quotation$/) {
- print qq|
-<input class=submit type=submit name=action value="|
- . $locale->text('Purchase Order') . qq|">|;
- }
- if (1) {
- print qq|
-<input class=submit type=submit name=action value="|
- . $locale->text('Invoice') . qq|">
-|;
-}
-
- if ($form->{type} =~ /sales_order$/) {
- print qq|
-<br>$form->{heading} als neue Vorlage verwenden für<br>
-<input class=submit type=submit name=action value="|
- . $locale->text('Purchase Order') . qq|">
-<input class=submit type=submit name=action value="|
- . $locale->text('Quotation') . qq|">
-|;
-
- } elsif ($form->{type} =~ /purchase_order$/) {
- print qq|
-<br>$form->{heading} als neue Vorlage verwenden für<br>
-<input class=submit type=submit name=action value="|
- . $locale->text('Sales Order') . qq|">
-<input class=submit type=submit name=action value="|
- . $locale->text('Quotation') . qq|">
-|;
-
- } else {
- print qq|
-<br>$form->{heading} als neue Vorlage verwenden für<br>
-<input class=submit type=submit name=action value="|
- . $locale->text('Order') . qq|">
-|;
- }
- } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount} && !$form->{proforma}) {
- print qq|
-<br>Workflow $form->{heading}<br>
-<input class=submit type=submit name=action value="|
- . $locale->text('Save as new') . qq|">
-<input class=submit type=submit name=action value="|
- . $locale->text('Invoice') . qq|">
-|;
- }
-
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|
-
-<input type=hidden name=rowcount value=$form->{rowcount}>
-
-<input name=callback type=hidden value="$form->{callback}">
-
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
-
-</form>
-
-</body>
-</html>
-|;
- $lxdebug->leave_sub();
-}
-
-sub update {
- $lxdebug->enter_sub();
-
- set_headings($form->{"id"} ? "edit" : "add");
-
- map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
- qw(exchangerate creditlimit creditremaining);
- $form->{update} = 1;
-
- &check_name($form->{vc});
-
- &check_project;
-
- $buysell = 'buy';
- $buysell = 'sell' if ($form->{vc} eq 'vendor');
- $form->{exchangerate} = $exchangerate
- if (
- $form->{forex} = (
- $exchangerate =
- $form->check_exchangerate(
- \%myconfig, $form->{currency}, $form->{transdate}, $buysell
- )));
-
- # for pricegroups
- $i = $form->{rowcount};
-
- $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
-
- if ( ($form->{"partnumber_$i"} eq "")
- && ($form->{"description_$i"} eq "")
- && ($form->{"partsgroup_$i"} eq "")) {
-
- $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
- &check_form;
-
- } else {
-
- $form->{"selected_unit_$i"} = $form->{"unit_$i"};
-
- if ( $form->{type} eq 'purchase_order'
- || $form->{type} eq 'request_quotation') {
- IR->retrieve_item(\%myconfig, \%$form);
- }
- if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
- IS->retrieve_item(\%myconfig, \%$form);
- }
-
- my $rows = scalar @{ $form->{item_list} };
-
- $form->{"discount_$i"} =
- $form->format_amount(\%myconfig, $form->{discount} * 100);
-
- if ($rows) {
- $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
-
- if ($rows > 1) {
-
- &select_item;
- exit;
-
- } else {
-
- $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
- if ($form->{"not_discountable_$i"}) {
- $form->{"discount_$i"} = 0;
- }
- map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
- qw(partnumber description unit);
- map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
- keys %{ $form->{item_list}[0] };
- if ($form->{"part_payment_id_$i"} ne "") {
- $form->{payment_id} = $form->{"part_payment_id_$i"};
- }
-
- $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
-
- ($dec) = ($s =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;