// stock : bugs fix and update of supplier order add product interface

This commit is contained in:
dSevere committed 2011-11-08 15:45:45 +00:00
1 parent 63c2159a98
commit 4812e7baf4
6 files changed
+72 -22

No files matched your search

@@ -75,11 +75,12 @@
{/block} {/block}
</h3> </h3>
</div> </div>
<div class="leadin">{block name="leadin"}{/block}</div>
</div> </div>
</div> </div>
{/if} {/if}
<div class="leadin">{block name="leadin"}{/block}</div>
{if isset($fields.title)}<h2>{$fields.title}</h2>{/if} {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"> <form id="{$table}_form" class="defaultForm" action="{$current}&{$submit_action}=1&token={$token}" method="post" enctype="multipart/form-data">
{if $form_id} {if $form_id}
@@ -39,7 +39,7 @@
</legend> </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> <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> <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>&nbsp;</p> <p>&nbsp;</p>
@@ -83,16 +83,16 @@
<input type="hidden" name="input_name_{$product.id_product}_{$product.id_product_attribute}" value="{$product.name}" /> <input type="hidden" name="input_name_{$product.id_product}_{$product.id_product_attribute}" value="{$product.name}" />
</td> </td>
<td class="center"> <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}&nbsp;<input type="text" name="input_unit_price_te_{$product.id_product}_{$product.id_product_attribute}" value="{$product.unit_price_te}" size="8" />&nbsp;{$currency->suffix}
</td> </td>
<td class="center"> <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>
<td class="center"> <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>
<td class="center"> <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>
<td class="center"> <td class="center">
<a href="#" id="deletelink|{$product.id_product}_{$product.id_product_attribute}" class="removeProductFromSupplierOrderLink"> <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.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.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>'+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}&nbsp;<input type="text" name="input_unit_price_te_'+product_infos.id+'" value="0" size="8" />&nbsp;{$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_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_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_tax_rate_'+product_infos.id+'" value="0" size="5" />%</td>'+
'<td class="center"><a href="#" class="removeProductFromSupplierOrderLink" id="deletelink|'+product_infos.id+'">'+ '<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"}" />'+ '<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>' '</a></td></tr>'
+24 -2
View File
@@ -40,6 +40,9 @@
//get reference on save link //get reference on save link
btn_save = $('span[class~="process-icon-save"]').parent(); 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 //get reference on form submit button
btn_submit = $('#{$table}_form_submit_btn'); btn_submit = $('#{$table}_form_submit_btn');
@@ -49,8 +52,14 @@
//override save link label with submit button value //override save link label with submit button value
lbl_save.html(btn_submit.attr("value")); lbl_save.html(btn_submit.attr("value"));
//add hidden input to emulate submit button click when posting the form -> field name posted if (btn_save_and_stay)
btn_submit.before('<input type="hidden" name="'+btn_submit.attr("name")+'" value="1" />'); {
//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 //hide standard submit button
btn_submit.hide(); btn_submit.hide();
@@ -58,8 +67,21 @@
//submit the form //submit the form
{block name=formSubmit} {block name=formSubmit}
btn_save.click(function() { 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(); $('#{$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} {/block}
}); });
</script> </script>
+11
View File
@@ -365,4 +365,15 @@ class SupplierOrderCore extends ObjectModel
$history->save(); $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 ((int)$item['variations'] <= 0)
{ {
if ($this->getCurrentCoverageWarehouse() == -1) // if all warehouses 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 else // else selected warehouse
$item['coverage'] = StockManagerFactory::getManager()->getProductCoverage($item['id'], $item['coverage'] = StockManagerFactory::getManager()->getProductCoverage(
0, $item['id'],
$this->getCurrentCoveragePeriod(), 0,
$this->getCurrentCoverageWarehouse()); $this->getCurrentCoveragePeriod(),
$this->getCurrentCoverageWarehouse()
);
// removes 'details' action on products without attributes // removes 'details' action on products without attributes
$this->addRowActionSkipList('details', array($item['id'])); $this->addRowActionSkipList('details', array($item['id']));
} }
@@ -350,7 +350,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
'type' => 'text', 'type' => 'text',
'label' => $this->l('Global discount rate:'), 'label' => $this->l('Global discount rate:'),
'name' => 'discount_rate', 'name' => 'discount_rate',
'size' => 5, 'size' => 7,
'required' => true, 'required' => true,
'p' => $this->l('This is the global discount rate for the order.'), '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) if ($id_supplier_order != null)
{ {
$supplier_order = new SupplierOrder($id_supplier_order); $supplier_order = new SupplierOrder($id_supplier_order);
$currency = new Currency($supplier_order->id_currency);
if (Validate::isLoadedObject($supplier_order)) if (Validate::isLoadedObject($supplier_order))
{ {
@@ -671,6 +672,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
{ {
// calculate md5 checksum on each product for use in tpl // calculate md5 checksum on each product for use in tpl
$item['checksum'] = md5(_COOKIE_KEY_.$item['id_product'].'_'.$item['id_product_attribute']); $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 // add id to ids list
$product_ids[] = $item['id_product'].'_'.$item['id_product_attribute']; $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['products_list'] = $products;
$this->tpl_form_vars['product_ids'] = implode($product_ids, '|'); $this->tpl_form_vars['product_ids'] = implode($product_ids, '|');
$this->tpl_form_vars['supplier_id'] = $supplier_order->id_supplier; $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 // get product informations
$entry->id_product = substr($id, 0, $pos); $entry->id_product = substr($id, 0, $pos);
$entry->id_product_attribute = substr($id, $pos + 1); $entry->id_product_attribute = substr($id, $pos + 1);
$entry->unit_price_te = (float)Tools::getValue('input_unit_price_te_'.$id, 0); $entry->unit_price_te = (float)str_replace(array(' ', ','), array('', '.'), Tools::getValue('input_unit_price_te_'.$id, 0));
$entry->quantity_expected = (int)Tools::getValue('input_quantity_expected_'.$id, 0); $entry->quantity_expected = (int)str_replace(array(' ', ','), array('', '.'), Tools::getValue('input_quantity_expected_'.$id, 0));
$entry->discount_rate = (float)Tools::getValue('input_discount_rate_'.$id, 0); $entry->discount_rate = (float)str_replace(array(' ', ','), array('', '.'), Tools::getValue('input_discount_rate_'.$id, 0));
$entry->tax_rate = (float)Tools::getValue('input_tax_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->reference = Tools::getValue('input_reference_'.$id, '');
$entry->ean13 = Tools::getValue('input_ean13_'.$id, ''); $entry->ean13 = Tools::getValue('input_ean13_'.$id, '');
$entry->name = Tools::getValue('input_name_'.$id, ''); $entry->name = Tools::getValue('input_name_'.$id, '');
@@ -1145,7 +1148,6 @@ class AdminSupplierOrdersControllerCore extends AdminController
// updates quantity received // updates quantity received
$supplier_order_detail->quantity_received += (int)$quantity; $supplier_order_detail->quantity_received += (int)$quantity;
// if current state is "Pending receipt", then we sets it to "Order received in part" // if current state is "Pending receipt", then we sets it to "Order received in part"
if (3 == $supplier_order->id_supplier_order_state) if (3 == $supplier_order->id_supplier_order_state)
$supplier_order->id_supplier_order_state = 4; $supplier_order->id_supplier_order_state = 4;
@@ -1626,6 +1628,13 @@ class AdminSupplierOrdersControllerCore extends AdminController
'desc' => $this->l('Save') 'desc' => $this->l('Save')
); );
break; break;
case 'edit':
$this->toolbar_btn['save-and-stay'] = array(
'href' => '#',
'desc' => $this->l('Save and stay')
);
default: default:
parent::initToolbar(); parent::initToolbar();
} }