Bei der Liste der Rechnungen beim Typ auch zwischen Verkaufsrechnungen ("R") und...
[kivitendo-erp.git] / bin / mozilla / is.pl
index 627a51d..10dc43e 100644 (file)
@@ -35,8 +35,8 @@ use SL::IS;
 use SL::PE;
 use Data::Dumper;
 
-require "$form->{path}/io.pl";
-require "$form->{path}/arap.pl";
+require "bin/mozilla/io.pl";
+require "bin/mozilla/arap.pl";
 require "bin/mozilla/drafts.pl";
 
 1;
@@ -61,7 +61,7 @@ sub add {
 
 
   $form->{callback} =
-    "$form->{script}?action=add&type=$form->{type}&login=$form->{login}&path=$form->{path}&password=$form->{password}"
+    "$form->{script}?action=add&type=$form->{type}&login=$form->{login}&password=$form->{password}"
     unless $form->{callback};
 
   $form{jsscript} = "date";
@@ -329,38 +329,11 @@ sub form_header {
   }
 
   my $set_duedate_url =
-    "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=set_duedate";
+    "$form->{script}?login=$form->{login}&password=$form->{password}&action=set_duedate";
 
   my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
   push(@ { $form->{AJAX} }, $pjx);
 
-  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/;
-    }
-  }
-
-  $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>|;
-
   my @old_project_ids = ($form->{"globalproject_id"});
   map({ push(@old_project_ids, $form->{"project_id_$_"})
           if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
@@ -370,7 +343,8 @@ sub form_header {
                    "projects" => { "key" => "ALL_PROJECTS",
                                    "all" => 0,
                                    "old_id" => \@old_project_ids },
-                   "employees" => "ALL_SALESMEN");
+                   "employees" => "ALL_SALESMEN",
+                   "taxzones" => "ALL_TAXZONES");
 
   my %labels;
   my @values = (undef);
@@ -425,6 +399,34 @@ sub form_header {
      . qq|</td>
          </tr>|;
 
+  %labels = ();
+  @values = ();
+  foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
+    push(@values, $item->{"id"});
+    $labels{$item->{"id"}} = $item->{"description"};
+  }
+
+  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>|;
+  }
+
   # set option selected
   foreach $item (qw(AR customer currency department employee)) {
     $form->{"select$item"} =~ s/ selected//;
@@ -472,7 +474,10 @@ sub form_header {
 
   $customer =
     ($form->{selectcustomer})
-    ? qq|<select name="customer">$form->{selectcustomer}</select>\n<input type="hidden" name="selectcustomer" value="$form->{selectcustomer}">|
+    ? qq|<select name="customer"
+onchange="document.getElementById('update_button').click();">| .
+    qq|$form->{selectcustomer}</select>\n<input type="hidden" name="selectcustomer" value="| .
+    Q($form->{selectcustomer}) . qq|">|
     : qq|<input name="customer" value="$form->{customer}" size="35">|;
 
   $department = qq|
@@ -528,7 +533,7 @@ sub form_header {
   
       # with JavaScript Calendar
       $button1 = qq|
-        <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}"></td>
+        <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>
         <td><input type="button" name="invdate" id="trigger1" value="|
         . $locale->text('button') . qq|"></td>|;
        
@@ -541,7 +546,7 @@ sub form_header {
   
       # without JavaScript Calendar
       $button1 =
-        qq|<td><input name="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}"></td>|;
+        qq|<td><input name="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>|;
       $button2 =
         qq|<td width="13"><input name="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}"></td>|;
     }
@@ -550,17 +555,17 @@ sub form_header {
   
       # with JavaScript Calendar
       $button1 = qq|
-        <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}"></td>
+        <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>
         <td><input type="button" name="invdate" id="trigger1" value="|
         . $locale->text('button') . qq|"></td>
         |;
       $button2 = qq|
-        <td width="13"><input name="duedate" id="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}"></td>
+        <td width="13"><input name="duedate" id="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"></td>
         <td width="4"><input type="button" name="duedate" id="trigger2" value="|
         . $locale->text('button') . qq|"></td></td>
       |;
       $button3 = qq|
-        <td width="13"><input name="deliverydate" id="deliverydate" size="11" title="$myconfig{dateformat}" value="$form->{deliverydate}"></td>
+        <td width="13"><input name="deliverydate" id="deliverydate" size="11" title="$myconfig{dateformat}" value="$form->{deliverydate}" onBlur=\"check_right_date_format(this)\"></td>
         <td width="4"><input type="button" name="deliverydate" id="trigger3" value="|
         . $locale->text('button') . qq|"></td></td>
       |;
@@ -577,9 +582,9 @@ sub form_header {
   
       # without JavaScript Calendar
       $button1 =
-        qq|<td><input name="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}"></td>|;
+        qq|<td><input name="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>|;
       $button2 =
-        qq|<td width="13"><input name=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
+        qq|<td width="13"><input name=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate} onBlur=\"check_right_date_format(this)\"></td>|;
     }
   }
   if ($form->{resubmit} && ($form->{format} eq "html")) {
@@ -588,9 +593,10 @@ sub form_header {
   } elsif ($form->{resubmit}) {
     $onload = qq|document.invoice.submit()|;
   } else {
-    $onload = "fokus()";
+    $onload = "focus()";
   }
-
+  $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
+  $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
   $credittext = $locale->text('Credit Limit exceeded!!!');
   if ($creditwarning) {
     $onload = qq|alert('$credittext')|;
@@ -752,7 +758,7 @@ print qq|     <tr>
              </tr>
         <tr>
           <th align="right" nowrap>| . $locale->text('Order Date') . qq|</th>
-          <td><input name="orddate" id="orddate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{orddate}) . qq|"></td>
+          <td><input name="orddate" id="orddate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{orddate}) . qq|" onBlur=\"check_right_date_format(this)\"></td>
           <td><input type="button" name="b_orddate" id="trigger_orddate" value="?"></td>
         </tr>
              <tr>
@@ -761,7 +767,7 @@ print qq|     <tr>
              </tr>
         <tr>
           <th align="right" nowrap>| . $locale->text('Quotation Date') . qq|</th>
-          <td><input name="quodate" id="quodate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{quodate}) . qq|"></td>
+          <td><input name="quodate" id="quodate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{quodate}) . qq|" onBlur=\"check_right_date_format(this)\"></td>
           <td><input type="button" name="b_quodate" id="trigger_quodate" value="?"></td>
         </tr>
              <tr>
@@ -1038,12 +1044,12 @@ if ($form->{type} eq "credit_note") {
     $exchangerate .= qq|<input type="hidden" name="forex_$i" value="$form->{"forex_$i"}">|;
 
     $column_data{"paid_$i"} =
-      qq|<td align="center"><input name="paid_$i" size="11" value="$form->{"paid_$i"}"></td>|;
+      qq|<td align="center"><input name="paid_$i" size="11" value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
     $column_data{"exchangerate_$i"} = qq|<td align="center">$exchangerate</td>|;
     $column_data{"AR_paid_$i"}      =
       qq|<td align="center"><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
     $column_data{"datepaid_$i"} =
-      qq|<td align="center"><input id="datepaid_$i" name="datepaid_$i"  size="11" title="$myconfig{dateformat}" value=$form->{"datepaid_$i"}>
+      qq|<td align="center"><input id="datepaid_$i" name="datepaid_$i"  size="11" title="$myconfig{dateformat}" value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
          <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
     $column_data{"source_$i"} =
       qq|<td align=center><input name="source_$i" size="11" value="$form->{"source_$i"}"></td>|;
@@ -1068,7 +1074,7 @@ if ($form->{type} eq "credit_note") {
     <td>
 |;
 
-  &print_options;
+  print_options();
 
   print qq|
     </td>
@@ -1159,7 +1165,7 @@ if ($form->{type} eq "credit_note") {
 $cgi->hidden("-name" => "callback", "-value" => $form->{callback}) 
 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
-map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(path login password));
+map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(login password));
 print qq|
 </form>
 
@@ -1431,6 +1437,7 @@ sub post {
   remove_draft() if $form->{remove_draft};
 
   if(!exists $form->{addition}) {
+    $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
     $form->{addition} = $print_post     ? "PRINTED AND POSTED" :
                         $form->{storno} ? "STORNO"             :
                                           "POSTED";
@@ -1480,7 +1487,7 @@ sub storno {
   }
 
   map({ my $key = $_; delete($form->{$key})
-          unless (grep({ $key eq $_ } qw(path login password id type))); }
+          unless (grep({ $key eq $_ } qw(login password id type))); }
       keys(%{ $form }));
 
   &invoice_links;
@@ -1607,6 +1614,7 @@ sub yes {
   if (IS->delete_invoice(\%myconfig, \%$form, $spool)) {
     # saving the history
        if(!exists $form->{addition}) {
+    $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; 
          $form->{addition} = "DELETED";
          $form->save_history($form->dbconnect(\%myconfig));
     }