/**
     * 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;'>&#42;</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();
    }
Beispiel #2
0
 /**
  * @url POST /project/:prj_uid/dynaforms
  *
  * @param string $prj_uid {@min 32}{@max 32}
  *
  */
 public function doGetDynaFormsId($prj_uid, $request_data)
 {
     try {
         $dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
         $dynaForm->setFormatFieldNameInUppercase(false);
         \G::LoadClass("pmDynaform");
         $pmDynaForm = new \pmDynaform();
         $_SESSION['PROCESS'] = $prj_uid;
         $return = array();
         foreach ($request_data['formId'] as $dyn_uid) {
             $response = $dynaForm->getDynaForm($dyn_uid);
             $result   = $this->parserDataDynaForm($response);
             $result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null)?json_decode($result['formContent']):"";
             $pmDynaForm->jsonr($result['formContent']);
             $return[] = $result;
         }
     } catch (\Exception $e) {
         throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
     }
     return $return;
 }
     $oReportTable->create($_POST['form']);
     $_POST['form']['REP_TAB_UID'] = $oReportTable->getRepTabUid();
 }
 $_POST['form']['REP_TAB_TYPE'] = 'NORMAL';
 $oReportTable->update($_POST['form']);
 $oReportVar = new ReportVar();
 $oReportTables = new ReportTables();
 $oReportTables->deleteAllReportVars($_POST['form']['REP_TAB_UID']);
 $aFields = array();
 if ($isBPMN) {
     G::LoadClass("pmDynaform");
     $pmDyna = new pmDynaform(array());
     $pmDyna->fields["CURRENT_DYNAFORM"] = $sDynUid;
     $dataDyna = $pmDyna->getDynaform();
     $json = G::json_decode($dataDyna["DYN_CONTENT"]);
     $data = $pmDyna->jsonr($json);
     G::pr($data);
     die;
 } else {
     $aAux = explode('-', $_POST['form']['REP_TAB_GRID']);
     global $G_FORM;
     require_once "classes/class.formBatchRouting.php";
     $G_FORM = new FormBatchRouting($_POST["form"]["PRO_UID"] . PATH_SEP . $aAux[1], PATH_DYNAFORM, SYS_LANG, false);
     $aAux = $G_FORM->getVars(false);
     foreach ($aAux as $aField) {
         $_POST['form']['FIELDS'][] = $aField['sName'] . '-' . $aField['sType'];
     }
 }
 $aFieldsClases = array();
 $i = 1;
 $aFieldsClases[$i]['FLD_NAME'] = 'APP_UID';