diff --git a/admin-dev/themes/template/helper/form/form.tpl b/admin-dev/themes/template/helper/form/form.tpl index 3ed7d63d3..452950f5d 100644 --- a/admin-dev/themes/template/helper/form/form.tpl +++ b/admin-dev/themes/template/helper/form/form.tpl @@ -75,11 +75,12 @@ {/block} -
{block name="leadin"}{/block}
{/if} +
{block name="leadin"}{/block}
+ {if isset($fields.title)}

{$fields.title}

{/if}
{if $form_id} diff --git a/admin-dev/themes/template/supplier_orders/form.tpl b/admin-dev/themes/template/supplier_orders/form.tpl index 0d79fcfc2..311cfbf5f 100644 --- a/admin-dev/themes/template/supplier_orders/form.tpl +++ b/admin-dev/themes/template/supplier_orders/form.tpl @@ -39,7 +39,7 @@

{l s='To add a product to the order, type the first letters of the product name, then select the it from the drop-down list:'}

- + {l s='Add a product to the supplier order'}

 

@@ -83,16 +83,16 @@ - + {$currency->prefix}  {$currency->suffix} - + - + % - + % @@ -132,10 +132,10 @@ ''+product_infos.reference+''+ ''+product_infos.ean13+''+ ''+product_infos.name+''+ - ''+ + '{$currency->prefix}  {$currency->suffix}'+ ''+ - ''+ - ''+ + '%'+ + '%'+ ''+ '{l s='+ '' diff --git a/admin-dev/themes/template/toolbar.tpl b/admin-dev/themes/template/toolbar.tpl index 4237bab7b..04b5714ab 100644 --- a/admin-dev/themes/template/toolbar.tpl +++ b/admin-dev/themes/template/toolbar.tpl @@ -40,6 +40,9 @@ //get reference on save link btn_save = $('span[class~="process-icon-save"]').parent(); + //get reference on save and stay link + btn_save_and_stay = $('span[class~="process-icon-save-and-stay"]').parent(); + //get reference on form submit button btn_submit = $('#{$table}_form_submit_btn'); @@ -49,8 +52,14 @@ //override save link label with submit button value lbl_save.html(btn_submit.attr("value")); - //add hidden input to emulate submit button click when posting the form -> field name posted - btn_submit.before(''); + if (btn_save_and_stay) + { + //get reference on current save link label + lbl_save_and_stay = $('#desc-{$table}-save-and-stay div'); + + //override save and stay link label with submit button value + lbl_save_and_stay.html(btn_submit.attr("value") + ' and stay'); + } //hide standard submit button btn_submit.hide(); @@ -58,8 +67,21 @@ //submit the form {block name=formSubmit} btn_save.click(function() { + //add hidden input to emulate submit button click when posting the form -> field name posted + btn_submit.before(''); + $('#{$table}_form').submit(); }); + + if (btn_save_and_stay) + { + btn_save_and_stay.click(function() { + //add hidden input to emulate submit button click when posting the form -> field name posted + btn_submit.before(''); + + $('#{$table}_form').submit(); + }); + } {/block} }); diff --git a/classes/stock/StockAvailable.php b/classes/stock/StockAvailable.php index 37532a6d0..228eb0bfe 100644 --- a/classes/stock/StockAvailable.php +++ b/classes/stock/StockAvailable.php @@ -263,17 +263,17 @@ class StockAvailableCore extends ObjectModel WHERE id_stock_available = '.(int)$id_stock_available); } } - + /** * For a given id_product and id_product_attribute update the quantity available */ public static function updateQuantity($id_product, $id_product_attribute, $delta_quantity, $id_shop = null) { $id_stock = self::getIdStockAvailable($id_product, $id_product_attribute, $id_shop); - + if (!$id_stock) return false; - + // Update quantity of the pack products if (Pack::isPack($id_product)) { @@ -284,7 +284,7 @@ class StockAvailableCore extends ObjectModel self::updateQuantity($product_pack->id, $pack_id_product_attribute, $product_pack->pack_quantity * $delta_quantity, $id_shop); } } - + $stock_available = new StockAvailable($id_stock); $stock_available->quantity = $stock_available->quantity + $delta_quantity; $stock_available->save(); diff --git a/classes/stock/SupplierOrder.php b/classes/stock/SupplierOrder.php index 907e80c64..e72c73898 100755 --- a/classes/stock/SupplierOrder.php +++ b/classes/stock/SupplierOrder.php @@ -365,4 +365,15 @@ class SupplierOrderCore extends ObjectModel $history->save(); } + + /** + * Remove all products in the order + */ + public function resetProducts() + { + $products = $this->getEntriesCollection(); + + foreach ($products as $p) + $p->delete(); + } } \ No newline at end of file diff --git a/controllers/admin/AdminStockCoverController.php b/controllers/admin/AdminStockCoverController.php index a60a7c7e7..5aece0692 100644 --- a/controllers/admin/AdminStockCoverController.php +++ b/controllers/admin/AdminStockCoverController.php @@ -175,12 +175,19 @@ class AdminStockCoverControllerCore extends AdminController if ((int)$item['variations'] <= 0) { if ($this->getCurrentCoverageWarehouse() == -1) // if all warehouses - $item['coverage'] = StockManagerFactory::getManager()->getProductCoverage($item['id'], 0, $this->getCurrentCoveragePeriod()); + $item['coverage'] = StockManagerFactory::getManager()->getProductCoverage( + $item['id'], + 0, + $this->getCurrentCoveragePeriod() + ); else // else selected warehouse - $item['coverage'] = StockManagerFactory::getManager()->getProductCoverage($item['id'], - 0, - $this->getCurrentCoveragePeriod(), - $this->getCurrentCoverageWarehouse()); + $item['coverage'] = StockManagerFactory::getManager()->getProductCoverage( + $item['id'], + 0, + $this->getCurrentCoveragePeriod(), + $this->getCurrentCoverageWarehouse() + ); + // removes 'details' action on products without attributes $this->addRowActionSkipList('details', array($item['id'])); } @@ -227,4 +234,4 @@ class AdminStockCoverControllerCore extends AdminController } return $warehouse; } -} \ No newline at end of file +} diff --git a/controllers/admin/AdminSupplierOrdersController.php b/controllers/admin/AdminSupplierOrdersController.php index 4cf3e249c..9b3e217e4 100644 --- a/controllers/admin/AdminSupplierOrdersController.php +++ b/controllers/admin/AdminSupplierOrdersController.php @@ -350,7 +350,7 @@ class AdminSupplierOrdersControllerCore extends AdminController 'type' => 'text', 'label' => $this->l('Global discount rate:'), 'name' => 'discount_rate', - 'size' => 5, + 'size' => 7, 'required' => true, 'p' => $this->l('This is the global discount rate for the order.'), ), @@ -648,6 +648,7 @@ class AdminSupplierOrdersControllerCore extends AdminController if ($id_supplier_order != null) { $supplier_order = new SupplierOrder($id_supplier_order); + $currency = new Currency($supplier_order->id_currency); if (Validate::isLoadedObject($supplier_order)) { @@ -671,6 +672,7 @@ class AdminSupplierOrdersControllerCore extends AdminController { // calculate md5 checksum on each product for use in tpl $item['checksum'] = md5(_COOKIE_KEY_.$item['id_product'].'_'.$item['id_product_attribute']); + $item['unit_price_te'] = Tools::ps_round($item['unit_price_te'], (int)$currency->decimals + 1); // add id to ids list $product_ids[] = $item['id_product'].'_'.$item['id_product_attribute']; @@ -679,6 +681,7 @@ class AdminSupplierOrdersControllerCore extends AdminController $this->tpl_form_vars['products_list'] = $products; $this->tpl_form_vars['product_ids'] = implode($product_ids, '|'); $this->tpl_form_vars['supplier_id'] = $supplier_order->id_supplier; + $this->tpl_form_vars['currency'] = $currency; } } @@ -932,10 +935,10 @@ class AdminSupplierOrdersControllerCore extends AdminController // get product informations $entry->id_product = substr($id, 0, $pos); $entry->id_product_attribute = substr($id, $pos + 1); - $entry->unit_price_te = (float)Tools::getValue('input_unit_price_te_'.$id, 0); - $entry->quantity_expected = (int)Tools::getValue('input_quantity_expected_'.$id, 0); - $entry->discount_rate = (float)Tools::getValue('input_discount_rate_'.$id, 0); - $entry->tax_rate = (float)Tools::getValue('input_tax_rate_'.$id, 0); + $entry->unit_price_te = (float)str_replace(array(' ', ','), array('', '.'), Tools::getValue('input_unit_price_te_'.$id, 0)); + $entry->quantity_expected = (int)str_replace(array(' ', ','), array('', '.'), Tools::getValue('input_quantity_expected_'.$id, 0)); + $entry->discount_rate = (float)str_replace(array(' ', ','), array('', '.'), Tools::getValue('input_discount_rate_'.$id, 0)); + $entry->tax_rate = (float)str_replace(array(' ', ','), array('', '.'), Tools::getValue('input_tax_rate_'.$id, 0)); $entry->reference = Tools::getValue('input_reference_'.$id, ''); $entry->ean13 = Tools::getValue('input_ean13_'.$id, ''); $entry->name = Tools::getValue('input_name_'.$id, ''); @@ -1145,7 +1148,6 @@ class AdminSupplierOrdersControllerCore extends AdminController // updates quantity received $supplier_order_detail->quantity_received += (int)$quantity; - // if current state is "Pending receipt", then we sets it to "Order received in part" if (3 == $supplier_order->id_supplier_order_state) $supplier_order->id_supplier_order_state = 4; @@ -1626,8 +1628,15 @@ class AdminSupplierOrdersControllerCore extends AdminController 'desc' => $this->l('Save') ); break; + + case 'edit': + $this->toolbar_btn['save-and-stay'] = array( + 'href' => '#', + 'desc' => $this->l('Save and stay') + ); + default: parent::initToolbar(); } } -} +} \ No newline at end of file