X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/4dbb09950c9f5596646537c12d991c99086fe7c1..46bc75c8:/bin/mozilla/oe.pl diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 91e178dc5..c1b281c6b 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -31,1411 +31,1136 @@ # Quotation module #====================================================================== +use POSIX qw(strftime); +use SL::DO; +use SL::FU; use SL::OE; use SL::IR; use SL::IS; +use SL::MoreCommon qw(ary_diff); use SL::PE; +use SL::ReportGenerator; +use List::MoreUtils qw(any none); +use List::Util qw(max reduce sum); +use Data::Dumper; -require "$form->{path}/io.pl"; -require "$form->{path}/arap.pl"; +require "bin/mozilla/io.pl"; +require "bin/mozilla/arap.pl"; +require "bin/mozilla/reportgenerator.pl"; + +use strict; + +our %TMPL_VAR; 1; + # end of main +# For locales.pl: +# $locale->text('Edit the purchase_order'); +# $locale->text('Edit the sales_order'); +# $locale->text('Edit the request_quotation'); +# $locale->text('Edit the sales_quotation'); -sub add { - $lxdebug->enter_sub(); +# $locale->text('Workflow purchase_order'); +# $locale->text('Workflow sales_order'); +# $locale->text('Workflow request_quotation'); +# $locale->text('Workflow sales_quotation'); - if ($form->{type} eq 'purchase_order') { - $form->{title} = $locale->text('Add Purchase Order'); - $form->{vc} = 'vendor'; - } - if ($form->{type} eq 'sales_order') { - $form->{title} = $locale->text('Add Sales Order'); - $form->{vc} = 'customer'; - } - if ($form->{type} eq 'request_quotation') { - $form->{title} = $locale->text('Add Request for Quotation'); - $form->{vc} = 'vendor'; - } - if ($form->{type} eq 'sales_quotation') { - $form->{title} = $locale->text('Add Quotation'); - $form->{vc} = 'customer'; - } +my $oe_access_map = { + 'sales_order' => 'sales_order_edit', + 'purchase_order' => 'purchase_order_edit', + 'request_quotation' => 'request_quotation_edit', + 'sales_quotation' => 'sales_quotation_edit', +}; - $form->{callback} = "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&password=$form->{password}" unless $form->{callback}; - - &order_links; - &prepare_order; - &display_form; +sub check_oe_access { + my $form = $main::form; + + my $right = $oe_access_map->{$form->{type}}; + $right ||= 'DOES_NOT_EXIST'; - $lxdebug->leave_sub(); + $main::auth->assert($right); } +sub set_headings { + $main::lxdebug->enter_sub(); -sub edit { - $lxdebug->enter_sub(); + my $form = $main::form; + my $locale = $main::locale; + + check_oe_access(); + + my ($action) = @_; if ($form->{type} eq 'purchase_order') { - $form->{title} = $locale->text('Edit Purchase Order'); + $form->{title} = $action eq "edit" ? + $locale->text('Edit Purchase Order') : + $locale->text('Add Purchase Order'); $form->{heading} = $locale->text('Purchase Order'); - $form->{vc} = 'vendor'; + $form->{vc} = 'vendor'; } if ($form->{type} eq 'sales_order') { - $form->{title} = $locale->text('Edit Sales Order'); + $form->{title} = $action eq "edit" ? + $locale->text('Edit Sales Order') : + $locale->text('Add Sales Order'); $form->{heading} = $locale->text('Sales Order'); - $form->{vc} = 'customer'; + $form->{vc} = 'customer'; } if ($form->{type} eq 'request_quotation') { - $form->{title} = $locale->text('Edit Request for Quotation'); + $form->{title} = $action eq "edit" ? + $locale->text('Edit Request for Quotation') : + $locale->text('Add Request for Quotation'); $form->{heading} = $locale->text('Request for Quotation'); - $form->{vc} = 'vendor'; + $form->{vc} = 'vendor'; } if ($form->{type} eq 'sales_quotation') { - $form->{title} = $locale->text('Edit Quotation'); + $form->{title} = $action eq "edit" ? + $locale->text('Edit Quotation') : + $locale->text('Add Quotation'); $form->{heading} = $locale->text('Quotation'); - $form->{vc} = 'customer'; + $form->{vc} = 'customer'; } - + + $main::lxdebug->leave_sub(); +} + +sub add { + $main::lxdebug->enter_sub(); + + my $form = $main::form; + + check_oe_access(); + + set_headings("add"); + + $form->{callback} = + "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}" + unless $form->{callback}; + &order_links; &prepare_order; &display_form; - - $lxdebug->leave_sub(); + + $main::lxdebug->leave_sub(); } +sub edit { + $main::lxdebug->enter_sub(); + my $form = $main::form; -sub order_links { - $lxdebug->enter_sub(); - # get customer/vendor - $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP"); - - # retrieve order/quotation - $form->{webdav} = $webdav; - - # set jscalendar - $form->{jscalendar} = $jscalendar; - - OE->retrieve(\%myconfig, \%$form); + check_oe_access(); - $taxincluded = $form->{taxincluded}; - $form->{shipto} = 1 if $form->{id}; - - if ($form->{"all_$form->{vc}"}) { - unless ($form->{"$form->{vc}_id"}) { - $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id}; - } - } - - $cp_id = $form->{cp_id}; - $intnotes=$form->{intnotes}; - # get customer / vendor - if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/ ) { - IR->get_vendor(\%myconfig, \%$form); - } - if ($form->{type} =~ /(sales|ship)_(order|quotation)/) { - IS->get_customer(\%myconfig, \%$form); - } - $form->{cp_id} = $cp_id; - - $form->{intnotes}=$intnotes; - ($form->{$form->{vc}}) = split /--/, $form->{$form->{vc}}; - $form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|; - - # build the popup menus - if (@{ $form->{"all_$form->{vc}"} }) { - $form->{$form->{vc}} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|; - map { $form->{"select$form->{vc}"} .= "