/**
  * @param integer $field_id
  *
  * @return CExClassFieldTranslation
  */
 static function tr($field_id)
 {
     static $cache = array();
     $lang = CAppUI::pref("LOCALE");
     if (isset($cache[$lang][$field_id])) {
         return $cache[$lang][$field_id];
     }
     $trans = new self();
     $trans->lang = $lang;
     $trans->ex_class_field_id = $field_id;
     if ($trans->loadMatchingObject()) {
         $cache[$lang][$field_id] = $trans;
     }
     return $trans;
 }
 /**
  * return the sex if found for firstname, else return null
  *
  * @param string $firstname the firstname to have
  *
  * @return string|null sex (u = undefined, f = female, m = male, null = not in base)
  */
 static function getSexFor($firstname)
 {
     $prenom_exploded = preg_split('/[-_ ]+/', $firstname);
     // get the first firstname of composed one
     $first_first_name = addslashes(trim(reset($prenom_exploded)));
     $object = new self();
     $object->firstname = $first_first_name;
     $nb_objects = $object->countMatchingList();
     if ($nb_objects > 1) {
         $object->language = "french";
         $object->loadMatchingObject();
     }
     if (!$object->_id || $object->sex == "u") {
         $object = new self();
         $object->firstname = $first_first_name;
         $object->loadMatchingObject();
     }
     return $object->sex ? $object->sex : "u";
 }
Example #3
0
 /**
  * @see parent::check()
  */
 function check()
 {
     if ($msg = parent::check()) {
         return $msg;
     }
     // Check unique affectation_id except absence (leave / return from leave)
     if ($this->movement_type != "AABS" && $this->movement_type != "RABS") {
         $movement = new self();
         $this->completeField("affectation_id");
         $movement->movement_type = $this->movement_type;
         $movement->affectation_id = $this->affectation_id;
         $movement->cancel = 0;
         $movement->loadMatchingObject();
         if ($this->affectation_id && $movement->_id && $this->_id != $movement->_id) {
             return CAppUI::tr("{$this->_class}-failed-affectation_id") . " : {$this->affectation_id}";
         }
     }
     return null;
 }
Example #4
0
 /**
  * Retourne le nom français du pays
  *
  * @param string $numerique
  *
  * @return mixed
  */
 static function getNomFR($numerique)
 {
     static $noms = array();
     if (array_key_exists($numerique, $noms)) {
         return $noms[$numerique];
     }
     $pays = new self();
     $pays->numerique = $numerique;
     $pays->loadMatchingObject();
     return $noms[$numerique] = $pays->nom_fr;
 }
 /**
  * @see parent::store()
  */
 function store()
 {
     if (!$this->_id && $this->rpu_id) {
         $echelle = new self();
         $echelle->rpu_id = $this->rpu_id;
         $echelle->loadMatchingObject();
         $this->_id = $echelle->_id;
     }
     $glasgow = null;
     if ($this->fieldModified("ouverture_yeux") || $this->fieldModified("rep_motrice") || $this->fieldModified("rep_verbale")) {
         $glasgow = $this->calculGlasgow();
     }
     // Standard Store
     if ($msg = parent::store()) {
         return $msg;
     }
     if ($glasgow != null) {
         $sejour = $this->loadRefRPU()->loadRefSejour();
         $constante = new CConstantesMedicales();
         $constante->_new_constantes_medicales = 1;
         $constante->patient_id = $sejour->loadRefPatient()->_id;
         $constante->context_class = $sejour->_class;
         $constante->context_id = $sejour->_id;
         $constante->glasgow = $glasgow;
         $constante->datetime = 'now';
         if ($msg = $constante->store()) {
             return $msg;
         }
     }
     return null;
 }
Example #6
0
 /**
  * Get match
  *
  * @param string $object_class Object class
  * @param string $tag          Tag name
  * @param string $value        Idex
  * @param string $object_id    Object ID
  *
  * @return CIdSante400 The matching external ID
  */
 static function getMatch($object_class, $tag, $value, $object_id = null)
 {
     $idex = new self();
     $idex->object_class = $object_class;
     $idex->tag = $tag;
     $idex->id400 = $value;
     $idex->object_id = $object_id;
     $idex->loadMatchingObject();
     return $idex;
 }
 /**
  * Get a stock from a product and a host
  *
  * @param CProduct  $product Product
  * @param CMbObject $host    Host
  *
  * @return CProductStockService
  */
 static function getFromProduct(CProduct $product, CMbObject $host)
 {
     $stock = new self();
     $stock->setObject($host);
     $stock->product_id = $product->_id;
     $stock->loadMatchingObject();
     return $stock;
 }
 /**
  * Create a User agent entry from a US string
  *
  * @param string $ua_string User agent string
  *
  * @return self
  */
 static function createFromUA($ua_string)
 {
     $user_agent = new self();
     $user_agent->user_agent_string = substr($ua_string, 0, 255);
     if (!$user_agent->loadMatchingObject()) {
         $browser = self::detect($ua_string);
         $user_agent->browser_name = $browser["Browser"];
         $user_agent->browser_version = $browser["Version"];
         $user_agent->platform_name = $browser["Platform"];
         $user_agent->platform_version = $browser["Platform_Version"];
         $user_agent->device_name = $browser["Device_Name"];
         $user_agent->device_maker = $browser["Device_Maker"];
         $user_agent->pointing_method = $browser["Device_Pointing_Method"];
         switch ($browser["Device_Type"]) {
             case "Mobile Device":
             case "Mobile Phone":
                 $user_agent->device_type = "mobile";
                 break;
             case "Desktop":
                 $user_agent->device_type = "desktop";
                 break;
             case "Tablet":
                 $user_agent->device_type = "tablet";
                 break;
             default:
                 $user_agent->device_type = "unknown";
                 break;
         }
         $user_agent->store();
     }
     return $user_agent;
 }
 /**
  * Finds a list corresponding to a few params
  *
  * @param CMbObject $object       The host object
  * @param string    $date         The date
  * @param string    $type         The type of list
  * @param int       $list_type_id List type ID
  * @param boolean   $load_list    If true, load references for list
  *
  * @return self|self[]
  */
 static function getList(CMbObject $object, $date = null, $type = null, $list_type_id = null, $with_refs = true)
 {
     $list = new self();
     $list->object_class = $object->_class;
     $list->object_id = $object->_id;
     $list->list_type_id = $list_type_id;
     $list->date = $date;
     $list->type = $type;
     $list->loadMatchingObject();
     $list->_ref_object = $object;
     if ($with_refs) {
         $list->loadRefListType()->loadRefsCategories();
     }
     $list->isReadonly();
     return $list;
 }
 /**
  * Load a token by it's hash
  *
  * @param string $hash The hash
  *
  * @return CViewAccessToken
  */
 static function getByHash($hash)
 {
     $token = new self();
     $token->hash = $hash;
     $token->loadMatchingObject();
     return $token;
 }