223 lines
8.2 KiB
PHP
223 lines
8.2 KiB
PHP
<?php
|
|
/**
|
|
* admin-display_class.php file defines method to display content tabs of admin page and module page form
|
|
*/
|
|
|
|
class BT_AdminDisplay implements BT_IAdmin
|
|
{
|
|
/**
|
|
* Magic Method __construct
|
|
*/
|
|
public function __construct()
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Magic Method __destruct
|
|
*/
|
|
public function __destruct()
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* run() method display all configured data admin
|
|
*
|
|
* @param array $aParam
|
|
* @return array
|
|
*/
|
|
public function run($aParam = null)
|
|
{
|
|
|
|
// set variables
|
|
$aDisplayData = array();
|
|
|
|
// get type
|
|
$aParam['sType'] = empty($aParam['sType'])? 'settings' : $aParam['sType'];
|
|
|
|
switch ($aParam['sType']) {
|
|
case 'settings' : // use case - display basic settings
|
|
case 'searchForm' : // use case - display search form of admin tab
|
|
require_once(_OTPR_PATH_LIB . 'module-dao_class.php');
|
|
|
|
// execute match function
|
|
$aDisplayData = call_user_func_array(array($this, '_display' . ucfirst($aParam['sType'])), array($aParam));
|
|
|
|
// check if orders detail have been registered
|
|
$aDisplayData['assign']['bRegisterOrders'] = BT_OtprModuleDao::isExistDiscountOrders();
|
|
$aDisplayData['assign']['sOrdersTplPath'] = _OTPR_PATH_TPL . _OTPR_TPL_ADMIN_PATH . _OTPR_TPL_REGISTER_ORDERS;
|
|
|
|
// check if 1.5 and multishop active and if group is selected
|
|
$bMultiShop = BT_OtprModuleTools::checkGroupMultiShop();
|
|
|
|
if ($bMultiShop && $aParam['sType'] != 'searchForm') {
|
|
$aDisplayData['assign']['bMultiGroupError'] = true;
|
|
$aDisplayData['assign']['sMultiTplPath'] = _OTPR_PATH_TPL . _OTPR_TPL_ADMIN_PATH . _OTPR_TPL_MULTI_SHOP;
|
|
}
|
|
break;
|
|
default :
|
|
break;
|
|
}
|
|
|
|
return $aDisplayData;
|
|
}
|
|
|
|
/**
|
|
* _displaySettings() method displays first page with all basic settings
|
|
*
|
|
* @param array $aPost
|
|
* @return array
|
|
*/
|
|
private function _displaySettings(array $aPost)
|
|
{
|
|
$aData = array();
|
|
|
|
// set date format translation
|
|
BT_OtprModuleTools::setDateFormatTitle();
|
|
|
|
// get token
|
|
if (version_compare(_PS_VERSION_, '1.5', '>')) {
|
|
$sAdminUrl = $_SERVER['SCRIPT_NAME'] . '?controller=AdminOrderTaxProfitReport&token=' . Tools::getAdminTokenLite('AdminOrderTaxProfitReport');
|
|
}
|
|
else {
|
|
$sAdminUrl = $_SERVER['SCRIPT_NAME'] . '?tab=AdminOrderTaxProfitReport&token=' .
|
|
Tools::getAdminToken('AdminOrderTaxProfitReport'.(int)(Tab::getIdFromClassName('AdminOrderTaxProfitReport')).(Tools::getValue('id_employee', OrderTaxProfitReport::$oCookie->id_employee)));
|
|
}
|
|
|
|
// set smarty variables
|
|
$aData['assign'] = array(
|
|
'bPS16' => version_compare(_PS_VERSION_, '1.6', '>'),
|
|
'bPS1606' => version_compare(_PS_VERSION_, '1.6.0.5', '>'),
|
|
'sURI' => BT_OtprModuleTools::truncateUri(),
|
|
'sActionSettings' => 'update',
|
|
'sTypeSettings' => 'settings',
|
|
'sDateFormat' => OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_DATE_FORMAT'],
|
|
'bUseHeadings' => OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_HEADINGS_TOTAL'],
|
|
'iFloatNumber' => OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_FLOAT_NUMBER'],
|
|
'sFloatSeparator' => OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_FLOAT_SEPARATOR'],
|
|
'bFixCellSize' => OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_FIX_CELL_SIZE'],
|
|
'iCellSize' => OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_CELL_SIZE'],
|
|
'iDefaultLang' => intval(OrderTaxProfitReport::$iCurrentLang),
|
|
'sHeaderTplPath' => _OTPR_PATH_TPL . _OTPR_TPL_ADMIN_PATH . _OTPR_TPL_HEADER,
|
|
'sModuleUptTplPath' => _OTPR_PATH_TPL . _OTPR_TPL_ADMIN_PATH . _OTPR_TPL_MODULE_UPDATE,
|
|
'aDateFormat' => $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'],
|
|
'sAdminTabUrl' => $sAdminUrl,
|
|
'sCurrentIso' => Language::getIsoById(OrderTaxProfitReport::$iCurrentLang),
|
|
'sDocUri' => _MODULE_DIR_ . _OTPR_MODULE_SET_NAME . '/',
|
|
'sDocName' => 'readme_' . ((OrderTaxProfitReport::$sCurrentLang == 'fr')? 'fr' : 'en') . '.pdf',
|
|
'sContactUs' => 'http://www.businesstech.fr/' . ((OrderTaxProfitReport::$sCurrentLang == 'fr')? 'fr/contactez-nous' : 'en/contact-us'),
|
|
'sTs' => time(),
|
|
);
|
|
|
|
// set tpl
|
|
$aData['tpl'] = _OTPR_TPL_ADMIN_PATH . _OTPR_TPL_SETTINGS;
|
|
|
|
return $aData;
|
|
}
|
|
|
|
/**
|
|
* _displaySearchForm() method displays search form of admin tab
|
|
*
|
|
* @param array $aPost
|
|
* @return array
|
|
*/
|
|
private function _displaySearchForm(array $aPost)
|
|
{
|
|
$aData = array();
|
|
|
|
// get templates
|
|
$aTemplates = BT_OtprModuleDao::getTemplates();
|
|
|
|
// set tpl title
|
|
BT_OtprModuleTools::getTranslatedTplTitle($aTemplates);
|
|
|
|
// set translation of columns title
|
|
BT_OtprModuleTools::setColTitle();
|
|
|
|
// get categories
|
|
$aCategories = BT_OtprModuleDao::getCategories();
|
|
|
|
// get different tax
|
|
$aTax = BT_OtprModuleDao::getTax();
|
|
|
|
// get different customer group
|
|
$aGroup = Group::getGroups(OrderTaxProfitReport::$iCurrentLang);
|
|
|
|
$aFormatGroup = array();
|
|
|
|
foreach ($aGroup as $iKey => $aGroupId) {
|
|
$aFormatGroup[$aGroupId['id_group']] = $aGroupId['name'];
|
|
}
|
|
unset($aGroup);
|
|
|
|
// add indent for each category => display combo with indentation
|
|
if (!empty($aCategories)) {
|
|
foreach ($aCategories as $nKey => &$aCategory) {
|
|
$aCategory['sIndent'] = str_repeat(' ', $aCategory['iNewLevel'] * 5);
|
|
}
|
|
}
|
|
|
|
if (!empty(OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_PREFERENCES'])) {
|
|
OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_PREFERENCES'] = unserialize(OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_PREFERENCES']);
|
|
}
|
|
|
|
// get preselection
|
|
$aSelection = !empty(OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_STATUS_SELECTION'])? unserialize(OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_STATUS_SELECTION']) : OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_STATUS_SELECTION'];
|
|
|
|
// get countries
|
|
$aCountries = Country::getCountries(OrderTaxProfitReport::$iCurrentLang, true);
|
|
|
|
// set smarty variables
|
|
$aData['assign'] = array(
|
|
'sURI' => (Tools::getIsset('sAdminTabURI')? Tools::getValue('sAdminTabURI') : BT_OtprModuleTools::truncateUri()),
|
|
'sActionExport' => 'export', /* use case - different submit in post method without XHR */
|
|
'aTypeExport' => $GLOBALS[_OTPR_MODULE_NAME . '_EXPORT_TYPE'],
|
|
'sDateFormat' => OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_DATE_FORMAT'],
|
|
'bUseHeadings' => OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_HEADINGS_TOTAL'],
|
|
'aPreferences' => OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_PREFERENCES'],
|
|
'aSelection' => $aSelection,
|
|
'iDefaultLang' => intval(OrderTaxProfitReport::$iCurrentLang),
|
|
'sDefaultLang' => OrderTaxProfitReport::$sCurrentLang,
|
|
'sHeaderTplPath' => _OTPR_PATH_TPL . _OTPR_TPL_ADMIN_PATH . _OTPR_TPL_HEADER,
|
|
'sModuleUptTplPath' => _OTPR_PATH_TPL . _OTPR_TPL_ADMIN_PATH . _OTPR_TPL_MODULE_UPDATE,
|
|
'aTemplates' => $aTemplates,
|
|
'aOrderStatusTitle' => BT_OtprModuleDao::getStatusOrder(),
|
|
'sDateFormat' => ((OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_DATE_FORMAT'] != false)? $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'][OrderTaxProfitReport::$aConfiguration[_OTPR_MODULE_NAME . '_DATE_FORMAT']]['format'] : $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT']['en']['format']) ,
|
|
'aSortGroupFields' => BT_OtprModuleTools::getSortFields(),
|
|
'aGroups' => $aFormatGroup,
|
|
'aTaxRate' => $aTax,
|
|
'aCategories' => $aCategories,
|
|
'aManufacturers' => Manufacturer::getManufacturers(),
|
|
'aSuppliers' => Supplier::getSuppliers(),
|
|
'aCountries' => ((count($aCountries) == 1)? false : $aCountries),
|
|
'aWayType' => $GLOBALS[_OTPR_MODULE_NAME . '_WAY'],
|
|
'bUseJqueryUI' => true,
|
|
'bUseJqueryFancy' => true,
|
|
'aImageSizes' => ImageType::getImagesTypes('products'),
|
|
'bSearchForm' => true,
|
|
'sCurrentIso' => Language::getIsoById(OrderTaxProfitReport::$iCurrentLang),
|
|
'bStockAdvanceEnable' => Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'),
|
|
);
|
|
|
|
// set tpl
|
|
$aData['tpl'] = _OTPR_TPL_FORM;
|
|
|
|
return $aData;
|
|
}
|
|
|
|
/**
|
|
* create() method manages singleton
|
|
*
|
|
* @return obj
|
|
*/
|
|
public static function create()
|
|
{
|
|
static $oDisplay;
|
|
|
|
if (null === $oDisplay) {
|
|
$oDisplay = new BT_AdminDisplay();
|
|
}
|
|
return $oDisplay;
|
|
}
|
|
} |