public function renderView()
 {
     $this->initPageHeaderToolbar();
     $this->tpl_view_vars = array('version' => array('php' => phpversion(), 'server' => $_SERVER['SERVER_SOFTWARE'], 'memory_limit' => ini_get('memory_limit'), 'max_execution_time' => ini_get('max_execution_time')), 'database' => array('version' => Db::getInstance()->getVersion(), 'prefix' => _DB_PREFIX_, 'engine' => _MYSQL_ENGINE_), 'uname' => function_exists('php_uname') ? php_uname('s') . ' ' . php_uname('v') . ' ' . php_uname('m') : '', 'apache_instaweb' => Tools::apacheModExists('mod_instaweb'), 'shop' => array('ps' => _PS_VERSION_, 'url' => Tools::getHttpHost(true) . __PS_BASE_URI__, 'theme' => _THEME_NAME_), 'mail' => Configuration::get('PS_MAIL_METHOD') == 1, 'smtp' => array('server' => Configuration::get('PS_MAIL_SERVER'), 'user' => Configuration::get('PS_MAIL_USER'), 'password' => Configuration::get('PS_MAIL_PASSWD'), 'encryption' => Configuration::get('PS_MAIL_SMTP_ENCRYPTION'), 'port' => Configuration::get('PS_MAIL_SMTP_PORT')), 'user_agent' => $_SERVER['HTTP_USER_AGENT']);
     $this->tpl_view_vars = array_merge($this->getTestResult(), $this->tpl_view_vars);
     return parent::renderView();
 }
 public function renderView()
 {
     $this->context = Context::getContext();
     if (!($group = $this->loadObject(true))) {
         return;
     }
     $this->tpl_view_vars = array('group' => $group, 'language' => $this->context->language, 'customerList' => $this->renderCustomersList($group), 'categorieReductions' => $this->formatCategoryDiscountList($group->id));
     return parent::renderView();
 }
 public function renderView()
 {
     $this->initTabModuleList();
     $this->filterTabModuleList();
     $this->context->smarty->assign('panel_title', $this->l('Use one of our recommended carrier modules'));
     $this->tpl_view_vars = array('modules_list' => $this->renderModulesList());
     unset($this->page_header_toolbar_btn['modules-list']);
     return parent::renderView();
 }
 public function renderView()
 {
     $this->initPageHeaderToolbar();
     $hosting_vars = array();
     if (!defined('_PS_HOST_MODE_')) {
         $hosting_vars = array('version' => array('php' => phpversion(), 'server' => $_SERVER['SERVER_SOFTWARE'], 'memory_limit' => ini_get('memory_limit'), 'max_execution_time' => ini_get('max_execution_time')), 'database' => array('version' => Db::getInstance()->getVersion(), 'server' => _DB_SERVER_, 'name' => _DB_NAME_, 'user' => _DB_USER_, 'prefix' => _DB_PREFIX_, 'engine' => _MYSQL_ENGINE_, 'driver' => Db::getClass()), 'uname' => function_exists('php_uname') ? php_uname('s') . ' ' . php_uname('v') . ' ' . php_uname('m') : '', 'apache_instaweb' => Tools::apacheModExists('mod_instaweb'));
     }
     $shop_vars = array('shop' => array('ps' => _PS_VERSION_, 'url' => $this->context->shop->getBaseURL(), 'theme' => $this->context->shop->theme_name), 'mail' => Configuration::get('PS_MAIL_METHOD') == 1, 'smtp' => array('server' => Configuration::get('PS_MAIL_SERVER'), 'user' => Configuration::get('PS_MAIL_USER'), 'password' => Configuration::get('PS_MAIL_PASSWD'), 'encryption' => Configuration::get('PS_MAIL_SMTP_ENCRYPTION'), 'port' => Configuration::get('PS_MAIL_SMTP_PORT')), 'user_agent' => $_SERVER['HTTP_USER_AGENT']);
     $this->tpl_view_vars = array_merge($this->getTestResult(), array_merge($hosting_vars, $shop_vars));
     return parent::renderView();
 }
 public function renderView()
 {
     $this->toolbar_title = $this->l('Payment');
     unset($this->toolbar_btn['back']);
     $shop_context = !Shop::isFeatureActive() || Shop::getContext() == Shop::CONTEXT_SHOP;
     if (!$shop_context) {
         $this->tpl_view_vars = array('shop_context' => $shop_context);
         return parent::renderView();
     }
     $this->tpl_view_vars = array('modules_list' => $this->renderModulesList('back-office,AdminPayment,index'), 'ps_base_uri' => __PS_BASE_URI__, 'url_submit' => self::$currentIndex . '&token=' . $this->token, 'shop_context' => $shop_context);
     return parent::renderView();
 }
 public function renderView()
 {
     $this->initWizard();
     if (Tools::getValue('id_carrier') && $this->access('edit')) {
         $carrier = $this->loadObject();
     } elseif ($this->access('add')) {
         $carrier = new Carrier();
     }
     if (!$this->access('edit') && Tools::getValue('id_carrier') || !$this->access('add') && !Tools::getValue('id_carrier')) {
         $this->errors[] = $this->trans('You do not have permission to use this wizard.', array(), 'Admin.Shipping.Notification');
         return;
     }
     $currency = $this->getActualCurrency();
     $this->tpl_view_vars = array('currency_sign' => $currency->sign, 'PS_WEIGHT_UNIT' => Configuration::get('PS_WEIGHT_UNIT'), 'enableAllSteps' => Validate::isLoadedObject($carrier), 'wizard_steps' => $this->wizard_steps, 'validate_url' => $this->context->link->getAdminLink('AdminCarrierWizard'), 'carrierlist_url' => $this->context->link->getAdminLink('AdminCarriers') . '&conf=' . ((int) Validate::isLoadedObject($carrier) ? 4 : 3), 'multistore_enable' => Shop::isFeatureActive(), 'wizard_contents' => array('contents' => array(0 => $this->renderStepOne($carrier), 1 => $this->renderStepThree($carrier), 2 => $this->renderStepFour($carrier), 3 => $this->renderStepFive($carrier))), 'labels' => array('next' => $this->trans('Next', array(), 'Admin.Global'), 'previous' => $this->trans('Previous', array(), 'Admin.Global'), 'finish' => $this->trans('Finish', array(), 'Admin.Actions')));
     if (Shop::isFeatureActive()) {
         array_splice($this->tpl_view_vars['wizard_contents']['contents'], 1, 0, array(0 => $this->renderStepTwo($carrier)));
     }
     $this->context->smarty->assign(array('carrier_logo' => Validate::isLoadedObject($carrier) && file_exists(_PS_SHIP_IMG_DIR_ . $carrier->id . '.jpg') ? _THEME_SHIP_DIR_ . $carrier->id . '.jpg' : false));
     $this->context->smarty->assign(array('logo_content' => $this->createTemplate('logo.tpl')->fetch()));
     $this->addjQueryPlugin(array('ajaxfileupload'));
     return parent::renderView();
 }
 public function renderView()
 {
     if (!($manufacturer = $this->loadObject())) {
         return;
     }
     $this->toolbar_btn['new'] = array('href' => $this->context->link->getAdminLink('AdminManufacturers') . '&addaddress=1&id_manufacturer=' . (int) $manufacturer->id, 'desc' => $this->l('Add address'));
     $this->toolbar_title = is_array($this->breadcrumbs) ? array_unique($this->breadcrumbs) : array($this->breadcrumbs);
     $this->toolbar_title[] = $manufacturer->name;
     $addresses = $manufacturer->getAddresses($this->context->language->id);
     $products = $manufacturer->getProductsLite($this->context->language->id);
     $total_product = count($products);
     for ($i = 0; $i < $total_product; $i++) {
         $products[$i] = new Product($products[$i]['id_product'], false, $this->context->language->id);
         $products[$i]->loadStockData();
         /* Build attributes combinations */
         $combinations = $products[$i]->getAttributeCombinations($this->context->language->id);
         foreach ($combinations as $k => $combination) {
             $comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference'];
             $comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13'];
             $comb_array[$combination['id_product_attribute']]['upc'] = $combination['upc'];
             $comb_array[$combination['id_product_attribute']]['quantity'] = $combination['quantity'];
             $comb_array[$combination['id_product_attribute']]['attributes'][] = array($combination['group_name'], $combination['attribute_name'], $combination['id_attribute']);
         }
         if (isset($comb_array)) {
             foreach ($comb_array as $key => $product_attribute) {
                 $list = '';
                 foreach ($product_attribute['attributes'] as $attribute) {
                     $list .= $attribute[0] . ' - ' . $attribute[1] . ', ';
                 }
                 $comb_array[$key]['attributes'] = rtrim($list, ', ');
             }
             isset($comb_array) ? $products[$i]->combination = $comb_array : '';
             unset($comb_array);
         }
     }
     $this->tpl_view_vars = array('manufacturer' => $manufacturer, 'addresses' => $addresses, 'products' => $products, 'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'shopContext' => Shop::getContext());
     return parent::renderView();
 }
 public function renderView()
 {
     $this->toolbar_title = $this->l('Payment: ');
     unset($this->toolbar_btn['back']);
     $shop_context = !Shop::isFeatureActive() || Shop::getContext() == Shop::CONTEXT_SHOP;
     if (!$shop_context) {
         $this->tpl_view_vars = array('shop_context' => $shop_context);
         return parent::renderView();
     }
     // link to modules page
     if (isset($this->payment_modules[0])) {
         $token_modules = Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $this->context->employee->id);
     }
     $display_restrictions = false;
     foreach ($this->payment_modules as $module) {
         if ($module->active) {
             $display_restrictions = true;
             break;
         }
     }
     $lists = array(array('items' => Currency::getCurrencies(), 'title' => $this->l('Currency restrictions'), 'desc' => $this->l('Please mark each checkbox for the currency, or currencies, in which you want the payment module(s) to be available.'), 'name_id' => 'currency', 'identifier' => 'id_currency', 'icon' => 'icon-money'), array('items' => Group::getGroups($this->context->language->id), 'title' => $this->l('Group restrictions'), 'desc' => $this->l('Please mark each checkbox for the customer group(s), in which you want the payment module(s) to be available.'), 'name_id' => 'group', 'identifier' => 'id_group', 'icon' => 'icon-group'), array('items' => Country::getCountries($this->context->language->id), 'title' => $this->l('Country restrictions'), 'desc' => $this->l('Please mark each checkbox for the country, or countries, in which you want the payment module(s) to be available.'), 'name_id' => 'country', 'identifier' => 'id_country', 'icon' => 'icon-globe'));
     foreach ($lists as $key_list => $list) {
         $list['check_list'] = array();
         foreach ($list['items'] as $key_item => $item) {
             $name_id = $list['name_id'];
             foreach ($this->payment_modules as $key_module => $module) {
                 if (isset($module->{$name_id}) && in_array($item['id_' . $name_id], $module->{$name_id})) {
                     $list['items'][$key_item]['check_list'][$key_module] = 'checked';
                 } else {
                     $list['items'][$key_item]['check_list'][$key_module] = 'unchecked';
                 }
                 if (!isset($module->{$name_id})) {
                     $module->{$name_id} = array();
                 }
                 if (!isset($module->currencies_mode)) {
                     $module->currencies_mode = '';
                 }
                 if (!isset($module->currencies)) {
                     $module->currencies = '';
                 }
                 // If is a country list and the country is limited, remove it from list
                 if ($name_id == 'country' && isset($module->limited_countries) && !empty($module->limited_countries) && is_array($module->limited_countries) && !in_array(strtoupper($item['iso_code']), array_map('strtoupper', $module->limited_countries))) {
                     $list['items'][$key_item]['check_list'][$key_module] = null;
                 }
             }
         }
         // update list
         $lists[$key_list] = $list;
     }
     $this->tpl_view_vars = array('modules_list' => $this->renderModulesList(), 'display_restrictions' => $display_restrictions, 'lists' => $lists, 'ps_base_uri' => __PS_BASE_URI__, 'payment_modules' => $this->payment_modules, 'url_submit' => self::$currentIndex . '&token=' . $this->token, 'shop_context' => $shop_context);
     return parent::renderView();
 }
 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();
 }
 public function renderView()
 {
     if (Tools::isSubmit('profitability_conf')) {
         return parent::renderOptions();
     }
     // $translations = array(
     // 	'Calendar' => $this->trans('Calendar', array(),'Admin.Global'),
     // 	'Day' => $this->trans('Day', array(), 'Admin.Global'),
     // 	'Month' => $this->trans('Month', array(), 'Admin.Global'),
     // 	'Year' => $this->trans('Year', array(), 'Admin.Global'),
     // 	'From' => $this->trans('From:', array(), 'Admin.Global'),
     // 	'To' => $this->trans('To:', array(), 'Admin.Global'),
     // 	'Save' => $this->trans('Save', array(), 'Admin.Global')
     // );
     if ($this->context->cookie->__get('stats_date_update') < strtotime(date('Y-m-d'))) {
         switch ($this->context->employee->preselect_date_range) {
             case 'day':
                 $date_from = date('Y-m-d');
                 $date_to = date('Y-m-d');
                 break;
             case 'prev-day':
                 $date_from = date('Y-m-d', strtotime('-1 day'));
                 $date_to = date('Y-m-d', strtotime('-1 day'));
                 break;
             case 'month':
             default:
                 $date_from = date('Y-m-01');
                 $date_to = date('Y-m-d');
                 break;
             case 'prev-month':
                 $date_from = date('Y-m-01', strtotime('-1 month'));
                 $date_to = date('Y-m-t', strtotime('-1 month'));
                 break;
             case 'year':
                 $date_from = date('Y-01-01');
                 $date_to = date('Y-m-d');
                 break;
             case 'prev-year':
                 $date_from = date('Y-m-01', strtotime('-1 year'));
                 $date_to = date('Y-12-t', strtotime('-1 year'));
                 break;
         }
         $this->context->employee->stats_date_from = $date_from;
         $this->context->employee->stats_date_to = $date_to;
         $this->context->employee->update();
         $this->context->cookie->__set('stats_date_update', strtotime(date('Y-m-d')));
         $this->context->cookie->write();
     }
     $calendar_helper = new HelperCalendar();
     $calendar_helper->setDateFrom(Tools::getValue('date_from', $this->context->employee->stats_date_from));
     $calendar_helper->setDateTo(Tools::getValue('date_to', $this->context->employee->stats_date_to));
     $stats_compare_from = $this->context->employee->stats_compare_from;
     $stats_compare_to = $this->context->employee->stats_compare_to;
     if (is_null($stats_compare_from) || $stats_compare_from == '0000-00-00') {
         $stats_compare_from = null;
     }
     if (is_null($stats_compare_to) || $stats_compare_to == '0000-00-00') {
         $stats_compare_to = null;
     }
     $calendar_helper->setCompareDateFrom($stats_compare_from);
     $calendar_helper->setCompareDateTo($stats_compare_to);
     $calendar_helper->setCompareOption(Tools::getValue('compare_date_option', $this->context->employee->stats_compare_option));
     $params = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to);
     $moduleManagerBuilder = ModuleManagerBuilder::getInstance();
     $moduleManager = $moduleManagerBuilder->build();
     $this->tpl_view_vars = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to, 'hookDashboardZoneOne' => Hook::exec('dashboardZoneOne', $params), 'hookDashboardZoneTwo' => Hook::exec('dashboardZoneTwo', $params), 'action' => '#', 'warning' => $this->getWarningDomainName(), 'new_version_url' => Tools::getCurrentUrlProtocolPrefix() . _PS_API_DOMAIN_ . '/version/check_version.php?v=' . _PS_VERSION_ . '&lang=' . $this->context->language->iso_code . '&autoupgrade=' . (int) ($moduleManager->isInstalled('autoupgrade') && $moduleManager->isEnabled('autoupgrade')) . '&hosted_mode=' . (int) defined('_PS_HOST_MODE_'), 'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'), 'calendar' => $calendar_helper->generate(), 'PS_DASHBOARD_SIMULATION' => Configuration::get('PS_DASHBOARD_SIMULATION'), 'datepickerFrom' => Tools::getValue('datepickerFrom', $this->context->employee->stats_date_from), 'datepickerTo' => Tools::getValue('datepickerTo', $this->context->employee->stats_date_to), 'preselect_date_range' => Tools::getValue('preselectDateRange', $this->context->employee->preselect_date_range));
     return parent::renderView();
 }
 public function renderView()
 {
     if (Tools::isSubmit('profitability_conf')) {
         return parent::renderOptions();
     }
     // $translations = array(
     // 	'Calendar' => $this->l('Calendar', 'AdminStatsTab'),
     // 	'Day' => $this->l('Day', 'AdminStatsTab'),
     // 	'Month' => $this->l('Month', 'AdminStatsTab'),
     // 	'Year' => $this->l('Year', 'AdminStatsTab'),
     // 	'From' => $this->l('From:', 'AdminStatsTab'),
     // 	'To' => $this->l('To:', 'AdminStatsTab'),
     // 	'Save' => $this->l('Save', 'AdminStatsTab')
     // );
     if ($this->context->cookie->__get('stats_date_update') < strtotime(date('Y-m-d'))) {
         switch ($this->context->employee->preselect_date_range) {
             case 'day':
                 $date_from = date('Y-m-d');
                 $date_to = date('Y-m-d');
                 break;
             case 'prev-day':
                 $date_from = date('Y-m-d', strtotime('-1 day'));
                 $date_to = date('Y-m-d', strtotime('-1 day'));
                 break;
             case 'month':
             default:
                 $date_from = date('Y-m-01');
                 $date_to = date('Y-m-d');
                 break;
             case 'prev-month':
                 $date_from = date('Y-m-01', strtotime('-1 month'));
                 $date_to = date('Y-m-t', strtotime('-1 month'));
                 break;
             case 'year':
                 $date_from = date('Y-01-01');
                 $date_to = date('Y-m-d');
                 break;
             case 'prev-year':
                 $date_from = date('Y-m-01', strtotime('-1 year'));
                 $date_to = date('Y-12-t', strtotime('-1 year'));
                 break;
         }
         $this->context->employee->stats_date_from = $date_from;
         $this->context->employee->stats_date_to = $date_to;
         $this->context->employee->update();
         $this->context->cookie->__set('stats_date_update', strtotime(date('Y-m-d')));
         $this->context->cookie->write();
     }
     $calendar_helper = new HelperCalendar();
     $calendar_helper->setDateFrom(Tools::getValue('date_from', $this->context->employee->stats_date_from));
     $calendar_helper->setDateTo(Tools::getValue('date_to', $this->context->employee->stats_date_to));
     $stats_compare_from = $this->context->employee->stats_compare_from;
     $stats_compare_to = $this->context->employee->stats_compare_to;
     if (is_null($stats_compare_from) || $stats_compare_from == '0000-00-00') {
         $stats_compare_from = null;
     }
     if (is_null($stats_compare_to) || $stats_compare_to == '0000-00-00') {
         $stats_compare_to = null;
     }
     $calendar_helper->setCompareDateFrom($stats_compare_from);
     $calendar_helper->setCompareDateTo($stats_compare_to);
     $calendar_helper->setCompareOption(Tools::getValue('compare_date_option', $this->context->employee->stats_compare_option));
     $params = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to);
     $this->tpl_view_vars = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to, 'hookDashboardZoneOne' => Hook::exec('dashboardZoneOne', $params), 'hookDashboardZoneTwo' => Hook::exec('dashboardZoneTwo', $params), 'action' => '#', 'warning' => $this->getWarningDomainName(), 'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'), 'calendar' => $calendar_helper->generate(), 'PS_DASHBOARD_SIMULATION' => Configuration::get('PS_DASHBOARD_SIMULATION'), 'datepickerFrom' => Tools::getValue('datepickerFrom', $this->context->employee->stats_date_from), 'datepickerTo' => Tools::getValue('datepickerTo', $this->context->employee->stats_date_to), 'preselect_date_range' => Tools::getValue('preselectDateRange', $this->context->employee->preselect_date_range));
     return parent::renderView();
 }
 public function renderView()
 {
     if (!($cart = $this->loadObject(true))) {
         return;
     }
     $customer = new Customer($cart->id_customer);
     $currency = new Currency($cart->id_currency);
     $this->context->cart = $cart;
     $this->context->currency = $currency;
     $this->context->customer = $customer;
     $this->toolbar_title = sprintf($this->l('Cart #%06d'), $this->context->cart->id);
     $products = $cart->getProducts();
     $customized_datas = Product::getAllCustomizedDatas((int) $cart->id);
     Product::addCustomizationPrice($products, $customized_datas);
     $summary = $cart->getSummaryDetails();
     /* Display order information */
     $id_order = (int) Order::getOrderByCartId($cart->id);
     $order = new Order($id_order);
     if (Validate::isLoadedObject($order)) {
         $tax_calculation_method = $order->getTaxCalculationMethod();
         $id_shop = (int) $order->id_shop;
     } else {
         $id_shop = (int) $cart->id_shop;
         $tax_calculation_method = Group::getPriceDisplayMethod(Group::getCurrent()->id);
     }
     if ($tax_calculation_method == PS_TAX_EXC) {
         $total_products = $summary['total_products'];
         $total_discounts = $summary['total_discounts_tax_exc'];
         $total_wrapping = $summary['total_wrapping_tax_exc'];
         $total_price = $summary['total_price_without_tax'];
         $total_shipping = $summary['total_shipping_tax_exc'];
     } else {
         $total_products = $summary['total_products_wt'];
         $total_discounts = $summary['total_discounts'];
         $total_wrapping = $summary['total_wrapping'];
         $total_price = $summary['total_price'];
         $total_shipping = $summary['total_shipping'];
     }
     foreach ($products as $k => &$product) {
         if ($tax_calculation_method == PS_TAX_EXC) {
             $product['product_price'] = $product['price'];
             $product['product_total'] = $product['total'];
         } else {
             $product['product_price'] = $product['price_wt'];
             $product['product_total'] = $product['total_wt'];
         }
         $image = array();
         if (isset($product['id_product_attribute']) && (int) $product['id_product_attribute']) {
             $image = Db::getInstance()->getRow('SELECT id_image FROM ' . _DB_PREFIX_ . 'product_attribute_image WHERE id_product_attribute = ' . (int) $product['id_product_attribute']);
         }
         if (!isset($image['id_image'])) {
             $image = Db::getInstance()->getRow('SELECT id_image FROM ' . _DB_PREFIX_ . 'image WHERE id_product = ' . (int) $product['id_product'] . ' AND cover = 1');
         }
         $product_obj = new Product($product['id_product']);
         $product['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct($product['id_product'], isset($product['id_product_attribute']) ? $product['id_product_attribute'] : null, (int) $id_shop);
         $image_product = new Image($image['id_image']);
         $product['image'] = isset($image['id_image']) ? ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $image_product->getExistingImgPath() . '.jpg', 'product_mini_' . (int) $product['id_product'] . (isset($product['id_product_attribute']) ? '_' . (int) $product['id_product_attribute'] : '') . '.jpg', 45, 'jpg') : '--';
     }
     $helper = new HelperKpi();
     $helper->id = 'box-kpi-cart';
     $helper->icon = 'icon-shopping-cart';
     $helper->color = 'color1';
     $helper->title = $this->l('Total Cart', null, null, false);
     $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id);
     $helper->value = Tools::displayPrice($total_price, $currency);
     $kpi = $helper->generate();
     $this->tpl_view_vars = array('kpi' => $kpi, 'products' => $products, 'discounts' => $cart->getCartRules(), 'order' => $order, 'cart' => $cart, 'currency' => $currency, 'customer' => $customer, 'customer_stats' => $customer->getStats(), 'total_products' => $total_products, 'total_discounts' => $total_discounts, 'total_wrapping' => $total_wrapping, 'total_price' => $total_price, 'total_shipping' => $total_shipping, 'customized_datas' => $customized_datas);
     return parent::renderView();
 }
