예제 #1
0
파일: edit.php 프로젝트: AppChecker/onxshop
 /**
  * main action
  */
 public function mainAction()
 {
     $this->Customer = new client_customer();
     $this->Company = new client_company();
     $this->Customer->setCacheable(false);
     $this->Company->setCacheable(false);
     $this->auth = Onxshop_Bo_Authentication::getInstance();
     if (is_numeric($this->GET['id'])) {
         $customer_id = $this->GET['id'];
     } else {
         $customer_id = 0;
     }
     /**
      * include node configuration
      */
     $node_conf = common_node::initConfiguration();
     $this->tpl->assign('NODE_CONF', $node_conf);
     /**
      * check access 
      */
     if (!$this->auth->hasPermission('customers', 'view')) {
         return false;
     }
     $this->saveForm($customer_id);
     $this->parseDetails($customer_id);
     return true;
 }
예제 #2
0
 /**
  * prepare data for payment gateway
  */
 function paymentPrepare($order_id)
 {
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     //$this->tpl->assign('NODE_CONF', $node_conf);
     $order_data = $this->Transaction->getOrderDetail($order_id);
     /**
      * process payment method only if status = 0 unpaid or 5 failed payment
      * 
      */
     if (!$this->checkOrderStatusValidForPayment($order_data['status'])) {
         return false;
     }
     if ($_SERVER['HTTPS']) {
         $protocol = 'https';
     } else {
         $protocol = 'http';
     }
     $server_url = "{$protocol}://{$_SERVER['HTTP_HOST']}";
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $worldpay_amount = $Order->calculatePayableAmount($order_data);
     $worldpay = array('URL' => ECOMMERCE_TRANSACTION_WORLDPAY_URL, 'instId' => ECOMMERCE_TRANSACTION_WORLDPAY_INSID, 'cartId' => $order_data['id'], 'amount' => $worldpay_amount, 'currency' => GLOBAL_DEFAULT_CURRENCY, 'desc' => ECOMMERCE_TRANSACTION_WORLDPAY_DESCRIPTION, 'testMode' => ECOMMERCE_TRANSACTION_WORLDPAY_TESTMODE, 'name' => $order_data['client']['customer']['title_before'] . ' ' . $order_data['client']['customer']['first_name'] . ' ' . $order_data['client']['customer']['last_name'], 'address' => $order_data['address']['invoices']['line_1'], 'postcode' => $order_data['address']['invoices']['post_code'], 'country' => $order_data['address']['invoices']['country']['iso_code2'], 'tel' => $order_data['address']['invoices']['telephone'], 'email' => $order_data['client']['customer']['email'], 'MC_callback' => "{$server_url}/page/" . $node_conf['id_map-payment_worldpay_callback'] . "?order_id={$order_data['id']}");
     return $worldpay;
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
 /**
  * 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;
 }
예제 #5
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     $this->tpl->assign("NODE_CONF", $node_conf);
     return true;
 }
예제 #6
0
 /**
  * prepare data for payment gateway
  */
 function paymentPrepare($order_id)
 {
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     $order_data = $this->Transaction->getOrderDetail($order_id);
     if ($_SERVER['HTTPS']) {
         $protocol = 'https';
     } else {
         $protocol = 'http';
     }
     $server_url = "{$protocol}://{$_SERVER['HTTP_HOST']}";
     $protx = array('URL' => ECOMMERCE_TRANSACTION_PROTX_URL, 'VPSProtocol' => ECOMMERCE_TRANSACTION_PROTX_VPSPROTOCOL, 'Vendor' => ECOMMERCE_TRANSACTION_PROTX_VENDOR, 'TxType' => ECOMMERCE_TRANSACTION_PROTX_TXTYPE, 'Crypt' => '', 'VendorEmail' => ECOMMERCE_TRANSACTION_PROTX_VENDOR_EMAIL);
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $protx_amount = $Order->calculatePayableAmount($order_data);
     $protx['Crypt']['VendorTxCode'] = $order_data['id'] . '_' . time();
     $protx['Crypt']['Amount'] = $protx_amount;
     $protx['Crypt']['Currency'] = GLOBAL_DEFAULT_CURRENCY;
     $protx['Crypt']['Description'] = "Payment for Basket created {$order_data['basket']['created']}";
     $protx['Crypt']['SuccessURL'] = "{$server_url}/page/" . $node_conf['id_map-payment_protx_success'] . "?order_id={$order_data['id']}";
     $protx['Crypt']['FailureURL'] = "{$server_url}/page/" . $node_conf['id_map-payment_protx_success'] . "?order_id={$order_data['id']}";
     $protx['Crypt']['CustomerEMail'] = $order_data['client']['customer']['email'];
     $protx['Crypt']['VendorEMail'] = $protx['VendorEmail'];
     $protx['Crypt']['eMailMessage'] = ECOMMERCE_TRANSACTION_PROTX_MAIL_MESSAGE;
     $protx['Crypt']['BillingSurname'] = $order_data['client']['customer']['last_name'];
     $protx['Crypt']['BillingFirstNames'] = $order_data['client']['customer']['first_name'];
     $protx['Crypt']['BillingAddress1'] = $order_data['address']['invoices']['line_1'];
     $protx['Crypt']['BillingCity'] = $order_data['address']['invoices']['city'];
     $protx['Crypt']['BillingPostCode'] = $order_data['address']['invoices']['post_code'];
     $protx['Crypt']['BillingCountry'] = $order_data['address']['invoices']['country']['iso_code2'];
     $protx['Crypt']['DeliverySurname'] = $order_data['client']['customer']['last_name'];
     $protx['Crypt']['DeliveryFirstNames'] = $order_data['client']['customer']['first_name'];
     $delivery_name = explode(" ", trim($order_data['address']['delivery']['name']));
     foreach ($delivery_name as $i => $item) {
         if ($i == 0) {
             $protx['Crypt']['DeliveryFirstNames'] = trim($item);
         }
         if ($i == count($delivery_name) - 1) {
             $protx['Crypt']['DeliverySurname'] = trim($item);
         }
     }
     $protx['Crypt']['DeliveryAddress1'] = $order_data['address']['delivery']['line_1'];
     $protx['Crypt']['DeliveryCity'] = $order_data['address']['delivery']['city'];
     $protx['Crypt']['DeliveryPostCode'] = $order_data['address']['delivery']['post_code'];
     $protx['Crypt']['DeliveryCountry'] = $order_data['address']['delivery']['country']['iso_code2'];
     $protx['Crypt']['Basket'] = '';
     $basket = count($order_data['basket']['items']);
     //Number of items in basket:Item 1 Description:Quantity of item 1:Unit cost item 1 minus tax:Tax of item 1:Cost of Item 1 inc tax:Total cost of item 1 (Quantity x cost inc tax):Item 2 Description:Quantity of item 2: .... :Cost of Item n inc tax:Total cost of item n
     foreach ($order_data['basket']['items'] as $item) {
         $basket = $basket . ':' . $item['product']['variety']['sku'] . ' - ' . $item['product']['name'] . ':' . $item['quantity'] . ':' . $item['product']['variety']['price'][GLOBAL_DEFAULT_CURRENCY]['price']['common']['value'] . ':' . $item['product']['variety']['price'][GLOBAL_DEFAULT_CURRENCY]['vat'] . ':' . $item['product']['variety']['price'][GLOBAL_DEFAULT_CURRENCY]['price']['common']['value_vat'] . ':' . $item['total_inc_vat'];
     }
     $protx['Crypt']['Basket'] = $basket;
     foreach ($protx['Crypt'] as $key => $val) {
         $crypt = $crypt . '&' . $key . '=' . $val;
     }
     $crypt = ltrim($crypt, '&');
     $protx['Crypt'] = self::encryptAes($crypt, ECOMMERCE_TRANSACTION_PROTX_PASSWORD);
     return $protx;
 }
예제 #7
0
 /**
  * main action
  */
 function mainAction()
 {
     /**
      * include node configuration
      */
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     $this->tpl->assign('NODE_CONF', $node_conf);
     /**
      * create product object
      */
     $this->Product = new ecommerce_product();
     $this->ProductVariety = new ecommerce_product_variety();
     $product_id = $this->GET['product_id'];
     $sku = $this->GET['sku'];
     if ($sku && !is_numeric($product_id)) {
         $variety_list = $this->ProductVariety->getVarietyListForSKU($sku);
     } else {
         $variety_list = $this->Product->getProductVarietyList($product_id);
     }
     if ($variety_list) {
         $product = $this->Product->getDetail($product_id);
         /**
          * variety list
          */
         foreach ($variety_list as $key => $variety) {
             if ($variety['publish'] == 1) {
                 //mark first variety checked
                 if ($key == 0) {
                     $variety['checked'] = "checked='checked'";
                 }
                 $this->tpl->assign('PRODUCT', $product);
                 $this->tpl->assign('VARIETY', $variety);
                 $Price = new Onxshop_Request("component/ecommerce/price~product_variety_id={$variety['id']}~");
                 $this->tpl->assign("PRICE", $Price->getContent());
                 if ($variety['stock'] > 0) {
                     if (trim($variety['subtitle']) != '') {
                         $this->tpl->parse("content.variety.item.onstock.subtitle");
                     }
                     $this->tpl->parse("content.variety.item.onstock");
                 } else {
                     if ($variety['stock'] < 0) {
                         $this->tpl->parse("content.variety.item.special");
                     } else {
                         $this->tpl->parse("content.variety.item.outofstock");
                     }
                 }
                 $this->tpl->parse("content.variety.item");
             }
         }
         /**
          * product options
          */
         $this->addProductOptions($product_id);
         $this->tpl->parse('content.variety');
         return true;
     }
 }
예제 #8
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     if ($_SESSION['client']['customer']['id'] > 0) {
         onxshopGoTo("page/{$node_conf['id_map-checkout_delivery_options']}");
     } else {
         onxshopGoTo("page/{$node_conf['id_map-checkout_login']}");
     }
     return true;
 }
