Commit 2640bb10 authored by Denis's avatar Denis

// AdminController and stock management : some debug and updates

parent e7cf665a
......@@ -77,13 +77,9 @@
<div class="translatable">
{foreach $languages as $language}
<div class="lang_{$language.id_lang}" style="display:{if $language.id_lang == $defaultFormLanguage}block{else}none{/if}; float: left;">
{if $input.type == 'tags'}
{literal}
<script type="text/javascript">
$().ready(function () {
var input_id = '{/literal}{if isset($input.id)}{$input.id}_{$language.id_lang}{else}{$input.name}_{$language.id_lang}{/if}{literal}';
$('#'+input_id).tagify({addTagPrompt: '{/literal}{l s='add tag'}{literal}'});
......@@ -119,7 +115,6 @@
$({/literal}'#{$table}{literal}_form').submit( function() {
$(this).find('#'+input_id).val($('#'+input_id).tagify('serialize'));
});
});
</script>
{/literal}
......@@ -349,15 +344,15 @@
{block name="after"}{/block}
{if isset($tinymce) && $tinymce}
<script type="text/javascript">
var iso = '{$iso}';
var pathCSS = '{$smarty.const._THEME_CSS_DIR_}';
var ad = '{$ad}';
$(document).ready(function(){
tinySetup();
{block name="autoload_tinyMCE"}
// change each by click to load only on click
$(".autoload_rte").each(function(e){
......@@ -368,7 +363,7 @@
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull|cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,undo,redo",
theme_advanced_buttons2 : "link,unlink,anchor,image,cleanup,code,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,charmap,media,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
theme_advanced_buttons4 : "",
});
})
{/block}
......
......@@ -88,7 +88,7 @@ $(document).ready(function() {
}
});
content.append($('<td class="empty"></td>'));
$('#details_{$id}').parent().parent().after(content);
$('#details_{$id}').parent().parent().after(content.show('slow'));
});
}
else
......@@ -98,7 +98,7 @@ $(document).ready(function() {
else
var content = $('<tr class="details_{$id}"></tr>');
content.append($('<td style="border:none!important;">'+data.data+'</td>').attr('colspan', $('#details_{$id}').parent().parent().find('td').length));
$('#details_{$id}').parent().parent().after(content);
$('#details_{$id}').parent().parent().after(content.show('slow'));
}
this.dataMaped = true;
this.opened = false;
......@@ -110,13 +110,13 @@ $(document).ready(function() {
if (this.opened)
{
$(this).find('img').attr('src', '../img/admin/more.png');
$(this).parent().parent().parent().find('.details_{$id}').hide();
$(this).parent().parent().parent().find('.details_{$id}').hide('slow');
this.opened = false
}
else
{
$(this).find('img').attr('src', '../img/admin/less.png');
$(this).parent().parent().parent().find('.details_{$id}').show();
$(this).parent().parent().parent().find('.details_{$id}').show('slow');
this.opened = true;
}
return false;
......
......@@ -351,8 +351,8 @@ class AdminControllerCore extends Controller
$country = Tools::getValue('country');
$version = Tools::getValue('version');
if (isset($item) AND isset($isoUser) AND isset($country))
$this->content = HelpAccess::getHelp($item, $isoUser, $country, $version);
if (isset($item) && isset($isoUser) && isset($country))
$this->content = HelpAccess::getHelp($item, $isoUser, $country, $version);
else
$this->content = 'none';
$this->display = 'content';
......@@ -501,7 +501,7 @@ class AdminControllerCore extends Controller
' <b>'.$this->table.'</b><br />'.
Tools::displayError('You cannot delete all of the items.');
}
else if (array_key_exists('delete', $this->list_skip_actions) AND in_array($object->id, $this->list_skip_actions['delete'])) //check if some ids are in list_skip_actions and forbid deletion
else if (array_key_exists('delete', $this->list_skip_actions) && in_array($object->id, $this->list_skip_actions['delete'])) //check if some ids are in list_skip_actions and forbid deletion
$this->_errors[] = Tools::displayError('You cannot delete this items.');
else
{
......@@ -544,6 +544,7 @@ class AdminControllerCore extends Controller
if (!count($this->_errors))
{
$id = (int)Tools::getValue($this->identifier);
/* Object update */
if (isset($id) && !empty($id))
{
......@@ -643,7 +644,8 @@ class AdminControllerCore extends Controller
if (Tools::isSubmit('submitAdd'.$this->table.'AndBackToParent'))
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$parent_id.'&conf=3&token='.$token;
// Default behavior (save and back)
$this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$token;
if (empty($this->redirect_after))
$this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$token;
}
}
else
......@@ -1002,7 +1004,7 @@ class AdminControllerCore extends Controller
public function displayAjax()
{
if($this->json)
if ($this->json)
{
$this->context->smarty->assign(array(
'json' => true,
......@@ -1638,7 +1640,7 @@ class AdminControllerCore extends Controller
unset($parse_query['setShopContext'], $parse_query['conf']);
$this->redirect_after = $url['path'].'?'.http_build_query($parse_query);
}
elseif (!Shop::isFeatureActive())
else if (!Shop::isFeatureActive())
$this->context->cookie->shopContext = 's-1';
$shop_id = '';
if ($this->context->cookie->shopContext)
......@@ -1647,9 +1649,9 @@ class AdminControllerCore extends Controller
if (count($split) == 2 && $split[0] == 's')
$shop_id = (int)$split[1];
}
elseif ($this->context->employee->id_profile == _PS_ADMIN_PROFILE_)
else if ($this->context->employee->id_profile == _PS_ADMIN_PROFILE_)
$shop_id = '';
elseif ($this->context->shop->getTotalShopsWhoExists() != Employee::getTotalEmployeeShopById((int)$this->context->employee->id))
else if ($this->context->shop->getTotalShopsWhoExists() != Employee::getTotalEmployeeShopById((int)$this->context->employee->id))
{
$shops = Employee::getEmployeeShopById((int)$this->context->employee->id);
if (count($shops))
......
......@@ -1078,7 +1078,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
if (Tools::isSubmit('submitBulkUpdatesupply_order_detail') && !($this->tabAccess['edit'] === '1'))
$this->_errors[] = Tools::displayError($this->l('You do not have the required permission to edit an order.'));
// Global checks when add / update a supply order
if (Tools::isSubmit('submitAddsupply_order'))
if (Tools::isSubmit('submitAddsupply_order') || Tools::isSubmit('submitAddsupply_orderAndStay'))
{
$this->action = 'save';
......
......@@ -63,76 +63,6 @@ class AdminTrackingController extends AdminController
));
}
public function getObjects($type)
{
switch ($type)
{
case 'categories_empty':
$sql = '
SELECT id_category
FROM `'._DB_PREFIX_.'category`
WHERE id_category NOT IN (
SELECT DISTINCT(id_category)
FROM `'._DB_PREFIX_.'category_product`
)
';
break;
case 'products_disabled':
$sql = '
SELECT *
FROM `'._DB_PREFIX_.'product`
WHERE active = 0
';
$this->_list['message'] = $this->l('List of disabled products:');
break;
case 'products_nostock':
$sql = '
SELECT DISTINCT(id_product)
FROM `'._DB_PREFIX_.'product`
WHERE id_product IN (
SELECT id_product
FROM `'._DB_PREFIX_.'product`
WHERE id_product NOT IN (
SELECT DISTINCT(id_product)
FROM `'._DB_PREFIX_.'product_attribute`
)
AND quantity <= 0
)
';
$this->_list['message'] = $this->l('List of out of stock products without attributes:');
break;
case 'attributes_nostock':
$sql = 'SELECT pa.*, ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, al.`name` AS attribute_name, a.`id_attribute`,
m.`name` AS manufacturer_name, pl.`name` AS name, p.`weight` AS product_weight, p.`active` AS active
FROM `'._DB_PREFIX_.'product_attribute` pa
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
ON pac.`id_product_attribute` = pa.`id_product_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute` a
ON a.`id_attribute` = pac.`id_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag
ON ag.`id_attribute_group` = a.`id_attribute_group`
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$this->context->language->id.')
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$this->context->language->id.')
LEFT JOIN `'._DB_PREFIX_.'product` p
ON (p.`id_product` = pa.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
'.Product::sqlStock('p', 'pa').'
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m
ON (p.`id_manufacturer` = m.`id_manufacturer`)
WHERE stock.quantity <= 0
ORDER BY pa.`id_product_attribute`';
$this->_list['message'] = $this->l('List of out of stock products with attributes:');
break;
}
return Db::getInstance()->executeS($sql);
}
public function getCustomListCategoriesEmpty()
{
$this->clearListOptions();
......@@ -149,10 +79,10 @@ class AdminTrackingController extends AdminController
$this->addRowAction('view');
$this->fieldsDisplay = (array(
'id_category' => array('title' => $this->l('ID')),
'id_category' => array('title' => $this->l('ID'), 'width' => 50),
'name' => array('title' => $this->l('Name')),
'description' => array('title' => $this->l('Description')),
'active' => array('title' => $this->l('Status'), 'type' => 'bool', 'active' => 'status')
'active' => array('title' => $this->l('Status'), 'type' => 'bool', 'active' => 'status', 'width' => 50)
));
$this->_filter = ' AND a.id_category NOT IN (
......@@ -160,7 +90,6 @@ class AdminTrackingController extends AdminController
FROM `'._DB_PREFIX_.'category_product` cp
)';
$this->getObjects('categories_empty');
$this->tpl_list_vars = array('sub_title' => $this->l('List of empty categories:'));
return parent::initList();
......@@ -177,29 +106,29 @@ class AdminTrackingController extends AdminController
self::$currentIndex = 'index.php?controller=AdminProducts';
$this->token = Tools::getAdminTokenLite('AdminProducts');
$this->show_toolbar = false;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->fieldsDisplay = array(
'ID' => array('title' => $this->l('ID')),
'manufacturer' => array('title' => $this->l('Manufacturer')),
'reference' => array('title' => $this->l('Reference')),
'id_product' => array('title' => $this->l('ID'), 'width' => 50),
'reference' => array('title' => $this->l('Reference'), 'width' => 150),
'name' => array('title' => $this->l('Name')),
'price' => array('title' => $this->l('Price')),
'tax' => array('title' => $this->l('Tax')),
'stock' => array('title' => $this->l('Stock')),
'weight' => array('title' => $this->l('Weight')),
'active' => array('title' => $this->l('Status'), 'type' => 'bool', 'active' => 'status')
'active' => array('title' => $this->l('Status'), 'type' => 'bool', 'active' => 'status', 'width' => 50)
);
$this->_filter = 'AND a.id_product IN (
SELECT id_product
FROM `'._DB_PREFIX_.'product`
WHERE id_product IN (
SELECT p.id_product
FROM `'._DB_PREFIX_.'product` p
'.Product::sqlStock('p').'
WHERE p.id_product IN (
SELECT DISTINCT(id_product)
FROM `'._DB_PREFIX_.'product_attribute`
)
AND quantity <= 0
AND stock.quantity <= 0
)';
$this->tpl_list_vars = array('sub_title' => $this->l('List of out of stock products without attributes:'));
$this->tpl_list_vars = array('sub_title' => $this->l('List of products with attributes and without available quantities for sale:'));
return parent::initList();
}
......@@ -216,29 +145,28 @@ class AdminTrackingController extends AdminController
self::$currentIndex = 'index.php?controller=AdminProducts';
$this->token = Tools::getAdminTokenLite('AdminProducts');
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->fieldsDisplay = array(
'ID' => array('title' => $this->l('ID')),
'manufacturer' => array('title' => $this->l('Manufacturer')),
'reference' => array('title' => $this->l('Reference')),
'id_product' => array('title' => $this->l('ID'), 'width' => 50),
'reference' => array('title' => $this->l('Reference'), 'width' => 150),
'name' => array('title' => $this->l('Name')),
'price' => array('title' => $this->l('Price')),
'tax' => array('title' => $this->l('Tax')),
'stock' => array('title' => $this->l('Stock')),
'weight' => array('title' => $this->l('Weight')),
'active' => array('title' => $this->l('Status'), 'type' => 'bool', 'active' => 'status')
'active' => array('title' => $this->l('Status'), 'type' => 'bool', 'active' => 'status', 'width' => 50)
);
$this->_filter = 'AND a.id_product IN (
SELECT id_product
FROM `'._DB_PREFIX_.'product`
WHERE id_product NOT IN (
SELECT p.id_product
FROM `'._DB_PREFIX_.'product` p
'.Product::sqlStock('p').'
WHERE p.id_product NOT IN (
SELECT DISTINCT(id_product)
FROM `'._DB_PREFIX_.'product_attribute`
)
AND quantity <= 0
AND stock.quantity <= 0
)';
$this->tpl_list_vars = array('sub_title' => $this->l('List of out of stock products with attributes:'));
$this->tpl_list_vars = array('sub_title' => $this->l('List of products without attributes and without available quantities for sale:'));
return parent::initList();
}
......@@ -258,12 +186,22 @@ class AdminTrackingController extends AdminController
self::$currentIndex = 'index.php?controller=AdminProducts';
$this->token = Tools::getAdminTokenLite('AdminProducts');
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->fieldsDisplay = array(
'id_product' => array('title' => $this->l('ID'), 'width' => 50),
'reference' => array('title' => $this->l('Reference'), 'width' => 150),
'name' => array('title' => $this->l('Name'))
);
return parent::initList();
}
public function clearListOptions()
{
$this->table = '';
$this->actions = array();
$this->lang = false;
$this->identifier = '';
$this->_defaultOrderBy = '';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment