static function find($found_id)
 {
     $found_collection = null;
     $collections = Collection::getAll();
     foreach ($collections as $collection) {
         $id = $collection->getId();
         if ($id == $found_id) {
             $found_collection = $collection;
         }
     }
     return $found_collection;
 }
 function test_deleteAll()
 {
     //Arrange
     $name = "Hello Kitty";
     $name2 = "Pokemon";
     $test_collection = new Collection($name);
     $test_collection->save();
     $test_collection2 = new Collection($name2);
     $test_collection2->save();
     //Act
     Collection::deleteAll();
     $result = Collection::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
 function test_deleteAll()
 {
     //Arrange
     $thing = "Run the World";
     $thing2 = "20 20 Experience";
     $test_collection = new Collection($thing);
     $test_collection->save();
     $test_collection2 = new Collection($thing2);
     $test_collection2->save();
     //Act
     Collection::deleteAll();
     //Assert
     $result = Collection::getAll();
     $this->assertEquals([], $result);
 }
Пример #4
0
<?php

include_once 'collection.php';
$Collection = new Collection();
$jsondata = array();
if (isset($_GET['all'])) {
    $jsondata = $Collection->getAll();
    for ($x = 0; $x < count($jsondata); $x++) {
        $id = $jsondata[$x][0];
        $num = $Collection->getCountSnippetsById($id);
        //array_push($jsondata[$x],$num[0][0]);
        $jsondata[$x]['num_snippets'] = $num[0][0];
    }
    //$jsondata = $Collection->getCountSnippetsById(1);
}
header('Content-type: application/json; charset=utf-8');
echo json_encode($jsondata);
//echo $jsondata[1][2];
exit;
Пример #5
0
 public function LoadByCritere($critere, $debutliste = null, $nbenr = null, $tri = 0, $sens = 'ASC')
 {
     $db = Database::getInstance();
     //var_dump($db);
     $tablename = $this->_tablename;
     $classe = $this->_classename;
     $req = "SELECT * FROM {$tablename} WHERE {$critere}";
     $tri++;
     $req .= " ORDER BY {$tri} {$sens}";
     //gestion de la limite
     if (!is_null($debutliste) && !is_null($nbenr)) {
         $req .= " LIMIT {$debutliste},{$nbenr}";
     }
     //var_dump($req);
     $stmt = $db->prepare($req);
     $stmt->execute();
     $lesobjets = new Collection();
     /*
      * Pour chaque ligne du jeu d'enregistrement
      */
     while ($jeuenregistrement = $stmt->fetch(PDO::FETCH_ASSOC)) {
         /*
          * Creation d'une collection de valeurs de champ
          */
         $params = new Collection();
         /*
          * Pour chacune des colonnes de la ligne en cours
          */
         foreach ($jeuenregistrement as $champ => $valeur) {
             //On stocke la valeur dans la collection
             $params->add($valeur);
         }
         $dataligne = $params->getAll();
         //var_dump($dataligne);
         /*
          * On instancie un objet avec toute les valeurs de ces colonnes (dans le tableau de valeur)
          */
         $monobjet = new $classe($dataligne);
         /*
          * On ajoute l'objet a la collection
          */
         $lesobjets->add($monobjet);
     }
     /*
      * Retour de la collection
      */
     return $lesobjets;
 }
Пример #6
0
Debug::enable();
$app = new Silex\Application();
// Set Silex debug mode in $app object
$app['debug'] = true;
$server = 'mysql:host=localhost;dbname=inventory';
$username = '******';
$password = '******';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get('/', function () use($app) {
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
$app->post('/collection', function () use($app) {
    $collection = new Collection($_POST['name']);
    $collection->save();
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
$app->post('/delete_collections', function () use($app) {
    Collection::deleteAll();
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
$app->post('/item', function () use($app) {
    $item = new Item($_POST['name']);
    $item->save();
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
$app->post('/delete_items', function () use($app) {
    Item::deleteAll();
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
return $app;
 public function index()
 {
     $this->layout->title = 'Collection';
     $this->layout->pageBar = false;
     $this->layout->content = View::make('admin.collections-all')->with(['collections' => Collection::getAll(), 'types' => Type::getSource(false), 'categories' => Category::getSource(false), 'maxHeight' => 500]);
 }
Пример #8
0
<?php

include "../patches.php";
$patch = new Patch(14);
if (!$patch->exists()) {
    $sql = "CREATE TABLE IF NOT EXISTS `bot_queues` (\n\t\t        `queue_id` INT(11) UNSIGNED NOT NULL,\n\t\t        `bot_id` INT(11) UNSIGNED NOT NULL,\n\t\t        `priority` INT(11) UNSIGNED NOT NULL,\n\t\t        PRIMARY KEY (`queue_id`, `bot_id`, `priority`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8";
    db()->execute($sql);
    $sql = "SELECT id, queue_id from bots";
    $bots = new Collection($sql);
    $bots->bindType("id", "Bot");
    $bots->bindType("queue_id", "Queue");
    foreach ($bots->getAll() as $row) {
        $bot = $row['Bot'];
        $queue = $row['Queue'];
        $sql = "INSERT INTO bot_queues VALUES(?, ?, 1)";
        $data = array($queue->id, $bot->id);
        db()->execute($sql, $data);
    }
    $sql = "DROP INDEX queue_id ON bots";
    db()->execute($sql);
    $sql = "ALTER TABLE bots DROP COLUMN queue_id";
    db()->execute($sql);
    $patch->finish("Added bots to queues");
}
Пример #9
0
<?php

include "../patches.php";
$patch = new Patch(18);
if (!$patch->exists()) {
    $createSql = "CREATE TABLE IF NOT EXISTS `webcam_images` (\n\t\t\t  `timestamp` datetime NOT NULL,\n\t\t\t  `image_id` bigint(11) unsigned NOT NULL,\n\t\t\t  `user_id` int(11) unsigned NOT NULL,\n\t\t\t  `bot_id` int(11) unsigned NULL,\n\t\t\t  `job_id` int(11) unsigned NULL,\n\t\t\t  PRIMARY KEY (`timestamp`, `image_id`),\n\t\t\t  FOREIGN KEY (`image_id`) REFERENCES s3_files(`id`) ON DELETE CASCADE,\n\t\t\t  FOREIGN KEY (`user_id`) REFERENCES users(`id`) ON DELETE CASCADE,\n\t\t\t  FOREIGN KEY (`bot_id`) REFERENCES bots(`id`) ON DELETE CASCADE,\n\t\t\t  FOREIGN KEY (`job_id`) REFERENCES jobs(`id`) ON DELETE CASCADE\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
    db()->execute($createSql);
    $failCount = 0;
    $rowSql = "SELECT id from jobs where webcam_images!=''";
    $jobsCollection = new Collection($rowSql);
    $jobsCollection->bindType('id', 'Job');
    $jobs = $jobsCollection->getAll();
    $total = $jobsCollection->count();
    $count = 0;
    $patch->progress(0);
    // Get the current webcam images in an array, so we can quickly skip those.
    $pdoStatement = db()->query("SELECT image_id from webcam_images");
    $existingImages = array();
    foreach ($pdoStatement->fetchAll(PDO::FETCH_ASSOC) as $row) {
        $existingImages[$row['image_id']] = true;
    }
    foreach ($jobs as $row) {
        /** @var Job $job */
        $job = $row['Job'];
        $images_json = $job->get('webcam_images');
        if ($job->isHydrated() && $images_json != "") {
            $images = json_decode($images_json, true);
            $rowData = array();
            foreach ($images as $timestamp => $image_id) {
                if (!array_key_exists($image_id, $existingImages)) {
                    $file = Storage::get($image_id);
Пример #10
0
 /**
  * Returns a new collection with the items from this collection and the provided combined.
  *
  * @param Collection $collection
  *
  * @return Collection
  */
 public function merge(Collection $collection)
 {
     return new Collection(array_merge($this->items, $collection->getAll()));
 }
 /**
  * Exports CSV
  */
 protected function renderCSV()
 {
     // exports orders
     if (Tools::isSubmit('csv_orders')) {
         $ids = array();
         foreach ($this->_list as $entry) {
             $ids[] = $entry['id_supply_order'];
         }
         if (count($ids) <= 0) {
             return;
         }
         $id_lang = Context::getContext()->language->id;
         $orders = new Collection('SupplyOrder', $id_lang);
         $orders->where('is_template', '=', false);
         $orders->where('id_supply_order', 'in', $ids);
         $id_warehouse = $this->getCurrentWarehouse();
         if ($id_warehouse != -1) {
             $orders->where('id_warehouse', '=', $id_warehouse);
         }
         $orders->getAll();
         $csv = new CSV($orders, $this->l('supply_orders'));
         $csv->export();
     } else {
         if (Tools::isSubmit('csv_orders_details')) {
             // header
             header('Content-type: text/csv');
             header('Content-Type: application/force-download; charset=UTF-8');
             header('Cache-Control: no-store, no-cache');
             header('Content-disposition: attachment; filename="' . $this->l('supply_orders_details') . '.csv"');
             // echoes details
             $ids = array();
             foreach ($this->_list as $entry) {
                 $ids[] = $entry['id_supply_order'];
             }
             if (count($ids) <= 0) {
                 return;
             }
             // for each supply order
             $keys = array('id_product', 'id_product_attribute', 'reference', 'supplier_reference', 'ean13', 'upc', 'name', 'unit_price_te', 'quantity_expected', 'quantity_received', 'price_te', 'discount_rate', 'discount_value_te', 'price_with_discount_te', 'tax_rate', 'tax_value', 'price_ti', 'tax_value_with_order_discount', 'price_with_order_discount_te', 'id_supply_order');
             echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $keys)));
             // overrides keys (in order to add FORMAT calls)
             $keys = array('sod.id_product', 'sod.id_product_attribute', 'sod.reference', 'sod.supplier_reference', 'sod.ean13', 'sod.upc', 'sod.name', 'FORMAT(sod.unit_price_te, 2)', 'sod.quantity_expected', 'sod.quantity_received', 'FORMAT(sod.price_te, 2)', 'FORMAT(sod.discount_rate, 2)', 'FORMAT(sod.discount_value_te, 2)', 'FORMAT(sod.price_with_discount_te, 2)', 'FORMAT(sod.tax_rate, 2)', 'FORMAT(sod.tax_value, 2)', 'FORMAT(sod.price_ti, 2)', 'FORMAT(sod.tax_value_with_order_discount, 2)', 'FORMAT(sod.price_with_order_discount_te, 2)', 'sod.id_supply_order');
             foreach ($ids as $id) {
                 $query = new DbQuery();
                 $query->select(implode(', ', $keys));
                 $query->from('supply_order_detail', 'sod');
                 $query->leftJoin('supply_order', 'so', 'so.id_supply_order = sod.id_supply_order');
                 $id_warehouse = $this->getCurrentWarehouse();
                 if ($id_warehouse != -1) {
                     $query->where('so.id_warehouse = ' . (int) $id_warehouse);
                 }
                 $query->where('sod.id_supply_order = ' . (int) $id);
                 $query->orderBy('sod.id_supply_order_detail DESC');
                 $resource = Db::getInstance()->query($query);
                 // gets details
                 while ($row = Db::getInstance()->nextRow($resource)) {
                     echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $row)));
                 }
             }
         } else {
             if (Tools::isSubmit('csv_order_details') && Tools::getValue('id_supply_order')) {
                 $supply_order = new SupplyOrder((int) Tools::getValue('id_supply_order'));
                 if (Validate::isLoadedObject($supply_order)) {
                     $details = $supply_order->getEntriesCollection();
                     $details->getAll();
                     $csv = new CSV($details, $this->l('supply_order') . '_' . $supply_order->reference . '_details');
                     $csv->export();
                 }
             }
         }
     }
 }
Пример #12
0
 public function live()
 {
     $this->assertAdmin();
     $this->setTitle("Live Bots View");
     $sql = "SELECT id, job_id FROM bots WHERE webcam_image_id != 0 AND last_seen > NOW() - 3600 ORDER BY last_seen DESC";
     $bots = new Collection($sql);
     $bots->bindType('id', 'Bot');
     $bots->bindType('job_id', 'Job');
     $this->set('bots', $bots->getAll());
     $this->set('dashboard_style', 'medium_thumbnails');
 }
Пример #13
0
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig');
});
$app->get("/collections", function () use($app) {
    return $app['twig']->render('collections.html.twig', array('collections' => Collection::getAll()));
});
$app->get("/types", function () use($app) {
    return $app['twig']->render('types.html.twig', array('types' => Type::getAll()));
});
$app->get("/searches", function () use($app) {
    return $app['twig']->render('searches.html.twig', array('searches' => Search::getAll()));
});
$app->post("/collections", function () use($app) {
    $collection = new Collection($_POST['thing']);
    $collection->save();
    return $app['twig']->render('collections.html.twig', array('collections' => Collection::getAll()));
});
$app->post("/types", function () use($app) {
    $type = new Type($_POST['descript']);
    $type->save();
    return $app['twig']->render('types.html.twig', array('types' => Type::getAll()));
});
$app->post("/searches", function () use($app) {
    $search = new Search($_POST['find']);
    $search->save();
    return $app['twig']->render('searches.html.twig', array('searches' => Search::getAll()));
});
$app->post("/delete_collections", function () use($app) {
    Collection::deleteAll();
    return $app['twig']->render('delete_collections.html.twig');
});
 protected function renderCSV()
 {
     if (Tools::isSubmit('export_csv')) {
         $stckmgtfr = ERP_STCKMGTFR;
         // get all filter
         //
         // category filer
         $id_category = Tools::isSubmit('id_category') ? (int) Tools::getValue('id_category') : -1;
         $query = new DbQuery();
         $query->select('id_product');
         $query->from('category_product');
         $query->where('id_category = ' . $id_category);
         $categories_exec = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
         $categories = null;
         foreach ($categories_exec as $category) {
             $categories[] = (int) $category['id_product'];
         }
         //If no data
         if ($id_category != -1 && $categories == null) {
             $this->displayWarning($this->l('No data to export in this category !'));
             return;
         }
         if ($categories != null) {
             $categories = array_unique($categories);
         }
         // supplier filter
         $id_supplier = Tools::isSubmit('id_supplier') ? (int) Tools::getValue('id_supplier') : -1;
         $query = null;
         $query = new DbQuery();
         $query->select('id_product');
         $query->from('product_supplier');
         $query->where('id_supplier = ' . $id_supplier);
         $suppliers_exec = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
         $suppliers = null;
         foreach ($suppliers_exec as $supplier) {
             $suppliers[] = (int) $supplier['id_product'];
         }
         //If no data
         if ($id_supplier != -1 && $suppliers == null) {
             $this->displayWarning($this->l('No data to export with this supplier !'));
             return;
         }
         if ($suppliers != null) {
             $suppliers = array_unique($suppliers);
         }
         // Filter by manufacturer
         $id_manufacturer = Tools::isSubmit('id_manufacturer') ? (int) Tools::getValue('id_manufacturer') : -1;
         $query = null;
         $query = new DbQuery();
         $query->select('id_product');
         $query->from('manufacturer', 'm');
         $query->innerjoin('product', 'p', 'm.id_manufacturer = p.id_manufacturer');
         $query->where('m.id_manufacturer = ' . $id_manufacturer);
         $manufacturers_exec = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
         $manufacturers = null;
         foreach ($manufacturers_exec as $manufacturer) {
             $manufacturers[] = (int) $manufacturer['id_product'];
         }
         //If no data
         if ($id_manufacturer != -1 && $manufacturers == null) {
             $this->displayWarning($this->l('No data to export with this manufacturer !'));
             return;
         }
         if ($manufacturers != null) {
             $manufacturers = array_unique($manufacturers);
         }
         // Quantity filter
         $table_quantity = 'quantity';
         $moreless = Tools::isSubmit('moreless') && in_array(Tools::getValue('moreless'), array('=', '>', '<')) ? Tools::getValue('moreless') : -1;
         $quantity = Tools::isSubmit('quantity_filter') ? (int) Tools::getValue('quantity_filter') : -1;
         if ($this->advanced_stock_management) {
             $id_warehouse = $this->getCurrentCoverageWarehouse();
             header('Content-type: text/csv');
             header('Cache-Control: no-store, no-cache');
             header('Content-disposition: attachment; filename=stock_' . date('Y-m-d_His') . '.csv');
             header('charset=iso-8859-1');
             // product attribute
             $combination = new DbQuery();
             $combination->select('
                         pa.id_product as id_product, 
                         pa.id_product_attribute as id_product_attribute, 
                         pa.reference as reference,
                         pa.ean13 as ean13, 
                         w.name as warehouse, 
                         wpl.id_warehouse_product_location,
                         wpl.location as location, 
                         area.name as areaname, 
                         subarea.name as subareaname');
             //if ($id_warehouse != -1)
             $combination->select('IFNULL(s.physical_quantity, 0) as physical_quantity, IFNULL(s.usable_quantity, 0) as usable_quantity');
             //else
             //$combination->select('SUM(IFNULL(s.physical_quantity, 0)) as physical_quantity, SUM(IFNULL(s.usable_quantity, 0)) as usable_quantity');
             $combination->from('product_attribute', 'pa');
             $combination->innerjoin('product', 'p', 'pa.id_product = p.id_product');
             $combination->leftjoin('warehouse_product_location', 'wpl', '(wpl.id_product = p.id_product AND wpl.id_product_attribute = IFNULL(pa.id_product_attribute, 0)' . ($id_warehouse != -1 ? ' AND wpl.id_warehouse = ' . (int) $id_warehouse : '') . ')');
             $combination->leftjoin('stock', 's', '(s.id_product = pa.id_product AND s.id_product_attribute = IFNULL(pa.id_product_attribute, 0))');
             $combination->leftjoin('warehouse', 'w', 's.id_warehouse = w.id_warehouse');
             $combination->leftjoin('erpip_warehouse_product_location', 'ewpl', '(wpl.id_warehouse_product_location = ewpl.id_warehouse_product_location)');
             $combination->leftjoin('erpip_zone', 'area', '(area.id_erpip_zone = ewpl.id_zone_parent)');
             $combination->leftjoin('erpip_zone', 'subarea', '(subarea.id_erpip_zone = ewpl.id_zone)');
             // apply filters
             // warehouse
             if ($id_warehouse != -1) {
                 $combination->where('s.id_warehouse = ' . (int) $id_warehouse . ' OR wpl.id_warehouse = ' . (int) $id_warehouse);
                 // area
                 if (Tools::isSubmit('area')) {
                     $combination->where('ewpl.id_zone_parent= ' . Tools::getValue('area'));
                     // sub area
                     if (Tools::isSubmit('subarea')) {
                         $combination->where('ewpl.id_zone= ' . Tools::getValue('subarea'));
                     }
                 }
             }
             if ($id_category != -1) {
                 $combination->where('pa.id_product IN (' . implode(',', array_map('intval', $categories)) . ')');
             }
             if ($id_supplier != -1) {
                 $combination->where('pa.id_product IN (' . implode(',', array_map('intval', $suppliers)) . ')');
             }
             if ($id_manufacturer != -1) {
                 $combination->where('pa.id_product IN (' . implode(',', array_map('intval', $manufacturers)) . ')');
             }
             if ($moreless != -1) {
                 if ($quantity > 0) {
                     $where_quantity_filter = ' physical_quantity ' . $moreless . ' ' . (int) $quantity;
                     if ($moreless == '=' && $quantity == 0 || $moreless == "<" && $quantity > 0) {
                         $where_quantity_filter .= ' OR physical_quantity IS NULL ';
                     }
                 }
                 $combination->where($where_quantity_filter);
             }
             $combination->groupBy('pa.id_product, pa.id_product_attribute, w.id_warehouse');
             $combination->orderBy('pa.id_product, pa.id_product_attribute');
             if ($this->controller_status == STATUS1) {
                 $combination->limit($stckmgtfr);
                 $this->informations[] = sprintf($this->l('You are using the free version of 1-Click ERP which limits document editing to %d products'), $stckmgtfr);
             }
             $combinations = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($combination);
             // List of product id
             $ids = array();
             foreach ($combinations as $combination) {
                 $ids[] = $combination['id_product'];
             }
             $ids = array_unique($ids);
             // Product without attribute
             $product = new DbQuery();
             $product->select('p.id_product as id_product, 
                         0 as id_product_attribute, 
                         p.reference as reference,
                         p.ean13 as ean13, 
                         w.name as warehouse, 
                         wpl.id_warehouse_product_location,
                         wpl.location as location, 
                         area.name as areaname, 
                         subarea.name as subareaname');
             //if ($id_warehouse != -1)
             $product->select('IFNULL(s.physical_quantity, 0) as physical_quantity, IFNULL(s.usable_quantity, 0) as usable_quantity');
             // else
             //$product->select('SUM(IFNULL(s.physical_quantity, 0)) as physical_quantity, SUM(IFNULL(s.usable_quantity, 0)) as usable_quantity');
             $product->from('product', 'p');
             $product->leftjoin('warehouse_product_location', 'wpl', '(wpl.id_product = p.id_product AND wpl.id_product_attribute = 0' . ($id_warehouse != -1 ? ' AND wpl.id_warehouse = ' . (int) $id_warehouse : '') . ')');
             $product->leftjoin('stock', 's', '(s.id_product = p.id_product)');
             $product->leftjoin('erpip_warehouse_product_location', 'ewpl', '(wpl.id_warehouse_product_location = ewpl.id_warehouse_product_location)');
             $product->leftjoin('warehouse', 'w', 's.id_warehouse = w.id_warehouse');
             $product->leftjoin('erpip_zone', 'area', '(area.id_erpip_zone = ewpl.id_zone_parent)');
             $product->leftjoin('erpip_zone', 'subarea', '(subarea.id_erpip_zone = ewpl.id_zone)');
             // apply filters
             if ($id_warehouse != -1) {
                 $product->where('s.id_warehouse = ' . (int) $id_warehouse . ' OR wpl.id_warehouse = ' . (int) $id_warehouse);
                 // Area
                 if (Tools::isSubmit('area')) {
                     $product->where('ewpl.id_zone_parent= ' . intval(Tools::getValue('area')));
                     // sub area
                     if (Tools::isSubmit('subarea')) {
                         $product->where('ewpl.id_zone= ' . intval(Tools::getValue('subarea')));
                     }
                 }
             }
             if ($id_category != -1) {
                 $product->where('p.id_product IN (' . implode(', ', array_map('intval', $categories)) . ')');
             }
             if ($id_supplier != -1) {
                 $product->where('p.id_product IN (' . implode(', ', array_map('intval', $suppliers)) . ')');
             }
             if ($id_manufacturer != -1) {
                 $product->where('p.id_product IN (' . implode(', ', array_map('intval', $manufacturers)) . ')');
             }
             if ($moreless != -1) {
                 if ($quantity > 0) {
                     $where_quantity_filter = ' physical_quantity ' . $moreless . ' ' . (int) $quantity;
                     if ($moreless == '=' && $quantity == 0 || $moreless == "<" && $quantity > 0) {
                         $where_quantity_filter .= ' OR physical_quantity IS NULL';
                     }
                 }
                 $product->where($where_quantity_filter);
             }
             if (count($ids) > 0) {
                 $product->where("p.id_product NOT IN (" . implode(',', array_map('intval', $ids)) . ")");
             }
             $product->groupBy('p.id_product, w.id_warehouse');
             $product->orderBy('p.id_product');
             if ($this->controller_status == STATUS1) {
                 $product->limit($stckmgtfr);
                 $this->informations[] = sprintf($this->l('You are using the free version of 1-Click ERP which limits document editing to %d products'), $stckmgtfr);
             }
             $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($product);
             // $query = array_merge($products, $combinations);
             $query = array_merge($products, $combinations);
             // we sort by id_product and id_product_attribute
             usort($query, array($this, "idproductSort"));
             if ($this->controller_status == STATUS1) {
                 $query = array_splice($query, 0, $stckmgtfr);
             }
             $csv_header_columns = array($this->l('EAN13'), $this->l('ID_PRODUCT'), $this->l('ID_PRODUCT_ATTRIBUTE'), $this->l('REFERENCE'), $this->l('PHYSICAL_QUANTITY'), $this->l('USABLE_QUANTITY'), self::transformText($this->l('WAREHOUSE')), $this->l('AREA'), $this->l('SUBAREA'), $this->l('LOCATION'), $this->l('WARNING'));
             echo implode(';', $csv_header_columns) . "\r\n";
             // generate csv file
             foreach ($query as $product) {
                 //alert in the case where the product has stock in warehouse without be located in this warehouse
                 $warning = '';
                 if (is_null($product['id_warehouse_product_location'])) {
                     $warning = sprintf($this->l('Product has stock in %s warehouse without being registered in this warehouse !'), $product['warehouse']);
                 }
                 $csv_value_columns = array(self::transformText($product['ean13']), $product['id_product'], $product['id_product_attribute'], self::transformText($product['reference']), self::transformText($product['physical_quantity']), self::transformText($product['usable_quantity']), self::transformText($product['warehouse']), self::transformText($product['areaname']), self::transformText($product['subareaname']), self::transformText($product['location']), self::transformText($warning));
                 echo implode(';', $csv_value_columns) . "\r\n";
             }
             echo sprintf($this->l('You are using the free version of 1-Click ERP which limits the export to %d products'), $stckmgtfr);
         } else {
             // we work in different stock table while advanced stock is disabled
             $table_stock = 'StockAvailable';
             $table_quantity = 'quantity';
             // create collection width current filter
             $id_lang = Context::getContext()->language->id;
             $stock = new Collection($table_stock, $id_lang);
             if ($id_category != -1) {
                 $stock->where('id_product', 'in', $categories);
             }
             if ($id_supplier != -1) {
                 $stock->where('id_product', 'in', $suppliers);
             }
             if ($id_manufacturer != -1) {
                 $stock->where('id_product', 'in', $manufacturers);
             }
             if ($moreless != -1) {
                 if ($quantity > 0) {
                     $where_quantity_filter = $table_quantity . ' ' . $moreless . ' ' . $quantity;
                     if ($moreless == '=' && $quantity == 0 || $moreless == "<" && $quantity > 0) {
                         $where_quantity_filter .= ' OR ' . $table_quantity . ' IS NULL';
                     }
                 }
                 $stock->sqlWhere($where_quantity_filter);
             }
             $stock->orderBy('id_product');
             $stock->orderBy('id_product_attribute');
             $stock->getAll();
             if ($this->controller_status == STATUS1) {
                 $stock = array_splice($stock, 0, $stckmgtfr);
                 $this->informations[] = sprintf($this->l('You are using the free version of 1-Click ERP which limits document editing to %d products'), $stckmgtfr);
             }
             // generation of CSV
             $csv = new CSV($stock, $this->l('stock') . '_' . date('Y-m-d_His'));
             $csv->export();
         }
         die;
     }
 }