// Update stock movements interface with new controllers + debug and optimisations
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9604 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1,209 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 7307 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class AdminStockMvt extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
$this->table = 'stock_mvt';
|
||||
$this->className = 'StockMvt';
|
||||
$this->edit = false;
|
||||
$this->delete = false;
|
||||
$this->view = false;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_stock_mvt' => array('title' => $this->l('ID'), 'width' => 40),
|
||||
'product_name' => array('title' => $this->l('Product Name'), 'width' => 200, 'havingFilter' => true),
|
||||
'physical_quantity' => array('title' => $this->l('Quantity'), 'width' => 40),
|
||||
'reason' => array('title' => $this->l('Reason'), 'width' => 200),
|
||||
'id_order' => array('title' => $this->l('ID Order'), 'width' => 40),
|
||||
'employee' => array('title' => $this->l('Employee'), 'width' => 100, 'havingFilter' => true),
|
||||
'warehouse' => array('title' => $this->l('Warehouse'), 'width' => 100, 'havingFilter' => true),
|
||||
);
|
||||
|
||||
$this->_select = 'CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) product_name, CONCAT(e.lastname, \' \', e.firstname) AS employee, mrl.name AS reason, CONCAT(w.reference, " - ", w.name) AS warehouse';
|
||||
$this->_join = 'INNER JOIN '._DB_PREFIX_.'stock stock ON a.id_stock = stock.id_stock
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (stock.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'stock_mvt_reason_lang` mrl ON (a.id_stock_mvt_reason = mrl.id_stock_mvt_reason AND mrl.id_lang = '.(int)$this->context->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.id_employee = a.id_employee)
|
||||
LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = stock.id_warehouse)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.id_product_attribute = stock.id_product_attribute)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (al.id_attribute = pac.id_attribute AND al.id_lang = '.(int)$this->context->language->id.')';
|
||||
$this->_group = 'GROUP BY a.id_stock_mvt';
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
/*if (Tools::isSubmit('rebuildStock'))
|
||||
StockMvt::addMissingMvt($this->context->employee->id, false);*/
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
parent::displayForm();
|
||||
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
$dl = 'name';
|
||||
echo '<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'&addstock_mvt_reason" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/search.gif" />'.$this->l('Stock Movement').'</legend>
|
||||
<label>'.$this->l('Name:').'</label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="40" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $dl, 'name');
|
||||
echo '</div>
|
||||
<div class="clear space"> </div>
|
||||
<label>'.$this->l('Action:').'</label>
|
||||
<div class="margin-form">
|
||||
<select name="sign">
|
||||
<option value="1">'.$this->l('Increase stock').'</option>
|
||||
<option value="-1">'.$this->l('Decrease stock').'</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="clear space"> </div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
/*
|
||||
public function viewstock_mvt()
|
||||
{
|
||||
$stockMvt = new StockMvt((int)Tools::getValue('id_stock_mvt'));
|
||||
$product = new Product((int)$stockMvt->id_product, true, $this->context->language->id);
|
||||
$movements = $product->getStockMvts($this->context->language->id);
|
||||
|
||||
echo '<h2>'.$this->l('Stock Movements for').' '.$product->name.'</h2>
|
||||
<table cellspacing="0" cellpadding="0" class="table widthfull">
|
||||
<tr>
|
||||
<th>'.$this->l('ID').'</th>
|
||||
<th>'.$this->l('Product Name').'</th>
|
||||
<th>'.$this->l('Quantity').'</th>
|
||||
<th>'.$this->l('Reason').'</th>
|
||||
<th>'.$this->l('Employee').'</th>
|
||||
<th>'.$this->l('Order').'</th>
|
||||
<th>'.$this->l('Date').'</th>
|
||||
</tr>';
|
||||
$irow = 0;
|
||||
foreach ($movements AS $k => $mvt)
|
||||
{
|
||||
echo '
|
||||
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
|
||||
<td>'.$mvt['id_stock_mvt'].'</td>
|
||||
<td>'.$mvt['product_name'].'</td>
|
||||
<td>'.$mvt['quantity'].'</td>
|
||||
<td>'.$mvt['reason'].'</td>
|
||||
<td>'.$mvt['employee'].'</td>
|
||||
<td>#'.$mvt['id_order'].'</td>
|
||||
<td>'.Tools::displayDate($mvt['date_add'], $this->context->language->id).'</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
*/
|
||||
public function display()
|
||||
{
|
||||
$old_post = false;
|
||||
|
||||
if (!isset($_GET['addstock_mvt_reason']) || (Tools::isSubmit('submitAddstock_mvt_reason') && Tools::getValue('id_stock_mvt_reason')))
|
||||
{
|
||||
if (isset($_POST))
|
||||
$old_post = $_POST;
|
||||
|
||||
echo '<h2>'.$this->l('Stock movement history').'</h2>';
|
||||
parent::display();
|
||||
/*if (!isset($_GET['view'.$this->table]))
|
||||
echo '
|
||||
<fieldset>
|
||||
<form method="post" action="'.self::$currentIndex.'&token='.$this->token.'&rebuildMvt=1">
|
||||
<label for="stock_rebuild">'.$this->l('Calculate the movement of inventory missing').'</label>
|
||||
<div class="margin-form">
|
||||
<input class="button" type="submit" name="rebuildStock" value="'.$this->l('Submit').'" />
|
||||
</div>
|
||||
</form>
|
||||
</fieldset><br />';*/
|
||||
}
|
||||
if (isset($_GET['view'.$this->table]))
|
||||
return;
|
||||
if ($old_post)
|
||||
$_POST = $old_post;
|
||||
|
||||
$this->table = 'stock_mvt_reason';
|
||||
$this->className = 'StockMvtReason';
|
||||
$this->identifier = 'id_stock_mvt_reason';
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->lang = true;
|
||||
$this->add = true;
|
||||
$this->view = false;
|
||||
$this->_listSkipDelete = array(1,2,3,4);
|
||||
|
||||
|
||||
$this->_defaultOrderBy = $this->identifier;
|
||||
$this->fieldsDisplay = array('id_stock_mvt_reason' => array('title' => $this->l('ID'), 'width' => 40),
|
||||
'sign' => array('title' => $this->l('Sign'), 'width' => 15, 'align' => 'center', 'type' => 'select', 'icon' => array(-1 => 'arrow_down.png', 1 => 'arrow_up.png'), 'orderby' => false),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 500));
|
||||
|
||||
$reasons_inc = StockMvtReason::getStockMvtReasons($this->context->language->id, 1);
|
||||
$reasons_dec = StockMvtReason::getStockMvtReasons($this->context->language->id, -1);
|
||||
|
||||
$this->optionsList = 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:'),
|
||||
'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:'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'select',
|
||||
'list' => $reasons_dec,
|
||||
'identifier' => 'id_stock_mvt_reason'
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
|
||||
|
||||
echo '<h2>'.$this->l('Stock movement reason').'</h2>';
|
||||
$this->postProcess();
|
||||
return parent::display();
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('.filter').keypress(function(event){
|
||||
$('table.{$table} .filter').keypress(function(event){
|
||||
formSubmit(event, 'submitFilterButton{$table}')
|
||||
})
|
||||
});
|
||||
@@ -47,8 +47,8 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
if ($(".datepicker").length > 0)
|
||||
$(".datepicker").datepicker({
|
||||
if ($("table.{$table} .datepicker").length > 0)
|
||||
$("table.{$table} .datepicker").datepicker({
|
||||
prevText: '',
|
||||
nextText: '',
|
||||
dateFormat: 'yy-mm-dd'
|
||||
@@ -99,7 +99,7 @@
|
||||
<td{if $simple_header} style="border:none;"{/if}>
|
||||
<table
|
||||
{if $table_id} id={$table_id}{/if}
|
||||
class="table {if $table_dnd}tableDnd{/if}"
|
||||
class="table {if $table_dnd}tableDnd{/if} {$table}"
|
||||
cellpadding="0" cellspacing="0"
|
||||
style="width: 100%; margin-bottom:10px;"
|
||||
>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
{*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 9556 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
{if count($list_warehouses) > 1}
|
||||
<form type="get" onchange="submit();">
|
||||
<label for="warehouse">{l s="Select a warehouse:"}</label>
|
||||
<input type="hidden" name="controller" value="AdminStockMvt" />
|
||||
<input type="hidden" name="token" value="{$token}" />
|
||||
<select name="warehouse">
|
||||
{foreach $list_warehouses as $warehouse}
|
||||
<option {if $warehouse.id_warehouse == $current_warehouse}selected="selected"{/if} value="{$warehouse.id_warehouse}">{$warehouse.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
{$content}
|
||||
Vendored
+2
@@ -370,6 +370,8 @@
|
||||
'AdminStockInstantStateController' => '',
|
||||
'AdminStockManagementControllerCore' => 'controllers/admin/AdminStockManagementController.php',
|
||||
'AdminStockManagementController' => '',
|
||||
'AdminStockMvtControllerCore' => 'controllers/admin/AdminStockMvtController.php',
|
||||
'AdminStockMvtController' => '',
|
||||
'AdminStoresControllerCore' => 'controllers/admin/AdminStoresController.php',
|
||||
'AdminStoresController' => '',
|
||||
'AdminToolsControllerCore' => 'controllers/admin/AdminToolsController.php',
|
||||
|
||||
@@ -595,6 +595,7 @@ class AdminControllerCore extends Controller
|
||||
if ($this->filter)
|
||||
{
|
||||
$_POST = array_merge($this->context->cookie->getFamily($this->table.'Filter_'), (isset($_POST) ? $_POST : array()));
|
||||
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
/* Extracting filters from $_POST on key filter_ */
|
||||
@@ -604,6 +605,7 @@ class AdminControllerCore extends Controller
|
||||
/* Table alias could be specified using a ! eg. alias!field */
|
||||
$tmp_tab = explode('!', $key);
|
||||
$filter = count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0];
|
||||
|
||||
if ($field = $this->filterToField($key, $filter))
|
||||
{
|
||||
$type = (array_key_exists('filter_type', $field) ? $field['filter_type'] : (array_key_exists('type', $field) ? $field['type'] : false));
|
||||
|
||||
@@ -99,7 +99,7 @@ class HelperListCore extends Helper
|
||||
'id_carrier' => 'id_carrier'
|
||||
);
|
||||
|
||||
// @var boolean ask for simple header : no filters, no paginations and no sorting
|
||||
/** @var boolean ask for simple header : no filters, no paginations and no sorting */
|
||||
public $simple_header = false;
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,7 +63,7 @@ class WarehouseCore extends ObjectModel
|
||||
protected $fieldsValidate = array(
|
||||
'id_address' => 'isUnsignedId',
|
||||
'reference' => 'isString',
|
||||
'name' => 'isString',
|
||||
'name' => 'isName',
|
||||
'id_employee' => 'isUnsignedId',
|
||||
'management_type' => 'isStockManagement',
|
||||
'id_currency' => 'isUnsignedId'
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @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::getStockMvtReasons($this->context->language->id, 1);
|
||||
$reasons_dec = StockMvtReason::getStockMvtReasons($this->context->language->id, -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:'),
|
||||
'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:'),
|
||||
'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('Add product to stock'),
|
||||
'image' => '../img/admin/arrow_up.png'
|
||||
),
|
||||
'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 warehouse where you want to add the product into')
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button'
|
||||
)
|
||||
);
|
||||
|
||||
return parent::initForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* AdminController::initList() override
|
||||
* @see AdminController::initList()
|
||||
*/
|
||||
public function initList()
|
||||
{
|
||||
//no link on list rows
|
||||
$this->list_no_link = true;
|
||||
|
||||
/*
|
||||
* Manage default list
|
||||
*/
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
$this->addRowActionSkipList('delete', array(1,2,3,4));
|
||||
|
||||
if (!isset($_GET['addstock_mvt_reason']) || (Tools::isSubmit('submitAddstock_mvt_reason') && Tools::getValue('id_stock_mvt_reason')))
|
||||
{
|
||||
$first_list = '<hr /><h2>'.$this->l('Stock movement reason').'</h2>';
|
||||
$first_list .= parent::initList();
|
||||
}
|
||||
|
||||
/*
|
||||
* Manage second list
|
||||
*/
|
||||
$warehouses = Warehouse::getWarehouseList(true);
|
||||
array_unshift($warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
|
||||
$this->context->smarty->assign('list_warehouses', $warehouses);
|
||||
$this->context->smarty->assign('current_warehouse', $this->getCurrentWarehouseId());
|
||||
|
||||
// reset actions and query vars
|
||||
$this->actions = array();
|
||||
unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
|
||||
|
||||
// override table, land, className and identifier for the current controller
|
||||
$this->table = 'stock_mvt';
|
||||
$this->className = 'StockMvt';
|
||||
$this->identifier = 'id_stock_mvt';
|
||||
$this->lang = false;
|
||||
|
||||
// test if a filter is applied for this list
|
||||
if (Tools::isSubmit('submitFilter'.$this->table) || $this->context->cookie->{'submitFilter'.$this->table} !== false)
|
||||
$this->filter = true;
|
||||
|
||||
// test if a filter reset request is required for this list
|
||||
if (isset($_POST['submitReset'.$this->table]))
|
||||
$this->action = 'reset_filters';
|
||||
else
|
||||
$this->action = '';
|
||||
|
||||
// redifine fields display
|
||||
$this->fieldsDisplay = array(
|
||||
'product_name' => array(
|
||||
'title' => $this->l('Product Name'),
|
||||
'width' => 200,
|
||||
'havingFilter' => true
|
||||
),
|
||||
'physical_quantity' => array(
|
||||
'title' => $this->l('Quantity'),
|
||||
'width' => 40,
|
||||
'filter_key' => 'a!physical_quantity'
|
||||
),
|
||||
'price_te' => array(
|
||||
'title' => $this->l('Price (TE)'),
|
||||
'width' => 70,
|
||||
'align' => 'right',
|
||||
'price' => true,
|
||||
'currency' => true,
|
||||
'filter_key' => 'a!price_te'
|
||||
),
|
||||
'reason' => array(
|
||||
'title' => $this->l('Reason'),
|
||||
'width' => 200,
|
||||
'havingFilter' => true
|
||||
),
|
||||
'id_order' => array(
|
||||
'title' => $this->l('ID Order'),
|
||||
'width' => 40
|
||||
),
|
||||
'employee' => array(
|
||||
'title' => $this->l('Employee'),
|
||||
'width' => 100,
|
||||
'havingFilter' => true
|
||||
),
|
||||
'date_add' => array(
|
||||
'title' => $this->l('Date'),
|
||||
'width' => 50,
|
||||
'align' => 'right',
|
||||
'type' => 'datetime',
|
||||
'filter_key' => 'a!date_add'
|
||||
),
|
||||
);
|
||||
|
||||
// make new query
|
||||
$this->_select = '
|
||||
CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) product_name, CONCAT(e.lastname, \' \', e.firstname) AS employee,
|
||||
mrl.name AS reason,
|
||||
w.id_currency as id_currency';
|
||||
|
||||
$this->_join = 'INNER JOIN '._DB_PREFIX_.'stock stock ON a.id_stock = stock.id_stock
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
stock.id_product = pl.id_product
|
||||
AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'stock_mvt_reason_lang` mrl ON (
|
||||
a.id_stock_mvt_reason = mrl.id_stock_mvt_reason
|
||||
AND mrl.id_lang = '.(int)$this->context->language->id.'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.id_employee = a.id_employee)
|
||||
LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = stock.id_warehouse)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.id_product_attribute = stock.id_product_attribute)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (
|
||||
al.id_attribute = pac.id_attribute
|
||||
AND al.id_lang = '.(int)$this->context->language->id.'
|
||||
)';
|
||||
$this->_group = 'GROUP BY a.id_stock_mvt';
|
||||
|
||||
$id_warehouse = $this->getCurrentWarehouseId();
|
||||
if ($id_warehouse > 0)
|
||||
$this->_where = ' AND w.id_warehouse = '.$id_warehouse;
|
||||
|
||||
// call postProcess() for take care about actions and filters
|
||||
$this->postProcess();
|
||||
|
||||
// generate the second list
|
||||
$second_list = parent::initList();
|
||||
|
||||
// reset all query vars
|
||||
unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
|
||||
|
||||
// return the two lists
|
||||
return $second_list.$first_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current warehouse for this controller
|
||||
*
|
||||
* @return int warehouse_id
|
||||
*/
|
||||
protected function getCurrentWarehouseId()
|
||||
{
|
||||
static $warehouse = 0;
|
||||
|
||||
if ($warehouse == 0)
|
||||
{
|
||||
$warehouse = -1;
|
||||
if ((int)Tools::getValue('warehouse'))
|
||||
$warehouse = (int)Tools::getValue('warehouse');
|
||||
else if ((int)$this->context->cookie->warehouse)
|
||||
$warehouse = (int)$this->context->cookie->warehouse;
|
||||
$this->context->cookie->warehouse = $warehouse;
|
||||
}
|
||||
|
||||
return $warehouse;
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,11 @@ 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 manage any stock in your warehouses, check the general default currency used in the soclution.
|
||||
For each warehouse, according to the law in your country, you have to verify the management type, the valuation currency, and the associated carriers and shops.')
|
||||
);
|
||||
|
||||
return parent::initList();
|
||||
}
|
||||
|
||||
@@ -296,6 +301,7 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
//force specific fields values
|
||||
if ($address != null)
|
||||
$this->fields_value = array(
|
||||
'id_address' => $address->id,
|
||||
'phone' => $address->phone,
|
||||
'address' => $address->address1,
|
||||
'address2' => $address->address2,
|
||||
@@ -304,6 +310,8 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
'id_country' => $address->id_country,
|
||||
'id_state' => $address->id_state,
|
||||
);
|
||||
else
|
||||
$this->fields_value['id_address'] = 0;
|
||||
|
||||
$this->fields_value['ids_shops[]'] = $shops;
|
||||
$this->fields_value['ids_carriers[]'] = $carriers;
|
||||
@@ -331,16 +339,16 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
$obj->setCarriers(Tools::getValue('ids_carriers'));
|
||||
|
||||
// update/create address if not exists
|
||||
if (Tools::isSubmit('id_address') && Tools::getValue('id_address') > 0)
|
||||
if (Tools::isSubmit('id_address') && (int)Tools::getValue('id_address') > 0)
|
||||
//update address
|
||||
$address = new Address((int)Tools::getValue('id_address'));
|
||||
else
|
||||
//create address
|
||||
$address = new Address();
|
||||
|
||||
$address->alias = Tools::getValue('name', null);
|
||||
$address->lastname = Tools::getValue('name', null);
|
||||
$address->firstname = Tools::getValue('name', null);
|
||||
$address->alias = Tools::getValue('reference', null);
|
||||
$address->lastname = 'warehouse'; // skip problem with numeric characters in warehouse name
|
||||
$address->firstname = 'warehouse'; // skip problem with numeric characters in warehouse name
|
||||
$address->address1 = Tools::getValue('address', null);
|
||||
$address->address2 = Tools::getValue('address2', null);
|
||||
$address->postcode = Tools::getValue('postcode', null);
|
||||
@@ -349,9 +357,15 @@ class AdminWarehousesControllerCore extends AdminController
|
||||
$address->id_state = Tools::getValue('id_state', null);
|
||||
$address->city = Tools::getValue('city', null);
|
||||
|
||||
$validation = $address->validateController();
|
||||
|
||||
// check address validity
|
||||
if (!$address->validateFields(false))
|
||||
if (count($validation) > 0)
|
||||
{
|
||||
foreach ($validation as $item)
|
||||
$this->_errors[] = $item;
|
||||
$this->_errors[] = Tools::displayError('The address is not correct. Check if all required fields are filled.');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Tools::isSubmit('id_address') && Tools::getValue('id_address') > 0)
|
||||
|
||||
Reference in New Issue
Block a user