Bugfix Tabindex in Kundenerfassenmaske fuer Preisgruppe
[kivitendo-erp.git] / bin / mozilla / ct.pl
index 0e1df52..fc260c6 100644 (file)
@@ -69,8 +69,7 @@ sub search {
   if ($form->{db} eq 'vendor') {
     $gifi = qq|
                <td><input name="l_gifi_accno" type=checkbox class=checkbox value=Y> |
-      . $locale->text('GIFI')
-      . qq|</td>
+      . $locale->text('GIFI') . qq|</td>
 |;
   }
 
@@ -112,8 +111,7 @@ sub search {
          <td><input name=status class=radio type=radio value=all checked>&nbsp;|
     . $locale->text('All') . qq|
          <input name=status class=radio type=radio value=orphaned>&nbsp;|
-    . $locale->text('Orphaned')
-    . qq|</td>
+    . $locale->text('Orphaned') . qq|</td>
        </tr>
        <tr>
          <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
@@ -121,54 +119,40 @@ sub search {
            <table>
              <tr>
                <td><input name="l_id" type=checkbox class=checkbox value=Y> |
-    . $locale->text('ID')
-    . qq|</td>
+    . $locale->text('ID') . qq|</td>
                <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
-    . $locale->text($label . ' Number')
-    . qq|</td>
+    . $locale->text($label . ' Number') . qq|</td>
                <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
-    . $locale->text('Company Name')
-    . qq|</td>
+    . $locale->text('Company Name') . qq|</td>
                <td><input name="l_address" type=checkbox class=checkbox value=Y> |
-    . $locale->text('Address')
-    . qq|</td>
+    . $locale->text('Address') . qq|</td>
              </tr>
              <tr>
                <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
-    . $locale->text('Contact')
-    . qq|</td>
+    . $locale->text('Contact') . qq|</td>
                <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
-    . $locale->text('Phone')
-    . qq|</td>
+    . $locale->text('Phone') . qq|</td>
                <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
-    . $locale->text('Fax')
-    . qq|</td>
+    . $locale->text('Fax') . qq|</td>
                <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
-    . $locale->text('E-mail')
-    . qq|</td>
+    . $locale->text('E-mail') . qq|</td>
              </tr>
              <tr>
                <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
-    . $locale->text('Tax Number')
-    . qq|</td>
+    . $locale->text('Tax Number') . qq|</td>
                $gifi
                <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
-    . $locale->text('SIC')
-    . qq|</td>
+    . $locale->text('SIC') . qq|</td>
                <td><input name="l_business" type=checkbox class=checkbox value=Y> |
-    . $locale->text('Type of Business')
-    . qq|</td>
+    . $locale->text('Type of Business') . qq|</td>
              </tr>
              <tr>
                <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
-    . $locale->text('Invoices')
-    . qq|</td>
+    . $locale->text('Invoices') . qq|</td>
                <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
-    . $locale->text('Orders')
-    . qq|</td>
+    . $locale->text('Orders') . qq|</td>
                <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
-    . $locale->text('Quotations')
-    . qq|</td>
+    . $locale->text('Quotations') . qq|</td>
              </tr>
            </table>
          </td>
@@ -479,6 +463,7 @@ sub form_header {
   $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
   $form->{creditlimit} =
     $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
+  $form->{discount} = $form->format_amount(\%myconfig, $form->{discount});
 
   if ($myconfig{role} eq 'admin') {
     $bcc = qq|
@@ -528,10 +513,10 @@ sub form_header {
   </tr>
 |;
   }
-
   $form->{selectbusiness} = qq|<option>\n|;
   map {
-    $form->{selectbusiness} .= qq|<option value=$_->{id}>$_->{description}\n|
+    $form->{selectbusiness} .=
+      qq|<option value=$_->{id}>$_->{description}\n|
   } @{ $form->{all_business} };
   if ($form->{business_save}) {
     $form->{selectbusiness} = $form->{business_save};
@@ -595,10 +580,44 @@ sub form_header {
 
   $select_greeting =
     qq|&nbsp;<select name=selected_cp_greeting><option></option>|;
-  map({ $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
+  map(
+     { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
   $select_greeting .= qq|</select>|;
 ## /LINET
 
+  if ($form->{db} eq 'customer') {
+
+    #get pricegroup and form it
+    $form->get_pricegroup(\%myconfig, { all => 1 });
+
+    $form->{pricegroup}    = "$form->{klass}";
+    $form->{pricegroup_id} = "$form->{klass}";
+
+    if (@{ $form->{all_pricegroup} }) {
+
+      $form->{selectpricegroup} = qq|<option>\n|;
+      map {
+        $form->{selectpricegroup} .=
+          qq|<option value="$_->{id}">$_->{pricegroup}\n|
+      } @{ $form->{all_pricegroup} };
+    }
+
+    if ($form->{selectpricegroup}) {
+      $form->{selectpricegroup} = $form->unescape($form->{selectpricegroup});
+
+      $pricegroup =
+        qq|<input type=hidden name=selectpricegroup value="|
+        . $form->escape($form->{selectpricegroup}, 1) . qq|">|;
+
+      $form->{selectpricegroup} =~
+        s/(<option value="\Q$form->{klass}\E")/$1 selected/;
+
+      $pricegroup .=
+        qq|<select name=klass tabindex=24>$form->{selectpricegroup}</select>|;
+
+    }
+  }
+
   # $locale->text('Customer Number')
   # $locale->text('Vendor Number')
   $form->{fokus} = "ct.name";
@@ -617,11 +636,9 @@ sub form_header {
       <table width=100%>
        <tr class=listheading>
          <th class=listheading colspan=2 width=50%>|
-    . $locale->text('Billing Address')
-    . qq|</th>
+    . $locale->text('Billing Address') . qq|</th>
          <th class=listheading width=50%>|
-    . $locale->text('Shipping Address')
-    . qq|</th>
+    . $locale->text('Shipping Address') . qq|</th>
        </tr>
        <tr height="5"></tr>
         $business_salesman
@@ -631,7 +648,7 @@ sub form_header {
        </tr>
        <tr>
          <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
-         <td><input name=name size=35 maxlength=35 tabindex=1 value="$form->{name}"></td>
+         <td><input name=name size=35 maxlength=75 tabindex=1 value="$form->{name}"></td>
          <td><input name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
        </tr>
        <tr>
@@ -644,13 +661,11 @@ sub form_header {
        <tr>
          <th align=right nowrap>| . $locale->text('Street') . qq|</th>
          <td><input name=street size=35 tabindex=4 maxlength=75 value="$form->{street}"></td>
-         <td><input name=shiptostreet size=35 maxlength=35 value="$form->{shiptostreet}"></td>
+         <td><input name=shiptostreet size=35 maxlength=75 value="$form->{shiptostreet}"></td>
        </tr>
        <tr>
          <th align=right nowrap>|
-    . $locale->text('Zipcode') . "/"
-    . $locale->text('City')
-    . qq|</th>
+    . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
          <td><input name=zipcode size=5 tabindex=5 maxlength=10 value="$form->{zipcode}">
           <input name=city size=30 tabindex=6 maxlength=75 value="$form->{city}"></td>
          <td><input name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
@@ -694,8 +709,7 @@ sub form_header {
                 <table>
                 <tr>
                  <th align=right nowrap>|
-    . $locale->text('Contact Person')
-    . qq|</th>
+    . $locale->text('Contact Person') . qq|</th>
                 </tr>
                 <tr>
                   <th></th>
@@ -709,8 +723,7 @@ sub form_header {
                 <tr>
                   <th></th>
                   <th align=left nowrap>|
-    . $locale->text('Given Name')
-    . qq|</th>
+    . $locale->text('Given Name') . qq|</th>
                   <td><input name=cp_givenname size=30 maxlength=40 value="$form->{cp_givenname}"></td>
                  <th align=left nowrap>| . $locale->text('Name') . qq|</th>
                   <td><input name=cp_name size=30 maxlength=40 value="$form->{cp_name}"></td>
@@ -746,8 +759,7 @@ sub form_header {
          <td><input name=creditlimit tabindex=13 size=9 value="$form->{creditlimit}"></td>
          <th align=right>| . $locale->text('Terms: Net') . qq|</th>
          <td><input name=terms tabindex=14 size=2 value="$form->{terms}">|
-    . $locale->text('days')
-    . qq|</td>
+    . $locale->text('days') . qq|</td>
          <th align=right>| . $locale->text('Discount') . qq|</th>
          <td><input name=discount tabindex=15 size=4 value="$form->{discount}">
          %</td>
@@ -773,6 +785,12 @@ sub form_header {
          <td><select name=language tabindex=23>$lang
                           </select></td>|;
 
+  if ($form->{db} eq 'customer') {
+
+    print qq|
+          <th align=right>| . $locale->text('Preisklasse') . qq|</th>
+          <td>$pricegroup</td>|;
+  }
   print qq|        </tr>
         <tr>
           <td align=right>| . $locale->text('Obsolete') . qq|</td>
@@ -834,6 +852,8 @@ sub form_footer {
 <input type=hidden name=callback value="$form->{callback}">
 <input type=hidden name=db value=$form->{db}>
 
+
+
 <br>
 $update_button
 <input class=submit type=submit name=action accesskey="s" value="|
@@ -957,8 +977,10 @@ sub save {
   if ($vertreter && $form->{db} eq "customer") {
     $form->isblank("salesman_id", $locale->text("Salesman missing!"));
   }
-  &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
-
+  $rc = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
+  if ($rc == 3) {
+    $form->error($locale->text('customernumber not unique!'));
+  }
   $form->redirect($locale->text($msg));
 
   $lxdebug->leave_sub();