예제 #9
0
 /**
  * public action
  */
 public function mainAction()
 {
     parent::mainAction();
     if ($_SESSION['client']['customer']['id'] == 0) {
         $node_conf = common_node::initConfiguration();
         onxshopGoto($node_conf['id_map-checkout_login']);
     }
     if ($_POST['node_id'] == $this->GET['node_id'] && is_numeric($_POST['selected_address_id'])) {
         onxshopGoto("page/{$_SESSION['active_pages'][0]}");
     }
     return true;
 }
예제 #10
0
 /**
  * init basket
  */
 protected function initModels()
 {
     $node_conf = common_node::initConfiguration();
     $this->tpl->assign('NODE_CONF', $node_conf);
     $this->Basket = new ecommerce_basket();
     $this->Basket->setCacheable(false);
     $this->Basket_content = new ecommerce_basket_content();
     $this->Basket_content->setCacheable(false);
     $this->Order = new ecommerce_order();
     $this->Order->setCacheable(false);
     return $Basket;
 }
예제 #11
0
 /**
  * get checkout pages ids
  */
 public function getCheckoutPagesIdMap()
 {
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     $this->tpl->assign('NODE_CONF', $node_conf);
     $conf['id_map-checkout_basket'] = $node_conf['id_map-checkout_basket'];
     $conf['id_map-checkout_login'] = $node_conf['id_map-checkout_login'];
     $conf['id_map-checkout_delivery_options'] = $node_conf['id_map-checkout_delivery_options'];
     $conf['id_map-checkout_gift'] = $node_conf['id_map-checkout_gift'];
     $conf['id_map-checkout_summary'] = $node_conf['id_map-checkout_summary'];
     $conf['id_map-checkout_payment'] = $node_conf['id_map-checkout_payment'];
     $conf['id_map-checkout_payment_success'] = $node_conf['id_map-checkout_payment_success'];
     $conf['id_map-checkout_payment_failure'] = $node_conf['id_map-checkout_payment_failure'];
     return $conf;
 }
