Browse Source

change ux quantity field from int to float type and use native input number to adjust quantity TG-50

SiM 5 years ago
parent
commit
3c7b48585a

+ 2 - 4
apps/admin/modules/kataoInvoice/templates/deliverSuccess.php

@@ -26,9 +26,7 @@ $criteria->addAscendingOrderByColumn(KataoInvoiceProductPeer::PRODUCT_NAME); ?>
  	<td><?php echo $katao_invoice_product->getProductName() ?></td>
  	<td style="text-align:center!important"><?php echo $katao_invoice_product->getQuantity() ?></td>
  	<td nowrap="nowrap" style="text-align:center!important">
- 		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_invoice_product->getId() ?>').value = Math.max(0, parseInt(document.getElementById('quantity_<?php echo $katao_invoice_product->getId() ?>').value) - 1); updateCurrentDelivered(<?php echo $katao_invoice_product->getId() ?>, <?php echo $total_delivered_quantity ?>);" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
-		<?php echo input_tag('quantity[' . $katao_invoice_product->getId() . ']', $quantity, array('style' => 'width: 20px; text-align: center;', 'class' => 'quantity-delivered', 'onchange' => 'updateCurrentDelivered(' . $katao_invoice_product->getId() . ', ' . $total_delivered_quantity . ');')) ?>
-		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_invoice_product->getId() ?>').value = parseInt(document.getElementById('quantity_<?php echo $katao_invoice_product->getId() ?>').value) + 1; updateCurrentDelivered(<?php echo $katao_invoice_product->getId() ?>, <?php echo $total_delivered_quantity ?>);" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+		<?php echo input_number_tag('quantity[' . $katao_invoice_product->getId() . ']', $quantity, array('style' => 'width: 60px; height: 20px; text-align: center;', 'class' => 'quantity-delivered', 'onchange' => 'updateCurrentDelivered(' . $katao_invoice_product->getId() . ', ' . $total_delivered_quantity . ');')) ?>
 	</td>
 	<td style="text-align:center!important"><span id="current-quantity-<?php echo $katao_invoice_product->getId() ?>"><?php echo $total_delivered_quantity + $quantity ?></span> / <?php echo $katao_product->getTotalReceivedQuantity($katao_invoice->getKataoPeriodId(), $katao_invoice->getKataoNodeId()) ?></td>
 
@@ -47,7 +45,7 @@ $criteria->addAscendingOrderByColumn(KataoInvoiceProductPeer::PRODUCT_NAME); ?>
 /* <![CDATA[ */
 
 function updateCurrentDelivered(id, total_delivered_quantity){
-	$('current-quantity-' + id).innerHTML = total_delivered_quantity + parseInt($F('quantity_' + id));
+	$('current-quantity-' + id).innerHTML = total_delivered_quantity + parseFloat($F('quantity_' + id));
 }
 
 /* ]]> */

+ 2 - 6
apps/admin/modules/kataoOrder/templates/adjustProductSuccess.php

@@ -28,9 +28,7 @@
  	<td><?php echo $katao_cart_product->getQuantity() ?></td>
  	<td nowrap="nowrap">
  	<?php if (!$view_mode_only): ?>
- 		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value = Math.max(0, parseInt(document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value) - 1)" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
-		<?php echo input_tag('quantity[' . $katao_cart_product->getId() . ']', $katao_cart_product->getQuantityAdjusted(), array('style' => 'width: 20px; text-align: center;')) ?>
-		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value = parseInt(document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value) + 1" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+		<?php echo input_number_tag('quantity[' . $katao_cart_product->getId() . ']', $katao_cart_product->getQuantityAdjusted(), array('style' => 'width: 60px; height: 20px; text-align: center;')) ?>
 	<?php else: ?>
 		<?php echo $katao_cart_product->getQuantityAdjusted() ?>
 	<?php endif ?>
@@ -42,9 +40,7 @@
  	<td><?php echo select_tag('new_user_id', options_for_select($katao_order_product->getMembersWithoutProduct(), false, array('include_custom' => '&mdash;&nbsp;Ajouter une commande à un adhérent&nbsp;&mdash;'))) ?></td>
  	<td>-</td>
  	<td nowrap="nowrap">
