# build selection list
if ($count < $myconfig->{vclimit}) {
- $query = qq|SELECT id, name
+ $query = qq|SELECT id, name, salesman_id
FROM $table WHERE not obsolete
ORDER BY name|;
$sth = $dbh->prepare($query);
delivery_customer_id = $form->{delivery_customer_id},
delivery_vendor_id = $form->{delivery_vendor_id},
employee_id = $form->{employee_id},
+ salesman_id = | . conv_i($form->{salesman_id}, 'NULL') . qq|,
storno = '$form->{storno}',
globalproject_id = | . conv_i($form->{"globalproject_id"}, 'NULL') . qq|,
cp_id = | . conv_i($form->{"cp_id"}, 'NULL') . qq|
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,
- a.employee_id, e.name AS employee, a.payment_id, a.language_id, a.delivery_customer_id, a.delivery_vendor_id, a.type
+ a.employee_id, e.name AS employee, a.salesman_id, a.payment_id, a.language_id, a.delivery_customer_id, a.delivery_vendor_id, a.type
FROM ar a
LEFT JOIN employee e ON (e.id = a.employee_id)
WHERE a.id = $form->{id}|;
c.email, c.cc, c.bcc, c.language_id, c.payment_id AS customer_payment_id,
c.street, c.zipcode, c.city, c.country,
$duedate + COALESCE(pt.terms_netto, 0) AS duedate, c.notes AS intnotes,
- b.discount AS tradediscount, b.description AS business, c.klass as customer_klass, c.taxzone_id
+ b.discount AS tradediscount, b.description AS business, c.klass as customer_klass, c.taxzone_id,
+ c.salesman_id
FROM customer c
LEFT JOIN business b ON (b.id = c.business_id)
LEFT JOIN payment_terms pt ON c.payment_id = pt.id
delivery_customer_id = $form->{delivery_customer_id},
globalproject_id = | . conv_i($form->{"globalproject_id"}, 'NULL') . qq|,
employee_id = $form->{employee_id},
+ salesman_id = | . conv_i($form->{salesman_id}, 'NULL') . qq|,
cp_id = | . conv_i($form->{cp_id}, 'NULL') . qq|
WHERE id = $form->{id}|;
$dbh->do($query) || $form->dberror($query);
# it will be killed out and then has to be fetched from the item scope query further down
$query = qq|SELECT o.cp_id, o.ordnumber, o.transdate, o.reqdate,
o.taxincluded, o.shippingpoint, o.shipvia, o.notes, o.intnotes,
- o.curr AS currency, e.name AS employee, o.employee_id,
+ o.curr AS currency, e.name AS employee, o.employee_id, o.salesman_id,
o.$form->{vc}_id, cv.name AS $form->{vc}, o.amount AS invtotal,
o.closed, o.reqdate, o.quonumber, o.department_id, o.cusordnumber,
d.description AS department, o.payment_id, o.language_id, o.taxzone_id,
if ($form->{all_customer}) {
unless ($form->{customer_id}) {
$form->{customer_id} = $form->{all_customer}->[0]->{id};
+ $form->{salesman_id} = $form->{all_customer}->[0]->{salesman_id};
}
}
"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);
foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
'-labels' => \%labels,
'-default' => $form->{"globalproject_id"}));
+ %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>|;
+
# set option selected
foreach $item (qw(AR customer currency department employee)) {
$form->{"select$item"} =~ s/ selected//;
<td colspan=2><select name=employee>$form->{selectemployee}</select></td>
<input type=hidden name=selectemployee value="$form->{selectemployee}">
<td></td>
- </tr>|;
+ </tr>
+ $salesman
+|;
if ($form->{type} eq "credit_note") {
print qq| <tr>
<th align=right nowrap>| . $locale->text('Credit Note Number') . qq|</th>
# 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
# forex
$form->{forex} = $form->{exchangerate};
+ $form->{salesman_id} = $salesman_id if ($editing);
+
$lxdebug->leave_sub();
}
"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);
foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
'-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});
<table>
$openclosed
$employee
+ $salesman
$ordnumber
<tr>
<th width="70%" align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
'SAVED FOR DUNNING' => 'Gespeichert',
'SCREENED' => 'Angezeigt',
'Sales Order' => 'Kundenauftrag',
+ 'Salesman' => 'Verkäufer/in',
'Save draft' => 'Entwurf speichern',
'Screen' => 'Bildschirm',
'Select a Customer' => 'Endkunde auswählen',
'SCREENED' => 'Angezeigt',
'Sales Order' => 'Kundenauftrag',
'Sales Orders' => 'Aufträge',
+ 'Salesman' => 'Verkäufer/in',
'Save' => 'Speichern',
'Save and Close' => 'Speichern und schließen',
'Save as new' => 'als neu speichern',
--- /dev/null
+-- @tag: oe_is_salesman
+-- @description: Speichern eines Verkäufers bei Angeboten und Ausgangsrechnungen
+-- @depends: release_2_4_1
+ALTER TABLE oe ADD COLUMN salesman_id integer;
+ALTER TABLE oe ADD FOREIGN KEY (salesman_id) REFERENCES employee (id);
+ALTER TABLE ar ADD COLUMN salesman_id integer;
+ALTER TABLE ar ADD FOREIGN KEY (salesman_id) REFERENCES employee (id);