예제 #12
0
 /**
  * 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);
     /**
      * basket
      */
     if (is_numeric($_SESSION['basket']['id']) && $this->customerData()) {
         $_Onxshop_Request = new Onxshop_Request("component/ecommerce/basket_detail");
         $this->tpl->assign("BASKET_DETAIL", $_Onxshop_Request->getContent());
     }
     return true;
 }
예제 #13
0
 public function mainAction()
 {
     $this->node_conf = common_node::initConfiguration();
     $this->tpl->assign('NODE_CONF', $this->node_conf);
     $this->Watchdog = new common_watchdog();
     $this->Product = new ecommerce_product();
     $this->Watchdog->setCacheable(false);
     // disable db cache for front-end users
     $customer_id = (int) $_SESSION['client']['customer']['id'];
     if ($this->GET['unsubscribe']) {
         $this->processUnsubscription($this->GET['wid'], $this->GET['unsubscribe'], $customer_id);
     } else {
         $this->forceLogin($customer_id);
         $this->processSubscription($customer_id, $this->GET['product_variety_id']);
         $this->listWatchedItems($customer_id);
     }
     return true;
 }
예제 #14
0
 /**
  * main action
  */
 public function mainAction()
 {
     if ($_SESSION['client']['customer']['id'] > 0) {
         $customer_id = $_SESSION['client']['customer']['id'];
     } else {
         if (Onxshop_Bo_Authentication::getInstance()->isAuthenticated()) {
             $customer_id = $this->GET['customer_id'];
         } else {
             msg('orders: You must be logged in first.', 'error');
             onxshopGoTo("/");
         }
     }
     /**
      * include node configuration
      */
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     $this->tpl->assign('NODE_CONF', $node_conf);
     /**
      * Get the list
      */
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $Order->setCacheable(false);
     $records = $Order->getOrderList($customer_id);
     /**
      * parse output
      */
     if (count($records) > 0) {
         foreach ($records as $item) {
             $item['order_created'] = strftime('%d/%m/%Y&nbsp;%H:%M', strtotime($item['order_created']));
             $item['status_title'] = $Order->getStatusTitle($item['order_status']);
             $this->tpl->assign('ITEM', $item);
             if ($Order->checkOrderStatusValidForPayment($item['order_status'])) {
                 $this->tpl->parse('content.orders.item.make_payment');
             }
             $this->tpl->parse('content.orders.item');
         }
         $this->tpl->parse('content.orders');
     } else {
         $this->tpl->parse('content.noorders');
     }
     return true;
 }
