Browse Source

add field 'Authorize decimal' in product edit form TG-49

SiM 5 years ago
parent
commit
601e256173

+ 8 - 1
apps/admin/modules/kataoProduct/templates/editSuccess.php

@@ -127,6 +127,13 @@
         </td>
       </tr>
   <?php endif ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['authorize_decimal']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['authorize_decimal'] ?>
+      <?php echo $form['authorize_decimal']->renderError() ?>
+        </td>
+      </tr>
       <tr valign="top">
 	  	<td colspan="2" align="left"><br /><u>Monnaie complémentaire</u></td>
 	  </tr>
@@ -235,4 +242,4 @@ computeSolPercent();
 <?php endif ?>
 
 /* ]]> */
-</script>
+</script>

+ 4 - 0
apps/admin/modules/kataoProduct/templates/showSuccess.php

@@ -48,6 +48,10 @@
       <th>Min order number:</th>
       <td><?php echo $katao_product->getMinOrderNumber() ?></td>
     </tr>
+    <tr valign="top">
+      <th>Authorize quantity with decimal:</th>
+      <td><?php echo $katao_product->getAuthorizeDecimal() ?></td>
+    </tr>
     <tr valign="top">
       <th>Margin:</th>
       <td><?php echo $katao_product->getMargin() ?></td>

+ 6 - 0
lib/form/KataoProductForm.class.php

@@ -52,6 +52,11 @@ class KataoProductForm extends BaseKataoProductForm {
 		if ((bool)$this->getObject()->getIsArchived()) {
 			$this->widgetSchema['is_archived']->setAttribute('checked', 'checked');
 		}
+		$this->widgetSchema['authorize_decimal'] = new wpWidgetFormInputCheckbox();
+		$this->widgetSchema['authorize_decimal']->setOption('value_attribute_value', 1);
+		if ((bool)$this->getObject()->getAuthorizeDecimal()) {
+			$this->widgetSchema['authorize_decimal']->setAttribute('checked', 'checked');
+		}
 
 		$this->widgetSchema['picture'] = new wpWidgetFormInputFile(array(), array('file_src' => $this->getObject()->getPicture()));
 		$this->validatorSchema['picture'] = new sfValidatorFile(array('required' => false, 'mime_types' => array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif', 'image/jpeg; charset=binary')), array('mime_types' => 'Merci de choisir une image au format jpg, png ou gif (%mime_type%)'));
@@ -71,6 +76,7 @@ class KataoProductForm extends BaseKataoProductForm {
 				'is_archived' => 'Archivé ?',
 				'accounting_code_purchase' => 'Achat',
 				'accounting_code_sell' => 'Vente',
+				'authorize_decimal' => 'Autoriser quantités avec décimales',
 				));
 
 		$this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'checkMaxSolAmount')), array('invalid' => 'Le montant de la monnaie complémentaire est trop important.')));

+ 2 - 0
lib/form/base/BaseKataoProductForm.class.php

@@ -27,6 +27,7 @@ class BaseKataoProductForm extends BaseFormPropel
       'picture'                  => new sfWidgetFormInput(),
       'delivery_delay'           => new sfWidgetFormInput(),
       'is_archived'              => new sfWidgetFormInput(),
+      'authorize_decimal'       => new sfWidgetFormInput(),
       'accounting_code_purchase' => new sfWidgetFormInput(),
       'accounting_code_sell'     => new sfWidgetFormInput(),
       'created_at'               => new sfWidgetFormDateTime(),
@@ -49,6 +50,7 @@ class BaseKataoProductForm extends BaseFormPropel
       'picture'                  => new sfValidatorString(array('max_length' => 255, 'required' => false)),
       'delivery_delay'           => new sfValidatorInteger(array('required' => false)),
       'is_archived'              => new sfValidatorInteger(array('required' => false)),
+      'authorize_decimal'       => new sfValidatorInteger(array('required' => false)),
       'accounting_code_purchase' => new sfValidatorString(array('max_length' => 12)),
       'accounting_code_sell'     => new sfValidatorString(array('max_length' => 12)),
       'created_at'               => new sfValidatorDateTime(array('required' => false)),

+ 4 - 0
lib/model/KataoProduct.php

@@ -185,6 +185,10 @@ class KataoProduct extends BaseKataoProduct {
         return $this->getIsArchived()?'Oui':'Non';
     }
 
+    public function getAuthorizeDecimalStr() {
+        return $this->getAuthorizeDecimal()?'Oui':'Non';
+    }
+
     public function getRealPicture() {
         return $this->hasPicture()?$this->getPicture():(wpConfig::hasDefaultProductPicture()?wpConfig::getDefaultProductPicture():'img04.gif');
     }