name = 'refundreason';
$this->tab = 'administration';
$this->author = 'Antadis';
$this->version = '1.0';
parent::__construct();
$this->displayName = $this->l('Reason for refund');
$this->description = $this->l('Allows to give a reason for refunds');
$this->reasons = array(
'---',
$this->l('Cancelled (before shipping)'),
$this->l('Cancelled (received, -7d)'),
$this->l('Return (received +7d)'),
$this->l('Product default'),
$this->l('Missing product (supplier)'),
$this->l('Logistics error'),
$this->l('Other'),
$this->l('ZZZZZ1'),
$this->l('ZZZZZ2'),
$this->l('ZZZZZ3'),
$this->l('ZZZZZ4'),
$this->l('ZZZZZ5'),
);
}
public function uninstall() {
Db::getInstance()->Execute('
DROP TABLE `'._DB_PREFIX_.'refundreason`
');
return parent::uninstall();
}
public function install() {
if(!(parent::install()
&& Db::getInstance()->Execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'refundreason` (
`id_reason` INTEGER NOT NULL,
`id_order_slip` INTEGER NOT NULL,
`id_employee` INTEGER DEFAULT NULL,
PRIMARY KEY(`id_reason`, `id_order_slip`)
) ENGINE=MyIsam DEFAULT CHARSET=utf8
')
&& $this->registerHook('adminOrder')
&& $this->registerHook('orderSlip')
)) {
return FALSE;
}
return TRUE;
}
public function hookAdminOrder($params) {
global $cookie;
$output = '';
if($reasons = Db::getInstance()->ExecuteS('
SELECT *
FROM `'._DB_PREFIX_.'order_slip` s
LEFT JOIN `'._DB_PREFIX_.'refundreason` r
ON s.`id_order_slip` = r.`id_order_slip`
WHERE s.`id_order` = '.(int) $params['id_order'].'
')) {
$output .= '