CGI::Carp qw(fatalsToBrowser); wieder rausgenommen
[kivitendo-erp.git] / bin / mozilla / ir.pl
index ac8b955..87ac207 100644 (file)
@@ -35,9 +35,9 @@ use SL::IR;
 use SL::IS;
 use SL::PE;
 
-require "$form->{path}/io.pl";
-require "$form->{path}/arap.pl";
-require "$form->{path}/common.pl";
+require "bin/mozilla/io.pl";
+require "bin/mozilla/arap.pl";
+require "bin/mozilla/common.pl";
 require "bin/mozilla/drafts.pl";
 
 1;
@@ -278,7 +278,8 @@ sub form_header {
   $form->get_lists("contacts" => "ALL_CONTACTS",
                    "projects" => { "key" => "ALL_PROJECTS",
                                    "all" => 0,
-                                   "old_id" => \@old_project_ids });
+                                   "old_id" => \@old_project_ids },
+                   "taxzones" => "ALL_TAXZONES");
 
   my %labels;
   my @values = (undef);
@@ -302,34 +303,33 @@ sub form_header {
                          '-labels' => \%labels,
                          '-default' => $form->{"globalproject_id"}));
 
-  if (@{ $form->{TAXZONE} }) {
-    $form->{selecttaxzone} = "";
-    foreach $item (@{ $form->{TAXZONE} }) {
-      if ($item->{id} == $form->{taxzone_id}) {
-        $form->{selecttaxzone} .=
-          "<option value=$item->{id} selected>" . H($item->{description}) .
-          "</option>";
-      } else {
-        $form->{selecttaxzone} .=
-          "<option value=$item->{id}>" . H($item->{description}) . "</option>";
-      }
-
-    }
-  } else {
-    $form->{selecttaxzone} =~ s/ selected//g;
-    if ($form->{taxzone_id} ne "") {
-      $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/;
-    }
+  %labels = ();
+  @values = ();
+  foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
+    push(@values, $item->{"id"});
+    $labels{$item->{"id"}} = $item->{"description"};
   }
 
-  $taxzone = qq|
-             <tr>
-               <th align=right>| . $locale->text('Steuersatz') . qq|</th>
-               <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
-               <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
-             </tr>|;
-
+  if (!$form->{"id"}) {
+    $taxzone = qq|
+    <tr>
+      <th align="right">| . $locale->text('Steuersatz') . qq|</th>
+      <td>| .
+        NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
+                             '-values' => \@values, '-labels' => \%labels)) . qq|
+      </td>
+    </tr>|;
 
+  } else {
+    $taxzone = qq|
+    <tr>
+      <th align="right">| . $locale->text('Steuersatz') . qq|</th>
+      <td>
+        <input type="hidden" name="taxzone_id" value="| . H($form->{"taxzone_id"}) . qq|">
+        | . H($labels{$form->{"taxzone_id"}}) . qq|
+      </td>
+    </tr>|;
+  }
 
   $vendor =
     ($form->{selectvendor})
@@ -826,19 +826,8 @@ sub form_footer {
                        '-class' => 'submit'));
   }
 
-  print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
-    qq|
-
-<input type=hidden name=rowcount value=$form->{rowcount}>
-
-<input name=callback type=hidden value="$form->{callback}">
-
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
-|
-  . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
-  . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
+  print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers);
+  $form->hide_form(qw(rowcount callback draft_id draft_description login password));
 
   # button for saving history
   if($form->{id} ne "") {
@@ -992,12 +981,20 @@ sub storno {
   invoice_links();
   prepare_invoice();
   relink_accounts();
-
+  
+  # saving the history
+  if(!exists $form->{addition} && $form->{id} ne "") {
+    $form->{snumbers} = qq|invnumber_| . $form->{invnumber};  
+    $form->{addition} = "CANCELED";
+    $form->save_history($form->dbconnect(\%myconfig));
+  }
+  # /saving the history
+  
   $form->{storno_id} = $form->{id};
   $form->{storno} = 1;
   $form->{id} = "";
   $form->{invnumber} = "Storno zu " . $form->{invnumber};
-
+  $form->{rowcount}++;
   &post();
   $lxdebug->leave_sub();
 
@@ -1041,6 +1038,7 @@ sub post_payment {
        
        if(!exists $form->{addition} && $form->{id} ne "") {
                # saving the history
+      $form->{snumbers} = qq|invnumber_| . $form->{invnumber};  
                $form->{addition} = "PAYMENT POSTED";
                $form->save_history($form->dbconnect(\%myconfig));
                # /saving the history 
@@ -1104,7 +1102,8 @@ sub post {
   if (IR->post_invoice(\%myconfig, \%$form)){
        # saving the history
        if(!exists $form->{addition} && $form->{id} ne "") {
-               $form->{addition} = "POSTED";
+      $form->{snumbers} = qq|invnumber_| . $form->{invnumber};  
+      $form->{addition} = "POSTED";
                #$form->{what_done} = $locale->text("Rechnungsnummer") . qq| | . $form->{invnumber};
                $form->save_history($form->dbconnect(\%myconfig));
        }
@@ -1157,6 +1156,7 @@ sub yes {
   if (IR->delete_invoice(\%myconfig, \%$form)) {
     # saving the history
     if(!exists $form->{addition}) {
+      $form->{snumbers} = qq|invnumber_| . $form->{invnumber};  
          $form->{addition} = "DELETED";
          $form->save_history($form->dbconnect(\%myconfig));
     }