Now there is no more 'pin_merge' so CHIP have their 'pins' in itself
This commit is contained in:
parent
a24e0569da
commit
0945b7da1b
|
@ -11,16 +11,59 @@
|
|||
protected static function table_name(){ static $table_name = 'chip'; return $table_name; }
|
||||
|
||||
|
||||
/* RENVOIE LA LISTE DES CARTES/PUCES DISPONIBLES EN FONCTION DES MODULES DE L'ENTREPOT
|
||||
/* RENVOIE LA LISTE DES CARTES/PUCES DISPONIBLES EN FONCTION DES MODULES DU GROUPE DE MACHINE
|
||||
*
|
||||
* @id_warehouse<int> UID de l'entrepot
|
||||
* @id_machine<int> UID de la machine
|
||||
*
|
||||
* @return chips<Array> Liste des puces/cartes disponibles
|
||||
*
|
||||
*/
|
||||
public static function getAll($id_warehouse){
|
||||
/* [1] On récupère les modules de l'entrepot courant
|
||||
=========================================================*/
|
||||
$module_merge = Table::get('module_merge')
|
||||
->whereIdWarehouse(7);
|
||||
public static function getForMachine($id_warehouse, $id_machine){
|
||||
|
||||
/* (1) On récupère les groupes de la machine
|
||||
---------------------------------------------------------*/
|
||||
$get_clus = new Repo('machine/getClusters', [$id_warehouse, $id_machine]);
|
||||
|
||||
$clusters = $get_clus->answer();
|
||||
|
||||
if( $clusters === false )
|
||||
return [];
|
||||
|
||||
|
||||
/* (2) On récupère les modules associés aux clusters
|
||||
---------------------------------------------------------*/
|
||||
$module_ids = [];
|
||||
|
||||
foreach($clusters as $cluster){
|
||||
|
||||
$get_mods = new Repo('module/getByMachineCluster', [$id_warehouse, $cluster['id_machine_cluster']]);
|
||||
|
||||
$mods = $get_mods->answer();
|
||||
|
||||
// si pas déja -> on ajoute l'id module à la liste
|
||||
if( is_array($mods) && !in_array($mods['id_module'], $module_ids) )
|
||||
$module_ids[] = $mods['id_module'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (3) On récupère la liste des CHIPS
|
||||
---------------------------------------------------------*/
|
||||
$chips = [];
|
||||
foreach($module_ids as $module_id){
|
||||
|
||||
$chip_req = Table::get('chip')
|
||||
->select('*')
|
||||
->whereIdModule($module_id);
|
||||
|
||||
$fetched = $chip_req->fetch();
|
||||
|
||||
// only one by ids
|
||||
$chips[$fetched['id_chip']] = $fetched;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$chip = Table::get('chip')
|
||||
|
|
Loading…
Reference in New Issue