/** * main action */ public function mainAction() { /** * check input */ if ($_SESSION['client']['customer']['id'] == 0 && !Onxshop_Bo_Authentication::getInstance()->isAuthenticated()) { msg('controllers/client/customer_detail: You must logged in.', 'error'); onxshopGoTo("/"); } else { if (is_numeric($this->GET['customer_id']) && constant('ONXSHOP_IN_BACKOFFICE')) { $customer_id = $this->GET['customer_id']; } else { $customer_id = $_SESSION['client']['customer']['id']; } } if (!is_numeric($customer_id)) { return false; } /** * initialize */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); /** * get customer detail */ $customer_detail = $Customer->getDetail($customer_id); if (is_array($customer_detail)) { $this->tpl->assign('ITEM', $customer_detail); } else { msg('controllers/client/customer_detail: cannot get detail', 'error'); } return true; }
/** * main action */ public function mainAction() { require_once 'models/client/client_customer.php'; $Customer = new client_customer(); /** * Display */ if (is_numeric($this->GET['customer_id'])) { $customer_detail = $Customer->getDetail($this->GET['customer_id']); } $this->tpl->assign('CUSTOMER', $customer_detail); return true; }
/** * main action */ public function mainAction() { require_once 'models/client/client_customer.php'; $Customer = new client_customer(); /** * include node configuration */ require_once 'models/common/common_node.php'; $node_conf = common_node::initConfiguration(); $this->tpl->assign('NODE_CONF', $node_conf); /** * Display */ if ($_SESSION['client']['customer']['id'] > 0 && is_numeric($_SESSION['client']['customer']['id'])) { $customer_detail = $Customer->getDetail($_SESSION['client']['customer']['id']); $this->tpl->assign('CUSTOMER', $customer_detail); $this->tpl->parse('content.customer'); } else { $this->tpl->parse('content.register'); $this->tpl->parse('content.login'); } return true; }
/** * get author detail */ public function getAuthorDetailbyId($author_id) { if ($author_id == 0) { return array('id' => 1000, 'username' => "superuser", 'email' => $GLOBALS['onxshop_conf']['global']['admin_email'], 'name' => $GLOBALS['onxshop_conf']['global']['admin_email_name']); } require_once 'models/client/client_customer.php'; $Custmer = new client_customer(); $customer = $Custmer->getDetail($author_id); if ($customer) { return array('id' => $customer['id'], 'username' => $customer['email'], 'email' => $customer['email'], 'name' => $customer['first_name'] . ' ' . $customer['last_name']); } return false; }
/** * Send email to customer * Return number of emails sent * */ public function sendNotification($customer_id, $template, $params) { require_once 'models/common/common_email.php'; require_once 'models/client/client_customer.php'; $Email = new common_email(); $Customer = new client_customer(); $customer = $Customer->getDetail($customer_id); if ($customer['id'] == 0 && $customer['status'] > 3) { return 0; } $params['customer'] = $customer; if (strlen($params['customer']['first_name']) == 0) { $params['customer'] = 'Customer'; } //this allows use customer data and company data in the mail template //is passed as DATA to template in common_email->_format $GLOBALS['common_email'] = $params; $email_recipient = $customer['email']; $name_recipient = $customer['first_name'] . ' ' . $customer['last_name']; $result = $Email->sendEmail($template, serialize($params), $email_recipient, $name_recipient); return $result ? 1 : 0; }
/** * delete address * * @param integer $address_id * Client address ID for delete * * @return boolean * Result of address deleting [true/false] */ public function deleteAddress($address_id) { if (!is_numeric($address_id)) { return false; } /** * address detail */ $address_detail = $this->detail($address_id); /** * customer detail */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); $customer_detail = $Customer->getDetail($address_detail['customer_id']); /** * check if address is not used */ if ($customer_detail['invoices_address_id'] != $address_id && $customer_detail['delivery_address_id'] != $address_id) { $address_detail['is_deleted'] = true; if ($this->update($address_detail)) { return true; } else { return false; } } else { msg("Address (id={$address_id}) is used as your active delivery or billing address", 'error'); return false; } }
/** * Send email after succesfull reward code allocation */ public function sendRewardEmail($invited_customer_id, $rewarded_customer_id, $code, $usage) { require_once 'models/common/common_email.php'; require_once 'models/client/client_customer.php'; $EmailForm = new common_email(); $Customer = new client_customer(); $Customer->setCacheable(false); $rewarded_customer = $Customer->getDetail($rewarded_customer_id); $invited_customer = $Customer->getDetail($invited_customer_id); $GLOBALS['common_email']['invited_customer'] = $invited_customer; $GLOBALS['common_email']['rewarded_customer'] = $rewarded_customer; $GLOBALS['common_email']['code'] = $code; $GLOBALS['common_email']['total_invited'] = $usage; $conf = ecommerce_promotion::initConfiguration(); $GLOBALS['common_email']['minimum_order_amount'] = $conf['minimum_order_amount']; $GLOBALS['common_email']['discount_value'] = $conf['discount_value']; $to_email = $rewarded_customer['email']; $to_name = $rewarded_customer['first_name'] . " " . $rewarded_customer['last_name']; $EmailForm->sendEmail('referral_reward', 'n/a', $to_email, $to_name); }