/** * 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; }
/** * 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; }
/** * 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; }