예제 #15
0
 /**
  * init configuration
  */
 static function initConfiguration()
 {
     if (array_key_exists('common_uri_mapping', $GLOBALS['onxshop_conf'])) {
         $conf = $GLOBALS['onxshop_conf']['common_uri_mapping'];
     } else {
         $conf = array();
     }
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     /**
      * default settings
      */
     if (!array_key_exists('homepage_id', $conf)) {
         $conf['homepage_id'] = $node_conf['id_map-homepage'];
     }
     if (!array_key_exists('404_id', $conf)) {
         $conf['404_id'] = $node_conf['id_map-404'];
     }
     if (!array_key_exists('seo', $conf)) {
         $conf['seo'] = true;
     }
     if (!array_key_exists('rewrite_home', $conf)) {
         $conf['rewrite_home'] = true;
     }
     if (!array_key_exists('delimiter', $conf)) {
         $conf['delimiter'] = '/';
     }
     if (!array_key_exists('append', $conf)) {
         $conf['append'] = '';
     }
     if (!array_key_exists('hash', $conf)) {
         $conf['hash'] = false;
     }
     if (!array_key_exists('and_string', $conf)) {
         $conf['and_string'] = I18N_AND;
     }
     return $conf;
 }
예제 #16
0
 /**
  * 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;
 }
예제 #17
0
 /**
  * prepare data for payment gateway
  */
 function paymentPrepare($order_id)
 {
     if (!is_numeric($order_id)) {
         return false;
     }
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     //$this->tpl->assign('NODE_CONF', $node_conf);
     $order_data = $this->Transaction->getOrderDetail($order_id);
     /**
      * process payment method only if status = 0 unpaid or 5 failed payment
      * 
      */
     if (!$this->checkOrderStatusValidForPayment($order_data['status'])) {
         return false;
     }
     /**
      * check if SSL is enabled
      */
     if ($_SERVER['HTTPS']) {
         $protocol = 'https';
     } else {
         $protocol = 'http';
     }
     $server_url = "{$protocol}://{$_SERVER['HTTP_HOST']}";
     /**
      * prepare data
      */
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $total_amount = $Order->calculatePayableAmount($order_data);
     $payment_gateway_data = array();
     $payment_gateway_data['order_data'] = $order_data;
     $payment_gateway_data['total_amount'] = $total_amount;
     $payment_gateway_data['server_url'] = $server_url;
     return $payment_gateway_data;
 }
예제 #18
0
 /**
  * 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);
     /**
      * client
      */
     require_once 'models/client/client_address.php';
     $Address = new client_address();
     if (is_numeric($this->GET['invoices_address_id'])) {
         $invoices_address_id = $this->GET['invoices_address_id'];
     }
     if (is_numeric($this->GET['delivery_address_id'])) {
         $delivery_address_id = $this->GET['delivery_address_id'];
     }
     //if we have not address_ids, we'll use session data
     if (!is_numeric($invoices_address_id) && !is_numeric($delivery_address_id)) {
         $invoices_address_id = $_SESSION['client']['customer']['invoices_address_id'];
         $delivery_address_id = $_SESSION['client']['customer']['delivery_address_id'];
     }
     if (is_numeric($invoices_address_id)) {
         $invoices = $Address->getDetail($invoices_address_id);
     } else {
         $invoices = false;
     }
     if (is_numeric($delivery_address_id)) {
         $delivery = $Address->getDetail($delivery_address_id);
     } else {
         $delivery = false;
     }
     $addr['invoices'] = $invoices;
     $addr['delivery'] = $delivery;
     $this->tpl->assign('ADDRESS', $addr);
     if (is_array($addr['invoices'])) {
         if ($addr['invoices']['line_2'] != '') {
             $this->tpl->parse('content.invoices.line_2');
         }
         if ($addr['invoices']['line_3'] != '') {
             $this->tpl->parse('content.invoices.line_3');
         }
         if ($this->GET['hide_button'] == 0) {
             $this->tpl->parse('content.invoices.button');
         }
         $this->tpl->parse('content.invoices');
     } else {
         if ($this->GET['hide_button'] == 0) {
             $this->tpl->parse('content.invoices_add_button');
         }
     }
     if (is_array($addr['delivery'])) {
         if ($addr['delivery']['line_2'] != '') {
             $this->tpl->parse('content.delivery.line_2');
         }
         if ($addr['delivery']['line_3'] != '') {
             $this->tpl->parse('content.delivery.line_3');
         }
         if ($this->GET['hide_button'] == 0) {
             $this->tpl->parse('content.delivery.button');
         }
         $this->tpl->parse('content.delivery');
     } else {
         if ($this->GET['hide_button'] == 0) {
             $this->tpl->parse('content.delivery_add_button');
         }
     }
     return true;
 }
