/** * Charge les listes de choix pour un utilisateur, ou la fonction et l'établissement de l'utilisateur connecté * * @param int $user_id identifiant de l'utilisateur * @param int $compte_rendu_id identifiant du compte-rendu * * @return void */ function loadLists($user_id, $compte_rendu_id = 0) { $where = array(); $user = CMediusers::get($user_id); $user->loadRefFunction(); if ($user_id) { $where[] = "(\n user_id = '{$user->user_id}' OR\n function_id = '{$user->function_id}' OR\n group_id = '{$user->_ref_function->group_id}'\n )"; } else { $compte_rendu = new CCompteRendu(); $compte_rendu->load($compte_rendu_id); $where[] = "(\n function_id IN('{$user->function_id}', '{$compte_rendu->function_id}') OR\n group_id IN('{$user->_ref_function->group_id}', '{$compte_rendu->group_id}')\n )"; } $where[] = $user->getDS()->prepare("`compte_rendu_id` IS NULL OR compte_rendu_id = %", $compte_rendu_id); $order = "user_id, function_id, group_id, nom ASC"; $lists = new CListeChoix(); $this->allLists = $lists->loadList($where, $order); foreach ($this->allLists as $list) { /** @var CListeChoix $list */ $this->addList($list->nom); } }
<?php /** * Modification de liste de choix * * @category CompteRendu * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:\$ * @link http://www.mediboard.org */ CCanDo::checkRead(); // Liste sélectionnée $liste_id = CValue::getOrSession("liste_id"); $liste = new CListeChoix(); $liste->load($liste_id); // Création du template $smarty = new CSmartyDP(); $smarty->assign("liste", $liste); $smarty->display("inc_list_choix.tpl");
$_POST["_source"] = CCompteRendu::replaceComponent($_POST["_source"], $header_id); } if ($footer_id != $cr->footer_id) { $_POST["_source"] = CCompteRendu::replaceComponent($_POST["_source"], $footer_id, "footer"); } } } } // Application des listes de choix $fields = array(); $values = array(); if (isset($_POST["_CListeChoix"])) { $listes = $_POST["_CListeChoix"]; foreach ($listes as $list_id => $options) { $options = array_map(array('CMbString', 'htmlEntities'), $options); $list = new CListeChoix(); $list->load($list_id); $is_empty = false; if ($check_to_empty_field && isset($_POST["_empty_list"][$list_id]) || !$check_to_empty_field && !isset($_POST["_empty_list"][$list_id])) { $values[] = ""; $is_empty = true; } else { if ($options === array(0 => "undef")) { continue; } CMbArray::removeValue("undef", $options); $values[] = nl2br(implode(", ", $options)); } $nom = CMbString::htmlEntities($list->nom, ENT_QUOTES); if ($is_empty) { $fields[] = "<span class=\"name\">[Liste - " . $nom . "]</span>";
<?php /** * Interface des listes de choix * * @category CompteRendu * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:\$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $filtre = new CListeChoix(); $filtre->user_id = CView::get("user_id", "num", true); $filtre->function_id = CView::get("function_id", "num", true); if (!$filtre->user_id && !$filtre->function_id) { $filtre->user_id = CMediusers::get()->_id; } $filtre->loadRefUser(); $filtre->loadRefFunction(); $module = CModule::getActive("dPcompteRendu"); $is_admin = $module && $module->canAdmin(); $access_function = $is_admin || CAppUI::conf("compteRendu CListeChoix access_function"); // Création du template $smarty = new CSmartyDP(); $smarty->assign("filtre", $filtre); $smarty->assign("access_function", $access_function); $smarty->display("vw_idx_listes.tpl");
* Export CSV des listes de choix * * @category CompteRendu * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:\$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $list = CValue::get('ids', array()); $owner_guid = CValue::get('owner_guid'); if (!is_array($list)) { $list = explode("-", $list); } $owner_view = ""; if ($owner_guid) { $owner = CMbObject::loadFromGuid($owner_guid); $owner_view = " - {$owner->_view}"; } $out = fopen('php://output', 'w'); header("Content-Type: application/csv"); header("Content-Disposition: attachment; filename=\"Listes de choix{$owner_view}.csv\""); $liste_choix = new CListeChoix(); fputcsv($out, array_keys($liste_choix->getCSVFields())); foreach ($list as $id) { if (!$liste_choix->load($id)) { continue; } fputcsv($out, $liste_choix->getCSVFields()); }
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:\$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $user_id = CValue::getOrSession("user_id"); $liste_id = CValue::getOrSession("liste_id"); // Utilisateurs disponibles $user = CMediusers::get($user_id); // Accès aux listes de choix de la fonction et de l'établissement $module = CModule::getActive("dPcompteRendu"); $is_admin = $module && $module->canAdmin(); $access_function = $is_admin || CAppUI::conf("compteRendu CListeChoix access_function"); $access_group = $is_admin || CAppUI::conf("compteRendu CListeChoix access_group"); // Liste sélectionnée $liste = new CListeChoix(); $liste->user_id = $user->_id; $liste->load($liste_id); if ($liste->_id) { if ($liste->function_id && !$access_function) { CAppUI::redirect("m=system&a=access_denied"); } if ($liste->group_id && !$access_group) { CAppUI::redirect("m=system&a=access_denied"); } } $liste->loadRefOwner(); $liste->loadRefModele(); $liste->loadRefsNotes(); $modeles = CCompteRendu::loadAllModelesFor($user->_id, "prat", null, "body"); $owners = $user->getOwners();
$user_id = $function_id = $group_id = null; switch ($owner->_class) { case "CMediusers": $user_id = $owner->_id; break; case "CFunctions": $function_id = $owner->_id; break; case "CGroups": $group_id = $owner->_id; } // Object columns on the first line $cols = fgetcsv($fp); // Each line while ($line = fgetcsv($fp)) { $object = new CListeChoix(); foreach ($cols as $index => $field) { $object->{$field} = $line[$index] === "" ? null : $line[$index]; } $object->user_id = $user_id; $object->function_id = $function_id; $object->group_id = $group_id; $alreadyExists = $object->loadMatchingObjectEsc(); if ($msg = $object->store()) { CAppUI::setMsg($msg); continue; } if ($alreadyExists) { CAppUI::setMsg("Liste de choix déjà présente"); } else { CAppUI::setMsg("CAideSaisie-msg-create");
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:\$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $liste_id = CValue::getOrSession("liste_id"); $user_id = CValue::getOrSession("user_id"); $function_id = CValue::getOrSession("function_id"); if ($user_id) { $user = CMediusers::get($user_id); $owners = $user->getOwners(); } else { $function = new CFunctions(); $function->load($function_id); $owners = $function->getOwners(); $user_id = ""; } $listes = CListeChoix::loadAllFor($user_id, $function_id); // Modèles associés foreach ($listes as $_listes) { foreach ($_listes as $_liste) { /** @var $_liste CListeChoix */ $_liste->loadRefModele(); } } // Création du template $smarty = new CSmartyDP(); $smarty->assign("liste_id", $liste_id); $smarty->assign("owners", $owners); $smarty->assign("listes", $listes); $smarty->display("inc_list_listes_choix.tpl");