Exemplo n.º 1
0
 /**
  * @see parent::checkProperty()
  */
 function checkProperty($object)
 {
     $propValue = CMbFieldSpec::checkNumeric($object->{$this->fieldName}, false);
     if ($propValue === null) {
         return "N'est pas une valeur décimale";
     }
     if (!preg_match("/^([0-9]+)(\\.[0-9]{0,4}){0,1}\$/", $propValue)) {
         return "N'est pas un pourcentage";
     }
     return null;
 }
Exemplo n.º 2
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Date de naissance au format : 'YYYY-MM-DD', accepte les mois lunaires." . parent::getLitteralDescription();
 }
Exemplo n.º 3
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Adresse IP au format binaire. " . parent::getLitteralDescription();
 }
 /**
  * @see parent::store()
  */
 function store()
 {
     if (!$this->_id && $this->concept_id) {
         $this->prop = $this->loadRefConcept()->prop;
     }
     // pour la valeur par defaut des enums
     /*if ($this->prop !== null) {
         $this->prop = str_replace("\\", "\\\\", $this->prop);
       }*/
     if (!$this->_id && $this->_make_unique_name) {
         $this->name = self::getUniqueName();
     }
     if ($msg = $this->check()) {
         return $msg;
     }
     /*if (!preg_match('/^[a-z0-9_]+$/i', $this->name)) {
         return "Nom de champ invalide ($this->name)";
       }*/
     $ds = $this->_spec->ds;
     if (!$this->_id) {
         $table_name = $this->getTableName();
         $sql_spec = $this->getSQLSpec(false);
         $query = "ALTER TABLE `{$table_name}` ADD `{$this->name}` {$sql_spec}";
         if (!$ds->query($query)) {
             return "Le champ '{$this->name}' n'a pas pu être ajouté à la table '{$table_name}' (" . $ds->error() . ")";
         }
         $spec_type = $this->_spec_object->getSpecType();
         // ajout de l'index
         if (in_array($spec_type, self::$_indexed_types)) {
             $query = "ALTER TABLE `{$table_name}` ADD INDEX (`{$this->name}`)";
             $ds->query($query);
         }
     } else {
         if ($this->fieldModified("name") || $this->fieldModified("prop")) {
             $table_name = $this->getTableName();
             $sql_spec = $this->getSQLSpec();
             $query = "ALTER TABLE `{$table_name}` CHANGE `{$this->_old->name}` `{$this->name}` {$sql_spec}";
             if (!$ds->query($query)) {
                 return "Le champ '{$this->name}' n'a pas pu être mis à jour (" . $ds->error() . ")";
             }
         }
     }
     $locale = $this->_locale;
     $locale_desc = $this->_locale_desc;
     $locale_court = $this->_locale_court;
     $triggered_data = $this->_triggered_data;
     if ($msg = parent::store()) {
         return $msg;
     }
     // form triggers
     if ($triggered_data) {
         $triggered_object = json_decode($triggered_data, true);
         if (is_array($triggered_object)) {
             foreach ($triggered_object as $_value => $_class_trigger_id) {
                 $trigger = new CExClassFieldTrigger();
                 $trigger->ex_class_field_id = $this->_id;
                 $trigger->trigger_value = $_value;
                 $trigger->loadMatchingObject();
                 if ($_class_trigger_id) {
                     $trigger->ex_class_triggered_id = $_class_trigger_id;
                     $trigger->store();
                 } else {
                     $trigger->delete();
                 }
             }
         }
     }
     // self translations
     if ($locale || $locale_desc || $locale_court) {
         $trans = $this->loadRefTranslation();
         $trans->std = $locale;
         $trans->desc = $locale_desc;
         $trans->court = $locale_court;
         if ($msg = $trans->store()) {
             mbTrace($msg, get_class($this), true);
         }
     }
     return null;
 }
