$nowTime = CMbDT::time(); $where = array("chir_id" => "= '{$chirSel}'", "date" => "= '{$today}'", "debut" => "<= '{$nowTime}'", "fin" => ">= '{$nowTime}'"); $plageSel->loadObject($where); } if (!$plageSel->plageconsult_id) { $plageSel->load($plageconsult_id); } else { $plageconsult_id = $plageSel->plageconsult_id; } if ($plageSel->chir_id != $chirSel && $plageSel->remplacant_id != $chirSel) { $plageconsult_id = null; $plageSel = new CPlageconsult(); } CValue::setSession("plageconsult_id", $plageconsult_id); // Liste des consultations a avancer si desistement $count_si_desistement = CConsultation::countDesistementsForDay(array($chirSel)); $nbjours = 7; $dateArr = CMbDT::date("+6 day", $debut); $plage = new CPlageconsult(); //where interv/hp $whereInterv = array(); $whereHP = array(); $where = array(); $where["date"] = "= '{$dateArr}'"; $where["chir_id"] = " = '{$chirSel}'"; $whereInterv["chir_id"] = $whereHP["chir_id"] = " = '{$chirSel}'"; $whereInterv["date"] = $whereHP["date"] = "= '{$dateArr}'"; if (!$plage->countList($where)) { $nbjours--; // Aucune plage le dimanche, on peut donc tester le samedi. $dateArr = CMbDT::date("+5 day", $debut);
// function selected $function_id = CValue::getOrSession("function_id"); $listFnc = array(); if ($function_id) { $listChir = CConsultation::loadPraticiens(PERM_EDIT, $function_id, null, true); foreach ($listChir as $_chir) { $_chir->loadRefFunction(); } } else { $listChir = CConsultation::loadPraticiens(PERM_EDIT); } // Liste des consultations a avancer si desistement $ds = $plage->getDS(); $now = CMbDT::date(); // get desistements $count_si_desistement = CConsultation::countDesistementsForDay($function_id ? array_keys($listChir) : array($chirSel), $now); // Liste des praticiens $fnc = new CFunctions(); $listFnc = $fnc->loadListWithPerms(PERM_READ, array("group_id" => " = '{$group->_id}' "), 'text'); $mediuser = new CMediusers(); foreach ($listFnc as $id => $_fnc) { $users = $mediuser->loadProfessionnelDeSanteByPref(PERM_READ, $_fnc->_id, null, true); if (!count($users)) { unset($listFnc[$id]); } } // if only one function and function_id if (count($listFnc) == 1 && !$chirSel) { $function_id = reset($listFnc)->_id; } // Période
$min_hour = 23; // gathering prat ids $ids = array(); $function = new CFunctions(); $function->load($function_id); if ($function->_id) { $function->loadRefsUsers(); foreach ($function->_ref_users as $_user) { $ids[] = $_user->_id; } } if (!$function_id && $chirSel) { $ids[] = $chirSel; } // Liste des consultations a avancer si desistement $count_si_desistement = CConsultation::countDesistementsForDay($ids, $today); // Période $debut = CValue::getOrSession("debut"); $debut = CMbDT::date("last sunday", $debut); $fin = CMbDT::date("next sunday", $debut); $debut = CMbDT::date("+1 day", $debut); $prev = CMbDT::date("-1 week", $debut); $next = CMbDT::date("+1 week", $debut); $dateArr = CMbDT::date("+6 day", $debut); $nbDays = 7; $listPlage = new CPlageconsult(); $whereInterv = array(); $whereHP = array(); $where = array(); $where["date"] = $whereInterv["date"] = $whereHP["date"] = "= '{$dateArr}'"; $whereInterv["chir_id"] = $whereHP["chir_id"] = "= '{$chirSel}' ";