예제 #19
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * get input
      */
     if (is_array($_POST['order'])) {
         $order_data = $_POST['order'];
     } else {
         $order_data = array();
     }
     /**
      * get node configuration
      */
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     $this->tpl->assign('NODE_CONF', $node_conf);
     /**
      * init basket
      */
     require_once 'models/ecommerce/ecommerce_order.php';
     require_once 'models/ecommerce/ecommerce_basket.php';
     $Order = new ecommerce_order();
     $Basket = new ecommerce_basket();
     $Order->setCacheable(false);
     $Basket->setCacheable(false);
     //temp
     if ($_POST['client']['customer']['currency_code']) {
         $currency_code = $_POST['client']['customer']['currency_code'];
     } else {
         $currency_code = $_SESSION['client']['customer']['currency_code'];
     }
     if ($_SESSION['client']['customer']['id'] > 0) {
         if (is_numeric($basket_id = $_SESSION['basket']['id'])) {
             //update basket
             $basket_detail = $Basket->detail($basket_id);
             $basket_detail['customer_id'] = $_SESSION['client']['customer']['id'];
             $Basket->update($basket_detail);
             //insert order
             if (isset($_POST['confirm'])) {
                 if ($_POST['order_terms_agreed'] == 'on') {
                     //insert only orders with some items in the basket :)
                     $basket_content = $Basket->getFullDetail($basket_id);
                     if (count($basket_content['items']) > 0) {
                         $order_data = $_POST['order'];
                         $order_data['basket_id'] = $_SESSION['basket']['id'];
                         $order_data['invoices_address_id'] = $_SESSION['client']['customer']['invoices_address_id'];
                         $order_data['delivery_address_id'] = $_SESSION['client']['customer']['delivery_address_id'];
                         $order_data['other_data']['delivery_options'] = $_SESSION['delivery_options'];
                         $order_data['other_data']['promotion_code'] = $_SESSION['promotion_code'];
                         $order_data['php_session_id'] = session_id();
                         if ($inserted_order_id = $Order->insertOrder($order_data)) {
                             $_SESSION['promotion_code'] = null;
                             $_SESSION['basket']['id'] = null;
                             //forward to payment page with pre-selected payment method
                             //onxshopGoTo("page/" . $node_conf['id_map-payment'] . "?order_id=$inserted_order_id&selected_poyment_type={$order_data['payment_type']}");
                             onxshopGoTo("page/" . $node_conf['id_map-payment'] . "?order_id={$inserted_order_id}");
                         }
                     } else {
                         msg("Can't insert an empty order.", 'error');
                     }
                 } else {
                     msg("You must agree with our Terms & Conditions", 'error');
                 }
             }
         }
         /**
          * prepare list of payment options
          */
         require_once 'models/ecommerce/ecommerce_transaction.php';
         $Transaction = new ecommerce_transaction();
         $transaction_type_allowed = $Transaction->conf['allowed_types'];
         foreach ($transaction_type_allowed as $type) {
             $this->tpl->parse("content.{$type}");
         }
         /**
          * gift option
          */
         if ($_SESSION['gift'] == 1) {
             $this->tpl->assign("GIFT", 1);
             $this->tpl->parse('content.gift');
         } else {
             $this->tpl->assign('GIFT', 0);
         }
         /**
          * gift message
          */
         if ($_SESSION['gift_message'] != '') {
             $this->tpl->assign("GIFT_MESSAGE", $_SESSION['gift_message']);
             $this->tpl->parse('content.gift_message');
         } else {
             $this->tpl->assign("GIFT_MESSAGE", '');
         }
     } else {
         //msg('You must be logged in first.', 'error');
         $_SESSION['to'] = "page/" . $node_conf['id_map-checkout'];
         onxshopGoTo("page/" . $node_conf['id_map-login']);
     }
     $this->tpl->assign("ORDER", $_POST['order']);
     /**
      * display virtual product option
      */
     if ($this->isBasketVirtualProductOnly()) {
         $this->tpl->parse('content.virtual_product');
     }
     return true;
 }
예제 #20
0
 /**
  * redirectToDeliveryOptionsPage
  */
 protected function redirectToDeliveryOptionsPage()
 {
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     msg("Sorry, selected delivery method cannot be used. Please choose a different one.");
     // forward only if there is a separate checkout delivery options page
     if ($node_conf['id_map-checkout_delivery_options'] != $_SESSION['active_pages'][0]) {
         onxshopGoTo("page/{$node_conf['id_map-checkout_delivery_options']}");
     }
 }
