use POSIX qw(strftime);
+use SL::FU;
use SL::OE;
use SL::IR;
use SL::IS;
use SL::PE;
use SL::ReportGenerator;
-use List::Util qw(max reduce);
+use List::Util qw(max reduce sum);
require "bin/mozilla/io.pl";
require "bin/mozilla/arap.pl";
$credittext = $locale->text('Credit Limit exceeded!!!');
+ my $follow_up_vc = $form->{ $form->{vc} eq 'customer' ? 'customer' : 'vendor' };
+ $follow_up_vc =~ s/--.*?//;
+ $TMPL_VAR{follow_up_trans_info} = ($form->{type} =~ /_quotation$/ ? $form->{quonumber} : $form->{ordnumber}) . " ($follow_up_vc)";
+
+ if ($form->{id}) {
+ my $follow_ups = FU->follow_ups('trans_id' => $form->{id});
+
+ if (scalar @{ $follow_ups }) {
+ $TMPL_VAR{num_follow_ups} = scalar @{ $follow_ups };
+ $TMPL_VAR{num_due_follow_ups} = sum map { $_->{due} * 1 } @{ $follow_ups };
+ }
+ }
+
$onload = ($form->{resubmit} && ($form->{format} eq "html")) ? "window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()"
: ($form->{resubmit}) ? "document.oe.submit()"
: ($creditwarning) ? "alert('$credittext')"
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
$TMPL_VAR{onload} = $onload;
-
+
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
set_headings($form->{"id"} ? "edit" : "add");
- map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining) unless $recursive_call;
+ map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate) unless $recursive_call;
$form->{update} = 1;
$payment_id = $form->{payment_id} if $form->{payment_id};
map { $form->{"select$_"} = "" } ($form->{vc}, currency);
- map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
- qw(creditlimit creditremaining);
-
$currency = $form->{currency};
&invoice_links;
qw(partnumber description unit);
}
- map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
- qw(creditlimit creditremaining);
-
&update;
$lxdebug->leave_sub();
}
+sub delivery_order {
+ $lxdebug->enter_sub();
+
+ if ($form->{type} =~ /^sales/) {
+ $auth->assert('sales_delivery_order_edit');
+
+ $form->{vc} = 'customer';
+ $form->{type} = 'sales_delivery_order';
+
+ } else {
+ $auth->assert('purchase_delivery_order_edit');
+
+ $form->{vc} = 'vendor';
+ $form->{type} = 'purchase_delivery_order';
+ }
+
+ require "bin/mozilla/do.pl";
+
+ $form->{cp_id} *= 1;
+ $form->{transdate} = $form->current_date(\%myconfig);
+ delete $form->{duedate};
+
+ $form->{closed} = 0;
+
+ $form->{old_employee_id} = $form->{employee_id};
+ $form->{old_salesman_id} = $form->{salesman_id};
+
+ # reset
+ map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued creditlimit creditremaining discount tradediscount oldinvtotal);
+
+ for $i (1 .. $form->{rowcount}) {
+ map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice basefactor);
+ }
+
+ my %old_values = map { $_ => $form->{$_} } qw(customer_id oldcustomer customer vendor_id oldvendor vendor);
+
+ order_links();
+
+ prepare_order();
+
+ map { $form->{$_} = $old_values{$_} if ($old_values{$_}) } keys %old_values;
+
+ update();
+
+ $lxdebug->leave_sub();
+}
+
sub e_mail {
$lxdebug->enter_sub();
check_oe_access();
+ retrieve_partunits() if ($form->{type} =~ /_delivery_order$/);
+
$form->{"taxaccounts"} =~ s/\s*$//;
$form->{"taxaccounts"} =~ s/^\s*//;
foreach my $accno (split(/\s*/, $form->{"taxaccounts"})) {
$lxdebug->leave_sub();
}
+sub report_for_todo_list {
+ $lxdebug->enter_sub();
+
+ my $quotations = OE->transactions_for_todo_list();
+ my $content;
+
+ if (@{ $quotations }) {
+ my $edit_url = build_std_url('script=oe.pl', 'action=edit', 'type=sales_quotation', 'vc=customer');
+
+ $content = $form->parse_html_template('oe/report_for_todo_list', { 'QUOTATIONS' => $quotations,
+ 'edit_url' => $edit_url });
+ }
+
+ $lxdebug->leave_sub();
+
+ return $content;
+}
+