Exemplo n.º 5
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Courriel au format : '*****@*****.**'. " . parent::getLitteralDescription();
 }
Exemplo n.º 6
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Texte long. " . parent::getLitteralDescription();
 }
Exemplo n.º 7
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     $literral = "Nombre entier";
     if ($this->length) {
         $length = $this->length;
         $literral .= " de {$length} chiffres";
     }
     if ($this->max || $this->min) {
         $literral .= "(";
         if ($this->max !== null) {
             $max = $this->max;
             $literral .= " < {$max}";
         }
         if ($this->min !== null) {
             $min = $this->min;
             $literral .= ", > {$min}";
         }
         $literral .= ")";
     }
     return "{$literral}. " . parent::getLitteralDescription();
 }
Exemplo n.º 8
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Date au format : 'YYYY-MM-DD'. " . parent::getLitteralDescription();
 }
Exemplo n.º 9
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Texte contenant du code PHP. " . parent::getLitteralDescription();
 }
Exemplo n.º 10
0
         $details['fields'][$k]['object']['spec'] = $v;
     }
 }
 // Extraction des champs de la BDD
 if ($ds && $object->_spec->table && $ds->loadTable($object->_spec->table)) {
     $details['no_table'] = false;
     $sql = "SHOW COLUMNS FROM `{$object->_spec->table}`";
     $list_fields = $ds->loadList($sql);
     foreach ($list_fields as $curr_field) {
         $details['fields'][$curr_field['Field']]['db'] = array();
         if (!isset($details['fields'][$curr_field['Field']]['object'])) {
             $details['fields'][$curr_field['Field']]['object'] = array();
             $details['fields'][$curr_field['Field']]['object']['spec'] = null;
         }
         $field =& $details['fields'][$curr_field['Field']]['db'];
         $props = CMbFieldSpec::parseDBSpec($curr_field['Type']);
         $field['type'] = $props['type'];
         $field['params'] = $props['params'];
         $field['unsigned'] = $props['unsigned'];
         $field['zerofill'] = $props['zerofill'];
         $field['null'] = $curr_field['Null'] != 'NO';
         $field['default'] = $curr_field['Default'];
         $field['index'] = null;
         $field['extra'] = $curr_field['Extra'];
     }
     // Extraction des Index
     $sql = "SHOW INDEX FROM `{$object->_spec->table}`";
     $list_indexes = $ds->loadList($sql);
     $duplicates = array_duplicates($list_indexes, 'Column_name');
     $details['duplicates'] = $duplicates;
     foreach ($list_indexes as $curr_index) {
Exemplo n.º 11
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Référence de classe, identifiant. " . parent::getLitteralDescription();
 }
Exemplo n.º 12
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     $litteral = "Heure";
     if ($this->duration) {
         $litteral = "Durée";
     }
     $litteral .= " au format 'HH:mm:ss'";
     if ($this->min || $this->max) {
         if ($this->min) {
             $litteral .= ", minimum : '{$this->min}'";
         }
         if ($this->max) {
             $litteral .= ", maximum : '{$this->max}'";
         }
     }
     return "{$litteral}. " . parent::getLitteralDescription();
 }
Exemplo n.º 13
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Code couleur hexadécimal #xxxxxx . " . parent::getLitteralDescription();
 }
Exemplo n.º 14
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     $litteral = "Code";
     if ($this->ccam) {
         $litteral = "Code CCAM de la forme : 'AAAANNN'";
     }
     if ($this->cim10) {
         $litteral = "Code CIM10 de la forme : 'ANNN' ou 'ANNNN'";
     }
     if ($this->adeli) {
         $litteral = "Code ADELI de 9 chiffres dont le dernier assure le contrôle de parité";
     }
     if ($this->insee) {
         $litteral = "Code INSEE de 15 chiffres";
     }
     if ($this->rib) {
         $litteral = "Code RIP de 23 chiffres dont les 2 derniers assurent le contrôle de parité";
     }
     if ($this->siret) {
         $litteral = "Code SIRET de 14 chiffres";
     }
     return "{$litteral}. " . parent::getLitteralDescription();
 }