예제 #21
0
 /**
  * format a message
  * 
  * @param string $template
  * message template file name
  * 
  * @return array
  * formated message data
  */
 function _format($template)
 {
     $orig = $this->get('content');
     $this->content = nl2br($this->get('content'));
     $tpl = new XTemplate("{$template}.html", getTemplateDir("{$template}.html", 'mail/'));
     $vars = get_object_vars($this);
     $tpl->assign('EMAIL', $vars);
     //read passed data
     if (is_array($GLOBALS['common_email'])) {
         $tpl->assign('DATA', $GLOBALS['common_email']);
     }
     // from $Onxshop_Request->_initTemplateVariables
     if ($_SERVER['SSL_PROTOCOL'] || $_SERVER['HTTPS']) {
         $protocol = 'https';
     } else {
         $protocol = 'http';
     }
     $tpl->assign('PROTOCOL', $protocol);
     $tpl->assign('URI', "{$protocol}://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}");
     $tpl->assign('_SERVER', $_SERVER);
     $tpl->assign('_SESSION', $_SESSION);
     $tpl->assign('CONFIGURATION', $GLOBALS['onxshop_conf']);
     $tpl->assign('_POST', $_POST);
     $tpl->assign('_GET', $_GET);
     $tpl->assign('GET', $_GET);
     // assign also to GET variable to keep consitent with normal templates initiated via a controller
     $tpl->assign('TIME', time());
     /**
      * include node configuration
      */
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     $tpl->assign('NODE_CONF', $node_conf);
     /**
      * parse
      */
     $tpl->parse('title');
     $tpl->parse('content');
     $this->content = $orig;
     $data['title'] = $tpl->text('title');
     $data['content']['html'] = $tpl->text('content');
     //get the text version
     $data['content']['txt'] = html2text($data['content']['html']);
     //convert relative links to absolute
     $data['content']['html'] = $this->rel2abs("http://{$_SERVER['HTTP_HOST']}", $data['content']['html']);
     $data['content']['txt'] = $this->rel2abs("http://{$_SERVER['HTTP_HOST']}", $data['content']['txt']);
     return $data;
 }
예제 #22
0
 /**
  * forward action
  */
 public function forwardAfterLogin()
 {
     /**
      * include node configuration
      */
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     //$this->tpl->assign('NODE_CONF', $node_conf);
     /**
      * check
      */
     if ($this->GET['to'] && !$_SESSION['to']) {
         if ($this->GET['to'] == 'ajax') {
             return true;
         } else {
             onxshopGoTo($this->GET['to']);
         }
     } else {
         if ($_SESSION['to']) {
             $to = $_SESSION['to'];
             $_SESSION['to'] = false;
             onxshopGoTo($to);
         } else {
             onxshopGoTo("page/" . $node_conf['id_map-myaccount']);
         }
     }
 }
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * include node configuration
      */
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     /**
      * client
      */
     require_once 'models/client/client_address.php';
     $Address = new client_address();
     if (is_numeric($this->GET['invoices_address_id'])) {
         $invoices_address_id = $this->GET['invoices_address_id'];
     }
     if (is_numeric($this->GET['delivery_address_id'])) {
         $delivery_address_id = $this->GET['delivery_address_id'];
     }
     // is guest checkout required?
     $guest_checkout = $_SESSION['client']['customer']['guest'];
     // address edit link
     if ($guest_checkout) {
         $this->tpl->assign('UPDATE_PAGE_ID', $node_conf['id_map-guest_registration']);
     } else {
         $this->tpl->assign('UPDATE_PAGE_ID', $node_conf['id_map-checkout_delivery_options']);
     }
     //if we have not address_ids, we'll use session data
     if (!is_numeric($invoices_address_id) && !is_numeric($delivery_address_id)) {
         $invoices_address_id = $_SESSION['client']['customer']['invoices_address_id'];
         $delivery_address_id = $_SESSION['client']['customer']['delivery_address_id'];
     }
     if (is_numeric($invoices_address_id)) {
         $invoices = $Address->getDetail($invoices_address_id);
     } else {
         if ($guest_checkout) {
             $invoices = $_SESSION['client']['address']['invoices'];
             $invoices['country']['name'] = $this->getCountryName($invoices['country_id']);
         } else {
             $invoices = false;
         }
     }
     if (is_numeric($delivery_address_id)) {
         $delivery = $Address->getDetail($delivery_address_id);
     } else {
         if ($guest_checkout) {
             $delivery = $_SESSION['client']['address']['delivery'];
             $delivery['country']['name'] = $this->getCountryName($delivery['country_id']);
         } else {
             $delivery = false;
         }
     }
     $addr['invoices'] = $invoices;
     $addr['delivery'] = $delivery;
     $this->tpl->assign('ADDRESS', $addr);
     if (is_array($addr['invoices'])) {
         if ($addr['invoices']['line_2'] != '') {
             $this->tpl->parse('content.invoices.line_2');
         }
         if ($addr['invoices']['line_3'] != '') {
             $this->tpl->parse('content.invoices.line_3');
         }
         if ($this->GET['hide_button'] == 0) {
             $this->tpl->parse('content.invoices.button');
         }
         $this->tpl->parse('content.invoices');
     }
     if (is_array($addr['delivery'])) {
         if ($addr['delivery']['line_2'] != '') {
             $this->tpl->parse('content.delivery.line_2');
         }
         if ($addr['delivery']['line_3'] != '') {
             $this->tpl->parse('content.delivery.line_3');
         }
         if ($this->GET['hide_button'] == 0) {
             $this->tpl->parse('content.delivery.button');
         }
         $this->tpl->parse('content.delivery');
     }
     return true;
 }
