// Improved SupplyOrders : states & history of reception

This commit is contained in:
bMancone
2012-02-22 16:49:54 +00:00
parent 0349bfb04b
commit 2c45847fa7
3 changed files with 28 additions and 19 deletions
@@ -28,6 +28,18 @@
{block name="other_input"} {block name="other_input"}
{if isset($supply_order) && $supply_order->id > 0 && isset($supply_order_states)} {if isset($supply_order) && $supply_order->id > 0 && isset($supply_order_states)}
<script>
$(document).ready(function() {
$('#id_supply_order_state option').each(function () {
if ($(this).attr('disabled') == false)
$(this).attr('selected', true);
return ($(this).attr('disabled') == true);
});
});
</script>
<input type="hidden" name="id_supply_order" id="id_supply_order" value="{$supply_order->id}"> <input type="hidden" name="id_supply_order" id="id_supply_order" value="{$supply_order->id}">
<label>{l s='Status of the order:'}</label> <label>{l s='Status of the order:'}</label>
+1
View File
@@ -165,6 +165,7 @@ class SupplyOrderStateCore extends ObjectModel
if ($ids) if ($ids)
$query->where('s.id_supply_order_state NOT IN('.implode(',', array_map('intval', $ids)).')'); $query->where('s.id_supply_order_state NOT IN('.implode(',', array_map('intval', $ids)).')');
$query->orderBy('sl.name ASC');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
} }
@@ -535,25 +535,17 @@ class AdminSupplyOrdersControllerCore extends AdminController
// overrides parent::initContent(); // overrides parent::initContent();
$this->initToolbar(); $this->initToolbar();
// given the current state, loads available states $states = SupplyOrderState::getStates();
$states = SupplyOrderState::getSupplyOrderStates($supply_order->id_supply_order_state); $allowed_states = SupplyOrderState::getSupplyOrderStates($supply_order->id_supply_order_state);
// gets the state that are not allowed
$allowed_states = array();
foreach ($states as &$state) foreach ($states as &$state)
{ {
$allowed_states[] = $state['id_supply_order_state']; $state['allowed'] = 0;
$state['allowed'] = 1; foreach ($allowed_states as $allowed_state)
} {
$not_allowed_states = SupplyOrderState::getStates($allowed_states); if ($state['id_supply_order_state'] == $allowed_state['id_supply_order_state'])
$state['allowed'] = 1;
// generates the final list of states }
$index = count($allowed_states);
foreach ($not_allowed_states as &$not_allowed_state)
{
$not_allowed_state['allowed'] = 0;
$states[$index] = $not_allowed_state;
++$index;
} }
// loads languages // loads languages
@@ -808,6 +800,10 @@ class AdminSupplyOrdersControllerCore extends AdminController
$helper->currentIndex = self::$currentIndex.$action; $helper->currentIndex = self::$currentIndex.$action;
$helper->ajax_params = array(
'display_product_history' => 1,
);
// display these global order informations // display these global order informations
$this->displayInformation($this->l('This interface allows you to update the quantities of this on-going order.').'<br />'); $this->displayInformation($this->l('This interface allows you to update the quantities of this on-going order.').'<br />');
$this->displayInformation($this->l('Be careful : once you update, you cannot go back unless you add new negative stock movements.').'<br />'); $this->displayInformation($this->l('Be careful : once you update, you cannot go back unless you add new negative stock movements.').'<br />');
@@ -1452,7 +1448,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
public function ajaxProcess() public function ajaxProcess()
{ {
// tests if an id is submit // tests if an id is submit
if (Tools::isSubmit('id')) if (Tools::isSubmit('id') && !Tools::isSubmit('display_product_history'))
{ {
// overrides attributes // overrides attributes
$this->identifier = 'id_supply_order_history'; $this->identifier = 'id_supply_order_history';
@@ -1525,14 +1521,14 @@ class AdminSupplyOrdersControllerCore extends AdminController
echo Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content)); echo Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content));
} }
else if (Tools::isSubmit('id_supply_order_detail')) else if (Tools::isSubmit('id') && Tools::isSubmit('display_product_history'))
{ {
$this->identifier = 'id_supply_order_receipt_history'; $this->identifier = 'id_supply_order_receipt_history';
$this->table = 'supply_order_receipt_history'; $this->table = 'supply_order_receipt_history';
$this->display = 'list'; $this->display = 'list';
$this->lang = false; $this->lang = false;
$lang_id = (int)$this->context->language->id; $lang_id = (int)$this->context->language->id;
$id_supply_order_detail = (int)Tools::getValue('id_supply_order_detail'); $id_supply_order_detail = (int)Tools::getValue('id');
unset($this->fieldsDisplay); unset($this->fieldsDisplay);
$this->fieldsDisplay = array( $this->fieldsDisplay = array(