public function renderList()
 {
     $this->toolbar_title = $this->l('Suppliers');
     return parent::renderList();
 }
 public function renderList()
 {
     $this->toolbar_title = $this->l('Order Management');
     $statuses_array = array();
     $statuses = ErpOrderState::getOrderStates((int) $this->context->language->id);
     foreach ($statuses as $status) {
         $statuses_array[$status['id_order_state']] = $status['name'];
     }
     require_once _PS_MODULE_DIR_ . 'erpillicopresta/models/ErpFeature.php';
     $this->context->smarty->assign(array('token_mr' => ModuleCore::isEnabled('mondialrelay') ? MondialRelay::getToken('back') : 'false', 'token_expeditor' => ModuleCore::isEnabled('expeditor') ? Tools::getAdminToken('AdminExpeditor' . (int) Tab::getIdFromClassName('AdminExpeditor') . (int) $this->context->employee->id) : 'false', 'id_employee' => (int) $this->context->employee->id, 'order_statuses' => $statuses_array, 'controller_status' => $this->controller_status, 'erp_feature' => ErpFeature::getFeaturesWithToken($this->context->language->iso_code), 'template_path' => $this->template_path, 'expeditor_status' => Configuration::get('EXPEDITOR_STATE_EXP'), '_module_dir_' => _MODULE_DIR_));
     $this->tpl_list_vars['has_bulk_actions'] = 'true';
     // handle may contain error messages
     $handle = Tools::getValue('handle');
     switch (trim($handle)) {
         case '':
             break;
         case 'false':
             $this->confirmations[] = $this->l('All orders have been updated') . '<br/>';
             break;
         default:
             if (!empty($handle)) {
                 // $handle = str_replace('u00e9', 'é', $handle);
                 // $handle = str_replace('u00ea', 'ê', $handle);
                 $handle = Tools::replaceAccentedChars($handle);
                 // We take note about orders with error: no valid carrier (split on order number #)
                 $orderWithoutShipping = strstr($handle, '#') != false ? true : false;
                 $errors = explode('<br/>', str_replace('#', '<br/>', $handle));
                 foreach ($errors as $key => $error) {
                     if (!empty($error)) {
                         if (!$orderWithoutShipping) {
                             $message = $error;
                         } else {
                             $message = $error;
                         }
                         $this->errors[] = Tools::displayError($message);
                     }
                 }
             }
             break;
     }
     if (Tools::getValue('linkPDF') != '' && Tools::getValue('newState') != '') {
         // if state need invoice generation
         if (ErpOrderState::invoiceAvailable(Tools::getValue('newState'))) {
             $pdf_link = new Link();
             $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateInvoicesPDF3&id_orders=' . Tools::getValue('linkPDF');
             $this->confirmations[] = '&nbsp;<a target="_blank" href="' . $pdf_link . '" alt="invoices">' . $this->l('Download all invoices') . '<br/></a>';
         }
         // if state need delivery slip generation
         if (ErpOrderState::deliverySlipAvailable(Tools::getValue('newState'))) {
             $pdf_link = new Link();
             $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateDeliverySlipsPDF2&id_orders=' . Tools::getValue('linkPDF');
             $this->confirmations[] = '&nbsp;<a target="_blank" href="' . $pdf_link . '" alt="delivery">' . $this->l('Download all delivery slip') . '<br/></a>';
         }
     }
     if (Tools::getValue('linkPDFPrint') != '') {
         if ($this->controller_status == STATUS1 && count(explode(',', Tools::getValue('linkPDFPrint'))) > ERP_ORDERFR) {
             $this->informations[] = sprintf($this->l('You are using the free version of 1-Click ERP which limits the possible number of documents to print to %d orders'), ERP_ORDERFR);
         } else {
             $invoices = '';
             $delivery = '';
             foreach (explode(',', Tools::getValue('linkPDFPrint')) as $id_order) {
                 if (ErpOrderState::invoiceAvailable(ErpOrder::getIdStateByIdOrder($id_order))) {
                     $invoices .= $id_order . ',';
                 }
                 if (ErpOrderState::deliverySlipAvailable(ErpOrder::getIdStateByIdOrder($id_order))) {
                     $delivery .= $id_order . ',';
                 }
             }
             if ($invoices != '') {
                 $pdf_link = new Link();
                 $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateInvoicesPDF3&id_orders=' . Tools::substr($invoices, 0, -1);
                 $this->confirmations[] = '&nbsp;<a target="_blank" href="' . $pdf_link . '" alt="invoices">' . $this->l('Download all invoices') . '</br></a>';
             }
             if ($delivery != '') {
                 $pdf_link = new Link();
                 $pdf_link = $pdf_link->getAdminLink("AdminAdvancedOrder", true) . '&submitAction=generateDeliverySlipsPDF2&id_orders=' . Tools::substr($delivery, 0, -1);
                 $this->confirmations[] = '&nbsp;<a target="_blank" href="' . $pdf_link . '" alt="delivery">' . $this->l('Download all delivery slip') . '</br></a>';
             }
             if ($invoices == '' && $delivery == '') {
                 $this->errors[] = $this->l('The selected orders have no invoice or delivery !') . '<br/>';
             }
         }
     }
     if (Tools::getValue('etiquettesMR') != '') {
         // Downlad all pdf and zip then delete and display link to zip file
         $etiquettesMR = explode(' ', Tools::getValue('etiquettesMR'));
         unset($etiquettesMR[count($etiquettesMR) - 1]);
         $zipPath = '../modules/erpillicopresta/export/mondialrelay.zip';
         $zip = new ZipArchive();
         if ($zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             throw new Exception($this->l('Impossible to create the zip archive containing the shipping labels to Mondial Relay carrier !') . '<br/>');
         }
         foreach ($etiquettesMR as $key => $i) {
             $zip->addFromString('mondialrelay_' . $key . '.pdf', Tools::file_get_contents($i));
         }
         $zip->close();
         //Display link to dl zip file
         $this->confirmations[] = '&nbsp;<a target="_blank" href="' . $zipPath . '" alt="zip_file">' . $this->l('Download zip archive which contents all labels for Mondial Relay shipment') . '<br/></a>';
         if (Tools::getValue('deliveryNumbersMR') != '') {
             // Get all tracking numbers
             $numbers = explode(" ", Tools::getValue('deliveryNumbersMR'));
             unset($numbers[count($numbers) - 1]);
             foreach ($numbers as $number) {
                 $tabNumber = explode("-", $number);
                 $order_carrier = new OrderCarrier(ErpOrder::getIdCarrierbyIdOrder((int) $tabNumber[1]));
                 $order = new ErpOrder((int) $tabNumber[1]);
                 // Update carrier
                 $order->shipping_number = $tabNumber[0];
                 $order->update();
                 // Update order_carrier
                 $order_carrier->tracking_number = pSQL($tabNumber[0]);
                 $order_carrier->update();
             }
         }
     }
     if (Tools::getValue('expeditorCSV') != '') {
         // CSV file creation
         $csvPath = '../modules/erpillicopresta/export/expeditor_inet.csv';
         $fileCSV = fopen($csvPath, 'w');
         // Fill in file
         fwrite($fileCSV, str_replace(',', '', Tools::getValue('expeditorCSV')));
         //Close
         fclose($fileCSV);
         // link creation
         $this->confirmations[] = '&nbsp;<a target="_blank" href="' . $csvPath . '" alt="csv_file">' . $this->l('Download export file (CSV) for ExpeditorInet') . '</br></a>';
     }
     if (Tools::getValue('idOthers') != '') {
         //BEGIN Initialisations for TNT
         if (Module::isEnabled('tntcarrier')) {
             $TNTCheck = false;
             require_once _PS_MODULE_DIR_ . '/tntcarrier/classes/PackageTnt.php';
             if (class_exists('ZipArchive', false) && ($tnt_zip = new ZipArchive())) {
                 // Protection du ZIP
                 $dateday = new DateTime();
                 $uniqid_file = uniqid('file_');
                 $token = md5($dateday->getTimestamp() . $uniqid_file);
                 // Put all tnt pdf into a zip
                 $tnt_zip_path = 'erpillicopresta/export/tnt_' . date('Y-m-d_His') . '_' . $uniqid_file . $token . '.zip';
                 if ($tnt_zip->open(_PS_MODULE_DIR_ . $tnt_zip_path, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
                     $this->errors[] = Tools::displayError($this->l('Failed to create a ZIP archive containing the shipping labels to TNT carrier !') . '<br/>');
                 } else {
                     // one or several id orders
                     $id_others_order_array = strpos(Tools::getValue('idOthers'), ',') !== false ? explode(',', Tools::getValue('idOthers')) : (int) Tools::getValue('idOthers');
                     // Browse all orders not in ExpeditorInet nor MondialRelay
                     foreach ((array) $id_others_order_array as $i => $id_order) {
                         // BEGIN Commande TNT
                         $id_order = (int) $id_order;
                         if (ErpOrder::isTntOrder($id_order)) {
                             // status change
                             $currOrder = new ErpOrder($id_order);
                             $currOrder->setCurrentState(4, $this->context->employee->id);
                             // Start to check that weight order is valid if not tnt crash !
                             //echo($data['poid'] * 1000);die;
                             // Get tracking number : dedicated class created for this action
                             // Execution of the hook generating the tracking number at an order opening ... So ctrl c / ctrl v to execute here
                             /*$erp_tntCarrier = new ErpTntCarrier();
                               $generate = $erp_tntCarrier->generateShipping($id_order);*/
                             $generateShipping = Hook::exec('adminOrder', array('id_order' => $id_order));
                             $tnt = new PackageTnt($id_order);
                             $tntNumber = $tnt->getShippingNumber();
                             if (count($tntNumber) == 0) {
                                 $this->errors[] = Tools::displayError($this->l('Failed to get shipping number from TNT services : you have to fit the weight of the order.'));
                                 continue;
                             }
                             $tntNumber = $tntNumber[0]['shipping_number'];
                             // Update order
                             $order_carrier = new OrderCarrier(ErpOrder::getIdCarrierbyIdOrder((int) $id_order));
                             $order = new ErpOrder((int) $id_order);
                             $order->shipping_number = $tntNumber;
                             $order->update();
                             $order_carrier->tracking_number = pSQL($tntNumber);
                             $order_carrier->update();
                             // Add pdf to zip
                             $tnt_zip->addFile(_PS_MODULE_DIR_ . '/tntcarrier/pdf/' . $tntNumber . '.pdf', $tntNumber . '.pdf');
                             $TNTCheck = true;
                         }
                         // END Order TNT
                         // SPLICE  idOther
                         if (is_array($id_others_order_array)) {
                             unset($id_others_order_array[$i]);
                         } else {
                             unset($id_others_order_array);
                         }
                     }
                     //Display dl zip link
                     $tnt_zip->close();
                     if ($TNTCheck) {
                         $this->confirmations[] = '&nbsp;<a target="_blank" href="' . _MODULE_DIR_ . $tnt_zip_path . '" alt="zip_file">' . $this->l('Download zip archive which contents all labels for TNT shipment') . '<br/></a>';
                     }
                 }
             } else {
                 $this->errors[] = Tools::displayError($this->l('Class ZipArchive does not exist !') . '<br/>');
             }
             //END Initialisations for TNT
         }
         // Display for order not  processed  : idothers
         if (isset($id_others_order_array)) {
             if (count($id_others_order_array) == 1) {
                 //var_dump($id_others_order_array);die();
                 if (is_array($id_others_order_array)) {
                     $id_others_order_array = $id_others_order_array[1];
                 }
                 $this->errors[] = Tools::displayError($this->l('The following order has not been processed : order #') . $id_others_order_array . '. ' . $this->l('Please make sure that the carrier is either TNT, ExpeditorInet, or MondialRelay and that the order fits the carrier requirements.'));
             } elseif (count($id_others_order_array) > 1) {
                 $this->errors[] = Tools::displayError($this->l('The following orders have not been processed : orders #') . implode(", ", $id_others_order_array) . '. ' . $this->l('Please make sure that the carrier is either TNT, ExpeditorInet, or MondialRelay and that the orders fit the carrier requirements.'));
             }
         }
     }
     return parent::renderList();
 }
 public function renderList()
 {
     $this->toolbar_title = $this->l('Auto restock');
     return parent::renderList();
 }
    public function renderDetails()
    {
        // tests if an id is submit
        if (Tools::isSubmit('id_supply_order') && !Tools::isSubmit('display_product_history')) {
            // overrides attributes
            $this->identifier = 'id_supply_order_history';
            $this->table = 'supply_order_history';
            $this->lang = false;
            $this->actions = array();
            $this->toolbar_btn = array();
            $this->list_simple_header = true;
            // gets current lang id
            $lang_id = (int) $this->context->language->id;
            // gets supply order id
            $id_supply_order = (int) Tools::getValue('id_supply_order');
            // creates new fields_list
            $this->fields_list = array('history_date' => array('title' => $this->l('Last update'), 'align' => 'left', 'type' => 'datetime', 'havingFilter' => true), 'history_employee' => array('title' => $this->l('Employee'), 'align' => 'left', 'havingFilter' => true), 'history_state_name' => array('title' => $this->l('Status'), 'align' => 'left', 'color' => 'color', 'havingFilter' => true));
            // loads history of the given order
            unset($this->_select, $this->_join, $this->_where, $this->_orderBy, $this->_orderWay, $this->_group, $this->_filterHaving, $this->_filter);
            $this->_select = '
			a.`date_add` as history_date,
			CONCAT(a.`employee_lastname`, \' \', a.`employee_firstname`) as history_employee,
			sosl.`name` as history_state_name,
			sos.`color` as color';
            $this->_join = '
			LEFT JOIN `' . _DB_PREFIX_ . 'supply_order_state` sos ON (a.`id_state` = sos.`id_supply_order_state`)
			LEFT JOIN `' . _DB_PREFIX_ . 'supply_order_state_lang` sosl ON
			(
				a.`id_state` = sosl.`id_supply_order_state`
				AND sosl.`id_lang` = ' . (int) $lang_id . '
			)';
            $this->_where = 'AND a.`id_supply_order` = ' . (int) $id_supply_order;
            $this->_orderBy = 'a.date_add';
            $this->_orderWay = 'DESC';
            return parent::renderList();
        } else {
            if (Tools::isSubmit('id_supply_order') && Tools::isSubmit('display_product_history')) {
                $this->identifier = 'id_supply_order_receipt_history';
                $this->table = 'supply_order_receipt_history';
                $this->actions = array();
                $this->toolbar_btn = array();
                $this->list_simple_header = true;
                $this->lang = false;
                $lang_id = (int) $this->context->language->id;
                $id_supply_order_detail = (int) Tools::getValue('id_supply_order');
                unset($this->fields_list);
                $this->fields_list = array('date_add' => array('title' => $this->l('Last update'), 'align' => 'left', 'type' => 'datetime', 'havingFilter' => true), 'employee' => array('title' => $this->l('Employee'), 'align' => 'left', 'havingFilter' => true), 'quantity' => array('title' => $this->l('Quantity received'), 'align' => 'left', 'havingFilter' => true));
                // loads history of the given order
                unset($this->_select, $this->_join, $this->_where, $this->_orderBy, $this->_orderWay, $this->_group, $this->_filterHaving, $this->_filter);
                $this->_select = 'CONCAT(a.`employee_lastname`, \' \', a.`employee_firstname`) as employee';
                $this->_where = 'AND a.`id_supply_order_detail` = ' . (int) $id_supply_order_detail;
                $this->_orderBy = 'a.date_add';
                $this->_orderWay = 'DESC';
                return parent::renderList();
            }
        }
    }
 public function renderList()
 {
     $this->toolbar_title = $this->l('Products list');
     $prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
     if (Tools::isSubmit('stockOrderby')) {
         $stockOrderby = Tools::getValue('stockOrderby');
         $_GET[$prefix . 'stockOrderby'] = $stockOrderby;
         $_GET['stockOrderby'] = $stockOrderby;
     }
     if (Tools::isSubmit('stockOrderway')) {
         $stockOrderway = Tools::getValue('stockOrderway');
         $_GET[$prefix . 'stockOrderway'] = $stockOrderway;
         $_GET['stockOrderway'] = $stockOrderway;
     }
     $this->processFilter();
     $this->getCurrentValue('stockOrderway');
     $this->getCurrentValue('stockOrderby');
     //sidebar
     require_once _PS_MODULE_DIR_ . 'erpillicopresta/models/ErpFeature.php';
     $this->tpl_list_vars['erp_feature'] = ErpFeature::getFeaturesWithToken($this->context->language->iso_code);
     $this->tpl_list_vars['template_path'] = $this->template_path;
     $advanced_stock_token = Tools::getAdminToken('AdminAdvancedStock' . (int) Tab::getIdFromClassName('AdminAdvancedStock') . (int) $this->context->employee->id);
     $this->tpl_list_vars['advanced_stock_token'] = $advanced_stock_token;
     return parent::renderList();
 }
Ejemplo n.º 6
0
 public function renderList()
 {
     $this->toolbar_title = $this->l('Areas');
     $cookie = new Cookie('psAdmin');
     $cookie->id_erpip_zone = Tools::getValue('id_erpip_zone');
     $cookie->id_warehouse = Tools::getValue('id_warehouse');
     $cookie->warehouse_name = Tools::getValue('warehouse_name');
     $cookie->zone_name = Tools::getValue('zone_name');
     return parent::renderList();
 }
 public function renderList()
 {
     $this->toolbar_title = $this->l('Stock');
     //                $this->page_header_toolbar_title = $this->l('Advanced Stock Management');
     $this->processFilter();
     if (Tools::isSubmit('submitReset' . $this->table)) {
         unset($this->context->cookie->stock_availableFilter_name);
     }
     if (Tools::isSubmit('export_csv')) {
         $this->renderCSV();
     }
     if (Tools::isSubmit('export_catalog')) {
         $this->renderCatalog();
     }
     if (Tools::isSubmit('id_warehouse') && Tools::getValue('id_warehouse') != '-1') {
         self::$currentIndex .= '&id_warehouse=' . (int) Tools::getValue('id_warehouse');
     }
     if (Tools::isSubmit('id_image') && Tools::getValue('id_image') != '-1') {
         self::$currentIndex .= '&id_image=' . (int) Tools::getValue('id_image');
     }
     if (Tools::isSubmit('id_category') && Tools::getValue('id_category') != '-1') {
         self::$currentIndex .= '&id_category=' . (int) Tools::getValue('id_category');
     }
     if (Tools::isSubmit('id_supplier') && Tools::getValue('id_supplier') != '-1') {
         self::$currentIndex .= '&id_supplier=' . (int) Tools::getValue('id_supplier');
     }
     if (Tools::isSubmit('id_manufacturer') && Tools::getValue('id_manufacturer') != '-1') {
         self::$currentIndex .= '&id_manufacturer=' . (int) Tools::getValue('id_manufacturer');
     }
     if (Tools::isSubmit('moreless') && in_array(Tools::getValue('moreless'), array('=', '>', '<'))) {
         self::$currentIndex .= '&moreless=' . Tools::getValue('moreless');
     }
     if (Tools::isSubmit('quantity_filter')) {
         self::$currentIndex .= '&quantity_filter=' . (int) Tools::getValue('quantity_filter');
     }
     return parent::renderList();
 }
Ejemplo n.º 8
0
    public function renderList()
    {
        $this->toolbar_title = $this->l('Inventory reports');
        if (Tools::isSubmit('id_container') && Tools::getValue('id_container') > 0) {
            self::$currentIndex .= '&id_container=' . (int) Tools::getValue('id_container');
        }
        // Get id container. if noone selected, take the first one
        if (($id_container = $this->getCurrentValue('id_container')) == false) {
            $id_container = (int) ErpInventory::getFirstId();
            $this->tpl_list_vars['id_container'] = $id_container;
        }
        // get total stock gap of inventory
        $total_stock_gap = InventoryProduct::getTotalStockGap($id_container);
        $this->tpl_list_vars['total_gap'] = Tools::displayPrice($total_stock_gap);
        // Query
        $this->_select = 'p.id_product,
						IF(pa.id_product_attribute, pa.reference, p.reference) as reference,
						IFNULL(pa.id_product_attribute, 0) as id_product_attribute,
			IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name,
			p.id_product, IFNULL(pa.id_product_attribute, 0) as id_product_attribute, w.name as warehouse, a.qte_before, a.qte_after, smrl.name as reason, (qte_after - qte_before) as gap,
			(
						SELECT ps.product_supplier_reference
						FROM ' . _DB_PREFIX_ . 'product_supplier ps
						WHERE ps.id_product = a.id_product
						AND ps.id_product_attribute = a.id_product_attribute
						LIMIT 1
			)as first_supplier_ref';
        $this->_join = 'INNER JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (a.id_product = pl.id_product AND pl.id_lang = ' . (int) $this->context->language->id . ')
				INNER JOIN ' . _DB_PREFIX_ . 'product p ON a.id_product = p.id_product
				INNER JOIN ' . _DB_PREFIX_ . 'stock_mvt_reason_lang smrl ON (a.id_mvt_reason = smrl.id_stock_mvt_reason AND smrl.id_lang = ' . (int) $this->context->language->id . ')
				INNER JOIN ' . _DB_PREFIX_ . 'stock_mvt_reason smr ON a.id_mvt_reason = smr.id_stock_mvt_reason
				INNER JOIN ' . _DB_PREFIX_ . 'warehouse w ON w.id_warehouse = a.id_warehouse
				INNER JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON a.id_product_attribute= pa.id_product_attribute
				INNER JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute
				INNER JOIN ' . _DB_PREFIX_ . 'attribute atr ON atr.id_attribute= pac.id_attribute
				INNER JOIN ' . _DB_PREFIX_ . 'attribute_lang al ON (al.id_attribute= pac.id_attribute AND al.id_lang=' . (int) $this->context->language->id . ')
				INNER JOIN ' . _DB_PREFIX_ . 'attribute_group_lang agl ON (agl.id_attribute_group= atr.id_attribute_group AND agl.id_lang=' . (int) $this->context->language->id . ')
				INNER JOIN ' . _DB_PREFIX_ . 'erpip_inventory i ON a.id_erpip_inventory = i.id_erpip_inventory';
        $this->_where = 'AND i.id_erpip_inventory = ' . $id_container;
        $this->_order = 'a.id_erpip_inventory_product DESC  LIMIT 10';
        $this->_group = 'GROUP BY a.id_product_attribute';
        // Send values to view
        $this->tpl_list_vars['containers'] = ErpInventory::getContainers();
        $list = parent::renderList();
        return $list;
    }
    public function renderList()
    {
        $this->toolbar_title = $this->l('Products list');
        if (Tools::isSubmit('id_display')) {
            self::$currentIndex .= '&id_display=' . (int) Tools::getValue('id_display');
        }
        if (Tools::isSubmit('id_warehouse') && Tools::getValue('id_warehouse') != '-1') {
            self::$currentIndex .= '&id_warehouse=' . (int) Tools::getValue('id_warehouse');
        }
        if (Tools::isSubmit('areaFilter')) {
            self::$currentIndex .= '&areaFilter=' . Tools::getValue('areaFilter');
        }
        if (Tools::isSubmit('subareaFilter')) {
            self::$currentIndex .= '&subareaFilter=' . Tools::getValue('subareaFilter');
        }
        if (Tools::isSubmit('id_category') && Tools::getValue('id_category') != '-1') {
            self::$currentIndex .= '&id_category=' . (int) Tools::getValue('id_category');
        }
        if (Tools::isSubmit('id_supplier') && Tools::getValue('id_supplier') != '-1') {
            self::$currentIndex .= '&id_supplier=' . (int) Tools::getValue('id_supplier');
        }
        if (Tools::isSubmit('id_manufacturer') && Tools::getValue('id_manufacturer') != '-1') {
            self::$currentIndex .= '&id_manufacturer=' . (int) Tools::getValue('id_manufacturer');
        }
        // Get display type
        $id_display = $this->getCurrentValue('id_display');
        // qubquery : return the first provider reference for principal product
        $this->_select = '
				cl.name as category_name,
				i.id_image,
				a.id_product as mvt_reason,
                                area.name as area_name, 
                                sub_area.name as sub_area_name, 
                                wpl.location as location,
				a.id_product as new_quantity,
				(
					SELECT ps.product_supplier_reference
					FROM ' . _DB_PREFIX_ . 'product_supplier ps
					WHERE ps.id_product = a.id_product
					AND ps.id_product_attribute = 0
					LIMIT 1
				)as first_supplier_ref,
                                (
                                    EXISTS(SELECT pa.id_product FROM ' . _DB_PREFIX_ . 'product_attribute pa WHERE pa.id_product = a.id_product LIMIT 1)
                                ) 
                                as have_attribute,
                                ';
        $this->_join = ' LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (pa.id_product = a.id_product)' . 'INNER JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (a.id_product = pl.id_product AND pl.id_lang = ' . (int) $this->context->language->id . ')
                                 INNER JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (a.id_category_default = cl.id_category AND cl.id_lang = ' . (int) $this->context->language->id . ')
                                 LEFT JOIN ' . _DB_PREFIX_ . 'image i ON a.id_product = i.id_product ';
        $this->_join .= ' LEFT JOIN ' . _DB_PREFIX_ . 'warehouse_product_location wpl ON (wpl.id_product = a.id_product AND wpl.id_product_attribute = IFNULL(pa.id_product_attribute, 0))';
        $this->_join .= ' LEFT JOIN ' . _DB_PREFIX_ . 'erpip_warehouse_product_location ewpl ON wpl.id_warehouse_product_location = ewpl.id_warehouse_product_location ';
        $this->_join .= ' LEFT JOIN ' . _DB_PREFIX_ . 'erpip_zone area ON area.id_erpip_zone = ewpl.id_zone_parent ';
        $this->_join .= ' LEFT JOIN ' . _DB_PREFIX_ . 'erpip_zone sub_area ON sub_area.id_erpip_zone = ewpl.id_zone ';
        // Render 1 : mix products and declination to sort by area
        if ($id_display == 1) {
            $this->_select .= 'IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as product_name,
                                        IFNULL((CONCAT(a.id_product, ";", pa.id_product_attribute)), a.id_product) as id_product,';
            $this->_join .= '
                            LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac ON (pac.id_product_attribute = pa.id_product_attribute)
                            LEFT JOIN `' . _DB_PREFIX_ . 'attribute` atr ON (atr.id_attribute = pac.id_attribute)
                            LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON (al.id_attribute = pac.id_attribute AND al.id_lang = ' . (int) $this->context->language->id . ')
                            LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group_lang` agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = ' . (int) $this->context->language->id . ')
                            ';
        } else {
            $this->_select .= 'pl.name as product_name,';
        }
        $this->tpl_list_vars['advanced_stock_token'] = $this->advanced_stock_token;
        // FILTERS
        // Init filters variables
        $this->tpl_list_vars['id_category'] = -1;
        $this->tpl_list_vars['id_supplier'] = -1;
        $this->tpl_list_vars['id_manufacturer'] = -1;
        $this->tpl_list_vars['id_warehouse'] = -1;
        $this->tpl_list_vars['areaFilter'] = -1;
        $this->tpl_list_vars['subareaFilter'] = -1;
        $this->tpl_list_vars['id_display'] = 0;
        // Add additional filters
        $this->tpl_list_vars['warehouses'] = Warehouse::getWarehouses();
        $this->tpl_list_vars['categories'] = Category::getSimpleCategories((int) $this->context->language->id);
        $this->tpl_list_vars['suppliers'] = Supplier::getSuppliers();
        $this->tpl_list_vars['manufacturers'] = Manufacturer::getManufacturers();
        $this->tpl_list_vars['controller_status'] = $this->controller_status;
        // Get inventory containers
        $this->tpl_list_vars['containers'] = ErpInventory::getContainers();
        // get conf stock gap
        $this->tpl_list_vars['gap_stock'] = Configuration::getGlobalValue('ERP_GAP_STOCK');
        require_once _PS_MODULE_DIR_ . 'erpillicopresta/models/ErpFeature.php';
        $this->tpl_list_vars['erp_feature'] = ErpFeature::getFeaturesWithToken($this->context->language->iso_code);
        $this->tpl_list_vars['template_path'] = $this->template_path;
        // get default inventory reasons
        if ($this->context->language->iso_code == 'fr') {
            $this->tpl_list_vars['reason_increase'] = ErpStockMvtReason::existsByName('Augmentation d\'inventaire');
            $this->tpl_list_vars['reason_decrease'] = ErpStockMvtReason::existsByName('Diminution d\'inventaire');
        } else {
            $this->tpl_list_vars['reason_increase'] = ErpStockMvtReason::existsByName('Increase of inventory');
            $this->tpl_list_vars['reason_decrease'] = ErpStockMvtReason::existsByName('Decrease of inventory');
        }
        // specify advanced stock manager or not
        if ($this->advanced_stock_management) {
            // Get the selected warehouse, if there's not, get the first one
            if (($id_warehouse = $this->getCurrentValue('id_warehouse')) == false) {
                $id_warehouse = $this->getCookie('id_warehouse');
                $this->tpl_list_vars['id_warehouse'] = $id_warehouse;
            }
            // filters warehouse location
            $area = $this->getCurrentValue('areaFilter');
            $subarea = $this->getCurrentValue('subareaFilter');
            $this->tpl_list_vars['areas'] = ErpZone::getZonesName($id_warehouse);
            $this->tpl_list_vars['sub_areas'] = $area ? ErpZone::getZonesName($id_warehouse, 'sub_area', $area) : array();
            // if an area AND an under area are specified, we filter the area and the under area for the specified area
            if ($area != false && $subarea != false) {
                $this->_where .= ' AND wpl.id_warehouse = ' . (int) $id_warehouse . '
                                                AND area.id_erpip_zone = "' . (int) $area . '" AND sub_area.id_erpip_zone = ' . (int) $subarea;
                $this->_group = 'GROUP BY a.id_product';
            } elseif ($area != false) {
                $this->_where .= ' AND wpl.id_warehouse=' . (int) $id_warehouse . ' AND area.id_erpip_zone = ' . (int) $area;
                //$this->_where .= ' AND area.id_erpip_zone = '.(int)$area;
                if ($id_display == 1) {
                    $this->_group = 'GROUP BY a.id_product, pa.id_product_attribute';
                } else {
                    $this->_group = 'GROUP BY a.id_product';
                }
            } else {
                $this->_where .= ' AND wpl.id_warehouse = ' . (int) $id_warehouse;
                if ($id_display == 1) {
                    $this->_group = 'GROUP BY a.id_product, pa.id_product_attribute';
                } else {
                    $this->_group = 'GROUP BY a.id_product';
                }
            }
        } else {
            if ($id_display == 1) {
                $this->_group = 'GROUP BY a.id_product, pa.id_product_attribute';
            } else {
                $this->_group = 'GROUP BY a.id_product';
            }
        }
        // filter the query with applied filters
        //category filter
        if (($id_category = $this->getCurrentValue('id_category')) != false) {
            $this->_where .= ' AND a.id_product IN (
                                    SELECT cp.id_product
                                    FROM ' . _DB_PREFIX_ . 'category_product cp
                                    WHERE cp.id_category = ' . (int) $id_category . '
                            )';
        }
        // provider filter
        if (($id_supplier = $this->getCurrentValue('id_supplier')) != false) {
            $this->_where .= ' AND a.id_product IN (
                                SELECT ps.id_product
                                FROM ' . _DB_PREFIX_ . 'product_supplier ps
                                WHERE ps.id_supplier = ' . (int) $id_supplier . '
                        )';
        }
        // Brand filter
        if (($id_manufacturer = $this->getCurrentValue('id_manufacturer')) != false) {
            $this->_where .= ' AND a.id_manufacturer = ' . (int) $id_manufacturer;
        }
        $this->displayInformation($this->l('Be careful, if you are using advanced [respectively simple] stock management, only products using advanced [respectively simple] stock management will be exported.'));
        $this->displayInformation($this->l('In advanced sotck managment, products that are not stocked in a warehouse will not appear.'));
        // Show information or confirm message / error at the end of the inventory
        /*switch(Tools::getValue('submitFilterproduct'))
        		{
        			case 0:
        				$this->displayInformation($this->l('New inventory'));
        			break;
        			case 1:
        				$this->confirmations[] = $this->l('Inventory completed');
        			break;
        			case 2:
        				$this->errors[] = Tools::displayError('There has been a problem while handling products');
        			break;
        			default:
        				$this->displayInformation($this->l('New inventory'));
        			break;
        		}*/
        // Add plugin simple tooltip
        $this->addJqueryPlugin('cluetip', _MODULE_DIR_ . 'erpillicopresta/js/cluetip/');
        // add jquery dialog
        $this->addJqueryUI('ui.dialog');
        // add plugin validity
        $this->addJqueryPlugin('validity.min', _MODULE_DIR_ . 'erpillicopresta/js/validity/');
        // Load JS
        $this->addJS(_MODULE_DIR_ . 'erpillicopresta/js/inventory_tools.js');
        $this->addJS(_MODULE_DIR_ . 'erpillicopresta/js/inventory.js');
        // Load CSS
        $this->addCSS(_MODULE_DIR_ . 'erpillicopresta/css/jquery.validity.css');
        $this->addCSS(_MODULE_DIR_ . 'erpillicopresta/css/jquery.cluetip.css');
        $list = parent::renderList();
        return $list;
    }