예제 #24
0
 /**
  * Check watchdog for given property
  *
  * If corresponding watchdog records are found, appropriate action is taken
  * 
  */
 public function checkWatchDog($name, $id, $old_value, $new_value, $no_action = false)
 {
     $name = pg_escape_string($name);
     if (is_numeric($id)) {
         $where = "AND (watched_item_id = {$id} OR watched_item_id IS NULL)";
     } else {
         $where = "AND watched_item_id IS NULL";
     }
     $records = $this->listing("name = '{$name}' {$where} AND publish = 1");
     $numSent = 0;
     foreach ($records as $record) {
         switch ($name) {
             case 'back_in_stock_customer':
                 if (is_numeric($id) && $old_value == 0 && $new_value > 0) {
                     require_once 'models/common/common_node.php';
                     $node_conf = common_node::initConfiguration();
                     $params = array('product' => $this->getProductInfo($id), 'unsubscribe' => array('page_id' => $node_conf['id_map-notifications'], 'key' => $this->generateKey($record['id']), 'id' => $record['id']));
                     if ($no_action) {
                         $numSent++;
                     } else {
                         $numSent += $this->sendNotification($record['customer_id'], 'notification_back_in_stock_customer', $params);
                         $this->setPublish($record['id'], 0);
                     }
                 }
                 break;
             case 'back_in_stock_admin':
                 if (is_numeric($id) && $old_value == 0 && $new_value > 0) {
                     $params = array('product' => $this->getProductInfo($id), 'old_value' => $old_value, 'new_value' => $new_value);
                     if ($no_action) {
                         $numSent++;
                     } else {
                         $numSent += $this->sendNotification($record['customer_id'], 'notification_back_in_stock_admin', $params);
                     }
                 }
                 break;
             case 'out_of_stock_admin':
                 if (is_numeric($id) && $old_value > 0 && $new_value == 0) {
                     $params = array('product' => $this->getProductInfo($id), 'old_value' => $old_value, 'new_value' => $new_value);
                     if ($no_action) {
                         $numSent++;
                     } else {
                         $numSent += $this->sendNotification($record['customer_id'], 'notification_out_of_stock_admin', $params);
                     }
                 }
                 break;
         }
     }
     return $numSent;
 }
예제 #25
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $Order->setCacheable(false);
     if (is_numeric($this->GET['order_id'])) {
         $order_id = $this->GET['order_id'];
     } else {
         msg('Order Detail: Missing order_id', 'error');
         return false;
     }
     /**
      * security code to allow unlogged users to pay for the order and view their invoice
      */
     $this->tpl->assign('ORDER_CODE', makeHash($this->GET['order_id']));
     /**
      * include node configuration
      */
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     $this->tpl->assign('NODE_CONF', $node_conf);
     /**
      * get detail
      */
     $order_data = $Order->getOrder($order_id);
     //security check of the owner
     $is_owner = $order_data['basket']['customer_id'] == $_SESSION['client']['customer']['id'];
     $is_bo_user = Onxshop_Bo_Authentication::getInstance()->isAuthenticated();
     $is_guest_user = $order_data['client']['customer']['status'] == 5;
     $is_same_session = $order_data['php_session_id'] == session_id() || $order_data['php_session_id'] == $this->GET['php_session_id'];
     $has_code = !empty($this->GET['code']) && verifyHash($order_data['id'], $this->GET['code']);
     if ($is_bo_user || $is_owner || $is_guest_user && $is_same_session || $has_code) {
         /**
          * display Make Payment if appropriate
          */
         if ($Order->checkOrderStatusValidForPayment($order_data['status'])) {
             $this->tpl->parse('content.make_payment');
         }
         /**
          * get address detail
          */
         $_Onxshop_Request = new Onxshop_Request("component/client/address~invoices_address_id={$order_data['invoices_address_id']}:hide_button=1~");
         $this->tpl->assign("ADDRESS_INVOICES", $_Onxshop_Request->getContent());
         $_Onxshop_Request = new Onxshop_Request("component/client/address~delivery_address_id={$order_data['delivery_address_id']}:hide_button=1~");
         $this->tpl->assign("ADDRESS_DELIVERY", $_Onxshop_Request->getContent());
         /**
          * basket detail
          * if the order is payed, display HTML basket from the invoice, otherwise generate on the fly
          */
         require_once 'models/ecommerce/ecommerce_invoice.php';
         $Invoice = new ecommerce_invoice();
         $Invoice->setCacheable(false);
         $invoice_data = $Invoice->getInvoiceForOrder($order_data['id']);
         if ($invoice_data) {
             $this->tpl->assign("BASKET_DETAIL", $invoice_data['basket_detail']);
             $this->tpl->parse("content.print_invoice");
         } else {
             $_Onxshop_Request = new Onxshop_Request("component/ecommerce/basket_detail~id={$order_data['basket_id']}:order_id={$order_id}:delivery_address_id={$order_data['delivery_address_id']}:delivery_options[carrier_id]={$order_data['other_data']['delivery_options']['carrier_id']}~");
             $this->tpl->assign("BASKET_DETAIL", $_Onxshop_Request->getContent());
         }
         //other data
         /* don't show
         			$order_data['other_data'] = unserialize($order_data['other_data']);
         			if (is_array($order_data['other_data'])) {
         				foreach ($order_data['other_data'] as $key=>$value) {
         					//format
         					$key = preg_replace("/required_/","",$key);
         		    		$key = preg_replace("/_/"," ",$key);
         		    		$key = ucfirst($key);
         		    
         					$note['key'] = $key;
         					$note['value'] = nl2br($value);
         					if ($note['value'] != '') {
         						$this->tpl->assign('OTHER_DATA', $note);
         						$this->tpl->parse('content.other_data.item');
         						$show_other_data = 1;
         					}
         				}
         				if ($show_other_data == 1) $this->tpl->parse('content.other_data');
         			}
         			*/
         $order_data['created'] = strftime('%d/%m/%Y', strtotime($order_data['basket']['created']));
         $this->tpl->assign('ORDER', $order_data);
     } else {
         msg('unauthorised access to view order detail', 'error');
     }
     return true;
 }
