public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
 {
     parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
 }
 public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
 {
     parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
     $nb_items = count($this->_list);
     for ($i = 0; $i < $nb_items; ++$i) {
         $item =& $this->_list[$i];
         if (Tools::isSubmit('ajax') && isset($item['id_order_detail'])) {
             // no details for this row
             $this->addRowActionSkipList('details', array($item['id_order_detail']));
             if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
                 $manager = StockManagerFactory::getManager();
                 $quantity_stock = (int) $manager->getProductRealQuantities((int) $item['product_id'], (int) $item['product_attribute_id'], null, true);
             } else {
                 $quantity_stock = (int) Product::getQuantity((int) $item['product_id'], (int) $item['product_attribute_id']);
             }
             // ges stock level color
             $item['stock_level_color'] = ErpSupplyOrderClasses::getStockLevelColor($quantity_stock);
         } else {
             // add view link for each row
             $item['href_view_link'] = Tools::safeOutput('index.php?controller=AdminOrders&' . $this->identifier . '=' . $item['id_order'] . '&view' . $this->table . '&token=' . Tools::getAdminTokenLite('AdminOrders'));
         }
     }
 }
 /**
  * AdminController::getList() override
  * @see AdminController::getList()
  */
 public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
 {
     if (Tools::isSubmit('csv_orders') || Tools::isSubmit('csv_orders_details') || Tools::isSubmit('csv_order_details') || Tools::isSubmit('export_history')) {
         $limit = false;
     }
     // defines button specific for non-template supply orders
     if (!$this->is_template_list) {
         // adds export csv buttons
         $this->toolbar_btn['export-csv-orders'] = array('short' => 'Export Orders', 'href' => $this->context->link->getAdminLink('AdminAdvancedSupplyOrder') . '&csv_orders&id_warehouse=' . $this->getCurrentWarehouse() . '&id_supplier=' . $this->getCurrentSupplier(), 'desc' => $this->l('Export Orders (CSV)'), 'class' => 'process-icon-export');
         $this->toolbar_btn['export-csv-details'] = array('short' => 'Export Orders Details', 'href' => $this->context->link->getAdminLink('AdminAdvancedSupplyOrder') . '&csv_orders_details&id_warehouse=' . $this->getCurrentWarehouse() . '&id_supplier=' . $this->getCurrentSupplier(), 'desc' => $this->l('Export Orders Details (CSV)'), 'class' => 'process-icon-export');
         unset($this->toolbar_btn['new']);
         if ($this->tabAccess['add'] === '1') {
             if ($this->controller_status == STATUS1 && $this->nbcmdfou >= 1) {
                 $text = addslashes($this->l('Only one order is allowed in FREE version. Switch to superior version to kick off the limit.'));
                 $this->toolbar_btn['new'] = array('js' => 'cancelBubble(event, \'' . $text . '\');', 'href' => '#', 'desc' => $this->l('Add New'));
             } else {
                 $this->toolbar_btn['new'] = array('href' => self::$currentIndex . '&add' . $this->table . '&token=' . $this->token, 'desc' => $this->l('Add New'));
             }
         }
     }
     parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
     // adds colors depending on the receipt state
     if ($order_by == 'quantity_expected') {
         $nb_items = count($this->_list);
         for ($i = 0; $i < $nb_items; ++$i) {
             $item =& $this->_list[$i];
             if ((int) $item['quantity_received'] == (int) $item['quantity_expected']) {
                 $item['class'] = 'received_equal_expected';
                 $item['color'] = '#00bb35';
             } else {
                 if ((int) $item['quantity_received'] > (int) $item['quantity_expected']) {
                     $item['class'] = 'received_sup_expected';
                     $item['color'] = '#fb0008';
                 }
             }
         }
     }
     // actions filters on supply orders list
     if ($this->table == 'supply_order') {
         $nb_items = count($this->_list);
         for ($i = 0; $i < $nb_items; $i++) {
             // if the current state doesn't allow order edit, skip the edit action
             if ($this->_list[$i]['editable'] == 0) {
                 $this->addRowActionSkipList('edit', $this->_list[$i]['id_supply_order']);
             }
             if ($this->_list[$i]['enclosed'] == 1 && $this->_list[$i]['receipt_state'] == 0) {
                 $this->addRowActionSkipList('changestate', $this->_list[$i]['id_supply_order']);
             }
             if (1 != $this->_list[$i]['pending_receipt']) {
                 $this->addRowActionSkipList('updatereceipt', $this->_list[$i]['id_supply_order']);
             }
         }
     }
     // only on home screen
     if ($this->display == 'update_receipt') {
         // Send the number of products to the template to hide or show the div-popup
         $nb_items = count($this->_list);
         $this->tpl_list_vars['nb_items'] = $nb_items;
         $ids = array();
         for ($i = 0; $i < $nb_items; ++$i) {
             $item =& $this->_list[$i];
             $id = $item['id_product'] . '_' . $item['id_product_attribute'];
             array_push($ids, $id);
         }
         $ids = implode('|', $ids);
         // assigns var
         $this->context->smarty->assign(array('ids' => $ids));
     }
 }
 public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
 {
     parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
     $nb_items = count($this->_list);
     // Alert if there are no orders in the status
     if ($nb_items == 0) {
         $this->errors[] = $this->l('No orders found with the given status');
     }
 }
 public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
 {
     if (Tools::isSubmit('csv') && (int) Tools::getValue('id_warehouse') != -1) {
         $limit = false;
     }
     $stckmgtfr = ERP_STCKMGTFR;
     if ($this->controller_status == STATUS1) {
         $limit = $stckmgtfr;
         $this->informations[] = sprintf($this->l('You are using the free version of 1-Click ERP which limits document editing to %d products'), $limit);
     }
     $order_by_valuation = false;
     $order_by_real_quantity = false;
     if ($this->context->cookie->{$this->table . 'Orderby'} == 'valuation') {
         unset($this->context->cookie->{$this->table . 'Orderby'});
         $order_by_valuation = true;
     } else {
         if ($this->context->cookie->{$this->table . 'Orderby'} == 'real_quantity') {
             echo '$order_by_real_quantity';
             unset($this->context->cookie->{$this->table . 'Orderby'});
             $order_by_real_quantity = true;
         } else {
             if (Tools::isSubmit('configurationOrderby') && Tools::getValue('configurationOrderby') == 'real_quantity') {
                 unset($this->context->cookie->{$this->table . 'Orderby'});
                 $order_by_real_quantity = true;
             }
         }
     }
     parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
     // Add columns only for the product in stock list
     if (isset($this->_list[0]['id_product'])) {
         $nb_items = count($this->_list);
         for ($i = 0; $i < $nb_items; ++$i) {
             $item =& $this->_list[$i];
             $item[$this->identifier] = $item['id_product'];
             // gets stock manager
             $manager = StockManagerFactory::getManager();
             $id_warehouse = (int) $this->getCurrentCoverageWarehouse();
             // gets quantities and valuation
             $query = new DbQuery();
             $query->select('SUM(physical_quantity) as physical_quantity');
             $query->select('SUM(usable_quantity) as usable_quantity');
             $query->select('SUM(price_te * physical_quantity) as valuation');
             $query->from('stock');
             $query->where('id_product =' . (int) $item['id_product'] . ' AND id_product_attribute = ' . (int) $item['id_product_attribute']);
             // If id = -1, all warehouses
             if ($id_warehouse != -1) {
                 $query->where('id_warehouse = ' . $id_warehouse);
             }
             $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
             $item['physical_quantity'] = $res['physical_quantity'] == '' ? 0 : $res['physical_quantity'];
             $item['usable_quantity'] = $res['usable_quantity'] == '' ? 0 : $res['usable_quantity'];
             // gets real_quantity depending on the warehouse
             $item['real_quantity'] = $manager->getProductRealQuantities($item['id_product'], $item['id_product_attribute'], $this->getCurrentCoverageWarehouse() == -1 ? null : array($this->getCurrentCoverageWarehouse()), true);
             // removes the valuation if the filter corresponds to 'all warehouses'
             if ($this->getCurrentCoverageWarehouse() == -1) {
                 $item['valuation'] = 'N/A';
             } else {
                 $item['valuation'] = $res['valuation'];
             }
         }
         if ($this->getCurrentCoverageWarehouse() != -1 && $order_by_valuation) {
             usort($this->_list, array($this, 'valuationCmp'));
         } else {
             if ($order_by_real_quantity) {
                 usort($this->_list, array($this, 'realQuantityCmp'));
             }
         }
     }
     if (isset($this->_list[0]['id_stock_available'])) {
         $nb_items = count($this->_list);
         for ($i = 0; $i < $nb_items; ++$i) {
             $item =& $this->_list[$i];
             if ((int) $item['id_product_attribute'] == 0) {
                 if (count(Product::getProductAttributesIds((int) $item['id_product'])) > 0) {
                     $item['quantity'] = '--';
                 }
             }
         }
     }
     // Add TTC price column for  stock, stock available & illicotimemachine
     if (isset($this->_list[0]['id_product']) || isset($this->_list[0]['id_stock_available']) || isset($this->_list[0]['id_stock_image_content'])) {
         $nb_items = count($this->_list);
         for ($i = 0; $i < $nb_items; ++$i) {
             $item =& $this->_list[$i];
             $query = new DbQuery();
             $query->select('rate');
             $query->from('tax', 't');
             $query->innerjoin('tax_rule', 'tr', 'tr.id_tax = t.id_tax');
             $query->where('t.id_tax = ' . (int) $item['id_tax_rules_group']);
             $query->where('tr.id_country = ' . (int) $this->context->country->id);
             $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
             // If we are on a product
             if ($item['price_attribute'] == null) {
                 $item['price'] = $item['price_product'];
                 $item['price_ttc'] = $item['price_product'] * ($res['rate'] / 100) + $item['price_product'];
             } else {
                 $item['price'] = $price = $item['price_product'] + $item['price_attribute'];
                 $item['price_ttc'] = $price * ($res['rate'] / 100) + $price;
             }
         }
     }
     // totals
     $this->getTotalPrices();
 }
 public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
 {
     if ($this->controller_status == STATUS1) {
         $limit = ERP_STCKMGTFR;
         $this->informations[] = sprintf($this->l('You are using the free version of 1-Click ERP which limits the display to %d products'), $limit);
     }
     parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
 }
 public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
 {
     if ($this->controller_status == STATUS1) {
         $limit = ERP_IVTFR;
         $this->informations[] = sprintf($this->l('You are using the free version of 1-Click ERP which limits the display to %d products'), $limit);
     }
     parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
     // Get the render type
     $id_display = $this->getCurrentValue('id_display');
     // Get the current warehouse
     $id_warehouse = $this->getCurrentValue('id_warehouse');
     if ($id_warehouse == '') {
         $id_warehouse = $this->getCookie('id_warehouse');
     }
     // Send number products to template to show/hide div-popup
     $nb_items = count($this->_list);
     $this->tpl_list_vars['nb_items'] = $nb_items;
     for ($i = 0; $i < $nb_items; ++$i) {
         $item =& $this->_list[$i];
         if (!isset($item['product_name']) && isset($item['name'])) {
             $item['product_name'] = $item['name'];
         }
         // set Ids depends of the current render
         if (strrpos($item['id_product'], ';') > 0) {
             $ids = explode(";", $item['id_product']);
             $id_product = $ids[0];
             $id_product_attribute = $ids[1];
         } else {
             $id_product = $item['id_product'];
             $id_product_attribute = 0;
         }
         $query = new DbQuery();
         // Products declensions (if render is mixed, force on an empty array)
         $attributes_ids = $id_display == 1 ? array() : Product::getProductAttributesIds((int) $id_product);
         $item['have_attribute'] = false;
         // add additional column only if we re on a product without declension
         // else they will be shown on declension
         if (count($attributes_ids) == 0) {
             // add quantity noted
             // If advanced stock manager is inactif, only show quantity
             if (!$this->advanced_stock_management) {
                 // get the quantity
                 $query->select('quantity');
                 $query->from('stock_available');
                 $query->where('id_product = ' . (int) $id_product . ' AND id_product_attribute = ' . (int) $id_product_attribute);
                 $query->orderBy('id_stock_available DESC');
                 // execute query
                 $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
                 // Add column to array
                 $item['quantity'] = $res['quantity'];
             } else {
                 // get the physical and usable quantity
                 $query->select('physical_quantity');
                 $query->select('usable_quantity');
                 $query->from('stock');
                 $query->where('id_product = ' . (int) $id_product . ' AND id_product_attribute = ' . (int) $id_product_attribute . ' AND id_warehouse =' . (int) $id_warehouse);
                 // Execute query
                 $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
                 // Add column to array
                 $item['physical_quantity'] = $res['physical_quantity'];
                 $item['usable_quantity'] = $res['usable_quantity'];
                 // the real quantity depends of the warehouse
                 $manager = StockManagerFactory::getManager();
                 $item['real_quantity'] = $manager->getProductRealQuantities($id_product, $id_product_attribute, $this->getCookie('id_warehouse') == -1 ? null : array($this->getCookie('id_warehouse')), true);
                 // add location
                 $location = ErpWarehouseProductLocationClass::getCompleteLocation($id_product, $id_product_attribute, $this->getCookie('id_warehouse') == -1 ? 1 : $this->getCookie('id_warehouse'));
                 $item['location'] = $location;
             }
         } else {
             $item['have_attribute'] = true;
         }
     }
     // display 0: add detail column +-
     if ($id_display == 0) {
         $this->addRowAction('details');
     }
     // display 1 : sort products by location
     /*else
       usort($this->_list, array('AdminInventoryController', 'cmp'));*/
 }