[Fix] module machineDefault/init
This commit is contained in:
parent
95365d9f88
commit
713f473c71
|
@ -333,7 +333,7 @@
|
|||
/* [1] On récupére la liste des actions
|
||||
=========================================================*/
|
||||
$actionsReq = new Repo('action/getAll');
|
||||
$actions = ($actionsReq->error==0) ? $actionsReq->answer() : [];
|
||||
$actions = ($actionsReq->error->get()==Err::Success) ? $actionsReq->answer() : [];
|
||||
// var_dump($actionsReq->answer());
|
||||
|
||||
/* [2] On regroupe les actions par TIMEOUT
|
||||
|
@ -347,8 +347,8 @@
|
|||
|
||||
/* (2) On ajoute l'action au TIMEOUT */
|
||||
$sorted_actions[$action['timeout']][] = [
|
||||
'id_action' => $action['id_action'],
|
||||
'name' => $action['name'],
|
||||
'id_action' => intval($action['id_action']),
|
||||
'name' => strtolower($action['name']),
|
||||
'previous' => $action['previous'],
|
||||
'action' => $action['action']
|
||||
];
|
||||
|
@ -357,23 +357,23 @@
|
|||
/* [3] On récupère la liste des états
|
||||
=========================================================*/
|
||||
$globalStatesReq = new Repo('global_state/getAll');
|
||||
$globalStates = ($globalStatesReq->error==0) ? $globalStatesReq->answer() : [];
|
||||
$globalStates = ($globalStatesReq->error->get()==Err::Success) ? $globalStatesReq->answer() : [];
|
||||
|
||||
/* [4] On récupère la liste des MODULES (puces)
|
||||
=========================================================*/
|
||||
$chipsReq = new Repo('chip/getAll', [$_SESSION['WAREHOUSE']['id']]);
|
||||
$chips = ($chipsReq->error==0) ? $chipsReq->answer() : [];
|
||||
$chips = ($chipsReq->error->get()==Err::Success) ? $chipsReq->answer() : [];
|
||||
|
||||
|
||||
foreach($chips as $c=>$chip){
|
||||
/* [5] On récupére la liste des PINS de chaque PUCE
|
||||
=========================================================*/
|
||||
$pinsReq = new Repo('pin_merge/getByIdChip', [$chip['id_chip']]);
|
||||
$pins = ($pinsReq->error==0) ? $pinsReq->answer() : [];
|
||||
$pins = ($pinsReq->error->get()==Err::Success) ? $pinsReq->answer() : [];
|
||||
|
||||
$chips[$c]['pins'] = [];
|
||||
foreach($pins as $p=>$pin)
|
||||
$chips[$c]['pins'][$p] = $pin['pin'];
|
||||
$chips[$c]['pins'][$p] = intval($pin['pin']);
|
||||
|
||||
|
||||
/* [6] On récupère valeurs pour chaque état de chaque PUCE
|
||||
|
@ -381,11 +381,15 @@
|
|||
$chips[$c]['states'] = [];
|
||||
|
||||
$statesReq = new Repo('state/getForChip', [$chip['id_chip']]);
|
||||
$states = ($statesReq->error==0) ? $statesReq->answer() : [];
|
||||
$states = ($statesReq->error->get()==Err::Success) ? $statesReq->answer() : [];
|
||||
|
||||
// On met en forme les données : "val1,val2,val3" -> [val1, val2, val3]
|
||||
foreach($states as $s=>$state)
|
||||
foreach($states as $s=>$state){
|
||||
|
||||
$chips[$c]['states'][$state['state']] = explode(',', $state['pin_values']);
|
||||
foreach($chips[$c]['states'][$state['state']] as $s2=>$state2)
|
||||
$chips[$c]['states'][$state['state']][$s2] = intval($state2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -393,22 +397,25 @@
|
|||
/* [7] On récupère les utilisateurs + accès sur la machine
|
||||
=========================================================*/
|
||||
/* (1) On récupère les utilisateurs et leurs permissions */
|
||||
$permissionsReq = new Repo('action_merge/getPermissions', [
|
||||
$permissionsReq = new Repo('action_merge/getAccess', [
|
||||
$_SESSION['WAREHOUSE']['id'],
|
||||
$id_machine
|
||||
]);
|
||||
$permissions = ($permissionsReq->error==0) ? $permissionsReq->answer() : [];
|
||||
$permissions = ($permissionsReq->error->get()==Err::Success) ? $permissionsReq->answer() : [];
|
||||
|
||||
/* (2) Pour formatte et indexe les permissions par CODE RFID */
|
||||
$indexed_permissions = [];
|
||||
|
||||
|
||||
foreach($permissions as $p=>$permission){
|
||||
$actionList = explode(',', $permission['agg_id_action']);
|
||||
$actionList = explode(',', $permission['id_action']);
|
||||
|
||||
foreach($actionList as $a=>$action)
|
||||
$actionList[$a] = intval($action);
|
||||
|
||||
sort($actionList);
|
||||
|
||||
$indexed_permissions[$permission['code']] = [
|
||||
'id_user' => $permission['id_user'],
|
||||
'id_user' => intval($permission['id_user']),
|
||||
'actions' => $actionList
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue