Merge branch 'bootstrap' of https://github.com/PrestaShop/PrestaShop into bootstrap
This commit is contained in:
@@ -72,6 +72,10 @@
|
||||
<button class="btn btn-default" name="submitLogin" type="submit">
|
||||
{l s='Log in'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-9 col-lg-offset-3">
|
||||
<p>
|
||||
<a href="#" class="show-forgot-password">
|
||||
<i class="icon-question-sign"></i>
|
||||
@@ -103,6 +107,10 @@
|
||||
<button class="btn btn-default" name="submitLogin" type="submit">
|
||||
{l s='Send'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-9 col-lg-offset-3">
|
||||
<p>
|
||||
<a href="#" class="show-login-form">
|
||||
<i class="icon-angle-left"></i>
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
{*
|
||||
* 2007-2013 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-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<!DOCTYPE html>
|
||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7 lt-ie6 " lang="en"> <![endif]-->
|
||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8 ie7" lang="en"> <![endif]-->
|
||||
<!--[if IE 8]> <html class="no-js lt-ie9 ie8" lang="en"> <![endif]-->
|
||||
<!--[if gt IE 8]> <html lang="fr" class="no-js ie9" lang="en"> <![endif]-->
|
||||
<html lang="{$iso}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="robots" content="NOFOLLOW, NOINDEX">
|
||||
<title>{$shop_name} {if $meta_title != ''}{if isset($navigationPipe)}{$navigationPipe|escape:'htmlall':'UTF-8'}{else}>{/if} {$meta_title}{/if} (PrestaShop™)</title>
|
||||
{foreach from=$css_files key=css_uri item=media}
|
||||
<link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" />
|
||||
{/foreach}
|
||||
{foreach from=$js_files item=js_uri}
|
||||
<script type="text/javascript" src="{$js_uri}"></script>
|
||||
{/foreach}
|
||||
<link rel="icon" type="image/vnd.microsoft.icon" href="{$img_dir}favicon.ico" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{$img_dir}favicon.ico" />
|
||||
<!--[if IE]>
|
||||
<link type="text/css" rel="stylesheet" href="{$base_url}css/admin-ie.css" />
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<div id="content" class="page-content">
|
||||
+3
-1
@@ -24,6 +24,7 @@
|
||||
*}
|
||||
{extends file="helpers/list/list_header.tpl"}
|
||||
{block name=override_header}
|
||||
{if isset($show_filter) && $show_filter}
|
||||
<fieldset>
|
||||
<h3><i class="icon-cogs"></i> {l s='Filters'}</h3>
|
||||
<div class="filter-stock">
|
||||
@@ -34,7 +35,7 @@
|
||||
<div id="stock_instant_state_form_warehouse" class="form-group">
|
||||
<label for="id_warehouse" class="control-label col-lg-3">{l s='Filter by warehouse:'}</label>
|
||||
<div class="col-lg-9">
|
||||
<select name="id_warehouse" onChange="$(this).parent().parent().submit();">
|
||||
<select name="id_warehouse" onChange="$('#stock_instant_state').submit();">
|
||||
{foreach from=$stock_instant_state_warehouses key=k item=i}
|
||||
<option {if $i.id_warehouse == $stock_instant_state_cur_warehouse} selected="selected"{/if} value="{$i.id_warehouse}">{$i.name}</option>
|
||||
{/foreach}
|
||||
@@ -45,4 +46,5 @@
|
||||
</form>
|
||||
</div>
|
||||
</fieldset>
|
||||
{/if}
|
||||
{/block}
|
||||
+2
-2
@@ -28,13 +28,13 @@
|
||||
<fieldset>
|
||||
<h3><i class="icon-cogs"></i> {l s='Filters'}</h3>
|
||||
<div class="filter-stock">
|
||||
<form type="get" class="form-horizontal">
|
||||
<form type="get" id="stock-movement-filter" class="form-horizontal">
|
||||
<input type="hidden" name="controller" value="AdminStockMvt" />
|
||||
<input type="hidden" name="token" value="{$token}" />
|
||||
<div class="form-group">
|
||||
<label for="id_warehouse" class="control-label col-lg-3">{l s='Filter movements by warehouse:'}</label>
|
||||
<div class="col-lg-9">
|
||||
<select name="id_warehouse" onChange="$(this).parent().submit();">
|
||||
<select name="id_warehouse" onChange="$('#stock-movement-filter').submit();">
|
||||
{foreach $list_warehouses as $warehouse}
|
||||
<option {if $warehouse.id_warehouse == $current_warehouse}selected="selected"{/if} value="{$warehouse.id_warehouse}">{$warehouse.name}</option>
|
||||
{/foreach}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="robots" content="NOFOLLOW, NOINDEX">
|
||||
<title>{$shop_name} {if $meta_title != ''}{$navigationPipe|escape:'htmlall':'UTF-8'} {$meta_title}{/if} (PrestaShop™)</title>
|
||||
<title>{$shop_name} {if $meta_title != ''}{if isset($navigationPipe)}{$navigationPipe|escape:'htmlall':'UTF-8'}{else}>{/if} {$meta_title}{/if} (PrestaShop™)</title>
|
||||
{if $display_header}
|
||||
<script type="text/javascript">
|
||||
var help_class_name = '{$controller_name}';
|
||||
@@ -102,9 +102,9 @@
|
||||
{/if}
|
||||
</head>
|
||||
|
||||
<body class="{if $employee->bo_menu}page-sidebar {* page-sidebar-closed *}{else}page-topbar{/if}">
|
||||
|
||||
{if $display_header}
|
||||
<body class="{if $employee->bo_menu}page-sidebar {* page-sidebar-closed *}{else}page-topbar{/if}">
|
||||
|
||||
{* begin HEADER *}
|
||||
<header id="header">
|
||||
<nav id="header_infos" role="navigation">
|
||||
@@ -280,23 +280,28 @@
|
||||
</nav>{* end header_infos*}
|
||||
</header>
|
||||
|
||||
{* end header*}
|
||||
{/if}
|
||||
|
||||
<div id="main">
|
||||
{include file='nav.tpl'}
|
||||
|
||||
<div id="content" class="page-content">
|
||||
{if $display_header && $install_dir_exists}
|
||||
{if $install_dir_exists}
|
||||
<div class="alert alert-warning">
|
||||
{l s='For security reasons, you must also:'} {l s='delete the /install folder'}
|
||||
</div>
|
||||
{/if}
|
||||
{if $display_header && $is_multishop && $shop_list && ($multishop_context & Shop::CONTEXT_GROUP || $multishop_context & Shop::CONTEXT_SHOP)}
|
||||
{if $is_multishop && $shop_list && ($multishop_context & Shop::CONTEXT_GROUP || $multishop_context & Shop::CONTEXT_SHOP)}
|
||||
<fieldset class="multishop_toolbar">
|
||||
<div class="col-lg-12 form-horizontal">
|
||||
<label class="control-label col-lg-3"><i class="icon-sitemap"></i> {l s='Multistore configuration for'}</label>
|
||||
<div class="col-lg-9">{$shop_list}</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
{/if}
|
||||
|
||||
{* end display_header*}
|
||||
{else}
|
||||
<body>
|
||||
<div id="main">
|
||||
<div id="content" class="page-content">
|
||||
{/if}
|
||||
@@ -89,6 +89,8 @@
|
||||
<input type="hidden" name="token" value="{$token}" />
|
||||
</fieldset>
|
||||
</form>
|
||||
{else}
|
||||
</fieldset>
|
||||
{/if}
|
||||
|
||||
{hook h='displayAdminListAfter'}
|
||||
|
||||
@@ -252,6 +252,10 @@
|
||||
</script>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{if $simple_header}
|
||||
<fieldset class="col-lg-12">
|
||||
<h3>{if is_array($title)}{$title|end}{else}{$title}{/if}</h3>
|
||||
{/if}
|
||||
<div class="table-responsive clearfix">
|
||||
<table
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
{include file='header.tpl'}
|
||||
|
||||
{if isset($conf)}
|
||||
<div class="alert alert-success">
|
||||
{$conf}
|
||||
@@ -91,5 +91,3 @@
|
||||
{if !$bootstrap}<div id="nobootstrap">{/if}
|
||||
{$page}
|
||||
{if !$bootstrap}</div>{/if}
|
||||
|
||||
{include file='footer.tpl'}
|
||||
@@ -679,8 +679,7 @@ class AdminControllerCore extends Controller
|
||||
'export_precontent' => "\xEF\xBB\xBF",
|
||||
'export_headers' => $headers,
|
||||
'export_content' => $content
|
||||
)
|
||||
);
|
||||
));
|
||||
|
||||
$this->layout = 'layout-export.tpl';
|
||||
}
|
||||
@@ -1284,20 +1283,32 @@ class AdminControllerCore extends Controller
|
||||
public function display()
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'display_header' => $this->display_header,
|
||||
'display_footer' => $this->display_footer,
|
||||
)
|
||||
);
|
||||
'display_header' => $this->display_header,
|
||||
'display_footer' => $this->display_footer,
|
||||
));
|
||||
|
||||
// Use page title from meta_title if it has been set else from the breadcrumbs array
|
||||
if (!$this->meta_title)
|
||||
$this->meta_title = strip_tags(is_array($this->toolbar_title) ? implode(' '.Configuration::get('PS_NAVIGATION_PIPE').' ', $this->toolbar_title) : $this->toolbar_title);
|
||||
$this->context->smarty->assign('meta_title', $this->meta_title);
|
||||
|
||||
$template_dirs = $this->context->smarty->getTemplateDir();
|
||||
|
||||
// Check if header/footer have been overriden
|
||||
$header_tpl = 'header.tpl';
|
||||
$footer_tpl = 'footer.tpl';
|
||||
foreach ($template_dirs as $template_dir)
|
||||
{
|
||||
if (file_exists($template_dir.DIRECTORY_SEPARATOR.'header.tpl'))
|
||||
$header_tpl = $template_dir.DIRECTORY_SEPARATOR.'header.tpl';
|
||||
if (file_exists($template_dir.DIRECTORY_SEPARATOR.'footer.tpl'))
|
||||
$footer_tpl = $template_dir.DIRECTORY_SEPARATOR.'footer.tpl';
|
||||
}
|
||||
|
||||
$tpl_action = $this->tpl_folder.$this->display.'.tpl';
|
||||
|
||||
// Check if action template has been overriden
|
||||
foreach ($this->context->smarty->getTemplateDir() as $template_dir)
|
||||
foreach ($template_dirs as $template_dir)
|
||||
if (file_exists($template_dir.DIRECTORY_SEPARATOR.$tpl_action) && $this->display != 'view' && $this->display != 'options')
|
||||
{
|
||||
if (method_exists($this, $this->display.Tools::toCamelCase($this->className)))
|
||||
@@ -1321,7 +1332,7 @@ class AdminControllerCore extends Controller
|
||||
$this->context->smarty->assign($type, $this->json ? Tools::jsonEncode(array_unique($this->$type)) : array_unique($this->$type));
|
||||
|
||||
$this->context->smarty->assign('page', $this->json ? Tools::jsonEncode($page) : $page);
|
||||
$this->smartyOutputContent($this->layout);
|
||||
$this->smartyOutputContent(array($header_tpl, $this->layout, $footer_tpl));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1974,12 +1985,10 @@ class AdminControllerCore extends Controller
|
||||
if ($this->display_header)
|
||||
$this->context->smarty->assign('displayBackOfficeHeader', Hook::exec('displayBackOfficeHeader', array()));
|
||||
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'displayBackOfficeTop' => Hook::exec('displayBackOfficeTop', array()),
|
||||
'submit_form_ajax' => (int)Tools::getValue('submitFormAjax')
|
||||
)
|
||||
);
|
||||
$this->context->smarty->assign(array(
|
||||
'displayBackOfficeTop' => Hook::exec('displayBackOfficeTop', array()),
|
||||
'submit_form_ajax' => (int)Tools::getValue('submitFormAjax')
|
||||
));
|
||||
|
||||
$this->initProcess();
|
||||
}
|
||||
|
||||
@@ -354,7 +354,11 @@ abstract class ControllerCore
|
||||
protected function smartyOutputContent($content)
|
||||
{
|
||||
$this->context->cookie->write();
|
||||
$this->context->smarty->display($content);
|
||||
if (is_array($content))
|
||||
foreach ($content as $tpl)
|
||||
$this->context->smarty->display($tpl);
|
||||
else
|
||||
$this->context->smarty->display($content);
|
||||
}
|
||||
|
||||
protected function isCached($template, $cacheId = null, $compileId = null)
|
||||
|
||||
@@ -37,6 +37,7 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
$this->context = Context::getContext();
|
||||
$this->table = 'stock';
|
||||
$this->className = 'Stock';
|
||||
$this->tpl_list_vars['show_filter'] = true;
|
||||
$this->lang = false;
|
||||
$this->multishop_context = Shop::CONTEXT_ALL;
|
||||
|
||||
@@ -106,7 +107,31 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
$this->page_header_toolbar_title = $this->l('Instant stock status');
|
||||
$this->page_header_toolbar_title = $this->l('Instant stock status');
|
||||
|
||||
if ($this->display == 'details')
|
||||
$this->page_header_toolbar_btn['back_to_list'] = array(
|
||||
'href' => Context::getContext()->link->getAdminLink('AdminStockInstantState').(Tools::getValue('id_warehouse') ? '&id_warehouse='.Tools::getValue('id_warehouse') : ''),
|
||||
'desc' => $this->l('Back to list'),
|
||||
'icon' => 'process-icon-back'
|
||||
);
|
||||
elseif (Tools::isSubmit('id_warehouse') && (int)Tools::getValue('id_warehouse') != -1)
|
||||
{
|
||||
$this->page_header_toolbar_btn['export-stock-state-quantities-csv'] = array(
|
||||
'short' => 'Export this list as CSV',
|
||||
'href' => $this->context->link->getAdminLink('AdminStockInstantState').'&csv_quantities&id_warehouse='.(int)$this->getCurrentCoverageWarehouse(),
|
||||
'desc' => $this->l('Export Quantities (CSV)'),
|
||||
'imgclass' => 'export'
|
||||
);
|
||||
|
||||
$this->page_header_toolbar_btn['export-stock-state-prices-csv'] = array(
|
||||
'short' => 'Export this list as CSV',
|
||||
'href' => $this->context->link->getAdminLink('AdminStockInstantState').'&csv_prices&id_warehouse='.(int)$this->getCurrentCoverageWarehouse(),
|
||||
'desc' => $this->l('Export Prices (CSV)'),
|
||||
'imgclass' => 'export'
|
||||
);
|
||||
}
|
||||
|
||||
parent::initPageHeaderToolbar();
|
||||
}
|
||||
|
||||
@@ -180,77 +205,148 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function renderDetails()
|
||||
{
|
||||
if (Tools::isSubmit('id_stock')) // if a product id is submit
|
||||
{
|
||||
$this->lang = false;
|
||||
$this->table = 'stock';
|
||||
$this->list_id = 'details';
|
||||
$this->tpl_list_vars['show_filter'] = false;
|
||||
$lang_id = (int)$this->context->language->id;
|
||||
$this->actions = array();
|
||||
$this->list_simple_header = true;
|
||||
$ids = explode('_', Tools::getValue('id_stock'));
|
||||
|
||||
if (count($ids) != 2)
|
||||
die;
|
||||
|
||||
$id_product = $ids[0];
|
||||
$id_product_attribute = $ids[1];
|
||||
$id_warehouse = Tools::getValue('id_warehouse', -1);
|
||||
$this->_select = 'IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name,
|
||||
w.id_currency, a.price_te, SUM(a.physical_quantity) as physical_quantity, SUM(a.usable_quantity) as usable_quantity,
|
||||
(a.price_te * SUM(a.physical_quantity)) as valuation';
|
||||
$this->_join = ' LEFT JOIN `'._DB_PREFIX_.'warehouse` AS w ON w.id_warehouse = a.id_warehouse';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
a.id_product = pl.id_product
|
||||
AND pl.id_lang = '.(int)$this->context->language->id.'
|
||||
)';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.id_product_attribute = a.id_product_attribute)';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'attribute` atr ON (atr.id_attribute = pac.id_attribute)';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (
|
||||
al.id_attribute = pac.id_attribute
|
||||
AND al.id_lang = '.(int)$this->context->language->id.'
|
||||
)';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (
|
||||
agl.id_attribute_group = atr.id_attribute_group
|
||||
AND agl.id_lang = '.(int)$this->context->language->id.'
|
||||
)';
|
||||
$this->_where = 'AND a.id_product = '.(int)$id_product.' AND a.id_product_attribute = '.(int)$id_product_attribute;
|
||||
|
||||
if ($id_warehouse != -1)
|
||||
$this->_where .= ' AND a.id_warehouse = '.(int)$id_warehouse;
|
||||
|
||||
$this->_groupBy = 'GROUP BY a.price_te';
|
||||
|
||||
self::$currentIndex = self::$currentIndex.'&id_stock='.Tools::getValue('id_stock').'&detailsstock';
|
||||
$this->processFilter();
|
||||
return parent::renderList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AdminController::getList() override
|
||||
* @see AdminController::getList()
|
||||
*/
|
||||
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
|
||||
{
|
||||
if ((Tools::isSubmit('csv_quantities') || Tools::isSubmit('csv_prices')) &&
|
||||
(int)Tools::getValue('id_warehouse') != -1)
|
||||
$limit = false;
|
||||
|
||||
$order_by_valuation = false;
|
||||
$order_by_real_quantity = false;
|
||||
|
||||
if ($this->context->cookie->{$this->table.'Orderby'} == 'valuation')
|
||||
if (Tools::isSubmit('id_stock'))
|
||||
{
|
||||
unset($this->context->cookie->{$this->table.'Orderby'});
|
||||
$order_by_valuation = true;
|
||||
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
|
||||
|
||||
$nb_items = count($this->_list);
|
||||
|
||||
for ($i = 0; $i < $nb_items; $i++)
|
||||
{
|
||||
$item = &$this->_list[$i];
|
||||
$manager = StockManagerFactory::getManager();
|
||||
$item['real_quantity'] = $manager->getProductRealQuantities(
|
||||
$item['id_product'],
|
||||
$item['id_product_attribute'],
|
||||
($this->getCurrentCoverageWarehouse() == -1 ? null : array($this->getCurrentCoverageWarehouse())),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
else if ($this->context->cookie->{$this->table.'Orderby'} == 'real_quantity')
|
||||
else
|
||||
{
|
||||
unset($this->context->cookie->{$this->table.'Orderby'});
|
||||
$order_by_real_quantity = true;
|
||||
if ((Tools::isSubmit('csv_quantities') || Tools::isSubmit('csv_prices')) &&
|
||||
(int)Tools::getValue('id_warehouse') != -1)
|
||||
$limit = false;
|
||||
|
||||
$order_by_valuation = false;
|
||||
$order_by_real_quantity = false;
|
||||
|
||||
if ($this->context->cookie->{$this->table.'Orderby'} == 'valuation')
|
||||
{
|
||||
unset($this->context->cookie->{$this->table.'Orderby'});
|
||||
$order_by_valuation = true;
|
||||
}
|
||||
else if ($this->context->cookie->{$this->table.'Orderby'} == 'real_quantity')
|
||||
{
|
||||
unset($this->context->cookie->{$this->table.'Orderby'});
|
||||
$order_by_real_quantity = true;
|
||||
}
|
||||
|
||||
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
|
||||
|
||||
$nb_items = count($this->_list);
|
||||
|
||||
for ($i = 0; $i < $nb_items; ++$i)
|
||||
{
|
||||
$item = &$this->_list[$i];
|
||||
|
||||
$item['price_te'] = '--';
|
||||
$item[$this->identifier] = $item['id_product'].'_'.$item['id_product_attribute'];
|
||||
|
||||
// gets stock manager
|
||||
$manager = StockManagerFactory::getManager();
|
||||
|
||||
// gets quantities and valuation
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(physical_quantity) as physical_quantity');
|
||||
$query->select('SUM(usable_quantity) as usable_quantity');
|
||||
$query->select('SUM(price_te * physical_quantity) as valuation');
|
||||
$query->from('stock');
|
||||
$query->where('id_product = '.(int)$item['id_product'].' AND id_product_attribute = '.(int)$item['id_product_attribute']);
|
||||
|
||||
if ($this->getCurrentCoverageWarehouse() != -1)
|
||||
$query->where('id_warehouse = '.(int)$this->getCurrentCoverageWarehouse());
|
||||
|
||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
|
||||
|
||||
$item['physical_quantity'] = $res['physical_quantity'];
|
||||
$item['usable_quantity'] = $res['usable_quantity'];
|
||||
|
||||
// gets real_quantity depending on the warehouse
|
||||
$item['real_quantity'] = $manager->getProductRealQuantities($item['id_product'],
|
||||
$item['id_product_attribute'],
|
||||
($this->getCurrentCoverageWarehouse() == -1 ? null : array($this->getCurrentCoverageWarehouse())),
|
||||
true);
|
||||
|
||||
// removes the valuation if the filter corresponds to 'all warehouses'
|
||||
if ($this->getCurrentCoverageWarehouse() == -1)
|
||||
$item['valuation'] = 'N/A';
|
||||
else
|
||||
$item['valuation'] = $res['valuation'];
|
||||
}
|
||||
|
||||
if ($this->getCurrentCoverageWarehouse() != -1 && $order_by_valuation)
|
||||
usort($this->_list, array($this, 'valuationCmp'));
|
||||
else if ($order_by_real_quantity)
|
||||
usort($this->_list, array($this, 'realQuantityCmp'));
|
||||
}
|
||||
|
||||
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
|
||||
|
||||
$nb_items = count($this->_list);
|
||||
|
||||
for ($i = 0; $i < $nb_items; ++$i)
|
||||
{
|
||||
$item = &$this->_list[$i];
|
||||
|
||||
$item['price_te'] = '--';
|
||||
$item[$this->identifier] = $item['id_product'].'_'.$item['id_product_attribute'];
|
||||
|
||||
// gets stock manager
|
||||
$manager = StockManagerFactory::getManager();
|
||||
|
||||
// gets quantities and valuation
|
||||
$query = new DbQuery();
|
||||
$query->select('SUM(physical_quantity) as physical_quantity');
|
||||
$query->select('SUM(usable_quantity) as usable_quantity');
|
||||
$query->select('SUM(price_te * physical_quantity) as valuation');
|
||||
$query->from('stock');
|
||||
$query->where('id_product = '.(int)$item['id_product'].' AND id_product_attribute = '.(int)$item['id_product_attribute']);
|
||||
|
||||
if ($this->getCurrentCoverageWarehouse() != -1)
|
||||
$query->where('id_warehouse = '.(int)$this->getCurrentCoverageWarehouse());
|
||||
|
||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
|
||||
|
||||
$item['physical_quantity'] = $res['physical_quantity'];
|
||||
$item['usable_quantity'] = $res['usable_quantity'];
|
||||
|
||||
// gets real_quantity depending on the warehouse
|
||||
$item['real_quantity'] = $manager->getProductRealQuantities($item['id_product'],
|
||||
$item['id_product_attribute'],
|
||||
($this->getCurrentCoverageWarehouse() == -1 ? null : array($this->getCurrentCoverageWarehouse())),
|
||||
true);
|
||||
|
||||
// removes the valuation if the filter corresponds to 'all warehouses'
|
||||
if ($this->getCurrentCoverageWarehouse() == -1)
|
||||
$item['valuation'] = 'N/A';
|
||||
else
|
||||
$item['valuation'] = $res['valuation'];
|
||||
}
|
||||
|
||||
if ($this->getCurrentCoverageWarehouse() != -1 && $order_by_valuation)
|
||||
usort($this->_list, array($this, 'valuationCmp'));
|
||||
else if ($order_by_real_quantity)
|
||||
usort($this->_list, array($this, 'realQuantityCmp'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,51 +395,6 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
return $warehouse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called when an ajax request is made
|
||||
* @see AdminController::postProcess()
|
||||
*/
|
||||
public function ajaxProcess()
|
||||
{
|
||||
if (Tools::isSubmit('id')) // if a product id is submit
|
||||
{
|
||||
$this->lang = false;
|
||||
$lang_id = (int)$this->context->language->id;
|
||||
$ids = explode('_', Tools::getValue('id'));
|
||||
if (count($ids) != 2)
|
||||
die;
|
||||
|
||||
$id_product = $ids[0];
|
||||
$id_product_attribute = $ids[1];
|
||||
$id_warehouse = Tools::getValue('id_warehouse', -1);
|
||||
|
||||
$query = new DbQuery();
|
||||
$query->select('w.id_currency, s.price_te, SUM(s.physical_quantity) as physical_quantity, SUM(s.usable_quantity) as usable_quantity,
|
||||
(s.price_te * SUM(s.physical_quantity)) as valuation');
|
||||
$query->from('stock', 's');
|
||||
$query->leftJoin('warehouse', 'w', 'w.id_warehouse = s.id_warehouse');
|
||||
$query->where('s.id_product = '.(int)$id_product.' AND s.id_product_attribute = '.(int)$id_product_attribute);
|
||||
if ($id_warehouse != -1)
|
||||
$query->where('s.id_warehouse = '.(int)$id_warehouse);
|
||||
$query->groupBy('s.price_te');
|
||||
|
||||
$datas = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
|
||||
foreach ($datas as &$data)
|
||||
{
|
||||
$currency = new Currency($data['id_currency']);
|
||||
if (Validate::isLoadedObject($currency))
|
||||
{
|
||||
$data['price_te'] = Tools::displayPrice($data['price_te'], $currency);
|
||||
$data['valuation'] = Tools::displayPrice($data['valuation'], $currency);
|
||||
}
|
||||
}
|
||||
|
||||
echo Tools::jsonEncode(array('data'=> $datas, 'fields_display' => $this->fields_list));
|
||||
}
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AdminController::initToolbar();
|
||||
*/
|
||||
@@ -355,12 +406,14 @@ class AdminStockInstantStateControllerCore extends AdminController
|
||||
'short' => 'Export this list as CSV',
|
||||
'href' => $this->context->link->getAdminLink('AdminStockInstantState').'&csv_quantities&id_warehouse='.(int)$this->getCurrentCoverageWarehouse(),
|
||||
'desc' => $this->l('Export Quantities (CSV)'),
|
||||
'imgclass' => 'export'
|
||||
);
|
||||
|
||||
$this->toolbar_btn['export-stock-state-prices-csv'] = array(
|
||||
'short' => 'Export this list as CSV',
|
||||
'href' => $this->context->link->getAdminLink('AdminStockInstantState').'&csv_prices&id_warehouse='.(int)$this->getCurrentCoverageWarehouse(),
|
||||
'desc' => $this->l('Export Prices (CSV)'),
|
||||
'imgclass' => 'export'
|
||||
);
|
||||
}
|
||||
parent::initToolbar();
|
||||
|
||||
@@ -112,7 +112,16 @@ class AdminStockMvtControllerCore extends AdminController
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
$this->page_header_toolbar_title = $this->l('Stock mouvement');
|
||||
$this->page_header_toolbar_title = $this->l('Stock mouvement');
|
||||
|
||||
if (Tools::isSubmit('id_warehouse') && (int)Tools::getValue('id_warehouse') != -1)
|
||||
$this->page_header_toolbar_btn['export-stock-mvt-csv'] = array(
|
||||
'short' => 'Export this list as CSV',
|
||||
'href' => $this->context->link->getAdminLink('AdminStockMvt').'&csv&id_warehouse='.(int)$this->getCurrentWarehouseId(),
|
||||
'desc' => $this->l('Export (CSV)'),
|
||||
'imgclass' => 'export'
|
||||
);
|
||||
|
||||
parent::initPageHeaderToolbar();
|
||||
}
|
||||
|
||||
@@ -244,13 +253,13 @@ class AdminStockMvtControllerCore extends AdminController
|
||||
public function initToolbar()
|
||||
{
|
||||
if (Tools::isSubmit('id_warehouse') && (int)Tools::getValue('id_warehouse') != -1)
|
||||
{
|
||||
$this->toolbar_btn['export-stock-mvt-csv'] = array(
|
||||
'short' => 'Export this list as CSV',
|
||||
'href' => $this->context->link->getAdminLink('AdminStockMvt').'&csv&id_warehouse='.(int)$this->getCurrentWarehouseId(),
|
||||
'desc' => $this->l('Export (CSV)'),
|
||||
'imgclass' => 'export'
|
||||
);
|
||||
}
|
||||
|
||||
parent::initToolbar();
|
||||
unset($this->toolbar_btn['new']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user