X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=5b1bc51d03ac17853b1e61127971f2bdbef73fea;hb=159b5368d8c1bb261cb36fc8643de5ca09a7f1d6;hp=6f12c94d37e156c9bc660ea2b8d0abfabc4d39ec;hpb=f9f5330a26eb3f447677ab2524c823cb9f96723b;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 6f12c94d3..5b1bc51d0 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1,4 +1,4 @@ -# #===================================================================== +#===================================================================== # LX-Office ERP # Copyright (C) 2004 # Based on SQL-Ledger Version 2.1.9 @@ -30,1005 +30,589 @@ # Order entry module # Quotation module #====================================================================== -use Data::Dumper; +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 -sub add { - $lxdebug->enter_sub(); +# 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'); - 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'; - } +# $locale->text('Workflow purchase_order'); +# $locale->text('Workflow sales_order'); +# $locale->text('Workflow request_quotation'); +# $locale->text('Workflow sales_quotation'); - $form->{callback} = - "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&password=$form->{password}" - unless $form->{callback}; +my $oe_access_map = { + 'sales_order' => 'sales_order_edit', + 'purchase_order' => 'purchase_order_edit', + 'request_quotation' => 'request_quotation_edit', + 'sales_quotation' => 'sales_quotation_edit', +}; - &order_links; - &prepare_order; - &display_form; +sub check_oe_access { + my $form = $main::form; - $lxdebug->leave_sub(); + my $right = $oe_access_map->{$form->{type}}; + $right ||= 'DOES_NOT_EXIST'; + + $main::auth->assert($right); } -sub edit { - $lxdebug->enter_sub(); +sub set_headings { + $main::lxdebug->enter_sub(); - # editing without stuff to edit? try adding it first - if ($form->{rowcount}) { - map { $id++ if $form->{"id_$_"} } (1 .. $form->{rowcount}); - if (!$id) { + my $form = $main::form; + my $locale = $main::locale; - # reset rowcount - undef $form->{rowcount}; - &add; - return; - } - } else { - if (!$form->{id}) { - &add; - return; - } - } + 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'; } 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'; } 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'; } 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'; } + $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 order_links { - $lxdebug->enter_sub(); +sub edit { + $main::lxdebug->enter_sub(); - # get customer/vendor - $form->all_vc(\%myconfig, $form->{vc}, - ($form->{vc} eq 'customer') ? "AR" : "AP"); + my $form = $main::form; - # retrieve order/quotation - $form->{webdav} = $webdav; + check_oe_access(); - # set jscalendar - $form->{jscalendar} = $jscalendar; + # show history button + $form->{javascript} = qq||; + #/show hhistory button - OE->retrieve(\%myconfig, \%$form); + $form->{simple_save} = 0; - # if multiple rowcounts (== collective order) then check if the - # there were more than one customer (in that case OE::retrieve removes - # the content from the field) - if ( $form->{rowcount} - && $form->{type} eq 'sales_order' - && defined $form->{customer} - && $form->{customer} eq '') { - - # $main::lxdebug->message(0, "Detected Edit order with concurrent customers"); - $form->error( - $locale->text( - 'Collective Orders only work for orders from one customer!') - ); - } + set_headings("edit"); - $taxincluded = $form->{taxincluded}; - $form->{shipto} = 1 if $form->{id}; + # editing without stuff to edit? try adding it first + if ($form->{rowcount} && !$form->{print_and_save}) { + my $id; + map { $id++ if $form->{"multi_id_$_"} } (1 .. $form->{rowcount}); + if (!$id) { - if ($form->{"all_$form->{vc}"}) { - unless ($form->{"$form->{vc}_id"}) { - $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id}; + # reset rowcount + undef $form->{rowcount}; + &add; + $main::lxdebug->leave_sub(); + return; } + } elsif (!$form->{id}) { + &add; + $main::lxdebug->leave_sub(); + return; } - $cp_id = $form->{cp_id}; - $intnotes = $form->{intnotes}; + my ($language_id, $printer_id); + if ($form->{print_and_save}) { + $form->{action} = "print"; + $form->{resubmit} = 1; + $language_id = $form->{language_id}; + $printer_id = $form->{printer_id}; + } - # get customer / vendor - if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/) { - IR->get_vendor(\%myconfig, \%$form); + set_headings("edit"); - #quote all_vendor Bug 133 - foreach $ref (@{ $form->{all_vendor} }) { - $ref->{name} = $form->quote($ref->{name}); - } + &order_links; + $form->{rowcount} = 0; + foreach my $ref (@{ $form->{form_details} }) { + $form->{rowcount}++; + map { $form->{"${_}_$form->{rowcount}"} = $ref->{$_} } keys %{$ref}; } - if ($form->{type} =~ /(sales|ship)_(order|quotation)/) { - IS->get_customer(\%myconfig, \%$form); - #quote all_vendor Bug 133 - foreach $ref (@{ $form->{all_customer} }) { - $ref->{name} = $form->quote($ref->{name}); - } + &prepare_order; + if ($form->{print_and_save}) { + $form->{language_id} = $language_id; + $form->{printer_id} = $printer_id; } - $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"}|; + &display_form; - # 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}"} .= "