public function actionLoad($id = 0) { $xml = new XmlForm(); if ($id == 0) { $rr = $xml->readsimple($id); } else { $rr = $xml->readnomen(); } $this->render('test', array('rr' => $rr)); }
/** * Function Form * * @author David S. Callizaya S. <*****@*****.**> * @access public * @param string filename * @param string home * @param string language * @param string forceParse * @param string $visual_frontend * @return string */ public function Form($filename, $home = '', $language = '', $forceParse = false, $visual_frontend = null) { $this->visual_frontend = $visual_frontend; if ($language === '') { $language = defined('SYS_LANG') ? SYS_LANG : 'en'; } if ($home === '') { $home = defined('PATH_XMLFORM') ? PATH_XMLFORM : (defined('PATH_DYNAFORM') ? PATH_DYNAFORM : ''); } //to do: obtain the error code in case the xml parsing has errors: DONE //Load and parse the xml file if (substr($filename, -4) !== '.xml') { $filename = $filename . '.xml'; } $this->home = $home; $res = parent::parseFile($filename, $language, $forceParse); if ($res == 1) { trigger_error('Faild to parse file ' . $filename . '.', E_USER_ERROR); } if ($res == 2) { trigger_error('Faild to create cache file "' . $xmlform->parsedFile . '".', E_USER_ERROR); } $this->setDefaultValues(); //to do: review if you can use the same form twice. in order to use once or not. //DONE: Use require to be able to use the same xmlform more than once. foreach ($this->fields as $k => $v) { //too memory? but it fails if it's loaded with baneco.xml with SYS_LANG='es' //NOTE: This fails apparently when class of ($this->fields[$k]) is PHP_Incomplete_Class (because of cache) if (is_object($v)) { //julichu $this->fields[$k]->owner =& $this; if ($this->fields[$k]->type === 'grid') { $this->fields[$k]->parseFile($home, $language); } } } $this->template = PATH_CORE . 'templates/' . $this->type . '.html'; }
} if ($key == 'FILENAME') { $Fields[$key] = myTruncate($value, 60, '_', '...pm'); } if ($length >= 250) { if ($key == 'FILENAME_LINK') { list($file, $rest) = explode('p=', $value); list($filenameLink, $rest) = explode('&', $rest); $Fields[$key] = myTruncate($filenameLink, 250 - $pathLength, '_', ''); $Fields[$key] = $file . "p=" . $Fields[$key] . '&' . $rest; } } } /* Render page */ if (isset($_REQUEST["processMap"]) && $_REQUEST["processMap"] == 1) { $G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent("xmlform", "xmlform", "processes/processes_Export", "", $Fields); G::RenderPage("publish", "raw"); } else { $xmlFrm = new XmlForm(); $xmlFrm->home = PATH_XMLFORM . "processes" . PATH_SEP; $xmlFrm->parseFile("processes_Export.xml", SYS_LANG, true); $Fields["xmlFrmFieldLabel"] = array("title" => $xmlFrm->fields["TITLE"]->label, "proTitle" => $xmlFrm->fields["PRO_TITLE"]->label, "proDescription" => $xmlFrm->fields["PRO_DESCRIPTION"]->label, "size" => $xmlFrm->fields["SIZE"]->label, "fileName" => $xmlFrm->fields["FILENAME_LABEL"]->label); echo G::json_encode($Fields); } } catch (Exception $e) { $G_PUBLISH = new Publisher(); $aMessage['MESSAGE'] = $e->getMessage(); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage); G::RenderPage('publish', 'raw'); }
/** * Get Data Generate * * @access public * @param string $pro_uid, Process Uid * @param string $tas_uid, Task Uid * @param string $dyn_uid, Dynaform Uid * @return string * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia */ public function getDataGenerate($pro_uid, $tas_uid, $dyn_uid) { G::LoadClass ('case'); G::LoadClass ('pmFunctions'); G::LoadClass ("configuration"); $hasTextArea = false; $conf = new \Configurations(); $generalConfCasesList = $conf->getConfiguration("ENVIRONMENT_SETTINGS", ""); if (isset($generalConfCasesList["casesListDateFormat"]) && !empty($generalConfCasesList["casesListDateFormat"])) { $dateFormat = $generalConfCasesList["casesListDateFormat"]; } else { $dateFormat = "Y/m/d"; } $oDyna = new \Dynaform(); $dataTask = $oDyna->load($dyn_uid); if ($dataTask['DYN_VERSION'] > 0) { G::LoadClass("pmDynaform"); $pmDyna = new \pmDynaform(array('APP_DATA' => array())); $pmDyna->fields["CURRENT_DYNAFORM"] = $dyn_uid; $json = G::json_decode($dataTask["DYN_CONTENT"]); $pmDyna->jsonr($json); $fieldsDyna = $json->items[0]->items; $xmlfrm = new \stdclass(); $xmlfrm->fields = array(); foreach ($fieldsDyna as $key => $value) { if ($value[0]->type == 'title' || $value[0]->type == 'submit') { continue; } $temp = new \stdclass(); $temp->type = $value[0]->type; $temp->label = $value[0]->label; $temp->name = $value[0]->name; $temp->required = (isset($value[0]->required)) ? $value[0]->required : 0; $temp->mode = (isset($value[0]->mode)) ? $value[0]->mode : 'edit'; if (!empty($value[0]->options)) { $temp->storeData = '['; foreach ($value[0]->options as $valueOption) { $temp->storeData .= '["' . $valueOption['value'] . '", "' . $valueOption['label'] . '"],'; } $temp->storeData = substr($temp->storeData,0,-1); $temp->storeData .= ']'; } $temp->readOnly = ($temp->mode == 'view') ? "1" : "0"; $temp->colWidth = 200; $xmlfrm->fields[] = $temp; } } else { $filename = $pro_uid . PATH_SEP . $dyn_uid . ".xml"; if (!class_exists('Smarty')) { require_once(PATH_THIRDPARTY . 'smarty' . PATH_SEP . 'libs' . PATH_SEP . 'Smarty.class.php'); } $xmlfrm = new \XmlForm(); $xmlfrm->home = PATH_DYNAFORM; $xmlfrm->parseFile($filename, SYS_LANG, true); } $caseColumns = array(); $caseReaderFields = array(); $dropList = array(); $comboBoxYesNoList = array(); $caseColumns[] = array("header" => "APP_UID", "dataIndex" => "APP_UID", "width" => 100, "hidden" => true, "hideable" => false); $caseColumns[] = array("header" => "#", "dataIndex" => "APP_NUMBER", "width" => 40, "sortable" => true); $caseColumns[] = array("header" => G::LoadTranslation("ID_TITLE"), "dataIndex" => "APP_TITLE", "width" => 180, "renderer" => "renderTitle", "sortable" => true); $caseColumns[] = array("header" => G::LoadTranslation("ID_SUMMARY"), "width" => 60, "renderer" => "renderSummary", "align" => "center"); $caseColumns[] = array("header" => "DEL_INDEX", "dataIndex" => "DEL_INDEX", "width" => 100, "hidden" => true, "hideable" => false); $caseReaderFields[] = array("name" => "APP_UID"); $caseReaderFields[] = array("name" => "APP_NUMBER"); $caseReaderFields[] = array("name" => "APP_TITLE"); $caseReaderFields[] = array("name" => "DEL_INDEX"); //$caseColumns[] = array("header" => "FLAG", "dataIndex" => "FLAG", "width" => 55, "xtype"=>"checkcolumn"); //$caseReaderFields[] = array("name" => "FLAG", "type"=>"bool"); foreach ($xmlfrm->fields as $index => $value) { $field = $value; $editor = null; $renderer = null; $readOnly = (isset($field->readOnly))? $field->readOnly : null; $required = (isset($field->required))? $field->required : null; $validate = (isset($field->validate))? strtolower($field->validate) : null; $fieldReadOnly = ($readOnly . "" == "1")? "readOnly: true," : null; $fieldRequired = ($required . "" == "1")? "allowBlank: false," : null; $fieldValidate = ($validate == "alpha" || $validate == "alphanum" || $validate == "email" || $validate == "int" || $validate == "real")? "vtype: \"$validate\"," : null; $fieldLabel = (($fieldRequired != null)? "<span style='color: red;'>*</span> ": null) . $field->label; $fieldDisabled = ($field->mode != "edit")? "true" : "false"; switch ($field->type) { case "dropdown": $dropList[] = $field->name; $align = "left"; if (empty($field->storeData)) { $editor = "* new Ext.form.ComboBox({ id: \"cbo" . $field->name . "_" . $pro_uid . "\", valueField: 'value', displayField: 'text', /*store: comboStore,*/ store: new Ext.data.JsonStore({ storeId: \"store" . $field->name . "_" . $pro_uid . "\", proxy: new Ext.data.HttpProxy({ url: 'proxyDataCombobox' }), root: 'records', fields: [{name: 'value'}, {name: 'text'} ] }), triggerAction: 'all', mode: 'local', editable: false, disabled: $fieldDisabled, lazyRender: false, $fieldReadOnly $fieldRequired $fieldValidate cls: \"\" }) *"; } else { $editor = "* new Ext.form.ComboBox({ id: \"cbo" . $field->name . "_" . $pro_uid . "\", typeAhead: true, autocomplete:true, editable:false, lazyRender:true, mode:'local', triggerAction:'all', forceSelection:true, valueField: 'value', displayField: 'text', store:new Ext.data.SimpleStore({ fields: [{name: 'value'}, {name: 'text'}], data: " . htmlspecialchars_decode($field->storeData) . ", sortInfo:{field:'text',direction:'ASC'} }), $fieldReadOnly $fieldRequired $fieldValidate cls: \"\" }) *"; } $editor = eregi_replace("[\n|\r|\n\r]", ' ', $editor); $width = $field->colWidth; $caseColumns[] = array("xtype" => "combocolumn", "gridId" => "gridId", "header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => "true", "clicksToEdit" => "1"); $caseReaderFields[] = array("name" => $field->name); break; case "date": //minValue: '01/01/06', //disabledDays: [0, 6], //disabledDaysText: 'Plants are not available on the weekends' $align = "center"; $size = 100; if (isset($field->size)) { $size = $field->size * 10; } $width = $size; $editor = "* new Ext.form.DateField({ format: \"$dateFormat\", $fieldReadOnly $fieldRequired $fieldValidate cls: \"\" }) *"; //$renderer = "* formatDate *"; $renderer = "* function (value){ return Ext.isDate(value)? value.dateFormat('{$dateFormat}') : value; } *"; if ($field->mode != "edit") { $editor = null; } $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true); $caseReaderFields[] = array("name" => $field->name, "type" => "date"); break; case "currency": //align: 'right', //renderer: 'usMoney', //allowBlank: false, //allowNegative: false, $align = 'right'; $size = 100; if (isset($field->size)) { $size = $field->size * 10; } $width = $size; $editor = "* new Ext.form.NumberField({ maxValue: 1000000, allowDecimals: true, allowNegative: true, $fieldReadOnly $fieldRequired $fieldValidate cls: \"\" }) *"; if ($field->mode != "edit") { $editor = null; } $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => true, "clicksToEdit" => 1, "sortable" => true); $caseReaderFields[] = array("name" => $field->name); break; case "percentage": $align = 'right'; $size = 100; if (isset($field->size)) { $size = $field->size * 10; } $width = $size; $editor = "* new Ext.form.NumberField({ maxValue: 100, allowDecimals: true, $fieldReadOnly $fieldRequired $fieldValidate cls: \"\" }) *"; $renderer = "* function (value){ return (value + ' %'); } *"; if ($field->mode != "edit") { $editor = null; } $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true); $caseReaderFields[] = array("name" => $field->name); break; case "textarea": $align = 'left'; $size = 200; if (isset($field->size)) { $size = $field->size * 15; } $width = $size; $editor = "* new Ext.form.TextArea({ growMin: 60, growMax: 1000, grow: true, autoHeight: true, disabled: $fieldDisabled, enterIsSpecial: false, preventScrollbars: false, $fieldReadOnly $fieldRequired $fieldValidate cls: \"\" }) *"; $renderer = "* function (value) { return (value); } *"; $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true); $caseReaderFields[] = array("name" => $field->name); $hasTextArea = true; break; case "link": $align = 'center'; $size = 100; if (isset($field->size)) { $size = $field->size * 10; } $width = $size; $editor = null; $renderer = "* function (value) { return linkRenderer(value); } *"; $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "hidden" => false, "hideable" => false, "clicksToEdit" => 1, "sortable" => true); $caseReaderFields[] = array("name" => $field->name); break; case "hidden": $align = 'left'; $size = 100; if (isset($field->size)) { $size = $field->size * 10; } $width = $size; $editor = "* new Ext.form.TextField({ allowBlank: false }) *"; $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)$width, "align" => $align, "editor" => $editor, "frame" => "true", "hidden" => "true", "hideable" => false, "clicksToEdit" => "1"); $caseReaderFields[] = array("name" => $field->name); break; case "yesno": $align = "right"; $size = 100; if (isset($field->size)) { $size = $field->size * 10; } $width = $size; $dropList[] = $field->name; $comboBoxYesNoList[] = $field->name; $editor="* new Ext.form.ComboBox({ id: \"cbo" . $field->name . "_" . $pro_uid . "\", valueField: 'value', displayField: 'text', store: new Ext.data.ArrayStore({ storeId: \"store" . $field->name . "_" . $pro_uid . "\", fields: ['value', 'text'], data: [[1, 'YES'], [0, 'NO'] ] }), typeAhead: true, triggerAction: 'all', mode: 'local', editable: false, disabled : $fieldDisabled, lazyRender: true, $fieldReadOnly $fieldRequired $fieldValidate cls: \"\" }) *"; /* $renderer = "* function(value) { idx = this.editor.store.find(this.editor.valueField, value); if (currentFieldEdited == '{$field->name}') { if (rec = this.editor.store.getAt(idx)) { rowLabels['{$field->name}'] = rec.get(this.editor.displayField); return rec.get(this.editor.displayField); } else { return value; } } else { if (typeof(currentFieldEdited) == 'undefined') { return value; } else { return (rowLabels['{$field->name}']); } } } *"; */ //$caseColumns[] = array('header' => $fieldLabel, 'dataIndex' => $field->name, 'width' => (int)$width, 'align' => $align, 'editor' => $editor, 'renderer' => $renderer, 'frame' => 'true', 'clicksToEdit' => '1'); $caseColumns[] = array("xtype" => "combocolumn", "gridId" => "gridId", "header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => "true", "clicksToEdit" => "1"); $caseReaderFields[] = array("name" => $field->name); break; case "text": default: $align = "left"; $size = 100; if (isset($field->size)) { $size = $field->size * 10; } $width = $size; $editor = "* new Ext.form.TextField({ $fieldReadOnly $fieldRequired $fieldValidate cls: \"\"}) *"; if ($field->mode != "edit" && $field->mode != "parent") { $editor = null; } $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => true, "clicksToEdit" => 1, "sortable" => true); $caseReaderFields[] = array("name" => $field->name); } } @unlink(PATH_C . "ws" . PATH_SEP . SYS_SYS . PATH_SEP . "xmlform" . PATH_SEP . $pro_uid . PATH_SEP . $dyn_uid . "." . SYS_LANG); $array ['columnModel'] = $caseColumns; $array ['readerFields'] = $caseReaderFields; $array ["dropList"] = $dropList; $array ["comboBoxYesNoList"] = $comboBoxYesNoList; $array ['hasTextArea'] = $hasTextArea; $temp = G::json_encode($array); //$temp = str_replace("***","'",$temp); $temp = str_replace('"*','', $temp); $temp = str_replace('*"','', $temp); $temp = str_replace('\t','', $temp); $temp = str_replace('\n','', $temp); $temp = str_replace('\/','/', $temp); $temp = str_replace('\"','"', $temp); $temp = str_replace('"checkcolumn"','\'checkcolumn\'',$temp); print $temp; die(); }
public function actionTest($id = false) { $xml = new XmlForm(); $rr = $xml->readsimple($id); if ($id) { $this->render('test_2', array('model' => array(), 'rr' => $rr)); return; } $connection = Yii::app()->db; $sql = 'SELECT productgroup_id.ckey AS zkey,' . 'product_group.ckey AS zid, ' . 'product_group.tnam AS zname, ' . 'product_group.cgr AS zgr ' . 'FROM product_group LEFT JOIN productgroup_id ON product_group.ckey=productgroup_id.id'; $res = $connection->createCommand($sql)->queryAll(); $this->render('test_2', array('model' => $res, 'rr' => $rr)); }