// StockMvtReason : added getStockMvtReasonsWithFilter(). Controllers : updated

This commit is contained in:
bMancone
2011-10-25 14:27:21 +00:00
parent a987a0f970
commit 56a4db3947
6 changed files with 85 additions and 46 deletions
+27
View File
@@ -72,6 +72,33 @@ class StockMvtReasonCore extends ObjectModel
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
}
/**
* Same as StockMvtReason::getStockMvtReasons(), ignoring a specific lists of ids
*
* @since 1.5.0
* @param int $id_lang
* @param array $ids_ignore
* @param int $sign optional
*/
public static function getStockMvtReasonsWithFilter($id_lang, $ids_ignore, $sign = null)
{
$query = new DbQuery();
$query->select('smrl.name, smr.id_stock_mvt_reason, smr.sign');
$query->from('stock_mvt_reason smr');
$query->leftjoin('stock_mvt_reason_lang smrl ON (smr.id_stock_mvt_reason = smrl.id_stock_mvt_reason AND smrl.id_lang='.(int)$id_lang.')');
if ($sign != null)
$query->where('smr.sign = '.(int)$sign);
if (count($ids_ignore))
{
$ids_ignore = array_map('intval', $ids_ignore);
$query->where('smr.id_stock_mvt_reason NOT IN('.implode(', ', $ids_ignore).')');
}
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
}
/**
* @since 1.5.0
*
@@ -158,7 +158,7 @@ class AdminStockCoverControllerCore extends AdminController
$this->displayInformation(
$this->l('Considering the coverage period choosen and the quantity of products/combinations that you sold,
this interface gives you an idea of when one product will run out of stock .'
this interface gives you an idea of when one product will run out of stock.'
)
);
@@ -94,6 +94,8 @@ class AdminStockInstantStateControllerCore extends AdminController
*/
public function initList()
{
$this->displayInformation($this->l('This interface allows you to display detailed informations on your stock, per warehouse.').'<br />');
$this->addRowAction('details');
//no link on list rows
@@ -246,7 +248,7 @@ class AdminStockInstantStateControllerCore extends AdminController
$this->_list = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
$this->_listTotal = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()');
$manager = StockManagerFactory::getManager();
foreach ($this->_list as &$row)
@@ -69,11 +69,11 @@ class AdminStockManagementControllerCore extends AdminController
parent::__construct();
// Override confirmation messages specifically for this controller
// overrides confirmation messages specifically for this controller
$this->_conf = array(
1 => $this->l('The product was successfully added to stock'),
2 => $this->l('The product was properly removed from the stock'),
3 => $this->l('The transfer was done properly'),
2 => $this->l('The product was successfully removed from the stock'),
3 => $this->l('The transfer was successfully done'),
);
}
@@ -88,19 +88,16 @@ class AdminStockManagementControllerCore extends AdminController
$this->addRowAction('removestock');
$this->addRowAction('transferstock');
//no link on list rows
// no link on list rows
$this->list_no_link = true;
$this->_select = 'a.id_product as id, COUNT(pa.id_product_attribute) as variations';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.id_product = a.id_product)';
$this->displayInformation(
$this->l('This interface allows you to manage the stocks of each of your products and their variations.
The quantities of each product are global, so includes all quantities of each warehouses.
You can add and delete products related to a given warehouse.
You can transfer products from a warehouse to another.'
)
);
$this->displayInformation($this->l('This interface allows you to manage the stocks of each of your products and their variations.').'<br />');
$this->displayInformation($this->l('Total quantities in stock represent the sum for all warehouses.').'<br />');
$this->displayInformation($this->l('Through this interface, you can add and delete products for a given warehouse.'));
$this->displayInformation($this->l('Also, you can transfer products between warehouses, or within one warehouse.'));
return parent::initList();
}
@@ -179,7 +176,7 @@ class AdminStockManagementControllerCore extends AdminController
'size' => 10,
'maxlength' => 6,
'required' => true,
'p' => $this->l('Physical quantity to add to the stock for this product')
'p' => $this->l('Physical quantity to add')
),
array(
'type' => 'radio',
@@ -200,7 +197,7 @@ class AdminStockManagementControllerCore extends AdminController
'label' => $this->l('Disabled')
)
),
'p' => $this->l('Is this quantity is usable for sale on shops, or reserved in the warehouse for other purpose ?:')
'p' => $this->l('Is this quantity usable for sale on shops, or reserved in the warehouse for other purposes?')
),
array(
'type' => 'select',
@@ -233,7 +230,7 @@ class AdminStockManagementControllerCore extends AdminController
'id' => 'id_currency',
'name' => 'name'
),
'p' => $this->l('The currency associated to the product unit price.'),
'p' => $this->l('The currency associated to the product unit price'),
),
array(
'type' => 'select',
@@ -241,11 +238,13 @@ class AdminStockManagementControllerCore extends AdminController
'name' => 'id_stock_mvt_reason',
'required' => true,
'options' => array(
'query' => StockMvtReason::getStockMvtReasons($this->context->language->id, 1),
'query' => StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id,
array(Configuration::get('PS_STOCK_MVT_TRANSFER_TO')),
1),
'id' => 'id_stock_mvt_reason',
'name' => 'name'
),
'p' => $this->l('Reason to add in stock movements'),
'p' => $this->l('Reason used in stock movements'),
),
),
'submit' => array(
@@ -313,11 +312,11 @@ class AdminStockManagementControllerCore extends AdminController
'size' => 10,
'maxlength' => 6,
'required' => true,
'p' => $this->l('Physical quantity to remove from the stock for this product')
'p' => $this->l('Physical quantity to remove')
),
array(
'type' => 'radio',
'label' => $this->l('Usable for sale?:'),
'label' => $this->l('Usable for sale:'),
'name' => 'usable',
'required' => true,
'class' => 't',
@@ -334,7 +333,7 @@ class AdminStockManagementControllerCore extends AdminController
'label' => $this->l('Disabled')
)
),
'p' => $this->l('Do you want to remove this quantity from usable quantity for sale on shops ?:')
'p' => $this->l('Do you want to remove this quantity from the usable quantity(yes) or the physical quantity(no)?')
),
array(
'type' => 'select',
@@ -354,11 +353,13 @@ class AdminStockManagementControllerCore extends AdminController
'name' => 'id_stock_mvt_reason',
'required' => true,
'options' => array(
'query' => StockMvtReason::getStockMvtReasons($this->context->language->id, -1),
'query' => StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id,
array(Configuration::get('PS_STOCK_MVT_TRANSFER_FROM')),
-1),
'id' => 'id_stock_mvt_reason',
'name' => 'name'
),
'p' => $this->l('Reason to add in stock movements'),
'p' => $this->l('Reason used in stock movements'),
),
),
'submit' => array(
+14 -8
View File
@@ -69,22 +69,24 @@ class AdminStockMvtControllerCore extends AdminController
),
);
$reasons_inc = StockMvtReason::getStockMvtReasons($this->context->language->id, 1);
$reasons_dec = StockMvtReason::getStockMvtReasons($this->context->language->id, -1);
$reasons_inc = StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id,
array(Configuration::get('PS_STOCK_MVT_TRANSFER_TO')), 1);
$reasons_dec = StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id,
array(Configuration::get('PS_STOCK_MVT_TRANSFER_FROM')), -1);
$this->options = array(
'general' => array(
'title' => $this->l('Options'),
'fields' => array(
'PS_STOCK_MVT_INC_REASON_DEFAULT' => array(
'title' => $this->l('Default Stock Movement reason for increment stock:'),
'title' => $this->l('Default reason when incrementing stock:'),
'cast' => 'intval',
'type' => 'select',
'list' => $reasons_inc,
'identifier' => 'id_stock_mvt_reason'
),
'PS_STOCK_MVT_DEC_REASON_DEFAULT' => array(
'title' => $this->l('Default Stock Movement reason for decrement stock:'),
'title' => $this->l('Default reason when decrementing stock:'),
'cast' => 'intval',
'type' => 'select',
'list' => $reasons_dec,
@@ -108,8 +110,8 @@ class AdminStockMvtControllerCore extends AdminController
{
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Add product to stock'),
'image' => '../img/admin/arrow_up.png'
'title' => $this->l('Stock Movement Reason'),
'image' => '../img/admin/edit.gif'
),
'input' => array(
array(
@@ -140,7 +142,7 @@ class AdminStockMvtControllerCore extends AdminController
'id' => 'id',
'name' => 'name'
),
'p' => $this->l('Select the warehouse where you want to add the product into')
'p' => $this->l('Select the corresponding action : increments or decrements stock.')
),
),
'submit' => array(
@@ -158,6 +160,9 @@ class AdminStockMvtControllerCore extends AdminController
*/
public function initList()
{
$this->displayInformation($this->l('This interface allows you to display the stock movements for a selected warehouse.').'<br />');
$this->displayInformation($this->l('Also, it allows you to add and edit your own stock movement reasons.'));
//no link on list rows
$this->list_no_link = true;
@@ -166,7 +171,8 @@ class AdminStockMvtControllerCore extends AdminController
*/
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->addRowActionSkipList('delete', array(1,2,3,4));
$this->addRowActionSkipList('edit', array(6, 7));
$this->addRowActionSkipList('delete', array(1, 2, 3, 4, 6, 7));
if (!isset($_GET['addstock_mvt_reason']) || (Tools::isSubmit('submitAddstock_mvt_reason') && Tools::getValue('id_stock_mvt_reason')))
{
+18 -15
View File
@@ -88,10 +88,13 @@ class AdminWarehousesControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'address` ad ON (ad.id_address = a.id_address)
LEFT JOIN `'._DB_PREFIX_.'country` c ON (c.id_country = ad.id_country)';
$this->displayInformation(
$this->l('This interface allows you to manage your warehouses. Before managing any stock in your warehouses, check the general default currency used.
For each warehouse, according to the law in your country, you have to check the management type, the valuation currency, and the associated carriers and shops.')
);
$this->displayInformation($this->l('This interface allows you to manage your warehouses.').'<br />');
$this->displayInformation($this->l('Before adding stock in your warehouses, you should check the general default currency used.').'<br />');
$this->displayInformation($this->l('Futhermore, for each warehouse, you have to check :
the management type (according to the law in your country), the valuation currency,
its associated carriers and shops.').'<br />');
$this->displayInformation($this->l('Finally, you can see detailed informations on your stock per warehouse, such as its valuation,
the number of products and quantities stored.'));
return parent::initList();
}
@@ -126,7 +129,7 @@ class AdminWarehousesControllerCore extends AdminController
'size' => 30,
'maxlength' => 32,
'required' => true,
'p' => $this->l('Code / Reference of this warehouse'),
'p' => $this->l('Reference of this warehouse'),
),
array(
'type' => 'text',
@@ -186,7 +189,7 @@ class AdminWarehousesControllerCore extends AdminController
'id' => 'id_country',
'name' => 'name'
),
'p' => $this->l('Country where state, region or city is located')
'p' => $this->l('Country where the state, region or city is located')
),
array(
'type' => 'select',
@@ -233,7 +236,7 @@ class AdminWarehousesControllerCore extends AdminController
'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.'),
'hint' => $this->l('Do not change this value before the end of the accounting period for this warehouse.'),
),
array(
'type' => 'select',
@@ -245,7 +248,7 @@ class AdminWarehousesControllerCore extends AdminController
'id' => 'id_currency',
'name' => 'name'
),
'hint' => $this->l('Do not change this value before the end of the accounting period for this Warehouse.'),
'hint' => $this->l('Do not change this value before the end of the accounting period for this warehouse.'),
),
array(
'type' => 'select',
@@ -258,13 +261,13 @@ class AdminWarehousesControllerCore extends AdminController
'id' => 'id_shop',
'name' => 'name'
),
'p' => $this->l('Associated shops'),
'hint' => $this->l('By associating a shop to a warehouse, all products in this warehouse will be available
for sale in the associated shop. Shipment of an order of this shop is also possible from this warehouse'),
'p' => $this->l('Shops'),
'hint' => $this->l('By associating a shop to a warehouse, all products in the warehouse will be available
for sale in it. It is also possible to ship orders of this shop from this warehouse'),
),
array(
'type' => 'select',
'label' => $this->l('Associated carriers:'),
'label' => $this->l('Carriers:'),
'name' => 'ids_carriers[]',
'required' => true,
'multiple' => true,
@@ -273,8 +276,8 @@ class AdminWarehousesControllerCore extends AdminController
'id' => 'id_carrier',
'name' => 'name'
),
'p' => $this->l('Associated carrier'),
'hint' => $this->l('You can specifiy the carriers availables for shipping orders from this warehouse'),
'p' => $this->l('Associated carriers'),
'hint' => $this->l('You can specifiy the carriers available to ship orders from this warehouse'),
),
),
'submit' => array(
@@ -407,7 +410,7 @@ class AdminWarehousesControllerCore extends AdminController
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
$content = '<div class="path_bar">';
$content .= sprintf($this->l('There are %s references (%d quantity), for a total of %d %s'), $refs, $res[0]['quantity'], $res[0]['total'], $res[0]['sign']);
$content .= sprintf($this->l('This warehouse stores %s reference(s) (%d quantity/ies), worth %d %s'), $refs, $res[0]['quantity'], $res[0]['total'], $res[0]['sign']);
$content .= '</div>';
echo Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content));
}