X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=d05745b8ee5e8873ba5d01efa5532ec554ca9f58;hb=c1dafb8482847bb39edd6340bbbcbb77a7abb7b3;hp=cf6bd40b2f4f5b13190d7f8f5752ee11588332c0;hpb=e44cbe168d7cdaedc952a23102d8c834bd3a2993;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index cf6bd40b2..d05745b8e 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 @@ -77,6 +77,22 @@ sub add { 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->{heading} = $locale->text('Purchase Order'); @@ -121,6 +137,14 @@ sub order_links { 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}; @@ -193,50 +217,36 @@ sub order_links { sub prepare_order { $lxdebug->enter_sub(); - $form->{format} = "html"; + $form->{format} = "pdf"; $form->{media} = "screen"; $form->{formname} = $form->{type}; - if ($form->{id}) { - map { $form->{$_} =~ s/\"/"/g } qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact); foreach $ref (@{ $form->{form_details} }) { - $i++; - map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref}; - $form->{"discount_$i"} = - $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100); - - ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/); - $dec = length $dec; - $decimalplaces = ($dec > 2) ? $dec : 2; - - $form->{"sellprice_$i"} = - $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, - $decimalplaces); - - (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/); - $dec_qty = length $dec_qty; + $form->{rowcount} = ++$i; - $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); - - map { $form->{"${_}_$i"} =~ s/\"/"/g } - qw(partnumber description unit); - $form->{rowcount} = $i; + map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref}; } - } elsif ($form->{rowcount}) { for my $i (1 .. $form->{rowcount}) { - $form->{"discount_$i"} = - $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100); - - ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/); + if ($form->{id}) { + $form->{"discount_$i"} = + $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100); + } else { + $form->{"discount_$i"} = + $form->format_amount(\%myconfig, $form->{"discount_$i"}); + } + ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/); $dec = length $dec; $decimalplaces = ($dec > 2) ? $dec : 2; + # copy reqdate from deliverydate for invoice -> order conversion + $form->{"reqdate_$i"} = $form->{"deliverydate_$i"} unless $form->{"reqdate_$i"}; + $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, - $decimalplaces); + $decimalplaces); (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/); $dec_qty = length $dec_qty; @@ -245,7 +255,6 @@ sub prepare_order { map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description unit); } - } $lxdebug->leave_sub(); } @@ -825,10 +834,15 @@ Bearbeiten des $form->{heading}
. $locale->text('Save as new') . qq|"> |; - if ($form->{type} =~ /quotation$/) { + if ($form->{type} =~ /sales_quotation$/) { print qq| |; + . $locale->text('Sales Order') . qq|">|; + } + if ($form->{type} =~ /request_quotation$/) { + print qq| +|; } print qq| |; } + } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount}) { + print qq| +
Workflow $form->{heading}
+ + +|; } + if ($form->{menubar}) { require "$form->{path}/menu.pl"; @@ -1312,6 +1335,11 @@ sub orders { } } + # only show checkboxes if gotten here via sales_order form. + if ($form->{type} =~ /sales_order/) { + unshift @column_index, "ids"; + } + if ($form->{l_subtotal} eq 'Y') { $callback .= "&l_subtotal=Y"; $href .= "&l_subtotal=Y"; @@ -1384,6 +1412,8 @@ sub orders { $column_header{employee} = qq|$employee|; + $column_header{ids} = qq||; + if ($form->{ $form->{vc} }) { $option = $locale->text(ucfirst $form->{vc}); $option .= " : $form->{$form->{vc}}"; @@ -1423,6 +1453,7 @@ sub orders { print qq| +
@@ -1443,7 +1474,7 @@ sub orders { |; # add sort and escape callback - $callback = $form->escape($callback . "&sort=$form->{sort}"); + $callback_escaped = $form->escape($callback . "&sort=$form->{sort}"); if (@{ $form->{OE} }) { $sameitem = $form->{OE}->[0]->{ $form->{sort} }; @@ -1455,6 +1486,7 @@ sub orders { $warehouse = $form->escape($form->{warehouse}); foreach $oe (@{ $form->{OE} }) { + $form->{rowcount} = ++$j; if ($form->{l_subtotal} eq 'Y') { if ($sameitem ne $oe->{ $form->{sort} }) { @@ -1483,12 +1515,13 @@ sub orders { $subtotalnetamount += $oe->{netamount}; $subtotalamount += $oe->{amount}; + $column_data{ids} = qq||; $column_data{id} = ""; $column_data{transdate} = ""; $column_data{reqdate} = ""; $column_data{$ordnumber} = - ""; + ""; $column_data{name} = ""; $column_data{employee} = ""; @@ -1546,7 +1579,27 @@ sub orders { -
$form->{title}$oe->{id}$oe->{transdate} $oe->{reqdate} {path}&action=$action&type=$form->{type}&id=$oe->{id}&warehouse=$warehouse&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&callback=$callback>$oe->{$ordnumber}{path}&action=$action&type=$form->{type}&id=$oe->{id}&warehouse=$warehouse&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&callback=$callback_escaped>$oe->{$ordnumber}$oe->{name}$oe->{employee} 

+|; + +# multiple invoice edit button only if gotten there via sales_order form. + +if ($form->{type} =~ /sales_order/) { +print qq| + + + + + + + + + + |; +} + +print qq| +

{script}> @@ -1751,9 +1804,13 @@ sub invoice { $lxdebug->enter_sub(); if ($form->{type} =~ /_order$/) { - $form->isblank("ordnumber", $locale->text('Order Number missing!')); - $form->isblank("transdate", $locale->text('Order Date missing!')); + # these checks only apply if the items don't bring their own ordnumbers/transdates. + # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields. + $form->isblank("ordnumber", $locale->text('Order Number missing!')) if ( +{ map { $form->{"ordnumber_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} ); + $form->isblank("transdate", $locale->text('Order Date missing!')) if ( +{ map { $form->{"transdate_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} ); + # also copy deliverydate from the order + $form->{deliverydate} = $form->{reqdate} if $form->{reqdate}; } else { $form->isblank("quonumber", $locale->text('Quotation Number missing!')); $form->isblank("transdate", $locale->text('Quotation Date missing!')); @@ -1788,7 +1845,15 @@ sub invoice { # close orders/quotations $form->{closed} = 1; - OE->save(\%myconfig, \%$form); + + # save order if one ordnumber has been given + # if not it's most likely a collective order, which can't be saved back + # so they just have to be closed + if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) { + OE->save(\%myconfig, \%$form); + } else { + OE->close_orders(\%myconfig, \%$form); + } $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig); $form->{duedate} = @@ -1861,6 +1926,9 @@ sub invoice { $dec = length $dec; $decimalplaces = ($dec > 2) ? $dec : 2; + # copy delivery date from reqdate for order -> invoice conversion + $form->{"deliverydate_$i"} = $form->{"reqdate_$i"} unless $form->{"deliverydate_$i"}; + $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); @@ -2042,6 +2110,15 @@ sub save_as_new { sub purchase_order { $lxdebug->enter_sub(); + if ( $form->{type} eq 'sales_quotation' + || $form->{type} eq 'request_quotation') { + $form->{closed} = 1; + OE->save(\%myconfig, \%$form); + } + + ($null, $form->{cp_id}) = split /--/, $form->{contact}; + $form->{cp_id} *= 1; + $form->{title} = $locale->text('Add Purchase Order'); $form->{vc} = "vendor"; $form->{type} = "purchase_order";