- 		<a href="javascript://" onclick="document.getElementById('quantity_0').value = Math.max(0, parseInt(document.getElementById('quantity_0').value) - 1)" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
-		<?php echo input_tag('quantity[0]', '0', array('style' => 'width: 20px; text-align: center;')) ?>
-		<a href="javascript://" onclick="document.getElementById('quantity_0').value = parseInt(document.getElementById('quantity_0').value) + 1" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+		<?php echo input_number_tag('quantity[0]', '0', array('style' => 'width: 60px; height: 20px; text-align: center;')) ?>
 	</td>
 </tr>
 <?php endif ?>

+ 2 - 3
apps/admin/modules/kataoOrder/templates/deliverProductSuccess.php

@@ -28,9 +28,8 @@
  	<td style="text-align:center!important"><?php echo $katao_cart_product->getQuantity() ?></td>
  	<td style="text-align:center!important"><?php echo $katao_cart_product->getQuantityAdjusted() ?></td>
  	<td nowrap="nowrap" style="text-align:center!important">
- 		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value = Math.max(0, parseInt(document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value) - 1); updateTotalDelivered();" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
-		<?php echo input_tag('quantity[' . $katao_cart_product->getId() . ']', $quantity, array('style' => 'width: 20px; text-align: center;', 'class' => 'quantity-delivered', 'onchange' => 'updateTotalDelivered();')) ?>
-		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value = parseInt(document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value) + 1; updateTotalDelivered();" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+		<?php echo input_number_tag('quantity[' . $katao_cart_product->getId() . ']', $quantity, array('style' => 'width: 60px; height: 20px; text-align: center;', 'class' => 'quantity-delivered', 'onchange' => 'updateTotalDelivered();')) ?>
+
 	</td>
 </tr>
 <?php endforeach ?>

+ 1 - 3
apps/admin/modules/kataoOrder/templates/receiveSuccess.php

@@ -19,9 +19,7 @@
  	<td><?php echo $katao_order_product->getProductName() ?></td>
  	<td style="text-align:center!important"><?php echo $katao_order_product->getQuantity() ?></td>
  	<td nowrap="nowrap" style="text-align:center!important">
- 		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_order_product->getId() ?>').value = Math.max(0, parseInt(document.getElementById('quantity_<?php echo $katao_order_product->getId() ?>').value) - 1)" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
-		<?php echo input_tag('quantity[' . $katao_order_product->getId() . ']', $katao_order_product->getHasBeenReceived()?$katao_order_product->getQuantityReceived():$katao_order_product->getQuantity(), array('style' => 'width: 20px; text-align: center;')) ?>
-		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_order_product->getId() ?>').value = parseInt(document.getElementById('quantity_<?php echo $katao_order_product->getId() ?>').value) + 1" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+		<?php echo input_number_tag('quantity[' . $katao_order_product->getId() . ']', $katao_order_product->getHasBeenReceived()?$katao_order_product->getQuantityReceived():$katao_order_product->getQuantity(), array('style' => 'width: 60px; height: 20px; text-align: center;')) ?>
 	</td>
 </tr>
 <?php endforeach ?>

+ 1 - 1
apps/frontend/modules/katao/actions/actions.class.php

