X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=0760f4afab0b1e72644168e409467ab79f371286;hb=981b670e29449b7ebffe6c910439a05e6613ec6b;hp=91e178dc589ca4c0425a3269a1dda954a7ddc7e9;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 91e178dc5..0760f4afa 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 @@ -31,7 +31,6 @@ # Quotation module #====================================================================== - use SL::OE; use SL::IR; use SL::IS; @@ -41,31 +40,33 @@ require "$form->{path}/io.pl"; require "$form->{path}/arap.pl"; 1; -# end of main +# end of main sub add { $lxdebug->enter_sub(); if ($form->{type} eq 'purchase_order') { $form->{title} = $locale->text('Add Purchase Order'); - $form->{vc} = 'vendor'; + $form->{vc} = 'vendor'; } if ($form->{type} eq 'sales_order') { $form->{title} = $locale->text('Add Sales Order'); - $form->{vc} = 'customer'; + $form->{vc} = 'customer'; } if ($form->{type} eq 'request_quotation') { $form->{title} = $locale->text('Add Request for Quotation'); - $form->{vc} = 'vendor'; + $form->{vc} = 'vendor'; } if ($form->{type} eq 'sales_quotation') { $form->{title} = $locale->text('Add Quotation'); - $form->{vc} = 'customer'; + $form->{vc} = 'customer'; } - $form->{callback} = "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&password=$form->{password}" unless $form->{callback}; - + $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; @@ -73,89 +74,117 @@ sub add { $lxdebug->leave_sub(); } - sub edit { $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) { + # reset rowcount + undef $form->{rowcount}; + &add; + return; + } + } else { + if (!$form->{id}) { + &add; + return; + } + } + if ($form->{type} eq 'purchase_order') { - $form->{title} = $locale->text('Edit Purchase Order'); + $form->{title} = $locale->text('Edit 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} = $locale->text('Edit 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} = $locale->text('Edit 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} = $locale->text('Edit Quotation'); $form->{heading} = $locale->text('Quotation'); - $form->{vc} = 'customer'; + $form->{vc} = 'customer'; } - + &order_links; &prepare_order; &display_form; - + $lxdebug->leave_sub(); } - - sub order_links { $lxdebug->enter_sub(); + # get customer/vendor - $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP"); - + $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); + # 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!')); + } + $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}; + + $cp_id = $form->{cp_id}; + $intnotes = $form->{intnotes}; + # get customer / vendor - if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/ ) { + 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"}|; + + $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}"} .= "