示例#1
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * Input data
      */
     if (is_numeric($this->GET['order_id'])) {
         $order_id = $this->GET['order_id'];
     } else {
         return false;
     }
     /**
      * Create objects
      */
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     /**
      * Get details for order
      */
     if (is_numeric($order_id)) {
         $order_data = $Order->getOrder($order_id);
     }
     if ($order_data['other_data']['gift'] == 1 || strlen($order_data['other_data']['gift_message']) > 0) {
         $this->tpl->assign("ORDER", $order_data);
         $this->tpl->parse('content.option');
     } else {
         $this->tpl->parse('content.nooption');
     }
     return true;
 }
示例#2
0
 /**
  * main action
  */
 public function mainAction()
 {
     if (!is_numeric($this->GET['order_id'])) {
         return false;
     }
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $order_detail = $Order->getOrder($this->GET['order_id']);
     //check owner
     if ($order_data['basket']['customer_id'] !== $_SESSION['client']['customer']['id'] && !Onxshop_Bo_Authentication::getInstance()->isAuthenticated()) {
         msg('gift_card:unauthorized access to view order detail');
         return false;
     } else {
         $this->tpl->assign('ORDER', $order_detail);
     }
     return true;
 }
示例#3
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * Input data
      */
     if (is_numeric($this->GET['id'])) {
         $order_id = $this->GET['id'];
     } else {
         return false;
     }
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $Order->setCacheable(false);
     require_once 'models/ecommerce/ecommerce_invoice.php';
     $Invoice = new ecommerce_invoice();
     $Invoice->setCacheable(false);
     if (is_numeric($order_id)) {
         $order_data = $Order->getOrder($order_id);
     }
     //security check of owner
     if ($order_data['basket']['customer_id'] !== $_SESSION['client']['customer']['id'] && !Onxshop_Bo_Authentication::getInstance()->isAuthenticated()) {
         msg('unauthorized access to view invoice detail', 'error');
     } else {
         if ($order_data['status'] != 0) {
             $invoice_detail = $Invoice->getInvoiceForOrder($order_data['id']);
             if ($invoice_detail) {
                 //$invoice_detail['created'] = strftime('%d/%m/%Y', strtotime($invoice_detail['created']));
                 $this->tpl->assign("INVOICE", $invoice_detail);
                 $this->tpl->parse('content.invoice');
             }
             $this->tpl->parse('content.print_invoice');
         } else {
             if ($Order->conf['proforma_invoice'] == true || ONXSHOP_IN_BACKOFFICE) {
                 $invoice_detail = array();
                 $invoice_detail['order_id'] = $order_id;
                 $this->tpl->assign("INVOICE", $invoice_detail);
                 $this->tpl->parse('content.print_invoice_proforma');
             }
         }
     }
     return true;
 }
示例#4
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * Input data
      */
     if (is_numeric($this->GET['id'])) {
         $order_id = $this->GET['id'];
     } else {
         return false;
     }
     /**
      * Create objects
      */
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     require_once 'models/ecommerce/ecommerce_delivery.php';
     $Delivery = new ecommerce_delivery();
     /**
      * Get details for order to be able make a security check
      */
     if (is_numeric($order_id)) {
         $order_data = $Order->getOrder($order_id);
     }
     //security check of owner
     if ($order_data['basket']['customer_id'] !== $_SESSION['client']['customer']['id'] && !Onxshop_Bo_Authentication::getInstance()->isAuthenticated()) {
         msg('unauthorized access to view transaction detail', 'error');
     } else {
         $delivery_list = $Delivery->getDeliveryListByOrderId($order_id);
         //print_r($transaction_list);
         if (is_array($delivery_list)) {
             foreach ($delivery_list as $item) {
                 $item['other_data'] = unserialize($item['other_data']);
                 if ($item['customer_note'] == "") {
                     $item['customer_note'] = 'n/a';
                 }
                 $this->tpl->assign('ITEM', $item);
                 $this->tpl->parse('content.item');
             }
         }
     }
     return true;
 }