@@ -128,7 +128,7 @@ class kataoActions extends sfActions {
         $this->forward404Unless($katao_product);
         $this->forward404If(!$katao_product->isCartable());
 
-        if (0 < (int)$request->getParameter('quantity')) {
+        if (0 < (float)$request->getParameter('quantity')) {
             $this->getUser()->getInstance()->addProductToCart($katao_product->getId(), $request->getParameter('quantity', 1));
         } else {
             $this->getUser()->getInstance()->removeProductFromCart($katao_product->getId());

+ 1 - 3
apps/frontend/modules/katao/templates/_products.php

@@ -40,9 +40,7 @@ if ($display) {
 			<?php if ($is_cartable): ?>
 				<div style="clear: both; padding-top: 15px">
 					<div style="float: left; padding-right: 10px">
-						<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_product->getId() ?>').value = Math.max(1, parseInt(document.getElementById('quantity_<?php echo $katao_product->getId() ?>').value) - 1)" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
-						<input type="text" name="quantity[<?php echo $katao_product->getId() ?>]" id="quantity_<?php echo $katao_product->getId() ?>" value="1" style="width: 20px; text-align: center;" />
-						<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_product->getId() ?>').value = parseInt(document.getElementById('quantity_<?php echo $katao_product->getId() ?>').value) + 1" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+						<input type="number" name="quantity[<?php echo $katao_product->getId() ?>]" id="quantity_<?php echo $katao_product->getId() ?>" value="1" style="width: 60px; height: 20px; text-align: center;" />	
 					</div>
 					<div style="float: left">
 						<a class="btn-commander" href="javascript://" onclick="window.location = '<?php echo url_for('@katao_cart_add_js') ?>?product=<?php echo $katao_product->getUrlIdentifier() ?>&quantity='+document.getElementById('quantity_<?php echo $katao_product->getId() ?>').value;">Commander</a>

+ 1 - 1
apps/frontend/modules/katao/templates/cartSuccess.php

@@ -60,7 +60,7 @@ unset($allLanguages[$default]);
 
 				<div style="clear: both">
 					<div style="float: left; padding-right: 10px">
-						<input type="text" name="quantity_<?php echo $katao_product->getId() ?>" id="quantity_<?php echo $katao_product->getId() ?>" value="<?php echo $quantity ?>" style="width: 20px; text-align: center;" />
+						<input type="number" name="quantity_<?php echo $katao_product->getId() ?>" id="quantity_<?php echo $katao_product->getId() ?>" value="<?php echo $quantity ?>" style="width: 60px; height: 20px; text-align: center;" />
 					</div>
 					<div style="float: left; padding-right: 10px; padding-top: 4px">
 						<a class="btn-plus" href="javascript://" onclick="window.location = '<?php echo url_for('@katao_cart_add_js') ?>?product=<?php echo $katao_product->getUrlIdentifier() ?>&quantity='+document.getElementById('quantity_<?php echo $katao_product->getId() ?>').value;">Mettre à jour</a>

+ 1 - 3
apps/frontend/modules/katao/templates/storeSuccess.php

@@ -74,9 +74,7 @@ unset($allLanguages[$default]);
 				<div style="clear: both; margin-top: 40px">
 				<?php if ($katao_product_cartable): ?>
 					<div style="float: left; padding-right: 10px">
-						<a href="javascript://" onclick="document.getElementById('quantity').value = Math.max(1, parseInt(document.getElementById('quantity').value) - 1)" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
-						<input type="text" name="quantity" id="quantity" value="1" style="width: 20px; text-align: center;" />
-						<a href="javascript://" onclick="document.getElementById('quantity').value = parseInt(document.getElementById('quantity').value) + 1" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+						<input type="number" name="quantity" id="quantity" value="1" style="width: 60px; height: 20px; text-align: center;" />
 					</div>
 					<div style="float: left">
 						<a class="btn-commander" href="javascript://" onclick="window.location = '<?php echo url_for('@katao_cart_add_js') ?>?product=<?php echo $katao_product->getUrlIdentifier() ?>&quantity='+document.getElementById('quantity').value;">Commander</a>

+ 6 - 6
lib/form/base/BaseKataoCartProductForm.class.php

@@ -20,10 +20,10 @@ class BaseKataoCartProductForm extends BaseFormPropel
       'product_price_euro'     => new sfWidgetFormInput(),
       'product_margin'         => new sfWidgetFormInput(),
       'product_tva_rate'       => new sfWidgetFormInput(),
-      'quantity'               => new sfWidgetFormInput(),
-      'quantity_adjusted'      => new sfWidgetFormInput(),
+      'quantity'               => new sfWidgetFormInputNumber(),
+      'quantity_adjusted'      => new sfWidgetFormInputNumber(),
       'has_been_adjusted'      => new sfWidgetFormInput(),
-      'quantity_delivered'     => new sfWidgetFormInput(),
+      'quantity_delivered'     => new sfWidgetFormInputNumber(),
       'katao_order_product_id' => new sfWidgetFormPropelSelect(array('model' => 'KataoOrderProduct', 'add_empty' => true)),
       'created_at'             => new sfWidgetFormDateTime(),
       'updated_at'             => new sfWidgetFormDateTime(),
@@ -38,10 +38,10 @@ class BaseKataoCartProductForm extends BaseFormPropel
       'product_price_euro'     => new sfValidatorNumber(),
       'product_margin'         => new sfValidatorNumber(array('required' => false)),
       'product_tva_rate'       => new sfValidatorNumber(array('required' => false)),
-      'quantity'               => new sfValidatorInteger(),
-      'quantity_adjusted'      => new sfValidatorInteger(array('required' => false)),
+      'quantity'               => new sfValidatorNumber(),
+      'quantity_adjusted'      => new sfValidatorNumber(array('required' => false)),
       'has_been_adjusted'      => new sfValidatorInteger(array('required' => false)),
-      'quantity_delivered'     => new sfValidatorInteger(array('required' => false)),
+      'quantity_delivered'     => new sfValidatorNumber(array('required' => false)),
       'katao_order_product_id' => new sfValidatorPropelChoice(array('model' => 'KataoOrderProduct', 'column' => 'id', 'required' => false)),
       'created_at'             => new sfValidatorDateTime(array('required' => false)),
       'updated_at'             => new sfValidatorDateTime(array('required' => false)),

+ 4 - 4
lib/form/base/BaseKataoInvoiceProductForm.class.php

@@ -22,8 +22,8 @@ class BaseKataoInvoiceProductForm extends BaseFormPropel
       'product_price_euro'     => new sfWidgetFormInput(),
       'product_margin'         => new sfWidgetFormInput(),
       'product_tva_rate'       => new sfWidgetFormInput(),
-      'quantity'               => new sfWidgetFormInput(),
-      'quantity_delivered'     => new sfWidgetFormInput(),
+      'quantity'               => new sfWidgetFormInputNumber(),
+      'quantity_delivered'     => new sfWidgetFormInputNumber(),
       'sol_amount'             => new sfWidgetFormInput(),
       'created_at'             => new sfWidgetFormDateTime(),
       'updated_at'             => new sfWidgetFormDateTime(),
@@ -40,8 +40,8 @@ class BaseKataoInvoiceProductForm extends BaseFormPropel
       'product_price_euro'     => new sfValidatorNumber(),
       'product_margin'         => new sfValidatorNumber(array('required' => false)),
       'product_tva_rate'       => new sfValidatorNumber(array('required' => false)),
-      'quantity'               => new sfValidatorInteger(),
-      'quantity_delivered'     => new sfValidatorInteger(array('required' => false)),
+      'quantity'               => new sfValidatorNumber(),
+      'quantity_delivered'     => new sfValidatorNumber(array('required' => false)),
       'sol_amount'             => new sfValidatorInteger(array('required' => false)),
       'created_at'             => new sfValidatorDateTime(array('required' => false)),
       'updated_at'             => new sfValidatorDateTime(array('required' => false)),

+ 6 - 6
lib/form/base/BaseKataoOrderProductForm.class.php

@@ -20,9 +20,9 @@ class BaseKataoOrderProductForm extends BaseFormPropel
       'product_price_euro' => new sfWidgetFormInput(),
       'product_margin'     => new sfWidgetFormInput(),
       'product_tva_rate'   => new sfWidgetFormInput(),
-      'quantity'           => new sfWidgetFormInput(),
-      'quantity_received'  => new sfWidgetFormInput(),
-      'quantity_delivered' => new sfWidgetFormInput(),
+      'quantity'           => new sfWidgetFormInputNumber(),
+      'quantity_received'  => new sfWidgetFormInputNumber(),
+      'quantity_delivered' => new sfWidgetFormInputNumber(),
       'has_been_received'  => new sfWidgetFormInput(),
       'has_been_delivered' => new sfWidgetFormInput(),
       'created_at'         => new sfWidgetFormDateTime(),
@@ -38,9 +38,9 @@ class BaseKataoOrderProductForm extends BaseFormPropel
       'product_price_euro' => new sfValidatorNumber(),
       'product_margin'     => new sfValidatorNumber(array('required' => false)),
       'product_tva_rate'   => new sfValidatorNumber(array('required' => false)),
-      'quantity'           => new sfValidatorInteger(),
-      'quantity_received'  => new sfValidatorInteger(array('required' => false)),
-      'quantity_delivered' => new sfValidatorInteger(array('required' => false)),
+      'quantity'           => new sfValidatorNumber(),
+      'quantity_received'  => new sfValidatorNumber(array('required' => false)),
+      'quantity_delivered' => new sfValidatorNumber(array('required' => false)),
       'has_been_received'  => new sfValidatorInteger(array('required' => false)),
       'has_been_delivered' => new sfValidatorInteger(array('required' => false)),
       'created_at'         => new sfValidatorDateTime(array('required' => false)),

+ 2 - 2
lib/form/base/BaseKataoSupplierInvoiceProductForm.class.php

@@ -20,7 +20,7 @@ class BaseKataoSupplierInvoiceProductForm extends BaseFormPropel
       'product_price_euro'        => new sfWidgetFormInput(),
       'product_margin'            => new sfWidgetFormInput(),
       'product_tva_rate'          => new sfWidgetFormInput(),
-      'quantity'                  => new sfWidgetFormInput(),
+      'quantity'                  => new sfWidgetFormInputNumber(),
       'product_price_total'       => new sfWidgetFormInput(),
       'created_at'                => new sfWidgetFormDateTime(),
       'updated_at'                => new sfWidgetFormDateTime(),
@@ -35,7 +35,7 @@ class BaseKataoSupplierInvoiceProductForm extends BaseFormPropel
       'product_price_euro'        => new sfValidatorNumber(),
       'product_margin'            => new sfValidatorNumber(array('required' => false)),
       'product_tva_rate'          => new sfValidatorNumber(array('required' => false)),
-      'quantity'                  => new sfValidatorInteger(),
+      'quantity'                  => new sfValidatorNumber(),
       'product_price_total'       => new sfValidatorNumber(array('required' => false)),
       'created_at'                => new sfValidatorDateTime(array('required' => false)),
       'updated_at'                => new sfValidatorDateTime(array('required' => false)),

+ 2 - 2
lib/model/KataoCartProductPeer.php

@@ -44,7 +44,7 @@ class KataoCartProductPeer extends BaseKataoCartProductPeer {
      * KataoCartProductPeer::n()
      *
      * @param int $id
-     * @param int $quantity
+     * @param float $quantity
      * @return
      */
     public static function adjustQuantity($id, $quantity) {
@@ -60,7 +60,7 @@ class KataoCartProductPeer extends BaseKataoCartProductPeer {
      * KataoCartProductPeer::deliverQuantity()
      *
      * @param int $id
-     * @param int $quantity
+     * @param float $quantity
      * @return
      */
     public static function deliverQuantity($id, $quantity) {

+ 3 - 3
lib/model/KataoOrder.php

@@ -64,7 +64,7 @@ class KataoOrder extends BaseKataoOrder {
      * KataoOrder::updateProductQuantity()
      *
      * @param int $katao_product_id
-     * @param int $katao_order_product_quantity
+     * @param float $katao_order_product_quantity
      * @return
      */
     public function updateProductQuantity($katao_product_id, $katao_order_product_quantity) {
@@ -99,7 +99,7 @@ class KataoOrder extends BaseKataoOrder {
      *
      * @param int $katao_user_id
      * @param int $katao_product_id
-     * @param int $quantity
+     * @param float $quantity
      * @return
      */
     public function addProductToUser($katao_user_id, $katao_product_id, $quantity) {
@@ -112,7 +112,7 @@ class KataoOrder extends BaseKataoOrder {
      * KataoOrder::updateProductQuantity()
      *
      * @param int $katao_product_id
-     * @param int $katao_order_product_quantity
+     * @param float $katao_order_product_quantity
      * @return KataoOrderProduct
      */
     public function getKataoOrderProductByProductId($katao_product_id) {

+ 1 - 1
lib/model/KataoOrderProduct.php

@@ -36,7 +36,7 @@ class KataoOrderProduct extends BaseKataoOrderProduct {
      * KataoOrderProduct::addProductToUser()
      *
      * @param int $katao_user_id
-     * @param int $quantity
+     * @param float $quantity
      * @return
      */
     public function addProductToUser($katao_user_id, $quantity) {

+ 1 - 1
lib/model/KataoOrderProductPeer.php

@@ -10,7 +10,7 @@ class KataoOrderProductPeer extends BaseKataoOrderProductPeer {
      * KataoOrderProductPeer::receiveQuantity()
      *
      * @param int $id
-     * @param int $quantity
+     * @param float $quantity
      * @return
      */
     public static function receiveQuantity($id, $quantity) {

+ 2 - 2
lib/model/KataoProduct.php

@@ -293,7 +293,7 @@ L\'équipe KATAO', $this->getName(), $this->getReference(), Utils::formatCurrenc
      *
      * @param int $katao_period_id
      * @param int $katao_node_id
-     * @return int
+     * @return float
      */
     public function getTotalReceivedQuantity($katao_period_id, $katao_node_id) {
         $return = 0;
@@ -318,7 +318,7 @@ L\'équipe KATAO', $this->getName(), $this->getReference(), Utils::formatCurrenc
      *
      * @param int $katao_period_id
      * @param int $katao_node_id
-     * @return int
+     * @return float
      */
     public function getTotalDeliveredQuantity($katao_invoice_id = false, $katao_period_id, $katao_node_id) {
         $return = 0;

+ 1 - 1
lib/model/KataoUser.php

@@ -111,7 +111,7 @@ class KataoUser extends BaseKataoUser {
      * KataoUser::addProductToCart()
      *
      * @param integer $product_id
-     * @param integer $quantity
+     * @param float $quantity
      * @return
      */
     public function addProductToCart($product_id, $quantity = 1) {

+ 27 - 0
lib/symfony/lib/helper/FormHelper.php

@@ -379,6 +379,33 @@ function input_tag($name, $value = null, $options = array())
   return tag('input', array_merge(array('type' => 'text', 'name' => $name, 'id' => get_id_from_name($name, $value), 'value' => $value), _convert_options($options)));
 }
 
+
+/**
+ * Returns an XHTML compliant <input> tag with type="number".
+ *
+ * The input_tag helper generates your basic XHTML <input> tag and can utilize any standard <input> tag parameters 
+ * passed in the optional <i>$options</i> parameter.
+ *
+ * <b>Examples:</b>
+ * <code>
+ *  echo input_number_tag('name');
+ * </code>
+ *
+ * <code>
+ *  echo input_number_tag('amount', $sf_params->get('amount'), array('size' => 8, 'maxlength' => 8));
+ * </code>
+ *
+ * @param  string $name     field name 
+ * @param  string $value    selected field value
+ * @param  array  $options  additional HTML compliant <input> tag parameters
+ *
+ * @return string XHTML compliant <input> tag with type="text"
+ */
+function input_number_tag($name, $value = null, $options = array())
+{
+  return tag('input', array_merge(array('type' => 'number', 'name' => $name, 'id' => get_id_from_name($name, $value), 'value' => $value), _convert_options($options)));
+}
+
 /**
  * Returns an XHTML compliant <input> tag with type="hidden".
  *

+ 49 - 0
lib/symfony/lib/widget/sfWidgetFormInputNumber.class.php

@@ -0,0 +1,49 @@
+<?php
+
+/*
+ * Inspired by sfWidgetFormInput.class.php
+ */
+
+/**
+ * sfWidgetFormInput represents an HTML input number tag.
+ *
+ * @package    symfony
+ * @subpackage widget
+ * @author     Simon WIRTH
+ */
+class sfWidgetFormInputNumber extends sfWidgetForm
+{
+  /**
+   * Constructor.
+   *
+   * Available options:
+   *
+   *  * type: The widget type (text by default)
+   *
+   * @param array $options     An array of options
+   * @param array $attributes  An array of default HTML attributes
+   *
+   * @see sfWidgetForm
+   */
+  protected function configure($options = array(), $attributes = array())
+  {
+    $this->addOption('type', 'number');
+
+    $this->setOption('is_hidden', false);
+  }
+
+  /**
+   * @param  string $name        The element name
+   * @param  string $value       The value displayed in this widget
+   * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
+   * @param  array  $errors      An array of errors for the field
+   *
+   * @return string An HTML tag string
+   *
+   * @see sfWidgetForm
+   */
+  public function render($name, $value = null, $attributes = array(), $errors = array())
+  {
+    return $this->renderTag('input', array_merge(array('type' => $this->getOption('type'), 'name' => $name, 'value' => $value), $attributes));
+  }
+}

+ 14 - 0
plugins/catalyz/web/js/tiny_mce/plugins/imagemanager/js/mox/dom/layer.js

@@ -305,6 +305,20 @@ mox.require([
 			return parseInt(s);
 		},
 
+/**
+		 * Parses a float value this method will return 0 if the string is empty.
+		 *
+		 * @param {string} s String to parse value of.
+		 * @return Parsed number.
+		 * @type int
+		 */
+		parseFloat : function(s) {
+			if (s == null || s == '' || s == '0')
+				return 0;
+
+			return parseFloat(s);
+		},
+
 		/**
 		 * Removes the element for the layer from DOM and also the blocker iframe.
 		 */