// stock : debug + interfaces optimizations + stockManager update
This commit is contained in:
@@ -59,6 +59,8 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
'width' => 150,
|
||||
'orderby' => false,
|
||||
'search' => false,
|
||||
'type' => 'price',
|
||||
'currency' => true,
|
||||
),
|
||||
'physical_quantity' => array(
|
||||
'title' => $this->l('Physical quantity'),
|
||||
@@ -107,7 +109,8 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name,
|
||||
IFNULL(s.physical_quantity, 0) as physical_quantity,
|
||||
IFNULL(s.usable_quantity, 0) as usable_quantity,
|
||||
s.price_te
|
||||
s.price_te,
|
||||
w.id_currency as id_currency
|
||||
FROM '._DB_PREFIX_.'product_attribute a
|
||||
INNER JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = a.id_product AND pl.id_lang = '.$lang_id.')
|
||||
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_product_attribute = a.id_product_attribute)
|
||||
@@ -115,6 +118,7 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
LEFT JOIN '._DB_PREFIX_.'attribute_lang al ON (al.id_attribute = atr.id_attribute AND al.id_lang = '.$lang_id.')
|
||||
LEFT JOIN '._DB_PREFIX_.'attribute_group_lang agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$lang_id.')
|
||||
INNER JOIN '._DB_PREFIX_.'stock s ON (a.id_product_attribute = s.id_product_attribute)
|
||||
LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = s.id_warehouse)
|
||||
WHERE a.id_product = '.$id_product.
|
||||
($warehouse != -1 ? ' AND s.id_warehouse = '.(int)$warehouse : ' ').'
|
||||
GROUP BY a.id_product_attribute';
|
||||
@@ -124,13 +128,19 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
|
||||
// queries
|
||||
$datas = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
foreach ($datas as &$data) // retrieves real quantity for each product
|
||||
|
||||
foreach ($datas as &$data)
|
||||
{
|
||||
// retrieves real quantity for each product
|
||||
$data['real_quantity'] = $manager->getProductRealQuantities($data['id_product'],
|
||||
$data['id'],
|
||||
($warehouse == -1 ? null : array($warehouse)), // all or selected warehouse(s)
|
||||
true);
|
||||
|
||||
// display price correctly
|
||||
$data['price_te'] = Tools::displayPrice($data['price_te'], (int)$data['id_currency']);
|
||||
}
|
||||
|
||||
echo Tools::jsonEncode(array('data'=> $datas, 'fields_display' => $this->fieldsDisplay));
|
||||
}
|
||||
die;
|
||||
@@ -148,9 +158,13 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
COUNT(pa.id_product_attribute) as variations,
|
||||
s.physical_quantity as physical_quantity,
|
||||
s.usable_quantity as usable_quantity,
|
||||
s.price_te as price_te';
|
||||
s.price_te as price_te,
|
||||
w.id_currency as id_currency';
|
||||
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.id_product = a.id_product)
|
||||
INNER JOIN `'._DB_PREFIX_.'stock` s ON (s.id_product = a.id_product)';
|
||||
INNER JOIN `'._DB_PREFIX_.'stock` s ON (s.id_product = a.id_product)
|
||||
LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = s.id_warehouse)';
|
||||
|
||||
if ($this->getCurrentCoverageWarehouse() != -1)
|
||||
$this->_where .= ' AND s.id_warehouse = '.$this->getCurrentCoverageWarehouse();
|
||||
|
||||
|
||||
@@ -116,10 +116,10 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
switch ($this->display)
|
||||
{
|
||||
case 'addstock' :
|
||||
$this->fields_form = array(
|
||||
$this->fields_form[]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Add product to stock'),
|
||||
'image' => '../img/admin/arrow_up.png'
|
||||
'image' => '../img/admin/add_stock.png'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
@@ -252,10 +252,10 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
break;
|
||||
|
||||
case 'removestock' :
|
||||
$this->fields_form = array(
|
||||
$this->fields_form[]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Remove product from stock'),
|
||||
'image' => '../img/admin/arrow_down.png'
|
||||
'image' => '../img/admin/remove_stock.png'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
@@ -367,10 +367,10 @@ class AdminStockManagementControllerCore extends AdminController
|
||||
break;
|
||||
|
||||
case 'transferstock' :
|
||||
$this->fields_form = array(
|
||||
$this->fields_form[]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Transfert product from warehouse to another'),
|
||||
'image' => '../img/admin/arrow-right.png'
|
||||
'image' => '../img/admin/transfer_stock.png'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
|
||||
@@ -81,14 +81,32 @@ class AdminStockMvtControllerCore extends AdminController
|
||||
'cast' => 'intval',
|
||||
'type' => 'select',
|
||||
'list' => $reasons_inc,
|
||||
'identifier' => 'id_stock_mvt_reason'
|
||||
'identifier' => 'id_stock_mvt_reason',
|
||||
'visibility' => Shop::CONTEXT_ALL
|
||||
),
|
||||
'PS_STOCK_MVT_DEC_REASON_DEFAULT' => array(
|
||||
'title' => $this->l('Default reason when decrementing stock:'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'select',
|
||||
'list' => $reasons_dec,
|
||||
'identifier' => 'id_stock_mvt_reason'
|
||||
'identifier' => 'id_stock_mvt_reason',
|
||||
'visibility' => Shop::CONTEXT_ALL
|
||||
),
|
||||
'PS_STOCK_CUSTOMER_ORDER_REASON' => array(
|
||||
'title' => $this->l('Default reason when decrementing stock when a customer order is shipped:'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'select',
|
||||
'list' => $reasons_dec,
|
||||
'identifier' => 'id_stock_mvt_reason',
|
||||
'visibility' => Shop::CONTEXT_ALL
|
||||
),
|
||||
'PS_STOCK_MVT_SUPPLIER_ORDER' => array(
|
||||
'title' => $this->l('Default reason when incrementing stock when a supplier order is received:'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'select',
|
||||
'list' => $reasons_inc,
|
||||
'identifier' => 'id_stock_mvt_reason',
|
||||
'visibility' => Shop::CONTEXT_ALL
|
||||
),
|
||||
),
|
||||
'submit' => array(),
|
||||
@@ -175,7 +193,8 @@ class AdminStockMvtControllerCore extends AdminController
|
||||
*/
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
$this->addRowActionSkipList('delete', array(1, 2, 3, 4, 6, 7, 8));
|
||||
$this->addRowActionSkipList('edit', array(1, 2, 3, 4, 5, 6, 7, 8));
|
||||
$this->addRowActionSkipList('delete', array(1, 2, 3, 4, 5, 6, 7, 8));
|
||||
|
||||
$this->toolbar_title = $this->l('Stock : Stock movements reasons');
|
||||
$first_list = parent::initList();
|
||||
@@ -195,6 +214,7 @@ class AdminStockMvtControllerCore extends AdminController
|
||||
unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
|
||||
|
||||
// override table, land, className and identifier for the current controller
|
||||
$this->deleted = false;
|
||||
$this->table = 'stock_mvt';
|
||||
$this->className = 'StockMvt';
|
||||
$this->identifier = 'id_stock_mvt';
|
||||
@@ -305,8 +325,14 @@ class AdminStockMvtControllerCore extends AdminController
|
||||
// reset all query vars
|
||||
unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
|
||||
|
||||
// reset default table and className for options list management
|
||||
$this->table = 'stock_mvt_reason';
|
||||
$this->className = 'StockMvtReason';
|
||||
|
||||
// return the two lists
|
||||
return $second_list.$first_list;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,4 +353,17 @@ class AdminStockMvtControllerCore extends AdminController
|
||||
|
||||
return $warehouse;
|
||||
}
|
||||
|
||||
/**
|
||||
* AdminController::postProcess() override
|
||||
* @see AdminController::postProcess()
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
//when deleting a movement reason, enable deleted flag for parent postProcess and no remove the corresponding row from the database
|
||||
if (Tools::isSubmit('delete'.$this->table))
|
||||
$this->deleted = true;
|
||||
|
||||
return parent::postProcess();
|
||||
}
|
||||
}
|
||||
@@ -129,6 +129,15 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
else
|
||||
$this->_errors[] = Tools::displayError($this->l('You do not have permission to edit here.'));
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('update_receipt') && Tools::isSubmit('id_supplier_order'))
|
||||
{
|
||||
// change the display type in order to add specific actions to
|
||||
$this->display = 'update_receipt';
|
||||
|
||||
// display correct toolBar
|
||||
$this->initToolbar();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,11 +151,6 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
Tools::isSubmit('submitAddsupplier_order_state') ||
|
||||
Tools::isSubmit('submitUpdatesupplier_order_state'))
|
||||
{
|
||||
if (Tools::isSubmit('updatesupplier_order_state'))
|
||||
$this->toolbar_title = $this->l('Stock : Update Supplier order state');
|
||||
else
|
||||
$this->toolbar_title = $this->l('Stock : Add Supplier order state');
|
||||
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Supplier Order State'),
|
||||
@@ -263,6 +267,48 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
)
|
||||
);
|
||||
|
||||
if (Tools::isSubmit('addsupplier_order_state'))
|
||||
$this->toolbar_title = $this->l('Stock : Add Supplier order state');
|
||||
else
|
||||
{
|
||||
$this->toolbar_title = $this->l('Stock : Update Supplier order state');
|
||||
|
||||
$id_supplier_order_state = Tools::getValue('id_supplier_order_state', 0);
|
||||
|
||||
// only some fields are editable for initial states
|
||||
if (in_array($id_supplier_order_state, array(1, 2, 3, 4, 5, 6)))
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Supplier Order State'),
|
||||
'image' => '../img/admin/edit.gif'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'lang' => true,
|
||||
'attributeLang' => 'name',
|
||||
'label' => $this->l('Name:'),
|
||||
'name' => 'name',
|
||||
'size' => 50,
|
||||
'required' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'color',
|
||||
'label' => $this->l('Back office color:'),
|
||||
'name' => 'color',
|
||||
'size' => 20,
|
||||
'p' => $this->l('Back office background will be displayed in this color. HTML colors only (e.g.,').' "lightblue", "#CC6600")'
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::initForm();
|
||||
}
|
||||
|
||||
@@ -281,10 +327,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
$this->addJqueryUI('ui.datepicker');
|
||||
|
||||
//get warehouses list
|
||||
$warehouses = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT `id_warehouse`, CONCAT(`reference`, " - ", `name`) as name
|
||||
FROM `'._DB_PREFIX_.'warehouse`
|
||||
ORDER BY `reference` ASC');
|
||||
$warehouses = Warehouse::getWarehouseList(true);
|
||||
|
||||
//get currencies list
|
||||
$currencies = Currency::getCurrencies();
|
||||
@@ -421,7 +464,6 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
*/
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
$this->addRowActionSkipList('edit', array(1, 2, 3, 4, 5, 6));
|
||||
$this->addRowActionSkipList('delete', array(1, 2, 3, 4, 5, 6));
|
||||
|
||||
$this->toolbar_title = $this->l('Stock : Suppliers Orders States');
|
||||
@@ -482,7 +524,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
),
|
||||
'state' => array(
|
||||
'title' => $this->l('State'),
|
||||
'width' => 150,
|
||||
'width' => 250,
|
||||
'filter_key' => 'stl!name',
|
||||
'color' => 'color',
|
||||
),
|
||||
@@ -523,7 +565,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
$this->_select = '
|
||||
CONCAT(e.lastname, \' \', e.firstname) AS employee,
|
||||
s.name AS supplier,
|
||||
CONCAT(w.reference, \' \', w.name) AS warehouse,
|
||||
w.name AS warehouse,
|
||||
stl.name AS state,
|
||||
st.delivery_note,
|
||||
st.editable,
|
||||
@@ -588,10 +630,10 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
$this->getlanguages();
|
||||
|
||||
// defines the fields of the form to display
|
||||
$this->fields_form = array(
|
||||
$this->fields_form[]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Supplier Order State'),
|
||||
'image' => '../img/admin/edit.gif'
|
||||
'image' => '../img/admin/cms.gif'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
@@ -711,11 +753,6 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
*/
|
||||
public function initUpdateReceiptContent()
|
||||
{
|
||||
// change the display type in order to add specific actions to
|
||||
$this->display = 'update_receipt';
|
||||
// overrides parent::initContent();
|
||||
$this->initToolbar();
|
||||
|
||||
$id_supplier_order = (int)Tools::getValue('id_supplier_order', null);
|
||||
|
||||
// if there is no order to fetch
|
||||
@@ -797,13 +834,19 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
)
|
||||
);
|
||||
|
||||
// defines which table we are using
|
||||
// attributes override
|
||||
unset($this->_select, $this->_join, $this->_where, $this->_orderBy, $this->_orderWay, $this->_group, $this->_filterHaving, $this->_filter);
|
||||
$this->table = 'supplier_order_detail';
|
||||
$this->identifier = 'id_supplier_order_detail';
|
||||
$this->className = 'SupplierOrderDetail';
|
||||
// theme pruposes
|
||||
$this->colorOnBackground = false;
|
||||
$this->list_simple_header = true;
|
||||
$this->list_no_link = true;
|
||||
$this->bulk_actions = array('Update' => array('text' => $this->l('Update selected'), 'confirm' => $this->l('Update selected items?')));
|
||||
$this->addRowAction('details');
|
||||
|
||||
// sets toolbar title with order reference
|
||||
$this->toolbar_title = sprintf($this->l('Reception of products for supplier order #%s'), $supplier_order->reference);
|
||||
|
||||
// gets lang info
|
||||
$this->lang = false;
|
||||
$lang_id = (int)$this->context->language->id;
|
||||
@@ -828,27 +871,18 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
$this->_where = 'AND a.`id_supplier_order` = '.(int)$id_supplier_order;
|
||||
$this->_group = 'GROUP BY a.id_supplier_order_detail';
|
||||
|
||||
$this->addRowAction('details');
|
||||
|
||||
// gets the list ordered by price desc, without limit
|
||||
$this->getList($lang_id, 'quantity_expected', 'DESC', 0, false, false);
|
||||
|
||||
// defines action for POST
|
||||
$action = '&id_supplier_order='.$id_supplier_order.'&submitUpdateReceipt';
|
||||
|
||||
// renders list
|
||||
$helper = new HelperList();
|
||||
$this->setHelperDisplay($helper);
|
||||
$helper->override_folder = 'supplier_orders_receipt_history/';
|
||||
$helper->simple_header = true;
|
||||
$helper->actions = $this->actions;
|
||||
$helper->table = $this->table;
|
||||
$helper->no_link = true;
|
||||
$helper->show_toolbar = false;
|
||||
$helper->toolbar_fix = false;
|
||||
$helper->shopLinkType = '';
|
||||
//$helper->shopLinkType = '';
|
||||
$helper->currentIndex = self::$currentIndex.$action;
|
||||
$helper->token = $this->token;
|
||||
$helper->identifier = $this->identifier;
|
||||
$helper->bulk_actions = array('Update' => array('text' => $this->l('Update selected'), 'confirm' => $this->l('Update selected items?')));
|
||||
|
||||
// display these global order informations
|
||||
$this->displayInformation($this->l('This interface allows you to update the quantities of this on-going order.').'<br />');
|
||||
@@ -860,7 +894,6 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
// assigns var
|
||||
$this->context->smarty->assign(array(
|
||||
'content' => $content,
|
||||
'supplier_order_reference' => $supplier_order->reference
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1193,7 +1226,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
$warehouse,
|
||||
(int)$quantity,
|
||||
Configuration::get('PS_STOCK_MVT_SUPPLIER_ORDER'),
|
||||
$supplier_order_detail->price_te,
|
||||
$supplier_order_detail->unit_price_te,
|
||||
true,
|
||||
$supplier_order->id);
|
||||
if ($res) // if product has been added
|
||||
@@ -1410,6 +1443,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
$this->className = 'SupplierOrderDetail';
|
||||
$this->colorOnBackground = false;
|
||||
$this->lang = false;
|
||||
$this->list_simple_header = true;
|
||||
$this->list_no_link = true;
|
||||
$lang_id = (int)$this->context->language->id;
|
||||
|
||||
// gets the id supplier to view
|
||||
@@ -1453,7 +1488,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
$warehouse = new Warehouse($supplier_order->id_warehouse);
|
||||
|
||||
// sets toolbar title with order reference
|
||||
$this->toolbar_title = sprintf($this->l('View Supplier Order #%s'), $supplier_order->reference);
|
||||
$this->toolbar_title = sprintf($this->l('Details on supplier order #%s'), $supplier_order->reference);
|
||||
|
||||
// re-defines fieldsDisplay
|
||||
$this->fieldsDisplay = array(
|
||||
@@ -1486,8 +1521,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
'orderby' => false,
|
||||
'filter' => false,
|
||||
'search' => false,
|
||||
'prefix' => $currency->prefix,
|
||||
'suffix' => $currency->suffix,
|
||||
'type' => 'price',
|
||||
'currency' => true,
|
||||
),
|
||||
'quantity_expected' => array(
|
||||
'title' => $this->l('Quantity'),
|
||||
@@ -1504,8 +1539,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
'orderby' => false,
|
||||
'filter' => false,
|
||||
'search' => false,
|
||||
'prefix' => $currency->prefix,
|
||||
'suffix' => $currency->suffix,
|
||||
'type' => 'price',
|
||||
'currency' => true,
|
||||
),
|
||||
'discount_rate' => array(
|
||||
'title' => $this->l('Discount rate'),
|
||||
@@ -1523,8 +1558,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
'orderby' => false,
|
||||
'filter' => false,
|
||||
'search' => false,
|
||||
'prefix' => $currency->prefix,
|
||||
'suffix' => $currency->suffix,
|
||||
'type' => 'price',
|
||||
'currency' => true,
|
||||
),
|
||||
'price_with_discount_te' => array(
|
||||
'title' => $this->l('Price with product discount (te)'),
|
||||
@@ -1533,8 +1568,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
'orderby' => false,
|
||||
'filter' => false,
|
||||
'search' => false,
|
||||
'prefix' => $currency->prefix,
|
||||
'suffix' => $currency->suffix,
|
||||
'type' => 'price',
|
||||
'currency' => true,
|
||||
),
|
||||
'tax_rate' => array(
|
||||
'title' => $this->l('Tax rate'),
|
||||
@@ -1552,8 +1587,8 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
'orderby' => false,
|
||||
'filter' => false,
|
||||
'search' => false,
|
||||
'prefix' => $currency->prefix,
|
||||
'suffix' => $currency->suffix,
|
||||
'type' => 'price',
|
||||
'currency' => true,
|
||||
),
|
||||
'price_ti' => array(
|
||||
'title' => $this->l('Price (ti)'),
|
||||
@@ -1562,35 +1597,22 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
'orderby' => false,
|
||||
'filter' => false,
|
||||
'search' => false,
|
||||
'prefix' => $currency->prefix,
|
||||
'suffix' => $currency->suffix,
|
||||
'type' => 'price',
|
||||
'currency' => true,
|
||||
),
|
||||
);
|
||||
|
||||
//some staff before render list
|
||||
foreach ($this->_list as &$item)
|
||||
{
|
||||
$item['unit_price_te'] = Tools::ps_round($item['unit_price_te'], 2);
|
||||
$item['price_te'] = Tools::ps_round($item['price_te'], 2);
|
||||
$item['tax_value'] = Tools::ps_round($item['tax_value'], 2);
|
||||
$item['tax_value_with_order_discount'] = Tools::ps_round($item['tax_value_with_order_discount'], 2);
|
||||
$item['price_ti'] = Tools::ps_round($item['price_ti'], 2);
|
||||
$item['price_with_discount_te'] = Tools::ps_round($item['price_with_discount_te'], 2);
|
||||
$item['price_with_order_discount_te'] = Tools::ps_round($item['price_with_order_discount_te'], 2);
|
||||
$item['discount_value_te'] = Tools::ps_round($item['discount_value_te'], 2);
|
||||
|
||||
$item['discount_rate'] = Tools::ps_round($item['discount_rate'], 4);
|
||||
$item['tax_rate'] = Tools::ps_round($item['tax_rate'], 4);
|
||||
}
|
||||
|
||||
// renders list
|
||||
$helper = new HelperList();
|
||||
$helper->simple_header = true;
|
||||
$helper->no_link = true;
|
||||
$this->setHelperDisplay($helper);
|
||||
$helper->show_toolbar = false;
|
||||
$helper->toolbar_fix = false;
|
||||
$helper->shopLinkType = '';
|
||||
$helper->identifier = $this->identifier;
|
||||
|
||||
$content = $helper->generateList($this->_list, $this->fieldsDisplay);
|
||||
|
||||
@@ -1604,11 +1626,11 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
'supplier_order_last_update' => Tools::displayDate($supplier_order->date_upd, $lang_id, true),
|
||||
'supplier_order_expected' => Tools::displayDate($supplier_order->date_delivery_expected, $lang_id, true),
|
||||
'supplier_order_discount_rate' => Tools::ps_round($supplier_order->discount_rate, 2),
|
||||
'supplier_order_total_te' => Tools::ps_round($supplier_order->total_te, 2),
|
||||
'supplier_order_discount_value_te' => Tools::ps_round($supplier_order->discount_value_te, 2),
|
||||
'supplier_order_total_with_discount_te' => Tools::ps_round($supplier_order->total_with_discount_te, 2),
|
||||
'supplier_order_total_tax' => Tools::ps_round($supplier_order->total_tax, 2),
|
||||
'supplier_order_total_ti' => Tools::ps_round($supplier_order->total_ti, 2),
|
||||
'supplier_order_total_te' => Tools::displayPrice($supplier_order->total_te, $currency),
|
||||
'supplier_order_discount_value_te' => Tools::displayPrice($supplier_order->discount_value_te, $currency),
|
||||
'supplier_order_total_with_discount_te' => Tools::displayPrice($supplier_order->total_with_discount_te, $currency),
|
||||
'supplier_order_total_tax' => Tools::displayPrice($supplier_order->total_tax, $currency),
|
||||
'supplier_order_total_ti' => Tools::displayPrice($supplier_order->total_ti, $currency),
|
||||
'supplier_order_currency' => $currency,
|
||||
);
|
||||
}
|
||||
@@ -1658,6 +1680,7 @@ class AdminSupplierOrdersControllerCore extends AdminController
|
||||
'desc' => $this->l('Save')
|
||||
);
|
||||
|
||||
case 'update_receipt':
|
||||
// Default cancel button - like old back link
|
||||
if (!isset($this->no_back) || $this->no_back == false)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,9 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
$this->table = 'warehouse';
|
||||
$this->className = 'Warehouse';
|
||||
$this->context = Context::getContext();
|
||||
$this->deleted = true;
|
||||
$this->lang = false;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'reference' => array(
|
||||
'title' => $this->l('Reference'),
|
||||
@@ -89,6 +91,7 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
// adds actions on rows
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('view');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
// query: select
|
||||
$this->_select = '
|
||||
@@ -123,6 +126,10 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
*/
|
||||
public function initForm()
|
||||
{
|
||||
// loads current warehouse
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
|
||||
// gets the manager of the warehouse
|
||||
$query = new DbQuery();
|
||||
$query->select('id_employee, CONCAT(lastname," ",firstname) as name');
|
||||
@@ -137,7 +144,7 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Warehouse management'),
|
||||
'image' => '../img/admin/tab.gif'
|
||||
'image' => '../img/admin/edit.gif'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
@@ -234,44 +241,6 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Management type:'),
|
||||
'name' => 'management_type',
|
||||
'required' => true,
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'WA',
|
||||
'name' => $this->l('Weight Average')
|
||||
),
|
||||
array(
|
||||
'id' => 'FIFO',
|
||||
'name' => $this->l('First In, First Out')
|
||||
),
|
||||
array(
|
||||
'id' => 'LIFO',
|
||||
'name' => $this->l('Last In, First Out')
|
||||
),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'p' => $this->l('Inventory valuation method'),
|
||||
'hint' => $this->l('Do not change this value before the end of the accounting period for this warehouse.'),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Stock valuation currency:'),
|
||||
'name' => 'id_currency',
|
||||
'required' => true,
|
||||
'options' => array(
|
||||
'query' => Currency::getCurrencies(),
|
||||
'id' => 'id_currency',
|
||||
'name' => 'name'
|
||||
),
|
||||
'hint' => $this->l('Do not change this value before the end of the accounting period for this warehouse.'),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Associated shops:'),
|
||||
@@ -295,22 +264,72 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
'multiple' => true,
|
||||
'options' => array(
|
||||
'query' => Carrier::getCarriers($this->context->language->id, true),
|
||||
'id' => 'id_carrier',
|
||||
'id' => 'id_reference',
|
||||
'name' => 'name'
|
||||
),
|
||||
'p' => $this->l('Associated carriers'),
|
||||
'hint' => $this->l('You can specifiy the carriers available to ship orders from this warehouse'),
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button'
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
// loads current warehouse
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
// It is not possible to change currency valuation and management type
|
||||
if (Tools::isSubmit('addwarehouse'))
|
||||
{
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Management type:'),
|
||||
'name' => 'management_type',
|
||||
'required' => true,
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'WA',
|
||||
'name' => $this->l('Weight Average')
|
||||
),
|
||||
array(
|
||||
'id' => 'FIFO',
|
||||
'name' => $this->l('First In, First Out')
|
||||
),
|
||||
array(
|
||||
'id' => 'LIFO',
|
||||
'name' => $this->l('Last In, First Out')
|
||||
),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'p' => $this->l('Inventory valuation method')
|
||||
);
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Stock valuation currency:'),
|
||||
'name' => 'id_currency',
|
||||
'required' => true,
|
||||
'options' => array(
|
||||
'query' => Currency::getCurrencies(),
|
||||
'id' => 'id_currency',
|
||||
'name' => 'name'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'management_type'
|
||||
);
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'id_currency'
|
||||
);
|
||||
}
|
||||
|
||||
$this->fields_form['submit'] = array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button'
|
||||
);
|
||||
|
||||
// loads current address for this warehouse - if possible
|
||||
$address = null;
|
||||
@@ -405,9 +424,19 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
$_POST['id_address'] = $address->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parent::postProcess();
|
||||
// hack for enable the possibility to update a warehouse without recreate new id
|
||||
$this->deleted = false;
|
||||
|
||||
return parent::postProcess();
|
||||
}
|
||||
else if (Tools::isSubmit('delete'.$this->table))
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
else if ($obj->getQuantitiesOfProducts() > 0)
|
||||
$this->_errors[] = $this->l('It is not possible to delete a Warehosue when there are products in it.');
|
||||
else
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user