Пример #1
0
 public static function createPartialOrderSlip($order, $amount, $shipping_cost_amount, $order_detail_list)
 {
     $currency = new JeproshopCurrencyModelCurrency($order->currency_id);
     $orderSlip = new JeproshopOrderSlipModelOrderSlip();
     $orderSlip->customer_id = (int) $order->customer_id;
     $orderSlip->order_id = (int) $order->order_id;
     $orderSlip->amount = (double) $amount;
     $orderSlip->shipping_cost = false;
     $orderSlip->shipping_cost_amount = (double) $shipping_cost_amount;
     $orderSlip->conversion_rate = $currency->conversion_rate;
     $orderSlip->partial = 1;
     if (!$orderSlip->add()) {
         return false;
     }
     $orderSlip->addPartialSlipDetail($order_detail_list);
     return true;
 }
Пример #2
0
 public function renderView($tpl = NULL)
 {
     if (!isset($this->context) || $this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     $app = JFactory::getApplication();
     $order = new JeproshopOrderModelOrder($app->input->get('order_id'));
     if (!JeproshopTools::isLoadedObject($order, 'order_id')) {
         JError::raiseError(500, JText::_('COM_JEPROSHOP_THE_ORDER_CANNOT_BE_FOUND_WITHIN_YOUR_DATA_BASE_MESSAGE'));
     }
     $customer = new JeproshopCustomerModelCustomer($order->customer_id);
     $carrier = new JeproshopCarrierModelCarrier($order->carrier_id);
     $products = $this->getProducts($order);
     $currency = new JeproshopCurrencyModelCurrency((int) $order->currency_id);
     // Carrier module call
     $carrier_module_call = null;
     if ($carrier->is_module) {
         /*$module = Module::getInstanceByName($carrier->external_module_name);
         		if (method_exists($module, 'displayInfoByCart'))
         			$carrier_module_call = call_user_func(array($module, 'displayInfoByCart'), $order->id_cart); */
     }
     // Retrieve addresses information
     $addressInvoice = new JeproshopAddressModelAddress($order->address_invoice_id, $this->context->language->lang_id);
     if (JeproshopTools::isLoadedObject($addressInvoice, 'address_id') && $addressInvoice->state_id) {
         $invoiceState = new JeproshopStateModelState((int) $addressInvoice->state_id);
     }
     if ($order->address_invoice_id == $order->address_delivery_id) {
         $addressDelivery = $addressInvoice;
         if (isset($invoiceState)) {
             $deliveryState = $invoiceState;
         }
     } else {
         $addressDelivery = new JeproshopAddressModelAddress($order->address_delivery_id, $this->context->language->lang_id);
         if (JeproshopTools::isLoadedObject($addressDelivery, 'address_id') && $addressDelivery->state_id) {
             $deliveryState = new JeproshopStateModelState((int) $addressDelivery->state_id);
         }
     }
     $title = JText::_('COM_JEPROSHOP_ORDER_LABEL') . ' ';
     //todo learn how to display
     //$toolbar_title = sprintf($this->l('Order #%1$d (%2$s) - %3$s %4$s'), $order->order_id, $order->reference, $customer->firstname, $customer->lastname);
     if (JeproshopShopModelShop::isFeaturePublished()) {
         $shop = new JeproshopShopModelShop((int) $order->shop_id);
         //$this->toolbar_title .= ' - '.sprintf($this->l('Shop: %s'), $shop->name);
     }
     JToolBarHelper::title($title);
     // gets warehouses to ship products, if and only if advanced stock management is activated
     $warehouse_list = null;
     $order_details = $order->getOrderDetailList();
     foreach ($order_details as $order_detail) {
         $product = new JeproshopProductModelProduct($order_detail->product_id);
         if (JeproshopSettingModelSetting::getValue('advanced_stock_management') && $product->advanced_stock_management) {
             $warehouses = JeproshopWarehouseModelWarehouse::getWarehousesByProductId($order_detail->product_id, $order_detail->product_attribute_id);
             foreach ($warehouses as $warehouse) {
                 if (!isset($warehouse_list[$warehouse->warehouse_id])) {
                     $warehouse_list[$warehouse->warehouse_id] = $warehouse;
                 }
             }
         }
     }
     $payment_methods = array();
     /*foreach (PaymentModule::getInstalledPaymentModules() as $payment)
     		{
     			$module = Module::getInstanceByName($payment['name']);
     			if (Validate::isLoadedObject($module) && $module->active)
     				$payment_methods[] = $module->displayName;
     		}*/
     // display warning if there are products out of stock
     $display_out_of_stock_warning = false;
     $current_order_status = $order->getCurrentOrderStatus();
     if (JeproshopSettingModelSetting::getValue('stock_management') && (!JeproshopTools::isLoadedObject($current_order_status, 'order_id') || $current_order_status->delivery != 1 && $current_order_status->shipped != 1)) {
         $display_out_of_stock_warning = true;
     }
     // products current stock (from stock_available)
     foreach ($products as &$product) {
         $product->current_stock = JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct($product->product_id, $product->product_attribute_id, $product->shop_id);
         $resume = JeproshopOrderSlipModelOrderSlip::getProductSlipResume($product->order_detail_id);
         $product->quantity_refundable = $product->product_quantity - $resume->product_quantity;
         $product->amount_refundable = $product->total_price_tax_incl - $resume->amount_tax_incl;
         $product->amount_refund = JeproshopTools::displayPrice($resume->amount_tax_incl, $currency);
         $product->refund_history = JeproshopOrderSlipModelOrderSlip::getProductSlipDetail($product->order_detail_id);
         $product->return_history = JeproshopOrderReturnModelOrderReturn::getProductReturnDetail($product->order_detail_id);
         // if the current stock requires a warning
         if ($product->current_stock == 0 && $display_out_of_stock_warning) {
             JError::raiseWarning(500, JText::_('COM_JEPROSHOP_THIS_PRODUCT_IS_OUT_OF_STOCK_LABEL') . ' : ' . $product->product_name);
         }
         if ($product->warehouse_id != 0) {
             $warehouse = new JeproshopWarehouseModelWarehouse((int) $product->warehouse_id);
             $product->warehouse_name = $warehouse->name;
         } else {
             $product->warehouse_name = '--';
         }
     }
     //$gender = new Gender((int)$customer->id_gender, $this->context->language->id);
     $history = $order->getHistory($this->context->language->lang_id);
     foreach ($history as &$order_state) {
         $order_state->text_color = JeproshopTools::getBrightness($order_state->color) < 128 ? 'white' : 'black';
     }
     $this->setLayout('view');
     $this->assignRef('order', $order);
     $cart = new JeproshopCartModelCart($order->cart_id);
     $this->assignRef('cart', $cart);
     $this->assignRef('customer', $customer);
     $customer_addresses = $customer->getAddresses($this->context->language->lang_id);
     $this->assignRef('customer_addresses', $customer_addresses);
     $this->assignRef('delivery_address', $addressDelivery);
     $this->assignRef('deliveryState', isset($deliveryState) ? $deliveryState : null);
     $this->assignRef('invoice_address', $addressInvoice);
     $this->assignRef('invoiceState', isset($invoiceState) ? $invoiceState : null);
     $customerStats = $customer->getStats();
     $this->assignRef('customerStats', $customerStats);
     $this->assignRef('products', $products);
     $discounts = $order->getCartRules();
     $this->assignRef('discounts', $discounts);
     $orderTotalPaid = $order->getOrdersTotalPaid();
     $this->assignRef('orders_total_paid_tax_incl', $orderTotalPaid);
     // Get the sum of total_paid_tax_incl of the order with similar reference
     $totalPaid = $order->getTotalPaid();
     $this->assignRef('total_paid', $totalPaid);
     $returns = JeproshopOrderReturnModelOrderReturn::getOrdersReturn($order->customer_id, $order->order_id);
     $this->assignRef('returns', $returns);
     $customerThreads = JeproshopCustomerThreadModelCustomerThread::getCustomerMessages($order->customer_id);
     $this->assignRef('customer_thread_message', $customerThreads);
     $orderMessages = JeproshopOrderMessageModelOrderMessage::getOrderMessages($order->lang_id);
     $this->assignRef('order_messages', $orderMessages);
     $messages = JeproshopMessageModelMessage::getMessagesByOrderId($order->order_id, true);
     $this->assignRef('messages', $messages);
     $carrier = new JeproshopCarrierModelCarrier($order->carrier_id);
     $this->assignRef('carrier', $carrier);
     $this->assignRef('history', $history);
     $statues = JeproshopOrderStatusModelOrderStatus::getOrderStatus($this->context->language->lang_id);
     $this->assignRef('order_statues', $statues);
     $this->assignRef('warehouse_list', $warehouse_list);
     $sources = JeproshopConnectionSourceModelConnectionSource::getOrderSources($order->order_id);
     $this->assignRef('sources', $sources);
     $orderStatus = $order->getCurrentOrderStatus();
     $this->assignRef('current_status', $orderStatus);
     $this->assignRef('currency', new JeproshopCurrencyModelCurrency($order->currency_id));
     $currencies = JeproshopCurrencyModelCurrency::getCurrenciesByShopId($order->shop_id);
     $this->assignRef('currencies', $currencies);
     $previousOrder = $order->getPreviousOrderId();
     $this->assignRef('previousOrder', $previousOrder);
     $nextOrder = $order->getNextOrderId();
     $this->assignRef('nextOrder', $nextOrder);
     //$this->assignRef('current_index', self::$currentIndex);
     $this->assignRef('carrier_module_call', $carrier_module_call);
     $this->assignRef('iso_code_lang', $this->context->language->iso_code);
     $this->assignRef('lang_id', $this->context->language->lang_id);
     $can_edit = true;
     $this->assignRef('can_edit', $can_edit);
     //($this->tabAccess['edit'] == 1));
     $this->assignRef('current_id_lang', $this->context->language->lang_id);
     $invoiceCollection = $order->getInvoicesCollection();
     $this->assignRef('invoices_collection', $invoiceCollection);
     $unPaid = $order->getNotPaidInvoicesCollection();
     $this->assignRef('not_paid_invoices_collection', $unPaid);
     $this->assignRef('payment_methods', $payment_methods);
     $invoiceAllowed = JeproshopSettingModelSetting::getValue('invoice_allowed');
     $this->assignRef('invoice_management_active', $invoiceAllowed);
     $display_warehouse = (int) JeproshopSettingModelSetting::getValue('advanced_stock_management');
     $this->assignRef('display_warehouse', $display_warehouse);
     $stockManagement = JeproshopSettingModelSetting::getValue('stock_management');
     $this->assignRef('stock_management', $stockManagement);
     /*$this->assignRef('HOOK_CONTENT_ORDER', Hook::exec('displayAdminOrderContentOrder', array(
     				'order' => $order,
     				'products' => $products,
     				'customer' => $customer)
     				),
     		$this->assignRef('HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array(
     				'order' => $order,
     				'products' => $products,
     				'customer' => $customer)
     				),
     		$this->assignRef('HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array(
     				'order' => $order,
     				'products' => $products,
     				'customer' => $customer)
     				
     		$this->assignRef('HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array(
     		$this->assignRef('order' => $order,
     		$this->assignRef('products' => $products,
     		$this->assignRef('customer' => $customer) */
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }