my $checkedclosed = $form->{"closed"} ? "checked" : "";
my $checkeddelivered = $form->{"delivered"} ? "checked" : "";
+ if ($form->{old_employee_id}) {
+ $form->{employee_id} = $form->{old_employee_id};
+ }
+ if ($form->{old_salesman_id}) {
+ $form->{salesman_id} = $form->{old_salesman_id};
+ }
+
map { $form->{$_} =~ s/\"/"/g }
qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
}
# set option selected
- foreach $item ($form->{vc}, currency, department, employee, ($form->{vc} eq "customer" ? customer : vendor)) {
+ foreach $item ($form->{vc}, currency, department, ($form->{vc} eq "customer" ? customer : vendor)) {
$form->{"select$item"} =~ s/ selected//;
$form->{"select$item"} =~
s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
"projects" => { "key" => "ALL_PROJECTS",
"all" => 0,
"old_id" => \@old_project_ids },
- "employees" => "ALL_SALESMEN",
+ "employees" => "ALL_EMPLOYEES",
+ "salesmen" => "ALL_SALESMEN",
"taxzones" => "ALL_TAXZONES",
"payments" => "ALL_PAYMENTS",
"currencies" => "ALL_CURRENCIES",
@values = ();
foreach my $item (@{ $form->{($form->{vc} eq "customer" ? "ALL_CUSTOMERS" : "ALL_VENDORS")}}) {
- push(@values, $item->{name}.qq|--|.$item->{"id"});
- $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"};
+ push(@values, $item->{"name"}.qq|--|.$item->{"id"});
+ $labels{$item->{"name"}.qq|--|.$item->{"id"}} = $item->{name};
}
$vc = qq|
<th align="right">| . $locale->text(ucfirst($form->{vc})) . qq|</th>
<td>| .
(($myconfig{vclimit} <= scalar(@values))
- ? qq|<input type="text" value="| . H($form->{"old$form->{vc}"}) . qq|" name="$form->{vc}">|
+ ? qq|<input type="text" value="| . H(($form->{"old$form->{vc}"} =~ /^(.*)\-\-.*$/)) . qq|" name="$form->{vc}">|
: (NTI($cgi->popup_menu('-name' => "$form->{vc}", '-default' => $form->{"old$form->{vc}"},
'-onChange' => 'document.getElementById(\'update_button\').click();',
'-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
'-labels' => \%labels,
'-default' => $form->{"globalproject_id"}));
-
- $salesman = "";
+
+ my $salesmen = "";
+ %labels = ();
+ @values = ();
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};
+ foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = ($item->{"name"} ne "" ? $item->{"name"} : $item->{"login"});
}
-
- $salesman =
+ $salesmen =
qq|<tr>
<th align="right">| . $locale->text('Salesman') . qq|</th>
<td>| .
- NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
+ NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{"salesman_id"} ? $form->{"salesman_id"} : $form->{"employee_id"},
'-values' => \@values, '-labels' => \%labels))
. qq|</td>
</tr>|;
%labels = ();
@values = ();
- foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
+ foreach my $item (@{ $form->{"ALL_EMPLOYEES"} }) {
push(@values, $item->{"id"});
- $labels{$item->{"id"}} = $item->{"name"};
+ $labels{$item->{"id"}} = $item->{"name"} ne "" ? $item->{"name"} : $item->{"login"};
}
- my $employees = qq|
+ my $employee = qq|
<tr>
<th align="right">| . $locale->text('Employee') . qq|</th>
<td>| .
- NTI($cgi->popup_menu('-name' => 'employee', '-default' => $form->{"employee"},
+ NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
'-values' => \@values, '-labels' => \%labels)) . qq|
</td>
</tr>|;
if ($form->{type} eq 'sales_order') {
if ($form->{selectemployee}) {
- $employee = qq|
- <input type=hidden name=customer_klass value=$form->{customer_klass}>
- $employees
-|;
+ $employee .= qq|
+ <input type="hidden" name="customer_klass" value="$form->{customer_klass}">|;
}
} else {
- $employee = qq|
- <input type=hidden name=customer_klass value=$form->{customer_klass}>
- $employees
-|;
+ $employee .= qq|
+ <input type="hidden" name="customer_klass" value="$form->{customer_klass}">|;
}
if ($form->{resubmit} && ($form->{format} eq "html")) {
$onload =
<table>
$openclosed
$employee
- $salesman
+ $salesmen
$ordnumber
<tr>
<th width="70%" align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
$form->get_lists("projects" => { "key" => "ALL_PROJECTS",
"all" => 1 },
+ "employees" => "ALL_EMPLOYEES",
$vc => "ALL_" . uc($vc));
my %labels = ();
NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
'-labels' => \%labels));
+ #employees
+ %labels = ();
+ @values = ("");
+ foreach my $item (@{ $form->{"ALL_EMPLOYEES"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"name"} ne "" ? $item->{"name"} : $item->{"login"};
+ }
+
+ my $employee_block = qq|
+ <tr>
+ <th align="right">| . $locale->text('Employee') . qq|</th>
+ <td>| .
+ NTI($cgi->popup_menu('-name' => 'employee_id',
+ '-values' => \@values,
+ '-labels' => \%labels)) . qq|
+ </td>
+ </tr>|;
+
%labels = ();
@values = ("");
foreach my $item (@{ $form->{($form->{vc} eq "customer" ? "ALL_CUSTOMERS" : "ALL_VENDORS")}}) {
push(@values, $item->{name}.qq|--|.$item->{"id"});
- $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"};
+ $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"};
}
my $vc_label = $form->{vc} eq "customer" ? $locale->text('Customer') : $locale->text('Vendor');
$vc =
$myconfig{vclimit} <= scalar(@values)
- ? qq|<input type="text" value="| . H($form->{"old$form->{vc}"}) . qq|" name="$form->{vc}">|
+ ? qq|<input type="text" value="| . H(($form->{"old$form->{vc}"} =~ /^(.*)\-\-.*$/)) . qq|" name="$form->{vc}">|
: NTI($cgi->popup_menu('-name' => "$form->{vc}",
'-default' => $form->{"old$form->{vc}"},
'-onChange' => 'document.getElementById(\'update_button\').click();',
'-values' => \@values,
'-labels' => \%labels));
-
$form->header;
print qq|
<th align=right>$ordlabel</th>
<td colspan=3><input name="$ordnumber" size=20></td>
</tr>
+ $employee_block
<tr>
<th align="right">| . $locale->text('Transaction description') . qq|</th>
<td colspan="3"><input name="transaction_description" size=20></td>
. $locale->text('Required by') . qq|</td>
</tr>
<tr>
- <td><input name="l_name" class=checkbox type=checkbox value=Y checked> ucfirst($form->{vc})</td>
+ <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vc_label</td>
<td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
<td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
. $locale->text('Ship via') . qq|</td>
<h4>$msg $form->{$ordnumber}</h4>
<p>
+<input type="hidden" name="yes_nextsub" value="delete_order_quotation">
<input name=action class=submit type=submit value="|
. $locale->text('Yes') . qq|">
+<input name=action class=submit type=submit onclick="history.back()" value="|
+ . $locale->text('No') . qq|">
</form>
</body>
$lxdebug->leave_sub();
}
-sub yes {
+sub delete_order_quotation {
$lxdebug->enter_sub();
if ($form->{type} =~ /_order$/) {
$err = $locale->text('Cannot delete quotation!');
}
if (OE->delete(\%myconfig, \%$form, $spool)){
- $form->redirect($msg);
# saving the history
if(!exists $form->{addition}) {
$form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
$form->save_history($form->dbconnect(\%myconfig));
}
# /saving the history
+ $form->info($msg);
+ exit();
}
$form->error($err);
sub invoice {
$lxdebug->enter_sub();
+ $form->{old_employee_id} = $form->{employee_id};
+ $form->{old_salesman_id} = $form->{salesman_id};
+
if ($form->{type} =~ /_order$/) {
# these checks only apply if the items don't bring their own ordnumbers/transdates.
$exchangerate =
$form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
$buysell);
+ print(STDERR "CURRENCY $form->{currency} DEFAULT: $form->{defaultcurrency} EXCHANGE $exchangerate\n");
if (!$exchangerate) {
&backorder_exchangerate($orddate, $buysell);
$lxdebug->leave_sub();
}
+sub check_for_direct_delivery_yes {
+ $lxdebug->enter_sub();
+
+ $form->{direct_delivery_checked} = 1;
+ delete @{$form}{grep /^shipto/, keys %{ $form }};
+ map { s/^CFDD_//; $form->{$_} = $form->{"CFDD_${_}"} } grep /^CFDD_/, keys %{ $form };
+ $form->{shipto} = 1;
+ purchase_order();
+ $lxdebug->leave_sub();
+}
+
+sub check_for_direct_delivery_no {
+ $lxdebug->enter_sub();
+
+ $form->{direct_delivery_checked} = 1;
+ delete @{$form}{grep /^shipto/, keys %{ $form }};
+ purchase_order();
+
+ $lxdebug->leave_sub();
+}
+
+sub check_for_direct_delivery {
+ $lxdebug->enter_sub();
+
+ if ($form->{direct_delivery_checked}
+ || (!$form->{shiptoname} && !$form->{shiptostreet} && !$form->{shipto_id})) {
+ $lxdebug->leave_sub();
+ return;
+ }
+
+ if ($form->{shipto_id}) {
+ Common->get_shipto_by_id(\%myconfig, $form, $form->{shipto_id}, "CFDD_");
+
+ } else {
+ map { $form->{"CFDD_${_}"} = $form->{$_ } } grep /^shipto/, keys %{ $form };
+ }
+
+ delete $form->{action};
+ $form->{VARIABLES} = [ map { { "key" => $_, "value" => $form->{$_} } } grep { ref $_ eq "" } keys %{ $form } ];
+
+ $form->header();
+ print $form->parse_html_template("oe/check_for_direct_delivery");
+
+ $lxdebug->leave_sub();
+
+ exit 0;
+}
+
sub purchase_order {
$lxdebug->enter_sub();
+ if ($form->{type} eq 'sales_order') {
+ check_for_direct_delivery();
+ }
+
if ( $form->{type} eq 'sales_quotation'
|| $form->{type} eq 'request_quotation') {
OE->close_order(\%myconfig, \%$form);
$form->{closed} = 0;
+ $form->{old_employee_id} = $form->{employee_id};
+ $form->{old_salesman_id} = $form->{salesman_id};
+
# reset
map { delete $form->{$_} }
qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
$lxdebug->leave_sub();
}
+sub yes {
+ call_sub($form->{yes_nextsub});
+}
+
+sub no {
+ call_sub($form->{no_nextsub});
+}