X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=20042ca75d31ec98d1e59aab79dbd7c24a3bf16e;hb=501107ad47b6385a9986aab9048b98ed5784182e;hp=91e178dc589ca4c0425a3269a1dda954a7ddc7e9;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 91e178dc5..20042ca75 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,7 +30,7 @@ # Order entry module # Quotation module #====================================================================== - +use Data::Dumper; use SL::OE; use SL::IR; @@ -41,31 +41,66 @@ require "$form->{path}/io.pl"; require "$form->{path}/arap.pl"; 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 { +# $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'; } - $form->{callback} = "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&password=$form->{password}" unless $form->{callback}; - + $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}" + unless $form->{callback}; + &order_links; &prepare_order; &display_form; @@ -73,89 +108,148 @@ sub add { $lxdebug->leave_sub(); } - sub edit { $lxdebug->enter_sub(); - 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'; + set_headings("edit"); + + # 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 '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(); } - - 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 ($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}; + } + + + # 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); + + #quote all_vendor Bug 133 + foreach $ref (@{ $form->{all_vendor} }) { + $ref->{name} = $form->quote($ref->{name}); + } + } 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}); + } + } $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"}|; + 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; + ($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}"} .= "|; + foreach $item (@{ $form->{payment_terms} }) { + if ($form->{payment_id} eq $item->{id}) { + $payment .= qq||; + } else { + $payment .= qq||; + } + } + if ($form->{jsscript}) { - if ($form->{jsscript}) - { # with JavaScript Calendar $button1 = qq| {transdate}> - text('button').qq|> + text('button') . qq|> |; - $button2 = qq| + $button2 = qq| {reqdate}> - text('button').qq|> + text('button') . qq|> |; + #write Trigger - $jsscript = Form->write_trigger(\%myconfig,"2","transdate","BL","trigger1","reqdate","BL","trigger2"); + $jsscript = + Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1", + "reqdate", "BL", "trigger2"); + + } else { - } - else - { - # without JavaScript Calendar - $button1 = qq| + # without JavaScript Calendar + $button1 = qq| {transdate}>|; - $button2 = qq| + $button2 = qq| {reqdate}>|; - } - - + } + if ($form->{id}) { $openclosed = qq| - - + +
|.$locale->text('Open').qq| |.$locale->text('Closed').qq| | + . $locale->text('Open') . qq| | + . $locale->text('Closed') . qq|
@@ -264,121 +390,234 @@ sub form_header { } # set option selected - foreach $item ($form->{vc}, currency, department, employee, contact) { + foreach $item ($form->{vc}, currency, department, employee) { $form->{"select$item"} =~ s/ selected//; - $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; + $form->{"select$item"} =~ + s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; } + #quote select[customer|vendor] Bug 133 + $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"}); + #build contacts if ($form->{all_contacts}) { - - $form->{selectcontact} = ""; - foreach $item (@{$form->{all_contacts}}) { - if ($form->{cp_id} == $item->{cp_id}) - { - $form->{selectcontact} .= ""; + foreach $item (@{ $form->{all_contacts} }) { + my $department = ($item->{cp_abteilung}) ? "--$item->{cp_abteilung}" : ""; + if ($form->{cp_id} == $item->{cp_id}) { + $form->{selectcontact} .= + ""; + } else { + $form->{selectcontact} .= ""; } - } - - $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate}); + } + } else { + $form->{selectcontact} =~ s/ selected//g; + if ($form->{cp_id} ne "") { + $form->{selectcontact} =~ s/value=$form->{cp_id}/value=$form->{cp_id} selected/; + } + } + + + if (@{ $form->{SHIPTO} }) { + $form->{selectshipto} = ""; + foreach $item (@{ $form->{SHIPTO} }) { + if ($item->{shipto_id} == $form->{shipto_id}) { + $form->{selectshipto} .= + ""; + } else { + $form->{selectshipto} .= + ""; + } + + } + } else { + $form->{selectshipto} =~ s/ selected//g; + if ($form->{shipto_id} ne "") { + $form->{selectshipto} =~ s/value=$form->{shipto_id}/value=$form->{shipto_id} selected/; + } + } + + $shipto = qq| + | . $locale->text('Shipping Address') . qq| + + |; + + + + + $form->{exchangerate} = + $form->format_amount(\%myconfig, $form->{exchangerate}); + + if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) { + $creditwarning = 1; + } else { + $creditwarning = 0; + } + + $form->{creditlimit} = + $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); + $form->{creditremaining} = + $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); + + $contact = + ($form->{selectcontact}) + ? qq|\n| + : qq||; - $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); - $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); - - $contact = ($form->{selectcontact}) ? qq|\n| : qq||; - $exchangerate = qq| {forex}> |; if ($form->{currency} ne $form->{defaultcurrency}) { if ($form->{forex}) { - $exchangerate .= qq||.$locale->text('Exchangerate').qq|$form->{exchangerate} + $exchangerate .= + qq|| + . $locale->text('Exchangerate') + . qq|$form->{exchangerate} {exchangerate}> |; } else { - $exchangerate .= qq||.$locale->text('Exchangerate').qq|{exchangerate}>|; + $exchangerate .= + qq|| + . $locale->text('Exchangerate') + . qq|{exchangerate}>|; } } - $vclabel = ucfirst $form->{vc}; $vclabel = $locale->text($vclabel); $terms = qq| - |.$locale->text('Terms: Net').qq| - {terms}> |.$locale->text('days').qq| + | . $locale->text('Terms: Net') . qq| + {terms}> | + . $locale->text('days') . qq| |; - if ($form->{business}) { $business = qq| - |.$locale->text('Business').qq| + | . $locale->text('Business') . qq| $form->{business} - |.$locale->text('Trade Discount').qq| - |.$form->format_amount(\%myconfig, $form->{tradediscount} * 100).qq| % + | . $locale->text('Trade Discount') . qq| + | + . $form->format_amount(\%myconfig, $form->{tradediscount} * 100) + . qq| % |; } + if ($form->{max_dunning_level}) { + $dunning = qq| + + + + + + + + + +
| . $locale->text('Max. Dunning Level') . qq|:$form->{max_dunning_level}| . $locale->text('Dunning Amount') . qq|:| + . $form->format_amount(\%myconfig, $form->{dunning_amount},2) + . qq|
+ + +|; + } + + if (@{ $form->{TAXZONE} }) { + $form->{selecttaxzone} = ""; + foreach $item (@{ $form->{TAXZONE} }) { + if ($item->{id} == $form->{taxzone_id}) { + $form->{selecttaxzone} .= + ""; + } else { + $form->{selecttaxzone} .= + ""; + } + + } + } else { + $form->{selecttaxzone} =~ s/ selected//g; + if ($form->{taxzone_id} ne "") { + $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/; + } + } + + if ($form->{rowcount} >0) { + $form->{selecttaxzone} =~ /