* @category Hospi
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 * @link     http://www.mediboard.org */
CCanDo::checkAdmin();
$now = CMbDT::dateTime();
$service_id = CValue::getOrSession("service_id");
$group = CGroups::loadCurrent();
// Liste des Etablissements
$etablissements = CMediusers::loadEtablissements(PERM_READ);
// Chargement du service à ajouter/editer
$service = new CService();
$service->group_id = $group->_id;
$service->load($service_id);
$service->loadRefsNotes();
// get nb of patients using this service
if ($service->_id) {
    $sejour = new CSejour();
    $where = array();
    $where["service_id"] = " = '{$service->_id}'";
    $where["sortie_prevue"] = "> '{$now}'";
    $where["annule"] = "!= '1'";
    $nb_sejours = $sejour->countList($where);
    CAppUI::stepAjax("Service-msg-%d_use_this_service", $nb_sejours ? UI_MSG_WARNING : UI_MSG_OK, $nb_sejours);
}
$praticiens = CAppUI::$user->loadPraticiens();
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("praticiens", $praticiens);
$smarty->assign("etablissements", $etablissements);