Exemplo n.º 15
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     $litterals = array();
     foreach ($this->_list as $_list) {
         $litterals[] = "'{$_list}' (" . CAppUI::tr($this->className . "." . $this->fieldName . "." . $_list) . ")";
     }
     return "Chaîne de caractère dont les valeurs possibles sont : " . implode(", ", $litterals) . ". " . parent::getLitteralDescription();
 }
Exemplo n.º 16
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Chaine de caractère de type uri'. " . parent::getLitteralDescription();
 }
Exemplo n.º 17
0
 /**
  * Get the litteral description of the spec
  *
  * @return string
  */
 function getLitteralDescription()
 {
     return "texte formaté en xml'. " . parent::getLitteralDescription();
 }
Exemplo n.º 18
0
 /**
  * @see parent::updatePlainFields()
  */
 function updatePlainFields()
 {
     parent::updatePlainFields();
     if ($this->value !== null) {
         $value_type = $this->loadRefValueType();
         if ($value_type->datatype === "NM") {
             $this->value = CMbFieldSpec::checkNumeric($this->value, false);
         }
     }
 }
 /**
  * Get observation results for this object
  *
  * @param CMbObject $object Reference object
  * @param bool      $utf8   Encode data int UTF-8
  *
  * @return array|CObservationResultSet[]
  */
 static function getResultsFor(CMbObject $object, $utf8 = true)
 {
     $request = new CRequest();
     $request->addTable("observation_result");
     $request->addSelect("*");
     $request->addLJoin(array("observation_result_set" => "observation_result_set.observation_result_set_id = observation_result.observation_result_set_id", "user_log" => "observation_result_set.observation_result_set_id = user_log.object_id AND\r\n                                     user_log.object_class = 'CObservationResultSet' AND user_log.type = 'create'", "users" => "users.user_id = user_log.user_id"));
     $request->addWhere(array("observation_result_set.context_class" => "= '{$object->_class}'", "observation_result_set.context_id" => "= '{$object->_id}'"));
     $request->addOrder("observation_result_set.datetime");
     $request->addOrder("observation_result.observation_result_id");
     $results = $object->_spec->ds->loadList($request->makeSelect());
     $times = array();
     $data = array();
     foreach ($results as $_result) {
         $_time = CMbDate::toUTCTimestamp($_result["datetime"]);
         $times[$_time] = $_result["datetime"];
         $unit_id = $_result["unit_id"] ? $_result["unit_id"] : "none";
         $label = null;
         if ($_result["label_id"]) {
             $label_obj = new CSupervisionGraphAxisValueLabel();
             $label_obj->load($_result["label_id"]);
             $label = $label_obj->title;
         }
         $float_value = $_result["value"];
         $float_value = CMbFieldSpec::checkNumeric($float_value, false);
         $_user_name = $_result["user_first_name"] . " " . $_result["user_last_name"];
         $data[$_result["value_type_id"]][$unit_id][] = array(0 => $_time, 1 => $float_value, "ts" => $_time, "value" => $_result["value"], "datetime" => $_result["datetime"], "file_id" => $_result["file_id"], "set_id" => $_result["observation_result_set_id"], "result_id" => $_result["observation_result_id"], "label_id" => $_result["label_id"], "label" => $utf8 ? utf8_encode($label) : $label, "user_id" => $_result["user_id"], "user" => $utf8 ? utf8_encode($_user_name) : $_user_name);
     }
     return array($data, $times);
 }