Beispiel #13
0
 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 renderView()
 {
     if (!($id_customer_thread = (int) Tools::getValue('id_customer_thread'))) {
         return;
     }
     $this->context = Context::getContext();
     if (!($thread = $this->loadObject())) {
         return;
     }
     $this->context->cookie->{'customer_threadFilter_cl!id_contact'} = $thread->id_contact;
     $employees = Employee::getEmployees();
     $messages = CustomerThread::getMessageCustomerThreads($id_customer_thread);
     $next_thread = CustomerThread::getNextThread((int) $thread->id);
     $actions = array();
     if ($next_thread) {
         $actions['next_thread'] = array('href' => self::$currentIndex . '&id_customer_thread=' . (int) $next_thread . '&viewcustomer_thread&token=' . $this->token, 'name' => $this->l('Reply to the next unanswered message in this category.'));
     } else {
         $actions['next_thread'] = array('href' => false, 'name' => $this->l('All other messages in this category have been answered.'));
     }
     if ($thread->status != 'closed') {
         $actions['closed'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=2&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'name' => $this->l('Mark this message as handled.'));
     }
     if ($thread->status != 'pending1') {
         $actions['pending1'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=3&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'name' => $this->l('Mark this message as "pending 1" (will be answered later).'));
     } else {
         $actions['pending1'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=1&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'name' => $this->l('Disable pending status.'));
     }
     if ($thread->status != 'pending2') {
         $actions['pending2'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=4&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'name' => $this->l('Mark this message as "pending 2" (will be answered later).'));
     } else {
         $actions['pending2'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=1&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'name' => $this->l('Disable pending status.'));
     }
     if ($thread->id_customer) {
         $customer = new Customer($thread->id_customer);
         $orders = Order::getCustomerOrders($customer->id);
         if ($orders && count($orders)) {
             $total_ok = 0;
             $orders_ok = array();
             foreach ($orders as $key => $order) {
                 if ($order['valid']) {
                     $orders_ok[] = $order;
                     $total_ok += $order['total_paid_real'];
                 }
                 $orders[$key]['date_add'] = Tools::displayDate($order['date_add']);
                 $orders[$key]['total_paid_real'] = Tools::displayPrice($order['total_paid_real'], new Currency((int) $order['id_currency']));
             }
         }
         $products = $customer->getBoughtProducts();
         if ($products && count($products)) {
             foreach ($products as $key => $product) {
                 $products[$key]['date_add'] = Tools::displayDate($product['date_add'], null, true);
             }
         }
     }
     foreach ($messages as $key => $message) {
         $messages[$key] = $this->displayMessage($message);
     }
     $this->tpl_view_vars = array('id_customer_thread' => $id_customer_thread, 'thread' => $thread, 'actions' => $actions, 'employees' => $employees, 'messages' => $messages, 'next_thread' => $next_thread, 'orders' => isset($orders) ? $orders : false, 'customer' => isset($customer) ? $customer : false, 'products' => isset($products) ? $products : false, 'total_ok' => isset($total_ok) ? Tools::displayPrice($total_ok, $this->context->currency) : false, 'orders_ok' => isset($orders_ok) ? $orders_ok : false, 'count_ok' => isset($orders_ok) ? count($orders_ok) : false);
     return parent::renderView();
 }
 public function renderView()
 {
     $this->tpl_view_vars['query'] = Tools::safeOutput($this->query);
     $this->tpl_view_vars['show_toolbar'] = true;
     if (count($this->errors)) {
         return parent::renderView();
     } else {
         $nb_results = 0;
         foreach ($this->_list as $list) {
             if ($list != false) {
                 $nb_results += count($list);
             }
         }
         $this->tpl_view_vars['nb_results'] = $nb_results;
         if (isset($this->_list['features']) && count($this->_list['features'])) {
             $this->tpl_view_vars['features'] = $this->_list['features'];
         }
         if (isset($this->_list['categories']) && count($this->_list['categories'])) {
             $categories = array();
             foreach ($this->_list['categories'] as $category) {
                 $categories[] = getPath($this->context->link->getAdminLink('AdminCategories', false), $category['id_category']);
             }
             $this->tpl_view_vars['categories'] = $categories;
         }
         if (isset($this->_list['products']) && count($this->_list['products'])) {
             $view = '';
             $this->initProductList();
             $helper = new HelperList();
             $helper->shopLinkType = '';
             $helper->simple_header = true;
             $helper->identifier = 'id_product';
             $helper->actions = array('edit');
             $helper->show_toolbar = false;
             $helper->table = 'product';
             $helper->currentIndex = $this->context->link->getAdminLink('AdminProducts', false);
             $helper->token = Tools::getAdminTokenLite('AdminProducts');
             if ($this->_list['products']) {
                 $view = $helper->generateList($this->_list['products'], $this->fields_list['products']);
             }
             $this->tpl_view_vars['products'] = $view;
         }
         if (isset($this->_list['customers']) && count($this->_list['customers'])) {
             $view = '';
             $this->initCustomerList();
             $helper = new HelperList();
             $helper->shopLinkType = '';
             $helper->simple_header = true;
             $helper->identifier = 'id_customer';
             $helper->actions = array('edit', 'view');
             $helper->show_toolbar = false;
             $helper->table = 'customer';
             $helper->currentIndex = $this->context->link->getAdminLink('AdminCustomers', false);
             $helper->token = Tools::getAdminTokenLite('AdminCustomers');
             if ($this->_list['customers']) {
                 foreach ($this->_list['customers'] as $key => $val) {
                     $this->_list['customers'][$key]['orders'] = Order::getCustomerNbOrders((int) $val['id_customer']);
                 }
                 $view = $helper->generateList($this->_list['customers'], $this->fields_list['customers']);
             }
             $this->tpl_view_vars['customers'] = $view;
         }
         if (isset($this->_list['orders']) && count($this->_list['orders'])) {
             $view = '';
             $this->initOrderList();
             $helper = new HelperList();
             $helper->shopLinkType = '';
             $helper->simple_header = true;
             $helper->identifier = 'id_order';
             $helper->actions = array('view');
             $helper->show_toolbar = false;
             $helper->table = 'order';
             $helper->currentIndex = $this->context->link->getAdminLink('AdminOrders', false);
             $helper->token = Tools::getAdminTokenLite('AdminOrders');
             if ($this->_list['orders']) {
                 $view = $helper->generateList($this->_list['orders'], $this->fields_list['orders']);
             }
             $this->tpl_view_vars['orders'] = $view;
         }
         if (isset($this->_list['modules']) && count($this->_list['modules'])) {
             $this->tpl_view_vars['modules'] = $this->_list['modules'];
         }
         if (isset($this->_list['addons']) && count($this->_list['addons'])) {
             $this->tpl_view_vars['addons'] = $this->_list['addons'];
         }
         return parent::renderView();
     }
 }
 public function renderView()
 {
     if (Tools::isSubmit('profitability_conf')) {
         return parent::renderOptions();
     }
     // $translations = array(
     // 	'Calendar' => $this->l('Calendar', 'AdminStatsTab'),
     // 	'Day' => $this->l('Day', 'AdminStatsTab'),
     // 	'Month' => $this->l('Month', 'AdminStatsTab'),
     // 	'Year' => $this->l('Year', 'AdminStatsTab'),
     // 	'From' => $this->l('From:', 'AdminStatsTab'),
     // 	'To' => $this->l('To:', 'AdminStatsTab'),
     // 	'Save' => $this->l('Save', 'AdminStatsTab')
     // );
     $calendar_helper = new HelperCalendar();
     $calendar_helper->setDateFrom(Tools::getValue('date_from', $this->context->employee->stats_date_from));
     $calendar_helper->setDateTo(Tools::getValue('date_to', $this->context->employee->stats_date_to));
     $stats_compare_from = $this->context->employee->stats_compare_from;
     $stats_compare_to = $this->context->employee->stats_compare_to;
     if (is_null($stats_compare_from) || $stats_compare_from == '0000-00-00') {
         $stats_compare_from = null;
     }
     if (is_null($stats_compare_to) || $stats_compare_to == '0000-00-00') {
         $stats_compare_to = null;
     }
     $calendar_helper->setCompareDateFrom($stats_compare_from);
     $calendar_helper->setCompareDateTo($stats_compare_to);
     $calendar_helper->setCompareOption(Tools::getValue('compare_date_option', $this->context->employee->stats_compare_option));
     $params = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to);
     $this->tpl_view_vars = array('date_from' => $this->context->employee->stats_date_from, 'date_to' => $this->context->employee->stats_date_to, 'hookDashboardZoneOne' => Hook::exec('dashboardZoneOne', $params), 'hookDashboardZoneTwo' => Hook::exec('dashboardZoneTwo', $params), 'action' => '#', 'warning' => $this->getWarningDomainName(), 'new_version_url' => Tools::getCurrentUrlProtocolPrefix() . 'api.prestashop.com/version/check_version.php?v=' . _PS_VERSION_ . '&lang=' . $this->context->language->iso_code . '&autoupgrade=' . (int) (Module::isInstalled('autoupgrade') && Module::isEnabled('autoupgrade')) . '&hosted_mode=' . (int) defined('_PS_HOST_MODE_'), 'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'), 'calendar' => $calendar_helper->generate(), 'PS_DASHBOARD_SIMULATION' => Configuration::get('PS_DASHBOARD_SIMULATION'), 'datepickerFrom' => Tools::getValue('datepickerFrom', $this->context->employee->stats_date_from), 'datepickerTo' => Tools::getValue('datepickerTo', $this->context->employee->stats_date_to), 'preselect_date_range' => Tools::getValue('preselectDateRange', $this->context->employee->preselect_date_range));
     return parent::renderView();
 }
 /**
  * @see AdminController::renderView()
  */
 public function renderView()
 {
     $this->show_toolbar = true;
     $this->toolbar_scroll = false;
     $this->table = 'supply_order_detail';
     $this->identifier = 'id_supply_order_detail';
     $this->className = 'SupplyOrderDetail';
     $this->colorOnBackground = false;
     $this->lang = false;
     $this->list_simple_header = true;
     $this->list_no_link = true;
     // gets the id supplier to view
     $id_supply_order = (int) Tools::getValue('id_supply_order');
     // gets global order information
     $supply_order = new SupplyOrder((int) $id_supply_order);
     if (Validate::isLoadedObject($supply_order)) {
         if (!$supply_order->is_template) {
             $this->displayInformation($this->l('This interface allows you to display detailed information about your order.') . '<br />');
         } else {
             $this->displayInformation($this->l('This interface allows you to display detailed information about your order template.') . '<br />');
         }
         $lang_id = (int) $supply_order->id_lang;
         // just in case..
         unset($this->_select, $this->_join, $this->_where, $this->_orderBy, $this->_orderWay, $this->_group, $this->_filterHaving, $this->_filter);
         // gets all information on the products ordered
         $this->_where = 'AND a.`id_supply_order` = ' . (int) $id_supply_order;
         // gets the list ordered by price desc, without limit
         $this->getList($lang_id, 'price_te', 'DESC', 0, false, false);
         // gets the currency used in this order
         $currency = new Currency($supply_order->id_currency);
         // gets the warehouse where products will be received
         $warehouse = new Warehouse($supply_order->id_warehouse);
         // sets toolbar title with order reference
         if (!$supply_order->is_template) {
             $this->toolbar_title = sprintf($this->l('Details on supply order #%s'), $supply_order->reference);
         } else {
             $this->toolbar_title = sprintf($this->l('Details on supply order template #%s'), $supply_order->reference);
         }
         // re-defines fields_list
         $this->fields_list = array('supplier_reference' => array('title' => $this->l('Supplier Reference'), 'align' => 'center', 'orderby' => false, 'filter' => false, 'search' => false), 'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'orderby' => false, 'filter' => false, 'search' => false), 'ean13' => array('title' => $this->l('EAN-13 or JAN barcode'), 'align' => 'center', 'orderby' => false, 'filter' => false, 'search' => false), 'upc' => array('title' => $this->l('UPC barcode'), 'align' => 'center', 'orderby' => false, 'filter' => false, 'search' => false), 'name' => array('title' => $this->l('Name'), 'orderby' => false, 'filter' => false, 'search' => false), 'unit_price_te' => array('title' => $this->l('Unit price (tax excl.)'), 'align' => 'right', 'orderby' => false, 'filter' => false, 'search' => false, 'type' => 'price', 'currency' => true), 'quantity_expected' => array('title' => $this->l('Quantity'), 'align' => 'right', 'orderby' => false, 'filter' => false, 'search' => false), 'price_te' => array('title' => $this->l('Price (tax excl.)'), 'align' => 'right', 'orderby' => false, 'filter' => false, 'search' => false, 'type' => 'price', 'currency' => true), 'discount_rate' => array('title' => $this->l('Discount percentage'), 'align' => 'right', 'orderby' => false, 'filter' => false, 'search' => false, 'suffix' => '%'), 'discount_value_te' => array('title' => $this->l('Discount value (tax excl.)'), 'align' => 'right', 'orderby' => false, 'filter' => false, 'search' => false, 'type' => 'price', 'currency' => true), 'price_with_discount_te' => array('title' => $this->l('Price with product discount (tax excl.)'), 'align' => 'right', 'orderby' => false, 'filter' => false, 'search' => false, 'type' => 'price', 'currency' => true), 'tax_rate' => array('title' => $this->l('Tax rate'), 'align' => 'right', 'orderby' => false, 'filter' => false, 'search' => false, 'suffix' => '%'), 'tax_value' => array('title' => $this->l('Tax value'), 'align' => 'right', 'orderby' => false, 'filter' => false, 'search' => false, 'type' => 'price', 'currency' => true), 'price_ti' => array('title' => $this->l('Price (tax incl.)'), 'align' => 'right', 'orderby' => false, 'filter' => false, 'search' => false, 'type' => 'price', 'currency' => true));
         //some staff before render list
         foreach ($this->_list as &$item) {
             $item['discount_rate'] = Tools::ps_round($item['discount_rate'], 4);
             $item['tax_rate'] = Tools::ps_round($item['tax_rate'], 4);
             $item['id_currency'] = $currency->id;
         }
         // unsets some buttons
         unset($this->toolbar_btn['export-csv-orders']);
         unset($this->toolbar_btn['export-csv-details']);
         unset($this->toolbar_btn['new']);
         // renders list
         $helper = new HelperList();
         $this->setHelperDisplay($helper);
         $helper->actions = array();
         $helper->show_toolbar = false;
         $helper->toolbar_btn = $this->toolbar_btn;
         $content = $helper->generateList($this->_list, $this->fields_list);
         // display these global order informations
         $this->tpl_view_vars = array('supply_order_detail_content' => $content, 'supply_order_warehouse' => Validate::isLoadedObject($warehouse) ? $warehouse->name : '', 'supply_order_reference' => $supply_order->reference, 'supply_order_supplier_name' => $supply_order->supplier_name, 'supply_order_creation_date' => Tools::displayDate($supply_order->date_add, null, false), 'supply_order_last_update' => Tools::displayDate($supply_order->date_upd, null, false), 'supply_order_expected' => Tools::displayDate($supply_order->date_delivery_expected, null, false), 'supply_order_discount_rate' => Tools::ps_round($supply_order->discount_rate, 2), 'supply_order_total_te' => Tools::displayPrice($supply_order->total_te, $currency), 'supply_order_discount_value_te' => Tools::displayPrice($supply_order->discount_value_te, $currency), 'supply_order_total_with_discount_te' => Tools::displayPrice($supply_order->total_with_discount_te, $currency), 'supply_order_total_tax' => Tools::displayPrice($supply_order->total_tax, $currency), 'supply_order_total_ti' => Tools::displayPrice($supply_order->total_ti, $currency), 'supply_order_currency' => $currency, 'is_template' => $supply_order->is_template);
     }
     return parent::renderView();
 }
 /**
  * This method generate the form for PDF translations
  */
 public function initFormPDF()
 {
     $name_var = $this->translations_informations[$this->type_selected]['var'];
     $GLOBALS[$name_var] = array();
     $missing_translations_pdf = array();
     $i18n_dir = $this->translations_informations[$this->type_selected]['dir'];
     $default_i18n_file = $i18n_dir . $this->translations_informations[$this->type_selected]['file'];
     if ($this->theme_selected == self::DEFAULT_THEME_NAME && _PS_MODE_DEV_) {
         $i18n_file = $default_i18n_file;
     } else {
         $i18n_dir = $this->translations_informations[$this->type_selected]['override']['dir'];
         $i18n_file = $i18n_dir . $this->translations_informations[$this->type_selected]['override']['file'];
     }
     $this->checkDirAndCreate($i18n_file);
     if (!file_exists($i18n_file) && !is_writable($i18n_dir) && !is_writable($i18n_file)) {
         $this->errors[] = sprintf(Tools::displayError('Cannot write into the "%s"'), $i18n_file);
     }
     @(include $i18n_file);
     // if the override's translation file is empty load the default file
     if (!isset($GLOBALS[$name_var]) || count($GLOBALS[$name_var]) == 0) {
         @(include $default_i18n_file);
     }
     $prefix_key = 'PDF';
     $tabs_array = array($prefix_key => array());
     $files_by_directory = $this->getFileToParseByTypeTranslation();
     foreach ($files_by_directory as $type => $directories) {
         foreach ($directories as $dir => $files) {
             foreach ($files as $file) {
                 if (!in_array($file, self::$ignore_folder) && Tools::file_exists_cache($file_path = $dir . $file)) {
                     if ($type == 'tpl') {
                         if (Tools::file_exists_cache($file_path) && is_file($file_path)) {
                             // Get content for this file
                             $content = file_get_contents($file_path);
                             // Parse this content
                             $matches = $this->userParseFile($content, $this->type_selected, 'tpl');
                             foreach ($matches as $key) {
                                 if (isset($GLOBALS[$name_var][$prefix_key . md5($key)])) {
                                     $tabs_array[$prefix_key][$key]['trad'] = html_entity_decode($GLOBALS[$name_var][$prefix_key . md5($key)], ENT_COMPAT, 'UTF-8');
                                 } else {
                                     if (!isset($tabs_array[$prefix_key][$key]['trad'])) {
                                         $tabs_array[$prefix_key][$key]['trad'] = '';
                                         if (!isset($missing_translations_pdf[$prefix_key])) {
                                             $missing_translations_pdf[$prefix_key] = 1;
                                         } else {
                                             $missing_translations_pdf[$prefix_key]++;
                                         }
                                     }
                                 }
                                 $tabs_array[$prefix_key][$key]['use_sprintf'] = $this->checkIfKeyUseSprintf($key);
                             }
                         }
                     } else {
                         if (Tools::file_exists_cache($file_path)) {
                             $tabs_array = $this->parsePdfClass($file_path, 'php', $GLOBALS[$name_var], $prefix_key, $tabs_array, $missing_translations_pdf);
                         }
                     }
                 }
             }
         }
     }
     $this->tpl_view_vars = array_merge($this->tpl_view_vars, array('count' => count($tabs_array['PDF']), 'limit_warning' => $this->displayLimitPostWarning(count($tabs_array['PDF'])), 'tabsArray' => $tabs_array, 'missing_translations' => $missing_translations_pdf));
     $this->initToolbar();
     $this->base_tpl_view = 'translation_form.tpl';
     return parent::renderView();
 }
 public function renderView()
 {
     $this->tpl_view_vars = array('modules_list' => $this->renderModulesList('back-office,AdminMarketing,index'));
     return parent::renderView();
 }
 public function renderView()
 {
     $referrer = new Referrer((int) Tools::getValue('id_referrer'));
     $display_tab = array('uniqs' => $this->l('Unique visitors'), 'visitors' => $this->l('Visitors'), 'visits' => $this->l('Visits'), 'pages' => $this->l('Pages viewed'), 'registrations' => $this->l('Registrations'), 'orders' => $this->l('Orders'), 'sales' => $this->l('Sales'), 'reg_rate' => $this->l('Registration rate'), 'order_rate' => $this->l('Order rate'), 'click_fee' => $this->l('Click fee'), 'base_fee' => $this->l('Base fee'), 'percent_fee' => $this->l('Percent fee'));
     $this->tpl_view_vars = array('enable_calendar' => $this->enableCalendar(), 'calendar_form' => $this->displayCalendar($this->action, $this->table, $this->identifier, (int) Tools::getValue($this->identifier)), 'referrer' => new Referrer((int) Tools::getValue('id_referrer')), 'display_tab' => $display_tab, 'id_employee' => (int) $this->context->employee->id, 'id_lang' => (int) $this->context->language->id);
     return parent::renderView();
 }
 /**
  * @see AdminController::renderView()
  */
 public function renderView()
 {
     // gets necessary objects
     $id_warehouse = (int) Tools::getValue('id_warehouse');
     $warehouse = new Warehouse($id_warehouse);
     $employee = new Employee($warehouse->id_employee);
     $currency = new Currency($warehouse->id_currency);
     $address = new Address($warehouse->id_address);
     $shops = $warehouse->getShops();
     $this->toolbar_title = $warehouse->name;
     // checks objects
     if (!Validate::isLoadedObject($warehouse) || !Validate::isLoadedObject($employee) || !Validate::isLoadedObject($currency) || !Validate::isLoadedObject($address)) {
         return parent::renderView();
     }
     // assigns to our view
     $this->tpl_view_vars = array('warehouse' => $warehouse, 'employee' => $employee, 'currency' => $currency, 'address' => $address, 'shops' => $shops, 'warehouse_num_products' => $warehouse->getNumberOfProducts(), 'warehouse_value' => Tools::displayPrice(Tools::ps_round($warehouse->getStockValue(), 2), $currency), 'warehouse_quantities' => $warehouse->getQuantitiesofProducts());
     return parent::renderView();
 }
 public function renderView()
 {
     $this->getCurrentValue('warehouseA');
     $this->getCurrentValue('warehouseB');
     //$this->getCurrentValue('name_or_ean', '');
     $this->context->smarty->assign(array('link_pdf' => $this->context->link->getAdminLink('AdminStockTransfer') . '&submitAction=generateTransferPDF'));
     // if we have transfert values already recorded, we send them (pagination & filter)
     if (Tools::isSubmit('transfers') && Tools::getValue('transfers') != '') {
         $this->context->smarty->assign(array('transfers' => Tools::getValue('transfers')));
     }
     $this->_helper_list = new HelperList();
     $this->clearListOptions();
     $this->content = $this->getCustomList();
     return AdminController::renderView();
 }
 public function renderView()
 {
     /** @var RequestSql $obj */
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $view = array();
     if ($results = Db::getInstance()->executeS($obj->sql)) {
         foreach (array_keys($results[0]) as $key) {
             $tab_key[] = $key;
         }
         $view['name'] = $obj->name;
         $view['key'] = $tab_key;
         $view['results'] = $results;
         $this->toolbar_title = $obj->name;
         $request_sql = new RequestSql();
         $view['attributes'] = $request_sql->attributes;
     } else {
         $view['error'] = true;
     }
     $this->tpl_view_vars = array('view' => $view);
     return parent::renderView();
 }
    public function renderView()
    {
        /** @var Customer $customer */
        if (!($customer = $this->loadObject())) {
            return;
        }
        $this->context->customer = $customer;
        $gender = new Gender($customer->id_gender, $this->context->language->id);
        $gender_image = $gender->getImage();
        $customer_stats = $customer->getStats();
        $sql = 'SELECT SUM(total_paid_real) FROM ' . _DB_PREFIX_ . 'orders WHERE id_customer = %d AND valid = 1';
        if ($total_customer = Db::getInstance()->getValue(sprintf($sql, $customer->id))) {
            $sql = 'SELECT SQL_CALC_FOUND_ROWS COUNT(*) FROM ' . _DB_PREFIX_ . 'orders WHERE valid = 1 AND id_customer != ' . (int) $customer->id . ' GROUP BY id_customer HAVING SUM(total_paid_real) > %d';
            Db::getInstance()->getValue(sprintf($sql, (int) $total_customer));
            $count_better_customers = (int) Db::getInstance()->getValue('SELECT FOUND_ROWS()') + 1;
        } else {
            $count_better_customers = '-';
        }
        $orders = Order::getCustomerOrders($customer->id, true);
        $total_orders = count($orders);
        for ($i = 0; $i < $total_orders; $i++) {
            $orders[$i]['total_paid_real_not_formated'] = $orders[$i]['total_paid_real'];
            $orders[$i]['total_paid_real'] = Tools::displayPrice($orders[$i]['total_paid_real'], new Currency((int) $orders[$i]['id_currency']));
        }
        $messages = CustomerThread::getCustomerMessages((int) $customer->id);
        $total_messages = count($messages);
        for ($i = 0; $i < $total_messages; $i++) {
            $messages[$i]['message'] = substr(strip_tags(html_entity_decode($messages[$i]['message'], ENT_NOQUOTES, 'UTF-8')), 0, 75);
            $messages[$i]['date_add'] = Tools::displayDate($messages[$i]['date_add'], null, true);
            if (isset(self::$meaning_status[$messages[$i]['status']])) {
                $messages[$i]['status'] = self::$meaning_status[$messages[$i]['status']];
            }
        }
        $groups = $customer->getGroups();
        $total_groups = count($groups);
        for ($i = 0; $i < $total_groups; $i++) {
            $group = new Group($groups[$i]);
            $groups[$i] = array();
            $groups[$i]['id_group'] = $group->id;
            $groups[$i]['name'] = $group->name[$this->default_form_language];
        }
        $total_ok = 0;
        $orders_ok = array();
        $orders_ko = array();
        foreach ($orders as $order) {
            if (!isset($order['order_state'])) {
                $order['order_state'] = $this->l('There is no status defined for this order.');
            }
            if ($order['valid']) {
                $orders_ok[] = $order;
                $total_ok += $order['total_paid_real_not_formated'];
            } else {
                $orders_ko[] = $order;
            }
        }
        $products = $customer->getBoughtProducts();
        $carts = Cart::getCustomerCarts($customer->id);
        $total_carts = count($carts);
        for ($i = 0; $i < $total_carts; $i++) {
            $cart = new Cart((int) $carts[$i]['id_cart']);
            $this->context->cart = $cart;
            $summary = $cart->getSummaryDetails();
            $currency = new Currency((int) $carts[$i]['id_currency']);
            $carrier = new Carrier((int) $carts[$i]['id_carrier']);
            $carts[$i]['id_cart'] = sprintf('%06d', $carts[$i]['id_cart']);
            $carts[$i]['date_add'] = Tools::displayDate($carts[$i]['date_add'], null, true);
            $carts[$i]['total_price'] = Tools::displayPrice($summary['total_price'], $currency);
            $carts[$i]['name'] = $carrier->name;
        }
        $sql = 'SELECT DISTINCT cp.id_product, c.id_cart, c.id_shop, cp.id_shop AS cp_id_shop
				FROM ' . _DB_PREFIX_ . 'cart_product cp
				JOIN ' . _DB_PREFIX_ . 'cart c ON (c.id_cart = cp.id_cart)
				JOIN ' . _DB_PREFIX_ . 'product p ON (cp.id_product = p.id_product)
				WHERE c.id_customer = ' . (int) $customer->id . '
					AND NOT EXISTS (
							SELECT 1
							FROM ' . _DB_PREFIX_ . 'orders o
							JOIN ' . _DB_PREFIX_ . 'order_detail od ON (o.id_order = od.id_order)
							WHERE product_id = cp.id_product AND o.valid = 1 AND o.id_customer = ' . (int) $customer->id . '
						)';
        $interested = Db::getInstance()->executeS($sql);
        $total_interested = count($interested);
        for ($i = 0; $i < $total_interested; $i++) {
            $product = new Product($interested[$i]['id_product'], false, $this->default_form_language, $interested[$i]['id_shop']);
            if (!Validate::isLoadedObject($product)) {
                continue;
            }
            $interested[$i]['url'] = $this->context->link->getProductLink($product->id, $product->link_rewrite, Category::getLinkRewrite($product->id_category_default, $this->default_form_language), null, null, $interested[$i]['cp_id_shop']);
            $interested[$i]['id'] = (int) $product->id;
            $interested[$i]['name'] = Tools::htmlentitiesUTF8($product->name);
        }
        $emails = $customer->getLastEmails();
        $connections = $customer->getLastConnections();
        if (!is_array($connections)) {
            $connections = array();
        }
        $total_connections = count($connections);
        for ($i = 0; $i < $total_connections; $i++) {
            $connections[$i]['http_referer'] = $connections[$i]['http_referer'] ? preg_replace('/^www./', '', parse_url($connections[$i]['http_referer'], PHP_URL_HOST)) : $this->l('Direct link');
        }
        $referrers = Referrer::getReferrers($customer->id);
        $total_referrers = count($referrers);
        for ($i = 0; $i < $total_referrers; $i++) {
            $referrers[$i]['date_add'] = Tools::displayDate($referrers[$i]['date_add'], null, true);
        }
        $customerLanguage = new Language($customer->id_lang);
        $shop = new Shop($customer->id_shop);
        $this->tpl_view_vars = array('customer' => $customer, 'gender' => $gender, 'gender_image' => $gender_image, 'registration_date' => Tools::displayDate($customer->date_add, null, true), 'customer_stats' => $customer_stats, 'last_visit' => Tools::displayDate($customer_stats['last_visit'], null, true), 'count_better_customers' => $count_better_customers, 'shop_is_feature_active' => Shop::isFeatureActive(), 'name_shop' => $shop->name, 'customer_birthday' => Tools::displayDate($customer->birthday), 'last_update' => Tools::displayDate($customer->date_upd, null, true), 'customer_exists' => Customer::customerExists($customer->email), 'id_lang' => $customer->id_lang, 'customerLanguage' => $customerLanguage, 'customer_note' => Tools::htmlentitiesUTF8($customer->note), 'messages' => $messages, 'groups' => $groups, 'orders' => $orders, 'orders_ok' => $orders_ok, 'orders_ko' => $orders_ko, 'total_ok' => Tools::displayPrice($total_ok, $this->context->currency->id), 'products' => $products, 'addresses' => $customer->getAddresses($this->default_form_language), 'discounts' => CartRule::getCustomerCartRules($this->default_form_language, $customer->id, false, false), 'carts' => $carts, 'interested' => $interested, 'emails' => $emails, 'connections' => $connections, 'referrers' => $referrers, 'show_toolbar' => true);
        return parent::renderView();
    }
 public function renderView()
 {
     $this->tpl_view_vars = array('doc' => $this->doc, 'theme_name' => $this->theme_name, 'img_error' => $this->img_error, 'modules_errors' => $this->modules_errors, 'back_link' => Context::getContext()->link->getAdminLink('AdminThemes'), 'image_link' => Context::getContext()->link->getAdminLink('AdminImages'));
     return parent::renderView();
 }
 public function renderView()
 {
     $this->addJS(_PS_JS_DIR_ . 'admin/import.js');
     $handle = $this->openCsvFile();
     $nb_column = $this->getNbrColumn($handle, $this->separator);
     $nb_table = ceil($nb_column / MAX_COLUMNS);
     $res = array();
     foreach ($this->required_fields as $elem) {
         $res[] = '\'' . $elem . '\'';
     }
     $data = array();
     for ($i = 0; $i < $nb_table; $i++) {
         $data[$i] = $this->generateContentTable($i, $nb_column, $handle, $this->separator);
     }
     $this->context->cookie->entity_selected = (int) Tools::getValue('entity');
     $this->context->cookie->iso_lang_selected = urlencode(Tools::getValue('iso_lang'));
     $this->context->cookie->separator_selected = urlencode($this->separator);
     $this->context->cookie->multiple_value_separator_selected = urlencode($this->multiple_value_separator);
     $this->context->cookie->csv_selected = urlencode(Tools::getValue('csv'));
     $this->tpl_view_vars = array('import_matchs' => Db::getInstance()->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'import_match', true, false), 'fields_value' => array('csv' => Tools::getValue('csv'), 'entity' => (int) Tools::getValue('entity'), 'iso_lang' => Tools::getValue('iso_lang'), 'truncate' => Tools::getValue('truncate'), 'forceIDs' => Tools::getValue('forceIDs'), 'regenerate' => Tools::getValue('regenerate'), 'sendemail' => Tools::getValue('sendemail'), 'match_ref' => Tools::getValue('match_ref'), 'separator' => $this->separator, 'multiple_value_separator' => $this->multiple_value_separator), 'nb_table' => $nb_table, 'nb_column' => $nb_column, 'res' => implode(',', $res), 'max_columns' => MAX_COLUMNS, 'no_pre_select' => array('price_tin', 'feature'), 'available_fields' => $this->available_fields, 'data' => $data);
     return parent::renderView();
 }
 public function renderView()
 {
     if (!($id_customer_thread = (int) Tools::getValue('id_customer_thread'))) {
         return;
     }
     $this->context = Context::getContext();
     if (!($thread = $this->loadObject())) {
         return;
     }
     $this->context->cookie->{'customer_threadFilter_cl!id_contact'} = $thread->id_contact;
     $employees = Employee::getEmployees();
     $messages = CustomerThread::getMessageCustomerThreads($id_customer_thread);
     foreach ($messages as $key => $mess) {
         if ($mess['id_employee']) {
             $employee = new Employee($mess['id_employee']);
             $messages[$key]['employee_image'] = $employee->getImage();
         }
         if (isset($mess['file_name']) && $mess['file_name'] != '') {
             $messages[$key]['file_name'] = _THEME_PROD_PIC_DIR_ . $mess['file_name'];
         } else {
             unset($messages[$key]['file_name']);
         }
         if ($mess['id_product']) {
             $product = new Product((int) $mess['id_product'], false, $this->context->language->id);
             if (Validate::isLoadedObject($product)) {
                 $messages[$key]['product_name'] = $product->name;
                 $messages[$key]['product_link'] = $this->context->link->getAdminLink('AdminProducts') . '&updateproduct&id_product=' . (int) $product->id;
             }
         }
     }
     $next_thread = CustomerThread::getNextThread((int) $thread->id);
     $contacts = Contact::getContacts($this->context->language->id);
     $actions = array();
     if ($next_thread) {
         $next_thread = array('href' => self::$currentIndex . '&id_customer_thread=' . (int) $next_thread . '&viewcustomer_thread&token=' . $this->token, 'name' => $this->l('Reply to the next unanswered message in this thread'));
     }
     if ($thread->status != 'closed') {
         $actions['closed'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=2&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Mark as "handled"'), 'name' => 'setstatus', 'value' => 2);
     } else {
         $actions['open'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=1&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Re-open'), 'name' => 'setstatus', 'value' => 1);
     }
     if ($thread->status != 'pending1') {
         $actions['pending1'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=3&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Mark as "pending 1" (will be answered later)'), 'name' => 'setstatus', 'value' => 3);
     } else {
         $actions['pending1'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=1&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Disable pending status'), 'name' => 'setstatus', 'value' => 1);
     }
     if ($thread->status != 'pending2') {
         $actions['pending2'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=4&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Mark as "pending 2" (will be answered later)'), 'name' => 'setstatus', 'value' => 4);
     } else {
         $actions['pending2'] = array('href' => self::$currentIndex . '&viewcustomer_thread&setstatus=1&id_customer_thread=' . (int) Tools::getValue('id_customer_thread') . '&viewmsg&token=' . $this->token, 'label' => $this->l('Disable pending status'), 'name' => 'setstatus', 'value' => 1);
     }
     if ($thread->id_customer) {
         $customer = new Customer($thread->id_customer);
         $orders = Order::getCustomerOrders($customer->id);
         if ($orders && count($orders)) {
             $total_ok = 0;
             $orders_ok = array();
             foreach ($orders as $key => $order) {
                 if ($order['valid']) {
                     $orders_ok[] = $order;
                     $total_ok += $order['total_paid_real'];
                 }
                 $orders[$key]['date_add'] = Tools::displayDate($order['date_add']);
                 $orders[$key]['total_paid_real'] = Tools::displayPrice($order['total_paid_real'], new Currency((int) $order['id_currency']));
             }
         }
         $products = $customer->getBoughtProducts();
         if ($products && count($products)) {
             foreach ($products as $key => $product) {
                 $products[$key]['date_add'] = Tools::displayDate($product['date_add'], null, true);
             }
         }
     }
     $timeline_items = $this->getTimeline($messages, $thread->id_order);
     $first_message = $messages[0];
     if (!$messages[0]['id_employee']) {
         unset($messages[0]);
     }
     $contact = '';
     foreach ($contacts as $c) {
         if ($c['id_contact'] == $thread->id_contact) {
             $contact = $c['name'];
         }
     }
     $this->tpl_view_vars = array('id_customer_thread' => $id_customer_thread, 'thread' => $thread, 'actions' => $actions, 'employees' => $employees, 'current_employee' => $this->context->employee, 'messages' => $messages, 'first_message' => $first_message, 'contact' => $contact, 'next_thread' => $next_thread, 'orders' => isset($orders) ? $orders : false, 'customer' => isset($customer) ? $customer : false, 'products' => isset($products) ? $products : false, 'total_ok' => isset($total_ok) ? Tools::displayPrice($total_ok, $this->context->currency) : false, 'orders_ok' => isset($orders_ok) ? $orders_ok : false, 'count_ok' => isset($orders_ok) ? count($orders_ok) : false, 'PS_CUSTOMER_SERVICE_SIGNATURE' => str_replace('\\r\\n', "\n", Configuration::get('PS_CUSTOMER_SERVICE_SIGNATURE', (int) $thread->id_lang)), 'timeline_items' => $timeline_items);
     if ($next_thread) {
         $this->tpl_view_vars['next_thread'] = $next_thread;
     }
     return parent::renderView();
 }
 public function renderView()
 {
     $this->initTabModuleList();
     $this->toolbar_title = $this->object->name;
     $products = $this->object->getProductsLite($this->context->language->id);
     $total_product = count($products);
     for ($i = 0; $i < $total_product; $i++) {
         $products[$i] = new Product($products[$i]['id_product'], false, $this->context->language->id);
         $products[$i]->loadStockData();
         // Build attributes combinations
         $combinations = $products[$i]->getAttributeCombinations($this->context->language->id);
         foreach ($combinations as $k => $combination) {
             $comb_infos = Supplier::getProductInformationsBySupplier($this->object->id, $products[$i]->id, $combination['id_product_attribute']);
             $comb_array[$combination['id_product_attribute']]['product_supplier_reference'] = $comb_infos['product_supplier_reference'];
             $comb_array[$combination['id_product_attribute']]['product_supplier_price_te'] = Tools::displayPrice($comb_infos['product_supplier_price_te'], new Currency($comb_infos['id_currency']));
             $comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference'];
             $comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13'];
             $comb_array[$combination['id_product_attribute']]['upc'] = $combination['upc'];
             $comb_array[$combination['id_product_attribute']]['quantity'] = $combination['quantity'];
             $comb_array[$combination['id_product_attribute']]['attributes'][] = array($combination['group_name'], $combination['attribute_name'], $combination['id_attribute']);
         }
         if (isset($comb_array)) {
             foreach ($comb_array as $key => $product_attribute) {
                 $list = '';
                 foreach ($product_attribute['attributes'] as $attribute) {
                     $list .= $attribute[0] . ' - ' . $attribute[1] . ', ';
                 }
                 $comb_array[$key]['attributes'] = rtrim($list, ', ');
             }
             isset($comb_array) ? $products[$i]->combination = $comb_array : '';
             unset($comb_array);
         } else {
             $product_infos = Supplier::getProductInformationsBySupplier($this->object->id, $products[$i]->id, 0);
             $products[$i]->product_supplier_reference = $product_infos['product_supplier_reference'];
             $products[$i]->product_supplier_price_te = Tools::displayPrice($product_infos['product_supplier_price_te'], new Currency($product_infos['id_currency']));
         }
     }
     $this->tpl_view_vars = array('supplier' => $this->object, 'products' => $products, 'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'shopContext' => Shop::getContext());
     return parent::renderView();
 }
 public function renderView()
 {
     $this->tpl_view_vars = array('modules_list' => $this->renderModulesList());
     return parent::renderView();
 }
 public function initViewDownload()
 {
     $this->tpl_folder = $this->tpl_folder . 'download/';
     return parent::renderView();
 }