X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIC.pm;h=2a9460745cac60b075bf1840fc3528b65758b792;hb=15aab04c1710b3c8a2bf8785aef31f13a958a43e;hp=d692b6a7588ac3a787e17770e057cb2abd9cf7ae;hpb=213317d3ebd9073e68ac4d0cc789b94c377f575e;p=kivitendo-erp.git diff --git a/SL/IC.pm b/SL/IC.pm index d692b6a75..2a9460745 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -25,7 +25,8 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1335, USA. #====================================================================== # # Inventory Control backend @@ -33,275 +34,20 @@ #====================================================================== package IC; -use Data::Dumper; -use SL::DBUtils; - -sub get_part { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - # connect to db - my $dbh = $form->dbconnect($myconfig); - - my $query = qq|SELECT p.*, - c1.accno AS inventory_accno, - c2.accno AS income_accno, - c3.accno AS expense_accno, - pg.partsgroup - FROM parts p - LEFT JOIN chart c1 ON (p.inventory_accno_id = c1.id) - 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 = ? |; - my @vars = ($form->{id}); - my $sth = $dbh->prepare($query); - $sth->execute(@vars) || $form->dberror("$query (" . join(', ', @vars) . ")"); - my $ref = $sth->fetchrow_hashref(NAME_lc); - - # copy to $form variables - map { $form->{$_} = $ref->{$_} } (keys %{$ref}); - - $sth->finish; - - my %oid = ('Pg' => 'a.oid', - 'Oracle' => 'a.rowid'); - - # part or service item - $form->{item} = ($form->{inventory_accno}) ? 'part' : 'service'; - if ($form->{assembly}) { - $form->{item} = 'assembly'; - - # retrieve assembly items - $query = qq|SELECT p.id, p.partnumber, p.description, - p.sellprice, p.weight, a.qty, a.bom, p.unit, - pg.partsgroup - 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 = ? - ORDER BY ?|; - @vars = ($form->{id}, $oid{$myconfig->{dbdriver}}); - $sth = $dbh->prepare($query); - $sth->execute(@vars) || $form->dberror("$query (" . join(', ', @vars) . ")"); - - $form->{assembly_rows} = 0; - while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { - $form->{assembly_rows}++; - foreach my $key (keys %{$ref}) { - $form->{"${key}_$form->{assembly_rows}"} = $ref->{$key}; - } - } - $sth->finish; - - } - - # setup accno hash for