Exemplo n.º 20
0
 /**
  * @see parent::updatePlainFields()
  */
 function updatePlainFields()
 {
     $group = CGroups::loadCurrent();
     if ($this->_poids_g) {
         $this->poids = round($this->_poids_g / 1000, 2);
     }
     foreach (self::$list_constantes as $_constant => &$_params) {
         // If field is a
         if ($this->{$_constant} === null && empty($_params["formfields"])) {
             continue;
         }
         if (isset($_params["formfields"])) {
             $conv = 1.0;
             if (isset($_params['conversion'])) {
                 $form_field_unite = '_' . $_params["unit_config"];
                 $_unite = $this->{$form_field_unite};
                 // Si le champ n'a pas de valeur, on regarde en config
                 if (!$_unite) {
                     $_unite = CAppUI::conf('dPpatients CConstantesMedicales ' . $_params["unit_config"], $group);
                 }
                 $conv = self::getConv($_constant, $_unite);
             }
             $_parts = array();
             $_empty = true;
             foreach ($_params["formfields"] as $_formfield) {
                 if (empty($this->{$_formfield}) && !is_numeric($this->{$_formfield})) {
                     break;
                 }
                 $_empty = false;
                 $_value = $this->{$_formfield};
                 $_value = CMbFieldSpec::checkNumeric($_value, false);
                 if ($conv != 1.0) {
                     $_value = round($_value / $conv, self::CONV_ROUND_UP);
                 }
                 $_parts[] = $_value;
             }
             // no value at all
             if ($_empty) {
                 $this->{$_constant} = "";
             } elseif (count($_parts) != count($_params["formfields"])) {
                 $this->{$_constant} = "";
             } else {
                 $this->{$_constant} = implode("|", $_parts);
             }
         }
     }
     parent::updatePlainFields();
 }
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Date et heure au format : 'YYYY-MM-DD HH:mm:ss'. " . parent::getLitteralDescription();
 }
Exemplo n.º 22
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Un texte formaté au format html. " . parent::getLitteralDescription();
 }
Exemplo n.º 23
0
 /**
  * Get database table info
  *
  * @param string $table          Table name
  * @param null   $field          Filter on field name (not sure)
  * @param bool   $reduce_strings Unquote strings and turns them to integer whenever possible
  *
  * @return string[][] Collection of properties
  */
 function getDBstruct($table, $field = null, $reduce_strings = false)
 {
     $list_fields = $this->loadList("SHOW COLUMNS FROM `{$table}`");
     $fields = array();
     foreach ($list_fields as $curr_field) {
         if (!$field) {
             continue;
         }
         $field_name = $curr_field['Field'];
         $fields[$field_name] = array();
         $_field =& $fields[$field_name];
         $props = CMbFieldSpec::parseDBSpec($curr_field['Type']);
         $_field['type'] = $props['type'];
         $_field['unsigned'] = $props['unsigned'];
         $_field['zerofill'] = $props['zerofill'];
         $_field['null'] = $curr_field['Null'] != 'NO';
         $_field['default'] = $curr_field['Default'];
         $_field['index'] = null;
         $_field['extra'] = $curr_field['Extra'];
         if ($reduce_strings && is_array($props['params'])) {
             foreach ($props['params'] as &$v) {
                 if ($v[0] === "'") {
                     $v = trim($v, "'");
                 } else {
                     $v = (int) $v;
                 }
             }
         }
         $_field['params'] = $props['params'];
         if ($field === $field_name) {
             return $_field;
         }
     }
     return $fields;
 }
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Mot de passe. " . parent::getLitteralDescription();
 }
Exemplo n.º 25
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Booléen au format : '0, 1'. " . parent::getLitteralDescription();
 }
Exemplo n.º 26
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     return "Numéro de téléphone (chiffres seulement, pas d'espaces). " . parent::getLitteralDescription();
 }