示例#5
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * Input data
      */
     if (is_numeric($this->GET['id'])) {
         $order_id = $this->GET['id'];
     } else {
         return false;
     }
     /**
      * Initialize objects
      */
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $Order->setCacheable(false);
     require_once 'models/ecommerce/ecommerce_transaction.php';
     $Transaction = new ecommerce_transaction();
     /**
      * Get details for order to be able make a security check
      */
     if (is_numeric($order_id)) {
         $order_data = $Order->getOrder($order_id);
     }
     //security check of owner
     if ($order_data['basket']['customer_id'] !== $_SESSION['client']['customer']['id'] && !Onxshop_Bo_Authentication::getInstance()->isAuthenticated()) {
         msg('unauthorized access to view transaction detail', 'error');
     } else {
         $transaction_list = $Transaction->getListForOrderId($order_id);
         //print_r($transaction_list);
         if (is_array($transaction_list)) {
             foreach ($transaction_list as $transaction_detail) {
                 $this->tpl->assign('TRANSACTION', $transaction_detail);
                 $this->tpl->parse('content.transaction');
             }
         } else {
             msg("Order id {$order_id} has no transactions");
         }
     }
     return true;
 }
示例#6
0
 /**
  * process callback
  */
 function paymentProcess($order_id, $crypt)
 {
     //hack for changing white space to + sign
     $crypt = str_replace(' ', '+', $crypt);
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     //decode crypt
     $decoded = self::decryptAes($crypt, ECOMMERCE_TRANSACTION_PROTX_PASSWORD);
     //explode protx data
     parse_str($decoded, $response);
     $this->msgProtxStatus($response['Status']);
     $order_data = $Order->getOrder($order_id);
     $transaction_data['order_id'] = $order_data['id'];
     $transaction_data['pg_data'] = serialize($response);
     $transaction_data['currency_code'] = GLOBAL_DEFAULT_CURRENCY;
     if (is_numeric($response['Amount'])) {
         $transaction_data['amount'] = $response['Amount'];
     } else {
         $transaction_data['amount'] = 0;
     }
     $transaction_data['created'] = date('c');
     $transaction_data['type'] = 'protx';
     if ($response['Status'] == 'OK') {
         $transaction_data['status'] = 1;
     } else {
         $transaction_data['status'] = 0;
     }
     /**
      * insert
      */
     if ($id = $this->Transaction->insert($transaction_data)) {
         // in payment_success must be everytime Status OK
         if ($response['Status'] == 'OK') {
             $Order->setStatus($order_id, 1);
             //send email to admin
             require_once 'models/common/common_email.php';
             $EmailForm = new common_email();
             $_Onxshop_Request = new Onxshop_Request("component/ecommerce/order_detail~order_id={$order_data['id']}~");
             $order_data['order_detail'] = $_Onxshop_Request->getContent();
             //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']['transaction'] = $transaction_data;
             $GLOBALS['common_email']['order'] = $order_data;
             if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $order_data['client']['customer']['email'], $order_data['client']['customer']['first_name'] . " " . $order_data['client']['customer']['last_name'])) {
                 msg('ecommerce_transaction: Cant send email.', 'error', 2);
             }
             if ($Order->conf['mail_to_address']) {
                 if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $Order->conf['mail_to_address'], $Order->conf['mail_to_name'])) {
                     msg('ecommerce_transaction: Cant send email.', 'error', 2);
                 }
             }
         } else {
             $Order->setStatus($order_id, 5);
         }
         return $id;
     } else {
         //to be sure...
         if ($response['Status'] == 'OK') {
             msg("Payment for order {$order_id} was successfully Authorised, but I cant save the transaction TxAuthNo {$pg_data['TxAuthNo']}!", 'error');
         }
         msg("payment/protx: cannot insert serialized pg_data: {$transaction_data['pg_data']}", 'error');
         return false;
     }
 }
