/**
  * Find the host from a context object
  *
  * @param CMbObject|string $context The context (séjour, rpu, service, etablissement)
  *
  * @return CGroups|CService|CFunctions|string
  */
 static function guessHost($context)
 {
     if ($context === "global") {
         return "global";
     }
     // Etablissement, service ou cabinet (deja un HOST)
     if ($context instanceof CGroups || $context instanceof CService || $context instanceof CFunctions || $context instanceof CBlocOperatoire) {
         return $context;
     }
     // Séjour d'urgence
     if ($context instanceof CSejour && $context->type == "urg") {
         $rpu = $context->loadRefRPU();
         if ($rpu && $rpu->_id) {
             $context = $rpu;
         }
     }
     // Sejour
     if ($context instanceof CSejour) {
         $affectation = $context->loadRefCurrAffectation();
         if (!$affectation->_id) {
             $affectation = $context->loadRefFirstAffectation();
         }
         return $affectation->loadRefService();
     }
     // Urgences
     if ($context instanceof CRPU) {
         /** @var CService $service */
         $service = null;
         if ($context->box_id) {
             return $context->loadRefBox()->loadRefService();
         }
         $sejour = $context->loadRefSejour();
         $affectation = $sejour->loadRefCurrAffectation();
         if (!$affectation->_id) {
             $affectation = $sejour->loadRefFirstAffectation();
         }
         $service = $affectation->loadRefService();
         if ($service && $service->_id) {
             return $service;
         }
         // Recherche du premier service d'urgences actif
         $group_id = CGroups::loadCurrent()->_id;
         $where = array("group_id" => "= '{$group_id}'", "urgence" => "= '1'", "cancelled" => "= '0'");
         $service = new CService();
         $service->loadObject($where, "nom");
         return $service;
     }
     // Utiliser le contexte de la consultation dans la cas des dossiers d'anesth
     if ($context instanceof CConsultAnesth) {
         $context = $context->loadRefConsultation();
     }
     // Utiliser le contexte du cabinet dans le cas des consultations
     if ($context instanceof CConsultation) {
         return $context->loadRefPlageConsult()->loadRefChir()->loadRefFunction();
     }
     return CGroups::loadCurrent();
 }
示例#2
0
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 21168 $
 */
CCanDo::checkRead();
// Récupération des paramètres
$service_id = CValue::postOrSession("service_id");
//Chargement de tous les services
$service = new CService();
$where = array();
$where["group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
$where["cancelled"] = "= '0'";
$services = $service->loadGroupList($where, "nom ASC");
$service_selectionne = new CService();
$where["service_id"] = " = '{$service_id}'";
$service_selectionne->loadObject($where);
$chambre = new CChambre();
$where = array();
$where["service_id"] = " = '{$service_selectionne->_id}'";
$chambres_service = $chambre->loadGroupList($where);
$ljoin = array();
$ljoin["service"] = "service.service_id = chambre.service_id";
$ljoin["emplacement"] = "emplacement.chambre_id = chambre.chambre_id";
$where = array();
$where["annule"] = "= '0'";
$where["emplacement.plan_x"] = "IS NOT NULL";
$where["emplacement.plan_y"] = "IS NOT NULL";
$where["service.service_id"] = " = '{$service_id}'";
$where["service.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
$chambre_places = $chambre->loadGroupList($where, null, null, null, $ljoin);
$chambres_non_placees = $chambres_service;