/** * Durée moyenne d'intervention * * @param int $chir_id [optional] * @param array|string $ccam [optional] * * @return int|bool Durée en minutes, 0 si aucune intervention, false si temps non calculé */ static function getTime($chir_id = 0, $ccam = null) { $where = array(); $total = array(); $total["occup_somme"] = 0; $total["nbInterventions"] = 0; $where["chir_id"] = "= '{$chir_id}'"; if (is_array($ccam)) { foreach ($ccam as $code) { $where[] = "ccam LIKE '%" . strtoupper($code) . "%'"; } } elseif ($ccam) { $where["ccam"] = "LIKE '%" . strtoupper($ccam) . "%'"; } $temp = new CTempsOp(); if (null == ($liste = $temp->loadList($where))) { return false; } foreach ($liste as $temps) { $total["nbInterventions"] += $temps->nb_intervention; $total["occup_somme"] += $temps->nb_intervention * strtotime($temps->occup_moy); } if ($total["nbInterventions"]) { $time = $total["occup_somme"] / $total["nbInterventions"]; } else { $time = 0; } return $time; }