public static function getCurrenciesByIdShop($id_shop = 0) { if (version_compare(_PS_VERSION_, '1.5.1', '>=')) { return Currency::getCurrenciesByIdShop($id_shop); } elseif (version_compare(_PS_VERSION_, '1.5', '>')) { $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'currency` c LEFT JOIN `' . _DB_PREFIX_ . 'currency_shop` cs ON (cs.`id_currency` = c.`id_currency`) ' . ($id_shop != 0 ? ' WHERE cs.`id_shop` = ' . (int) $id_shop : '') . ' GROUP BY c.id_currency ORDER BY `name` ASC'; return Db::getInstance()->executeS($sql); } else { $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'currency` c'; return Db::getInstance()->executeS($sql); } }
public function renderView() { $order = new Order(Tools::getValue('id_order')); if (!Validate::isLoadedObject($order)) { $this->errors[] = Tools::displayError('The order cannot be found within your database.'); } $customer = new Customer($order->id_customer); $carrier = new Carrier($order->id_carrier); $products = $this->getProducts($order); $currency = new Currency((int) $order->id_currency); // 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 Address($order->id_address_invoice, $this->context->language->id); if (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state) { $invoiceState = new State((int) $addressInvoice->id_state); } if ($order->id_address_invoice == $order->id_address_delivery) { $addressDelivery = $addressInvoice; if (isset($invoiceState)) { $deliveryState = $invoiceState; } } else { $addressDelivery = new Address($order->id_address_delivery, $this->context->language->id); if (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) { $deliveryState = new State((int) $addressDelivery->id_state); } } $this->toolbar_title = sprintf($this->l('Order #%1$d (%2$s) - %3$s %4$s'), $order->id, $order->reference, $customer->firstname, $customer->lastname); if (Shop::isFeatureActive()) { $shop = new Shop((int) $order->id_shop); $this->toolbar_title .= ' - ' . sprintf($this->l('Shop: %s'), $shop->name); } // 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 Product($order_detail['product_id']); if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management) { $warehouses = Warehouse::getWarehousesByProductId($order_detail['product_id'], $order_detail['product_attribute_id']); foreach ($warehouses as $warehouse) { if (!isset($warehouse_list[$warehouse['id_warehouse']])) { $warehouse_list[$warehouse['id_warehouse']] = $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_state = $order->getCurrentOrderState(); if (Configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || $current_order_state->delivery != 1 && $current_order_state->shipped != 1)) { $display_out_of_stock_warning = true; } // products current stock (from stock_available) foreach ($products as &$product) { $product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($product['product_id'], $product['product_attribute_id'], $product['id_shop']); $resume = OrderSlip::getProductSlipResume($product['id_order_detail']); $product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity']; $product['amount_refundable'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl']; $product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl'], $currency); $product['refund_history'] = OrderSlip::getProductSlipDetail($product['id_order_detail']); $product['return_history'] = OrderReturn::getProductReturnDetail($product['id_order_detail']); // if the current stock requires a warning if ($product['current_stock'] == 0 && $display_out_of_stock_warning) { $this->displayWarning($this->l('This product is out of stock: ') . ' ' . $product['product_name']); } if ($product['id_warehouse'] != 0) { $warehouse = new Warehouse((int) $product['id_warehouse']); $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->id); foreach ($history as &$order_state) { $order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black'; } // Smarty assign $this->tpl_view_vars = array('order' => $order, 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array('delivery' => $addressDelivery, 'deliveryState' => isset($deliveryState) ? $deliveryState : null, 'invoice' => $addressInvoice, 'invoiceState' => isset($invoiceState) ? $invoiceState : null), 'customerStats' => $customer->getStats(), 'products' => $products, 'discounts' => $order->getCartRules(), 'orders_total_paid_tax_incl' => $order->getOrdersTotalPaid(), 'total_paid' => $order->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), 'customer_thread_message' => CustomerThread::getCustomerMessages($order->id_customer), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier), 'history' => $history, 'states' => OrderState::getOrderStates($this->context->language->id), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($order->id), 'currentState' => $order->getCurrentOrderState(), 'currency' => new Currency($order->id_currency), 'currencies' => Currency::getCurrenciesByIdShop($order->id_shop), 'previousOrder' => $order->getPreviousOrderId(), 'nextOrder' => $order->getNextOrderId(), 'current_index' => self::$currentIndex, 'carrierModuleCall' => $carrier_module_call, 'iso_code_lang' => $this->context->language->iso_code, 'id_lang' => $this->context->language->id, 'can_edit' => $this->tabAccess['edit'] == 1, 'current_id_lang' => $this->context->language->id, 'invoices_collection' => $order->getInvoicesCollection(), 'not_paid_invoices_collection' => $order->getNotPaidInvoicesCollection(), 'payment_methods' => $payment_methods, 'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $order->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')); return parent::renderView(); }
public function ajaxProcessGetCurrenciesOptions() { if (!($res = Currency::getCurrenciesByIdShop((int) Tools::getValue('id_shop')))) { return; } $tpl = $this->createTemplate('specific_prices_shop_update.tpl'); $tpl->assign(array('option_list' => $res, 'key_id' => 'id_currency', 'key_value' => 'name')); $this->content = $tpl->fetch(); }
public function renderView() { $order = new Order(Tools::getValue('id_order')); if (!Validate::isLoadedObject($order)) { $this->errors[] = Tools::displayError('The order cannot be found within your database.'); } $customer = new Customer($order->id_customer); $carrier = new Carrier($order->id_carrier); $products = $this->getProducts($order); $order_details = AphOrderDetail::getList($order->id); foreach ($order_details as &$order_detail) { $products[$order_detail['id_order_detail']]['delivery_date'] = $order_detail['delivery_date']; $products[$order_detail['id_order_detail']]['delivery_time_from'] = $order_detail['delivery_time_from']; $products[$order_detail['id_order_detail']]['delivery_time_to'] = $order_detail['delivery_time_to']; } $currency = new Currency((int) $order->id_currency); // 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 Address($order->id_address_invoice, $this->context->language->id); if (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state) { $invoiceState = new State((int) $addressInvoice->id_state); } if ($order->id_address_invoice == $order->id_address_delivery) { $addressDelivery = $addressInvoice; if (isset($invoiceState)) { $deliveryState = $invoiceState; } } else { $addressDelivery = new Address($order->id_address_delivery, $this->context->language->id); if (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) { $deliveryState = new State((int) $addressDelivery->id_state); } } $this->toolbar_title = sprintf($this->l('Order #%1$d (%2$s) - %3$s %4$s'), $order->id, $order->reference, $customer->firstname, $customer->lastname); if (Shop::isFeatureActive()) { $shop = new Shop((int) $order->id_shop); $this->toolbar_title .= ' - ' . sprintf($this->l('Shop: %s'), $shop->name); } // 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 Product($order_detail['product_id']); if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management) { $warehouses = Warehouse::getWarehousesByProductId($order_detail['product_id'], $order_detail['product_attribute_id']); foreach ($warehouses as $warehouse) { if (!isset($warehouse_list[$warehouse['id_warehouse']])) { $warehouse_list[$warehouse['id_warehouse']] = $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_state = $order->getCurrentOrderState(); if (Configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || $current_order_state->delivery != 1 && $current_order_state->shipped != 1)) { $display_out_of_stock_warning = true; } // products current stock (from stock_available) foreach ($products as &$product) { // Get total customized quantity for current product $customized_product_quantity = 0; if (is_array($product['customizedDatas'])) { foreach ($product['customizedDatas'] as $customizationPerAddress) { foreach ($customizationPerAddress as $customizationId => $customization) { $customized_product_quantity += (int) $customization['quantity']; } } } $product['customized_product_quantity'] = $customized_product_quantity; $product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($product['product_id'], $product['product_attribute_id'], $product['id_shop']); $resume = OrderSlip::getProductSlipResume($product['id_order_detail']); $product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity']; $product['amount_refundable'] = $product['total_price_tax_excl'] - $resume['amount_tax_excl']; $product['amount_refundable_tax_incl'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl']; $product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl'], $currency); $product['refund_history'] = OrderSlip::getProductSlipDetail($product['id_order_detail']); $product['return_history'] = OrderReturn::getProductReturnDetail($product['id_order_detail']); // if the current stock requires a warning if ($product['current_stock'] <= 0 && $display_out_of_stock_warning) { $this->displayWarning($this->l('This product is out of stock: ') . ' ' . $product['product_name']); } if ($product['id_warehouse'] != 0) { $warehouse = new Warehouse((int) $product['id_warehouse']); $product['warehouse_name'] = $warehouse->name; $warehouse_location = WarehouseProductLocation::getProductLocation($product['product_id'], $product['product_attribute_id'], $product['id_warehouse']); if (!empty($warehouse_location)) { $product['warehouse_location'] = $warehouse_location; } else { $product['warehouse_location'] = false; } } else { $product['warehouse_name'] = '--'; $product['warehouse_location'] = false; } } $gender = new Gender((int) $customer->id_gender, $this->context->language->id); $history = $order->getHistory($this->context->language->id); foreach ($history as &$order_state) { $order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black'; } // Smarty assign $this->tpl_view_vars = array('order' => $order, 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array('delivery' => $addressDelivery, 'deliveryState' => isset($deliveryState) ? $deliveryState : null, 'invoice' => $addressInvoice, 'invoiceState' => isset($invoiceState) ? $invoiceState : null), 'customerStats' => $customer->getStats(), 'products' => $products, 'discounts' => $order->getCartRules(), 'orders_total_paid_tax_incl' => $order->getOrdersTotalPaid(), 'total_paid' => $order->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), 'customer_thread_message' => CustomerThread::getCustomerMessages($order->id_customer, null, $order->id), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier), 'history' => $history, 'states' => OrderState::getOrderStates($this->context->language->id), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($order->id), 'currentState' => $order->getCurrentOrderState(), 'currency' => new Currency($order->id_currency), 'currencies' => Currency::getCurrenciesByIdShop($order->id_shop), 'previousOrder' => $order->getPreviousOrderId(), 'nextOrder' => $order->getNextOrderId(), 'current_index' => self::$currentIndex, 'carrierModuleCall' => $carrier_module_call, 'iso_code_lang' => $this->context->language->iso_code, 'id_lang' => $this->context->language->id, 'can_edit' => $this->tabAccess['edit'] == 1, 'current_id_lang' => $this->context->language->id, 'invoices_collection' => $order->getInvoicesCollection(), 'not_paid_invoices_collection' => $order->getNotPaidInvoicesCollection(), 'payment_methods' => $payment_methods, 'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $order->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'), 'HOOK_CONTENT_ORDER' => Hook::exec('displayAdminOrderContentOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array('order' => $order, 'products' => $products, 'customer' => $customer))); $options_time = array(); $time_slice = Configuration::get('APH_CALENDAR_TIME_SLICE'); for ($hours = 0; $hours < 24; $hours++) { // the interval for hours is '1' for ($mins = 0; $mins < 60; $mins += $time_slice) { // the interval for mins is 'APH_CALENDAR_TIME_SLICE' $options_time[str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($mins, 2, '0', STR_PAD_LEFT)] = str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($mins, 2, '0', STR_PAD_LEFT); } } $this->tpl_view_vars['options_time'] = $options_time; $employees = array(); $e = AphEmployeeProduct::getEmployeesByShop((int) Context::getContext()->shop->id); foreach ($e as $employee) { $employees[$employee['id_employee']] = $employee['fullName']; } $this->tpl_view_vars['employees'] = $employees; $helper = new HelperView($this); $this->setHelperDisplay($helper); $helper->tpl_vars = $this->getTemplateViewVars(); $helper->base_folder = $this->getTemplatePath() . 'aph_orders/helpers/'; $helper->base_tpl = 'view/view.tpl'; $view = $helper->generateView(); return $view; }
public function renderView() { $order = new Order(Tools::getValue('id_order')); if (!Validate::isLoadedObject($order)) { $this->errors[] = Tools::displayError('The order cannot be found within your database.'); } $customer = new Customer($order->id_customer); $carrier = new Carrier($order->id_carrier); $products = $this->getProducts($order); $currency = new Currency((int) $order->id_currency); // 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 Address($order->id_address_invoice, $this->context->language->id); if (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state) { $invoiceState = new State((int) $addressInvoice->id_state); } if ($order->id_address_invoice == $order->id_address_delivery) { $addressDelivery = $addressInvoice; if (isset($invoiceState)) { $deliveryState = $invoiceState; } } else { $addressDelivery = new Address($order->id_address_delivery, $this->context->language->id); if (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) { $deliveryState = new State((int) $addressDelivery->id_state); } } $this->toolbar_title = sprintf($this->l('Order #%1$d (%2$s) - %3$s %4$s'), $order->id, $order->reference, $customer->firstname, $customer->lastname); if (Shop::isFeatureActive()) { $shop = new Shop((int) $order->id_shop); $this->toolbar_title .= ' - ' . sprintf($this->l('Shop: %s'), $shop->name); } // 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 Product($order_detail['product_id']); if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management) { $warehouses = Warehouse::getWarehousesByProductId($order_detail['product_id'], $order_detail['product_attribute_id']); foreach ($warehouses as $warehouse) { if (!isset($warehouse_list[$warehouse['id_warehouse']])) { $warehouse_list[$warehouse['id_warehouse']] = $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_state = $order->getCurrentOrderState(); if (Configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || $current_order_state->delivery != 1 && $current_order_state->shipped != 1)) { $display_out_of_stock_warning = true; } // products current stock (from stock_available) foreach ($products as &$product) { // Get total customized quantity for current product $customized_product_quantity = 0; if (is_array($product['customizedDatas'])) { foreach ($product['customizedDatas'] as $customizationPerAddress) { foreach ($customizationPerAddress as $customizationId => $customization) { $customized_product_quantity += (int) $customization['quantity']; } } } $product['customized_product_quantity'] = $customized_product_quantity; $product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($product['product_id'], $product['product_attribute_id'], $product['id_shop']); $resume = OrderSlip::getProductSlipResume($product['id_order_detail']); $product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity']; $product['amount_refundable'] = $product['total_price_tax_excl'] - $resume['amount_tax_excl']; $product['amount_refundable_tax_incl'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl']; $product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl'], $currency); $product['refund_history'] = OrderSlip::getProductSlipDetail($product['id_order_detail']); $product['return_history'] = OrderReturn::getProductReturnDetail($product['id_order_detail']); // if the current stock requires a warning if ($product['current_stock'] == 0 && $display_out_of_stock_warning) { $this->displayWarning($this->l('This product is out of stock: ') . ' ' . $product['product_name']); } if ($product['id_warehouse'] != 0) { $warehouse = new Warehouse((int) $product['id_warehouse']); $product['warehouse_name'] = $warehouse->name; $warehouse_location = WarehouseProductLocation::getProductLocation($product['product_id'], $product['product_attribute_id'], $product['id_warehouse']); if (!empty($warehouse_location)) { $product['warehouse_location'] = $warehouse_location; } else { $product['warehouse_location'] = false; } } else { $product['warehouse_name'] = '--'; $product['warehouse_location'] = false; } } $gender = new Gender((int) $customer->id_gender, $this->context->language->id); $history = $order->getHistory($this->context->language->id); foreach ($history as &$order_state) { $order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black'; } //by webkul to get data to show hotel rooms order data on order detail page $cart_id = Cart::getCartIdByOrderId(Tools::getValue('id_order')); $cart_detail_data = array(); $cart_detail_data_obj = new HotelCartBookingData(); $cart_detail_data = $cart_detail_data_obj->getCartCurrentDataByCartId((int) $cart_id); if ($cart_detail_data) { foreach ($cart_detail_data as $key => $value) { $product_image_id = Product::getCover($value['id_product']); $link_rewrite = (new Product((int) $value['id_product'], Configuration::get('PS_LANG_DEFAULT')))->link_rewrite[Configuration::get('PS_LANG_DEFAULT')]; if ($product_image_id) { $cart_detail_data[$key]['image_link'] = $this->context->link->getImageLink($link_rewrite, $product_image_id['id_image'], 'small_default'); } else { $cart_detail_data[$key]['image_link'] = $this->context->link->getImageLink($link_rewrite, $this->context->language->iso_code . "-default", 'small_default'); } $cart_detail_data[$key]['room_type'] = (new Product((int) $value['id_product']))->name[Configuration::get('PS_LANG_DEFAULT')]; $cart_detail_data[$key]['room_num'] = (new HotelRoomInformation((int) $value['id_room']))->room_num; $cart_detail_data[$key]['date_from'] = (new DateTime($value['date_from']))->format('d-M Y'); $cart_detail_data[$key]['date_to'] = (new DateTime($value['date_to']))->format('d-M Y'); $cust_obj = new Customer($value['id_customer']); $cart_detail_data[$key]['alloted_cust_name'] = $cust_obj->firstname . ' ' . $cust_obj->lastname; $cart_detail_data[$key]['alloted_cust_email'] = $cust_obj->email; $cart_detail_data[$key]['avail_rooms_to_swap'] = (new HotelBookingDetail())->getAvailableRoomsForSwaping($value['date_from'], $value['date_to'], $value['id_product'], $value['id_hotel']); $obj_booking_dtl = new HotelBookingDetail(); $num_days = $obj_booking_dtl->getNumberOfDays($cart_detail_data[$key]['date_from'], $cart_detail_data[$key]['date_to']); //quantity of product $cart_detail_data[$key]['amt_with_qty'] = $value['amount'] * $num_days; } } //end //by webkul to send order status on order detail page $obj_bookin_detail = new HotelBookingDetail(); $htl_booking_data_order_id = $obj_bookin_detail->getBookingDataByOrderId(Tools::getValue('id_order')); if ($htl_booking_data_order_id) { foreach ($htl_booking_data_order_id as $key => $value) { $htl_booking_data_order_id[$key]['room_num'] = (new HotelRoomInformation())->getHotelRoomInfoById($value['id_room']); $htl_booking_data_order_id[$key]['order_status'] = $value['id_status']; $htl_booking_data_order_id[$key]['date_from'] = (new DateTime($value['date_from']))->format('d-M Y'); $htl_booking_data_order_id[$key]['date_to'] = (new DateTime($value['date_to']))->format('d-M Y'); } } $htl_order_status = HotelOrderStatus::getAllHotelOrderStatus(); //end // Smarty assign $this->tpl_view_vars = array('htl_booking_order_data' => $htl_booking_data_order_id, 'hotel_order_status' => $htl_order_status, 'cart_detail_data' => $cart_detail_data, 'order' => $order, 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array('delivery' => $addressDelivery, 'deliveryState' => isset($deliveryState) ? $deliveryState : null, 'invoice' => $addressInvoice, 'invoiceState' => isset($invoiceState) ? $invoiceState : null), 'customerStats' => $customer->getStats(), 'products' => $products, 'discounts' => $order->getCartRules(), 'orders_total_paid_tax_incl' => $order->getOrdersTotalPaid(), 'total_paid' => $order->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), 'customer_thread_message' => CustomerThread::getCustomerMessages($order->id_customer, null, $order->id), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier), 'history' => $history, 'states' => OrderState::getOrderStates($this->context->language->id), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($order->id), 'currentState' => $order->getCurrentOrderState(), 'currency' => new Currency($order->id_currency), 'currencies' => Currency::getCurrenciesByIdShop($order->id_shop), 'previousOrder' => $order->getPreviousOrderId(), 'nextOrder' => $order->getNextOrderId(), 'current_index' => self::$currentIndex, 'carrierModuleCall' => $carrier_module_call, 'iso_code_lang' => $this->context->language->iso_code, 'id_lang' => $this->context->language->id, 'can_edit' => $this->tabAccess['edit'] == 1, 'current_id_lang' => $this->context->language->id, 'invoices_collection' => $order->getInvoicesCollection(), 'not_paid_invoices_collection' => $order->getNotPaidInvoicesCollection(), 'payment_methods' => $payment_methods, 'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $order->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'), 'HOOK_CONTENT_ORDER' => Hook::exec('displayAdminOrderContentOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array('order' => $order, 'products' => $products, 'customer' => $customer))); return parent::renderView(); }
private function validateCSVCurrencies($csv_data, $csv_data_count) { if (version_compare(_PS_VERSION_, '1.5', '<')) { $currencies = Currency::getCurrencies(); } else { $currencies = Currency::getCurrenciesByIdShop((int) $this->context->shop->id); } $available_currencies = array(); foreach ($currencies as $data) { $available_currencies[] = $data['iso_code']; } $wrong_currencies = ''; for ($i = 0; $i < $csv_data_count; $i++) { if (!in_array($csv_data[$i][DpdGroupCSV::COLUMN_CURRENCY], $available_currencies)) { $wrong_currencies .= $i + self::DEFAULT_FIRST_LINE_INDEX . ', '; } } $this->removeLastSymbolsFromString($wrong_currencies); return empty($wrong_currencies) ? true : $wrong_currencies; }
public function renderView() { $neoExchange = new NeoExchanges(Tools::getValue('id_neo_exchange')); $order = new Order(Tools::getValue('id_neo_exchange')); if (!Validate::isLoadedObject($neoExchange)) { $this->errors[] = Tools::displayError('The order cannot be found within your database.'); } $customer = new Customer($neoExchange->id_customer); //$carrier = new Carrier($neoExchange->id_carrier); $currency = new Currency((int) $neoExchange->id_currency); $buys = new NeoItemsBuyCore(Tools::getValue('id_neo_exchange')); $sales = new NeoItemsSalesCore(Tools::getValue('id_neo_exchange')); $products = $this->getProducts($buys); $products2 = $this->getProducts($sales); //$products = $this->getProducts($neoExchange); // 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'), $neoExchange->id_cart); } // Retrieve addresses information $addressInvoice = new Address($neoExchange->id_address_invoice, $this->context->language->id); if (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state) $invoiceState = new State((int)$addressInvoice->id_state); if ($neoExchange->id_address_invoice == $neoExchange->id_address_delivery) { $addressDelivery = $addressInvoice; if (isset($invoiceState)) $deliveryState = $invoiceState; } else { $addressDelivery = new Address($neoExchange->id_address_delivery, $this->context->language->id); if (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) $deliveryState = new State((int)($addressDelivery->id_state)); }*/ $this->toolbar_title = sprintf($this->l('Intercambio #%1$d (%2$s) - %3$s %4$s'), $neoExchange->id, $neoExchange->reference, $customer->firstname, $customer->lastname); if (Shop::isFeatureActive()) { $shop = new Shop((int) $neoExchange->id_shop); $this->toolbar_title .= ' - ' . sprintf($this->l('Shop: %s'), $shop->name); } // gets warehouses to ship products, if and only if advanced stock management is activated $warehouse_list = null; $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_state = $neoExchange->getCurrentOrderState(); if (Configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || $current_order_state->delivery != 1 && $current_order_state->shipped != 1)) { $display_out_of_stock_warning = true; } $total_buy = 0; $total_sale = 0; $products_buy = count($products); $products_sale = count($products2); // products current stock (from stock_available) foreach ($products as &$product) { $total_buy += $product['price']; } foreach ($products2 as &$product) { $total_sale += $product['price']; } $gender = new Gender((int) $customer->id_gender, $this->context->language->id); $history = $neoExchange->getHistory($this->context->language->id); foreach ($history as &$order_state) { $order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black'; } // Smarty assign $this->tpl_view_vars = array('order' => $neoExchange, 'customer' => $customer, 'gender' => $gender, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'customerStats' => $customer->getStats(), 'products' => $products, 'products2' => $products2, 'total_buy' => $total_buy, 'total_sale' => $total_sale, 'products_buy' => $products_buy, 'products_sale' => $products_sale, 'neo_order_shipping_price' => 0, 'orders_total_paid_tax_incl' => $neoExchange->getOrdersTotalPaid(), 'total_paid' => $neoExchange->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($neoExchange->id_customer, $neoExchange->id), 'customer_thread_message' => CustomerThread::getCustomerMessages($neoExchange->id_customer), 'orderMessages' => OrderMessage::getOrderMessages($neoExchange->id_lang), 'messages' => Message::getMessagesByOrderId($neoExchange->id, true), 'history' => $history, 'neoStatus' => NeoStatusCore::getNeoStatus(), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($neoExchange->id), 'currentState' => $neoExchange->getCurrentOrderState(), 'currency' => new Currency($neoExchange->id_currency), 'currencies' => Currency::getCurrenciesByIdShop($neoExchange->id_shop), 'previousOrder' => $neoExchange->getPreviousOrderId(), 'nextOrder' => $neoExchange->getNextOrderId(), 'current_index' => self::$currentIndex, 'iso_code_lang' => $this->context->language->iso_code, 'id_lang' => $this->context->language->id, 'can_edit' => $this->tabAccess['edit'] == 1, 'current_id_lang' => $this->context->language->id, 'invoices_collection' => $neoExchange->getInvoicesCollection(), 'not_paid_invoices_collection' => $neoExchange->getNotPaidInvoicesCollection(), 'payment_methods' => $payment_methods, 'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $neoExchange->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'), 'HOOK_CONTENT_ORDER' => Hook::exec('displayAdminOrderContentOrder', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer)), 'HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer))); return parent::renderView(); }
/** * Modifies the current context and replaces the info related to shop, link, language and currency. * * We need this when generating the product data for the different shops and languages. * The currency will be the first found for the shop, but it defaults to the PS default currency * if no shop specific one is found. * * @param int $id_lang the language ID to add to the new context. * @param int $id_shop the shop ID to add to the new context. * @return Context the new context. */ protected function makeContext($id_lang, $id_shop) { if (_PS_VERSION_ >= '1.5') { // Reset the shop context to be the current processed shop. This will fix the "friendly url" format of urls // generated through the Link class. Shop::setContext(Shop::CONTEXT_SHOP, $id_shop); // Reset the dispatcher singleton instance so that the url rewrite setting is check on a shop basis when // generating product urls. This will fix the issue of incorrectly formatted urls when one shop has the // rewrite setting enabled and another does not. Dispatcher::$instance = null; if (method_exists('ShopUrl', 'resetMainDomainCache')) { // Reset the shop url domain cache so that it is re-initialized on a shop basis when generating product // image urls. This will fix the issue of the image urls having an incorrect shop base url when the // shops are configured to use different domains. ShopUrl::resetMainDomainCache(); } foreach (Currency::getCurrenciesByIdShop($id_shop) as $row) { if ($row['deleted'] === '0' && $row['active'] === '1') { $currency = new Currency($row['id_currency']); break; } } } $context = Context::getContext(); $context->language = new Language($id_lang); $context->shop = new Shop($id_shop); $context->link = new Link('http://', 'http://'); $context->currency = isset($currency) ? $currency : Currency::getDefaultCurrency(); return $context; }
public function renderView() { $order = new Order(Tools::getValue('id_order')); if (!Validate::isLoadedObject($order)) { $this->errors[] = $this->trans('The order cannot be found within your database.', array(), 'Admin.OrdersCustomers.Notification'); } $customer = new Customer($order->id_customer); $carrier = new Carrier($order->id_carrier); $products = $this->getProducts($order); $currency = new Currency((int) $order->id_currency); // 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 Address($order->id_address_invoice, $this->context->language->id); if (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state) { $invoiceState = new State((int) $addressInvoice->id_state); } if ($order->id_address_invoice == $order->id_address_delivery) { $addressDelivery = $addressInvoice; if (isset($invoiceState)) { $deliveryState = $invoiceState; } } else { $addressDelivery = new Address($order->id_address_delivery, $this->context->language->id); if (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) { $deliveryState = new State((int) $addressDelivery->id_state); } } $this->toolbar_title = $this->trans('Order #%id% (%ref%) - %firstname% %lastname%', array('%id%' => $order->id, '%ref%' => $order->reference, '%firstname%' => $customer->firstname, '%lastname%' => $customer->lastname), 'Admin.OrdersCustomers.Feature'); if (Shop::isFeatureActive()) { $shop = new Shop((int) $order->id_shop); $this->toolbar_title .= ' - ' . sprintf($this->trans('Shop: %s', array(), 'Admin.OrdersCustomers.Feature'), $shop->name); } // 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 Product($order_detail['product_id']); if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management) { $warehouses = Warehouse::getWarehousesByProductId($order_detail['product_id'], $order_detail['product_attribute_id']); foreach ($warehouses as $warehouse) { if (!isset($warehouse_list[$warehouse['id_warehouse']])) { $warehouse_list[$warehouse['id_warehouse']] = $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_state = $order->getCurrentOrderState(); if (Configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || $current_order_state->delivery != 1 && $current_order_state->shipped != 1)) { $display_out_of_stock_warning = true; } // products current stock (from stock_available) foreach ($products as &$product) { // Get total customized quantity for current product $customized_product_quantity = 0; if (is_array($product['customizedDatas'])) { foreach ($product['customizedDatas'] as $customizationPerAddress) { foreach ($customizationPerAddress as $customizationId => $customization) { $customized_product_quantity += (int) $customization['quantity']; } } } $product['customized_product_quantity'] = $customized_product_quantity; $product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($product['product_id'], $product['product_attribute_id'], $product['id_shop']); $resume = OrderSlip::getProductSlipResume($product['id_order_detail']); $product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity']; $product['amount_refundable'] = $product['total_price_tax_excl'] - $resume['amount_tax_excl']; $product['amount_refundable_tax_incl'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl']; $product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl'], $currency); $product['refund_history'] = OrderSlip::getProductSlipDetail($product['id_order_detail']); $product['return_history'] = OrderReturn::getProductReturnDetail($product['id_order_detail']); // if the current stock requires a warning if ($product['current_stock'] <= 0 && $display_out_of_stock_warning) { $this->displayWarning($this->trans('This product is out of stock: ', array(), 'Admin.OrdersCustomers.Notification') . ' ' . $product['product_name']); } if ($product['id_warehouse'] != 0) { $warehouse = new Warehouse((int) $product['id_warehouse']); $product['warehouse_name'] = $warehouse->name; $warehouse_location = WarehouseProductLocation::getProductLocation($product['product_id'], $product['product_attribute_id'], $product['id_warehouse']); if (!empty($warehouse_location)) { $product['warehouse_location'] = $warehouse_location; } else { $product['warehouse_location'] = false; } } else { $product['warehouse_name'] = '--'; $product['warehouse_location'] = false; } } // Package management for order foreach ($products as &$product) { $pack_items = $product['cache_is_pack'] ? Pack::getItemTable($product['id_product'], $this->context->language->id, true) : array(); foreach ($pack_items as &$pack_item) { $pack_item['current_stock'] = StockAvailable::getQuantityAvailableByProduct($pack_item['id_product'], $pack_item['id_product_attribute'], $pack_item['id_shop']); // if the current stock requires a warning if ($product['current_stock'] <= 0 && $display_out_of_stock_warning) { $this->displayWarning($this->trans('This product, included in package (' . $product['product_name'] . ') is out of stock: ', array(), 'Admin.OrdersCustomers.Notification') . ' ' . $pack_item['product_name']); } $this->setProductImageInformations($pack_item); if ($pack_item['image'] != null) { $name = 'product_mini_' . (int) $pack_item['id_product'] . (isset($pack_item['id_product_attribute']) ? '_' . (int) $pack_item['id_product_attribute'] : '') . '.jpg'; // generate image cache, only for back office $pack_item['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $pack_item['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg'); if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { $pack_item['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); } else { $pack_item['image_size'] = false; } } } $product['pack_items'] = $pack_items; } $gender = new Gender((int) $customer->id_gender, $this->context->language->id); $history = $order->getHistory($this->context->language->id); foreach ($history as &$order_state) { $order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black'; } // Smarty assign $this->tpl_view_vars = array('order' => $order, 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array('delivery' => $addressDelivery, 'deliveryState' => isset($deliveryState) ? $deliveryState : null, 'invoice' => $addressInvoice, 'invoiceState' => isset($invoiceState) ? $invoiceState : null), 'customerStats' => $customer->getStats(), 'products' => $products, 'discounts' => $order->getCartRules(), 'orders_total_paid_tax_incl' => $order->getOrdersTotalPaid(), 'total_paid' => $order->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), 'customer_thread_message' => CustomerThread::getCustomerMessages($order->id_customer, null, $order->id), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier), 'history' => $history, 'states' => OrderState::getOrderStates($this->context->language->id), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($order->id), 'currentState' => $order->getCurrentOrderState(), 'currency' => new Currency($order->id_currency), 'currencies' => Currency::getCurrenciesByIdShop($order->id_shop), 'previousOrder' => $order->getPreviousOrderId(), 'nextOrder' => $order->getNextOrderId(), 'current_index' => self::$currentIndex, 'carrierModuleCall' => $carrier_module_call, 'iso_code_lang' => $this->context->language->iso_code, 'id_lang' => $this->context->language->id, 'can_edit' => $this->access('edit'), 'current_id_lang' => $this->context->language->id, 'invoices_collection' => $order->getInvoicesCollection(), 'not_paid_invoices_collection' => $order->getNotPaidInvoicesCollection(), 'payment_methods' => $payment_methods, 'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $order->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'), 'carrier_list' => $this->getCarrierList($order), 'recalculate_shipping_cost' => (int) Configuration::get('PS_ORDER_RECALCULATE_SHIPPING'), 'HOOK_CONTENT_ORDER' => Hook::exec('displayAdminOrderContentOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array('order' => $order, 'products' => $products, 'customer' => $customer))); return parent::renderView(); }