X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FOE.pm;h=b1e1f9f304e422e2f026c1e3f877458e4790b2e5;hb=d2b06f2b3452f281d68b9df4c1bdabd0f483bbf8;hp=ce8c9281cdbc99802bf022fdf05e8d3036be2c1e;hpb=9bc403900c57c9bc3afd5a1a429d2e1f71dd8aa6;p=kivitendo-erp.git diff --git a/SL/OE.pm b/SL/OE.pm index ce8c9281c..b1e1f9f30 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -41,19 +41,7 @@ use SL::CVar; use SL::DBUtils; use SL::IC; -=head1 NAME - -OE.pm - Order entry module - -=head1 DESCRIPTION - -OE.pm is part of the OE module. OE is responsible for sales and purchase orders, as well as sales quotations and purchase requests. This file abstracts the database tables C and C. - -=head1 FUNCTIONS - -=over 4 - -=cut +use strict; sub transactions { $main::lxdebug->enter_sub(); @@ -88,7 +76,7 @@ sub transactions { qq| ex.$rate AS exchangerate, | . qq| pr.projectnumber AS globalprojectnumber, | . qq| e.name AS employee, s.name AS salesman, | . - qq| ct.country, ct.ustid | . + qq| ct.${vc}number AS vcnumber, ct.country, ct.ustid | . qq|FROM oe o | . qq|JOIN $vc ct ON (o.${vc}_id = ct.id) | . qq|LEFT JOIN employee e ON (o.employee_id = e.id) | . @@ -111,7 +99,18 @@ sub transactions { qq|AND ((globalproject_id = ?) OR EXISTS | . qq| (SELECT * FROM orderitems oi | . qq| WHERE oi.project_id = ? AND oi.trans_id = o.id))|; - push(@values, $form->{"project_id"}, $form->{"project_id"}); + push(@values, conv_i($form->{"project_id"}), conv_i($form->{"project_id"})); + } + + if ($form->{"projectnumber"}) { + $query .= <{"projectnumber"} . "%", "%" . $form->{"projectnumber"} . "%" ; } if ($form->{"${vc}_id"}) { @@ -944,22 +943,6 @@ sub retrieve { return $rc; } -=item retrieve_simple PARAMS - -simple OE retrieval by id. does not look up customer, vendor, units or any other stuff. only oe and orderitems. - - my $order = retrieve_simple(id => 2); - - $order => { - %_OE_CONTENT, - orderitems => [ - %_ORDERITEM_ROW_1, - %_ORDERITEM_ROW_2, - ... - ] - } - -=cut sub retrieve_simple { $main::lxdebug->enter_sub(); @@ -976,8 +959,8 @@ sub retrieve_simple { my $oe_query = qq|SELECT * FROM oe WHERE id = ?|; my $oi_query = qq|SELECT * FROM orderitems WHERE trans_id = ?|; - my ($order) = selectall_array_query($form, $dbh, $oe_query, conv_i($params{id})); - $order->{orderitems} = selectall_array_query($form, $dbh, $oi_query, conv_i($params{id})); + my $order = selectfirst_hashref_query($form, $dbh, $oe_query, conv_i($params{id})); + $order->{orderitems} = selectall_hashref_query( $form, $dbh, $oi_query, conv_i($params{id})); $main::lxdebug->leave_sub(); @@ -1214,13 +1197,13 @@ sub order_details { } $query = qq|SELECT p.partnumber, p.description, p.unit, a.qty, | . - qq|pg.partsgroup | . - qq|FROM assembly a | . - qq| JOIN parts p ON (a.parts_id = p.id) | . - qq| LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) | . - qq| WHERE a.bom = '1' | . - qq| AND a.id = ? | . $sortorder; - @values = ($form->{"id_$i"}); + qq|pg.partsgroup | . + qq|FROM assembly a | . + qq| JOIN parts p ON (a.parts_id = p.id) | . + qq| LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) | . + qq| WHERE a.bom = '1' | . + qq| AND a.id = ? | . $sortorder; + @values = ($form->{"id_$i"}); $sth = $dbh->prepare($query); $sth->execute(@values) || $form->dberror($query); @@ -1294,4 +1277,70 @@ sub project_description { return $value; } +########################## +# Get data for the submitted order id +# from database +# +sub get_order_data_by_ordnumber { + $main::lxdebug->enter_sub(); + + my $self = shift; + my %params = @_; + + Common::check_params(\%params, qw(ordnumber)); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $dbh = $form->get_standard_dbh(); + + my @values = ($params{ordnumber}); + + # We query the database for the fields we need using the submitted "ordnumber" + my $query = <leave_sub(); + + return $result; +} + 1; + +__END__ + +=head1 NAME + +OE.pm - Order entry module + +=head1 DESCRIPTION + +OE.pm is part of the OE module. OE is responsible for sales and purchase orders, as well as sales quotations and purchase requests. This file abstracts the database tables C and C. + +=head1 FUNCTIONS + +=over 4 + +=item retrieve_simple PARAMS + +simple OE retrieval by id. does not look up customer, vendor, units or any other stuff. only oe and orderitems. + + my $order = retrieve_simple(id => 2); + + $order => { + %_OE_CONTENT, + orderitems => [ + %_ORDERITEM_ROW_1, + %_ORDERITEM_ROW_2, + ... + ] + } + +=back + +=cut