X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=0760f4afab0b1e72644168e409467ab79f371286;hb=82ee22347be2f2ee96d09a9fd0b45710f9552582;hp=d9ccd05a886d95c3bdd6442fe0f0d3062ae1b6bd;hpb=d319704a66e9be64da837ccea10af6774c2b0838;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index d9ccd05a8..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 @@ -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'); @@ -115,11 +131,20 @@ sub order_links { # 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}; @@ -196,31 +221,34 @@ sub prepare_order { $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++; + $form->{rowcount} = ++$i; + map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref}; - $form->{"discount_$i"} = + } + + for my $i (1 .. $form->{rowcount}) { + $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100); - ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/); + ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/); $dec = length $dec; $decimalplaces = ($dec > 2) ? $dec : 2; $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); - $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); + + (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/); + $dec_qty = length $dec_qty; + $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description unit); - $form->{rowcount} = $i; } - } $lxdebug->leave_sub(); } @@ -241,14 +269,12 @@ sub form_header { $button1 = qq| {transdate}> text('button') - . qq|> + . $locale->text('button') . qq|> |; $button2 = qq| {reqdate}> text('button') - . qq|> + . $locale->text('button') . qq|> |; #write Trigger @@ -272,11 +298,9 @@ sub form_header { + . $locale->text('Open') . qq| + . $locale->text('Closed') . qq|
| - . $locale->text('Open') - . qq| | - . $locale->text('Closed') - . qq|
@@ -345,8 +369,7 @@ sub form_header { | . $locale->text('Terms: Net') . qq| {terms}> | - . $locale->text('days') - . qq| + . $locale->text('days') . qq| |; @@ -371,14 +394,12 @@ sub form_header { | - . $locale->text('Quotation Number') - . qq| + . $locale->text('Quotation Number') . qq| | - . $locale->text('Customer Order Number') - . qq| + . $locale->text('Customer Order Number') . qq| @@ -419,8 +440,7 @@ sub form_header { $ordnumber = qq| | - . $locale->text('Quotation Number') - . qq| + . $locale->text('Quotation Number') . qq| @@ -471,6 +491,7 @@ sub form_header { if ($form->{type} eq 'sales_order') { if ($form->{selectemployee}) { $employee = qq| + {customer_klass}> | . $locale->text('Salesperson') . qq| @@ -481,6 +502,7 @@ sub form_header { } } else { $employee = qq| + {customer_klass}> | . $locale->text('Employee') . qq| @@ -537,8 +559,7 @@ sub form_header { {vc}_id value=$form->{"$form->{vc}_id"}> {vc}"}"> | - . $locale->text('Contact Person') - . qq| + . $locale->text('Contact Person') . qq| $contact $creditremaining @@ -573,7 +594,7 @@ sub form_header { - + $jsscript @@ -589,7 +610,7 @@ $jsscript - + @@ -633,8 +654,7 @@ sub form_footer { if ($form->{taxaccounts}) { $taxincluded = qq| {taxincluded}> | - . $locale->text('Tax Included') - . qq|

+ . $locale->text('Tax Included') . qq|

|; } @@ -749,7 +769,7 @@ sub form_footer { if ($webdav) { $webdav_list = qq| - + Dokumente im Webdav-Repository @@ -758,7 +778,7 @@ sub form_footer { |; foreach $file (keys %{ $form->{WEBDAV} }) { $webdav_list .= qq| - + @@ -813,7 +833,7 @@ Bearbeiten des $form->{heading}
|; } - print qq| + print qq| |; @@ -843,14 +863,23 @@ Bearbeiten des $form->{heading}
. $locale->text('Order') . qq|"> |; } + } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount}) { + print qq| +
Workflow $form->{heading}
+ + +|; } + if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } - print qq| + print qq| {rowcount}> @@ -888,7 +917,9 @@ sub update { \%myconfig, $form->{currency}, $form->{transdate}, $buysell ))); - my $i = $form->{rowcount}; + # for pricegroups + $i = $form->{rowcount}; + $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1; if ( ($form->{"partnumber_$i"} eq "") @@ -940,6 +971,7 @@ sub update { $form->{"sellprice_$i"} = $sellprice; } else { + $form->{"sellprice_$i"} *= (1 - $form->{tradediscount}); # if there is an exchange rate adjust sellprice $form->{"sellprice_$i"} /= $exchangerate; } @@ -960,7 +992,13 @@ sub update { $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); $form->{"qty_$i"} = - $form->format_amount(\%myconfig, $form->{"qty_$i"}); + $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); + + # get pricegroups for parts + IS->get_pricegroups_for_parts(\%myconfig, \%$form); + + # build up html code for prices_$i + &set_pricegroup($i); } &display_form; @@ -986,6 +1024,8 @@ sub update { } } } + + $lxdebug->leave_sub(); } @@ -1046,7 +1086,8 @@ sub search { $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|; map { - $form->{selectwarehouse} .= " + $department = qq| + @@ -1099,11 +1140,9 @@ sub search { $openclosed = qq| + . $locale->text('Open') . qq| + . $locale->text('Closed') . qq| |; } else { @@ -1122,14 +1161,12 @@ sub search { $button1 = qq| + . $locale->text('button') . qq|> |; $button2 = qq| + . $locale->text('button') . qq|> |; #write Trigger @@ -1187,34 +1224,27 @@ sub search { | . $locale->text('ID') . qq| + . $locale->text('Date') . qq| + . $locale->text('Required by') . qq| + . $locale->text('Ship via') . qq| + . $locale->text('Amount') . qq| + . $locale->text('Tax') . qq| + . $locale->text('Total') . qq| + . $locale->text('Subtotal') . qq|
$file $form->{WEBDAV}{$file}
| . $locale->text('Department') . qq|
| - . $locale->text('Open') - . qq| {closed}> | - . $locale->text('Closed') - . qq|
text('button') - . qq|> text('button') - . qq|> $ordlabel | - . $locale->text('Date') - . qq| | - . $locale->text('Required by') - . qq|
$vclabel $employee | - . $locale->text('Ship via') - . qq|
| - . $locale->text('Amount') - . qq| | - . $locale->text('Tax') - . qq| | - . $locale->text('Total') - . qq|
| - . $locale->text('Subtotal') - . qq|
@@ -1294,6 +1324,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"; @@ -1366,6 +1401,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}}"; @@ -1405,6 +1442,7 @@ sub orders { print qq| +
@@ -1425,7 +1463,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} }; @@ -1437,6 +1475,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} }) { @@ -1465,12 +1504,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} = ""; @@ -1528,7 +1568,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}> @@ -1733,8 +1793,10 @@ 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 ) }->{''} ); } else { $form->isblank("quonumber", $locale->text('Quotation Number missing!')); @@ -1770,7 +1832,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} = @@ -1846,7 +1916,10 @@ sub invoice { $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); - $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); + + (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/); + $dec_qty = length $dec_qty; + $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description unit); @@ -2119,7 +2192,8 @@ sub ship_receive { # undo formatting from prepare_order map { - $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) + $form->{"${_}_$i"} = + $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(qty ship); $n = ($form->{"qty_$i"} -= $form->{"ship_$i"}); if (abs($n) > 0 @@ -2271,7 +2345,7 @@ sub display_ship_receive { - + @@ -2344,7 +2418,7 @@ sub display_ship_receive { qq|$description|; $column_data{qty} = qq|| - . $form->format_amount(\%myconfig, $form->{"qty_$i"}) + . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty) . qq||; $column_data{ship} = qq|{rowcount}> @@ -2655,7 +2729,7 @@ sub list_transfer { qq|{warehouse_id}>$ref->{warehouse} |; $column_data{qty} = qq|{qty}>| - . $form->format_amount(\%myconfig, $ref->{qty}) + . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty) . qq||; $column_data{transfer} = qq||; @@ -2676,7 +2750,7 @@ sub list_transfer { - +
@@ -2719,4 +2793,3 @@ sub transfer { $lxdebug->leave_sub(); } -