protected function getAddresses($order_id) { $Invoice = new ecommerce_invoice(); $Invoice->setCacheable(false); $invoice = $Invoice->getInvoiceForOrder($order_id); return array("address_invoice" => $invoice['address_invoice'], "address_delivery" => $invoice['address_delivery']); }
/** * 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; }
/** * get invoice detail */ function getInvoiceDetail($order_id) { if (!is_numeric($order_id)) { return false; } require_once 'models/ecommerce/ecommerce_invoice.php'; $Invoice = new ecommerce_invoice(); $Invoice->setCacheable(false); $invoice_detail = $Invoice->getInvoiceForOrder($order_id); if (is_array($invoice_detail)) { return $invoice_detail; } else { return false; } }
/** * 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; }
/** * 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; }