예제 #1
0
 /**
  * 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;
 }
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage PlanningOp
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$chir_id = CValue::get("chir_id", 0);
$codes = CValue::get("codes", "");
$javascript = CValue::get("javascript", true);
$codes = explode("|", $codes);
$result = CTempsOp::getTime($chir_id, $codes);
$temps = $result ? strftime("%Hh%M", $result) : ($temps = "-");
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("temps", $temps);
$smarty->assign("javascript", $javascript);
$smarty->display("inc_get_time.tpl");