diff --git a/build/api/module/machineDefault.php b/build/api/module/machineDefault.php index 487893c..34d444b 100755 --- a/build/api/module/machineDefault.php +++ b/build/api/module/machineDefault.php @@ -481,7 +481,7 @@ $sorted_actions[$action['timeout']][] = [ 'id_action' => intval($action['id_action']), 'name' => strtolower($action['name']), - 'previous' => $action['previous'], + 'required' => $action['required'], 'action' => $action['action'] ]; } @@ -495,20 +495,17 @@ /* [4] On récupère la liste des MODULES (puces) =========================================================*/ - $chipsReq = new Repo('chip/getAll', [$_SESSION['WAREHOUSE']['id']]); + $chipsReq = new Repo('chip/getForMachine', [$_SESSION['WAREHOUSE']['id'], $id_machine]); $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->get()==Err::Success) ? $pinsReq->answer() : []; - - $chips[$c]['pins'] = []; - foreach($pins as $p=>$pin) - $chips[$c]['pins'][$p] = intval($pin['pin']); + $chips[$c]['pins'] = explode(',', $chip['pins']); + if( !is_array($chip['pins']) ) + $chips[$c]['pins'] = []; /* [6] On récupère valeurs pour chaque état de chaque PUCE =========================================================*/ @@ -520,7 +517,7 @@ // On met en forme les données : "val1,val2,val3" -> [val1, val2, val3] foreach($states as $s=>$state){ - $chips[$c]['states'][$state['state']] = explode(',', $state['pin_values']); + $chips[$c]['states'][$state['state']] = explode(',', $state['values']); foreach($chips[$c]['states'][$state['state']] as $s2=>$state2) $chips[$c]['states'][$state['state']][$s2] = intval($state2); } @@ -543,6 +540,7 @@ foreach($permissions as $p=>$permission){ $actionList = explode(',', $permission['id_action']); + foreach($actionList as $a=>$action) $actionList[$a] = intval($action);