static function loadValuesFromDB()
 {
     global $dPconfig;
     $ds = CSQLDataSource::get("std");
     $request = "SELECT * FROM config_db WHERE config_db.key " . CSQLDataSource::prepareNotIn(self::$forbidden_values);
     $configs = $ds->loadList($request);
     foreach ($configs as $_value) {
         CMbConfig::loadConf(explode(" ", $_value['key']), $_value['value'], $dPconfig);
     }
     // Réinclusion du config_overload
     if (is_file(__DIR__ . "/config_overload.php")) {
         include __DIR__ . "/config_overload.php";
     }
 }
Beispiel #2
0
// Cas de l'affichage des lits libres
//
if ($typeVue == 0) {
    // Recherche de tous les lits disponibles
    $sql = "SELECT lit.lit_id\r\n          FROM affectation\r\n          LEFT JOIN lit ON lit.lit_id = affectation.lit_id\r\n          LEFT JOIN chambre ON lit.chambre_id = chambre.chambre_id\r\n          WHERE '{$date_recherche}' BETWEEN affectation.entree AND affectation.sortie\r\n          AND chambre.annule = '0'\r\n          AND lit.annule = '0'\r\n          AND affectation.effectue = '0'\r\n          GROUP BY lit.lit_id";
    $occupes = $ds->loadlist($sql);
    $arrayIn = array();
    foreach ($occupes as $key => $occupe) {
        $arrayIn[] = $occupe["lit_id"];
    }
    $notIn = count($arrayIn) > 0 ? implode(', ', $arrayIn) : 0;
    $libre = array();
    if (is_array($services_ids) && count($services_ids)) {
        $sql = "SELECT lit.chambre_id, lit.lit_id, lit.nom AS lit, chambre.nom AS chambre, chambre.caracteristiques as caracteristiques, service.nom AS service, MIN(affectation.entree) AS limite\r\n            FROM lit\r\n            LEFT JOIN affectation ON affectation.lit_id = lit.lit_id\r\n            AND (affectation.entree > '{$date_recherche}' OR affectation.entree IS NULL)\r\n            LEFT JOIN chambre ON chambre.chambre_id = lit.chambre_id\r\n            LEFT JOIN service ON service.service_id = chambre.service_id\r\n            WHERE lit.lit_id NOT IN({$notIn})\r\n            AND chambre.annule = '0'\r\n            AND lit.annule = '0'\r\n            AND service.group_id = '{$group->_id}'\r\n            AND service.service_id " . CSQLDataSource::prepareIn($services_ids) . "\r\n            GROUP BY lit.lit_id\r\n            ORDER BY service.nom, chambre.nom, lit.nom, limite DESC";
        $libre = $ds->loadList($sql);
        $sql = "SELECT lit.chambre_id, patients.sexe, lit.nom AS lit, chambre.nom AS chambre, service.nom AS service\r\n            FROM affectation\r\n            LEFT JOIN lit ON lit.lit_id = affectation.lit_id\r\n            LEFT JOIN chambre ON chambre.chambre_id = lit.chambre_id\r\n            LEFT JOIN service ON chambre.service_id = chambre.service_id\r\n            LEFT JOIN sejour ON sejour.sejour_id = affectation.sejour_id\r\n            LEFT JOIN patients ON patients.patient_id = sejour.patient_id\r\n            WHERE '{$date_recherche}' BETWEEN affectation.entree AND affectation.sortie\r\n            AND affectation.lit_id IS NOT NULL\r\n            AND lit.chambre_id " . CSQLDataSource::prepareIn(CMbArray::pluck($libre, "chambre_id")) . " AND lit.lit_id " . CSQLDataSource::prepareNotIn(CMbArray::pluck($libre, "lit_id")) . "\r\n           GROUP BY lit.lit_id";
        $autre_sexe_chambre = $ds->loadList($sql);
        foreach ($autre_sexe_chambre as $key => $_autre) {
            $autre_sexe_chambre[$_autre["chambre_id"]] = $_autre;
        }
    }
} else {
    if ($typeVue == 1) {
        // Recherche des patients du praticien
        // Qui ont une affectation
        $listAff = array("Aff" => array(), "NotAff" => array());
        if (is_array($services_ids) && count($services_ids)) {
            $affectation = new CAffectation();
            $ljoin = array("lit" => "affectation.lit_id = lit.lit_id", "chambre" => "chambre.chambre_id = lit.chambre_id", "service" => "service.service_id = chambre.service_id", "sejour" => "sejour.sejour_id   = affectation.sejour_id");
            $where = array("affectation.entree" => "< '{$date_recherche}'", "affectation.sortie" => "> '{$date_recherche}'", "service.service_id" => CSQLDataSource::prepareIn($services_ids), "sejour.praticien_id" => CSQLDataSource::prepareIn(array_keys($listPrat), $selPrat), "sejour.group_id" => "= '{$group->_id}'");
            $order = "service.nom, chambre.nom, lit.nom";
 /**
  * Chargement de la liste des utilisateurs à partir de leur type
  *
  * @param array  $user_types  Tableau des types d'utilisateur
  * @param int    $permType    Niveau de permission
  * @param int    $function_id Filtre sur une fonction spécifique
  * @param string $name        Filtre sur un nom d'utilisateur
  * @param bool   $actif       Filtre sur les utilisateurs actifs
  * @param bool   $secondary   Inclut les fonctions secondaires dans le filtre sur les fonctions
  * @param bool   $reverse     Utilise les types en inclusion ou en exclusion
  *
  * @return CMediusers[]
  */
 function loadListFromType($user_types = null, $permType = PERM_READ, $function_id = null, $name = null, $actif = true, $secondary = false, $reverse = false)
 {
     $where = array();
     $ljoin = array();
     if ($actif) {
         $where["users_mediboard.actif"] = "= '1'";
     }
     // Filters on users values
     $ljoin["users"] = "`users`.`user_id` = `users_mediboard`.`user_id`";
     if ($name) {
         $where["users.user_last_name"] = "LIKE '{$name}%'";
     }
     $ljoin["functions_mediboard"] = "functions_mediboard.function_id = users_mediboard.function_id";
     $ljoin["secondary_function"] = "secondary_function.user_id = users_mediboard.user_id";
     $ljoin[] = "functions_mediboard AS sec_fnc_mb ON sec_fnc_mb.function_id = secondary_function.function_id";
     if ($function_id) {
         if ($secondary) {
             $where[] = "'{$function_id}' IN (users_mediboard.function_id, secondary_function.function_id)";
         } else {
             $where["users_mediboard.function_id"] = "= '{$function_id}'";
         }
     }
     // Filter on current group or users in secondaries functions
     $group = CGroups::loadCurrent();
     $where[] = "functions_mediboard.group_id = '{$group->_id}' OR sec_fnc_mb.group_id = '{$group->_id}'";
     // Filter on user type
     if (is_array($user_types)) {
         $utypes_flip = array_flip(CUser::$types);
         foreach ($user_types as &$_type) {
             $_type = $utypes_flip[$_type];
         }
         $where["users.user_type"] = $reverse ? CSQLDataSource::prepareNotIn($user_types) : CSQLDataSource::prepareIn($user_types);
     }
     $order = "`users`.`user_last_name`, `users`.`user_first_name`";
     $group_by = array("user_id");
     // Get all users
     $mediuser = new CMediusers();
     /** @var CMediusers[] $mediusers */
     $mediusers = $mediuser->loadList($where, $order, null, $group_by, $ljoin);
     // Mass fonction standard preloading
     self::massLoadFwdRef($mediusers, "function_id");
     self::massCountBackRefs($mediusers, "secondary_functions");
     // Filter a posteriori to unable mass preloading of function
     self::filterByPerm($mediusers, $permType);
     // Associate cached function
     foreach ($mediusers as $_mediuser) {
         $_mediuser->loadRefFunction();
     }
     return $mediusers;
 }
Beispiel #4
0
 /**
  * Load Sejour for technicien at a date
  *
  * @param int  $technicien_id           Le technicien concerné
  * @param date $date                    La date de référence
  * @param bool $show_cancelled_services Afficher ou non les services inactifs
  *
  * @return CSejour[]
  */
 static function loadSejoursSSRfor($technicien_id, $date, $show_cancelled_services = true)
 {
     $group = CGroups::loadCurrent();
     // Masquer les services inactifs
     if (!$show_cancelled_services) {
         $service = new CService();
         $service->group_id = $group->_id;
         $service->cancelled = "1";
         $services = $service->loadMatchingList();
         $where[] = "sejour.service_id IS NULL OR sejour.service_id " . CSQLDataSource::prepareNotIn(array_keys($services));
     }
     $where["type"] = "= 'ssr'";
     $where["group_id"] = "= '{$group->_id}'";
     $where["annule"] = "= '0'";
     $where["bilan_ssr.technicien_id"] = $technicien_id ? "= '{$technicien_id}'" : "IS NULL";
     $leftjoin["bilan_ssr"] = "bilan_ssr.sejour_id = sejour.sejour_id";
     return CSejour::loadListForDate($date, $where, "entree_reelle", null, null, $leftjoin);
 }
if ($order_col == "praticien_id") {
    $order = "sejour.praticien_id {$order_way}, patients.nom, patients.prenom";
}
if ($order_col == "libelle") {
    $order = "sejour.libelle {$order_way}, patients.nom, patients.prenom";
}
if ($order_col == "service_id") {
    $order = "sejour.service_id {$order_way}, patients.nom, patients.prenom";
}
// Masquer les services inactifs
if (!$show_cancelled_services) {
    $service = new CService();
    $service->group_id = $group->_id;
    $service->cancelled = "1";
    $services = $service->loadMatchingList();
    $where[] = " sejour.service_id IS NULL OR sejour.service_id " . CSQLDataSource::prepareNotIn(array_keys($services));
}
$sejours = CSejour::loadListForDate($date, $where, $order, null, null, $ljoin);
// Filtre sur les services
$services = array();
$praticiens = array();
$kines = array();
$sejours_by_kine = array("" => array());
CStoredObject::massLoadFwdRef($sejours, "praticien_id");
CStoredObject::massLoadBackRefs($sejours, "bilan_ssr");
// Filtres des séjours
foreach ($sejours as $_sejour) {
    // Filtre sur service
    $service = $_sejour->loadFwdRef("service_id", true);
    $services[$service->_id] = $service;
    if ($filter->service_id && $_sejour->service_id != $filter->service_id) {
 * @package    Mediboard
 * @subpackage Hospi
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$keywords = CValue::get("keywords", "%%");
$lit_id = CValue::get("lit_id");
$lit = new C**t();
$lit->load($lit_id);
$liaisons_items = $lit->loadRefsLiaisonsItems();
$items_prestations = CMbObject::massLoadFwdRef($liaisons_items, "item_prestation_id");
$items_prestations_ids = CMbArray::pluck($items_prestations, "object_id");
// Un niveau unique par prestation
$where = array();
$where["object_id"] = CSQLDataSource::prepareNotIn($items_prestations_ids);
$where["object_class"] = " = 'CPrestationJournaliere'";
$where["group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
$ljoin = array();
$ljoin["prestation_journaliere"] = "prestation_journaliere.prestation_journaliere_id = item_prestation.object_id";
$item_prestation = new CItemPrestation();
/** @var CItemPrestation[] $items_prestations */
$items_prestations = $item_prestation->seek($keywords, $where, null, null, $ljoin);
$items_by_prestation = array();
$prestations = array();
foreach ($items_prestations as $_item_prestation) {
    if (!isset($items_by_prestation[$_item_prestation->object_id])) {
        $items_by_prestation[$_item_prestation->object_id] = array();
    }
    $items_by_prestation[$_item_prestation->object_id][$_item_prestation->rank] = $_item_prestation;
    if (!isset($prestations[$_item_prestation->object_id])) {