Lieferungen für Lieferanten in der Stammdaten->Lieferantenmaske hatte ein paar Daten...
[kivitendo-erp.git] / bin / mozilla / oe.pl
index 7c9ee98..da09648 100644 (file)
@@ -452,10 +452,10 @@ sub form_footer {
         $form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
 
         $TMPL_VAR{tax} .= qq|
-             <tr>
-               <th align=right>$form->{"${item}_description"}&nbsp;| . $form->{"${item}_rate"} * 100 .qq|%</th>
-               <td align=right>$form->{"${item}_total"}</td>
-             </tr> |;
+              <tr>
+                <th align=right>$form->{"${item}_description"}&nbsp;| . $form->{"${item}_rate"} * 100 .qq|%</th>
+                <td align=right>$form->{"${item}_total"}</td>
+              </tr> |;
       }
     }
 
@@ -470,14 +470,14 @@ sub form_footer {
         $form->{"${item}_netto"} = $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
 
         $TMPL_VAR{tax} .= qq|
-             <tr>
-               <th align=right>Enthaltene $form->{"${item}_description"}&nbsp;| . $form->{"${item}_rate"} * 100 .qq|%</th>
-               <td align=right>$form->{"${item}_total"}</td>
-             </tr>
-             <tr>
-               <th align=right>Nettobetrag</th>
-               <td align=right>$form->{"${item}_netto"}</td>
-             </tr> |;
+              <tr>
+                <th align=right>Enthaltene $form->{"${item}_description"}&nbsp;| . $form->{"${item}_rate"} * 100 .qq|%</th>
+                <td align=right>$form->{"${item}_total"}</td>
+              </tr>
+              <tr>
+                <th align=right>Nettobetrag</th>
+                <td align=right>$form->{"${item}_netto"}</td>
+              </tr> |;
       }
     }
   }
@@ -552,7 +552,7 @@ sub update {
     my $rows = scalar @{ $form->{item_list} };
 
     # hier ist das problem fuer bug 817 $form->{discount} wird nicht durchgeschliffen
-    # ferner fallunterscheidung fuer verkauf oder einkauf s.a. bug 736 jb 04.05.2009
+    # ferner fallunterscheidung fuer verkauf oder einkauf s.a. bug 736 jb 04.05.2009
     # select discount as vendor_discount from vendor ||
     # select discount as customer_discount from customer
     $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"$form->{vc}_discount"} * 100);
@@ -745,7 +745,8 @@ sub orders {
     "shipvia",                 "globalprojectnumber",
     "transaction_description", "open",
     "delivered", "marge_total", "marge_percent",
-    "country",                 "ustid",
+    "vcnumber",                "ustid",
+    "country",
   );
 
   # only show checkboxes if gotten here via sales_order form.
@@ -782,7 +783,7 @@ sub orders {
   my @hidden_variables = map { "l_${_}" } @columns;
   push @hidden_variables, "l_subtotal", $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered ordnumber quonumber
                                                         transaction_description transdatefrom transdateto type vc employee_id salesman_id
-                                                        reqdatefrom reqdateto projectnumber);
+                                                        reqdatefrom reqdateto projectnumber project_id);
 
   my $href = build_std_url('action=orders', grep { $form->{$_} } @hidden_variables);
 
@@ -807,6 +808,7 @@ sub orders {
     'delivered'               => { 'text' => $locale->text('Delivered'), },
     'marge_total'             => { 'text' => $locale->text('Ertrag'), },
     'marge_percent'           => { 'text' => $locale->text('Ertrag prozentual'), },
+    'vcnumber'                => { 'text' => $form->{vc} eq 'customer' ? $locale->text('Customer Number') : $locale->text('Vendor Number'), },
     'country'                 => { 'text' => $locale->text('Country'), },
     'ustid'                   => { 'text' => $locale->text('USt-IdNr.'), },
   );
@@ -1057,8 +1059,8 @@ sub save_and_close {
   # saving the history
   if(!exists $form->{addition}) {
     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
-       $form->{addition} = "SAVED";
-       $form->save_history($form->dbconnect(\%myconfig));
+    $form->{addition} = "SAVED";
+    $form->save_history($form->dbconnect(\%myconfig));
   }
   # /saving the history
 
@@ -1164,8 +1166,8 @@ sub save {
   # saving the history
   if(!exists $form->{addition}) {
     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
-       $form->{addition} = "SAVED";
-       $form->save_history($form->dbconnect(\%myconfig));
+    $form->{addition} = "SAVED";
+    $form->save_history($form->dbconnect(\%myconfig));
   }
   # /saving the history
 
@@ -1252,8 +1254,8 @@ sub delete_order_quotation {
     # saving the history
     if(!exists $form->{addition}) {
       $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
-         $form->{addition} = "DELETED";
-         $form->save_history($form->dbconnect(\%myconfig));
+      $form->{addition} = "DELETED";
+      $form->save_history($form->dbconnect(\%myconfig));
     }
     # /saving the history
     $form->info($msg);
@@ -1367,7 +1369,8 @@ sub invoice {
   $form->{type} = "invoice";
 
   # locale messages
-  $locale = new Locale "$myconfig{countrycode}", "$script";
+  $main::locale = new Locale "$myconfig{countrycode}", "$script";
+  $locale = $main::locale;
 
   require "bin/mozilla/$form->{script}";
 
@@ -1457,16 +1460,16 @@ sub backorder_exchangerate {
     <td>
       <table>
         <tr>
-         <th align=right>| . $locale->text('Currency') . qq|</th>
-         <td>$form->{currency}</td>
-       </tr>
-       <tr>
-         <th align=right>| . $locale->text('Date') . qq|</th>
-         <td>$orddate</td>
-       </tr>
+          <th align=right>| . $locale->text('Currency') . qq|</th>
+          <td>$form->{currency}</td>
+        </tr>
+        <tr>
+          <th align=right>| . $locale->text('Date') . qq|</th>
+          <td>$orddate</td>
+        </tr>
         <tr>
-         <th align=right>| . $locale->text('Exchangerate') . qq|</th>
-         <td><input name=exchangerate size=11></td>
+          <th align=right>| . $locale->text('Exchangerate') . qq|</th>
+          <td><input name=exchangerate size=11></td>
         </tr>
       </table>
     </td>
@@ -1685,7 +1688,9 @@ sub purchase_order {
   check_oe_access();
   $main::auth->assert('purchase_order_edit');
 
+  $form->{sales_order_to_purchase_order} = 0;
   if ($form->{type} eq 'sales_order') {
+    $form->{sales_order_to_purchase_order} = 1;
     check_for_direct_delivery();
   }
 
@@ -1703,6 +1708,8 @@ sub purchase_order {
 
   &poso;
 
+  delete $form->{sales_order_to_purchase_order};
+
   $main::lxdebug->leave_sub();
 }
 
@@ -1751,8 +1758,14 @@ sub poso {
   $form->{old_salesman_id}     = $form->{salesman_id};
 
   # reset
-  map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered
-                                ordnumber);
+  map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered ordnumber);
+
+  # if purchase_order was generated from sales_order, use lastcost_$i as sellprice_$i
+  if ( $form->{sales_order_to_purchase_order} ) {
+    for my $i (1 .. $form->{rowcount}) {
+      $form->{"sellprice_${i}"} = $form->format_amount(\%myconfig,$form->{"lastcost_${i}"});
+    };
+  };
 
   for my $i (1 .. $form->{rowcount}) {
     map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice basefactor discount);