// Normalize
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12652 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -28,57 +28,55 @@
|
||||
abstract class ModuleGridCore extends Module
|
||||
{
|
||||
protected $_employee;
|
||||
|
||||
|
||||
/** @var string array graph data */
|
||||
protected $_values = array();
|
||||
|
||||
|
||||
/** @var integer total number of values **/
|
||||
protected $_totalCount = 0;
|
||||
|
||||
|
||||
/**@var string graph titles */
|
||||
protected $_title;
|
||||
|
||||
|
||||
/**@var integer start */
|
||||
protected $_start;
|
||||
|
||||
|
||||
/**@var integer limit */
|
||||
protected $_limit;
|
||||
|
||||
|
||||
/**@var string column name on which to sort */
|
||||
protected $_sort = null;
|
||||
|
||||
|
||||
/**@var string sort direction DESC/ASC */
|
||||
protected $_direction = null;
|
||||
|
||||
/** @var ModuleGridEngine grid engine */
|
||||
protected $_render;
|
||||
|
||||
public function install()
|
||||
{
|
||||
return (parent::install());
|
||||
}
|
||||
|
||||
abstract protected function getData();
|
||||
|
||||
public function setEmployee($id_employee)
|
||||
{
|
||||
$this->_employee = new Employee((int)($id_employee));
|
||||
$this->_employee = new Employee($id_employee);
|
||||
}
|
||||
|
||||
public function setLang($id_lang)
|
||||
{
|
||||
$this->_id_lang = $id_lang;
|
||||
}
|
||||
|
||||
|
||||
public function create($render, $type, $width, $height, $start, $limit, $sort, $dir)
|
||||
{
|
||||
if (!Tools::file_exists_cache($file = dirname(__FILE__).'/../modules/'.$render.'/'.$render.'.php'))
|
||||
die(Tools::displayError());
|
||||
require_once($file);
|
||||
$this->_render = new $render($type);
|
||||
|
||||
|
||||
$this->_start = $start;
|
||||
$this->_limit = $limit;
|
||||
$this->_sort = $sort;
|
||||
$this->_direction = $dir;
|
||||
|
||||
|
||||
$this->getData();
|
||||
|
||||
$this->_render->setTitle($this->_title);
|
||||
@@ -87,32 +85,32 @@ abstract class ModuleGridCore extends Module
|
||||
$this->_render->setTotalCount($this->_totalCount);
|
||||
$this->_render->setLimit($this->_start, $this->_limit);
|
||||
}
|
||||
|
||||
|
||||
public function render()
|
||||
{
|
||||
$this->_render->render();
|
||||
}
|
||||
|
||||
|
||||
public function engine($params)
|
||||
{
|
||||
if (!($render = Configuration::get('PS_STATS_GRID_RENDER')))
|
||||
return Tools::displayError('No grid engine selected');
|
||||
if (!file_exists(dirname(__FILE__).'/../modules/'.$render.'/'.$render.'.php'))
|
||||
return Tools::displayError('Grid engine selected is unavailable.');
|
||||
|
||||
|
||||
$grider = 'grider.php?render='.$render.'&module='.Tools::safeOutput(Tools::getValue('module'));
|
||||
|
||||
|
||||
$context = Context::getContext();
|
||||
$grider .= '&id_employee='.(int)($context->employee->id);
|
||||
$grider .= '&id_lang='.(int)($context->language->id);
|
||||
|
||||
if (!isset($params['width']) OR !Validate::IsUnsignedInt($params['width']))
|
||||
$grider .= '&id_employee='.(int)$context->employee->id;
|
||||
$grider .= '&id_lang='.(int)$context->language->id;
|
||||
|
||||
if (!isset($params['width']) || !Validate::IsUnsignedInt($params['width']))
|
||||
$params['width'] = 600;
|
||||
if (!isset($params['height']) OR !Validate::IsUnsignedInt($params['height']))
|
||||
if (!isset($params['height']) || !Validate::IsUnsignedInt($params['height']))
|
||||
$params['height'] = 920;
|
||||
if (!isset($params['start']) OR !Validate::IsUnsignedInt($params['start']))
|
||||
if (!isset($params['start']) || !Validate::IsUnsignedInt($params['start']))
|
||||
$params['start'] = 0;
|
||||
if (!isset($params['limit']) OR !Validate::IsUnsignedInt($params['limit']))
|
||||
if (!isset($params['limit']) || !Validate::IsUnsignedInt($params['limit']))
|
||||
$params['limit'] = 40;
|
||||
|
||||
$grider .= '&width='.$params['width'];
|
||||
@@ -129,11 +127,11 @@ abstract class ModuleGridCore extends Module
|
||||
$grider .= '&sort='.$params['sort'];
|
||||
if (isset($params['dir']) && Validate::isSortDirection($params['dir']))
|
||||
$grider .= '&dir='.$params['dir'];
|
||||
|
||||
|
||||
require_once(dirname(__FILE__).'/../modules/'.$render.'/'.$render.'.php');
|
||||
return call_user_func(array($render, 'hookGridEngine'), $params, $grider);
|
||||
}
|
||||
|
||||
|
||||
protected function csvExport($datas)
|
||||
{
|
||||
$this->_sort = $datas['defaultSortColumn'];
|
||||
@@ -144,23 +142,23 @@ abstract class ModuleGridCore extends Module
|
||||
|
||||
if (isset($datas['option']))
|
||||
$this->setOption($datas['option'], $layers);
|
||||
|
||||
if (sizeof($datas['columns']))
|
||||
|
||||
if (count($datas['columns']))
|
||||
{
|
||||
foreach ($datas['columns'] AS $column)
|
||||
foreach ($datas['columns'] as $column)
|
||||
$this->_csv .= $column['header'].';';
|
||||
$this->_csv = rtrim($this->_csv, ';')."\n";
|
||||
|
||||
foreach ($this->_values AS $value)
|
||||
|
||||
foreach ($this->_values as $value)
|
||||
{
|
||||
foreach ($datas['columns'] AS $column)
|
||||
foreach ($datas['columns'] as $column)
|
||||
$this->_csv .= $value[$column['dataIndex']].';';
|
||||
$this->_csv = rtrim($this->_csv, ';')."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_displayCsv();
|
||||
}
|
||||
|
||||
|
||||
protected function _displayCsv()
|
||||
{
|
||||
ob_end_clean();
|
||||
@@ -169,13 +167,12 @@ abstract class ModuleGridCore extends Module
|
||||
echo $this->_csv;
|
||||
exit;
|
||||
}
|
||||
|
||||
abstract protected function getData();
|
||||
|
||||
|
||||
public function getDate()
|
||||
{
|
||||
return ModuleGraph::getDateBetween($this->_employee);
|
||||
}
|
||||
|
||||
public function getLang()
|
||||
{
|
||||
return $this->_id_lang;
|
||||
|
||||
Reference in New Issue
Block a user