2012 lines
65 KiB
PHP
2012 lines
65 KiB
PHP
<?php
|
|
/**
|
|
* common.conf.php file defines all needed constants and variables for all using module context - install / admin / tab
|
|
*/
|
|
|
|
/* defines module name
|
|
* uses => set short name of module
|
|
*/
|
|
define('_OTPR_MODULE_NAME', 'OTPR');
|
|
|
|
/* defines set module name
|
|
* uses => on setting name of module
|
|
*/
|
|
define('_OTPR_MODULE_SET_NAME', 'ordertaxprofitreport');
|
|
|
|
/* defines root path of module
|
|
* uses => with all included files
|
|
*/
|
|
define('_OTPR_PATH_ROOT', _PS_MODULE_DIR_ . _OTPR_MODULE_SET_NAME . '/');
|
|
|
|
/* defines conf path
|
|
* uses => with including conf files in match environment
|
|
*/
|
|
define('_OTPR_PATH_CONF', _OTPR_PATH_ROOT . 'conf/');
|
|
|
|
/* defines libraries path
|
|
* uses => with all class files
|
|
*/
|
|
define('_OTPR_PATH_LIB', _OTPR_PATH_ROOT . 'lib/');
|
|
|
|
/* defines common library path
|
|
* uses => to include class files
|
|
*/
|
|
define('_OTPR_PATH_LIB_COMMON', _OTPR_PATH_LIB . 'common/');
|
|
|
|
/* defines sql path
|
|
* uses => with all SQL script
|
|
*/
|
|
define('_OTPR_PATH_SQL', _OTPR_PATH_ROOT . 'sql/');
|
|
|
|
/* defines views folder
|
|
* uses => to include css / js / templates files
|
|
*/
|
|
define('_OTPR_PATH_VIEWS', 'views/');
|
|
|
|
/* defines js URL
|
|
* uses => to include js files on templates (use prestashop constant _MODULE_DIR_)
|
|
*/
|
|
define('_OTPR_URL_JS', _MODULE_DIR_ . _OTPR_MODULE_SET_NAME . '/' ._OTPR_PATH_VIEWS . '/js/');
|
|
|
|
/* defines css URL
|
|
* uses => to include css files on templates (use prestashop constant _MODULE_DIR_)
|
|
*/
|
|
define('_OTPR_URL_CSS', _MODULE_DIR_ . _OTPR_MODULE_SET_NAME . '/' . _OTPR_PATH_VIEWS . '/css/');
|
|
|
|
/* defines img path
|
|
* uses => to include all used images
|
|
*/
|
|
define('_OTPR_PATH_IMG', _OTPR_MODULE_SET_NAME . '/' . _OTPR_PATH_VIEWS . 'img/');
|
|
|
|
/* defines img URL
|
|
* uses => to include img files in templates (use prestashop constant _MODULE_DIR_)
|
|
*/
|
|
define('_OTPR_URL_IMG', _MODULE_DIR_ . '/' . _OTPR_PATH_IMG);
|
|
|
|
/* defines tpl path name
|
|
* uses => with included templates
|
|
*/
|
|
define('_OTPR_PATH_TPL_NAME', _OTPR_PATH_VIEWS . 'templates/');
|
|
|
|
/* defines tpl path
|
|
* uses => with included templates
|
|
*/
|
|
define('_OTPR_PATH_TPL', _OTPR_PATH_ROOT . _OTPR_PATH_TPL_NAME);
|
|
|
|
/* defines error tpl
|
|
* uses => with display error - transverse tpl
|
|
*/
|
|
define('_OTPR_TPL_ERROR', _OTPR_PATH_TPL_NAME . 'admin/error.tpl');
|
|
|
|
/* defines activate / desactivate debug mode
|
|
* uses => only in debug / programming mode
|
|
*/
|
|
define('_OTPR_DEBUG', false);
|
|
|
|
/* defines variable for setting configuration options
|
|
* uses => with install or update action - declare all mandatory values stored by prestashop in module using
|
|
*/
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_CONFIGURATION'] = array(
|
|
_OTPR_MODULE_NAME . '_MODULE_VERSION' => '0',
|
|
_OTPR_MODULE_NAME . '_DATE_FORMAT' => 'en',
|
|
_OTPR_MODULE_NAME . '_HEADINGS_TOTAL' => 1,
|
|
_OTPR_MODULE_NAME . '_STATUS_SELECTION' => '',
|
|
_OTPR_MODULE_NAME . '_PREFERENCES' => '',
|
|
_OTPR_MODULE_NAME . '_FLOAT_NUMBER' => 2,
|
|
_OTPR_MODULE_NAME . '_FLOAT_SEPARATOR' => '.',
|
|
_OTPR_MODULE_NAME . '_FIX_CELL_SIZE' => 0,
|
|
_OTPR_MODULE_NAME . '_CELL_SIZE' => 115,
|
|
);
|
|
|
|
/* defines variable for setting admin tab title
|
|
* uses => in install / ADMIN mode
|
|
*/
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_TABS'] = array(
|
|
'AdminOrderTaxProfitReport' => array(
|
|
'lang' => array(
|
|
'en' => 'Order Tax Profit Report',
|
|
'fr' => 'Rapport Commandes TVA Bénéfices',
|
|
'es' => 'Beneficios IVA Informe Controles',
|
|
'de' => 'Vorteile Berichtsteuerelemente',
|
|
'it' => 'Vantaggi IVA Segnala Controls'
|
|
),
|
|
'parent' => ((version_compare(_PS_VERSION_, '1.5.0', '>'))? 'AdminParentOrders' : 'AdminOrders'), // name of parent tab, go in BO check id of concerned tab
|
|
),
|
|
);
|
|
|
|
/* defines variable for setting hooks
|
|
* uses => in INSTALL / ADMIN / HOOK mode
|
|
*/
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_HOOKS'] = array('newOrder' => '');
|
|
|
|
if (version_compare(_PS_VERSION_, '1.5', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_HOOKS']['validateOrder'] = 'Action';
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_HOOKS']['orderStatusPostUpdate'] = 'Action';
|
|
}
|
|
|
|
/* defines variable for english and french date format
|
|
* uses => with admin interface
|
|
*/
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'] = array(
|
|
'en' => array(
|
|
'format' => 'mm/dd/yy',
|
|
'sql' => '%m/%d/%Y',
|
|
'label' => '',
|
|
),
|
|
'fr' => array(
|
|
'format' => 'dd/mm/yy',
|
|
'sql' => '%d/%m/%Y',
|
|
'label' => '',
|
|
),
|
|
);
|
|
|
|
/* defines if constant module is defined */
|
|
$sConfDateFormat = (!Configuration::get(_OTPR_MODULE_NAME . '_DATE_FORMAT')? 'en' : Configuration::get(_OTPR_MODULE_NAME . '_DATE_FORMAT'));
|
|
|
|
/* defines variable for english and french date format
|
|
* uses => with admin interface
|
|
*/
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_SQL_TABLES'] = array(
|
|
'discount' => array('name' => 'discount', 'prefix' => 'DISC', 'totalField' => 'discounts'),
|
|
'wrapping' => array('name' => 'wrapping', 'prefix' => 'WRA', 'totalField' => 'wrapping'),
|
|
'wholesale_price' => array('name' => 'wholesale_price', 'prefix' => 'WHP', 'totalField' => 'wholesale_price'),
|
|
);
|
|
|
|
/* defines variable for columns used in report
|
|
* ADD column => add in $GLOBALS[_OTPR_MODULE_NAME . '_COLS'] below by copying pasting
|
|
* Don't forget to add a matched line in module-tools_class.php file at setColTitle() function in order to translate a technical field name
|
|
* uses => with install / admin interface
|
|
*/
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array(
|
|
'shop_name' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => ((version_compare(_PS_VERSION_, '1.5', '>'))? 's.name as shop_name' : '" " as shop_name'),
|
|
'type' => 's',
|
|
'sort' => 2,
|
|
'realname' => 'shop_name',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => ((version_compare(_PS_VERSION_, '1.5', '>'))? '' : Configuration::get('PS_SHOP_NAME')),
|
|
'group' => array('order', 'product', 'brand', 'supplier', 'category'),
|
|
),
|
|
'id_order' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'o.id_order',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'o.id_order',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'credit'),
|
|
),
|
|
'invoice_number' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'o.invoice_number',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'o.invoice_number',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'delivery_number' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'o.delivery_number',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'o.delivery_number',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'ord_date_add' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'DATE_FORMAT(o.date_add, "' . $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'][$sConfDateFormat]['sql'] . '") as ord_date_add',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'o.date_add',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'ord_date_upd' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'DATE_FORMAT(o.date_upd, "' . $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'][$sConfDateFormat]['sql'] . '") as ord_date_upd',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'o.date_upd',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'order_state' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'osl.name as order_state',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'osl.name',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'ord_carrier' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'car.name as ord_carrier',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'car.name',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'ord_payment_method' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'o.payment as ord_payment_method',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'o.payment',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'credit'),
|
|
),
|
|
'ord_delivery_date' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'DATE_FORMAT(o.delivery_date, "' . $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'][$sConfDateFormat]['sql'] . '") as ord_delivery_date',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'ord_delivery_date',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'ord_invoice_date' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'DATE_FORMAT(o.invoice_date, "' . $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'][$sConfDateFormat]['sql'] . '") as ord_invoice_date',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'ord_invoice_date',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'credit'),
|
|
),
|
|
'total_paid' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'o.total_paid / ' . (version_compare(_PS_VERSION_, '1.4.0.1') != -1 ? 'o.conversion_rate' : 'cu.conversion_rate') . ' as total_paid',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_paid',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'total_paid_real' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'o.total_paid_real / ' . (version_compare(_PS_VERSION_, '1.4.0.1') != -1 ? 'o.conversion_rate' : 'cu.conversion_rate') . ' as total_paid_real',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_paid_real',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
// 'total_products_no_tax' => array(
|
|
// 'use' => true,
|
|
// 'display' => true,
|
|
// 'db' => 'o.total_products / ' . (version_compare(_PS_VERSION_, '1.4.0.1') != -1 ? 'o.conversion_rate' : 'cu.conversion_rate') . ' as total_products_no_tax',
|
|
// 'type' => 'n',
|
|
// 'sort' => 1,
|
|
// 'realname' => 'total_products',
|
|
// 'title' => '',
|
|
// 'prefix' => '',
|
|
// 'suffix' => '',
|
|
// 'group' => array('order', 'customer'),
|
|
// ),
|
|
'total_discounts_no_tax' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '- SUM(ood.DISC_TAX_EXCL / ' . (version_compare(_PS_VERSION_, '1.4.0.1') != -1 ? 'o.conversion_rate' : 'cu.conversion_rate') . ') as total_discounts_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_discounts_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'product', 'brand', 'supplier', 'category', 'customer'),
|
|
),
|
|
'discounts_tax_amount' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '- SUM(ood.DISC_TAX_AMOUNT / ' . (version_compare(_PS_VERSION_, '1.4.0.1') != -1 ? 'o.conversion_rate' : 'cu.conversion_rate') . ') as discounts_tax_amount',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'discounts_tax_amount',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'product', 'brand', 'supplier', 'category'),
|
|
),
|
|
'total_wrapping_no_tax' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'oow.WRA_TAX_EXCL / ' . (version_compare(_PS_VERSION_, '1.4.0.1') != -1 ? 'o.conversion_rate' : 'cu.conversion_rate') . ' as total_wrapping_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_wrapping_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'wrapping_tax_amount' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'oow.WRA_TAX_AMOUNT / ' . (version_compare(_PS_VERSION_, '1.4.0.1') != -1 ? 'o.conversion_rate' : 'cu.conversion_rate') . ' as wrapping_tax_amount',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'wrapping_tax_amount',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'ecotax_no_tax' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity * (od.ecotax / ' . (version_compare(_PS_VERSION_, '1.3.3', '<') ? '(1 + (od.tax_rate / 100))' : '1' ) . ' / ' . (version_compare(_PS_VERSION_, '1.4.0.1', '>') ? 'o.conversion_rate' : 'cu.conversion_rate') . ')) as ecotax_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'ecotax_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'product', 'brand', 'supplier', 'category'),
|
|
),
|
|
);
|
|
|
|
/* hack for over 1.5 */
|
|
if (version_compare(_PS_VERSION_, '1.5', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_products_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
// 'db' => 'SUM(od.product_quantity * (od.product_price - (od.reduction_amount / (1 + (IF(t.rate IS NOT NULL, t.rate, 0) / 100)))) * (1 - (od.reduction_percent / 100)) / o.conversion_rate) as total_products_no_tax',
|
|
'db' => 'SUM(od.product_quantity * (od.unit_price_tax_excl / o.conversion_rate)) as total_products_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_products_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'customer'),
|
|
);
|
|
}
|
|
/* hack for over 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.4.0.1', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_products_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity * ((od.product_price * (1 - (od.group_reduction / 100))) - (od.reduction_amount / (1 + (od.tax_rate / 100)))) * (1 - (od.reduction_percent / 100)) / o.conversion_rate) as total_products_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_products_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'customer'),
|
|
);
|
|
}
|
|
/* hack for 1.3.2.3 to 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.3.2.2', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_products_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity * (((od.product_price + (od.product_quantity_discount / (1 + (od.tax_rate / 100))) - (od.reduction_amount ' . (version_compare(_PS_VERSION_, '1.3.2.3', '>')?' * (1 - (od.group_reduction / 100))' : '') . ')) * (1 - (od.reduction_percent / 100)) - (od.product_quantity_discount / (1 + (od.tax_rate / 100))) )) / cu.conversion_rate) as total_products_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_products_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'customer'),
|
|
);
|
|
}
|
|
/* hack for under 1.3.2.3 */
|
|
else {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_products_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity * od.product_price / cu.conversion_rate) as total_products_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_products_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'customer'),
|
|
);
|
|
}
|
|
|
|
/* ecotax hack for < 1.3.3 */
|
|
if (version_compare(_PS_VERSION_, '1.3.3', '<')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['ecotax_tax_amount'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity * (od.ecotax - (od.ecotax / (1 + (od.tax_rate / 100))) / ' . (version_compare(_PS_VERSION_, '1.4.0.1', '>') ? 'o.conversion_rate' : 'cu.conversion_rate') . ')) as ecotax_tax_amount',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'ecotax_tax_amount',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'product', 'brand', 'supplier', 'category'),
|
|
);
|
|
}
|
|
/* ecotax hack for > 1.3.3 */
|
|
else {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['ecotax_tax_amount'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity * (od.ecotax * (od.ecotax_tax_rate / 100) / ' . (version_compare(_PS_VERSION_, '1.4.0.1', '>') ? 'o.conversion_rate' : 'cu.conversion_rate') . ')) as ecotax_tax_amount',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'ecotax_tax_amount',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'product', 'brand', 'supplier', 'category'),
|
|
);
|
|
}
|
|
|
|
/* hack for over 1.5 */
|
|
if (version_compare(_PS_VERSION_, '1.5', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_prod_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
// 'db' => 'SUM(((od.product_price - (od.reduction_amount / (1 + (IF(t.rate IS NOT NULL, t.rate, 0) / 100)))) * (1 - (od.reduction_percent / 100))) * od.product_quantity * (IF(t.rate IS NOT NULL, t.rate, 0) / 100) / o.conversion_rate) as total_prod_tax',
|
|
'db' => 'SUM(od.product_quantity * od.unit_price_tax_excl * (IF(t.rate IS NOT NULL, t.rate, 0) / 100) / o.conversion_rate) as total_prod_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_prod_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'product', 'brand', 'supplier', 'category', 'customer'),
|
|
);
|
|
}
|
|
/* hack for over 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.4.0.1', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_prod_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM((((od.product_price * (1 - (od.group_reduction / 100))) - (od.reduction_amount / (1 + (od.tax_rate / 100)))) * (1 - (od.reduction_percent / 100))) * od.product_quantity * (od.tax_rate / 100) / o.conversion_rate) as total_prod_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_prod_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'product', 'customer'),
|
|
);
|
|
}
|
|
/* hack for 1.3.2.3 to 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.3.2.2', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_prod_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(((od.product_price + (od.product_quantity_discount / (1 + (od.tax_rate / 100))) - od.reduction_amount' . (version_compare(_PS_VERSION_, '1.3.2.3', '>')?' * (1 - (od.group_reduction / 100))' : '') . ') * (1 - (od.reduction_percent / 100)) - (od.product_quantity_discount / (1 + (od.tax_rate / 100))) ) * od.product_quantity * (od.tax_rate / 100) / cu.conversion_rate ) as total_prod_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_prod_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'product', 'customer'),
|
|
);
|
|
}
|
|
/* hack under 1.3.2.3 */
|
|
else {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_prod_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_price * od.product_quantity * (od.tax_rate / 100) / cu.conversion_rate ) as total_prod_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_prod_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'product', 'customer'),
|
|
);
|
|
}
|
|
|
|
/* use case - only for over 1.4 version */
|
|
if (version_compare(_PS_VERSION_, '1.4.0', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_shipping_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '( o.total_shipping - (o.total_shipping / ( 1 + (o.carrier_tax_rate / 100)))) / o.conversion_rate as total_shipping_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_shipping_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
);
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_shipping'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '(o.total_shipping / ( 1 + (o.carrier_tax_rate / 100))) / o.conversion_rate as total_shipping',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_shipping',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
);
|
|
}
|
|
else {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_shipping_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '( o.total_shipping - (o.total_shipping / ( 1 + IF(ct.rate IS NOT NULL, (ct.rate / 100), 0)))) / cu.conversion_rate as total_shipping_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_shipping_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
);
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_shipping'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '(o.total_shipping / ( 1 + IF(ct.rate IS NOT NULL, (ct.rate / 100), 0))) / cu.conversion_rate as total_shipping',
|
|
'type' => 'n',
|
|
'sort' => 0,
|
|
'realname' => 'total_shipping',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
);
|
|
}
|
|
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['total_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as total_tax',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'total_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
'calculate' => array(
|
|
'unit' => array('total_prod_tax', 'total_shipping_tax', 'discounts_tax_amount', 'wrapping_tax_amount'),
|
|
'global' => array('total_prod_tax', 'total_shipping_tax', 'discounts_tax_amount', 'wrapping_tax_amount'),
|
|
),
|
|
);
|
|
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array_merge($GLOBALS[_OTPR_MODULE_NAME . '_COLS'], array(
|
|
'total_cost' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(owp.WHP_PRICE * od.product_quantity) as total_cost',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'total_cost',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'customer'),
|
|
),
|
|
'price' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'ROUND(p.price, 2) as price',
|
|
'type' => 'n',
|
|
'sort' => 0,
|
|
'realname' => 'o.price',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
));
|
|
|
|
|
|
/* hack for over 1.5 */
|
|
if (version_compare(_PS_VERSION_, '1.5', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['gross_profit'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
// 'db' => 'SUM((((od.product_price - (od.reduction_amount / (1 + (IF(t.rate IS NOT NULL, t.rate, 0) / 100)))) * (1 - (od.reduction_percent / 100)) / o.conversion_rate) - (owp.WHP_PRICE )) * od.product_quantity ) as gross_profit',
|
|
'db' => 'SUM(((od.unit_price_tax_excl / o.conversion_rate) - owp.WHP_PRICE) * od.product_quantity) as gross_profit',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'gross_profit',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'customer'),
|
|
);
|
|
}
|
|
/* hack for over 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.4.0.1', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['gross_profit'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(((((od.product_price * (1 - (od.group_reduction / 100))) - (od.reduction_amount / (1 + (od.tax_rate / 100)))) * (1 - (od.reduction_percent / 100)) / o.conversion_rate) - (IF(pa.wholesale_price <> 0 AND pa.wholesale_price IS NOT NULL, pa.wholesale_price, p.wholesale_price))) * od.product_quantity ) as gross_profit',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'gross_profit',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'customer'),
|
|
);
|
|
}
|
|
/* hack for 1.3.2.3 to 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.3.2.2', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['gross_profit'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(((((od.product_price + (od.product_quantity_discount / (1 + (od.tax_rate / 100))) - od.reduction_amount) ' . (version_compare(_PS_VERSION_, '1.3.2.3', '>')?' * (1 - (od.group_reduction / 100))' : '') . ' * (1 - (od.reduction_percent / 100)) - (od.product_quantity_discount / (1 + (od.tax_rate / 100))) ) / cu.conversion_rate) - (IF(pa.wholesale_price <> 0 AND pa.wholesale_price IS NOT NULL, pa.wholesale_price, p.wholesale_price))) * od.product_quantity ) as gross_profit',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'gross_profit',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'customer'),
|
|
);
|
|
}
|
|
/* hack under 1.3.2.3 */
|
|
else {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['gross_profit'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM((((od.product_price / cu.conversion_rate) - IF(pa.wholesale_price <> 0 AND pa.wholesale_price IS NOT NULL, pa.wholesale_price, p.wholesale_price)) * od.product_quantity) ) as gross_profit',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'gross_profit',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'customer'),
|
|
);
|
|
}
|
|
|
|
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array_merge($GLOBALS[_OTPR_MODULE_NAME . '_COLS'], array(
|
|
'net_profit' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as net_profit',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'net_profit',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'customer'),
|
|
'calculate' => array(
|
|
'global' => array('gross_profit', 'total_discounts_no_tax', 'total_wrapping_no_tax'),
|
|
'unit' => array('gross_profit', 'total_discounts_no_tax', 'total_wrapping_no_tax'),
|
|
),
|
|
),
|
|
'gross_margin' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as gross_margin',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'gross_margin',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('order', 'customer'),
|
|
'calculate' => array(
|
|
'unit' => array('gross_profit', 'total_products_no_tax', '100'),
|
|
'global' => array('gross_profit', 'total_products_no_tax', '100'),
|
|
),
|
|
),
|
|
'net_margin' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as net_margin',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'net_margin',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('order', 'customer'),
|
|
'calculate' => array(
|
|
'global' => array('total_products_no_tax', 'total_discounts_no_tax', 'total_wrapping_no_tax', 'total_cost', 'total_products_no_tax', 'total_discounts_no_tax', 'total_wrapping_no_tax', '100'),
|
|
'unit' => array('total_products_no_tax', 'total_discounts_no_tax', 'total_wrapping_no_tax', 'total_cost', 'total_products_no_tax', 'total_discounts_no_tax', 'total_wrapping_no_tax', '100'),
|
|
),
|
|
),
|
|
/* For product report */
|
|
'id_product' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'p.id_product as id_product',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'p.id_product',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product'),
|
|
),
|
|
'product_name' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'od.product_name as product_name',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'product_name',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product'),
|
|
'defaulttext' => '',
|
|
),
|
|
'product_ref' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'p.reference as product_ref',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'product_ref',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product'),
|
|
'defaulttext' => '',
|
|
),
|
|
'product_ean' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'p.ean13 as product_ean',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'product_ean',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product'),
|
|
'defaulttext' => '',
|
|
),
|
|
'product_upc' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => ((version_compare(_PS_VERSION_, '1.4', '>'))? 'p.upc as product_upc' : '0 as product_upc'),
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'product_upc',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product'),
|
|
'defaulttext' => '',
|
|
),
|
|
'product_supplier_ref' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => (version_compare(_PS_VERSION_, '1.5', '>')? 'ps.product_supplier_reference' : 'p.supplier_reference') . ' as product_supplier_ref',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'product_supplier_ref',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product'),
|
|
'defaulttext' => '',
|
|
),
|
|
'prod_total_quantity' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity) as prod_total_quantity',
|
|
'type' => 'i',
|
|
'sort' => 1,
|
|
'realname' => 'prod_total_quantity',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'brand', 'supplier', 'category'),
|
|
),
|
|
));
|
|
|
|
/* use case - only for over 1.5 version */
|
|
if (version_compare(_PS_VERSION_, '1.5', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['prod_tax_rate'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 't.rate as prod_tax_rate',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_tax_rate',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('product'),
|
|
'calculate' => array(
|
|
'global' => array('0'),
|
|
),
|
|
);
|
|
}
|
|
else {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['prod_tax_rate'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'tax_rate as prod_tax_rate',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_tax_rate',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('product'),
|
|
'calculate' => array(
|
|
'global' => array('0'),
|
|
),
|
|
);
|
|
}
|
|
|
|
/* hack for over 1.5 */
|
|
if (version_compare(_PS_VERSION_, '1.5', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['prod_unit_price'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
// 'db' => 'AVG((od.product_price - (od.reduction_amount / (1 + (IF(t.rate IS NOT NULL, t.rate, 0) / 100)))) * (1 - (od.reduction_percent / 100)) / o.conversion_rate) as prod_unit_price',
|
|
'db' => 'AVG(od.unit_price_tax_excl / o.conversion_rate) as prod_unit_price',
|
|
// 'install' => 'od.product_price - (od.reduction_amount / (1 + (IF(t.rate IS NOT NULL, t.rate, 0) / 100)))) * (1 - (od.reduction_percent / 100)) / o.conversion_rate as prod_unit_price',
|
|
'install' => '(od.unit_price_tax_excl / o.conversion_rate) as prod_unit_price',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_unit_price',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'brand', 'supplier', 'category'),
|
|
'calculate' => array(
|
|
'global' => array('0'),
|
|
),
|
|
);
|
|
}
|
|
/* hack for over 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.4.0.1', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['prod_unit_price'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'AVG((od.product_price - (od.reduction_amount / (1 + (od.tax_rate / 100)))) * (1 - (od.reduction_percent / 100)) / o.conversion_rate) as prod_unit_price',
|
|
'install' => '(od.product_price - (od.reduction_amount / (1 + (od.tax_rate / 100)))) * (1 - (od.reduction_percent / 100)) / o.conversion_rate as prod_unit_price',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_unit_price',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'brand', 'supplier', 'category'),
|
|
'calculate' => array(
|
|
'global' => array('0'),
|
|
),
|
|
);
|
|
}
|
|
/* hack for 1.3.2.3 to 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.3.2.2', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['prod_unit_price'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'AVG((od.product_price + (od.product_quantity_discount / (1 + (od.tax_rate / 100))) - od.reduction_amount ' . (version_compare(_PS_VERSION_, '1.3.2.3', '>')?' * (1 - (od.group_reduction / 100))' : '') . ' * (1 - (od.reduction_percent / 100)) - (od.product_quantity_discount / (1 + (od.tax_rate / 100))) / cu.conversion_rate)) as prod_unit_price',
|
|
'install' => '((od.product_price + (od.product_quantity_discount / (1 + (od.tax_rate / 100))) - (od.reduction_amount ' . (version_compare(_PS_VERSION_, '1.3.2.3', '>')?' * (1 - (od.group_reduction / 100))' : '') . ')) * (1 - (od.reduction_percent / 100)) - (od.product_quantity_discount / (1 + (od.tax_rate / 100))) / cu.conversion_rate) as prod_unit_price',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_unit_price',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'brand', 'supplier', 'category'),
|
|
'calculate' => array(
|
|
'global' => array('0'),
|
|
),
|
|
);
|
|
}
|
|
/* hack under 1.3.2.3 */
|
|
else {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['prod_unit_price'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'od.product_price / cu.conversion_rate as prod_unit_price',
|
|
'install' => 'od.product_price / cu.conversion_rate as prod_unit_price',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_unit_price',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'brand', 'supplier', 'category'),
|
|
'calculate' => array(
|
|
'global' => array('0'),
|
|
),
|
|
);
|
|
}
|
|
if (version_compare(_PS_VERSION_, '1.5.0', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array_merge($GLOBALS[_OTPR_MODULE_NAME . '_COLS'], array(
|
|
'prod_total_costs' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity * (owp.WHP_PRICE)) as prod_total_costs',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_total_costs',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'brand', 'supplier', 'category', 'customer'),
|
|
),
|
|
));
|
|
}
|
|
else
|
|
{
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array_merge($GLOBALS[_OTPR_MODULE_NAME . '_COLS'], array(
|
|
'prod_total_costs' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity * (IF(pa.wholesale_price <> 0 AND pa.wholesale_price IS NOT NULL, pa.wholesale_price, p.wholesale_price))) as prod_total_costs',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_total_costs',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'brand', 'supplier', 'category', 'customer'),
|
|
),
|
|
));
|
|
}
|
|
|
|
/* hack for over 1.5 */
|
|
if (version_compare(_PS_VERSION_, '1.5', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['prod_total_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
// 'db' => 'SUM(od.product_quantity * (od.product_price - (od.reduction_amount / (1 + (IF(t.rate IS NOT NULL, t.rate, 0) / 100)))) * (1 - (od.reduction_percent / 100)) / o.conversion_rate) as prod_total_no_tax',
|
|
'db' => 'SUM(od.product_quantity * (od.unit_price_tax_excl / o.conversion_rate)) as prod_total_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_total_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'order', 'brand', 'supplier', 'category', 'customer'),
|
|
);
|
|
}
|
|
/* hack for over 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.4.0.1', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['prod_total_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity * ((od.product_price * (1 - (od.group_reduction / 100))) - (od.reduction_amount / (1 + (od.tax_rate / 100)))) * (1 - (od.reduction_percent / 100)) / o.conversion_rate) as prod_total_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_total_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'order', 'brand', 'supplier', 'category', 'customer'),
|
|
);
|
|
}
|
|
/* hack for 1.3.2.3 to 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.3.2.2', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['prod_total_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity * ((od.product_price + (od.product_quantity_discount / (1 + (od.tax_rate / 100))) - od.reduction_amount ' . (version_compare(_PS_VERSION_, '1.3.2.3', '>')?' * (1 - (od.group_reduction / 100))' : '') . ' * (1 - (od.reduction_percent / 100)) - (od.product_quantity_discount / (1 + (od.tax_rate / 100))) )) / cu.conversion_rate) as prod_total_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_total_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'order', 'brand', 'supplier', 'category', 'customer'),
|
|
);
|
|
}
|
|
/* hack for under 1.3.2.3 */
|
|
else {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['prod_total_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity * od.product_price / cu.conversion_rate) as prod_total_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'prod_total_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'order', 'brand', 'supplier', 'category', 'customer'),
|
|
);
|
|
}
|
|
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array_merge($GLOBALS[_OTPR_MODULE_NAME . '_COLS'], array(
|
|
'prod_total_tax'=> array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as prod_total_tax',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'prod_total_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'product'),
|
|
'calculate' => array(
|
|
'unit' => array('total_prod_tax', 'discounts_tax_amount'),
|
|
'global' => array('total_prod_tax', 'discounts_tax_amount'),
|
|
),
|
|
),
|
|
'prod_gross_profit' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as prod_gross_profit',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'prod_gross_profit',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'brand', 'supplier', 'category', 'customer'),
|
|
'calculate' => array(
|
|
'global' => array('prod_total_no_tax', 'prod_total_costs'),
|
|
'unit' => array('prod_total_no_tax', 'prod_total_costs'),
|
|
),
|
|
),
|
|
'prod_gross_margin' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as prod_gross_margin',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'prod_gross_margin',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('product', 'brand', 'supplier', 'category', 'customer'),
|
|
'calculate' => array(
|
|
'global' => array('prod_total_no_tax', 'prod_total_costs', 'prod_total_no_tax', '100'),
|
|
'unit' => array('prod_total_no_tax', 'prod_total_costs', 'prod_total_no_tax', '100'),
|
|
),
|
|
),
|
|
'prod_net_profit' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as prod_net_profit',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'prod_net_profit',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'brand', 'supplier', 'category', 'customer'),
|
|
'calculate' => array(
|
|
'global' => array('prod_total_no_tax', 'prod_total_costs', 'total_discounts_no_tax'),
|
|
'unit' => array('prod_total_no_tax', 'prod_total_costs', 'total_discounts_no_tax'),
|
|
),
|
|
),
|
|
'prod_net_margin' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as prod_net_margin',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'prod_net_margin',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('product', 'brand', 'supplier', 'category', 'customer'),
|
|
'calculate' => array(
|
|
'global' => array('prod_total_no_tax', 'prod_total_costs', 'total_discounts_no_tax', 'prod_total_no_tax', '100'),
|
|
'unit' => array('prod_total_no_tax', 'prod_total_costs', 'total_discounts_no_tax', 'prod_total_no_tax', '100'),
|
|
),
|
|
),
|
|
'percent_total_sales' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as percent_total_sales',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'percent_total_sales',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('product', 'brand', 'supplier', 'category'),
|
|
'calculate' => array(
|
|
'global' => array('100'),
|
|
),
|
|
'calculation' => 'prod_total_no_tax',
|
|
),
|
|
'percent_total_gross_profits' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as percent_total_gross_profits',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'percent_total_gross_profits',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('product', 'brand', 'supplier', 'category'),
|
|
'calculate' => array(
|
|
'global' => array('100'),
|
|
),
|
|
'calculation' => 'prod_gross_profit',
|
|
),
|
|
'percent_total_net_profits' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as percent_total_net_profits',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'percent_total_net_profits',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('product', 'brand', 'supplier', 'category'),
|
|
'calculate' => array(
|
|
'global' => array('100'),
|
|
),
|
|
'calculation' => 'prod_net_profit',
|
|
),
|
|
'total_sales_cumulative' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as total_sales_cumulative',
|
|
'type' => 'n',
|
|
'sort' => 0,
|
|
'realname' => 'total_sales_cumulative',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('product', 'brand', 'supplier', 'category'),
|
|
'calculate' => array(
|
|
'global' => array('100'),
|
|
),
|
|
'cumulative' => 'percent_total_sales',
|
|
),
|
|
'total_gross_profits_cumulative' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as total_gross_profits_cumulative',
|
|
'type' => 'n',
|
|
'sort' => 0,
|
|
'realname' => 'total_gross_profits_cumulative',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('product', 'brand', 'supplier', 'category'),
|
|
'calculate' => array(
|
|
'global' => array('100'),
|
|
),
|
|
'cumulative' => 'percent_total_gross_profits',
|
|
),
|
|
'total_net_profits_cumulative' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as total_net_profits_cumulative',
|
|
'type' => 'n',
|
|
'sort' => 0,
|
|
'realname' => 'total_net_profits_cumulative',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '%',
|
|
'group' => array('product', 'brand', 'supplier', 'category'),
|
|
'calculate' => array(
|
|
'global' => array('100'),
|
|
),
|
|
'cumulative' => 'percent_total_net_profits',
|
|
),
|
|
'cat_name' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'cl.name as cat_name',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'cl.name',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'defaulttext' => '',
|
|
'group' => array('product', 'category'),
|
|
),
|
|
'id_category' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'p.id_category_default as id_category',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'p.id_category_default',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'category'),
|
|
),
|
|
'manufacturer_name' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'm.name as manufacturer_name',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'm.name',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'defaulttext' => '',
|
|
'group' => array('product', 'brand'),
|
|
),
|
|
'id_manufacturer' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'p.id_manufacturer as id_manufacturer',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'p.id_manufacturer',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'brand'),
|
|
),
|
|
'supplier_name' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'sp.name as supplier_name',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'sp.name',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'defaulttext' => '',
|
|
'group' => array('product', 'supplier'),
|
|
),
|
|
'id_supplier' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'p.id_supplier as id_supplier',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'p.id_supplier',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product', 'supplier'),
|
|
),
|
|
'email' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'c.email',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'c.email',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'birthday' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'c.birthday',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'c.birthday',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'lastname' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'c.lastname',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'c.lastname',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'credit'),
|
|
),
|
|
'firstname' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'c.firstname',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'c.firstname',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'credit'),
|
|
),
|
|
'cust_date_add' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'DATE_FORMAT(c.date_add, "' . $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'][$sConfDateFormat]['sql'] . '") as cust_date_add',
|
|
'type' => 'd',
|
|
'sort' => 0,
|
|
'realname' => 'c.date_add',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'cust_date_upd' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'DATE_FORMAT(c.date_upd, "' . $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'][$sConfDateFormat]['sql'] . '") as cust_date_upd',
|
|
'type' => 'd',
|
|
'sort' => 0,
|
|
'realname' => 'c.date_upd',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'addr_company' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'a.company as addr_company',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'a.company',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'addr_lastname' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'a.lastname as addr_lastname',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'a.lastname',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'addr_firstname' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'a.firstname as addr_firstname',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'a.firstname',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'addr_address1' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'a.address1 as addr_address1',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'a.address1',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'addr_address2' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'a.address2 as addr_address2',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'a.address2',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'addr_postcode' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'a.postcode as addr_postcode',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'a.postcode',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'addr_city' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'a.city as addr_city',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'a.city',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
'addr_country' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'co.name as addr_country',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'co.name',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order', 'customer'),
|
|
),
|
|
'addr_phone' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'a.phone as addr_phone',
|
|
'type' => 's',
|
|
'sort' => 0,
|
|
'realname' => 'a.phone',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('order'),
|
|
),
|
|
));
|
|
|
|
|
|
/* Special case: this is not a string or number, the ID image returned by MySQL
|
|
* is then used to generate the image URL
|
|
*/
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['id_image'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'i.id_image',
|
|
'type' => 'm',
|
|
'sort' => 0,
|
|
'realname' => 'i.id_image',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('product'),
|
|
'calculate' => array(
|
|
'unit' => array('id_product', 'id_image'),
|
|
),
|
|
);
|
|
|
|
/* For customer report */
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array_merge($GLOBALS[_OTPR_MODULE_NAME . '_COLS'], array(
|
|
'id_customer' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'c.id_customer',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'c.id_customer',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('customer'),
|
|
),
|
|
'first_order' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '(SELECT DATE_FORMAT(MIN(invoice_date), "' . $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'][$sConfDateFormat]['sql'] . '") FROM `' . _DB_PREFIX_ . 'orders` AS o2 WHERE valid = 1 and id_customer = c.id_customer) AS first_order',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'first_order',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('customer'),
|
|
),
|
|
'last_order' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '(SELECT DATE_FORMAT(MAX(invoice_date), "' . $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'][$sConfDateFormat]['sql'] . '") FROM `' . _DB_PREFIX_ . 'orders` AS o2 WHERE valid = 1 and id_customer = c.id_customer) AS last_order',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'last_order',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('customer'),
|
|
),
|
|
'nb_orders' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'COUNT(DISTINCT(o.id_order)) AS nb_orders',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'nb_orders',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('customer'),
|
|
),
|
|
'order_nb_products' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_quantity) AS order_nb_products',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'order_nb_products',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('customer'),
|
|
),
|
|
'average_cart' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'AVG(o.total_paid) AS average_cart',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'average_cart',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('customer'),
|
|
'no_total' => 1,
|
|
),
|
|
'products_ordered' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => ' 0 AS products_ordered',
|
|
'type' => 'm',
|
|
'sort' => 0,
|
|
'realname' => '',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('customer'),
|
|
'calculate' => array(
|
|
'unit' => array('id_customer'),
|
|
),
|
|
),
|
|
));
|
|
|
|
/* For credit slips report */
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array_merge($GLOBALS[_OTPR_MODULE_NAME . '_COLS'], array(
|
|
'id_slip' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'os.id_order_slip as id_slip',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'os.id_order_slip',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
),
|
|
'slip_date' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'DATE_FORMAT(os.date_add, "' . $GLOBALS[_OTPR_MODULE_NAME . '_DATE_FORMAT'][$sConfDateFormat]['sql'] . '") as slip_date',
|
|
'type' => 's',
|
|
'sort' => 1,
|
|
'realname' => 'os.date_add',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
),
|
|
));
|
|
/* hack for over 1.5 */
|
|
if (version_compare(_PS_VERSION_, '1.5', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['slip_product_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(osd.amount_tax_excl) as slip_product_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_product_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
);
|
|
}
|
|
/* hack for over 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.4.0.1', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['slip_product_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM((((od.product_price * (1 - (od.group_reduction / 100))) - (od.reduction_amount / (1 + (od.tax_rate / 100)))) * (1 - (od.reduction_percent / 100))) * osd.product_quantity / o.conversion_rate) as slip_product_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_product_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
);
|
|
}
|
|
/* hack for 1.3.2.3 to 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.3.2.2', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['slip_product_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM((od.product_price + (od.product_quantity_discount / (1 + (od.tax_rate / 100))) - od.reduction_amount' . (version_compare(_PS_VERSION_, '1.3.2.3', '>')?' * (1 - (od.group_reduction / 100))' : '') . ' * (1 - (od.reduction_percent / 100)) - (od.product_quantity_discount / (1 + (od.tax_rate / 100))) ) * osd.product_quantity / cu.conversion_rate ) as slip_product_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_product_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
);
|
|
}
|
|
/* hack under 1.3.2.3 */
|
|
else {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['slip_product_no_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_price * osd.product_quantity / cu.conversion_rate ) as slip_product_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_product_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
);
|
|
}
|
|
|
|
/* hack for over 1.5 */
|
|
if (version_compare(_PS_VERSION_, '1.5', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['slip_product_total_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(osd.amount_tax_incl - osd.amount_tax_excl) as slip_product_total_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_product_total_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
);
|
|
}
|
|
/* hack for over 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.4.0.1', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['slip_product_total_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM((((od.product_price * (1 - (od.group_reduction / 100))) - (od.reduction_amount / (1 + (od.tax_rate / 100)))) * (1 - (od.reduction_percent / 100))) * osd.product_quantity * (od.tax_rate / 100) / o.conversion_rate) as slip_product_total_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_product_total_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
);
|
|
}
|
|
/* hack for 1.3.2.3 to 1.4.0.1 */
|
|
elseif (version_compare(_PS_VERSION_, '1.3.2.2', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['slip_product_total_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM((od.product_price + (od.product_quantity_discount / (1 + (od.tax_rate / 100))) - od.reduction_amount' . (version_compare(_PS_VERSION_, '1.3.2.3', '>')?' * (1 - (od.group_reduction / 100))' : '') . ' * (1 - (od.reduction_percent / 100)) - (od.product_quantity_discount / (1 + (od.tax_rate / 100))) ) * osd.product_quantity * (od.tax_rate / 100) / cu.conversion_rate ) as slip_product_total_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_product_total_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
);
|
|
}
|
|
/* hack under 1.3.2.3 */
|
|
else {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS']['slip_product_total_tax'] = array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => 'SUM(od.product_price * osd.product_quantity * (od.tax_rate / 100) / cu.conversion_rate ) as slip_product_total_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_product_total_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
);
|
|
}
|
|
|
|
/* use case - only for over 1.5 version */
|
|
if (version_compare(_PS_VERSION_, '1.5.0', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array_merge($GLOBALS[_OTPR_MODULE_NAME . '_COLS'], array(
|
|
'slip_total_shipping_tax' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '( os.shipping_cost_amount - (os.shipping_cost_amount / ( 1 + (o.carrier_tax_rate / 100)))) / o.conversion_rate as slip_total_shipping_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_total_shipping_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
),
|
|
'slip_total_shipping_no_tax' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '(os.shipping_cost_amount / ( 1 + (o.carrier_tax_rate / 100))) / o.conversion_rate as slip_total_shipping_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_total_shipping_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
),
|
|
));
|
|
}
|
|
/* use case - only for over 1.4 version */
|
|
elseif (version_compare(_PS_VERSION_, '1.4.0', '>')) {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array_merge($GLOBALS[_OTPR_MODULE_NAME . '_COLS'], array(
|
|
'slip_total_shipping_tax' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '(os.shipping_cost * ( o.total_shipping - (o.total_shipping / ( 1 + (o.carrier_tax_rate / 100))))) / o.conversion_rate as slip_total_shipping_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_total_shipping_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
),
|
|
'slip_total_shipping_no_tax' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '(os.shipping_cost * (o.total_shipping / ( 1 + (o.carrier_tax_rate / 100)))) / o.conversion_rate as slip_total_shipping_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_total_shipping_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
),
|
|
));
|
|
}
|
|
else {
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array_merge($GLOBALS[_OTPR_MODULE_NAME . '_COLS'], array(
|
|
'slip_total_shipping_tax' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '(os.shipping_cost * ( o.total_shipping - (o.total_shipping / ( 1 + IF(ct.rate IS NOT NULL, (ct.rate / 100), 0))))) / cu.conversion_rate as slip_total_shipping_tax',
|
|
'type' => 'n',
|
|
'sort' => 1,
|
|
'realname' => 'slip_total_shipping_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
),
|
|
'slip_total_shipping_no_tax' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '(os.shipping_cost * (o.total_shipping / ( 1 + IF(ct.rate IS NOT NULL, (ct.rate / 100), 0)))) / cu.conversion_rate as slip_total_shipping_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 0,
|
|
'realname' => 'slip_total_shipping_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
),
|
|
));
|
|
}
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_COLS'] = array_merge($GLOBALS[_OTPR_MODULE_NAME . '_COLS'], array(
|
|
'slip_total_no_tax' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as slip_total_no_tax',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'slip_total_no_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
'calculate' => array(
|
|
'global' => array('slip_product_no_tax', 'slip_total_shipping_no_tax'),
|
|
'unit' => array('slip_product_no_tax', 'slip_total_shipping_no_tax'),
|
|
),
|
|
),
|
|
'slip_total_tax' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as slip_total_tax',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'slip_total_tax',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
'calculate' => array(
|
|
'global' => array('slip_product_total_tax', 'slip_total_shipping_tax'),
|
|
'unit' => array('slip_product_total_tax', 'slip_total_shipping_tax'),
|
|
),
|
|
),
|
|
'slip_total_incl' => array(
|
|
'use' => true,
|
|
'display' => true,
|
|
'db' => '0 as slip_total_incl',
|
|
'type' => 'n',
|
|
'sort' => 2,
|
|
'realname' => 'slip_total_incl',
|
|
'title' => '',
|
|
'prefix' => '',
|
|
'suffix' => '',
|
|
'group' => array('credit'),
|
|
'calculate' => array(
|
|
'global' => array('slip_product_no_tax', 'slip_total_shipping_no_tax', 'slip_product_total_tax', 'slip_total_shipping_tax'),
|
|
'unit' => array('slip_product_no_tax', 'slip_total_shipping_no_tax', 'slip_product_total_tax', 'slip_total_shipping_tax'),
|
|
),
|
|
),
|
|
));
|
|
|
|
/* defines variable for report templates
|
|
* uses => with install / admin interface
|
|
* ADD => add as you want report type, just pick cols name above. Have to write translation title as below, See result in order's admin tab
|
|
*/
|
|
$GLOBALS[_OTPR_MODULE_NAME . '_SEARCH_TEMPLATE'] = array(
|
|
'basic' => array(
|
|
'cols' => array(
|
|
'shop_name', 'id_order', 'ord_date_add', 'invoice_number', 'ord_invoice_date',
|
|
'lastname', 'firstname', 'addr_postcode', 'addr_city', 'addr_country',
|
|
'total_paid', 'total_products_no_tax', 'total_prod_tax', 'ecotax_no_tax', 'ecotax_tax_amount', 'total_shipping', 'total_shipping_tax',
|
|
'total_discounts_no_tax', 'discounts_tax_amount', 'total_wrapping_no_tax', 'wrapping_tax_amount', 'total_tax',
|
|
'order_state', 'total_cost', 'gross_profit', 'net_profit', 'gross_margin', 'net_margin'
|
|
),
|
|
'groupby' => 'od.id_order',
|
|
'orderby' => 'od.id_order',
|
|
'lang' => array('en' => 'Basic', 'fr' => 'Basique', 'es' => 'Básico', 'de' => 'Grundlegende', 'it' => 'Di base'),
|
|
'group' => 'order',
|
|
),
|
|
'vatonly' => array(
|
|
'cols' => array(
|
|
'shop_name', 'id_order', 'ord_date_add', 'invoice_number', 'ord_invoice_date',
|
|
'total_products_no_tax', 'total_prod_tax', 'ecotax_no_tax', 'ecotax_tax_amount', 'total_discounts_no_tax', 'discounts_tax_amount', 'total_wrapping_no_tax',
|
|
'wrapping_tax_amount', 'total_shipping', 'total_shipping_tax', 'total_tax', 'lastname', 'firstname', 'addr_company'
|
|
),
|
|
'groupby' => 'od.id_order',
|
|
'orderby' => 'od.id_order',
|
|
'lang' => array('en' => 'Tax only', 'fr' => 'TVA', 'es' => 'IVA', 'de' => 'Mehrwertsteuer', 'it' => 'IVA'),
|
|
'group' => 'order',
|
|
),
|
|
'profitonly' => array(
|
|
'cols' => array(
|
|
'shop_name', 'id_order', 'ord_date_add', 'invoice_number', 'ord_invoice_date',
|
|
'total_discounts_no_tax', 'discounts_tax_amount', 'total_wrapping_no_tax', 'wrapping_tax_amount','total_products_no_tax',
|
|
'total_prod_tax', 'ecotax_no_tax', 'ecotax_tax_amount', 'total_cost', 'gross_profit', 'net_profit', 'gross_margin', 'net_margin',
|
|
'email', 'lastname', 'firstname', 'addr_company'
|
|
),
|
|
'groupby' => 'od.id_order',
|
|
'orderby' => 'od.id_order',
|
|
'lang' => array('en' => 'Profit', 'fr' => 'Bénéfices', 'es' => 'Ganancias', 'de' => 'Ertrag', 'it' => 'Guadagni' ),
|
|
'group' => 'order',
|
|
),
|
|
'all' => array(
|
|
'cols' => array(
|
|
'shop_name', 'id_order', 'ord_date_add', 'ord_date_upd', 'invoice_number', 'ord_invoice_date', 'delivery_number',
|
|
'ord_delivery_date', 'ord_payment_method', 'ord_carrier', 'total_paid', 'total_paid_real', 'total_shipping', 'total_shipping_tax',
|
|
'total_discounts_no_tax', 'discounts_tax_amount', 'total_wrapping_no_tax', 'wrapping_tax_amount',
|
|
'total_products_no_tax', 'total_prod_tax', 'ecotax_no_tax', 'ecotax_tax_amount', 'total_tax', 'total_cost', 'gross_profit', 'net_profit', 'gross_margin', 'net_margin',
|
|
'email', 'birthday', 'lastname', 'firstname', 'cust_date_add', 'cust_date_upd',
|
|
'addr_company', 'addr_lastname', 'addr_firstname', 'addr_address1', 'addr_address2', 'addr_postcode', 'addr_city', 'addr_country', 'addr_phone'
|
|
),
|
|
'groupby' => 'od.id_order',
|
|
'orderby' => 'od.id_order',
|
|
'lang' => array('en' => 'Full', 'fr' => 'Complet', 'es' => 'Completar', 'de' => 'Abschließen', 'it' => 'Completare' ),
|
|
'group' => 'order',
|
|
),
|
|
'product' => array(
|
|
'cols' => array(
|
|
'shop_name', 'id_product', 'id_image', 'product_ref', 'product_name', 'product_supplier_ref', 'product_ean', 'product_upc', 'prod_total_quantity', 'prod_unit_price', 'prod_tax_rate', 'total_discounts_no_tax', 'discounts_tax_amount',
|
|
'prod_total_no_tax', 'total_prod_tax', 'ecotax_no_tax', 'ecotax_tax_amount', 'prod_total_tax', 'prod_total_costs', 'prod_gross_profit', 'prod_gross_margin', 'prod_net_profit', 'prod_net_margin','manufacturer_name', 'cat_name',
|
|
'percent_total_sales', 'total_sales_cumulative', 'percent_total_gross_profits', 'total_gross_profits_cumulative', 'percent_total_net_profits', 'total_net_profits_cumulative'
|
|
),
|
|
'groupby' => 'od.product_id',
|
|
'orderby' => 'od.product_id',
|
|
'lang' => array('en' => 'Product', 'fr' => 'Produit', 'es' => 'Producto', 'de' => 'Produkt', 'it' => 'Prodotto' ),
|
|
'group' => 'product',
|
|
'attribute' => true,
|
|
),
|
|
'brand' => array(
|
|
'cols' => array(
|
|
'shop_name', 'id_manufacturer', 'manufacturer_name', 'prod_total_quantity', 'total_discounts_no_tax', 'prod_total_no_tax', 'ecotax_no_tax', 'prod_total_costs',
|
|
'prod_gross_profit', 'prod_gross_margin', 'prod_net_profit', 'prod_net_margin','manufacturer_name',
|
|
'percent_total_sales', 'total_sales_cumulative', 'percent_total_gross_profits', 'total_gross_profits_cumulative', 'percent_total_net_profits', 'total_net_profits_cumulative'
|
|
),
|
|
'groupby' => 'p.id_manufacturer',
|
|
'orderby' => 'p.id_manufacturer',
|
|
'lang' => array('en' => 'Brand', 'fr' => 'Marque', 'es' => 'marcar', 'de' => 'markieren', 'it' => 'segnare' ),
|
|
'group' => 'brand',
|
|
),
|
|
'supplier' => array(
|
|
'cols' => array(
|
|
'shop_name', 'id_supplier', 'supplier_name', 'prod_total_quantity', 'total_discounts_no_tax', 'discounts_tax_amount', 'prod_total_no_tax', 'ecotax_no_tax', 'prod_total_costs',
|
|
'prod_gross_profit', 'prod_gross_margin', 'prod_net_profit', 'prod_net_margin',
|
|
'percent_total_sales', 'total_sales_cumulative', 'percent_total_gross_profits', 'total_gross_profits_cumulative', 'percent_total_net_profits', 'total_net_profits_cumulative'
|
|
),
|
|
'groupby' => 'p.id_supplier',
|
|
'orderby' => 'p.id_supplier',
|
|
'lang' => array('en' => 'Supplier', 'fr' => 'Fournisseur', 'es' => 'Proveedor', 'de' => 'Lieferant', 'it' => 'Fornitore' ),
|
|
'group' => 'supplier',
|
|
),
|
|
'category' => array(
|
|
'cols' => array(
|
|
'shop_name', 'id_category', 'cat_name', 'prod_total_quantity', 'total_discounts_no_tax', 'discounts_tax_amount', 'prod_total_no_tax', 'ecotax_no_tax', 'prod_total_costs',
|
|
'prod_gross_profit', 'prod_gross_margin', 'prod_net_profit', 'prod_net_margin', 'cat_name',
|
|
'percent_total_sales', 'total_sales_cumulative', 'percent_total_gross_profits', 'total_gross_profits_cumulative', 'percent_total_net_profits', 'total_net_profits_cumulative'
|
|
),
|
|
'groupby' => 'p.id_category_default',
|
|
'orderby' => 'p.id_category_default',
|
|
'lang' => array('en' => 'Category', 'fr' => 'Catégorie', 'es' => 'categoría', 'de' => 'Kategorie', 'it' => 'categoria' ),
|
|
'group' => 'category',
|
|
),
|
|
'customer' => array(
|
|
'cols' => array(
|
|
'id_customer', 'lastname', 'firstname', 'email', 'addr_company', 'addr_address1', 'addr_address2', 'addr_postcode', 'addr_city', 'addr_country', 'addr_phone',
|
|
'first_order', 'last_order', 'nb_orders', 'order_nb_products', 'average_cart', 'products_ordered',
|
|
'prod_total_no_tax', 'prod_total_costs', 'total_discounts_no_tax', 'prod_gross_profit', 'prod_net_profit', 'prod_gross_margin', 'prod_net_margin'
|
|
),
|
|
'groupby' => 'o.id_customer',
|
|
'orderby' => 'c.lastname',
|
|
'lang' => array('en' => 'Customer', 'fr' => 'Client', 'es' => 'Cliente', 'de' => 'Kunde', 'it' => 'Cliente' ),
|
|
'group' => 'customer',
|
|
),
|
|
'credit' => array(
|
|
'cols' => array(
|
|
'id_slip', 'id_order', 'lastname', 'firstname', 'ord_invoice_date', 'slip_date', 'ord_payment_method', 'slip_product_no_tax', 'slip_product_total_tax',
|
|
'slip_total_shipping_no_tax', 'slip_total_shipping_tax', 'slip_total_no_tax', 'slip_total_tax', 'slip_total_incl'
|
|
),
|
|
'groupby' => 'os.id_order_slip',
|
|
'orderby' => 'os.id_order_slip',
|
|
'lang' => array('en' => 'Store Credit', 'fr' => 'Avoirs', 'es' => 'Activos', 'de' => 'Geldern', 'it' => 'Asset'),
|
|
'group' => 'credit',
|
|
),
|
|
); |