$debut_periode = "{$a}-{$m}-01"; $fin_periode = CMbDT::transform('+1 month', $debut_periode, '%Y-%m-%d'); $fin_periode = CMbDT::transform('-1 day', $fin_periode, '%Y-%m-%d'); } $tableau_periode = array(); for ($i = 0; $i < CMbDT::daysRelative($debut_periode, $fin_periode) + 1; $i++) { $tableau_periode[$i] = CMbDT::transform('+' . $i . 'day', $debut_periode, '%Y-%m-%d'); } $where = array(); $where[] = "((date_debut >= '{$debut_periode}' AND date_debut <= '{$fin_periode}'" . ")OR (date_fin >= '{$debut_periode}' AND date_fin <= '{$fin_periode}')" . "OR (date_debut <='{$debut_periode}' AND date_fin >= '{$fin_periode}'))"; $where["user_id"] = CSQLDataSource::prepareIn(array_keys($mediusers), $filter->user_id); $plageconge = new CPlageConge(); $plagesconge = array(); $orderby = "user_id"; /** @var CPlageConge[] $plagesconge */ $plagesconge = $plageconge->loadList($where, $orderby); $tabUser_plage = array(); $tabUser_plage_indices = array(); foreach ($plagesconge as $_plage) { $_plage->loadRefUser(); $_plage->_ref_user->loadRefFunction(); $_plage->_deb = CMbDT::daysRelative($debut_periode, $_plage->date_debut); $_plage->_fin = CMbDT::daysRelative($_plage->date_debut, $_plage->date_fin) + 1; $_plage->_duree = CMbDT::daysRelative($_plage->date_debut, $_plage->date_fin) + 1; } $smarty = new CSmartyDP(); $smarty->assign("debut_periode", $debut_periode); $smarty->assign("filter", $filter); $smarty->assign("plagesconge", $plagesconge); $smarty->assign("choix", $choix); $smarty->assign("mediusers", $mediusers);
$_op->loadRefSalle(); $_op->_ref_salle->loadRefBloc(); if ($_op->_ref_salle->_ref_bloc->group_id != $g->_id) { $color = "#748dee"; } ajoutEvent($planning, $_op, $_op->date, $_op->_ref_salle->nom, $color, "operation"); } // plages conge if (CModule::getActive("dPpersonnel")) { $conge = new CPlageConge(); $where_conge = array(); $where_conge["date_debut"] = " <= '{$fin}' "; $where_conge["date_fin"] = " >= '{$debut}' "; $where_conge["user_id"] = " = '{$chirSel}' "; /** @var CPlageConge[] $conges */ $conges = $conge->loadList($where_conge); foreach ($conges as $_conge) { $_dates = array(); $_dates[] = $_conge->date_debut; $_date = $_conge->date_debut; if ($_conge->date_debut != $_conge->date_fin) { while ($_date != $_conge->date_fin) { $_date = CMbDT::date("+1 DAY", $_date); $_dates[] = $_date; } } $libelle = '<h3 style="text-align: center"> CONGES</h3> <p style="text-align: center">' . CMbString::htmlEntities($_conge->libelle) . '</p>'; foreach ($_dates as $_date) { $event = new CPlanningEvent($_conge->_guid . $_date, $_date, 1430, $libelle, "#ddd", true, "hatching", null, false);
* @version $Revision$ */ CCanDo::checkEdit(); $type = CValue::getOrSession("type"); // Week dates $date = CValue::getOrSession("date", CMbDT::date()); $monday = CMbDT::date("last monday", CMbDT::date("+1 DAY", $date)); $sunday = CMbDT::date("next sunday", CMbDT::date("-1 DAY", $date)); // Chargement des conges $plage_conge = new CPlageConge(); $where = array(); $where["date_debut"] = "<= '{$sunday}'"; $where["date_fin"] = ">= '{$monday}'"; $order = "date_debut DESC, date_fin DESC"; /** @var CPlageConge[] $plages_conge */ $plages_conge = $plage_conge->loadList($where, $order); // Début et fin d'activite foreach (CEvenementSSR::getActiveTherapeutes($monday, $sunday) as $_therapeute) { // Pseudo plage de début if (($deb = $_therapeute->deb_activite) && $deb >= $monday) { $plage = CPlageConge::makePseudoPlage($_therapeute->_id, "deb", $monday); $plages_conge[$plage->_id] = $plage; } // Pseudo plage de fin if (($fin = $_therapeute->fin_activite) && $fin <= $sunday) { $plage = CPlageConge::makePseudoPlage($_therapeute->_id, "fin", $sunday); $plages_conge[$plage->_id] = $plage; } } /** @var CSejour[] $sejours */ $sejours = array();
$mediuser = new CMediusers(); $mediusers = $mediuser->loadListFromType(); // load ref function foreach ($mediusers as $_medius) { $_medius->loadRefFunction(); } // Query $where = array(); $where["user_id"] = CSQLDataSource::prepareIn(array_keys($mediusers), $filter->user_id); $debut = CValue::first($filter->date_debut, $filter->date_fin); $fin = CValue::first($filter->date_fin, $filter->date_debut); if ($fin || $debut) { $where["date_debut"] = "<= '{$fin}'"; $where["date_fin"] = ">= '{$debut}'"; } $plages = $filter->loadList($where); // Regrouper par utilisateur $found_users = array(); $plages_per_user = array(); foreach ($plages as $_plage) { $found_users[$_plage->user_id] = $mediusers[$_plage->user_id]; if (!isset($plages_per_user[$_plage->user_id])) { $plages_per_user[$_plage->user_id] = 0; } $plages_per_user[$_plage->user_id]++; } $nbusers = count($found_users); $page = intval(CValue::get('page', 0)); $found_users = array_slice($found_users, $page, 20, true); // Création du template $smarty = new CSmartyDP();