Exemplo n.º 27
0
 /**
  * @see parent::getLitteralDescription()
  */
 function getLitteralDescription()
 {
     $litteral = "Chaîne de caractère, longueur : ";
     $properties = array();
     if ($this->minLength) {
         $properties[] = "min : {$this->minLength}";
     }
     if ($this->maxLength) {
         $properties[] = "max : {$this->maxLength}";
     }
     if (!$this->maxLength && !$this->minLength && $this->length) {
         $properties[] = "{$this->length} caractères";
     }
     if (!$this->maxLength && !$this->length) {
         $properties[] = "max : 255";
     }
     if (count($properties)) {
         $litteral .= "[" . implode(", ", $properties) . "]";
     }
     return "{$litteral}. " . parent::getLitteralDescription();
 }
Exemplo n.º 28
0
 /**
  * @see parent::getFormHtmlElement()
  */
 function getFormHtmlElement($object, $params, $value, $className)
 {
     $form = CMbArray::extract($params, "form");
     $increment = CMbArray::extract($params, "increment");
     $showPlus = CMbArray::extract($params, "showPlus");
     $fraction = CMbArray::extract($params, "fraction");
     $showFraction = CMbArray::extract($params, "showFraction");
     $deferEvent = CMbArray::extract($params, "deferEvent");
     $bigButtons = CMbArray::extract($params, "bigButtons");
     $readonly = CMbArray::get($params, "readonly");
     $field = CMbString::htmlSpecialChars($this->fieldName);
     $min = CMbArray::extract($params, "min");
     if ($min === null) {
         $min = CMbFieldSpec::checkNumeric($this->min, false);
     }
     $max = CMbArray::extract($params, "max");
     if ($max === null) {
         $max = CMbFieldSpec::checkNumeric($this->max, false);
     }
     $new_value = CMbArray::extract($params, "value");
     if ($new_value !== null) {
         $value = $new_value;
     }
     $decimals = CMbArray::extract($params, "decimals", $this->decimals);
     if ($decimals == null) {
         $decimals = isset($this->precise) ? 4 : 2;
     }
     $step = CMbArray::extract($params, "step");
     $step = CMbFieldSpec::checkNumeric($step, false);
     CMbArray::defaultValue($params, "size", 4);
     if ($form && $increment && !$readonly) {
         $sHtml = $this->getFormElementText($object, $params, ($value >= 0 && $showPlus ? '+' : '') . ($value == 0 && $showPlus ? '0' : $value), $className, "number");
         $sHtml .= '
 <script type="text/javascript">
   Main.add(function(){
     var element = $(document.forms["' . $form . '"]["' . $field . '"]);
     
     if ($(element.form).isReadonly()) return;
     
     element.addSpinner({';
         if ($step) {
             $sHtml .= "step: {$step},";
         }
         if ($decimals) {
             $sHtml .= "decimals: {$decimals},";
         }
         if ($this->pos) {
             $sHtml .= "min: 0,";
         } elseif (isset($min)) {
             $sHtml .= "min: {$min},";
         }
         if (isset($max)) {
             $sHtml .= "max: {$max},";
         }
         if ($deferEvent) {
             $sHtml .= "deferEvent: true,";
         }
         if ($bigButtons) {
             $sHtml .= "bigButtons: true,";
         }
         if ($showPlus) {
             $sHtml .= "showPlus: true,";
         }
         if ($fraction) {
             $sHtml .= "fraction: true,";
         }
         if ($showFraction) {
             $sHtml .= "showFraction: true,";
         }
         $sHtml .= '_:0 // IE rules
     });
   });
 </script>';
     } else {
         $sHtml = $this->getFormElementText($object, $params, $value, $className, "number");
     }
     return $sHtml;
 }
Exemplo n.º 29
0
 /**
  * Check a length strictly positive one-byte value
  * 
  * @param mixed $length Value to check
  * 
  * @return mixed Cast value, null on failure
  */
 static function checkLengthValue($length)
 {
     if (!($length = CMbFieldSpec::checkNumeric($length))) {
         return null;
     }
     if ($length < 1 || $length > 255) {
         return null;
     }
     return $length;
 }