- # retrieve order for single id
- # NOTE: this query is intended to fetch all information only ONCE.
- # so if any of these infos is important (or even different) for any item,
- # it will be killed out and then has to be fetched from the item scope query further down
- $query =
- qq|SELECT dord.cp_id, dord.donumber, dord.ordnumber, dord.transdate, dord.reqdate,
- dord.shippingpoint, dord.shipvia, dord.notes, dord.intnotes,
- e.name AS employee, dord.employee_id, dord.salesman_id,
- dord.${vc}_id, cv.name AS ${vc},
- dord.closed, dord.reqdate, dord.department_id, dord.cusordnumber,
- d.description AS department, dord.language_id,
- dord.shipto_id,
- dord.globalproject_id, dord.delivered, dord.transaction_description
- FROM delivery_orders dord
- JOIN ${vc} cv ON (dord.${vc}_id = cv.id)
- LEFT JOIN employee e ON (dord.employee_id = e.id)
- LEFT JOIN department d ON (dord.department_id = d.id)
- WHERE dord.id = ?|;
- $sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id}));
-
- $ref = $sth->fetchrow_hashref(NAME_lc);
- $sth->finish();
+ $main::lxdebug->leave_sub();
+
+ return 1;
+ }
+
+ my @do_ids = map { conv_i($_) } ($mode eq 'multi' ? @{ $params{ids} } : ($params{ids}));
+ my $do_ids_placeholders = join(', ', ('?') x scalar(@do_ids));
+
+ # retrieve order for single id
+ # NOTE: this query is intended to fetch all information only ONCE.
+ # so if any of these infos is important (or even different) for any item,
+ # it will be killed out and then has to be fetched from the item scope query further down
+ $query =
+ qq|SELECT dord.cp_id, dord.donumber, dord.ordnumber, dord.transdate, dord.reqdate,
+ dord.shippingpoint, dord.shipvia, dord.notes, dord.intnotes,
+ e.name AS employee, dord.employee_id, dord.salesman_id,
+ dord.${vc}_id, cv.name AS ${vc},
+ dord.closed, dord.reqdate, dord.department_id, dord.cusordnumber,
+ d.description AS department, dord.language_id,
+ dord.shipto_id,
+ dord.globalproject_id, dord.delivered, dord.transaction_description,
+ dord.taxzone_id, dord.taxincluded, dord.terms, (SELECT cu.name FROM currencies cu WHERE cu.id=dord.currency_id) AS currency,
+ dord.delivery_term_id, dord.itime::DATE AS insertdate
+ FROM delivery_orders dord
+ JOIN ${vc} cv ON (dord.${vc}_id = cv.id)
+ LEFT JOIN employee e ON (dord.employee_id = e.id)
+ LEFT JOIN department d ON (dord.department_id = d.id)
+ WHERE dord.id IN ($do_ids_placeholders)|;
+ $sth = prepare_execute_query($form, $dbh, $query, @do_ids);
+
+ delete $form->{"${vc}_id"};
+ my $pos = 0;
+ $form->{ordnumber_array} = ' ';
+ $form->{cusordnumber_array} = ' ';
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ if ($form->{"${vc}_id"} && ($ref->{"${vc}_id"} != $form->{"${vc}_id"})) {
+ $sth->finish();
+ $main::lxdebug->leave_sub();
+
+ return 0;
+ }