Speichern und Anzeigen eines Verkäufers bei Verkaufsmasken.
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 26 Mar 2007 08:27:24 +0000 (08:27 +0000)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 26 Mar 2007 08:27:24 +0000 (08:27 +0000)
SL/Form.pm
SL/IS.pm
SL/OE.pm
bin/mozilla/is.pl
bin/mozilla/oe.pl
locale/de/is
locale/de/oe
sql/Pg-upgrade2/oe_is_salesman.sql [new file with mode: 0644]

index e1ea941..3f1e877 100644 (file)
@@ -1707,7 +1707,7 @@ sub all_vc {
 
   # 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);
index 6c0f71b..cd90a85 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -1050,6 +1050,7 @@ Message: $form->{message}\r| if $form->{message};
               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|
@@ -1482,7 +1483,7 @@ sub retrieve_invoice {
                 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}|;
@@ -1685,7 +1686,8 @@ sub get_customer {
                  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
index 27f57f9..f9bcd34 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -447,6 +447,7 @@ Message: $form->{message}\r| if $form->{message};
              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);
@@ -677,7 +678,7 @@ sub retrieve {
     # 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,
index 85e03c1..bf64bb6 100644 (file)
@@ -121,6 +121,7 @@ sub invoice_links {
   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};
     }
   }
 
@@ -367,7 +368,8 @@ sub form_header {
                    "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"} }) {
@@ -405,6 +407,22 @@ sub form_header {
                          '-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//;
@@ -717,7 +735,9 @@ print qq|       </table>
                <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>
index be14286..7d42d82 100644 (file)
@@ -167,6 +167,8 @@ sub order_links {
   # set jscalendar
   $form->{jscalendar} = $jscalendar;
 
+  my $editing = $form->{id};
+
   OE->retrieve(\%myconfig, \%$form);
 
   if ($form->{payment_id}) {
@@ -179,6 +181,8 @@ sub order_links {
     $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
@@ -282,6 +286,8 @@ sub order_links {
   # forex
   $form->{forex} = $form->{exchangerate};
 
+  $form->{salesman_id} = $salesman_id if ($editing);
+
   $lxdebug->leave_sub();
 }
 
@@ -418,7 +424,8 @@ sub form_header {
                    "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"} }) {
@@ -456,6 +463,25 @@ sub form_header {
                          '-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});
 
@@ -803,6 +829,7 @@ print qq|       </table>
            <table>
              $openclosed
              $employee
+        $salesman
              $ordnumber
              <tr>
           <th width="70%" align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
index 7d1e006..e3f858e 100644 (file)
@@ -190,6 +190,7 @@ $self->{texts} = {
   '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',
index 115ad87..e025858 100644 (file)
@@ -193,6 +193,7 @@ $self->{texts} = {
   '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',
diff --git a/sql/Pg-upgrade2/oe_is_salesman.sql b/sql/Pg-upgrade2/oe_is_salesman.sql
new file mode 100644 (file)
index 0000000..c994d73
--- /dev/null
@@ -0,0 +1,7 @@
+-- @tag: oe_is_salesman
+-- @description: Speichern eines Verk&auml;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);