2017-09-23 17:05:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace database\repo;
|
|
|
|
use \database\core\DatabaseDriver;
|
|
|
|
use \error\core\Err;
|
|
|
|
use \database\core\Repo;
|
|
|
|
use \orm\core\Table;
|
|
|
|
use \orm\core\Rows;
|
|
|
|
|
|
|
|
class module extends parentRepo{
|
|
|
|
|
|
|
|
protected static function table_name(){ static $table_name = 'module'; return $table_name; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* [1] Fetch all modules
|
|
|
|
*
|
|
|
|
* @return modules<Array> The list of modules
|
|
|
|
* FALSE on error
|
|
|
|
*
|
|
|
|
=========================================================*/
|
|
|
|
public static function getAll(){
|
|
|
|
return Table::get('module')->select('*')->fetch();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* [2] Fetch all modules for the given warehouse
|
|
|
|
*
|
|
|
|
* @id_warehouse<int> UID of the given warehouse
|
|
|
|
*
|
|
|
|
* @return modules<Array> The list of modules
|
|
|
|
* FALSE on error
|
|
|
|
*
|
|
|
|
=========================================================*/
|
2017-09-25 13:29:15 +00:00
|
|
|
public static function getForWarehouse($id_warehouse){
|
2017-09-23 17:05:54 +00:00
|
|
|
|
|
|
|
/* (1) Build request */
|
|
|
|
$modules = Table::get('module')->select('*');
|
|
|
|
$merge = Table::get('module_availability')->whereIdWarehouse($id_warehouse);
|
|
|
|
$merge->join('id_module', $modules);
|
|
|
|
|
|
|
|
return $merge->fetch();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* [3] Fetch all modules for the given machine_cluster
|
|
|
|
*
|
|
|
|
* @id_warehouse<int> UID of the given warehouse
|
|
|
|
* @id_machine_cluster<int> UID of the given machine_cluster
|
|
|
|
*
|
|
|
|
* @return modules<Array> The list of modules
|
|
|
|
* FALSE on error
|
|
|
|
*
|
|
|
|
=========================================================*/
|
2017-09-25 13:29:15 +00:00
|
|
|
public static function getForMachineCluster($id_warehouse, $id_machine_cluster){
|
2017-09-23 17:05:54 +00:00
|
|
|
|
2017-09-25 13:29:15 +00:00
|
|
|
/* (1) On récupère le ETREE de la machine
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
$module = Table::get('module')
|
|
|
|
->select('id_module')
|
|
|
|
->select('name');
|
|
|
|
|
|
|
|
$etree = Table::get('etree')
|
|
|
|
->join('id_module', $module);
|
|
|
|
|
|
|
|
$merge = Table::get('module_merge')
|
|
|
|
->join('id_etree', $etree)
|
2017-09-23 17:05:54 +00:00
|
|
|
->whereIdWarehouse($id_warehouse)
|
|
|
|
->whereIdMachineCluster($id_machine_cluster);
|
|
|
|
|
|
|
|
return $merge->fetch();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|