示例#7
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * check
      */
     if (is_numeric($this->GET['id'])) {
         $order_id = $this->GET['id'];
     } else {
         return false;
     }
     /**
      * initialise
      */
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     /**
      * save
      */
     if (isset($_POST['save'])) {
         //get order detail
         $order_data = $Order->getDetail($order_id);
         //prepare data for update
         $order_data['note_backoffice'] = $_POST['order']['note_backoffice'];
         //update order data
         if (!$Order->updateOrder($order_data)) {
             msg("Cannot update order data (Order ID {$order_id})", 'error');
         }
         //update order status (warning: order status change can trigger other events affection order_data)
         if ($order_data['status'] != $_POST['order']['status']) {
             $order_data['status'] = $_POST['order']['status'];
             if (!$Order->setStatus($order_id, $_POST['order']['status'])) {
                 msg("Cannot update order status (Order ID {$order_id})", 'error');
             }
             onxshopGoTo("/backoffice/orders/{$order_id}/detail");
         }
     }
     /**
      * get full detail (including relations)
      */
     $full_order_data = $Order->getOrder($order_id);
     // status
     $status = $Order->conf['status'];
     // parse select box
     foreach ($status as $key => $s) {
         $s1['id'] = $key;
         $s1['name'] = $s;
         if ($s1['id'] == $full_order_data['status']) {
             $s1['selected'] = 'selected="selected"';
         } else {
             $s1['selected'] = '';
         }
         $this->tpl->assign('STATUS', $s1);
         $this->tpl->parse('content.status');
     }
     // parse log
     foreach ($full_order_data['log'] as $log) {
         $log['name'] = $status[$log['status']];
         $this->tpl->assign('STATUS', $log);
         $this->tpl->parse('content.log');
     }
     if ($full_order_data['note_customer'] == '') {
         $full_order_data['note_customer'] = "n/a.";
     }
     $this->tpl->assign('ORDER', $full_order_data);
     /**
      * ACL
      */
     if (!preg_match("/-warehouse\$/", $_SESSION['authentication']['username'])) {
         $this->tpl->parse('content.customer_detail');
         $this->tpl->parse('content.accounting_detail');
     }
     return true;
 }
 /**
  * get order detail
  */
 function getOrderDetail($order_id)
 {
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $Order->setCacheable(false);
     $order_data = $Order->getOrder($order_id);
     return $order_data;
 }
示例#9
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * check GET.id
      */
     if (is_numeric($this->GET['id'])) {
         $order_id = $this->GET['id'];
     } else {
         msg("component/ecommerce/invoice: GET.id is not numeric", 'error');
         return false;
     }
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_invoice.php';
     require_once 'models/ecommerce/ecommerce_order.php';
     $Invoice = new ecommerce_invoice();
     $Order = new ecommerce_order();
     $Invoice->setCacheable(false);
     $Order->setCacheable(false);
     $this->tpl->assign('CONF', $Invoice->conf);
     /**
      * get order data
      */
     $order_data = $Order->getOrder($order_id);
     /** 
      * check owner
      */
     //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) {
         /**
          * check dift option
          */
         if ($order_data['other_data']['delivery_options']['other_data']['gift'] == 1 || $order_data['other_data']['gift'] == 1) {
             $this->tpl->parse('content.gift');
         }
         /**
          * display appropriate carrier logo
          */
         $carrier_id = $order_data['other_data']['delivery_options']['carrier_id'];
         $this->tpl->parse("content.type.carrier_id_{$carrier_id}");
         $this->tpl->parse('content.type');
         /**
          * get invoice details
          */
         $invoice_data = $Invoice->getInvoiceForOrder($this->GET['id']);
         /**
          * other data
          */
         /*
         $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');
         }
         */
         //$invoice_data['created'] = strftime('%d/%m/%Y', strtotime($invoice_data['created']));
         if (empty($invoice_data['basket_detail_enhanced'])) {
             $invoice_data['basket_detail_enhanced'] = $invoice_data['basket_detail'];
         }
         $this->tpl->assign('INVOICE', $invoice_data);
         $this->tpl->assign('ORDER', $order_data);
         if ($Invoice->conf['company_logo'] != '') {
             $this->tpl->parse('content.logoimage');
         } else {
             $this->tpl->parse('content.logotypo');
         }
     } else {
         msg('unauthorized access to view order detail');
     }
     return true;
 }
