* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 9565 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* @since 1.5.0
*/
class AdminStockMvtControllerCore extends AdminController
{
public function __construct()
{
$this->context = Context::getContext();
$this->table = 'stock_mvt_reason';
$this->className = 'StockMvtReason';
$this->lang = true;
$this->fieldsDisplay = array(
'id_stock_mvt_reason' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 40,
'widthColumn' => 40,
'search' => false,
),
'sign' => array(
'title' => $this->l('Sign'),
'width' => 80,
'widthColumn' => 100,
'align' => 'center',
'type' => 'select',
'filter_key' => 'a!sign',
'select' => array(
'1' => $this->l('Increment'),
'-1' => $this->l('Decrement'),
),
'icon' => array(
-1 => 'arrow_down.png',
1 => 'arrow_up.png'
),
'orderby' => false
),
'name' => array(
'title' => $this->l('Name'),
'filter_key' => 'b!name',
'width' => 500
),
);
$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 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 reason when decrementing stock:'),
'cast' => 'intval',
'type' => 'select',
'list' => $reasons_dec,
'identifier' => 'id_stock_mvt_reason'
),
),
'submit' => array(),
)
);
$this->context->smarty->assign('list_warehouses', array());
parent::__construct();
}
/**
* AdminController::initForm() override
* @see AdminController::initForm()
*/
public function initForm()
{
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Stock Movement Reason'),
'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' => 'select',
'label' => $this->l('Action:'),
'name' => 'sign',
'required' => true,
'options' => array(
'query' => array(
array(
'id' => '1',
'name' => $this->l('Increase stock')
),
array(
'id' => '-1',
'name' => $this->l('Decrease stock')
),
),
'id' => 'id',
'name' => 'name'
),
'p' => $this->l('Select the corresponding action : increments or decrements stock.')
),
),
'submit' => array(
'title' => $this->l(' Save '),
'class' => 'button'
)
);
return parent::initForm();
}
/**
* AdminController::initList() override
* @see AdminController::initList()
*/
public function initList()
{
$this->displayInformation($this->l('This interface allows you to display the stock movements for a selected warehouse.').'
');
$this->displayInformation($this->l('Also, it allows you to add and edit your own stock movement reasons.'));
// access
if (!($this->tabAccess['add'] === '1'))
$this->no_add = true;
//no link on list rows
$this->list_no_link = true;
/*
* Manage default list
*/
$this->addRowAction('edit');
$this->addRowAction('delete');
$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')))
{
$first_list = '