/** * 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; }
/** * main action */ public function mainAction() { require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); $breakdown_period = $this->getBreakdownPeriod(); $product_list = $Order->getProductSalesList($breakdown_period['from'], $breakdown_period['to']); $this->renderList($product_list); return true; }
/** * main action */ public function mainAction() { set_time_limit(0); require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); if (is_numeric($this->GET['customer_id'])) { //display all orders when looking for a customer $filter = array(); $filter['status'] = 'all'; } else { $filter = $_SESSION['bo']['order-list-filter']; } /** * Get the list */ $records = $Order->getOrderListForExport($filter, $this->GET['inlude_products'] == 1, $this->GET['customer_id']); if (is_array($records)) { /** * parse records */ $header = 0; foreach ($records as $record) { /** * Create header */ if ($header == 0) { foreach ($record as $key => $val) { $column['name'] = $key; $this->tpl->assign('COLUMN', $column); $this->tpl->parse('content.th'); } $header = 1; } foreach ($record as $key => $val) { if (!is_numeric($val)) { $val = addslashes($val); $val = '"' . $val . '"'; $val = preg_replace("/[\n\r]/", '', $val); } $this->tpl->assign('value', $val); $this->tpl->parse('content.item.attribute'); } $this->tpl->parse('content.item'); } //set the headers for the output $this->sendCSVHeaders('orders' . ($this->GET['inlude_products'] == 1 ? '-products' : '')); } else { echo "no records"; exit; } return true; }
/** * get order list */ function getOrderList() { require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); $filter = array(); if (is_numeric($this->GET['status'])) { $filter['status'] = $this->GET['status']; } else { $filter['status'] = 1; } $customer_id = NULL; $order_list = $Order->getFullDetailList($customer_id, $filter); return $order_list; }
public function mainActionX() { require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); $filter = array(); $filter['status'] = 1; $customer_id = 0; $order_list = $Order->getFullDetailList($customer_id, $filter); //print_r($order_list); exit; if (is_array($sitemap)) { $this->tpl->assign("ITEM", $item); $this->tpl->parse("content.item"); } header('Content-Type: text/xml; charset=UTF-8'); return true; }
/** * 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; }
/** * 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 %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; }
/** * main action */ public function mainAction() { return true; $order_id = (int) $this->GET['order_id']; if ($order_id == 0) { return true; } $Order = new ecommerce_order(); $Order->setCacheable(false); $order_data = $Order->getFullDetail($order_id); if ($order_data['transaction']['id'] > 0) { $this->tpl->parse('content.button'); if ($this->GET['resend_email'] == 'yes') { // implement in your installation onxshopGoto("/backoffice/orders/{$order_data['id']}/detail"); } } return true; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * main action */ public function mainAction() { require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); if ($_POST['time_frame'] != '') { $time_frame = $_POST['time_frame']; } else { $time_frame = 'day'; } $this->tpl->assign("SELECTED_{$time_frame}", "selected='selected'"); $this->tpl->assign("TIME_FRAME", $time_frame); if ($time_frame == 'month') { $limit = 24; } else { $limit = 30; } $data = $Order->getStatData($time_frame, $limit); if (is_array($data)) { $this->generateNumOrdersGraph($data, $time_frame); $this->generateRevenueGraph($data, $time_frame); } return true; }
/** * main action */ public function mainAction() { if (!is_numeric($this->GET['order_id'])) { msg("Onxshop_Controller_Component_Ecommerce_Gift_Voucher_Generate: order_id isn't numeric"); return false; } $order_id = $this->GET['order_id']; if ($gift_voucher_product_id = $this->getGiftVoucherProductId()) { /** * get order detail */ require_once 'models/ecommerce/ecommerce_order.php'; $EcommerceOrder = new ecommerce_order(); $EcommerceOrder->setCacheable(false); $order_detail = $EcommerceOrder->getFullDetail($order_id); /** * find if the order contains gift */ if ($voucher_basket_items = $this->getVoucherBasketItems($order_detail, $gift_voucher_product_id)) { return $this->generateVouchers($voucher_basket_items); } } return true; }
/** * 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; } }
/** * main action */ public function mainAction() { /*$order = $this->GET['order']; $search = trim($_POST['search']); $customer_id = $this->GET['customer_id']; $status = $this->GET['status'];*/ if (is_array($_SESSION['bo']['order-list-filter'])) { $order_list_filter = $_SESSION['bo']['order-list-filter']; } else { $order_list_filter = array(); } if (is_numeric($this->GET['customer_id'])) { $customer_id = $this->GET['customer_id']; //display all orders when looking for a customer $order_list_filter = array(); $order_list_filter['status'] = 'all'; } else { $customer_id = NULL; } if (is_numeric($this->GET['status'])) { $order_list_filter['status'] = $this->GET['status']; } /** * if query is numeric, go strait to order detail */ if (is_numeric($_POST['order-list-filter']['query'])) { onxshopGoTo("/backoffice/orders/{$_POST['order-list-filter']['query']}/detail"); } /** * 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}"; /** * Initialize order object */ require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); /** * Get order list */ $order_list = $Order->getOrderList($customer_id, $order_list_filter, $per_page, $from); $count = $Order->getOrderListCount($customer_id, $order_list_filter); if ($count > 0) { /** * Display pagination */ $_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 ($order_list as $item) { $even_odd = 'odd' != $even_odd ? 'odd' : 'even'; $item['even_odd'] = $even_odd; $item['order_created'] = strftime('%c', strtotime($item['order_created'])); $item['last_activity'] = strftime('%c', strtotime($item['last_activity'])); if (!is_numeric($item['goods_net'])) { $item['goods_net'] = 0; } // display payment due (for unpaid orders only) if ($item['order_status'] == 0 && isset($item['other_data']['payment_due'])) { $item['payment_due'] = $item['other_data']['payment_due']; } $item['status'] = $Order->getStatusTitle($item['order_status']); $this->tpl->assign('ITEM', $item); $this->tpl->parse('content.list.item'); } $this->tpl->parse('content.list'); } else { $this->tpl->parse('content.empty'); } return true; }
/** * Return true if delivery to given country is VAT eligible * * @param int $country_id Country Id to check EU status * @return boolean */ function isVatEligibleByCountry($country_id) { $order_conf = ecommerce_order::initConfiguration(); $exclude_vat = false; require_once 'models/international/international_country.php'; if (is_numeric($country_id)) { $Country = new international_country(); $country_data = $Country->detail($country_id); $exclude_vat = $order_conf['non_eu_zero_vat'] && !$country_data['eu_status']; } return !$exclude_vat; }
/** * sendEmail */ public function sendEmail() { require_once 'models/common/common_email.php'; $CommonEmail = new common_email(); require_once 'models/ecommerce/ecommerce_order.php'; $ecommerce_order_conf = ecommerce_order::initConfiguration(); //admin_email_name $template = 'return'; $content = $this->getResultHtml(); $email_recipient = $ecommerce_order_conf['product_returns_mail_to_address']; $name_recipient = $ecommerce_order_conf['product_returns_mail_to_name']; $email_from = $_SESSION['client']['customer']['email']; $name_from = "{$_SESSION['client']['customer']['first_name']} {$_SESSION['client']['customer']['last_name']}"; if ($CommonEmail->sendEmail($template, $content, $email_recipient, $name_recipient, $email_from, $name_from)) { return true; } else { return false; } }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; } }
/** * check if given order is finished and related to given basket */ protected function orderFinished($basket_id, $order_id) { if (!is_numeric($order_id)) { return false; } $Order = new ecommerce_order(); $order = $Order->getDetail($order_id); return $order['basket_id'] == $basket_id; }
/** * check order status * process payment method only if status = 0 unpaid or 5 failed payment */ function checkOrderStatusValidForPayment($status) { require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); return $Order->checkOrderStatusValidForPayment($status); }
/** * processNilPayment */ public function processNilPayment($order_data) { if (!is_array($order_data)) { return false; } if ($order_data['basket']['total'] > 0) { return false; } require_once 'models/ecommerce/ecommerce_order.php'; $EcommerceOrder = new ecommerce_order(); $EcommerceOrder->setCacheAble(false); //mark as payed $log_data_id = $EcommerceOrder->setStatus($order_data['id'], 1); return $log_data_id; }
/** * 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; } }
/** * get basket by order id */ public function getBasketByOrderId($order_id) { if (!is_numeric($order_id)) { return false; } require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); if ($order_detail = $Order->getDetail($order_id)) { if ($basket_detail = $this->getFullDetail($order_detail['basket_id'])) { return $basket_detail; } else { return false; } } else { return false; } }
protected function isVatEligible($customer_id) { $result = true; if (is_numeric($_SESSION['client']['customer']['delivery_address_id'])) { require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); return $Order->isVatEligible($_SESSION['client']['customer']['delivery_address_id'], $customer_id); } return $result; }
/** * 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; }
/** * 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; }