/** * @see parent::getHtmlValue() */ function getHtmlValue($object, $smarty = null, $params = array()) { $value = $object->{$this->fieldName}; // Empty value: no paragraph if (!$value) { return ""; } // Truncate case: no breakers but inline bullets instead if ($truncate = CValue::read($params, "truncate")) { $value = CMbString::truncate($value, $truncate === true ? null : $truncate); $value = CMbString::nl2bull($value); return CMbString::htmlSpecialChars($value); } // Markdown case: full delegation if ($this->markdown) { // In order to prevent from double escaping $content = CMbString::markdown(html_entity_decode($value)); return "<div class='markdown'>{$content}</div>"; } // Standard case: breakers and paragraph enhancers $text = ""; $value = str_replace(array("\r\n", "\r"), "\n", $value); $paragraphs = preg_split("/\n{2,}/", $value); foreach ($paragraphs as $_paragraph) { if (!empty($_paragraph)) { $_paragraph = nl2br(CMbString::htmlSpecialChars($_paragraph)); $text .= "<p>{$_paragraph}</p>"; } } return $text; }
/** * @see parent::getValue() */ function getValue($object, $smarty = null, $params = array()) { if ($this->class) { return CMbString::htmlSpecialChars(CAppUI::tr($object->{$this->fieldName})); } return parent::getValue($object, $smarty, $params); }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $field = CMbString::htmlSpecialChars($this->fieldName); $value = CMbString::htmlSpecialChars($value); $class = CMbString::htmlSpecialChars("{$className} {$this->prop}"); $form = CMbArray::extract($params, "form"); $extra = CMbArray::makeXmlAttributes($params); return "<input type=\"tel\" name=\"{$field}\" value=\"{$value}\" class=\"{$class} styled-element\" {$extra} />"; }
/** * Process the exported data * * @param string $export Data * @param string $label Add an optionnal label * @param bool $log Log to file or echo data * * @return int The size of the data written in the log file **/ function processLog($export, $label = null, $log = false) { $export = CMbString::htmlSpecialChars($export); $time = date("Y-m-d H:i:s"); $msg = "\n<pre>[{$time}] {$label}: {$export}</pre>"; if ($log) { return file_put_contents(LOG_PATH, $msg, FILE_APPEND); } echo $msg; return null; }
/** * Process the exported data * * @param string $export Data * @param string $label Add an optionnal label * @param bool $onlyPlainField Only get DB fields and there values if export is object * * @return int The size of the data written in the log file **/ static function log($export, $label = null, $onlyPlainField = false) { if (!CAppUI::conf("debug")) { return null; } if ($export instanceof CMbObject && $onlyPlainField) { $export = $export->getPlainFields(); } $export = print_r($export, true); $export = CMbString::htmlSpecialChars($export); $time = date("Y-m-d H:i:s"); $msg = "\n<pre>[{$time}] {$label}: {$export}</pre>"; return file_put_contents(DEBUG_PATH, $msg, FILE_APPEND); }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $field = CMbString::htmlSpecialChars($this->fieldName); $form = CMbArray::extract($params, "form"); $extra = CMbArray::makeXmlAttributes($params); $readonly = CMbArray::extract($params, "readonly"); $default_color = $this->default ? $this->default : "ffffff"; $reset_value = $this->notNull ? $default_color : ""; $bg_reset = $reset_value ? "#{$reset_value}" : "transparent"; $value = !$value && ($this->notNull || $this->default) ? $default_color : $value; $sHtml = "\n <input type=\"text\" class=\"color_picker\" name=\"{$field}\" value=\"{$value}\" {$extra} />\n <button type=\"button\" onclick=\"var elem = \$(this).previous('input'); \$V(elem, '{$reset_value}', true); elem.setStyle({backgroundColor: '{$bg_reset}'});\" class='cancel notext'></button>\n "; if ($form && !$readonly) { $js_params = "{}"; if (!$this->notNull) { $js_params = "{required:false}"; } $sHtml .= "<script type=\"text/javascript\">\n Main.add(function(){\n var _e = getForm('" . $form . "').elements['" . $field . "'];\n new jscolor.color(_e, {$js_params});\n })\n </script>"; } return $sHtml; }
/** * Ajoute un champ * * @param string $field nom du champ * @param string $value [optional] * @param array $options [optional] * @param boolean $htmlescape [optional] * * @return void */ function addProperty($field, $value = null, $options = array(), $htmlescape = true) { if ($htmlescape) { $value = CMbString::htmlSpecialChars($value); } $sec = explode(' - ', $field, 3); switch (count($sec)) { case 3: $section = $sec[0]; $item = $sec[1]; $sub_item = $sec[2]; break; case 2: $section = $sec[0]; $item = $sec[1]; $sub_item = ''; break; default: trigger_error("Error while exploding the string", E_USER_ERROR); return; } if (!array_key_exists($section, $this->sections)) { $this->sections[$section] = array(); } if ($sub_item != '' && !array_key_exists($item, $this->sections[$section])) { $this->sections[$section][$item] = array(); } if ($sub_item == '') { $this->sections[$section][$field] = array("view" => CMbString::htmlEntities($item), "field" => $field, "value" => $value, "fieldHTML" => CMbString::htmlEntities("[{$field}]", ENT_QUOTES), "valueHTML" => $value, "shortview" => $section . " - " . $item, "options" => $options); } else { $this->sections[$section][$item][$sub_item] = array("view" => CMbString::htmlEntities($sub_item), "field" => $field, "value" => $value, "fieldHTML" => CMbString::htmlEntities("[{$field}]", ENT_QUOTES), "valueHTML" => $value, "shortview" => $section . " - " . $item . " - " . $sub_item, "options" => $options); } // Barcode if (isset($options["barcode"])) { if ($sub_item) { $_field =& $this->sections[$section][$item][$sub_item]; } else { $_field =& $this->sections[$section][$field]; } if ($this->valueMode) { $src = $this->getBarcodeDataUri($_field['value'], $options["barcode"]); } else { $src = $_field['fieldHTML']; } $_field["field"] = ""; if ($options["barcode"]["title"]) { $_field["field"] .= $options["barcode"]["title"] . "<br />"; } $_field["field"] .= "<img alt=\"{$field}\" src=\"{$src}\" "; foreach ($options["barcode"] as $name => $attribute) { $_field["field"] .= " {$name}=\"{$attribute}\""; } $_field["field"] .= "/>"; } // Custom data if (isset($options["data"])) { $_field =& $this->sections[$section][$item][$sub_item]; $data = $options["data"]; $view = $_field['field']; $_field["field"] = "[<span data-data=\"{$data}\">{$view}</span>]"; } // Image (from a CFile object) if (isset($options["image"])) { $_field =& $this->sections[$section][$field]; $data = ""; if ($this->valueMode) { $file = new CFile(); $file->load($_field['value']); if ($file->_id) { // Resize the image CAppUI::requireLibraryFile("phpThumb/phpthumb.class"); include_once "lib/phpThumb/phpThumb.config.php"; $thumbs = new phpthumb(); $thumbs->setSourceFilename($file->_file_path); $thumbs->w = 640; $thumbs->f = "png"; $thumbs->GenerateThumbnail(); $data = "data:" . $file->file_type . ";base64," . urlencode(base64_encode($thumbs->IMresizedData)); } } $src = $this->valueMode ? $data : $_field['fieldHTML']; $_field["field"] = "<img src=\"" . $src . "\" />"; } }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $form = CMbArray::extract($params, "form"); // needs to be extracted $field = CMbString::htmlSpecialChars($this->fieldName); $extra = CMbArray::makeXmlAttributes($params); $sHtml = '<input type="password" name="' . $field . '" class="' . CMbString::htmlSpecialChars(trim($className . ' ' . $this->prop)) . ' styled-element" '; if ($this->revealable) { $sHtml .= ' value="' . CMbString::htmlSpecialChars($value) . '" '; } $sHtml .= $extra . ' />'; if ($this->revealable) { $sHtml .= '<button class="lookup notext" type="button" onclick="var i=$(this).previous(\'input\');i.type=(i.type==\'password\')?\'text\':\'password\'"></button>'; } if ($this->randomizable) { $random_call = "getRandomPassword('{$object->_class}', '{$field}');"; $title = CAppUI::tr("common-action-Get random password"); $sHtml .= '<button class="change notext" type="button" onclick="' . $random_call . '" title="' . $title . '"></button>'; } $sHtml .= '<span id="' . $field . '_message"></span>'; return $sHtml; }
/** * Return a string of XML attributes based on given array key-value pairs * * @param array $array The source array * * @return string String attributes like 'key1="value1" ... keyN="valueN"' */ static function makeXmlAttributes($array) { $return = ''; foreach ($array as $key => $value) { if ($value !== null) { $value = trim(CMbString::htmlSpecialChars($value)); $return .= "{$key}=\"{$value}\" "; } } return $return; }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $sHtml = ""; $field = CMbString::htmlSpecialChars($this->fieldName); $typeEnum = CMbArray::extract($params, "typeEnum", $this->typeEnum ? $this->typeEnum : "radio"); $separator = CMbArray::extract($params, "separator"); $disabled = CMbArray::extract($params, "disabled"); $readonly = CMbArray::extract($params, "readonly"); $default = CMbArray::extract($params, "default", $this->default); $form = CMbArray::extract($params, "form"); // needs to be extracted $className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}")); $extra = CMbArray::makeXmlAttributes($params); // Empty label if ($emptyLabel = CMbArray::extract($params, "emptyLabel")) { $emptyLabel = "— " . CAppUI::tr($emptyLabel); } switch ($typeEnum) { case "radio": // Attributes for all inputs $attributes = array("type" => "radio", "name" => $field); if (null === $value) { $value = "{$default}"; } for ($i = 1; $i >= 0; $i--) { $attributes["value"] = "{$i}"; $attributes["checked"] = $value === "{$i}" ? "checked" : null; $attributes["disabled"] = $disabled === "{$i}" || $readonly ? "disabled" : null; $attributes["class"] = $className; $xmlAttributes = CMbArray::makeXmlAttributes($attributes); $sHtml .= "\n<input {$xmlAttributes} {$extra} />"; $sTr = CAppUI::tr("bool.{$i}"); $sHtml .= "\n<label for=\"{$field}_{$i}\">{$sTr}</label> "; if ($separator && $i != 0) { $sHtml .= "\n{$separator}"; } } return $sHtml; case "checkbox": $disabled = $readonly ? "disabled=\"1\"" : $disabled; if (null === $value) { $value = "{$default}"; } if ($value !== null && $value == 1) { $checked = " checked=\"checked\""; } else { $checked = ""; $value = "0"; } $sHtml = '<input type="checkbox" name="__' . $field . '" onclick="$V(this.form.' . $field . ', $V(this)?1:0);" ' . $checked . ' ' . $disabled . ' />'; $sHtml .= '<input type="hidden" name="' . $field . '" ' . $extra . ' value="' . $value . '" />'; return $sHtml; case "select": $disabled = $readonly ? "disabled=\"1\"" : $disabled; $sHtml = "<select name=\"{$field}\" class=\"{$className}\" {$disabled} {$extra}>"; if ($emptyLabel) { if ($value === null) { $sHtml .= "\n<option value=\"\" selected=\"selected\">{$emptyLabel}</option>"; } else { $sHtml .= "\n<option value=\"\">{$emptyLabel}</option>"; } } foreach ($this->_locales as $key => $item) { if ($value !== null && $value === "{$key}" || $value === null && "{$key}" === "{$this->default}" && !$emptyLabel) { $selected = " selected=\"selected\""; } else { $selected = ""; } $sHtml .= "\n<option value=\"{$key}\" {$selected}>{$item}</option>"; } $sHtml .= "\n</select>"; return $sHtml; } }
/** * Get an HTML form datetime input corresponding to the bound object value * * @param object $object Object holding the field * @param array $params Extra parameters * @param string $value The actual value * @param string $className Extra CSS class name * @param string $format Optional datetime format * * @return string HTML form datetime string */ function getFormElementDateTime($object, $params, $value, $className, $format = "%d/%m/%Y %H:%M") { if ($object->_locked) { $params["readonly"] = "readonly"; } $class = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}")); $field = CMbString::htmlSpecialChars($this->fieldName); // Format the date $date = ""; if ($value && $value != '0000-00-00' && $value != '00:00:00' && $value != '0000-00-00 00:00:00') { $date = $this instanceof CDateSpec && $this->progressive ? $this->getValue($object, null, $params) : CMbDT::format($value, $format); } $form = CMbArray::extract($params, "form"); $register = CMbArray::extract($params, "register"); $style = CMbArray::extract($params, "style"); $tabindex = CMbArray::extract($params, "tabindex"); $readonly = CMbArray::get($params, "readonly"); $extra = CMbArray::makeXmlAttributes($params); $html = array(); $html[] = '<input name="' . $field . '_da" type="text" value="' . $date . '" class="' . $class . ' styled-element" readonly="readonly" ' . (isset($tabindex) ? 'tabindex="' . $tabindex . '" ' : '') . ' style="' . $style . '" />'; $html[] = '<input name="' . $field . '" type="hidden" value="' . $value . '" class="' . $class . '" ' . $extra . ' data-visual-element="' . $field . '_da" />'; if ($form && !$readonly && ($register || $this instanceof CTimeSpec)) { $register = $this instanceof CDateSpec && $this->progressive ? 'regProgressiveField' : 'regField'; $html[] = '<script type="text/javascript"> Main.add(function(){Calendar.' . $register . '(getForm("' . $form . '").elements["' . $field . '"])}) </script>'; } return implode("\n", $html); }
/** * The default Smarty escape * * @param string $string The string to escape * * @return string Escaped string */ function cleanField($string) { if (!is_scalar($string)) { return $string; } return CMbString::htmlSpecialChars($string, ENT_QUOTES); }
case "text/medistory-form": if (class_exists("CMedistoryImprime")) { $includeInfosFile = CMedistoryImprime::toHTML($raw_content); $show_editor = false; $display_as_is = true; break; } case "text/ami-patient-text": if (class_exists("CAMIDocument")) { $includeInfosFile = CAMIDocument::toHTML($raw_content); $show_editor = false; $display_as_is = true; break; } case "text/plain": $includeInfosFile = "<pre>" . CMbString::htmlSpecialChars($raw_content) . "</pre>"; break; case "text/html": $includeInfosFile = CMbString::purifyHTML($raw_content); $show_editor = false; $display_as_is = true; break; } } if ($fileSel->isPDFconvertible()) { $isConverted = true; $fileconvert = $fileSel->loadPDFconverted(); $success = 1; if (!$fileconvert->_id) { $success = $fileSel->convertToPDF(); }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $field = CMbString::htmlSpecialChars($this->fieldName); $locales = $this->_locales; $typeEnum = CMbArray::extract($params, "typeEnum", $this->typeEnum ? $this->typeEnum : "checkbox"); $separator = CMbArray::extract($params, "separator", $this->vertical ? "<br />" : null); $cycle = CMbArray::extract($params, "cycle", 1); $alphabet = CMbArray::extract($params, "alphabet", false); $size = CMbArray::extract($params, "size", 0); $onchange = CMbArray::get($params, "onchange"); $form = CMbArray::extract($params, "form"); // needs to be extracted $readonly = CMbArray::extract($params, "readonly") == 1; $extra = CMbArray::makeXmlAttributes($params); $className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}")); if ($alphabet) { asort($locales); } $uid = uniqid(); $value_array = $this->getListValues($value); switch ($typeEnum) { case "select": if ($readonly) { $readonly = "readonly"; } $sHtml = "<script type=\"text/javascript\">\n Main.add(function(){\n var select = \$\$('select[data-select_set={$uid}]')[0],\n element = select.previous(),\n tokenField = new TokenField(element, {" . ($onchange ? "onChange: function(){ {$onchange} }.bind(element)" : "") . "});\n\n select.observe('change', function(event){\n tokenField.setValues(\$A(select.options).filter(function(o){return o.selected}).pluck('value'));\n\n element.fire('ui:change');\n });\n });\n </script>"; $sHtml .= "<input type=\"hidden\" name=\"{$field}\" value=\"{$value}\" class=\"{$className}\" {$extra} />\n"; $sHtml .= "<select class=\"{$className}\" multiple=\"multiple\" size=\"{$size}\" data-select_set=\"{$uid}\" {$extra} {$readonly}>"; foreach ($locales as $key => $item) { if (!empty($value_array) && in_array($key, $value_array)) { $selected = " selected=\"selected\""; } else { $selected = ""; } $sHtml .= "\n<option value=\"{$key}\" {$selected}>{$item}</option>"; } $sHtml .= "\n</select>"; break; default: case "checkbox": $sHtml = "<span id=\"set-container-{$uid}\">\n"; $sHtml .= "<input type=\"hidden\" name=\"{$field}\" value=\"{$value}\" class=\"{$className}\" {$extra} />\n"; $sHtml .= "<script type=\"text/javascript\">\n Main.add(function(){\n var cont = \$('set-container-{$uid}'),\n element = cont.down('input[type=hidden]'),\n tokenField = new TokenField(element, {" . ($onchange ? "onChange: function(){ {$onchange} }.bind(element)" : "") . "});\n\n cont.select('input[type=checkbox]').invoke('observe', 'click', function(event){\n var elt = Event.element(event);\n tokenField.toggle(elt.value, elt.checked);\n\n element.fire('ui:change');\n });\n });\n </script>"; $compteur = 0; if ($readonly) { $readonly = "disabled"; } foreach ($locales as $key => $item) { $selected = ""; if (!empty($value_array) && in_array($key, $value_array)) { $selected = " checked=\"checked\""; } $sHtml .= "\n<label>\n <input type=\"checkbox\" name=\"_{$field}_{$key}\" value=\"{$key}\" class=\"set-checkbox token{$uid}\" {$selected} {$readonly} />\n {$item}\n </label> "; $compteur++; $modulo = $compteur % $cycle; if ($separator != null && $modulo == 0 && $compteur < count($locales)) { $sHtml .= $separator; } } $sHtml .= "</span>\n"; } return $sHtml; }
/** * @see parent::getFormHtmlElement() */ function getFormHtmlElement($object, $params, $value, $className) { $field = CMbString::htmlSpecialChars($this->fieldName); $typeEnum = CMbArray::extract($params, "typeEnum", $this->typeEnum ? $this->typeEnum : "select"); $columns = CMbArray::extract($params, "columns", $this->columns ? $this->columns : 1); $separator = CMbArray::extract($params, "separator"); $cycle = CMbArray::extract($params, "cycle", 1); $alphabet = CMbArray::extract($params, "alphabet", false); $form = CMbArray::extract($params, "form"); // needs to be extracted // Empty label if ($emptyLabel = CMbArray::extract($params, "emptyLabel")) { $emptyLabel = CAppUI::tr($emptyLabel); } // Extra info por HTML generation $extra = CMbArray::makeXmlAttributes($params); $locales = $this->_locales; $className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}")); $html = ""; // Alpha sorting if ($alphabet) { asort($locales); } // Turn readonly to disabled $readonly = CMbArray::extract($params, "readonly"); $disabled = $readonly ? "disabled=\"1\"" : ""; switch ($typeEnum) { default: case "select": $html .= "<select name=\"{$field}\" class=\"{$className}\" {$disabled} {$extra}>"; // Empty option label if ($emptyLabel) { $emptyLabel = "— {$emptyLabel}"; if ($value === null) { $html .= "\n<option value=\"\" selected=\"selected\">{$emptyLabel}</option>"; } else { $html .= "\n<option value=\"\">{$emptyLabel}</option>"; } } // All other options foreach ($locales as $key => $item) { $selected = ""; if ($value !== null && $value === "{$key}" || $value === null && "{$key}" === "{$this->default}" && !$emptyLabel) { $selected = " selected=\"selected\""; } $html .= "\n<option value=\"{$key}\" {$selected}>{$item}</option>"; } $html .= "\n</select>"; return $html; case "radio": $compteur = 0; // Empty radio label if ($emptyLabel) { if ($value === null) { $html .= "\n<input type=\"radio\" name=\"{$field}\" value=\"\" checked=\"checked\" />"; } else { $html .= "\n<input type=\"radio\" name=\"{$field}\" value=\"\" />"; } $html .= "<label for=\"{$field}_\">{$emptyLabel}</label> "; } // All other radios foreach ($locales as $key => $item) { $selected = ""; if ($value !== null && $value === "{$key}" || $value === null && "{$key}" === "{$this->default}") { $selected = " checked=\"checked\""; } $html .= "\n<input type=\"radio\" name=\"{$field}\" value=\"{$key}\" {$selected} class=\"{$className}\" {$disabled} {$extra} />\n <label for=\"{$field}_{$key}\">{$item}</label> "; $compteur++; $modulo = $compteur % $cycle; if ($separator != null && $modulo == 0 && $compteur < count($locales)) { $html .= $separator; } if ($this->vertical) { $html .= "<br />\n"; } } return $html; } }
/** * @param array $params Template params: * - options : array of objects with IDs * - choose : string alternative for Choose default option * - size : interger for size of text input * @see classes/CMbFieldSpec#getFormHtmlElement($object, $params, $value, $className) * * @return string */ function getFormHtmlElement($object, $params, $value, $className) { if ($options = CMbArray::extract($params, "options")) { $field = CMbString::htmlSpecialChars($this->fieldName); $className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}")); $extra = CMbArray::makeXmlAttributes($params); $choose = CMbArray::extract($params, "choose", "Choose"); $choose = CAppUI::tr($choose); $html = "\n<select name=\"{$field}\" class=\"{$className}\" {$extra}>"; $html .= "\n<option value=\"\">— {$choose}</option>"; foreach ($options as $_option) { $selected = $value == $_option->_id ? "selected=\"selected\"" : ""; $html .= "\n<option value=\"{$_option->_id}\" {$selected}>{$_option->_view}</option>"; } $html .= "\n</select>"; return $html; } CMbArray::defaultValue($params, "size", 25); return $this->getFormElementText($object, $params, $value, $className); }
/** * @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; }
function addRPU($elParent, CRPU $mbObject) { $sejour = $mbObject->loadRefSejour(); $this->addElement($elParent, "CP", $mbObject->_cp); $this->addElement($elParent, "COMMUNE", $mbObject->_ville); $this->addElement($elParent, "NAISSANCE", CMbDT::transform($mbObject->_naissance, null, "%d/%m/%Y")); $this->addElement($elParent, "SEXE", strtoupper($mbObject->_sexe)); $this->addElement($elParent, "ENTREE", CMbDT::transform($sejour->entree, null, "%d/%m/%Y %H:%M")); $this->addElement($elParent, "MODE_ENTREE", $sejour->mode_entree); $this->addElement($elParent, "PROVENANCE", $sejour->provenance == "8" ? "5" : $sejour->provenance); if ($sejour->transport == "perso_taxi") { $sejour->transport = "perso"; } if ($sejour->transport == "ambu_vsl") { $sejour->transport = "ambu"; } $this->addElement($elParent, "TRANSPORT", strtoupper($sejour->transport)); $this->addElement($elParent, "TRANSPORT_PEC", strtoupper($mbObject->pec_transport)); $motif = CMbString::htmlSpecialChars($mbObject->motif); if (CAppUI::conf("dPurgences CRPU gestion_motif_sfmu", $sejour->loadRefEtablissement()) == 2 || $mbObject->motif_sfmu) { $motif = $mbObject->loadRefMotifSFMU()->code; } $this->addElement($elParent, "MOTIF", $motif); if (CModule::getActive("oscour") && CAppUI::conf("dPurgences gerer_circonstance") && CAppUI::conf("oscour version_complete")) { $circonstance = $mbObject->loadRefCirconstance(); $this->addElement($elParent, "CIRCONSTANCE", $circonstance->code); } $this->addElement($elParent, "GRAVITE", strtoupper($mbObject->ccmu)); $this->addElement($elParent, "DP", $mbObject->_DP[0] . preg_replace("/[^\\d]/", "", substr($mbObject->_DP, 1))); $liste_da = $this->addElement($elParent, "LISTE_DA"); if ($dr = $sejour->_ext_diagnostic_relie) { $this->addDiagAssocie($liste_da, $dr->code[0] . preg_replace("/[^\\d]/", "", substr($dr->code, 1))); } $das = $sejour->_diagnostics_associes; if (is_array($das)) { foreach ($das as $_da) { $_da = $_da[0] . preg_replace("/[^\\d]/", "", substr($_da, 1)); $this->addDiagAssocie($liste_da, $_da); } } $liste_actes = $this->addElement($elParent, "LISTE_ACTES"); $codes_ccam = $sejour->_ref_consult_atu->_codes_ccam; if (is_array($codes_ccam)) { foreach ($codes_ccam as $_code_ccam) { $this->addActeCCAM($liste_actes, $_code_ccam); } } $sortie = null; if ($sejour->sortie_reelle) { $sortie = $sejour->sortie_reelle; } else { // on recherche la première affectation qui n'est pas dans un service d'urgences ou externe $affectation = new CAffectation(); $ljoin["service"] = "`service`.`service_id` = `affectation`.`service_id`"; $where = array(); $where["sejour_id"] = " = '{$sejour->_id}'"; $where["service.cancelled"] = " = '0'"; $where["service.uhcd"] = " = '0'"; $where["service.urgence"] = " = '0'"; $affectation->loadObject($where, "entree ASC", null, $ljoin); if ($affectation->_id) { $sortie = $affectation->entree; } } if ($sortie) { $this->addElement($elParent, "SORTIE", CMbDT::transform($sortie, null, "%d/%m/%Y %H:%M")); } if (CModule::getActive("cerveau")) { // on recherche la première affectation vers UHCD $affectation = new CAffectation(); $ljoin["service"] = "`service`.`service_id` = `affectation`.`service_id`"; $ljoin["sejour"] = "`affectation`.`sejour_id` = `sejour`.`sejour_id`"; $where = array(); $where["affectation.sejour_id"] = " = '{$sejour->_id}'"; $where["service.cancelled"] = " = '0'"; $where["service.uhcd"] = " = '1'"; $where["sejour.uhcd"] = " = '1'"; $affectation->loadObject($where, "entree ASC", null, $ljoin); if (!$affectation->_id) { $mode_sortie = $mbObject->_mode_sortie; $destination = $sejour->destination; $orientation = $mbObject->orientation; // Dans le cas où l'on ne créé pas un relicat, on va aller chercher les valeurs sur l'affectation de médecine if ($mbObject->mutation_sejour_id && CAppUI::conf("dPurgences create_sejour_hospit")) { // on recherche la première affectation qui ni UHCD, ni URG $affectation_medecine = new CAffectation(); $ljoin["service"] = "`service`.`service_id` = `affectation`.`service_id`"; $ljoin["sejour"] = "`affectation`.`sejour_id` = `sejour`.`sejour_id`"; $where = array(); $where["affectation.sejour_id"] = " = '{$sejour->_id}'"; $where["service.cancelled"] = " = '0'"; $where["service.uhcd"] = " != '1'"; $where["service.urgence"] = " != '1'"; $affectation_medecine->loadObject($where, "entree ASC", null, $ljoin); if ($affectation_medecine) { $service = $affectation_medecine->loadRefService(); $mode_sortie = "6"; $destination = $service->default_destination; $orientation = $service->default_orientation; } } } else { // Dans le cas où l'on a eu une mutation les données du RPU concerne la mut. UHCD $mode_sortie = "6"; $destination = "1"; $orientation = "UHCD"; } $this->addElement($elParent, "MODE_SORTIE", $mode_sortie); $this->addElement($elParent, "DESTINATION", $destination); $this->addElement($elParent, "ORIENT", strtoupper($orientation)); if ($affectation->_id) { $this->addElement($elParent, "ENTREE_UHCD", CMbDT::transform($affectation->entree, null, "%d/%m/%Y %H:%M")); $this->addElement($elParent, "MODE_SORTIE_UHCD", $mbObject->_mode_sortie); $this->addElement($elParent, "DESTINATION_UHCD", $sejour->destination); $this->addElement($elParent, "ORIENT_UHCD", strtoupper($mbObject->orientation)); } } else { if (!$sortie) { $this->addElement($elParent, "SORTIE", CMbDT::transform($sejour->sortie_prevue, null, "%d/%m/%Y %H:%M")); } $this->addElement($elParent, "MODE_SORTIE", $mbObject->_mode_sortie); $this->addElement($elParent, "DESTINATION", $sejour->destination); $this->addElement($elParent, "ORIENT", strtoupper($mbObject->orientation)); } }