# Hier wird das prepared Statement für die Schleife über alle Lagerplätze vorbereitet
my $transferPartSQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, comment, employee_id, qty, trans_id, trans_type_id)
- VALUES (?, ?, ?, ?, ?,(SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
+ VALUES (?, ?, ?, ?, ?,(SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
(SELECT id FROM transfer_type WHERE direction = 'out' AND description = 'used'))|;
my $sthTransferPartSQL = prepare_query($form, $dbh, $transferPartSQL);
my $kannNichtFertigen =""; # der return-string für die fehlermeldung inkl. welche waren zum fertigen noch fehlen
- while (my $hash_ref = $sth_part_qty_assembly->fetchrow_hashref()) { # Schleife für $query=select parts_id,qty from assembly
+ while (my $hash_ref = $sth_part_qty_assembly->fetchrow_hashref()) { # Schleife für $query=select parts_id,qty from assembly
my $partsQTY = $hash_ref->{qty} * $params{qty}; # benötigte teile * anzahl erzeugnisse
my $currentPart_ID = $hash_ref->{parts_id};
return $kannNichtFertigen;
}
- # soweit alles gut. Jetzt noch die wirkliche Lagerbewegung für das Erzeugnis ausführen ...
+ # soweit alles gut. Jetzt noch die wirkliche Lagerbewegung für das Erzeugnis ausführen ...
my $transferAssemblySQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, comment, employee_id, qty, trans_id, trans_type_id)
- VALUES (?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
+ VALUES (?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
(SELECT id FROM transfer_type WHERE direction = 'in' AND description = 'stock'))|;
my $sthTransferAssemblySQL = prepare_query($form, $dbh, $transferAssemblySQL);
do_statement($form, $sthTransferAssemblySQL, $transferAssemblySQL, $params{assembly_id}, $params{dst_warehouse_id}, $params{dst_bin_id}, $params{chargenumber}, $params{comment}, $params{login}, $params{qty});
"comment" => "i1.comment",
"trans_type" => "tt.description",
"trans_id" => "i1.trans_id",
+ "oe_id" => "COALESCE(i1.oe_id, i2.oe_id)",
"date" => "i1.itime::DATE",
"itime" => "i1.itime",
"employee" => "e.name",
my $sth = prepare_execute_query($form, $dbh, $query, @filter_vars, @filter_vars, @filter_vars);
+ my ($h_oe_id, $q_oe_id);
+ if ($form->{l_oe_id}) {
+ $q_oe_id = <<SQL;
+ SELECT oe.id AS id,
+ CASE WHEN oe.quotation THEN oe.quonumber ELSE oe.ordnumber END AS number,
+ CASE
+ WHEN oe.customer_id IS NOT NULL AND COALESCE(oe.quotation, FALSE) THEN 'sales_quotation'
+ WHEN oe.customer_id IS NOT NULL AND NOT COALESCE(oe.quotation, FALSE) THEN 'sales_order'
+ WHEN oe.customer_id IS NULL AND COALESCE(oe.quotation, FALSE) THEN 'request_quotation'
+ ELSE 'purchase_order'
+ END AS type
+ FROM oe
+ WHERE oe.id = ?
+
+ UNION
+
+ SELECT dord.id AS id, dord.donumber AS number,
+ CASE
+ WHEN dord.customer_id IS NULL THEN 'purchase_delivery_order'
+ ELSE 'sales_delivery_order'
+ END AS type
+ FROM delivery_orders dord
+ WHERE dord.id = ?
+
+ UNION
+
+ SELECT ar.id AS id, ar.invnumber AS number, 'sales_invoice' AS type
+ FROM ar
+ WHERE ar.id = ?
+
+ UNION
+
+ SELECT ap.id AS id, ap.invnumber AS number, 'purchase_invoice' AS type
+ FROM ap
+ WHERE ap.id = ?
+SQL
+ $h_oe_id = prepare_query($form, $dbh, $q_oe_id);
+ }
+
my @contents = ();
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
map { /^r_/; $ref->{"$'"} = $ref->{$_} } keys %$ref;
next if (('<=' eq $f_qty_op) && ($qty > $f_qty));
}
+ if ($h_oe_id && $ref->{oe_id}) {
+ do_statement($form, $h_oe_id, $q_oe_id, ($ref->{oe_id}) x 4);
+ $ref->{oe_id_info} = $h_oe_id->fetchrow_hashref() || {};
+ }
+
push @contents, $ref;
}
$sth->finish();
+ $h_oe_id->finish() if $h_oe_id;
$main::lxdebug->leave_sub();
my $self = shift;
my %params = @_;
- Common::check_params(\%params, qw(parts_id warehouse_id)); #die brauchen wir
+ Common::check_params(\%params, qw(parts_id warehouse_id)); #die brauchen wir
my $myconfig = \%main::myconfig;
my $form = $main::form;
my $query = qq| SELECT SUM(qty), bin_id, chargenumber FROM inventory where parts_id = ? AND warehouse_id = ? GROUP BY bin_id, chargenumber|;
my $sth_QTY = prepare_execute_query($form, $dbh, $query, ,$params{parts_id}, $params{warehouse_id}); #info: aufruf an DBUtils.pm
-
+
my $max_qty_parts = 0; #Initialisierung mit 0
while (my $ref = $sth_QTY->fetchrow_hashref()) { # wir laufen über alle chargen und Lagerorte (s.a. SQL-Query oben)
- $max_qty_parts += $ref->{sum};
+ $max_qty_parts += $ref->{sum};
}
$main::lxdebug->leave_sub();
my $self = shift;
my %params = @_;
- Common::check_params(\%params, qw(parts_id )); #die brauchen wir
+ Common::check_params(\%params, qw(parts_id )); #die brauchen wir
my $myconfig = \%main::myconfig;
my $form = $main::form;
my $query = qq| SELECT partnumber, description FROM parts where id = ? |;
my $sth = prepare_execute_query($form, $dbh, $query, ,$params{parts_id}); #info: aufruf zu DBUtils.pm
-
- my $ref = $sth->fetchrow_hashref();
- my $part_description = $ref->{partnumber} . " " . $ref->{description};
+
+ my $ref = $sth->fetchrow_hashref();
+ my $part_description = $ref->{partnumber} . " " . $ref->{description};
$main::lxdebug->leave_sub();
$form->{sort} ||= 'date';
my %filter;
- my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber partdescription chargenumber trans_type comment qty employee projectnumber);
+ my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber partdescription chargenumber trans_type comment qty employee oe_id projectnumber);
# filter stuff
map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber);
'qty' => { 'text' => $locale->text('Qty'), },
'employee' => { 'text' => $locale->text('Employee'), },
'projectnumber' => { 'text' => $locale->text('Project Number'), },
+ 'oe_id' => { 'text' => $locale->text('Document'), },
);
my $href = build_std_url('action=generate_journal', grep { $form->{$_} } @hidden_variables);
my $all_units = AM->retrieve_units(\%myconfig, $form);
my @contents = WH->get_warehouse_journal(%filter);
+ my %doc_types = ( 'sales_quotation' => { script => 'oe', title => $locale->text('Sales quotation') },
+ 'sales_order' => { script => 'oe', title => $locale->text('Sales Order') },
+ 'request_quotation' => { script => 'oe', title => $locale->text('Request quotation') },
+ 'purchase_order' => { script => 'oe', title => $locale->text('Purchase Order') },
+ 'sales_delivery_order' => { script => 'do', title => $locale->text('Sales delivery order') },
+ 'purchase_delivery_order' => { script => 'do', title => $locale->text('Purchase delivery order') },
+ 'sales_invoice' => { script => 'is', title => $locale->text('Sales Invoice') },
+ 'purchase_invoice' => { script => 'ir', title => $locale->text('Purchase Invoice') },
+ );
+
foreach $entry (@contents) {
$entry->{qty} = $form->format_amount_units('amount' => $entry->{qty},
'part_unit' => $entry->{partunit},
'align' => $column_alignment{trans_type},
};
+ if ($form->{l_oe_id}) {
+ $row->{oe_id}->{data} = '';
+ my $info = $entry->{oe_id_info};
+
+ if ($info && $info->{id} && $info->{type} && $doc_types{$info->{type}}) {
+ $row->{oe_id} = { data => $doc_types{ $info->{type} }->{title} . ' ' . $info->{number},
+ link => build_std_url('script=' . $doc_types{ $info->{type} }->{script} . '.pl', 'action=edit', 'id=' . $info->{id}, 'type=' . $info->{type}) };
+ }
+ }
+
$report->add_data($row);
}
'Do you want to <b>limit</b> your search?' => 'Wollen Sie Ihre Suche <b>spezialisieren</b>?',
'Do you want to carry this shipping address over to the new purchase order so that the vendor can deliver the goods directly to your customer?' => 'Wollen Sie diese Lieferadresse in den neuen Lieferantenauftrag übernehmen, damit der Händler die Waren direkt an Ihren Kunden liefern kann?',
'Do you want to store the existing onhand values into a new warehouse?' => 'Möchten Sie die vorhandenen Mengendaten in ein Lager übertragen?',
+ 'Document' => 'Dokument',
'Documents in the WebDAV repository' => 'Dokumente im WebDAV-Repository',
'Done' => 'Fertig',
'Download the backup' => 'Die Sicherungsdatei herunterladen',
'Projects' => 'Projekte',
'Projecttransactions' => 'Projektbuchungen',
'Prozentual/Absolut' => 'Prozentual/Absolut',
+ 'Purchase Invoice' => 'Einkaufsrechnung',
'Purchase Order' => 'Lieferantenauftrag',
'Purchase Orders' => 'Lieferantenaufträge',
'Purchase Price' => 'Einkaufspreis',
'Purchase Prices' => 'Einkaufspreise',
+ 'Purchase delivery order' => 'Lieferschein (Einkauf)',
'Purchase invoices' => 'Einkaufsrechnungen',
'Qty' => 'Menge',
'Qty according to delivery order' => 'Menge laut Lieferschein',
'Sales Order' => 'Kundenauftrag',
'Sales Orders' => 'Aufträge',
'Sales and purchase invoices with inventory transactions with taxkeys' => 'Einkaufs- und Verkaufsrechnungen mit Warenbestandsbuchungen mit Steuerschlüsseln',
+ 'Sales delivery order' => 'Lieferschein (Verkauf)',
'Sales invoice number' => 'Ausgangsrechnungsnummer',
'Sales invoices' => 'Verkaufsrechnungen',
'Sales quotation' => 'Angebot',
'Dependency loop detected:' => 'Schleife in den Abhängigkeiten entdeckt:',
'Description' => 'Beschreibung',
'Directory' => 'Verzeichnis',
+ 'Document' => 'Dokument',
'Dunning' => 'Mahnung',
'ELSE' => 'Zusatz',
'Employee' => 'Bearbeiter',
'Produce Assembly' => 'Erzeugnis fertigen',
'Proforma Invoice' => 'Proformarechnung',
'Project Number' => 'Projektnummer',
+ 'Purchase Invoice' => 'Einkaufsrechnung',
'Purchase Order' => 'Lieferantenauftrag',
+ 'Purchase delivery order' => 'Lieferschein (Einkauf)',
'Qty' => 'Menge',
'Quantity missing.' => 'Die Mengenangabe fehlt.',
'Quotation' => 'Angebot',
'SCREENED' => 'Angezeigt',
'Sales Invoice' => 'Rechnung',
'Sales Order' => 'Kundenauftrag',
+ 'Sales delivery order' => 'Lieferschein (Verkauf)',
'Sales quotation' => 'Angebot',
'Select a Customer' => 'Endkunde auswählen',
'Select a customer' => 'Einen Kunden auswählen',
<tr>
<td align="right"><input name="l_employee" id="l_employee" class="checkbox" type="checkbox" value="Y"></td>
<td nowrap><label for="l_employee">Bearbeiter</label></td>
+ <td align="right"><input name="l_oe_id" id="l_oe_id" class="checkbox" type="checkbox" value="Y"></td>
+ <td nowrap><label for="l_oe_id">Dokument</label></td>
<td align="right"><input name="l_projectnumber" id="l_projectnumber" class="checkbox" type="checkbox" value="Y" checked></td>
<td nowrap><label for="l_projectnumber">Projektnummer</label></td>
</tr>
<tr>
<td align="right"><input name="l_employee" id="l_employee" class="checkbox" type="checkbox" value="Y"></td>
<td nowrap><label for="l_employee"><translate>Employee</translate></label></td>
+ <td align="right"><input name="l_oe_id" id="l_oe_id" class="checkbox" type="checkbox" value="Y"></td>
+ <td nowrap><label for="l_oe_id"><translate>Document</translate></label></td>
<td align="right"><input name="l_projectnumber" id="l_projectnumber" class="checkbox" type="checkbox" value="Y" checked></td>
<td nowrap><label for="l_projectnumber"><translate>Project Number</translate></label></td>
</tr>