// Chargement de l'affectation sélectionnée $affectation = new CAffectationPersonnel(); if ($affect_id) { $affectation->load($affect_id); $affectation->loadRefObject(); $affectation->_ref_object->loadRefsFwd(); } if ($affect_id == 0) { $user_id = ""; } // Liste des utilisateur faisant parti du personnel $personnel = new CPersonnel(); $groupby = "user_id"; $ljoin["users"] = "users.user_id = personnel.user_id"; $order = "users.user_last_name"; $personnels = $personnel->loadGroupList(array(), $order, null, $groupby, $ljoin); foreach ($personnels as &$personnel) { $mediuser = new CMediusers(); $listUsers[$personnel->user_id] = $mediuser->load($personnel->user_id); } // Calcul des personnel_ids pour chaque user $where = array(); foreach ($listUsers as $key => $user) { $personnel = new CPersonnel(); $where["user_id"] = " = '{$key}'"; $personnels = $personnel->loadList($where); foreach ($personnels as $keyPers => $_personnel) { $listPers[$key][$_personnel->emplacement] = $_personnel->_id; } } $listAffectations = array();
$personnel->loadBackRefs("affectations", "affect_id DESC", "0,20"); $personnel->countBackRefs("affectations"); // Chargement de la liste des affectations pour le filtre $filter = new CPersonnel(); $where = array(); $ljoin["users"] = "users.user_id = personnel.user_id"; $order = "users.user_last_name"; if ($emplacement) { $where["emplacement"] = " = '{$emplacement}'"; $filter->emplacement = $emplacement; } if ($_user_last_name) { $where["user_last_name"] = "LIKE '%{$_user_last_name}%'"; $filter->_user_last_name = $_user_last_name; } if ($_user_first_name) { $where["user_first_name"] = "LIKE '%{$_user_first_name}%'"; $filter->_user_first_name = $_user_first_name; } $filter->nullifyEmptyFields(); $personnels = $filter->loadGroupList($where, $order, null, null, $ljoin); foreach ($personnels as $key => $_personnel) { $_personnel->loadRefUser(); $_personnel->countBackRefs("affectations"); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("personnels", $personnels); $smarty->assign("personnel", $personnel); $smarty->assign("filter", $filter); $smarty->display("vw_edit_personnel.tpl");
/** * Charge le personnel pour l'établissement courant * * @param string $emplacement Emplacement du personnel * @param bool $actif Seulement les actifs * @param bool $groupby Grouper par utilisateur * * @return CPersonnel[] */ static function loadListPers($emplacement, $actif = true, $groupby = false) { $personnel = new CPersonnel(); $where = array(); if (is_array($emplacement)) { $where["emplacement"] = $personnel->_spec->ds->prepareIn($emplacement); } else { $where["emplacement"] = "= '{$emplacement}'"; } // Could have been ambiguous with CMediusers.actif if ($actif) { $where[] = "personnel.actif = '1'"; $where[] = "users_mediboard.actif = '1'"; } $ljoin["users"] = "personnel.user_id = users.user_id"; $ljoin["users_mediboard"] = "users_mediboard.user_id = users.user_id"; $order = "users.user_last_name"; $group = $groupby ? "personnel.user_id" : null; /** @var CPersonnel[] $personnels */ $personnels = $personnel->loadGroupList($where, $order, null, $group, $ljoin); $users = CMbObject::massLoadFwdRef($personnels, "user_id"); CMbObject::massLoadFwdRef($users, "function_id"); foreach ($personnels as $_personnel) { $_personnel->loadRefUser()->loadRefFunction(); } return $personnels; }