示例#10
0
 /**
  * process callback
  */
 function paymentProcess($order_id, $pg_data)
 {
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     // check if $pg_data['VendorTxCode'] = $_GET['order_id']
     //$this->msgProtxStatus($pg_data['Status']);
     $order_data = $Order->getOrder($order_id);
     //print_r($order_data);
     /**
      * optional: process payment method only if status = 0 unpaid or 5 failed payment 
      * (better to save transaction every time)
      */
     //if (!$this->checkOrderStatusValidForPayment($order_data['status'])) return false;
     $transaction_data['order_id'] = $order_data['id'];
     $transaction_data['pg_data'] = serialize($pg_data);
     $transaction_data['currency_code'] = GLOBAL_DEFAULT_CURRENCY;
     if (is_numeric($pg_data['authCost'])) {
         $transaction_data['amount'] = $pg_data['authCost'];
     } else {
         $transaction_data['amount'] = 0;
     }
     $transaction_data['created'] = date('c');
     $transaction_data['type'] = 'worldpay';
     if ($pg_data['transStatus'] == 'Y') {
         $transaction_data['status'] = 1;
     } else {
         $transaction_data['status'] = 0;
     }
     /**
      * check installation id
      */
     if ($pg_data['installation'] != ECOMMERCE_TRANSACTION_WORLDPAY_INSID) {
         msg("payment/worldpay: wrong installation id {$pg_data['installation']}, serialized pg_data: {$transaction_data['pg_data']}", 'error');
         return false;
     }
     /**
      * insert
      */
     if ($id = $this->Transaction->insert($transaction_data)) {
         // in payment_success must be everytime Status OK
         if ($pg_data['transStatus'] == 'Y') {
             $Order->setStatus($order_id, 1);
             //send email to admin
             require_once 'models/common/common_email.php';
             $EmailForm = new common_email();
             $_Onxshop_Request = new Onxshop_Request("component/ecommerce/order_detail~order_id={$order_data['id']}~");
             $order_data['order_detail'] = $_Onxshop_Request->getContent();
             //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']['transaction'] = $transaction_data;
             $GLOBALS['common_email']['order'] = $order_data;
             if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $order_data['client']['customer']['email'], $order_data['client']['customer']['first_name'] . " " . $order_data['client']['customer']['last_name'])) {
                 msg("ecommerce_transaction: Can't send email.", 'error', 2);
             }
             if ($Order->conf['mail_to_address']) {
                 if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $Order->conf['mail_to_address'], $Order->conf['mail_to_name'])) {
                     msg('ecommerce_transaction: Cant send email.', 'error', 2);
                 }
             }
             /**
              * cancel immediatelly if it was only a test
              */
             if ($pg_data['testMode'] == 100) {
                 $Order->setStatus($order_id, 4);
                 msg("Order #{$order_id} has been cancelled, because Worldpay testMode was active.");
             }
         } else {
             $Order->setStatus($order_id, 5);
         }
         return $id;
     } else {
         //to be sure...
         if ($pg_data['Status'] == 'OK') {
             msg("Payment for order {$order_id} was successfully Authorised, but I cant save the transaction id {$pg_data['transId']}!", 'error');
         }
         msg("payment/worldpay: cannot insert serialized pg_data: {$transaction_data['pg_data']}", 'error');
         return false;
     }
 }
示例#11
0
 /**
  * process callback
  */
 function paymentProcess($order_id, $crypt)
 {
     //hack for changing white space to + sign
     $crypt = str_replace(' ', '+', $crypt);
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     require_once 'lib/protx.functions.php';
     //decode crypt
     $pg_data_x = simpleXor(base64Decode($crypt), ECOMMERCE_TRANSACTION_PROTX_PASSWORD);
     //explode protx data
     $pg_data = getToken($pg_data_x);
     /**
      * PROTX:
      * vpstxid [int]
      * avscv2 [int]
      * txauthno[int]
      * vpsstatus[int]
      */
     /*
     $pg_data_x = explode('&', $pg_data_x);
     for ($i=1; $i<count($pg_data_x); $i++) {
         $param = explode('=', $pg_data_x[$i]);
     	    	$pg_data[$param[0]] = $param[1];
     }
     */
     //print_r($pg_data);
     // check if $pg_data['VendorTxCode'] = $_GET['order_id']
     $this->msgProtxStatus($pg_data['Status']);
     $order_data = $Order->getOrder($order_id);
     //print_r($order_data);
     /**
      * optional: save only orders in valid status
      */
     /*
     if ($order_data['status'] == 1 || $order_data['status'] == 2 || $order_data['status'] == 3 || $order_data['status'] == 4) {
     	msg("Ecommerce_transaction: Order in status New (paid), Dispatched, Completed, Cancelled", 'error', 2);
     	msg("This order (id=$order_id) was already paid before.", 'error');
     }
     */
     $transaction_data['order_id'] = $order_data['id'];
     $transaction_data['pg_data'] = serialize($pg_data);
     $transaction_data['currency_code'] = GLOBAL_DEFAULT_CURRENCY;
     if (is_numeric($pg_data['Amount'])) {
         $transaction_data['amount'] = $pg_data['Amount'];
     } else {
         $transaction_data['amount'] = 0;
     }
     $transaction_data['created'] = date('c');
     $transaction_data['type'] = 'protx';
     if ($pg_data['Status'] == 'OK') {
         $transaction_data['status'] = 1;
     } else {
         $transaction_data['status'] = 0;
     }
     /**
      * insert
      */
     if ($id = $this->Transaction->insert($transaction_data)) {
         // in payment_success must be everytime Status OK
         if ($pg_data['Status'] == 'OK') {
             $Order->setStatus($order_id, 1);
             //send email to admin
             require_once 'models/common/common_email.php';
             $EmailForm = new common_email();
             $_Onxshop_Request = new Onxshop_Request("component/ecommerce/order_detail~order_id={$order_data['id']}~");
             $order_data['order_detail'] = $_Onxshop_Request->getContent();
             //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']['transaction'] = $transaction_data;
             $GLOBALS['common_email']['order'] = $order_data;
             if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $order_data['client']['customer']['email'], $order_data['client']['customer']['first_name'] . " " . $order_data['client']['customer']['last_name'])) {
                 msg('ecommerce_transaction: Cant send email.', 'error', 2);
             }
             if ($Order->conf['mail_to_address']) {
                 if (!$EmailForm->sendEmail('new_order_paid', 'n/a', $Order->conf['mail_to_address'], $Order->conf['mail_to_name'])) {
                     msg('ecommerce_transaction: Cant send email.', 'error', 2);
                 }
             }
         } else {
             $Order->setStatus($order_id, 5);
         }
         return $id;
     } else {
         //to be sure...
         if ($pg_data['Status'] == 'OK') {
             msg("Payment for order {$order_id} was successfully Authorised, but I cant save the transaction TxAuthNo {$pg_data['TxAuthNo']}!", 'error');
         }
         msg("payment/protx: cannot insert serialized pg_data: {$transaction_data['pg_data']}", 'error');
         return false;
     }
 }
