From 195883fdfd3b10f329036767f027baa6e7c402b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stephan=20K=C3=B6hler?= Date: Mon, 31 Oct 2005 19:49:54 +0000 Subject: [PATCH] Preisgruppenerweiterung auf Basis von Andres Patch - Thanks -Preisgruppenverwaltung -Preiseingabe der Preisgruppen in Masken Waren,etc. -Auswahl der Preisgruppen in den Verkaufsmasken -... Erweiterung Datenbankschema --- SL/CT.pm | 21 ++- SL/Form.pm | 62 ++++++--- SL/IC.pm | 92 ++++++++++++- SL/IS.pm | 168 ++++++++++++++++++++++- SL/OE.pm | 10 +- SL/PE.pm | 130 ++++++++++++++++++ bin/mozilla/ct.pl | 113 +++++++++------- bin/mozilla/ic.pl | 159 +++++++++++----------- bin/mozilla/io.pl | 217 ++++++++++++++++++++++++++---- bin/mozilla/ir.pl | 11 +- bin/mozilla/is.pl | 31 +++-- bin/mozilla/oe.pl | 82 +++++------- bin/mozilla/pe.pl | 238 ++++++++++++++++++++++++++++++++- menu.ini | 13 +- sql/Pg-upgrade-2.1.1-2.1.2.sql | 21 +++ sql/lx-office.sql | 25 +++- 16 files changed, 1137 insertions(+), 256 deletions(-) diff --git a/SL/CT.pm b/SL/CT.pm index c6f55da3b..1db023b98 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -221,16 +221,21 @@ sub save_customer { my ($self, $myconfig, $form) = @_; + # set pricegroup to default + if ($form->{klass}) { } + else { $form->{klass} = 0; } + # connect to database my $dbh = $form->dbconnect($myconfig); ##LINET - map({ $form->{"cp_${_}"} = $form->{"selected_cp_${_}"} - if ($form->{"selected_cp_${_}"}); + map({ + $form->{"cp_${_}"} = $form->{"selected_cp_${_}"} + if ($form->{"selected_cp_${_}"}); } qw(title greeting)); - +# # escape ' map { $form->{$_} =~ s/\'/\'\'/g } - qw(customernumber name street zipcode city country homepage contact notes cp_title cp_greeting language); + qw(customernumber name street zipcode city country homepage contact notes cp_title cp_greeting language pricegroup); ##/LINET # assign value discount, terms, creditlimit $form->{discount} = $form->parse_amount($myconfig, $form->{discount}); @@ -314,7 +319,8 @@ sub save_customer { username = '$form->{username}', salesman_id = '$form->{salesman_id}', user_password = '$form->{user_password}', - c_vendor_id = '$form->{c_vendor_id}' + c_vendor_id = '$form->{c_vendor_id}', + klass = '$form->{klass}' WHERE id = $form->{id}|; $dbh->do($query) || $form->dberror($query); @@ -362,8 +368,9 @@ sub save_vendor { # connect to database my $dbh = $form->dbconnect($myconfig); ##LINET - map({ $form->{"cp_${_}"} = $form->{"selected_cp_${_}"} - if ($form->{"selected_cp_${_}"}); + map({ + $form->{"cp_${_}"} = $form->{"selected_cp_${_}"} + if ($form->{"selected_cp_${_}"}); } qw(title greeting)); # escape ' diff --git a/SL/Form.pm b/SL/Form.pm index d6cbc0b7c..215083830 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -382,8 +382,8 @@ function fokus(){document.$self->{fokus}.focus();} $jsscript = qq| + + $self->{javascript} |; } @@ -450,25 +450,25 @@ sub write_trigger { $trigger_1 = qq| Calendar.setup( -  { -    inputField  : "$inputField_1", -    ifFormat    :"$ifFormat", -    align    : "$align_1",      -    button      : "$button_1" -  } -  ); + { + inputField : "$inputField_1", + ifFormat :"$ifFormat", + align : "$align_1", + button : "$button_1" + } + ); |; if ($qty == 2) { $trigger_2 = qq| Calendar.setup( { -     inputField  : "$inputField_2", -     ifFormat    :"$ifFormat", -    align    : "$align_2",      -    button      : "$button_2" -  } -  ); + inputField : "$inputField_2", + ifFormat :"$ifFormat", + align : "$align_2", + button : "$button_2" + } + ); |; } $jsscript = qq| @@ -2120,6 +2120,38 @@ sub get_partsgroup { } +sub get_pricegroup { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $p) = @_; + + my $dbh = $self->dbconnect($myconfig); + + my $query = qq|SELECT p.id, p.pricegroup + FROM pricegroup p|; + + $query .= qq| + ORDER BY pricegroup|; + + if ($p->{all}) { + $query = qq|SELECT id, pricegroup FROM pricegroup + ORDER BY pricegroup|; + } + + my $sth = $dbh->prepare($query); + $sth->execute || $self->dberror($query); + + $self->{all_pricegroup} = (); + while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { + push @{ $self->{all_pricegroup} }, $ref; + } + $sth->finish; + $dbh->disconnect; + + $main::lxdebug->leave_sub(); +} + + sub audittrail { my ($self, $dbh, $myconfig, $audittrail) = @_; diff --git a/SL/IC.pm b/SL/IC.pm index 48c799675..2db7546b1 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -33,7 +33,7 @@ #====================================================================== package IC; - +use Data::Dumper; sub get_part { $main::lxdebug->enter_sub(); @@ -101,6 +101,76 @@ sub get_part { $form->{amount}{IC_expense} = $form->{expense_accno}; $form->{amount}{IC_cogs} = $form->{expense_accno}; + # get prices + $query = + qq|SELECT p.parts_id, p.pricegroup_id, p.price, (SELECT pg.pricegroup FROM pricegroup pg WHERE pg.id=p.pricegroup_id) AS pricegroup FROM prices p + WHERE parts_id = $form->{id} + ORDER by pricegroup|; + + $sth = $dbh->prepare($query); + $sth->execute || $form->dberror($query); + + @pricegroups = (); + @pricegroups_not_used = (); + + #for pricegroups + my $i = 1; + while ( + ($form->{"klass_$i"}, $form->{"pricegroup_id_$i"}, + $form->{"price_$i"}, $form->{"pricegroup_$i"}) + = $sth->fetchrow_array + ) { + $form->{"price_$i"} = $form->round_amount($form->{"price_$i"}, 5); + $form->{"price_$i"} = + $form->format_amount($myconfig, $form->{"price_$i"}, 5); + push @pricegroups, $form->{"pricegroup_id_$i"}; + $i++; + } + + $sth->finish; + + # get pricegroups + $query = qq|SELECT p.id, p.pricegroup FROM pricegroup p|; + + $pkq = $dbh->prepare($query); + $pkq->execute || $form->dberror($query); + while ($pkr = $pkq->fetchrow_hashref(NAME_lc)) { + push @{ $form->{PRICEGROUPS} }, $pkr; + } + $pkq->finish; + + #find not used pricegroups + while ($tmp = pop @{ $form->{PRICEGROUPS} }) { + my $insert = 0; + foreach $item (@pricegroups) { + if ($item eq $tmp->{id}) { + + #drop + $insert = 1; + } + } + if ($insert == 0) { + push @pricegroups_not_used, $tmp; + } + } + + # if not used pricegroups are avaible + if (@pricegroups_not_used) { + + foreach $name (@pricegroups_not_used) { + $form->{"klass_$i"} = "$name->{id}"; + $form->{"price_$i"} = $form->round_amount($form->{sellprice}, 5); + $form->{"price_$i"} = + $form->format_amount($myconfig, $form->{"price_$i"}, 5); + $form->{"pricegroup_id_$i"} = "$name->{id}"; + $form->{"pricegroup_$i"} = "$name->{pricegroup}\n"; + $i++; + } + } + + #correct rows + $form->{price_rows} = $i - 1; + unless ($form->{item} eq 'service') { # get makes @@ -332,6 +402,26 @@ sub save { WHERE id = $form->{id}|; $dbh->do($query) || $form->dberror($query); + # delete price records + $query = qq|DELETE FROM prices + WHERE parts_id = $form->{id}|; + $dbh->do($query) || $form->dberror($query); + + # insert price records only if different to sellprice + for my $i (1 .. $form->{price_rows}) { + if (( $form->{"price_$i"} + || $form->{"klass_$i"} + || $form->{"pricegroup_id_$i"}) and $form->{"price_$i"} != $form->{sellprice}) { + $klass = $form->parse_amount($myconfig, $form->{"klass_$i"}); + $price = $form->parse_amount($myconfig, $form->{"price_$i"}); + $pricegroup_id = + $form->parse_amount($myconfig, $form->{"pricegroup_id_$i"}); + $query = qq|INSERT INTO prices (parts_id, pricegroup_id, price) + VALUES($form->{id},$pricegroup_id,$price)|; + $dbh->do($query) || $form->dberror($query); + } + } + # insert makemodel records unless ($form->{item} eq 'service') { for my $i (1 .. $form->{makemodel_rows}) { diff --git a/SL/IS.pm b/SL/IS.pm index eac4440ae..a547fa945 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -34,6 +34,8 @@ package IS; +use Data::Dumper; + sub invoice_details { $main::lxdebug->enter_sub(); @@ -365,7 +367,7 @@ sub customer_details { sub post_invoice { $main::lxdebug->enter_sub(); - +print STDERR "IS.pm-post_invoice\n"; my ($self, $myconfig, $form) = @_; # connect to database, turn off autocommit @@ -549,16 +551,21 @@ sub post_invoice { ? qq|'$form->{"deliverydate_$i"}'| : "NULL"; + + # get pricegroup_id and save ist + ($null, my $pricegroup_id) = split /--/, $form->{"sellprice_drag_$i"}; + # save detail record in invoice table $query = qq|INSERT INTO invoice (trans_id, parts_id, description, qty, sellprice, fxsellprice, discount, allocated, assemblyitem, - unit, deliverydate, project_id, serialnumber) + unit, deliverydate, project_id, serialnumber, pricegroup_id) VALUES ($form->{id}, $form->{"id_$i"}, '$form->{"description_$i"}', $form->{"qty_$i"}, $form->{"sellprice_$i"}, $fxsellprice, $form->{"discount_$i"}, $allocated, 'f', '$form->{"unit_$i"}', $deliverydate, (SELECT id from project where projectnumber = '$project_id'), - '$form->{"serialnumber_$i"}')|; + '$form->{"serialnumber_$i"}', + '$pricegroup_id')|; $dbh->do($query) || $form->dberror($query); if ($form->{lizenzen}) { @@ -1105,7 +1112,7 @@ sub delete_invoice { sub retrieve_invoice { $main::lxdebug->enter_sub(); - +print STDERR "IS.pm-retrieve_invoice\n"; my ($self, $myconfig, $form) = @_; # connect to database @@ -1211,7 +1218,7 @@ sub retrieve_invoice { i.discount, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, pr.projectnumber, i.serialnumber, p.partnumber, p.assembly, p.bin, p.notes AS partnotes, i.id AS invoice_pos, - pg.partsgroup + pg.partsgroup, i.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=i.pricegroup_id) as pricegroup FROM invoice i JOIN parts p ON (i.parts_id = p.id) LEFT JOIN project pr ON (i.project_id = pr.id) @@ -1306,7 +1313,7 @@ sub get_customer { c.email, c.cc, c.bcc, c.language, c.street, c.zipcode, c.city, c.country, $duedate + c.terms AS duedate, c.notes AS intnotes, - b.discount AS tradediscount, b.description AS business + b.discount AS tradediscount, b.description AS business, c.klass as customer_klass FROM customer c LEFT JOIN business b ON (b.id = c.business_id) WHERE c.id = $form->{customer_id}|; @@ -1513,7 +1520,6 @@ sub retrieve_item { $stw->finish; } } - } $sth->finish; $dbh->disconnect; @@ -1521,6 +1527,154 @@ sub retrieve_item { $main::lxdebug->leave_sub(); } +########################## +# get pricegroups from database +# build up selected pricegroup +# if an exchange rate - change price +# for each part +# +sub get_pricegroups_for_parts { +print STDERR "IS.pm - get_pricegroups_for_parts\n"; + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $form) = @_; + + my $dbh = $form->dbconnect($myconfig); + + my $i = 1; + my $id = 0; + + while (($form->{"id_$i"}) or ($form->{"new_id_$i"})) { + + $id = $form->{"id_$i"}; + + if (!($form->{"id_$i"}) and $form->{"new_id_$i"}) { + + $id = $form->{"new_id_$i"}; + } + + ($price, $selectedpricegroup_id) = split /--/, $form->{"sellprice_drag_$i"}; +# print (STDERR "sellprice_drag_$i", Dumper($form->{"sellprice_drag_$i"})); + + $pricegroup_old = $form->{"pricegroup_old_$i"}; +# print (STDERR "pricegroup_old_i-$i", Dumper($pricegroup_old)); + + $price_new = $form->{"price_new_$i"}; + + $price_old = $form->{"price_old_$i"}; + + + $query = qq|SELECT pricegroup_id, (SELECT p.sellprice from parts p where p.id = $id) as default_sellprice,(SELECT pg.pricegroup FROM pricegroup pg WHERE id=pricegroup_id) AS pricegroup, price, '' AS selected FROM prices WHERE parts_id = $id UNION SELECT 0 as pricegroup_id,(SELECT sellprice FROM parts WHERE id=$id) as default_sellprice,'' as pricegroup, (SELECT DISTINCT sellprice from parts where id=$id) as price, 'selected' AS selected from prices ORDER BY pricegroup|; + + $pkq = $dbh->prepare($query); + $pkq->execute || $form->dberror($query); + while ($pkr = $pkq->fetchrow_hashref(NAME_lc)) { +# push @{ $form->{PRICES}{$id} }, $pkr; + push @{ $form->{PRICES}{$i} }, $pkr; + $pkr->{id} = $id; + $pkr->{selected} = ''; + + # if there is an exchange rate change price + if (($form->{exchangerate} * 1) != 0) { +# print STDERR "WECHSELKURS?-$form->{exchangerate}\n"; + $pkr->{price} /= $form->{exchangerate}; + } + $pkr->{price} = $form->format_amount($myconfig,$pkr->{price},5); + + + if ($selectedpricegroup_id eq undef) { + if ($pkr->{pricegroup_id} eq $form->{customer_klass}) { +print STDERR " INIT ROW \n"; +#print (STDERR " PREIS", Dumper($pkr->{price})); + $pkr->{selected} = ' selected'; + $last->{selected} = ''; +# print (STDERR " SELLPRICE", Dumper($form->{"sellprice_$i"})); + + # no customer pricesgroup set + if ($pkr->{price} == $pkr->{default_sellprice}) { +print (STDERR " PREIS IST DEFAULT-SELLPRICE", Dumper($form->{"sellprice_$i"})); + $pkr->{price} = $form->{"sellprice_$i"}; + +# if ($form->{tradediscount}){ +# print (STDERR "TRADE--", Dumper($pkr->{price})); +# $pkr->{price} =$pkr->{price} * (1 - $form->{tradediscount}); +# $pkr->{price} = $form->format_amount($myconfig,$pkr->{price},5); +# print (STDERR "TRADE--", Dumper($pkr->{price})); +# } + + } else { +print STDERR " PREIS IST NICHT NULL\n"; + $form->{"sellprice_$i"} = $pkr->{price}; + } +# print (STDERR " PRICE", Dumper($pkr->{price})); + + } else { +print STDERR " INIT ROW but what\n"; +print (STDERR " PREIS -", Dumper($pkr->{price}), "Default", Dumper($pkr->{default_sellprice})); + if ($pkr->{price} == $pkr->{default_sellprice}) { +print (STDERR " PREIS IST DEFAULT-", Dumper($form->{"sellprice_$i"})); + $pkr->{price} = $form->{"sellprice_$i"}; + $pkr->{selected} = ' selected'; + } + } + } + if ($selectedpricegroup_id or $selectedpricegroup_id == 0){ + if ($selectedpricegroup_id ne $pricegroup_old) { + if ($pkr->{pricegroup_id} eq $selectedpricegroup_id) { + if ($price_new != $form->{"sellprice_$i"}) { +print STDERR " MANUELLEN PREIS WÄHLEN\n"; + } else { +print STDERR " UPDATE CHANGE PRICEGROUP\n"; + $pkr->{selected} = ' selected'; + $last->{selected} = ''; +#$form->{"pricegroup_old_$i"} = $pkr->{$pricegroup_id}; + } + } + } else { + if (($price_new != $form->{"sellprice_$i"}) and ($price_new ne 0)) { + if ($pkr->{pricegroup_id} == 0) { +print STDERR " UPDATE CHANGE PRICEGROUP with price manuelly\n"; +print (STDERR " SELLPRICE??? ---", Dumper($form->{"sellprice_$i"})); +print (STDERR " NEWPRICE??? ---", Dumper($price_new)); + $pkr->{price} = $form->{"sellprice_$i"}; + $pkr->{selected} = ' selected'; + $last->{selected} = ''; + #$form->{"sellprice_$i"} = $form->format_amount($myconfig, $price_new, 2); +# print (STDERR "----5555---", Dumper($pkr)); + } + } else { + if ($pkr->{pricegroup_id} eq $selectedpricegroup_id) { +print STDERR " UPDATE NO CHANGE\n"; + $pkr->{selected} = ' selected'; + $last->{selected} = ''; +print STDERR " DEFAULTPRICE??? ---$pkr->{default_sellprice}\n"; +print (STDERR " SELLPRICE??? ---", Dumper($form->{"sellprice_$i"})); +# print (STDERR " HIER DER SELLPRICE DEFAULT??? ---", Dumper($form)); +print STDERR " NEWPRICE??? ---$price_new_\n"; + if (($pkr->{pricegroup_id} == 0) and ($pkr->{price} == $form->{"sellprice_$i"})) { +print (STDERR " UPDATE NO CHANGE BUT PRICE MANUELLY SET", Dumper($pkr->{price})); + # $pkr->{price} = $form->{"sellprice_$i"}; + } else { + $pkr->{price} = $form->{"sellprice_$i"}; + } +#print (STDERR " FEHLER", Dumper($form->{"sellprice_$i"})); + } + } + } + } + } + $i++; + + $pkq->finish; + } + + $dbh->disconnect; + +# print (STDERR "TEST", Dumper($form->{PRICES})); +# print (STDERR "TEST id_$i", Dumper($form->{"id_$i"})); + $main::lxdebug->leave_sub(); +} + sub webdav_folder { $main::lxdebug->enter_sub(); diff --git a/SL/OE.pm b/SL/OE.pm index b39c8e94f..334355d28 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -311,11 +311,14 @@ sub save { $reqdate = ($form->{"reqdate_$i"}) ? qq|'$form->{"reqdate_$i"}'| : "NULL"; + # get pricegroup_id and save ist + ($null, my $pricegroup_id) = split /--/, $form->{"sellprice_drag_$i"}; + # save detail record in orderitems table $query = qq|INSERT INTO orderitems (|; $query .= "id, " if $form->{"orderitems_id_$i"}; $query .= qq|trans_id, parts_id, description, qty, sellprice, discount, - unit, reqdate, project_id, serialnumber, ship) + unit, reqdate, project_id, serialnumber, ship, pricegroup_id) VALUES (|; $query .= qq|$form->{"orderitems_id_$i"},| if $form->{"orderitems_id_$i"}; @@ -323,7 +326,8 @@ sub save { '$form->{"description_$i"}', $form->{"qty_$i"}, $fxsellprice, $form->{"discount_$i"}, '$form->{"unit_$i"}', $reqdate, (SELECT id from project where projectnumber = '$project_id'), - '$form->{"serialnumber_$i"}', $form->{"ship_$i"})|; + '$form->{"serialnumber_$i"}', $form->{"ship_$i"}, + '$pricegroup_id')|; $dbh->do($query) || $form->dberror($query); $form->{"sellprice_$i"} = $fxsellprice; @@ -631,7 +635,7 @@ sub retrieve { o.sellprice, o.parts_id AS id, o.unit, o.discount, p.bin, p.notes AS partnotes, o.reqdate, o.project_id, o.serialnumber, o.ship, pr.projectnumber, - pg.partsgroup + pg.partsgroup, o.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=o.pricegroup_id) as pricegroup FROM orderitems o JOIN parts p ON (o.parts_id = p.id) LEFT JOIN chart c1 ON (p.inventory_accno_id = c1.id) diff --git a/SL/PE.pm b/SL/PE.pm index 9c17b524f..1532e79ce 100644 --- a/SL/PE.pm +++ b/SL/PE.pm @@ -35,6 +35,8 @@ package PE; +use Data::Dumper; + sub projects { $main::lxdebug->enter_sub(); @@ -290,5 +292,133 @@ sub delete_tuple { $main::lxdebug->leave_sub(); } +########################## +# get pricegroups from database +# +sub pricegroups { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $form) = @_; + + my $var; + + # connect to database + my $dbh = $form->dbconnect($myconfig); + + my $sortorder = ($form->{sort}) ? $form->{sort} : "pricegroup"; + + my $query = qq|SELECT g.id, g.pricegroup + FROM pricegroup g|; + + my $where = "1 = 1"; + + if ($form->{pricegroup}) { + $var = $form->like(lc $form->{pricegroup}); + $where .= " AND lower(g.pricegroup) LIKE '$var'"; + } + $query .= qq| + WHERE $where + ORDER BY $sortorder|; + + if ($form->{status} eq 'orphaned') { + $query = qq|SELECT pg.* + FROM pricegroup pg + LEFT JOIN prices p ON (p.pricegroup_id = pg.id) + WHERE $where + EXCEPT + SELECT pg.* + FROM pricegroup pg + JOIN prices p ON (p.pricegroup_id = pg.id) + WHERE $where + ORDER BY $sortorder|; + } +print STDERR "asdfasdf-$query\n"; + + $sth = $dbh->prepare($query); + $sth->execute || $form->dberror($query); + + my $i = 0; + while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { + push @{ $form->{item_list} }, $ref; + $i++; + } + + $sth->finish; + $dbh->disconnect; + + $main::lxdebug->leave_sub(); + + return $i; +} +######################## +# save pricegruop to database +# +sub save_pricegroup { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $form) = @_; + + # connect to database + my $dbh = $form->dbconnect($myconfig); + + map { $form->{$_} =~ s/\'/\'\'/g } (pricegroup); + + $form->{discount} /= 100; + + if ($form->{id}) { + $query = qq|UPDATE pricegroup SET + pricegroup = '$form->{pricegroup}' + WHERE id = $form->{id}|; + } else { + $query = qq|INSERT INTO pricegroup + (pricegroup) + VALUES ('$form->{pricegroup}')|; + } + $dbh->do($query) || $form->dberror($query); + + $dbh->disconnect; + + $main::lxdebug->leave_sub(); +} +############################ +# get one pricegroup from database +# +sub get_pricegroup { + $main::lxdebug->enter_sub(); +print STDERR "PE.pm-get_pricegroup\n"; + my ($self, $myconfig, $form) = @_; + + # connect to database + my $dbh = $form->dbconnect($myconfig); + + my $query = qq|SELECT p.id, p.pricegroup + FROM pricegroup p + WHERE p.id = $form->{id}|; + my $sth = $dbh->prepare($query); + $sth->execute || $form->dberror($query); + + my $ref = $sth->fetchrow_hashref(NAME_lc); + + map { $form->{$_} = $ref->{$_} } keys %$ref; + + $sth->finish; + + # check if it is orphaned + $query = qq|SELECT count(*) + FROM prices p + WHERE p.pricegroup_id = $form->{id}|; + $sth = $dbh->prepare($query); + $sth->execute || $form->dberror($query); + + ($form->{orphaned}) = $sth->fetchrow_array; + $form->{orphaned} = !$form->{orphaned}; + + $sth->finish; + + $dbh->disconnect; +#print (STDERR " ", Dumper($form)); + $main::lxdebug->leave_sub(); +} + 1; diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index 18171b5d1..c1bd16e21 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -69,8 +69,7 @@ sub search { if ($form->{db} eq 'vendor') { $gifi = qq| | - . $locale->text('GIFI') - . qq| + . $locale->text('GIFI') . qq| |; } @@ -112,8 +111,7 @@ sub search {  | . $locale->text('All') . qq|  | - . $locale->text('Orphaned') - . qq| + . $locale->text('Orphaned') . qq| | . $locale->text('Include in Report') . qq| @@ -121,54 +119,40 @@ sub search { + . $locale->text('ID') . qq| + . $locale->text($label . ' Number') . qq| + . $locale->text('Company Name') . qq| + . $locale->text('Address') . qq| + . $locale->text('Contact') . qq| + . $locale->text('Phone') . qq| + . $locale->text('Fax') . qq| + . $locale->text('E-mail') . qq| + . $locale->text('Tax Number') . qq| $gifi + . $locale->text('SIC') . qq| + . $locale->text('Type of Business') . qq| + . $locale->text('Invoices') . qq| + . $locale->text('Orders') . qq| + . $locale->text('Quotations') . qq|
| - . $locale->text('ID') - . qq| | - . $locale->text($label . ' Number') - . qq| | - . $locale->text('Company Name') - . qq| | - . $locale->text('Address') - . qq|
| - . $locale->text('Contact') - . qq| | - . $locale->text('Phone') - . qq| | - . $locale->text('Fax') - . qq| | - . $locale->text('E-mail') - . qq|
| - . $locale->text('Tax Number') - . qq| | - . $locale->text('SIC') - . qq| | - . $locale->text('Type of Business') - . qq|
| - . $locale->text('Invoices') - . qq| | - . $locale->text('Orders') - . qq| | - . $locale->text('Quotations') - . qq|
@@ -363,7 +347,6 @@ sub list_names { if ($ref->{id} eq $sameid) { map { $column_data{$_} = " " } @column_index; - map { $column_data{$_} = "$ref->{$_} " } (invnumber, ordnumber, quonumber); } else { map { $column_data{$_} = "$ref->{$_} " } @column_index; @@ -529,10 +512,10 @@ sub form_header { |; } - $form->{selectbusiness} = qq|\n|; + + $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"}; + + $column_data{sellprice_drag} = + qq||; + + }else { + # for last row + $column_data{sellprice_drag} = + qq|format_amount(\%myconfig, $form->{"prices_$i"}, + $decimalplaces) + . qq|>|; + } + + $column_data{sellprice} = + qq|format_amount(\%myconfig, $form->{"sellprice_$i"}, + $decimalplaces) + . qq|>|; + } +#print (STDERR "io.pl---555-i-$i", Dumper($form->{"price_old_$i"})); $column_data{discount} = qq|format_amount(\%myconfig, $form->{"discount_$i"}) @@ -289,6 +340,10 @@ sub display_row { {"orderitems_id_$i"}> {"bo_$i"}> +{"pricegroup_old_$i"}> +{"price_old_$i"}> +format_amount(\%myconfig,$form->{"price_new_$i"}).qq|> + {"id_$i"}> {"inventory_accno_$i"}> @@ -357,9 +412,53 @@ sub display_row { $lxdebug->leave_sub(); } -sub select_item { +################################################## +# build html-code for pricegroups in variable $form->{prices_$j} + +sub set_pricegroup { $lxdebug->enter_sub(); +print STDERR "io.pl-set_pricegroup-i-$i\n"; + for $j (1 .. $i) { + + my $pricegroup_old = $form->{"pricegroup_old_$i"}; + if ($form->{PRICES}{ $j }) { + $len = 0; + $prices = ''; + $price = 0; + foreach $item (@{ $form->{PRICES}{ $j } }) { +print STDERR "TEST--i--$i--jjj-$j\n"; +# print STDERR "-VOR PREIS--$item->{price}--PREISGRUOP-$item->{pricegroup_id}\n"; + $price = $form->round_amount($myconfig, $item->{price},5); + $price = $form->format_amount($myconfig, $item->{price},2); + $price = $item->{price}; +# print STDERR "-NACH PREIS--$price--PREISGRUOP-$item->{pricegroup_id}\n"; + $pricegroup_id = $item->{pricegroup_id}; + $pricegroup = $item->{pricegroup}; + # build dragdrop for pricegroups + $prices .= + qq|\n|; + + $len += 1; +# print STDERR "prices---$prices\n"; + # set new selectedpricegroup_id and prices for "Preis" + if ($item->{selected}) { + $form->{"pricegroup_old_$j"} = $pricegroup_id; + $form->{"price_new_$j"} = $price; + $form->{"sellprice_$j"} = $price; + } + if ($len >= 1) { + $form->{"prices_$j"} = $prices; + } + } + } + } + print (STDERR "", Dumper($form->{PRICES})); + $lxdebug->leave_sub(); +} +sub select_item { + $lxdebug->enter_sub(); +print STDERR "io.pl-select_item\n"; @column_index = qw(ndx partnumber description onhand sellprice); $column_data{ndx} = qq| |; @@ -411,10 +510,11 @@ sub select_item { } map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description unit); - +#sk tradediscount +print STDERR "TRADEDISCOUNT $ref->{sellprice}\n"; $ref->{sellprice} = $form->round_amount($ref->{sellprice} * (1 - $form->{tradediscount}), 2); - +print STDERR "TRADEDISCOUNT $ref->{sellprice}\n"; $column_data{ndx} = qq||; $column_data{partnumber} = @@ -496,7 +596,7 @@ sub select_item { sub item_selected { $lxdebug->enter_sub(); - +print STDERR "io.pl-item_selected\n"; # replace the last row with the checked row $i = $form->{rowcount}; $i = $form->{assembly_rows} if ($form->{item} eq 'assembly'); @@ -504,6 +604,10 @@ sub item_selected { # index for new item $j = $form->{ndx}; + #sk + #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"}; + #$form->{"sellprice_$i"} = $form->{"sellprice_$i"}; + # if there was a price entered, override it $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); @@ -563,6 +667,12 @@ sub item_selected { $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice) if $form->{item} ne 'assembly'; + # get pricegroups for parts + IS->get_pricegroups_for_parts(\%myconfig, \%$form); + + # build up html code for prices_$i + set_pricegroup(); + &display_form; $lxdebug->leave_sub(); @@ -638,10 +748,11 @@ sub new_item { sub display_form { $lxdebug->enter_sub(); - +print STDERR "io.pl-display_form\n"; # if we have a display_form if ($form->{display_form}) { &{"$form->{display_form}"}; +print STDERR " --------------------- exit\n"; exit; } if ( $form->{print_and_post} @@ -676,10 +787,23 @@ sub display_form { $subroutine = "display_row"; if ($form->{item} eq 'part') { +print STDERR " part\n"; + #set preisgruppenanzahl + $numrows = $form->{price_rows}; + $subroutine = "price_row"; + + &{$subroutine}($numrows); + $numrows = ++$form->{makemodel_rows}; $subroutine = "makemodel_row"; } if ($form->{item} eq 'assembly') { +print STDERR " assembly\n"; + $numrows = ++$form->{price_rows}; + $subroutine = "price_row"; + + &{$subroutine}($numrows); + $numrows = ++$form->{makemodel_rows}; $subroutine = "makemodel_row"; @@ -690,6 +814,12 @@ sub display_form { $subroutine = "assembly_row"; } if ($form->{item} eq 'service') { +print STDERR " service\n"; + $numrows = ++$form->{price_rows}; + $subroutine = "price_row"; + + &{$subroutine}($numrows); + $numrows = 0; } @@ -707,7 +837,7 @@ sub display_form { sub check_form { $lxdebug->enter_sub(); - +print STDERR "io.pl-check_form\n"; my @a = (); my $count = 0; my @flds = ( @@ -752,6 +882,8 @@ sub check_form { map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds; + #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"}; + $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"}); $form->{weight} += ($form->{"qty_$i"} * $form->{"weight_$i"}); $count++; @@ -808,6 +940,20 @@ sub check_form { } } + + #sk +print STDERR "LEVEL--$form->{level}\n"; +print STDERR "Type--$form->{type}\n"; + # if pricegroups + if ($form->{type} =~ (/sales_quotation/) or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/)) or (($form->{level} eq undef) and ($form->{type} =~ /invoice/)) or ($form->{type} =~ /sales_order/)) { + + # get pricegroups for parts + IS->get_pricegroups_for_parts(\%myconfig, \%$form); + + # build up html code for prices_$i + set_pricegroup(); + + } &display_form; @@ -829,6 +975,8 @@ sub invoicetotal { $discount = $form->parse_amount(\%myconfig, $form->{"discount_$i"}); $qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"}); + #($form->{"sellprice_$i"}, $form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"}; + $amount = $sellprice * (1 - $discount / 100) * $qty; map { $form->{"${_}_base"} += $amount } (split / /, $form->{"taxaccounts_$i"}); @@ -852,7 +1000,7 @@ sub invoicetotal { sub validate_items { $lxdebug->enter_sub(); - +print STDERR "io.pl-validate_items\n"; # check if items are valid if ($form->{rowcount} == 1) { &update; @@ -1086,7 +1234,7 @@ sub send_email { sub print_options { $lxdebug->enter_sub(); - +print STDERR "io.pl-print_options\n"; $form->{sendmode} = "attachment"; $form->{copies} = 3 unless $form->{copies}; @@ -1243,7 +1391,7 @@ sub print_options { sub print { $lxdebug->enter_sub(); - +print STDERR "io.pl-print\n"; # if this goes to the printer pass through if ($form->{media} eq 'printer' || $form->{media} eq 'queue') { $form->error($locale->text('Select postscript or PDF!')) @@ -1261,10 +1409,10 @@ sub print { sub print_form { $lxdebug->enter_sub(); my ($old_form) = @_; - +print STDERR "io.pl-print_form\n"; $inv = "inv"; $due = "due"; - +#print (STDERR "", Dumper($form)); $numberfld = "invnumber"; $display_form = @@ -1356,7 +1504,16 @@ sub print_form { if (!$form->{"${inv}number"} && !$form->{preview}) { $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld); if ($form->{media} ne 'email') { + + $i = $form->{rowcount}; + # get pricegroups for parts + IS->get_pricegroups_for_parts(\%myconfig, \%$form); + + # build up html code for prices_$i + set_pricegroup(); + $form->{rowcount}--; + &{"$display_form"}; exit; } @@ -1552,7 +1709,7 @@ sub print_form { sub customer_details { $lxdebug->enter_sub(); - +print STDERR "io.pl-customer_details\n"; IS->customer_details(\%myconfig, \%$form); $lxdebug->leave_sub(); } @@ -1578,23 +1735,29 @@ sub post_as_new { sub ship_to { $lxdebug->enter_sub(); - +print STDERR "io.pl-ship_to\n"; $title = $form->{title}; $form->{title} = $locale->text('Ship to'); map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); - $form_id = $form->{id}; + # get details for name &{"$form->{vc}_details"}; - $form->{id} = $form_id; $number = ($form->{vc} eq 'customer') ? $locale->text('Customer Number') : $locale->text('Vendor Number'); + $i = $form->{rowcount}; + # get pricegroups for parts + IS->get_pricegroups_for_parts(\%myconfig, \%$form); + + # build up html code for prices_$i + set_pricegroup(); + $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form"; $form->{rowcount}--; diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index a684593e7..caa8a0e6d 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -43,7 +43,7 @@ require "$form->{path}/arap.pl"; sub add { $lxdebug->enter_sub(); - +print STDERR "ir.pl-add\n"; $form->{title} = $locale->text('Add Vendor Invoice'); &invoice_links; @@ -67,7 +67,7 @@ sub edit { sub invoice_links { $lxdebug->enter_sub(); - +print STDERR "ir.pl-invoice_links\n"; # create links $form->{webdav} = $webdav; @@ -160,7 +160,7 @@ sub invoice_links { sub prepare_invoice { $lxdebug->enter_sub(); - +print STDERR "ir.pl-prepare_invoice\n"; if ($form->{id}) { map { $form->{$_} =~ s/\"/"/g } qw(invnumber ordnumber quonumber); @@ -188,7 +188,7 @@ sub prepare_invoice { sub form_header { $lxdebug->enter_sub(); - +print STDERR "ir.pl-form_header\n"; # set option selected foreach $item (qw(AP vendor currency department contact)) { $form->{"select$item"} =~ s/ selected//; @@ -304,6 +304,7 @@ sub form_header { {type}> +{level}> {creditlimit}> {creditremaining}> @@ -416,7 +417,7 @@ $jsscript sub form_footer { $lxdebug->enter_sub(); - +print STDERR "ir.pl-form_footer\n"; $form->{invtotal} = $form->{invsubtotal}; if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) { diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 4e6a066db..31d017eef 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -33,6 +33,7 @@ use SL::IS; use SL::PE; +use Data::Dumper; require "$form->{path}/io.pl"; require "$form->{path}/arap.pl"; @@ -66,7 +67,7 @@ sub add { sub edit { $lxdebug->enter_sub(); - +print STDERR "is.pl-edit\n"; $form->{title} = $locale->text('Edit Sales Invoice'); if ($myconfig{acs} =~ "AR--Add Sales Invoice" || $myconfig{acs} =~ "AR--AR") @@ -83,7 +84,7 @@ sub edit { sub invoice_links { $lxdebug->enter_sub(); - +print STDERR "is.pl-invoice_links\n"; $form->{vc} = 'customer'; # create links @@ -183,7 +184,7 @@ sub invoice_links { sub prepare_invoice { $lxdebug->enter_sub(); - +print STDERR "is.pl-prepare_invoice\n"; $form->{type} = "invoice"; $form->{formname} = "invoice"; $form->{format} = "html"; @@ -194,12 +195,14 @@ sub prepare_invoice { map { $form->{$_} =~ s/\"/"/g } qw(invnumber ordnumber quonumber shippingpoint shipvia notes intnotes); +# # get pricegroups for parts +# IS->get_pricegroups_for_parts(\%myconfig, \%$form); + foreach $ref (@{ $form->{invoice_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; @@ -212,6 +215,10 @@ sub prepare_invoice { map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description unit partnotes); $form->{rowcount} = $i; + +# # build up html code for prices_$i +# print STDERR "set_pricegroup aus is.pl-prepare_invoice\n"; +# set_pricegroup(); } } $lxdebug->leave_sub(); @@ -219,7 +226,7 @@ sub prepare_invoice { sub form_header { $lxdebug->enter_sub(); - +print STDERR "is.pl-form_header\n"; # set option selected foreach $item (qw(AR customer currency department employee contact)) { $form->{"select$item"} =~ s/ selected//; @@ -389,6 +396,7 @@ sub form_header { | . $locale->text('Customer') . qq| $customer + {customer_klass}> {customer_id}> | @@ -514,7 +522,7 @@ $jsscript sub form_footer { $lxdebug->enter_sub(); - +print STDERR "is.pl-form_footer\n"; $form->{invtotal} = $form->{invsubtotal}; if (($rows = $form->numtextrows($form->{notes}, 26, 8)) < 2) { @@ -852,7 +860,7 @@ sub form_footer { sub update { $lxdebug->enter_sub(); - +print STDERR "is.pl-update\n"; map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); @@ -916,7 +924,7 @@ sub update { } else { $sellprice = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}); - +#print STDERR " SELLPRICE-111- $sellprice\n"; map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit); map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } @@ -973,6 +981,11 @@ sub update { } } + # get pricegroups for parts + IS->get_pricegroups_for_parts(\%myconfig, \%$form, "new"); + + # build up html code for prices_$i + set_pricegroup(); } &display_form; @@ -1003,7 +1016,7 @@ sub update { sub post { $lxdebug->enter_sub(); - +print STDERR "is.pl-post\n"; $form->isblank("invdate", $locale->text('Invoice Date missing!')); $form->isblank("customer", $locale->text('Customer missing!')); diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 44bfbd49d..482b4c7e4 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -241,14 +241,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 +270,9 @@ sub form_header { + . $locale->text('Open') . qq| + . $locale->text('Closed') . qq|
| - . $locale->text('Open') - . qq| | - . $locale->text('Closed') - . qq|
@@ -345,8 +341,7 @@ sub form_header { | . $locale->text('Terms: Net') . qq| {terms}> | - . $locale->text('days') - . qq| + . $locale->text('days') . qq| |; @@ -371,14 +366,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 +412,7 @@ sub form_header { $ordnumber = qq| | - . $locale->text('Quotation Number') - . qq| + . $locale->text('Quotation Number') . qq| @@ -471,6 +463,7 @@ sub form_header { if ($form->{type} eq 'sales_order') { if ($form->{selectemployee}) { $employee = qq| + {customer_klass}> | . $locale->text('Salesperson') . qq| @@ -481,6 +474,7 @@ sub form_header { } } else { $employee = qq| + {customer_klass}> | . $locale->text('Employee') . qq| @@ -537,8 +531,7 @@ sub form_header { {vc}_id value=$form->{"$form->{vc}_id"}> {vc}"}"> | - . $locale->text('Contact Person') - . qq| + . $locale->text('Contact Person') . qq| $contact $creditremaining @@ -633,8 +626,7 @@ sub form_footer { if ($form->{taxaccounts}) { $taxincluded = qq| {taxincluded}> | - . $locale->text('Tax Included') - . qq|

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

|; } @@ -888,7 +880,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 +934,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; } @@ -961,6 +956,12 @@ sub update { $decimalplaces); $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); + + # get pricegroups for parts + IS->get_pricegroups_for_parts(\%myconfig, \%$form); + + # build up html code for prices_$i + set_pricegroup(); } &display_form; @@ -1046,7 +1047,8 @@ sub search { $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|; map { - $form->{selectwarehouse} .= "