Identifiant de la machine * * @return count Retourne le compte horaire * */ public function getCount($params){ extract($params); /* (1) Check if machine have motheure etree activated ---------------------------------------------------------*/ $mod = Table::get('module') ->whereName('motheure'); $etree = Table::get('etree') ->whereDaemon('simple') ->join('id_module', $mod); $mc = Table::get('module_merge') ->join('id_etree', $etree); $m = Table::get('machine') ->select('id_machine') ->whereId($id_machine); $mc_m = Table::get('machine_cluster_merge') ->join('id_machine', $m) ->join('id_machine_cluster', $mc); /* (1) If not the etree -> exit */ if( count($mc_m->fetch()) == 0 ) return ['error' => new Error(Err::NoMatchFound)]; /* (2) Get the motor count ---------------------------------------------------------*/ /* (1) Fetch count */ $count = Table::get('motheure') ->unique() ->select('count') ->whereIdMachine($id_machine) ->fetch(); /* (2) If no result -> return 0 */ if( !is_array($count) || !isset($count['count']) ) return ['count' => 0]; /* (3) Else -> return the count */ return [ 'count' => $count['count'] ]; } } ?>