Keine globalen Variablen überschreiben.
[kivitendo-erp.git] / bin / mozilla / io.pl
index b8009c0..b8f892b 100644 (file)
@@ -33,6 +33,8 @@
 #
 #######################################################################
 
+use SL::IC;
+
 # any custom scripts for this one
 if (-f "$form->{path}/custom_io.pl") {
   eval { require "$form->{path}/custom_io.pl"; };
@@ -843,6 +845,9 @@ sub new_item {
 
 sub display_form {
   $lxdebug->enter_sub();
+
+  relink_accounts();
+
   $form->language_payment(\%myconfig);
 
   # if we have a display_form
@@ -937,7 +942,7 @@ sub check_form {
   my @a     = ();
   my $count = 0;
   my @flds  = (
-    qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values)
+    qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values sellprice_pg pricegroup_old price_old price_new unit_old ordnumber transdate longdescription basefactor)
   );
 
 
@@ -1219,6 +1224,10 @@ sub quotation {
   $lxdebug->leave_sub();
 }
 
+sub request_for_quotation {
+  quotation();
+}
+
 sub e_mail {
   $lxdebug->enter_sub();
   if ($form->{second_run}) {
@@ -1460,8 +1469,8 @@ sub print_options {
   $format .= qq|</select>|;
 
   if (scalar(keys (%{ $form->{languages} })) !=0) {
-
-    $language_select = qq|<select name=language_id>|;
+    $language_select = qq|<select name=language_id>
+               <option value=""></option>}|;
     foreach $item (@{ $form->{languages} }) {
       if ($form->{language_id} eq $item->{id}) {
         $language_select .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
@@ -1733,8 +1742,12 @@ sub print_form {
     ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
 
   $language_saved = $form->{language_id};
+  $payment_id_saved = $form->{payment_id};
+
   &{"$form->{vc}_details"};
+
   $form->{language_id} = $language_saved;
+  $form->{payment_id} = $payment_id_saved;
 
   $form->{"email"} = $saved_email if ($saved_email);
   $form->{"cc"}    = $saved_cc    if ($saved_cc);
@@ -2003,6 +2016,16 @@ sub ship_to {
          <td>$form->{name}</td>
          <td><input name=shiptoname size=35 value="$form->{shiptoname}"></td>
        </tr>
+       <tr>
+         <th align=right nowrap>| . $locale->text('Department') . qq|</th>
+         <td>$form->{department_1}</td>
+         <td><input name=shiptodepartment_1 size=35 value="$form->{shiptodepartment_1}"></td>
+       </tr>
+       <tr>
+         <th align=right nowrap>&nbsp;</th>
+         <td>$form->{department_2}</td>
+         <td><input name=shiptodepartment_2 size=35 value="$form->{shiptodepartment_2}"></td>
+       </tr>
        <tr>
          <th align=right nowrap>| . $locale->text('Street') . qq|</th>
          <td>$form->{street}</td>
@@ -2053,7 +2076,7 @@ sub ship_to {
 
   # delete shipto
   map { delete $form->{$_} }
-    qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail header);
+    qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2 header);
   $form->{title} = $title;
 
   foreach $key (keys %$form) {
@@ -2115,3 +2138,21 @@ sub new_license {
   $lxdebug->leave_sub();
 }
 
+sub relink_accounts {
+  $lxdebug->enter_sub();
+
+  $form->{"taxaccounts"} =~ s/\s*$//;
+  $form->{"taxaccounts"} =~ s/^\s*//;
+  foreach my $accno (split(/\s*/, $form->{"taxaccounts"})) {
+    map({ delete($form->{"${accno}_${_}"}); } qw(rate description taxnumber));
+  }
+  $form->{"taxaccounts"} = "";
+
+  for (my $i = 1; $i <= $form->{"rowcount"}; $i++) {
+    if ($form->{"id_$i"}) {
+      IC->retrieve_accounts(\%myconfig, $form, $form->{"id_$i"}, $i, 1);
+    }
+  }
+
+  $lxdebug->leave_sub();
+}