X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=b8d754c5c0f88da233261ff99999dc5b36a6d487;hb=d7f060429e809653d45e93e86b3c5c8d7129e0a9;hp=d05745b8ee5e8873ba5d01efa5532ec554ca9f58;hpb=b3721e4e65d62ea30b68b00ac77b4495b1f17337;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index d05745b8e..b8d754c5c 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -30,41 +30,75 @@ # Order entry module # Quotation module #====================================================================== +use Data::Dumper; use SL::OE; use SL::IR; use SL::IS; use SL::PE; -require "$form->{path}/io.pl"; -require "$form->{path}/arap.pl"; +require "bin/mozilla/io.pl"; +require "bin/mozilla/arap.pl"; 1; # end of main -sub add { +# 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'); + +# $locale->text('Workflow purchase_order'); +# $locale->text('Workflow sales_order'); +# $locale->text('Workflow request_quotation'); +# $locale->text('Workflow sales_quotation'); + +sub set_headings { $lxdebug->enter_sub(); + my ($action) = @_; + if ($form->{type} eq 'purchase_order') { - $form->{title} = $locale->text('Add Purchase Order'); - $form->{vc} = 'vendor'; + $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('Add Sales Order'); - $form->{vc} = 'customer'; + $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('Add Request for Quotation'); - $form->{vc} = 'vendor'; + $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('Add Quotation'); - $form->{vc} = 'customer'; + $form->{title} = $action eq "edit" ? + $locale->text('Edit Quotation') : + $locale->text('Add Quotation'); + $form->{heading} = $locale->text('Quotation'); + $form->{vc} = 'customer'; } + $lxdebug->leave_sub(); +} + +sub add { + $lxdebug->enter_sub(); + + set_headings("add"); + $form->{callback} = - "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&password=$form->{password}" + "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}" unless $form->{callback}; &order_links; @@ -76,46 +110,46 @@ sub add { sub edit { $lxdebug->enter_sub(); + # show history button + $form->{javascript} = qq||; + #/show hhistory button + + $form->{simple_save} = 0; + + set_headings("edit"); # editing without stuff to edit? try adding it first if ($form->{rowcount}) { - map {$id++ if $form->{"id_$_"}} (1 .. $form->{rowcount}); + map { $id++ if $form->{"multi_id_$_"} } (1 .. $form->{rowcount}); if (!$id) { + # reset rowcount undef $form->{rowcount}; &add; + $lxdebug->leave_sub(); return; } - } else { - if (!$form->{id}) { - &add; - return; - } + } elsif (!$form->{id}) { + &add; + $lxdebug->leave_sub(); + return; } - if ($form->{type} eq 'purchase_order') { - $form->{title} = $locale->text('Edit 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->{heading} = $locale->text('Sales Order'); - $form->{vc} = 'customer'; - } - if ($form->{type} eq 'request_quotation') { - $form->{title} = $locale->text('Edit 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->{heading} = $locale->text('Quotation'); - $form->{vc} = 'customer'; + if ($form->{print_and_save}) { + $form->{action} = "print"; + $form->{resubmit} = 1; + $language_id = $form->{language_id}; + $printer_id = $form->{printer_id}; } + set_headings("edit"); + &order_links; &prepare_order; + if ($form->{print_and_save}) { + $form->{language_id} = $language_id; + $form->{printer_id} = $printer_id; + } &display_form; $lxdebug->leave_sub(); @@ -123,26 +157,44 @@ sub edit { 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; - + $form->{webdav} = $webdav; + $form->{jsscript} = 1; - # set jscalendar - $form->{jscalendar} = $jscalendar; + my $editing = $form->{id}; OE->retrieve(\%myconfig, \%$form); + if ($form->{payment_id}) { + $payment_id = $form->{payment_id}; + } + if ($form->{language_id}) { + $language_id = $form->{language_id}; + } + if ($form->{taxzone_id}) { + $taxzone_id = $form->{taxzone_id}; + } + + $salesman_id = $form->{salesman_id} if ($editing); + + # if multiple rowcounts (== collective order) then check if the - # there were more than one customer (in that case OE::retrieve removes + # 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!')); + 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!') + ); } $taxincluded = $form->{taxincluded}; @@ -158,15 +210,36 @@ sub order_links { $intnotes = $form->{intnotes}; # get customer / vendor - if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/) { + if ($form->{type} =~ /(purchase_order|request_quotation)/) { IR->get_vendor(\%myconfig, \%$form); + + #quote all_vendor Bug 133 + foreach $ref (@{ $form->{all_vendor} }) { + $ref->{name} = $form->quote($ref->{name}); + } + } - if ($form->{type} =~ /(sales|ship)_(order|quotation)/) { + if ($form->{type} =~ /sales_(order|quotation)/) { IS->get_customer(\%myconfig, \%$form); + + #quote all_vendor Bug 133 + foreach $ref (@{ $form->{all_customer} }) { + $ref->{name} = $form->quote($ref->{name}); + } + } $form->{cp_id} = $cp_id; - $form->{intnotes} = $intnotes; + if ($payment_id) { + $form->{payment_id} = $payment_id; + } + if ($language_id) { + $form->{language_id} = $language_id; + } + if ($taxzone_id) { + $form->{taxzone_id} = $taxzone_id; + } + $form->{intnotes} = $intnotes if $intnotes; ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} }; $form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|; @@ -175,18 +248,11 @@ sub order_links { if (@{ $form->{"all_$form->{vc}"} }) { $form->{ $form->{vc} } = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|; - map { $form->{"select$form->{vc}"} .= "\n" } (@{ $form->{"all_$form->{vc}"} }); } - # currencies - @curr = split /:/, $form->{currencies}; - chomp $curr[0]; - $form->{defaultcurrency} = $curr[0]; - $form->{currency} = $form->{defaultcurrency} unless $form->{currency}; - - map { $form->{selectcurrency} .= "\n" } (@{ $form->{all_departments} }); } $form->{employee} = "$form->{employee}--$form->{employee_id}"; - # sales staff - if (@{ $form->{all_employees} }) { - $form->{selectemployee} = ""; - map { $form->{selectemployee} .= "