예제 #26
0
 /**
  * main payment action
  */
 public function mainPaymentAction()
 {
     setlocale(LC_MONETARY, $GLOBALS['onxshop_conf']['global']['locale']);
     /**
      * check input values
      */
     if (is_numeric($this->GET['order_id'])) {
         $order_id = $this->GET['order_id'];
     } else {
         msg('Payment: Missing order_id', 'error', 1);
         onxshopGoTo("/page/" . $node_conf['id_map-404']);
         return false;
     }
     /**
      * include node configuration
      */
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     $this->tpl->assign('NODE_CONF', $node_conf);
     /**
      * get order detail
      */
     $order_data = $this->Transaction->getOrderDetail($order_id);
     // need to assign ORDER detail into template before processing Google Analytics
     $this->tpl->assign("ORDER", $order_data);
     /**
      * google analytics
      */
     //TODO: NOTE: Do not include the square brackets when setting the values for the form. In addition, do not use commas to separate the thousands place in your total, tax, and shipping fields - any digits after the comma will be dropped.
     if ($GLOBALS['onxshop_conf']['global']['google_analytics'] != '') {
         foreach ($order_data['basket']['items'] as $item) {
             $this->tpl->assign("ITEM", $item);
             $this->tpl->parse('content.google_analytics.item');
         }
         $this->tpl->parse('content.google_analytics');
     }
     /**
      * Google Adwords, must be numeric
      */
     if (is_numeric($GLOBALS['onxshop_conf']['global']['google_adwords'])) {
         $this->tpl->parse('content.google_adwords');
     }
     /**
      * find what payment method we use
      */
     $payment_type = $this->Transaction->getPaymentTypeForOrder($order_id);
     /**
      * check whether payment is supported
      */
     $controller = "component/ecommerce/payment/{$payment_type}";
     if (getTemplateDir($controller . ".html") == '') {
         msg("Unsupported payment type {$payment_type}", 'error');
         return false;
     }
     /**
      * Check order permission
      */
     $is_owner = $order_data['basket']['customer_id'] == $_SESSION['client']['customer']['id'];
     $is_bo_user = Onxshop_Bo_Authentication::getInstance()->isAuthenticated();
     $is_guest_user = $order_data['client']['customer']['status'] == 5;
     $is_same_session = $order_data['php_session_id'] == session_id() || $order_data['php_session_id'] == $this->GET['php_session_id'];
     $has_code = !empty($this->GET['code']) && verifyHash($order_data['id'], $this->GET['code']);
     if ($is_bo_user || $is_owner || $is_guest_user && $is_same_session || $has_code) {
         /**
          * process payment method only if status = 0 unpaid or 5 failed payment 
          */
         if ($this->checkOrderStatusValidForPayment($order_data['status'])) {
             $total_payment_amount = $order_data['basket']['total'];
             if (round($total_payment_amount, 2) == 0) {
                 //nil payment - payment is not needed
                 if ($this->processNilPayment($order_data)) {
                     $this->tpl->parse('content.nil_payment');
                 } else {
                     msg("Cannot process nil payment for order ID {$order_id}", 'error');
                 }
             } else {
                 //process payment method as subcontent
                 $_Onxshop_Request = new Onxshop_Request("component/ecommerce/payment/{$payment_type}~order_id={$order_id}~");
                 $this->tpl->assign("RESULT", $_Onxshop_Request->getContent());
             }
         } else {
             msg("Order ID {$order_data['id']} cannot be paid, because order status is: {$order_data['status_title']}", 'error');
             return false;
         }
     } else {
         /**
          * forward to login
          */
         if ($_SESSION['client']['customer']['id'] == 0) {
             msg('You must login first.');
             onxshopGoTo("/page/" . $node_conf['id_map-login']);
         }
         msg('Unauthorised access to order detail');
         onxshopGoTo("/page/" . $node_conf['id_map-404']);
         return false;
     }
     setlocale(LC_MONETARY, LOCALE);
     return true;
 }