bebeboutik/modules/paymentinfo/manage.php
2016-07-18 11:45:18 +02:00

88 lines
2.3 KiB
PHP

<?php
$useSSL = TRUE;
require_once(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
$controller->preProcess();
if (!$cookie->isLogged())
Tools::redirect('authentication.php?back=modules/paymentinfo/manage.php');
include(dirname(__FILE__).'/../../header.php');
// DELETE ACCOUNT PAYPAL
if (Tools::getValue('delete_agreement')) {
$id_paypal_agreement = Tools::getValue('delete_agreement');
$id_customer_test = Db::getInstance()->getValue('
SELECT `id_customer`
FROM `'._DB_PREFIX_.'paypal_customer_agreement`
WHERE `id_paypal_agreement`= '.(int) $id_paypal_agreement.'
');
if(empty($id_customer_test)) {
return false;
}
if($id_customer_test != $cookie->id_customer) {
return false;
}
// DELETE
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'paypal_customer_agreement`
WHERE `id_paypal_agreement`= '.(int) $id_paypal_agreement
);
$smarty->assign(array(
'delete' => true,
));
}
// DELETE PAYBOX CARD
if (Tools::getValue('delete_card')) {
$id_paybox_card = Tools::getValue('delete_card');
$id_customer_test = Db::getInstance()->getValue('
SELECT `id_customer`
FROM `'._DB_PREFIX_.'paybox_customer_agreement`
WHERE `id_paybox_card`= '.(int) $id_paybox_card.'
');
if(empty($id_customer_test)) {
return false;
}
if($id_customer_test != $cookie->id_customer) {
return false;
}
// DELETE
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'paybox_customer_agreement`
WHERE `id_paybox_card`= '.(int) $id_paybox_card
);
$smarty->assign(array(
'delete' => true,
));
}
// account paypal
$paypal_accounts = Db::getInstance()->executes('
SELECT `id_paypal_agreement`, `email`, `name`, `city`, `date_add`
FROM `'._DB_PREFIX_.'paypal_customer_agreement`
WHERE `id_customer`= '.(int) $cookie->id_customer.'
');
// account paybox
$paybox_accounts = Db::getInstance()->executes('
SELECT `id_paybox_card`, `value`, `date`, `payment_type`
FROM `'._DB_PREFIX_.'paybox_customer_agreement`
WHERE `id_customer`= '.(int) $cookie->id_customer.'
');
$smarty->assign(array(
'paypal_accounts' => $paypal_accounts,
'paybox_accounts' => $paybox_accounts,
));
// @TODO account cb
echo Module::display(dirname(__FILE__).'/paymentinfo.php', 'paymentinfo.tpl');
include(dirname(__FILE__).'/../../footer.php');