X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIC.pm;h=a4b17f844b1da3b8c409d0fcb6a05f37ceeebfe2;hb=12c628c589ea4e0da1caf190416da08946c54636;hp=11bf58690659a4e3e2c2f9235792ea867adb404a;hpb=b80a03a9cf7a249e771c5ce080970ce5131e10f0;p=kivitendo-erp.git diff --git a/SL/IC.pm b/SL/IC.pm index 11bf58690..a4b17f844 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -34,6 +34,7 @@ package IC; use Data::Dumper; +use SL::DBUtils; sub get_part { $main::lxdebug->enter_sub(); @@ -53,9 +54,10 @@ sub get_part { LEFT JOIN chart c2 ON (p.income_accno_id = c2.id) LEFT JOIN chart c3 ON (p.expense_accno_id = c3.id) LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) - WHERE p.id = $form->{id}|; + WHERE p.id = ? |; + my @vars = ($form->{id}); my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute(@vars) || $form->dberror("$query (" . join(', ', @vars) . ")"); my $ref = $sth->fetchrow_hashref(NAME_lc); # copy to $form variables @@ -78,12 +80,12 @@ sub get_part { FROM parts p JOIN assembly a ON (a.parts_id = p.id) LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) - WHERE a.id = $form->{id} - ORDER BY $oid{$myconfig->{dbdriver}}|; - + WHERE a.id = ? + ORDER BY ?|; + @vars = ($form->{id}, $oid{$myconfig->{dbdriver}}); $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); - + $sth->execute(@vars) || $form->dberror("$query (" . join(', ', @vars) . ")"); + $form->{assembly_rows} = 0; while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { $form->{assembly_rows}++; @@ -105,11 +107,12 @@ sub get_part { # 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} + WHERE parts_id = ? ORDER by pricegroup|; + @vars = ($form->{id}); $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute(@vars) || $form->dberror("$query (" . join(', ', @vars) . ")"); @pricegroups = (); @pricegroups_not_used = (); @@ -177,10 +180,10 @@ sub get_part { # get makes if ($form->{makemodel}) { $query = qq|SELECT m.make, m.model FROM makemodel m - WHERE m.parts_id = $form->{id}|; - + WHERE m.parts_id = ?|; + @vars = ($form->{id}); $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute(@vars) || $form->dberror("$query (" . join(', ', @vars) . ")"); my $i = 1; while (($form->{"make_$i"}, $form->{"model_$i"}) = $sth->fetchrow_array) @@ -195,9 +198,10 @@ sub get_part { # get translations $form->{language_values} = ""; - $query = qq|SELECT language_id, translation FROM translation WHERE parts_id = $form->{id}|; + $query = qq|SELECT language_id, translation FROM translation WHERE parts_id = ?|; + @vars = ($form->{id}); $trq = $dbh->prepare($query); - $trq->execute || $form->dberror($query); + $trq->execute(@vars) || $form->dberror("$query (" . join(', ', @vars) . ")"); while ($tr = $trq->fetchrow_hashref(NAME_lc)) { $form->{language_values} .= "---+++---".$tr->{language_id}."--++--".$tr->{translation}; } @@ -791,7 +795,7 @@ sub adjust_inventory { $sth->finish; # update assembly - my $rc = $form->update_balance($dbh, "parts", "onhand", qq|id = $id|, $qty); + my $rc = $form->update_balance($dbh, "parts", "onhand", qq|id = ?|, $qty, $id); $main::lxdebug->leave_sub(); @@ -1145,7 +1149,7 @@ sub all_parts { p.priceupdate, p.image, p.drawing, p.microfiche, pg.partsgroup, '' AS invnumber, o.ordnumber, o.quonumber, oi.trans_id, - ct.name|; + ct.name, NULL AS deliverydate|; if ($form->{ordered}) { $query .= qq|$union @@ -1172,7 +1176,7 @@ sub all_parts { p.priceupdate, p.image, p.drawing, p.microfiche, pg.partsgroup, '' AS invnumber, o.ordnumber, o.quonumber, oi.trans_id, - ct.name|; + ct.name, NULL AS deliverydate|; $query .= qq|$union SELECT $flds, 'oe' AS module, 'purchase_order' AS type, @@ -1210,7 +1214,7 @@ sub all_parts { p.priceupdate, p.image, p.drawing, p.microfiche, pg.partsgroup, '' AS invnumber, o.ordnumber, o.quonumber, oi.trans_id, - ct.name|; + ct.name, NULL AS deliverydate|; if ($form->{quoted}) { $query .= qq|$union @@ -1237,7 +1241,7 @@ sub all_parts { p.priceupdate, p.image, p.drawing, p.microfiche, pg.partsgroup, '' AS invnumber, o.ordnumber, o.quonumber, oi.trans_id, - ct.name|; + ct.name, NULL AS deliverydate|; $query .= qq|$union SELECT $flds, 'oe' AS module, 'request_quotation' AS type, @@ -1742,7 +1746,7 @@ sub retrieve_languages { } sub follow_account_chain { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(2); my ($self, $form, $dbh, $transdate, $accno_id, $accno) = @_; @@ -1768,13 +1772,13 @@ sub follow_account_chain { push(@visited_accno_ids, $accno_id); } - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(2); return ($accno_id, $accno); } sub retrieve_accounts { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(2); my ($self, $myconfig, $form, $parts_id, $index, $copy_accnos) = @_; @@ -1827,7 +1831,7 @@ sub retrieve_accounts { if (!$ref) { $dbh->disconnect(); - return $main::lxdebug->leave_sub(); + return $main::lxdebug->leave_sub(2); } $ref->{"inventory_accno_id"} = undef unless ($ref->{"is_part"}); @@ -1854,16 +1858,17 @@ sub retrieve_accounts { "WHERE t.id IN " . " (SELECT tk.tax_id " . " FROM taxkeys tk " . - " WHERE tk.chart_id = $accno_id AND startdate <= $transdate " . + " WHERE tk.chart_id = ? AND startdate <= " . quote_db_date($transdate) . " ORDER BY startdate DESC LIMIT 1) "; + @vars = ($accno_id); $sth = $dbh->prepare($query); - $sth->execute() || $form->dberror($query); + $sth->execute(@vars) || $form->dberror("$query (" . join(', ', @vars) . ")"); $ref = $sth->fetchrow_hashref(); $sth->finish(); $dbh->disconnect(); unless ($ref) { - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(2); return; } @@ -1880,6 +1885,7 @@ sub retrieve_accounts { # " || taxaccounts_$index " . $form->{"taxaccounts_$index"} . # " || taxaccounts " . $form->{"taxaccounts"}); - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(2); } + 1;