bebeboutik/modules/invite/ajax_sponsor.php
2017-11-07 12:17:20 +01:00

35 lines
1.3 KiB
PHP

<?php
$useSSL = TRUE;
require_once(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
$id_customer = (int)Tools::getValue('id');
$id_sponsor = (int)Tools::getValue('sponsor', 0);
$token = Tools::getValue('token');
// Display form edit
if ($id_customer !== 0 && Tools::getValue('adtoken') === Tools::encrypt('InviteAdmSponsor'.$id_customer)) {
$sponsor = new Customer($id_sponsor);
$smarty->assign(array(
'base_dir' => _PS_BASE_URL_.__PS_BASE_URI__,
'token' => $token,
'id_customer' => $id_customer,
'sponsor' => (Validate::isLoadedObject($sponsor)) ? $sponsor : false,
));
echo $smarty->fetch(file_exists(_PS_THEME_DIR_.'modules/invite/ajax_sponsor.tpl') ?
'../../themes/'._THEME_NAME_.'/modules/invite/ajax_sponsor.tpl' :
'ajax_sponsor.tpl', __FILE__);
exit;
}
// Search customer by email
elseif (Tools::getvalue('action') == 'search') {
$q = Tools::getValue('term');
$sql = 'SELECT `id_customer` AS id, CONCAT_WS(" ", `lastname`, `firstname`, CONCAT("(", `email`, ")")) AS value
FROM `'._DB_PREFIX_.'customer` WHERE `email` LIKE "'.pSQL($q).'%"';
$result = Db::getInstance()->executeS($sql);
echo Tools::jsonEncode($result);
exit;
}