// stock : bugs fix and update of supplier order add product interface
This commit is contained in:
@@ -75,11 +75,12 @@
|
||||
{/block}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="leadin">{block name="leadin"}{/block}</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="leadin">{block name="leadin"}{/block}</div>
|
||||
|
||||
{if isset($fields.title)}<h2>{$fields.title}</h2>{/if}
|
||||
<form id="{$table}_form" class="defaultForm" action="{$current}&{$submit_action}=1&token={$token}" method="post" enctype="multipart/form-data">
|
||||
{if $form_id}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</legend>
|
||||
|
||||
<p class="clear">{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:'}</p>
|
||||
<input type="text" size="75" id="cur_product_name" />
|
||||
<input type="text" size="100" id="cur_product_name" />
|
||||
<span onclick="addProduct();" style="cursor: pointer;"><img src="../img/admin/add.gif" alt="{l s='Add a product to the supplier order'}" title="{l s='Add a product to the supplier order'}" /></span>
|
||||
|
||||
<p> </p>
|
||||
@@ -83,16 +83,16 @@
|
||||
<input type="hidden" name="input_name_{$product.id_product}_{$product.id_product_attribute}" value="{$product.name}" />
|
||||
</td>
|
||||
<td class="center">
|
||||
<input type="text" name="input_unit_price_te_{$product.id_product}_{$product.id_product_attribute}" value="{$product.unit_price_te|escape:'htmlall':'UTF-8'}" size="8" />
|
||||
{$currency->prefix} <input type="text" name="input_unit_price_te_{$product.id_product}_{$product.id_product_attribute}" value="{$product.unit_price_te}" size="8" /> {$currency->suffix}
|
||||
</td>
|
||||
<td class="center">
|
||||
<input type="text" name="input_quantity_expected_{$product.id_product}_{$product.id_product_attribute}" value="{$product.quantity_expected|escape:'htmlall':'UTF-8'}" size="5" />
|
||||
<input type="text" name="input_quantity_expected_{$product.id_product}_{$product.id_product_attribute}" value="{$product.quantity_expected}" size="5" />
|
||||
</td>
|
||||
<td class="center">
|
||||
<input type="text" name="input_discount_rate_{$product.id_product}_{$product.id_product_attribute}" value="{$product.discount_rate|escape:'htmlall':'UTF-8'}" size="5" />
|
||||
<input type="text" name="input_discount_rate_{$product.id_product}_{$product.id_product_attribute}" value="{round($product.discount_rate, 2)}" size="5" />%
|
||||
</td>
|
||||
<td class="center">
|
||||
<input type="text" name="input_tax_rate_{$product.id_product}_{$product.id_product_attribute}" value="{$product.tax_rate|escape:'htmlall':'UTF-8'}" size="5" />
|
||||
<input type="text" name="input_tax_rate_{$product.id_product}_{$product.id_product_attribute}" value="{round($product.tax_rate, 2)}" size="5" />%
|
||||
</td>
|
||||
<td class="center">
|
||||
<a href="#" id="deletelink|{$product.id_product}_{$product.id_product_attribute}" class="removeProductFromSupplierOrderLink">
|
||||
@@ -132,10 +132,10 @@
|
||||
'<td>'+product_infos.reference+'<input type="hidden" name="input_check_'+product_infos.id+'" value="'+product_infos.checksum+'" /><input type="hidden" name="input_name_'+product_infos.id+'" value="'+product_infos.reference+'" /></td>'+
|
||||
'<td>'+product_infos.ean13+'<input type="hidden" name="input_ean13_'+product_infos.id+'" value="'+product_infos.ean13+'" /></td>'+
|
||||
'<td>'+product_infos.name+'<input type="hidden" name="input_name_'+product_infos.id+'" value="'+product_infos.name+'" /></td>'+
|
||||
'<td class="center"><input type="text" name="input_unit_price_te_'+product_infos.id+'" value="0" size="8" /></td>'+
|
||||
'<td class="center">{$currency->prefix} <input type="text" name="input_unit_price_te_'+product_infos.id+'" value="0" size="8" /> {$currency->suffix}</td>'+
|
||||
'<td class="center"><input type="text" name="input_quantity_expected_'+product_infos.id+'" value="0" size="5" /></td>'+
|
||||
'<td class="center"><input type="text" name="input_discount_rate_'+product_infos.id+'" value="0" size="5" /></td>'+
|
||||
'<td class="center"><input type="text" name="input_tax_rate_'+product_infos.id+'" value="0" size="5" /></td>'+
|
||||
'<td class="center"><input type="text" name="input_discount_rate_'+product_infos.id+'" value="0" size="5" />%</td>'+
|
||||
'<td class="center"><input type="text" name="input_tax_rate_'+product_infos.id+'" value="0" size="5" />%</td>'+
|
||||
'<td class="center"><a href="#" class="removeProductFromSupplierOrderLink" id="deletelink|'+product_infos.id+'">'+
|
||||
'<img src="../img/admin/delete.gif" alt="{l s="Remove this product from the order"}" title="{l s="Remove this product from the order"}" />'+
|
||||
'</a></td></tr>'
|
||||
|
||||
@@ -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('<input type="hidden" name="'+btn_submit.attr("name")+'" value="1" />');
|
||||
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('<input type="hidden" name="'+btn_submit.attr("name")+'" value="1" />');
|
||||
|
||||
$('#{$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('<input type="hidden" name="'+btn_submit.attr("name")+'AndStay" value="1" />');
|
||||
|
||||
$('#{$table}_form').submit();
|
||||
});
|
||||
}
|
||||
{/block}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user