Anzeige und Auswahl von Projektnummern bei Einkaufs- und Verkaufsbelegen nur noch...
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 20 Feb 2007 09:09:28 +0000 (09:09 +0000)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 20 Feb 2007 09:09:28 +0000 (09:09 +0000)
19 files changed:
SL/Form.pm
SL/IR.pm
SL/IS.pm
SL/OE.pm
bin/mozilla/arap.pl
bin/mozilla/common.pl
bin/mozilla/io.pl
bin/mozilla/ir.pl
bin/mozilla/is.pl
bin/mozilla/oe.pl
locale/de/am
locale/de/cn
locale/de/common
locale/de/dn
locale/de/ic
locale/de/io
locale/de/ir
locale/de/is
locale/de/oe

index f7cf1a8..842afe8 100644 (file)
@@ -1451,8 +1451,16 @@ sub get_projects {
   if (!$all) {
     $where = "WHERE active ";
     if ($old_id) {
-      $where .= " OR (id = ?) ";
-      push(@values, $old_id);
+      if (ref($old_id) eq "ARRAY") {
+        my @ids = grep({ $_ } @{$old_id});
+        if (@ids) {
+          $where .= " OR id IN (" . join(",", map({ "?" } @ids)) . ") ";
+          push(@values, @ids);
+        }
+      } else {
+        $where .= " OR (id = ?) ";
+        push(@values, $old_id);
+      }
     }
   }
 
index af80fce..e75fd30 100644 (file)
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -371,10 +371,6 @@ sub post_invoice {
 
       }
 
-      $project_id = 'NULL';
-      if ($form->{"projectnumber_$i"}) {
-        $project_id = $form->{"projectnumber_$i"};
-      }
       $deliverydate =
         ($form->{"deliverydate_$i"})
         ? qq|'$form->{"deliverydate_$i"}'|
@@ -387,7 +383,7 @@ sub post_invoice {
                  VALUES ($form->{id}, $form->{"id_$i"},
                  '$form->{"description_$i"}', | . ($form->{"qty_$i"} * -1) . qq|,  | . ($baseqty * -1) . qq|,
                  $form->{"sellprice_$i"}, $fxsellprice, $allocated,
-                 '$form->{"unit_$i"}', $deliverydate, (SELECT id FROM project WHERE projectnumber = '$project_id'),
+                 '$form->{"unit_$i"}', $deliverydate, | . conv_i($form->{"project_id_$i"}) . qq|,
                  '$form->{"serialnumber_$i"}')|;
       $dbh->do($query) || $form->dberror($query);
     }
@@ -639,6 +635,7 @@ sub post_invoice {
              curr = '$form->{currency}',
              department_id = $form->{department_id},
               storno = '$form->{storno}',
+              globalproject_id = | . conv_i($form->{"globalproject_id"}, 'NULL') . qq|,
               cp_id = | . conv_i($form->{cp_id}, 'NULL') . qq|
               WHERE id = $form->{id}|;
   $dbh->do($query) || $form->dberror($query);
@@ -844,7 +841,7 @@ sub retrieve_invoice {
 
     # retrieve invoice
     $query = qq|SELECT a.cp_id, a.invnumber, a.transdate AS invdate, a.duedate,
-                a.orddate, a.quodate,
+                a.orddate, a.quodate, a.globalproject_id,
                 a.ordnumber, a.quonumber, a.paid, a.taxincluded, a.notes, a.taxzone_id, a.storno, a.gldate,
                a.intnotes, a.curr AS currency
                FROM ap a
index b595616..da23eb4 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -685,10 +685,6 @@ sub post_invoice {
         }
       }
 
-      $project_id = 'NULL';
-      if ($form->{"projectnumber_$i"}) {
-        $project_id = $form->{"projectnumber_$i"};
-      }
       $deliverydate =
         ($form->{"deliverydate_$i"})
         ? qq|'$form->{"deliverydate_$i"}'|
@@ -708,7 +704,7 @@ sub post_invoice {
                  '$form->{"description_$i"}', '$form->{"longdescription_$i"}', $form->{"qty_$i"},
                  $form->{"sellprice_$i"}, $fxsellprice,
                  $form->{"discount_$i"}, $allocated, 'f',
-                 '$form->{"unit_$i"}', $deliverydate, (SELECT id from project where projectnumber = '$project_id'),
+                 '$form->{"unit_$i"}', $deliverydate, | . conv_i($form->{"project_id_$i"}) . qq|,
                  '$form->{"serialnumber_$i"}', '$pricegroup_id',
                  '$form->{"ordnumber_$i"}', '$form->{"transdate_$i"}', '$form->{"cusordnumber_$i"}', $baseqty, '$subtotal')|;
       $dbh->do($query) || $form->dberror($query);
@@ -1009,6 +1005,7 @@ Message: $form->{message}\r| if $form->{message};
               delivery_vendor_id = $form->{delivery_vendor_id},
               employee_id = $form->{employee_id},
               storno = '$form->{storno}',
+              globalproject_id = | . conv_i($form->{"globalproject_id"}, 'NULL') . qq|,
               cp_id = | . conv_i($form->{"cp_id"}, 'NULL') . qq|
               WHERE id = $form->{id}
              |;
@@ -1484,7 +1481,7 @@ sub retrieve_invoice {
 
     # retrieve invoice
     $query = qq|SELECT a.invnumber, a.ordnumber, a.quonumber, a.cusordnumber,
-                a.orddate, a.quodate,
+                a.orddate, a.quodate, a.globalproject_id,
                 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,
index 1967fc0..64ba141 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -311,10 +311,6 @@ sub save {
 
       $netamount += $form->{"sellprice_$i"} * $form->{"qty_$i"};
 
-      $project_id = 'NULL';
-      if ($form->{"projectnumber_$i"}) {
-        $project_id = $form->{"projectnumber_$i"};
-      }
       $reqdate =
         ($form->{"reqdate_$i"}) ? qq|'$form->{"reqdate_$i"}'| : "NULL";
 
@@ -335,7 +331,7 @@ sub save {
       $query .= qq|$form->{id}, $form->{"id_$i"},
                   '$form->{"description_$i"}', '$form->{"longdescription_$i"}', $form->{"qty_$i"}, $baseqty,
                   $fxsellprice, $form->{"discount_$i"},
-                  '$form->{"unit_$i"}', $reqdate, (SELECT id from project where projectnumber = '$project_id'),
+                  '$form->{"unit_$i"}', $reqdate, | . conv_i($form->{"project_id_$i"}, 'NULL') . qq|,
                   '$form->{"serialnumber_$i"}', $form->{"ship_$i"}, '$pricegroup_id',
                   '$form->{"ordnumber_$i"}', '$form->{"transdate_$i"}', '$form->{"cusordnumber_$i"}', '$subtotal')|;
       $dbh->do($query) || $form->dberror($query);
@@ -671,13 +667,12 @@ sub retrieve {
                o.closed, o.reqdate, o.quonumber, o.department_id, o.cusordnumber,
                d.description AS department, o.payment_id, o.language_id, o.taxzone_id,
                 o.delivery_customer_id, o.delivery_vendor_id, o.proforma, o.shipto_id,
-                o.globalproject_id, pr.projectnumber AS globalprojectnumber,
+                o.globalproject_id,
                 o.delivered
                FROM oe o
                JOIN $form->{vc} cv ON (o.$form->{vc}_id = cv.id)
                LEFT JOIN employee e ON (o.employee_id = e.id)
                LEFT JOIN department d ON (o.department_id = d.id)
-          LEFT JOIN project pr ON (o.globalproject_id = pr.id)
                |
       . ($form->{id}
          ? qq|WHERE o.id = $form->{id}|
index 48cb610..073b51c 100644 (file)
@@ -272,7 +272,7 @@ sub add_transaction {
 sub check_project {
   $lxdebug->enter_sub();
 
-  for $i (0 .. $form->{rowcount}) {
+  for $i (1 .. $form->{rowcount}) {
     my $suffix = $i ? "_$i" : "";
     my $prefix = $i ? "" : "global";
     $form->{"${prefix}project_id${suffix}"} = "" unless $form->{"${prefix}projectnumber$suffix"};
index 6793a1d..0307d77 100644 (file)
@@ -452,6 +452,13 @@ sub E {
   return $form->escape($_[0]);
 }
 
+sub NTI {
+  my ($element) = @_;
+
+  $element =~ s/tabindex\s*=\s*"\d+"//;
+  return $element;
+}
+
 sub format_dates {
   $lxdebug->enter_sub();
 
index 8b0b7fc..d8b522d 100644 (file)
@@ -242,6 +242,13 @@ sub display_row {
     $delvar       = 'reqdate';
   }
 
+  my %projectnumber_labels = ();
+  my @projectnumber_values = ("");
+  foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+    push(@projectnumber_values, $item->{"id"});
+    $projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"};
+  }
+
   for $i (1 .. $numrows) {
 
     # undo formatting
@@ -486,11 +493,12 @@ sub display_row {
           <b>$serialnumber</b>&nbsp;<input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}">|;
     }
 
-    print qq|
-          <b>$projectnumber</b>&nbsp;<input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}">
-                 <input type=hidden name="oldprojectnumber_$i" value="$form->{"projectnumber_$i"}">
-                 <input type=hidden name="project_id_$i" value="$form->{"project_id_$i"}">
-|;
+    print qq|<b>$projectnumber</b>&nbsp;| .
+      NTI($cgi->popup_menu('-name' => "project_id_$i",
+                           '-values' => \@projectnumber_values,
+                           '-labels' => \%projectnumber_labels,
+                           '-default' => $form->{"project_id_$i"}));
+
     if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
       my $reqdate_term =
         ($form->{type} eq 'invoice')
@@ -881,6 +889,9 @@ sub display_form {
 
   relink_accounts();
 
+  my $new_rowcount = $form->{"rowcount"} * 1 + 1;
+  $form->{"project_id_${new_rowcount}"} = $form->{"globalproject_id"};
+
   $form->language_payment(\%myconfig);
 
   # if we have a display_form
index 1b99f5f..6744764 100644 (file)
@@ -36,6 +36,7 @@ use SL::PE;
 
 require "$form->{path}/io.pl";
 require "$form->{path}/arap.pl";
+require "$form->{path}/common.pl";
 
 1;
 
@@ -259,7 +260,14 @@ sub form_header {
 <input type=hidden name=forex value=$form->{forex}>
 |;
 
-  $form->get_lists("contacts" => "ALL_CONTACTS");
+  my @old_project_ids = ($form->{"globalproject_id"});
+  map({ push(@old_project_ids, $form->{"project_id_$_"})
+          if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
+  $form->get_lists("contacts" => "ALL_CONTACTS",
+                   "projects" => { "key" => "ALL_PROJECTS",
+                                   "all" => 0,
+                                   "old_id" => \@old_project_ids });
 
   my (%labels, @values);
   foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
@@ -268,8 +276,19 @@ sub form_header {
       ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
   }
   my $contact =
-    $cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
-                     '-labels' => \%labels, '-default' => $form->{"cp_id"});
+    NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
+                         '-labels' => \%labels, '-default' => $form->{"cp_id"}));
+
+  %labels = ();
+  @values = ("");
+  foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+    push(@values, $item->{"id"});
+    $labels{$item->{"id"}} = $item->{"projectnumber"};
+  }
+  my $globalprojectnumber =
+    NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
+                         '-labels' => \%labels,
+                         '-default' => $form->{"globalproject_id"}));
 
   if (@{ $form->{TAXZONE} }) {
     $form->{selecttaxzone} = "";
@@ -457,11 +476,7 @@ sub form_header {
         </tr>
              <tr>
           <th align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
-          <td>
-            <input name="globalprojectnumber" size="11" value="| . Q($form->{globalprojectnumber}) . qq|">
-            <input type="hidden" name="oldglobalprojectnumber" value="| . Q($form->{globalprojectnumber}) . qq|">
-            <input type="hidden" name="globalproject_id" value="| . Q($form->{globalproject_id}) . qq|">
-          </td:>
+          <td>$globalprojectnumber</td>
              </tr>
      </table>
          </td>
@@ -813,8 +828,6 @@ sub update {
 
   &check_name(vendor);
 
-  &check_project;
-
   $form->{exchangerate} = $exchangerate
     if (
         $form->{forex} = (
index 3b298f1..f4556cf 100644 (file)
@@ -353,8 +353,15 @@ sub form_header {
                <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
              </tr>|;
 
+  my @old_project_ids = ($form->{"globalproject_id"});
+  map({ push(@old_project_ids, $form->{"project_id_$_"})
+          if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
   $form->get_lists("contacts" => "ALL_CONTACTS",
-                   "shipto" => "ALL_SHIPTO");
+                   "shipto" => "ALL_SHIPTO",
+                   "projects" => { "key" => "ALL_PROJECTS",
+                                   "all" => 0,
+                                   "old_id" => \@old_project_ids });
 
   my (%labels, @values);
   foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
@@ -363,8 +370,8 @@ sub form_header {
       ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
   }
   my $contact =
-    $cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
-                     '-labels' => \%labels, '-default' => $form->{"cp_id"});
+    NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
+                         '-labels' => \%labels, '-default' => $form->{"cp_id"}));
 
   %labels = ();
   @values = ("");
@@ -377,10 +384,21 @@ sub form_header {
   my $shipto = qq|
                <th align=right>| . $locale->text('Shipping Address') . qq|</th>
                <td>| .
-    $cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
-                     '-labels' => \%labels, '-default' => $form->{"shipto_id"})
+    NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
+                         '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
     . qq|</td>|;
 
+  %labels = ();
+  @values = ("");
+  foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+    push(@values, $item->{"id"});
+    $labels{$item->{"id"}} = $item->{"projectnumber"};
+  }
+  my $globalprojectnumber =
+    NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
+                         '-labels' => \%labels,
+                         '-default' => $form->{"globalproject_id"}));
+
   # set option selected
   foreach $item (qw(AR customer currency department employee)) {
     $form->{"select$item"} =~ s/ selected//;
@@ -743,11 +761,7 @@ print qq|     <tr>
              </tr>
              <tr>
           <th align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
-          <td>
-            <input name="globalprojectnumber" size="11" value="| . Q($form->{globalprojectnumber}) . qq|">
-            <input type="hidden" name="oldglobalprojectnumber" value="| . Q($form->{globalprojectnumber}) . qq|">
-            <input type="hidden" name="globalproject_id" value="| . Q($form->{globalproject_id}) . qq|">
-          </td>
+          <td>$globalprojectnumber</td>
              </tr>
            </table>
           </td>
@@ -1167,8 +1181,6 @@ sub update {
 
   &check_name(customer);
 
-  &check_project;
-
   $form->{exchangerate} = $exchangerate
     if (
         $form->{forex} = (
index e2fb8a2..0d6c3ce 100644 (file)
@@ -407,11 +407,15 @@ sub form_header {
   #quote select[customer|vendor] Bug 133
   $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
 
+  my @old_project_ids = ($form->{"globalproject_id"});
+  map({ push(@old_project_ids, $form->{"project_id_$_"})
+          if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
   $form->get_lists("contacts" => "ALL_CONTACTS",
                    "shipto" => "ALL_SHIPTO",
                    "projects" => { "key" => "ALL_PROJECTS",
                                    "all" => 0,
-                                   "old_id" => $form->{"globalproject_id"} });
+                                   "old_id" => \@old_project_ids });
 
   my (%labels, @values);
   foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
@@ -420,8 +424,8 @@ sub form_header {
       ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
   }
   my $contact =
-    $cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
-                     '-labels' => \%labels, '-default' => $form->{"cp_id"});
+    NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
+                         '-labels' => \%labels, '-default' => $form->{"cp_id"}));
 
   %labels = ();
   @values = ("");
@@ -431,6 +435,13 @@ sub form_header {
       $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"};
   }
 
+  my $shipto = qq|
+               <th align=right>| . $locale->text('Shipping Address') . qq|</th>
+               <td>| .
+    NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
+                         '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
+    . qq|</td>|;
+
   %labels = ();
   @values = ("");
   foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
@@ -438,16 +449,9 @@ sub form_header {
     $labels{$item->{"id"}} = $item->{"projectnumber"};
   }
   my $globalprojectnumber =
-    $cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
-                     '-labels' => \%labels,
-                     '-default' => $form->{"globalproject_id"});
-
-  my $shipto = qq|
-               <th align=right>| . $locale->text('Shipping Address') . qq|</th>
-               <td>| .
-    $cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
-                     '-labels' => \%labels, '-default' => $form->{"shipto_id"})
-    . qq|</td>|;
+    NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
+                         '-labels' => \%labels,
+                         '-default' => $form->{"globalproject_id"}));
 
   $form->{exchangerate} =
     $form->format_amount(\%myconfig, $form->{exchangerate});
@@ -1127,8 +1131,6 @@ sub update {
 
   &check_name($form->{vc});
 
-  &check_project;
-
   $buysell              = 'buy';
   $buysell              = 'sell' if ($form->{vc} eq 'vendor');
   $form->{exchangerate} = $exchangerate
index 38e3ac1..7b42a3a 100644 (file)
@@ -315,6 +315,7 @@ $self->{texts} = {
 $self->{subs} = {
   'E'                           => 'E',
   'H'                           => 'H',
+  'NTI'                         => 'NTI',
   'Q'                           => 'Q',
   'account_header'              => 'account_header',
   'add'                         => 'add',
index 402c50c..2c52989 100644 (file)
@@ -207,6 +207,7 @@ $self->{texts} = {
 $self->{subs} = {
   'E'                           => 'E',
   'H'                           => 'H',
+  'NTI'                         => 'NTI',
   'Q'                           => 'Q',
   'add'                         => 'add',
   'add_transaction'             => 'add_transaction',
index 551e135..e3c5b89 100644 (file)
@@ -25,6 +25,7 @@ $self->{texts} = {
 $self->{subs} = {
   'E'                           => 'E',
   'H'                           => 'H',
+  'NTI'                         => 'NTI',
   'Q'                           => 'Q',
   'build_std_url'               => 'build_std_url',
   'calculate_qty'               => 'calculate_qty',
index fe1aa2a..669fc3c 100644 (file)
@@ -200,6 +200,7 @@ gestartet',
 $self->{subs} = {
   'E'                           => 'E',
   'H'                           => 'H',
+  'NTI'                         => 'NTI',
   'Q'                           => 'Q',
   'add'                         => 'add',
   'add_transaction'             => 'add_transaction',
index 3e96773..3f39db6 100644 (file)
@@ -245,6 +245,7 @@ aktualisieren wollen?',
 $self->{subs} = {
   'E'                           => 'E',
   'H'                           => 'H',
+  'NTI'                         => 'NTI',
   'Q'                           => 'Q',
   'add'                         => 'add',
   'addtop100'                   => 'addtop100',
index e8fc49d..d7a9be1 100644 (file)
@@ -144,6 +144,7 @@ $self->{texts} = {
 $self->{subs} = {
   'E'                           => 'E',
   'H'                           => 'H',
+  'NTI'                         => 'NTI',
   'Q'                           => 'Q',
   'build_std_url'               => 'build_std_url',
   'calculate_qty'               => 'calculate_qty',
index 2e14867..0e493fa 100644 (file)
@@ -201,6 +201,7 @@ $self->{texts} = {
 $self->{subs} = {
   'E'                           => 'E',
   'H'                           => 'H',
+  'NTI'                         => 'NTI',
   'Q'                           => 'Q',
   'add'                         => 'add',
   'add_transaction'             => 'add_transaction',
index cd4ca7f..96134c9 100644 (file)
@@ -226,6 +226,7 @@ $self->{texts} = {
 $self->{subs} = {
   'E'                           => 'E',
   'H'                           => 'H',
+  'NTI'                         => 'NTI',
   'Q'                           => 'Q',
   'add'                         => 'add',
   'add_transaction'             => 'add_transaction',
index 52db95a..0905fba 100644 (file)
@@ -241,6 +241,7 @@ $self->{texts} = {
 $self->{subs} = {
   'E'                           => 'E',
   'H'                           => 'H',
+  'NTI'                         => 'NTI',
   'Q'                           => 'Q',
   'add'                         => 'add',
   'add_transaction'             => 'add_transaction',