# editing without stuff to edit? try adding it first
if ($form->{rowcount}) {
- map { $id++ if $form->{"id_$_"} } (1 .. $form->{rowcount});
+ map { $id++ if $form->{"multi_id_$_"} } (1 .. $form->{rowcount});
if (!$id) {
# reset rowcount
undef $form->{rowcount};
&add;
+ $lxdebug->leave_sub();
return;
}
- } else {
- if (!$form->{id}) {
- &add;
- return;
- }
+ } elsif (!$form->{id}) {
+ &add;
+ $lxdebug->leave_sub();
+ return;
}
if ($form->{print_and_save}) {
# set jscalendar
$form->{jscalendar} = $jscalendar;
+ my $editing = $form->{id};
+
OE->retrieve(\%myconfig, \%$form);
if ($form->{payment_id}) {
$taxzone_id = $form->{taxzone_id};
}
+ $salesman_id = $form->{salesman_id} if ($editing);
+
# if multiple rowcounts (== collective order) then check if the
# there were more than one customer (in that case OE::retrieve removes
if (@{ $form->{"all_$form->{vc}"} }) {
$form->{ $form->{vc} } =
qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
- map { $form->{"select$form->{vc}"} .= "<option>$_->{name}--$_->{id}\n" }
+ map { $form->{"select$form->{vc}"} .=
+"<option>$_->{name}--$_->{id}</option>\n" }
(@{ $form->{"all_$form->{vc}"} });
}
$form->{defaultcurrency} = $curr[0];
$form->{currency} = $form->{defaultcurrency} unless $form->{currency};
- map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
+ map { $form->{selectcurrency} .= "<option>$_</option>\n" } @curr;
$form->{taxincluded} = $taxincluded if ($form->{id});
map {
$form->{selectdepartment} .=
- "<option>$_->{description}--$_->{id}\n"
+ "<option>$_->{description}--$_->{id}</option>\n"
} (@{ $form->{all_departments} });
}
# sales staff
if (@{ $form->{all_employees} }) {
$form->{selectemployee} = "";
- map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
+ map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}</option>\n" }
(@{ $form->{all_employees} });
}
# forex
$form->{forex} = $form->{exchangerate};
+ $form->{salesman_id} = $salesman_id if ($editing);
+
$lxdebug->leave_sub();
}
#quote select[customer|vendor] Bug 133
$form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
+ #substitute \n and \r to \s (bug 543)
+ $form->{"select$form->{vc}"} =~ s/[\n\r]/ /g;
+
my @old_project_ids = ($form->{"globalproject_id"});
map({ push(@old_project_ids, $form->{"project_id_$_"})
if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
"shipto" => "ALL_SHIPTO",
"projects" => { "key" => "ALL_PROJECTS",
"all" => 0,
- "old_id" => \@old_project_ids });
+ "old_id" => \@old_project_ids },
+ "employees" => "ALL_SALESMEN");
- my (%labels, @values);
+ my %labels;
+ my @values = (undef);
foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
push(@values, $item->{"cp_id"});
$labels{$item->{"cp_id"}} = $item->{"cp_name"} .
'-labels' => \%labels,
'-default' => $form->{"globalproject_id"}));
+ $salesman = "";
+ if ($form->{type} =~ /^sales_/) {
+ %labels = ();
+ @values = ("");
+ foreach my $item (@{ $form->{ALL_SALESMEN} }) {
+ push(@values, $item->{id});
+ $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
+ }
+
+ $salesman =
+ qq|<tr>
+ <th align="right">| . $locale->text('Salesman') . qq|</th>
+ <td>| .
+ NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
+ '-values' => \@values, '-labels' => \%labels))
+ . qq|</td>
+ </tr>|;
+ }
+
$form->{exchangerate} =
$form->format_amount(\%myconfig, $form->{exchangerate});
$vc =
($form->{"select$form->{vc}"})
- ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
+ ? qq|<select name="$form->{vc}"
+onchange="document.getElementById('update_button').click();">| .
+ qq|$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="| .
+ Q($form->{"select$form->{vc}"}) . qq|">|
: qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
$department = qq|
<table>
$openclosed
$employee
+ $salesman
$ordnumber
<tr>
<th width="70%" align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
<td>$intnotes</td>
</tr>
<th align=right>| . $locale->text('Payment Terms') . qq|</th>
- <td><select name=payment_id tabindex=24>$payment
+ <td><select name=payment_id>$payment
</select></td>
</table>
</td>
<tr>
<td>
|;
- &print_options;
+ print_options();
print qq|
</td>
$form->all_vc(\%myconfig, $form->{vc},
($form->{vc} eq 'customer') ? "AR" : "AP");
- map { $vc .= "<option>$_->{name}--$_->{id}\n" }
+ map { $vc .= "<option>$_->{name}--$_->{id}</option>\n" }
@{ $form->{"all_$form->{vc}"} };
$vclabel = ucfirst $form->{vc};
$vc =
($vc)
- ? qq|<select name=$form->{vc}><option>\n$vc</select>|
+ ? qq|<select name=$form->{vc}><option>\n$vc</option></select>|
: qq|<input name=$form->{vc} size=35>|;
# departments
map {
$form->{selectdepartment} .=
- "<option>$_->{description}--$_->{id}\n"
+ "<option>$_->{description}--$_->{id}</option>\n"
} (@{ $form->{all_departments} });
}
<table>
<tr>
<th align=right>$vclabel</th>
- <td colspan=3>$vc</td>
+ <td colspan="3">$vc</td>
</tr>
$department
<tr>
$subtotalamount += $oe->{amount};
$column_data{ids} =
- qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
+ qq|<td><input name="multi_id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
$column_data{id} = "<td>$oe->{id}</td>";
$column_data{transdate} = "<td>$oe->{transdate} </td>";
$column_data{reqdate} = "<td>$oe->{reqdate} </td>";
OE->close_order(\%myconfig, \%$form);
}
+ if ($form->{type} =~ /^sales_/) {
+ delete($form->{ordnumber});
+ }
+
$form->{cp_id} *= 1;
$form->{title} = $locale->text('Add Purchase Order');
OE->close_order(\%myconfig, $form);
}
+ if ($form->{type} eq "purchase_order") {
+ delete($form->{ordnumber});
+ }
+
$form->{cp_id} *= 1;
$form->{title} = $locale->text('Add Sales Order');
sub e_mail {
$lxdebug->enter_sub();
- $form->{saveasnew} = 1;
- $form->{closed} = 0;
$form->{print_and_save} = 1;
- map { delete $form->{$_} } qw(printed emailed queued);
- # Let Lx-Office assign a new order number if the user hasn't changed the
- # previous one. If it has been changed manually then use it as-is.
- my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
- if ($form->{saved_xyznumber} &&
- ($form->{saved_xyznumber} eq $form->{$idx})) {
- delete($form->{$idx});
- }
+ if (!$form->{id}) {
+ $print_post = 1;
- &save;
+ my $saved_form = save_form();
+
+ save();
+
+ my %saved_vars;
+ map({ $saved_vars{$_} = $form->{$_}; } qw(id ordnumber quonumber));
+ restore_form($saved_form);
+ map({ $form->{$_} = $saved_vars{$_}; } qw(id ordnumber quonumber));
+ }
- &edit_e_mail;
+ edit_e_mail();
$lxdebug->leave_sub();
}