tabindex-Attribute entfernt, damit der Browser die Tabreinhenfolge selber vergibt...
[kivitendo-erp.git] / bin / mozilla / oe.pl
index da5ab00..98e68d2 100644 (file)
@@ -120,19 +120,19 @@ sub edit {
 
   # editing without stuff to edit? try adding it first
   if ($form->{rowcount}) {
-    map { $id++ if $form->{"id_$_"} } (1 .. $form->{rowcount});
+    map { $id++ if $form->{"multi_id_$_"} } (1 .. $form->{rowcount});
     if (!$id) {
 
       # reset rowcount
       undef $form->{rowcount};
       &add;
+      $lxdebug->leave_sub();
       return;
     }
-  } else {
-    if (!$form->{id}) {
-      &add;
-      return;
-    }
+  } elsif (!$form->{id}) {
+    &add;
+    $lxdebug->leave_sub();
+    return;
   }
 
   if ($form->{print_and_save}) {
@@ -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});
 
@@ -665,7 +691,7 @@ sub form_header {
       $employee = qq|
     <input type=hidden name=customer_klass value=$form->{customer_klass}>
              <tr>
-               <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
+               <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
                <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
                <input type=hidden name=selectemployee value="$form->{selectemployee}">
                 <td></td>
@@ -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>
@@ -967,7 +994,7 @@ sub form_footer {
                <td>$intnotes</td>
              </tr>
          <th align=right>| . $locale->text('Payment Terms') . qq|</th>
-         <td><select name=payment_id tabindex=24>$payment
+         <td><select name=payment_id>$payment
                           </select></td>
            </table>
          </td>
@@ -1297,7 +1324,7 @@ sub search {
     $form->{vc}    = 'customer';
     $ordlabel      = $locale->text('Order Number');
     $ordnumber     = 'ordnumber';
-    $employee      = $locale->text('Salesperson');
+    $employee      = $locale->text('Employee');
   }
 
   if ($form->{type} eq 'sales_quotation') {
@@ -1576,11 +1603,10 @@ sub orders {
   if ($form->{vc} eq 'customer') {
     if ($form->{type} eq 'sales_order') {
       $form->{title} = $locale->text('Sales Orders');
-      $employee = $locale->text('Salesperson');
     } else {
       $form->{title} = $locale->text('Quotations');
-      $employee = $locale->text('Employee');
     }
+    $employee = $locale->text('Employee');
     $name = $locale->text('Customer');
   }
 
@@ -1727,7 +1753,7 @@ sub orders {
     $subtotalamount    += $oe->{amount};
 
     $column_data{ids} =
-      qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
+      qq|<td><input name="multi_id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
     $column_data{id}        = "<td>$oe->{id}</td>";
     $column_data{transdate} = "<td>$oe->{transdate}&nbsp;</td>";
     $column_data{reqdate}   = "<td>$oe->{reqdate}&nbsp;</td>";
@@ -2509,3 +2535,26 @@ sub poso {
   $lxdebug->leave_sub();
 }
 
+sub e_mail {
+  $lxdebug->enter_sub();
+
+  $form->{saveasnew}      = 1;
+  $form->{closed}         = 0;
+  $form->{print_and_save} = 1;
+  map { delete $form->{$_} } qw(printed emailed queued);
+
+  # Let Lx-Office assign a new order number if the user hasn't changed the
+  # previous one. If it has been changed manually then use it as-is.
+  my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
+  if ($form->{saved_xyznumber} &&
+      ($form->{saved_xyznumber} eq $form->{$idx})) {
+    delete($form->{$idx});
+  }
+
+  &save;
+
+  &edit_e_mail;
+
+  $lxdebug->leave_sub();
+}
+