示例#12
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;
 }
示例#13
0
 /**
  * generate invoice data
  */
 function generateInvoiceData($order_id)
 {
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $Order->setCacheable(false);
     $order_data = $Order->getOrder($order_id);
     $invoice['order_id'] = $order_id;
     $invoice['goods_net'] = $order_data['basket']['sub_total']['net'];
     $invoice['goods_vat'] = $order_data['basket']['sub_total']['vat'];
     $invoice['delivery_net'] = $order_data['basket']['delivery']['value_net'];
     $invoice['delivery_vat'] = $order_data['basket']['delivery']['vat'];
     $invoice['payment_amount'] = $order_data['basket']['total'];
     if ($order_data['payment_type'] != '') {
         $invoice['payment_type'] = $order_data['payment_type'];
     } else {
         $invoice['payment_type'] = 'n/a';
     }
     $invoice['created'] = date('c');
     $invoice['modified'] = date('c');
     $invoice['status'] = 1;
     //usefull for debug $invoice['other_data'] = serialize($order_data);
     //customer detail
     $invoice['customer_name'] = "{$order_data['client']['customer']['title_before']} {$order_data['client']['customer']['first_name']} {$order_data['client']['customer']['last_name']}";
     $invoice['customer_email'] = "{$order_data['client']['customer']['email']}";
     /**
      * FIXME
      * shouldn't call controllers from model
      * this should be moved into the invoice controller
      *
      */
     //get HTML content
     //basket_detail
     $_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']}~");
     $invoice['basket_detail'] = $_Onxshop_Request->getContent();
     $_Onxshop_Request = new Onxshop_Request("component/ecommerce/basket_detail_enhanced~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']}~");
     $invoice['basket_detail_enhanced'] = $_Onxshop_Request->getContent();
     //address_invoice
     $_Onxshop_Request = new Onxshop_Request("component/client/address~invoices_address_id={$order_data['invoices_address_id']}:hide_button=1~");
     $invoice['address_invoice'] = $_Onxshop_Request->getContent();
     //address_delivery
     $_Onxshop_Request = new Onxshop_Request("component/client/address~delivery_address_id={$order_data['delivery_address_id']}:hide_button=1~");
     $invoice['address_delivery'] = $_Onxshop_Request->getContent();
     //get the text version
     $invoice['address_invoice'] = html2text($invoice['address_invoice']);
     $invoice['address_delivery'] = html2text($invoice['address_delivery']);
     $invoice['face_value_voucher'] = $order_data['basket']['face_value_voucher'];
     return $invoice;
 }