/** * main action */ public function mainAction() { /** * include node configuration */ require_once 'models/common/common_node.php'; $node_conf = common_node::initConfiguration(); /** * customer detail */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); if ($_POST['register'] || $_POST['login']) { //check validation of submited fields if ($Customer->checkLoginId($_POST['client']['customer'])) { $_SESSION['r_client'] = $_POST['client']; $this->dispatchToRegistration($node_conf); } else { $this->tpl->assign('CLIENT', $_POST['client']); $this->tpl->parse('content.login'); } } else { $this->tpl->parse('content.form'); } /** * check status */ if ($_SESSION['client']['customer']['id'] > 0 && is_numeric($_SESSION['client']['customer']['id'])) { $this->actionAfterLogin(); } return true; }
/** * checkCookieForToken */ protected function checkCookieForToken() { if (isset($_COOKIE['onxshop_token'])) { require_once 'models/client/client_customer_token.php'; $Token = new client_customer_token(); $Token->setCacheable(false); $customer_detail = $Token->getCustomerDetailForToken($_COOKIE['onxshop_token']); if ($customer_detail) { require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); $conf = $Customer::initConfiguration(); if ($conf['login_type'] == 'username') { $username = $customer_detail['username']; } else { $username = $customer_detail['email']; } $customer_detail = $Customer->login($username); if ($customer_detail) { $_SESSION['client']['customer'] = $customer_detail; $_SESSION['use_page_cache'] = false; } else { msg('Autologin failed', 'error', 1); } } else { msg('Invalid autologin token supplied', 'error', 1); //delete cookie setcookie('onxshop_token', '', time() - 3600, '/'); } } }
/** * main action */ public function mainAction() { if ($this->GET['email']) { $email = $this->GET['email']; } else { if ($_POST['client']['customer']['email']) { $email = $_POST['client']['customer']['email']; } else { $email = ''; } } $this->tpl->assign('EMAIL', $email); require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); if ($_POST['submit']) { if ($Customer->newsletterUnSubscribe($email)) { //$this->tpl->parse('content.newsletter_unsubscribed'); $hide_form = 1; } else { // } } if ($hide_form == 0) { $this->tpl->parse('content.request_form'); } return true; }
/** * main action */ public function mainAction() { if ($_SESSION['client']['customer']['id'] > 0) { require_once 'models/client/client_customer.php'; $ClientCustomer = new client_customer(); if ($ClientCustomer->logout()) { msg("Logout of {$_SESSION['client']['customer']['email']}", 'ok', 1); //$_SESSION['client']['customer']['id'] = 0; unset($_SESSION['client']); // unlink basket from customer unset($_SESSION['basket']); // clear gift parameters unset($_SESSION['gift']); unset($_SESSION['gift_message']); $this->invalidateToken(); //clean facebook auth $this->logoutFromFacebook(); } else { msg("Customer logout failed", 'error'); } } //forward to the homepage onxshopGoTo(AFTER_CLIENT_LOGOUT_URL); return true; }
/** * main action */ public function mainAction() { /** * include node configuration */ require_once 'models/common/common_node.php'; $node_conf = common_node::initConfiguration(); //$this->tpl->assign('NODE_CONF', $node_conf); /** * customer detail */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); if ($_POST['register']) { //check validation of submited fields if ($Customer->checkLoginId($_POST['client']['customer'])) { $_SESSION['r_client'] = $_POST['client']; $this->dispatchToRegistration($node_conf); } else { msg("User email {$_POST['client']['customer']['email']} is already registered", 'error', 0, 'account_exists'); $this->tpl->assign('CLIENT', $_POST['client']); } } return true; }
/** * main action */ public function mainAction() { /** * initialize */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); if (is_array($_POST['client'])) { $this->tpl->assign('CLIENT', $_POST['client']); } /** * save */ if ($_POST['client']['customer']['save_newsletter_signup'] && $_POST['client']['customer']['first_name'] && $_POST['client']['customer']['last_name'] && $_POST['client']['customer']['email']) { if ($id = $Customer->newsletterSubscribe($_POST['client']['customer'])) { msg("Subscribed {$customer['email']}"); $this->tpl->parse('content.thank_you'); // set status cookie setcookie("newsletter_status", "1", time() + 3600 * 24 * 1000, "/"); // set customer status if ($_POST['client']['customer']['email'] == $_SESSION['client']['customer']['email']) { $_SESSION['client']['customer']['newsletter'] = 1; } } else { msg("Can't subscribe {$customer['email']}", 'error'); $this->tpl->parse('content.form'); } } else { $this->tpl->parse('content.form'); } return true; }
/** * main action */ public function mainAction() { /** * client */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); if ($_POST['submit']) { $customer_data = $Customer->getClientByEmail($_POST['client']['customer']['email']); if (is_array($customer_data)) { require_once 'models/common/common_email.php'; $EmailForm = new common_email(); //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']['customer'] = $customer_data; if (!$EmailForm->sendEmail('password_reminder', 'n/a', $customer_data['email'], $customer_data['first_name'] . " " . $customer_data['last_name'])) { msg("Can't send email with password reminder", 'error'); } $this->tpl->parse('content.password_sent'); $hide_form = 1; } } if ($hide_form == 0) { $this->tpl->parse('content.request_form'); } //sanitize before we add HTML attribute checked="checked" :) if (is_array($_POST['client'])) { $this->tpl->assign('CLIENT', $_POST['client']); } return true; }
/** * 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() { if ($_SESSION['client']['customer']['id'] == 0 && !Onxshop_Bo_Authentication::getInstance()->isAuthenticated()) { msg('client_edit: You must be logged in first.', 'error'); onxshopGoTo("/"); } require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); $customer_id = $_SESSION['client']['customer']['id']; if (!is_numeric($customer_id)) { return false; } if ($_POST['save']) { $_POST['client']['customer']['id'] = $customer_id; // do not allow to set certain properties unset($_POST['client']['customer']['status']); unset($_POST['client']['customer']['group_id']); unset($_POST['client']['customer']['group_ids']); unset($_POST['client']['customer']['role_ids']); unset($_POST['client']['customer']['account_type']); unset($_POST['client']['customer']['other_data']); /** * check birthday field format */ if ($_POST['client']['customer']['birthday']) { // check, expected as dd/mm/yyyy if (!preg_match('/^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$/', $_POST['client']['customer']['birthday'])) { msg('Invalid format for birthday, use dd/mm/yyyy', 'error'); return false; } // Format to ISO $_POST['client']['customer']['birthday'] = strftime('%Y-%m-%d', strtotime(str_replace('/', '-', $_POST['client']['customer']['birthday']))); } /** * update */ if ($Customer->updateClient($_POST['client'])) { msg(I18N_CUSTOMER_DATA_UPDATED); } else { msg("Can't update client data", 'error'); } } $client_data = $Customer->getClientData($customer_id); $client_data['customer']['newsletter'] = $client_data['customer']['newsletter'] == 1 ? 'checked="checked" ' : ''; // format birthday only if available to avoid 01/01/1970 by default if ($client_data['customer']['birthday'] != '') { $client_data['customer']['birthday'] = strftime('%d/%m/%Y', strtotime($client_data['customer']['birthday'])); } $this->tpl->assign('CLIENT', $client_data); /** * show password field only if previously set */ if ($client_data['customer']['password']) { $this->tpl->parse('content.password'); } return true; }
/** * main action */ public function mainAction() { /** * input */ if (is_numeric($_POST['customer_id'])) { $customer_id = $_POST['customer_id']; } else { $customer_id = 0; } /** * bo users list */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $bo_users_list = $Customer->getCustomersWithRole(); foreach ($bo_users_list as $customer) { $this->tpl->assign('CUSTOMER', $customer); if ($customer['id'] == $customer_id) { $this->tpl->assign('SELECTED', 'selected="selected"'); } else { $this->tpl->assign('SELECTED', ''); } $this->tpl->parse('content.item'); } /** * stats */ $author_stats = array(); /** * common_node */ require_once 'models/common/common_node.php'; $Node = new common_node(); $author_stats['common_node'] = $Node->getAuthorStats($customer_id); /** * common_image */ require_once 'models/common/common_image.php'; $Image = new common_image(); $author_stats['common_image'] = $Image->getAuthorStats($customer_id); /** * common_revision */ require_once 'models/common/common_revision.php'; $Revision = new common_revision(); $author_stats['common_revision'] = $Revision->getAuthorStats($customer_id); /** * assign */ $this->tpl->assign('AUTHOR_STATS', $author_stats); 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() { if ($customer_data = $_POST['client']['customer']) { require_once 'models/client/client_customer.php'; $Customer = new client_customer(); if ($id = $Customer->registerCustomer($customer_data)) { onxshop_flush_cache(); onxshopGoTo("/backoffice/customers/{$id}/detail"); } else { msg("Cannot add user", 'error'); } } return true; }
/** * main action */ public function mainAction() { /** * client */ $Customer = new client_customer(); $Customer->setCacheable(false); if ($_SESSION['client']['customer']['id'] > 0 && !$this->GET['client']['email']) { //msg('you are in'); //onxshopGoTo($this->GET['to']); } else { /* client submitted username/password */ if (isset($_POST['login'])) { $customer_detail = $Customer->login($_POST['client']['customer']['email'], md5($_POST['client']['customer']['password'])); if ($customer_detail) { $_SESSION['client']['customer'] = $customer_detail; if (isset($_POST['autologin'])) { // auto login (TODO allow to enable/disable this behaviour globally) $Customer->generateAndSaveOnxshopToken($customer_detail['id']); } } else { $this->loginFailed(); } } /* log in as client from backoffice */ if (Onxshop_Bo_Authentication::getInstance()->isAuthenticated() && $this->GET['client']['email']) { $customer_detail = $Customer->getClientByEmail($this->GET['client']['email']); if ($customer_detail) { $_SESSION['client']['customer'] = $customer_detail; } else { msg('Login from backoffice failed.', 'error'); } } } /** * check status */ if ($_SESSION['client']['customer']['id'] > 0 && is_numeric($_SESSION['client']['customer']['id'])) { $this->actionAfterLogin(); } //output $this->tpl->assign('CLIENT', $_POST['client']); $this->tpl->parse('content.login_box'); return true; }
/** * loginToOnxshop */ public function loginToOnxshop($user_profile) { require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); if ($customer_detail = $Customer->getUserByTwitterId($user_profile->id)) { //already exists a valid account, we can login msg("{$customer_detail['email']} is already registered", 'ok', 1); $_SESSION['client']['customer'] = $customer_detail; $_SESSION['use_page_cache'] = false; // auto login (TODO allow to enable/disable this behaviour) $Customer->generateAndSaveOnxshopToken($customer_detail['id']); } else { msg("Twitter ID {$user_profile->id} sucessfully authorised, but must register locally", 'ok', 1); //forward to registration $this->mapUserToOnxshop($user_profile); onxshopGoTo("/page/13"); //TODO get node_id from conf } }
/** * 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; }
/** * main action */ public function mainAction() { require_once 'models/common/common_session.php'; require_once 'models/common/common_session_archive.php'; $Session = new common_session(); $Session_archive = new common_session_archive(); $Session->setCacheable(false); require_once 'models/client/client_customer.php'; // filter if (isset($this->GET['filter'])) { $_SESSION['filter'] = $this->GET['filter']; } $filter = $_SESSION['filter']; if ($filter['active'] == 1) { $this->tpl->assign('ACTIVE_selected_1', "selected='selected'"); } else { $this->tpl->assign('ACTIVE_selected_0', "selected='selected'"); } if (!is_numeric($filter['customer_id']) || $filter['customer_id'] < 0) { $filter['customer_id'] = ''; } $this->tpl->assign("FILTER", $filter); $session_ttl = round($Session->conf['ttl'] / 3600, 1); $this->tpl->assign('SESSION_TTL', $session_ttl); $Customer = new client_customer(); $Customer->setCacheable(false); //pagination if (is_numeric($this->GET['limit_from']) && is_numeric($this->GET['limit_per_page'])) { $from = $this->GET['limit_from']; $per_page = $this->GET['limit_per_page']; } else { $from = 0; $per_page = 5; } $limit = "{$from},{$per_page}"; if (is_numeric($filter['customer_id'])) { $where = "customer_id = {$filter['customer_id']}"; } else { $where = ''; } $count_active = $Session->count($where); $count_archive = $Session_archive->count($where); if ($filter['active'] == 1) { $sessions = $Session->listing($where, 'modified DESC', $limit); $count = $count_active; } else { $session_active = $Session->listing($where, 'modified DESC', $limit); //pagination must be handled differently if (count($session_active) < $per_page) { //start to show archive, but use different "from" $from_archived = $from + count($session_active) - $count_active; $session_archive = $Session_archive->listing($where, 'modified DESC', "{$from_archived},{$per_page}"); $sessions = array_merge($session_active, $session_archive); } else { $sessions = $session_active; } $count = $count_active + $count_archive; } foreach ($sessions as $s) { $s['session_data'] = $this->unserialize_session_data($s['session_data']); if ($s['http_referer'] == '') { $link_block = "referer_na"; } else { $link_block = "referer_link"; } if (!is_array($s['session_data']['history'])) { $s['session_data']['history'] = array(); } foreach ($s['session_data']['history'] as $history) { //temp if (!is_array($history)) { $history = array('time' => 'n/a', 'uri' => $history); } else { $history['time'] = strftime('%H:%M', $history['time']); } $this->tpl->assign('HISTORY', $history); $this->tpl->parse('content.item.history'); } $s['time_diff'] = strtotime($s['modified']) - strtotime($s['created']); $s['time_diff'] = round($s['time_diff'] / 60); $s['created'] = strftime('%d/%m/%Y %H:%M', strtotime($s['created'])); $s['modified'] = strftime('%d/%m/%Y %H:%M', strtotime($s['modified'])); if ($s['customer_id'] > 0) { $this->tpl->assign('CUSTOMER', $Customer->detail($s['customer_id'])); } else { $this->tpl->assign('CUSTOMER', ''); } // show messages if (ONXSHOP_DEBUG_OUTPUT_FILE) { $messages_file = ONXSHOP_PROJECT_DIR . "var/log/messages/{$s['ip_address']}-{$s['session_id']}.log"; if (file_exists($messages_file)) { $s['messages'] = file_get_contents($messages_file); } } $this->tpl->assign('SESSION', $s); $this->tpl->parse("content.item.{$link_block}"); if ($s['messages'] != '') { $this->tpl->parse('content.item.session_messages'); } $this->tpl->parse('content.item'); } //pagination //$link = "/backoffice/advanced/logs"; $link = $_SERVER['REDIRECT_URL']; $_Onxshop_Request = new Onxshop_Request("component/pagination~limit_from={$from}:limit_per_page={$per_page}:count={$count}:link={$link}:option_show_all=1:option_per_page=1~"); $this->tpl->assign('PAGINATION', $_Onxshop_Request->getContent()); return true; }
/** * main action */ public function mainAction() { require_once 'models/client/client_customer.php'; require_once 'models/client/client_customer_taxonomy.php'; $Customer = new client_customer(); $Taxonomy = new client_customer_taxonomy(); //force cache even for back office user $Customer->setCacheable(true); /** * Filtering */ /** * Get the list */ $customer_filter = $_SESSION['bo']['customer-filter']; // account_type is integer, but we also allow in UI to use it for backoffice users if ($customer_filter['account_type'] == 'backoffice') { $customer_filter['backoffice_role_only'] = 1; } // get the list $customer_list = $Customer->getClientList(0, $customer_filter); if (is_array($customer_list) && count($customer_list) > 0) { /** * Sorting */ if ($this->GET['customer-list-sort-by']) { $_SESSION['bo']['customer-list-sort-by'] = $this->GET['customer-list-sort-by']; } if ($this->GET['customer-list-sort-direction']) { $_SESSION['bo']['customer-list-sort-direction'] = $this->GET['customer-list-sort-direction']; } if ($_SESSION['bo']['customer-list-sort-by']) { $sortby = $_SESSION['bo']['customer-list-sort-by']; } else { $sortby = "id"; } if ($_SESSION['bo']['customer-list-sort-direction']) { $direction = $_SESSION['bo']['customer-list-sort-direction']; } else { $direction = "DESC"; } //msg("Sorted by $sortby $direction"); switch ($sortby) { default: case 'id': $customer_list = php_multisort($customer_list, array(array('key' => 'customer_id', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric'))); foreach ($customer_list as $item) { $p[] = $item; } $customer_list = $p; break; case 'last_order': $customer_list = php_multisort($customer_list, array(array('key' => 'last_order', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric'))); foreach ($customer_list as $item) { $p[] = $item; } $customer_list = $p; break; case 'goods_net': $customer_list = php_multisort($customer_list, array(array('key' => 'goods_net', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric'))); foreach ($customer_list as $item) { $p[] = $item; } $customer_list = $p; break; case 'count_baskets': $customer_list = php_multisort($customer_list, array(array('key' => 'count_baskets', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric'))); foreach ($customer_list as $item) { $p[] = $item; } $customer_list = $p; break; case 'count_orders': $customer_list = php_multisort($customer_list, array(array('key' => 'count_orders', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric'))); foreach ($customer_list as $item) { $p[] = $item; } $customer_list = $p; break; case 'count_items': $customer_list = php_multisort($customer_list, array(array('key' => 'count_items', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric'))); foreach ($customer_list as $item) { $p[] = $item; } $customer_list = $p; break; } /** * Initialize pagination variables */ if (is_numeric($this->GET['limit_from'])) { $from = $this->GET['limit_from']; } else { $from = 0; } if (is_numeric($this->GET['limit_per_page'])) { $per_page = $this->GET['limit_per_page']; } else { $per_page = 25; } $limit = "{$from},{$per_page}"; /** * Display pagination */ //$link = "/page/" . $_SESSION['active_pages'][0]; $count = count($customer_list); $_Onxshop_Request = new Onxshop_Request("component/pagination~limit_from={$from}:limit_per_page={$per_page}:count={$count}~"); $this->tpl->assign('PAGINATION', $_Onxshop_Request->getContent()); /** * Display items * Implemented pagination */ foreach ($customer_list as $i => $customer) { if ($i >= $from && $i < $from + $per_page) { $even_odd = 'odd' != $even_odd ? 'odd' : 'even'; $item['even_odd'] = $even_odd; $taxonomy = $Taxonomy->getRelationsToCustomer($customer['customer_id']); foreach ($taxonomy as $t) { $customer['class'] .= "t{$t} "; } $role_ids = $Customer->getRoleIds($customer['customer_id']); foreach ($role_ids as $r) { $customer['class'] .= "role_{$r} "; } $this->tpl->assign('ITEM', $customer); $this->tpl->parse('content.list.item'); } } $this->tpl->parse('content.list'); } else { msg("No user found", 'error'); } return true; }
/** * Convert facebook user ids to local customer ids * * @return array */ protected function facebookToCustomerIds($facebook_ids) { $result = array(); if (is_array($facebook_ids) && count($facebook_ids) > 0 && ($ids = $this->prepareListForSql($facebook_ids, true))) { $Customer = new client_customer(); $list = $Customer->listing("facebook_id IN ({$ids})"); if (is_array($list) && count($list) > 0) { foreach ($list as $item) { $result[] = $item['id']; } } } return $result; }
/** * processCustomerDetails */ public function processCustomerDetails($form_data) { require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); $customer_details = $Customer->getClientByEmail($form_data['email']); if (is_numeric($customer_details['id'])) { return $Customer->mergePreservedAccount($customer_details, $form_data); } else { return $Customer->insertPreservedCustomer($form_data); } }
/** * get customer detail * * @param integer $id * customer ID * * @return array * customer informations */ function getCustomerDetail($id) { require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $data = $Customer->getClientData($id); return $data; }
/** * 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; }
/** * get detail of one order * * @param unknown_type $id * @return unknown */ function getOrder($id) { require_once 'models/ecommerce/ecommerce_basket.php'; require_once 'models/client/client_customer.php'; require_once 'models/ecommerce/ecommerce_order_log.php'; require_once 'models/ecommerce/ecommerce_delivery.php'; $Basket = new ecommerce_basket(); $Customer = new client_customer(); $OrderLog = new ecommerce_order_log(); $Delivery = new ecommerce_delivery(); $Basket->setCacheable(false); $Customer->setCacheable(false); $OrderLog->setCacheable(false); //this can be cached (submitted orders cannot change address) $Delivery->setCacheable(false); $order = $this->getDetail($id); //get promotion code $order['promotion_code'] = $this->getPromotionCode($id); //get basket detail $basket_detail = $Basket->getDetail($order['basket_id']); $include_vat = $this->isVatEligible($order['delivery_address_id'], $basket_detail['customer_id']); $basket_content = $Basket->getFullDetail($order['basket_id'], GLOBAL_DEFAULT_CURRENCY); $Basket->calculateBasketSubTotals($basket_content, $include_vat); $Basket->calculateBasketDiscount($basket_content, $order['promotion_code'], false); $basket_content['delivery'] = $Delivery->getDeliveryByOrderId($id); $Basket->calculateBasketTotals($basket_content); $order['basket'] = $basket_content; //get client detail $order['client'] = $Customer->getClientData($basket_content['customer_id']); //get status (log) detail $order['log'] = $OrderLog->getLog($id); $order['status_title'] = $this->getStatusTitle($order['status']); //get address detail require_once 'models/client/client_address.php'; $Address = new client_address(); $Address->setCacheable(false); $address_detail['delivery'] = $Address->getDetail($order['delivery_address_id']); $address_detail['invoices'] = $Address->getDetail($order['invoices_address_id']); $order['address'] = $address_detail; //get invoice detail $order['invoice'] = $this->getInvoiceDetail($id); //get transaction detail $order['transaction'] = $this->getTransactionDetail($id); // get stats $order['client']['stats'] = $this->getNumberOfCustomersOrders($basket_detail['customer_id']); //print_r($order); return $order; }
/** * main action */ public function mainAction() { /** * initialise client_customer object */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); /** * process when submited */ if ($_POST['submit']) { /** * assign first */ if (is_array($_POST['client'])) { $this->tpl->assign('CLIENT', $_POST['client']); } /** * get detail */ $customer_data = $Customer->getClientByEmail($_POST['client']['customer']['email']); /** * when real client, get key */ if (is_array($customer_data)) { $current_key = $Customer->getPasswordKey($_POST['client']['customer']['email']); $customer_data['password_key'] = $current_key; } /** * if key was generated successfully, than send it by email */ if ($current_key) { require_once 'models/common/common_email.php'; $EmailForm = new common_email(); //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']['customer'] = $customer_data; if (!$EmailForm->sendEmail('request_password_change', 'n/a', $customer_data['email'], $customer_data['first_name'] . " " . $customer_data['last_name'])) { msg("Can't send email with request for password reset", 'error'); } $this->tpl->parse('content.request_sent'); $hide_form = 1; } } /** * reset password when valied email and key is provided */ if ($this->GET['email'] && $this->GET['key']) { if ($Customer->resetPassword($this->GET['email'], $this->GET['key'])) { msg("Password for {$this->GET['email']} has for been renewed.", 'ok', 2); $this->tpl->parse('content.password_changed'); $hide_form = 1; } } /** * conditional display form */ if ($hide_form == 0) { $this->tpl->parse('content.request_form'); } return true; }
public function authenticate($username, $password) { $Client_Customer = new client_customer(); $Client_Customer->setCacheable(false); $customer_detail = $Client_Customer->login($username, md5($password)); if ($customer_detail) { $Permission = new client_role_permission(); $Permission->setCacheable(false); if ($Permission->isBackofficeUser($customer_detail['id'])) { return $customer_detail; } } return false; }
/** * add customers to group */ public function addCustomersToGroup($group_id, $group_ids_remove) { require_once 'models/client/client_group.php'; require_once 'models/client/client_customer.php'; $ClientGroup = new client_group(); $Customer = new client_customer(); //force cache even for back office user $Customer->setCacheable(true); if ($group_filter = $this->getGroupFilter($group_id)) { $customer_list = $Customer->getClientList(0, $group_filter); $list_count = count($customer_list); if ($Customer->addCustomersToGroupFromList($customer_list, $group_id, $group_ids_remove)) { msg("All {$list_count} customers were added to group ID {$group_id}"); //flush cache as we are using forced cache for client_customer in backoffice $Customer->flushCache(); } else { msg("Cannot add {$list_count} customers to group ID {$group_id}", 'error'); return false; } } else { return false; } }
/** * 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; }
/** * main action */ public function mainAction() { $customer_id = $_SESSION['client']['customer']['id']; if (!is_numeric($customer_id)) { msg("Address management requires active customer ID"); return true; } /** * initialize */ require_once 'models/client/client_customer.php'; require_once 'models/client/client_address.php'; require_once 'models/international/international_country.php'; $Customer = new client_customer(); $Address = new client_address(); $Country = new international_country(); $Customer->setCacheable(false); $Address->setCacheable(false); /** * add address */ if ($_POST['add_address']) { $_POST['client']['address']['customer_id'] = $customer_id; if ($address_id = $Address->insert($_POST['client']['address'])) { msg('New address added to your list.'); } else { msg('Address is not valid', 'error'); } } /** * select address */ if ($_POST['select_address']) { $customer_detail = $Customer->detail($customer_id); $customer_detail["{$this->GET['type']}_address_id"] = $_POST['select_address']; if ($Customer->update($customer_detail)) { $_SESSION['client']['customer'] = $customer_detail; onxshopGoTo($_SESSION['referer'], 2); } else { msg("Cannot select this address", 'error'); } } /** * remove address */ if (is_numeric($_POST['remove_address'])) { $address_id_to_remove = $_POST['remove_address']; $address_detail = $Address->detail($address_id_to_remove); if ($address_detail['customer_id'] == $customer_id) { if ($Address->deleteAddress($address_id_to_remove)) { msg('Address has been removed'); } else { msg('Cannot remove address', 'error'); } } else { msg("This is not your address!", 'error'); } } /** * address list */ $addresses = $Address->listing("customer_id = {$customer_id} AND is_deleted IS NOT TRUE", "id DESC"); $current_invoices = $_SESSION['client']['customer']['invoices_address_id']; $current_delivery = $_SESSION['client']['customer']['delivery_address_id']; foreach ($addresses as $addr) { $country_detail = $Country->detail($addr['country_id']); $addr['country'] = $country_detail; $this->tpl->assign('address', $addr); if ($addr['line_2'] != '') { $this->tpl->parse('content.address.line_2'); } if ($addr['line_3'] != '') { $this->tpl->parse('content.address.line_3'); } if ($this->GET['type'] != '') { $this->tpl->parse('content.address.select'); } else { if ($addr['id'] != $current_invoices && $addr['id'] != $current_delivery) { $this->tpl->parse('content.address.delete'); } } if ($current_invoices == $addr['id']) { $this->tpl->parse('content.address.is_invoices'); } if ($current_delivery == $addr['id']) { $this->tpl->parse('content.address.is_delivery'); } $this->tpl->parse('content.address'); } /** * country list */ $countries = $Country->listing("", "name ASC"); if (!isset($_POST['client']['address']['country_id'])) { $_POST['client']['address']['country_id'] = $Country->conf['default_id']; } foreach ($countries as $c) { if ($c['publish'] == 1) { if ($c['id'] == $_POST['client']['address']['country_id']) { $c['selected'] = "selected='selected'"; } else { $c['selected'] = ''; } $this->tpl->assign('country', $c); $this->tpl->parse('content.country.item'); } } $this->tpl->parse('content.country'); /** * assign to template */ $this->tpl->assign('client', $_POST['client']); return true; }
/** * Returns customer detail if given token exists and is published * otherwise return false */ function getCustomerDetailForToken($token) { if (strlen($token) != 32) { return false; } $token_escaped = pg_escape_string($token); $result = $this->listing("token = '{$token_escaped}' AND publish = 1"); if ($result[0]['customer_id'] > 0) { require_once 'models/client/client_customer.php'; $Customer = new client_customer(); $Customer->setCacheable(false); $customer_detail = $Customer->detail($result[0]['customer_id']); return $customer_detail; } return false; }
/** * Update customer's other_data to include given home store_id * * @param int $store_id Store id */ protected function updateCustomersHomeStore($store_id) { $customer_id = (int) $_SESSION['client']['customer']['id']; if ($customer_id == 0) { return false; } $Customer = new client_customer(); // update other_data $_SESSION['client']['customer']['store_id'] = $store_id; $Customer->updateCustomer(array('id' => $customer_id, 'other_data' => $_SESSION['client']['customer']['other_data'])); return true; }
/** * main action */ public function mainAction() { /** * create object */ require_once 'models/client/client_customer.php'; $Customer = new client_customer(); /** * Set Variables */ if ($this->GET['type'] == 'worst') { $order = 'ASC'; } else { $order = 'DESC'; } /** * number of items limit */ if (is_numeric($this->GET['limit'])) { $limit = $this->GET['limit']; } else { $limit = false; } /** * period limit in days */ if (is_numeric($this->GET['period_limit'])) { $period_limit = $this->GET['period_limit']; } else { $period_limit = 7; } /** * customer limit */ if (is_numeric($this->GET['customer_id'])) { $customer_id = $this->GET['customer_id']; } else { if ($this->GET['customer_id'] == 'session') { if ($_SESSION['client']['customer']['id'] > 0) { $customer_id = $_SESSION['client']['customer']['id']; } else { msg("You are not logged in as a customer, displaying normal best buys"); $customer_id = false; } } else { $customer_id = false; } } /** * Get product_list */ $product_list = $Customer->getProductsByCustomer($order, $limit, $customer_id, $period_limit); /** * if product sales in last 7 was empty, recalculate with no period limit */ if (count($product_list) == 0) { $period_limit = 0; $product_list = $Customer->getProductsByCustomer($order, $limit, $customer_id, $period_limit); } /** * Pass product_id_list to product_list controller */ $this->renderList($product_list); return true; }