if (!$all) {
$where = "WHERE active ";
if ($old_id) {
- $where .= " OR (id = ?) ";
- push(@values, $old_id);
+ if (ref($old_id) eq "ARRAY") {
+ my @ids = grep({ $_ } @{$old_id});
+ if (@ids) {
+ $where .= " OR id IN (" . join(",", map({ "?" } @ids)) . ") ";
+ push(@values, @ids);
+ }
+ } else {
+ $where .= " OR (id = ?) ";
+ push(@values, $old_id);
+ }
}
}
}
- $project_id = 'NULL';
- if ($form->{"projectnumber_$i"}) {
- $project_id = $form->{"projectnumber_$i"};
- }
$deliverydate =
($form->{"deliverydate_$i"})
? qq|'$form->{"deliverydate_$i"}'|
VALUES ($form->{id}, $form->{"id_$i"},
'$form->{"description_$i"}', | . ($form->{"qty_$i"} * -1) . qq|, | . ($baseqty * -1) . qq|,
$form->{"sellprice_$i"}, $fxsellprice, $allocated,
- '$form->{"unit_$i"}', $deliverydate, (SELECT id FROM project WHERE projectnumber = '$project_id'),
+ '$form->{"unit_$i"}', $deliverydate, | . conv_i($form->{"project_id_$i"}) . qq|,
'$form->{"serialnumber_$i"}')|;
$dbh->do($query) || $form->dberror($query);
}
curr = '$form->{currency}',
department_id = $form->{department_id},
storno = '$form->{storno}',
+ globalproject_id = | . conv_i($form->{"globalproject_id"}, 'NULL') . qq|,
cp_id = | . conv_i($form->{cp_id}, 'NULL') . qq|
WHERE id = $form->{id}|;
$dbh->do($query) || $form->dberror($query);
# retrieve invoice
$query = qq|SELECT a.cp_id, a.invnumber, a.transdate AS invdate, a.duedate,
- a.orddate, a.quodate,
+ a.orddate, a.quodate, a.globalproject_id,
a.ordnumber, a.quonumber, a.paid, a.taxincluded, a.notes, a.taxzone_id, a.storno, a.gldate,
a.intnotes, a.curr AS currency
FROM ap a
}
}
- $project_id = 'NULL';
- if ($form->{"projectnumber_$i"}) {
- $project_id = $form->{"projectnumber_$i"};
- }
$deliverydate =
($form->{"deliverydate_$i"})
? qq|'$form->{"deliverydate_$i"}'|
'$form->{"description_$i"}', '$form->{"longdescription_$i"}', $form->{"qty_$i"},
$form->{"sellprice_$i"}, $fxsellprice,
$form->{"discount_$i"}, $allocated, 'f',
- '$form->{"unit_$i"}', $deliverydate, (SELECT id from project where projectnumber = '$project_id'),
+ '$form->{"unit_$i"}', $deliverydate, | . conv_i($form->{"project_id_$i"}) . qq|,
'$form->{"serialnumber_$i"}', '$pricegroup_id',
'$form->{"ordnumber_$i"}', '$form->{"transdate_$i"}', '$form->{"cusordnumber_$i"}', $baseqty, '$subtotal')|;
$dbh->do($query) || $form->dberror($query);
delivery_vendor_id = $form->{delivery_vendor_id},
employee_id = $form->{employee_id},
storno = '$form->{storno}',
+ globalproject_id = | . conv_i($form->{"globalproject_id"}, 'NULL') . qq|,
cp_id = | . conv_i($form->{"cp_id"}, 'NULL') . qq|
WHERE id = $form->{id}
|;
# retrieve invoice
$query = qq|SELECT a.invnumber, a.ordnumber, a.quonumber, a.cusordnumber,
- a.orddate, a.quodate,
+ a.orddate, a.quodate, a.globalproject_id,
a.transdate AS invdate, a.deliverydate, a.paid, a.storno, a.gldate,
a.shippingpoint, a.shipvia, a.terms, a.notes, a.intnotes, a.taxzone_id,
a.duedate, a.taxincluded, a.curr AS currency, a.shipto_id, a.cp_id,
$netamount += $form->{"sellprice_$i"} * $form->{"qty_$i"};
- $project_id = 'NULL';
- if ($form->{"projectnumber_$i"}) {
- $project_id = $form->{"projectnumber_$i"};
- }
$reqdate =
($form->{"reqdate_$i"}) ? qq|'$form->{"reqdate_$i"}'| : "NULL";
$query .= qq|$form->{id}, $form->{"id_$i"},
'$form->{"description_$i"}', '$form->{"longdescription_$i"}', $form->{"qty_$i"}, $baseqty,
$fxsellprice, $form->{"discount_$i"},
- '$form->{"unit_$i"}', $reqdate, (SELECT id from project where projectnumber = '$project_id'),
+ '$form->{"unit_$i"}', $reqdate, | . conv_i($form->{"project_id_$i"}, 'NULL') . qq|,
'$form->{"serialnumber_$i"}', $form->{"ship_$i"}, '$pricegroup_id',
'$form->{"ordnumber_$i"}', '$form->{"transdate_$i"}', '$form->{"cusordnumber_$i"}', '$subtotal')|;
$dbh->do($query) || $form->dberror($query);
o.closed, o.reqdate, o.quonumber, o.department_id, o.cusordnumber,
d.description AS department, o.payment_id, o.language_id, o.taxzone_id,
o.delivery_customer_id, o.delivery_vendor_id, o.proforma, o.shipto_id,
- o.globalproject_id, pr.projectnumber AS globalprojectnumber,
+ o.globalproject_id,
o.delivered
FROM oe o
JOIN $form->{vc} cv ON (o.$form->{vc}_id = cv.id)
LEFT JOIN employee e ON (o.employee_id = e.id)
LEFT JOIN department d ON (o.department_id = d.id)
- LEFT JOIN project pr ON (o.globalproject_id = pr.id)
|
. ($form->{id}
? qq|WHERE o.id = $form->{id}|
sub check_project {
$lxdebug->enter_sub();
- for $i (0 .. $form->{rowcount}) {
+ for $i (1 .. $form->{rowcount}) {
my $suffix = $i ? "_$i" : "";
my $prefix = $i ? "" : "global";
$form->{"${prefix}project_id${suffix}"} = "" unless $form->{"${prefix}projectnumber$suffix"};
return $form->escape($_[0]);
}
+sub NTI {
+ my ($element) = @_;
+
+ $element =~ s/tabindex\s*=\s*"\d+"//;
+ return $element;
+}
+
sub format_dates {
$lxdebug->enter_sub();
$delvar = 'reqdate';
}
+ my %projectnumber_labels = ();
+ my @projectnumber_values = ("");
+ foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+ push(@projectnumber_values, $item->{"id"});
+ $projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"};
+ }
+
for $i (1 .. $numrows) {
# undo formatting
<b>$serialnumber</b> <input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}">|;
}
- print qq|
- <b>$projectnumber</b> <input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}">
- <input type=hidden name="oldprojectnumber_$i" value="$form->{"projectnumber_$i"}">
- <input type=hidden name="project_id_$i" value="$form->{"project_id_$i"}">
-|;
+ print qq|<b>$projectnumber</b> | .
+ NTI($cgi->popup_menu('-name' => "project_id_$i",
+ '-values' => \@projectnumber_values,
+ '-labels' => \%projectnumber_labels,
+ '-default' => $form->{"project_id_$i"}));
+
if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
my $reqdate_term =
($form->{type} eq 'invoice')
relink_accounts();
+ my $new_rowcount = $form->{"rowcount"} * 1 + 1;
+ $form->{"project_id_${new_rowcount}"} = $form->{"globalproject_id"};
+
$form->language_payment(\%myconfig);
# if we have a display_form
require "$form->{path}/io.pl";
require "$form->{path}/arap.pl";
+require "$form->{path}/common.pl";
1;
<input type=hidden name=forex value=$form->{forex}>
|;
- $form->get_lists("contacts" => "ALL_CONTACTS");
+ my @old_project_ids = ($form->{"globalproject_id"});
+ map({ push(@old_project_ids, $form->{"project_id_$_"})
+ if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
+ $form->get_lists("contacts" => "ALL_CONTACTS",
+ "projects" => { "key" => "ALL_PROJECTS",
+ "all" => 0,
+ "old_id" => \@old_project_ids });
my (%labels, @values);
foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
}
my $contact =
- $cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{"cp_id"});
+ NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
+ '-labels' => \%labels, '-default' => $form->{"cp_id"}));
+
+ %labels = ();
+ @values = ("");
+ foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"projectnumber"};
+ }
+ my $globalprojectnumber =
+ NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
+ '-labels' => \%labels,
+ '-default' => $form->{"globalproject_id"}));
if (@{ $form->{TAXZONE} }) {
$form->{selecttaxzone} = "";
</tr>
<tr>
<th align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
- <td>
- <input name="globalprojectnumber" size="11" value="| . Q($form->{globalprojectnumber}) . qq|">
- <input type="hidden" name="oldglobalprojectnumber" value="| . Q($form->{globalprojectnumber}) . qq|">
- <input type="hidden" name="globalproject_id" value="| . Q($form->{globalproject_id}) . qq|">
- </td:>
+ <td>$globalprojectnumber</td>
</tr>
</table>
</td>
&check_name(vendor);
- &check_project;
-
$form->{exchangerate} = $exchangerate
if (
$form->{forex} = (
<input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
</tr>|;
+ my @old_project_ids = ($form->{"globalproject_id"});
+ map({ push(@old_project_ids, $form->{"project_id_$_"})
+ if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
$form->get_lists("contacts" => "ALL_CONTACTS",
- "shipto" => "ALL_SHIPTO");
+ "shipto" => "ALL_SHIPTO",
+ "projects" => { "key" => "ALL_PROJECTS",
+ "all" => 0,
+ "old_id" => \@old_project_ids });
my (%labels, @values);
foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
}
my $contact =
- $cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{"cp_id"});
+ NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
+ '-labels' => \%labels, '-default' => $form->{"cp_id"}));
%labels = ();
@values = ("");
my $shipto = qq|
<th align=right>| . $locale->text('Shipping Address') . qq|</th>
<td>| .
- $cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{"shipto_id"})
+ NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
+ '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
. qq|</td>|;
+ %labels = ();
+ @values = ("");
+ foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"projectnumber"};
+ }
+ my $globalprojectnumber =
+ NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
+ '-labels' => \%labels,
+ '-default' => $form->{"globalproject_id"}));
+
# set option selected
foreach $item (qw(AR customer currency department employee)) {
$form->{"select$item"} =~ s/ selected//;
</tr>
<tr>
<th align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
- <td>
- <input name="globalprojectnumber" size="11" value="| . Q($form->{globalprojectnumber}) . qq|">
- <input type="hidden" name="oldglobalprojectnumber" value="| . Q($form->{globalprojectnumber}) . qq|">
- <input type="hidden" name="globalproject_id" value="| . Q($form->{globalproject_id}) . qq|">
- </td>
+ <td>$globalprojectnumber</td>
</tr>
</table>
</td>
&check_name(customer);
- &check_project;
-
$form->{exchangerate} = $exchangerate
if (
$form->{forex} = (
#quote select[customer|vendor] Bug 133
$form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
+ my @old_project_ids = ($form->{"globalproject_id"});
+ map({ push(@old_project_ids, $form->{"project_id_$_"})
+ if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
$form->get_lists("contacts" => "ALL_CONTACTS",
"shipto" => "ALL_SHIPTO",
"projects" => { "key" => "ALL_PROJECTS",
"all" => 0,
- "old_id" => $form->{"globalproject_id"} });
+ "old_id" => \@old_project_ids });
my (%labels, @values);
foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
}
my $contact =
- $cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{"cp_id"});
+ NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
+ '-labels' => \%labels, '-default' => $form->{"cp_id"}));
%labels = ();
@values = ("");
$item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"};
}
+ my $shipto = qq|
+ <th align=right>| . $locale->text('Shipping Address') . qq|</th>
+ <td>| .
+ NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
+ '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
+ . qq|</td>|;
+
%labels = ();
@values = ("");
foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
$labels{$item->{"id"}} = $item->{"projectnumber"};
}
my $globalprojectnumber =
- $cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
- '-labels' => \%labels,
- '-default' => $form->{"globalproject_id"});
-
- my $shipto = qq|
- <th align=right>| . $locale->text('Shipping Address') . qq|</th>
- <td>| .
- $cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{"shipto_id"})
- . qq|</td>|;
+ NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
+ '-labels' => \%labels,
+ '-default' => $form->{"globalproject_id"}));
$form->{exchangerate} =
$form->format_amount(\%myconfig, $form->{exchangerate});
&check_name($form->{vc});
- &check_project;
-
$buysell = 'buy';
$buysell = 'sell' if ($form->{vc} eq 'vendor');
$form->{exchangerate} = $exchangerate
$self->{subs} = {
'E' => 'E',
'H' => 'H',
+ 'NTI' => 'NTI',
'Q' => 'Q',
'account_header' => 'account_header',
'add' => 'add',
$self->{subs} = {
'E' => 'E',
'H' => 'H',
+ 'NTI' => 'NTI',
'Q' => 'Q',
'add' => 'add',
'add_transaction' => 'add_transaction',
$self->{subs} = {
'E' => 'E',
'H' => 'H',
+ 'NTI' => 'NTI',
'Q' => 'Q',
'build_std_url' => 'build_std_url',
'calculate_qty' => 'calculate_qty',
$self->{subs} = {
'E' => 'E',
'H' => 'H',
+ 'NTI' => 'NTI',
'Q' => 'Q',
'add' => 'add',
'add_transaction' => 'add_transaction',
$self->{subs} = {
'E' => 'E',
'H' => 'H',
+ 'NTI' => 'NTI',
'Q' => 'Q',
'add' => 'add',
'addtop100' => 'addtop100',
$self->{subs} = {
'E' => 'E',
'H' => 'H',
+ 'NTI' => 'NTI',
'Q' => 'Q',
'build_std_url' => 'build_std_url',
'calculate_qty' => 'calculate_qty',
$self->{subs} = {
'E' => 'E',
'H' => 'H',
+ 'NTI' => 'NTI',
'Q' => 'Q',
'add' => 'add',
'add_transaction' => 'add_transaction',
$self->{subs} = {
'E' => 'E',
'H' => 'H',
+ 'NTI' => 'NTI',
'Q' => 'Q',
'add' => 'add',
'add_transaction' => 'add_transaction',
$self->{subs} = {
'E' => 'E',
'H' => 'H',
+ 'NTI' => 'NTI',
'Q' => 'Q',
'add' => 'add',
'add_transaction' => 'add_transaction',