// Improved SupplyOrders : states & history of reception
This commit is contained in:
+12
@@ -28,6 +28,18 @@
|
||||
{block name="other_input"}
|
||||
|
||||
{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}">
|
||||
<label>{l s='Status of the order:'}</label>
|
||||
|
||||
|
||||
@@ -165,6 +165,7 @@ class SupplyOrderStateCore extends ObjectModel
|
||||
if ($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);
|
||||
}
|
||||
|
||||
|
||||
@@ -535,25 +535,17 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
// overrides parent::initContent();
|
||||
$this->initToolbar();
|
||||
|
||||
// given the current state, loads available states
|
||||
$states = SupplyOrderState::getSupplyOrderStates($supply_order->id_supply_order_state);
|
||||
$states = SupplyOrderState::getStates();
|
||||
$allowed_states = SupplyOrderState::getSupplyOrderStates($supply_order->id_supply_order_state);
|
||||
|
||||
// gets the state that are not allowed
|
||||
$allowed_states = array();
|
||||
foreach ($states as &$state)
|
||||
{
|
||||
$allowed_states[] = $state['id_supply_order_state'];
|
||||
$state['allowed'] = 1;
|
||||
}
|
||||
$not_allowed_states = SupplyOrderState::getStates($allowed_states);
|
||||
|
||||
// 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;
|
||||
$state['allowed'] = 0;
|
||||
foreach ($allowed_states as $allowed_state)
|
||||
{
|
||||
if ($state['id_supply_order_state'] == $allowed_state['id_supply_order_state'])
|
||||
$state['allowed'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// loads languages
|
||||
@@ -808,6 +800,10 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
|
||||
$helper->currentIndex = self::$currentIndex.$action;
|
||||
|
||||
$helper->ajax_params = array(
|
||||
'display_product_history' => 1,
|
||||
);
|
||||
|
||||
// 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('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()
|
||||
{
|
||||
// tests if an id is submit
|
||||
if (Tools::isSubmit('id'))
|
||||
if (Tools::isSubmit('id') && !Tools::isSubmit('display_product_history'))
|
||||
{
|
||||
// overrides attributes
|
||||
$this->identifier = 'id_supply_order_history';
|
||||
@@ -1525,14 +1521,14 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
|
||||
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->table = 'supply_order_receipt_history';
|
||||
$this->display = 'list';
|
||||
$this->lang = false;
|
||||
$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);
|
||||
$this->fieldsDisplay = array(
|
||||
|
||||
Reference in New Issue
Block a user