コード例 #1
0
ファイル: order_list.php プロジェクト: AppChecker/onxshop
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
ファイル: invoice_detail.php プロジェクト: AppChecker/onxshop
 /**
  * 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;
     }
     /**
      * 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;
 }
コード例 #5
0
 /**
  * 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;
 }
コード例 #6
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;
 }
コード例 #7
0
 /**
  * get payment type
  */
 function getPaymentTypeForOrder($order_id)
 {
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $Order->setCacheable(false);
     $order_data = $Order->detail($order_id);
     return $order_data['payment_type'];
 }
コード例 #8
0
ファイル: invoice.php プロジェクト: AppChecker/onxshop
 /**
  * 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;
 }
コード例 #9
0
ファイル: order_detail.php プロジェクト: AppChecker/onxshop
 /**
  * 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;
 }
コード例 #10
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;
 }
コード例 #11
0
 /**
  * Try to reward inviting user in referreal system
  * 
  * @param  int $order_id Order to check
  * @return boolean If attempt was successfull
  */
 public function rewardInvitingUser($order_id)
 {
     // get order detail
     require_once 'models/ecommerce/ecommerce_order.php';
     $EcommerceOrder = new ecommerce_order();
     $EcommerceOrder->setCacheable(false);
     $order_detail = $EcommerceOrder->getFullDetail($order_id);
     // get promotion detail
     $code = pg_escape_string($this->getPromotionCodeForOrder($order_id));
     $promotions = $this->listing("code_pattern = '{$code}'");
     $promotion = $promotions[0];
     if (substr($promotion['code_pattern'], 0, 4) === "REF-") {
         $usage = $this->getCountUsageOfSingleCode($code) + 1;
         // check if a user is not already rewarded
         $this->setCacheable(false);
         $rewarded_codes = $this->listing("generated_by_order_id = {$order_id}");
         if (count($rewarded_codes) == 0) {
             // automatically extend to 20 invites
             if ($promotion['uses_per_coupon'] > 0 && $usage > $promotion['uses_per_coupon'] && $usage < 20) {
                 $promotion['uses_per_coupon'] += 10;
                 $this->updatePromotion($promotion);
             }
             $data = array('title' => "Referral voucher code", 'description' => '', 'publish' => 1, 'type' => 3, 'code_pattern' => $this->generateRandomCode('REW-', 5, 5), 'discount_fixed_value' => $promotion['discount_fixed_value'], 'discount_percentage_value' => 0, 'discount_free_delivery' => 0, 'uses_per_coupon' => 1, 'uses_per_customer' => 1, 'limit_list_products' => '', 'other_data' => NULL, 'limit_delivery_country_id' => 0, 'limit_delivery_carrier_id' => 0, 'limit_by_customer_id' => $promotion['generated_by_customer_id'], 'limit_to_first_order' => 0, 'limit_to_order_amount' => $promotion['limit_to_order_amount'], 'generated_by_order_id' => $order_id, 'generated_by_customer_id' => $order_detail['basket']['customer_id']);
             $this->insert($data);
             $invited_customer_id = $order_detail['basket']['customer_id'];
             $rewarded_customer_id = $promotion['generated_by_customer_id'];
             $code = $data['code_pattern'];
             $this->sendRewardEmail($invited_customer_id, $rewarded_customer_id, $code, $usage);
             // send warning email when 15 invites reached
             if ($usage == 15) {
                 $this->sendWarningEmail($rewarded_customer_id);
             }
             return true;
         }
     }
     return false;
 }