Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorNiclas Zimmermann <niclas@lx-office-hosting.de>
Thu, 13 Sep 2012 12:49:02 +0000 (14:49 +0200)
committerNiclas Zimmermann <niclas@lx-office-hosting.de>
Thu, 13 Sep 2012 12:49:02 +0000 (14:49 +0200)
SL/AR.pm
SL/DO.pm
SL/OE.pm
bin/mozilla/cp.pl
bin/mozilla/do.pl
bin/mozilla/oe.pl
templates/webpages/ar/search.html
templates/webpages/cp/form_header.html
templates/webpages/do/search.html
templates/webpages/oe/search.html

index 002041e..8c72d3c 100644 (file)
--- a/SL/AR.pm
+++ b/SL/AR.pm
@@ -472,6 +472,10 @@ sub ar_transactions {
     qq|LEFT JOIN department d ON (d.id = a.department_id)|;
 
   my $where = "1 = 1";
+  if ($form->{customernumber}) {
+    $where .= " AND c.customernumber = ?";
+    push(@values, $form->{customernumber});
+  }
   if ($form->{customer_id}) {
     $where .= " AND a.customer_id = ?";
     push(@values, $form->{customer_id});
index 8d61b0f..c4303f4 100644 (file)
--- a/SL/DO.pm
+++ b/SL/DO.pm
@@ -62,7 +62,7 @@ sub transactions {
 
   my $query =
     qq|SELECT dord.id, dord.donumber, dord.ordnumber, dord.transdate,
-         ct.name, dord.${vc}_id, dord.globalproject_id,
+         ct.${vc}number, ct.name, dord.${vc}_id, dord.globalproject_id,
          dord.closed, dord.delivered, dord.shippingpoint, dord.shipvia,
          dord.transaction_description,
          pr.projectnumber AS globalprojectnumber,
index 07758a8..bdff8cb 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -78,7 +78,7 @@ sub transactions {
 
   $query =
     qq|SELECT o.id, o.ordnumber, o.transdate, o.reqdate, | .
-    qq|  o.amount, ct.name, o.netamount, o.${vc}_id, o.globalproject_id, | .
+    qq|  o.amount, ct.${vc}number, ct.name, o.netamount, o.${vc}_id, o.globalproject_id, | .
     qq|  o.closed, o.delivered, o.quonumber, o.shippingpoint, o.shipvia, | .
     qq|  o.transaction_description, | .
     qq|  o.marge_total, o.marge_percent, | .
index 1f061ad..885c88e 100644 (file)
@@ -36,6 +36,7 @@ use SL::IS;
 use SL::IR;
 use SL::AR;
 use SL::AP;
+use Data::Dumper;
 use strict;
 #use warnings;
 
@@ -71,13 +72,14 @@ sub payment {
   # für bugfix 1771 (doppelte Leerzeichen werden nicht 'gepostet')
   $form->{"select$form->{vc}"} = "";
 
+  $form->{selectcustomer} .= "<option value=\"\"></option>\n" if $form->{vc} eq "customer";
+
   if ($form->{"all_$form->{vc}"}) {
     # s.o. jb 12.10.2010
     $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
     map { $form->{"select$form->{vc}"} .= "<option value=\"$_->{name}--$_->{id}\">$_->{name}--$_->{id}</option>\n" }
       @{ $form->{"all_$form->{vc}"} };
   }
-
   CP->paymentaccounts(\%myconfig, \%$form);
 
   # Standard Konto für Umlaufvermögen
@@ -135,6 +137,13 @@ sub form_header {
   if ($form->{ $form->{vc} } eq "") {
     map { $form->{"addr$_"} = "" } (1 .. 4);
   }
+
+  # sometimes it happens that values in customer arrive without the signs '--'
+  # but in order to select the right option field we need values with '--'
+  if ($form->{vc} eq "customer"){
+    my ($customername) = split /--/, $form->{ $form->{vc} };
+    $form->{ $form->{vc} } = $customername . "--" . $form->{customer_id};
+  }
   # bugfix 1771
   # geändert von <option>asdf--2929
   # nach:
@@ -252,15 +261,30 @@ sub update {
     }
   }
 
+  # search by customernumber
+  # the customernumber has to be correct otherwise nothing is found
+  if ($form->{vc} eq 'customer' and $form->{customernumber} and $form->{ARAP} eq 'AR') {
+    $form->{open} ='Y'; # only open invoices
+    # ar_transactions automatically searches by $form->{customer_id} or else
+    # $form->{customer} if available, and these variables will always be set
+    # so we have to empty these values first
+    $form->{customer_id} = '';
+    $form->{customer} = '';
+    AR->ar_transactions(\%myconfig, \%$form);
+
+    # Here we just take the first returned value even if the custumernumber
+    # may not be unique
+    $form->{customer} = $form->{AR}[0]{name};
+    $form->{customer_id} = $form->{AR}[0]{customer_id};
+  }
+
   # search by invoicenumber, 
   if ($form->{invnumber}) { 
-    $form->{open} ='Y'; # nur die offenen rechnungen
+    $form->{open} ='Y'; # only open invoices
     if ($form->{ARAP} eq 'AR'){
-
       # ar_transactions automatically searches by $form->{customer_id} or else
       # $form->{customer} if available, and these variables will always be set
-      # when we have a dropdown field rather than an input field, so we have to
-      # empty these values first
+      # so we have to empty these values first
       $form->{customer_id} = '';
       $form->{customer} = '';
       AR->ar_transactions(\%myconfig, \%$form);
@@ -296,7 +320,7 @@ sub update {
   }
 
   # determine customer/vendor
-  if ( $form->{customer_id} and $form->{invnumber} ) {
+  if ( $form->{customer_id} and ($form->{invnumber} or $form->{customernumber}) ) {
     # we already know the exact customer_id, so fill $form with customer data
     IS->get_customer(\%myconfig, \%$form);
     $updated = 1;
index d58c826..1bcf209 100644 (file)
@@ -488,7 +488,7 @@ sub orders {
   my @columns = qw(
     ids                     transdate
     id                      donumber
-    ordnumber
+    ordnumber               customernumber
     name                    employee  salesman
     shipvia                 globalprojectnumber
     transaction_description
@@ -516,6 +516,7 @@ sub orders {
     'id'                      => { 'text' => $locale->text('ID'), },
     'donumber'                => { 'text' => $locale->text('Delivery Order'), },
     'ordnumber'               => { 'text' => $locale->text('Order'), },
+    'customernumber'          => { 'text' => $locale->text('Customer Number'), },
     'name'                    => { 'text' => $form->{vc} eq 'customer' ? $locale->text('Customer') : $locale->text('Vendor'), },
     'employee'                => { 'text' => $locale->text('Employee'), },
     'salesman'                => { 'text' => $locale->text('Salesman'), },
index 683801a..51b3c77 100644 (file)
@@ -779,6 +779,7 @@ sub orders {
   my @columns = (
     "transdate",               "reqdate",
     "id",                      $ordnumber,
+    "customernumber", 
     "name",                    "netamount",
     "tax",                     "amount",
     "curr",                    "employee",
@@ -838,6 +839,7 @@ sub orders {
     'ordnumber'               => { 'text' => $locale->text('Order'), },
     'quonumber'               => { 'text' => $form->{type} eq "request_quotation" ? $locale->text('RFQ') : $locale->text('Quotation'), },
     'name'                    => { 'text' => $form->{vc} eq 'customer' ? $locale->text('Customer') : $locale->text('Vendor'), },
+    'customernumber'          => { 'text' => $locale->text('Customer Number'), },
     'netamount'               => { 'text' => $locale->text('Amount'), },
     'tax'                     => { 'text' => $locale->text('Tax'), },
     'amount'                  => { 'text' => $locale->text('Total'), },
index 2da9339..89cb50c 100644 (file)
           <tr>
            <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
            <td nowrap>[% 'Customer' | $T8 %]</td>
+           <td align=right><input name="l_customernumber" class=checkbox type=checkbox value=Y></td>
+           <td nowrap>[% 'Customer Number' | $T8 %]</td>
+          </tr>
+          <tr>
            <td align=right><input name="l_netamount" class=checkbox type=checkbox value="Y" checked></td>
            <td nowrap>[% 'Amount' | $T8 %]</td>
            <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
index bc02918..c513eca 100644 (file)
@@ -25,7 +25,7 @@
         <tr>
           <th align=right>[% is_customer ? LxERP.t8('Customer') : LxERP.t8('Vendor') %]</th>
           <td>[% vccontent %]</td>
-          [% IF vc == 'customer' %]
+         [% IF vc == 'customer' %]
            [% L.hidden_tag('selectcustomer', selectcustomer) %]
            [% L.hidden_tag('customer_id', customer_id) %]
            [% L.hidden_tag('oldcustomer', oldcustomer) %]
            [% L.hidden_tag('oldvendor', oldvendor) %]
           [% END %]
         </tr>
+        [% IF vc == 'customer' %]
+        <tr>
+          <th align=right>[% 'Customer Number' | $T8 %]</th>
+          <td><input name="customernumber" size="35"</td>
+        </tr>
+        [% END %]
         <tr>
           <th align=right>[% 'Invoice Number' | $T8 %]</th>
           <td><input name="invnumber" size="35"</td>
index 213f962..66cd07f 100644 (file)
          <input name="l_name" id="l_name" class="checkbox" type="checkbox" value="Y" checked>
          <label for="l_name">[% IF is_customer %][% 'Customer' | $T8 %][% ELSE %][% 'Vendor' | $T8 %][% END %]</label>
         </td>
+
+        [% IF is_customer %]
+        <td>
+         <input name="l_customernumber" id="l_customernumber" class="checkbox" type="checkbox" value="Y">
+         <label for="l_customernumber">[% 'Customer Number' | $T8 %]</label>
+        </td>
+        [% END %]
        </tr>
 
        <tr>
index fb28ea1..9282beb 100644 (file)
          <label for="l_shipvia">[% 'Ship via' | $T8 %]</label>
         </td>
        </tr>
+       <tr>
+        <td>
+         <input name="l_customernumber" id="l_customernumber" class="checkbox" type="checkbox" value="Y">
+         <label for="l_customernumber">[% 'Customer Number' | $T8 %]</label>
+        </td>
+       </tr>
        <tr>
         <td>
          <input name="l_netamount" id="l_netamount" class="checkbox" type="checkbox" value="Y">