Ejemplo n.º 1
0
 public function evaluateVariable()
 {
     $process = new Process();
     if (!$process->isBpmnProcess($_SESSION['PROCESS'])) {
         return;
     }
     require_once PATH_CORE . 'controllers/pmTablesProxy.php';
     $pmTablesProxy = new pmTablesProxy();
     $variableModule = new ProcessMaker\BusinessModel\Variable();
     $searchTypes = array('checkgroup', 'dropdown', 'suggest');
     $processVariables = $pmTablesProxy->getDynaformVariables($_SESSION['PROCESS'], $searchTypes, false);
     $variables = $this->affected_fields;
     $variables = array_unique($variables);
     $newFields = array();
     $arrayValues = array();
     $arrayLabels = array();
     if (is_array($variables) && is_array($processVariables)) {
         foreach ($variables as $var) {
             if (strpos($var, '_label') === false) {
                 if (in_array($var, $processVariables)) {
                     if (isset($this->aFields[$var]) && is_array($this->aFields[$var][1])) {
                         $varLabel = $var . '_label';
                         $arrayValue = $this->aFields[$var];
                         if (is_array($arrayValue) && sizeof($arrayValue)) {
                             foreach ($arrayValue as $val) {
                                 if (is_array($val)) {
                                     $val = array_values($val);
                                     $arrayValues[] = $val[0];
                                     $arrayLabels[] = $val[1];
                                 }
                             }
                             if (sizeof($arrayLabels)) {
                                 $varInfo = $variableModule->getVariableTypeByName($_SESSION['PROCESS'], $var);
                                 if (is_array($varInfo) && sizeof($varInfo)) {
                                     $varType = $varInfo['VAR_FIELD_TYPE'];
                                     switch ($varType) {
                                         case 'array':
                                             $arrayLabels = '["' . implode('","', $arrayLabels) . '"]';
                                             $newFields[$var] = $arrayValues;
                                             $newFields[$varLabel] = $arrayLabels;
                                             break;
                                         case 'string':
                                             $newFields[$var] = $arrayValues[0];
                                             $newFields[$varLabel] = $arrayLabels[0];
                                             break;
                                     }
                                     $this->affected_fields[] = $varLabel;
                                     $this->aFields = array_merge($this->aFields, $newFields);
                                     unset($newFields);
                                     unset($arrayValues);
                                     unset($arrayLabels);
                                 }
                             }
                         }
                     }
                     if (isset($this->aFields[$var]) && is_string($this->aFields[$var])) {
                         $varInfo = $variableModule->getVariableTypeByName($_SESSION['PROCESS'], $var);
                         $options = G::json_decode($varInfo["VAR_ACCEPTED_VALUES"]);
                         $no = count($options);
                         for ($io = 0; $io < $no; $io++) {
                             if ($options[$io]->value === $this->aFields[$var]) {
                                 $this->aFields[$var . "_label"] = $options[$io]->label;
                             }
                         }
                         if ($varInfo["VAR_DBCONNECTION"] !== "" && $varInfo["VAR_DBCONNECTION"] !== "none" && $varInfo["VAR_SQL"] !== "") {
                             try {
                                 $cnn = Propel::getConnection($varInfo["VAR_DBCONNECTION"]);
                                 $stmt = $cnn->createStatement();
                                 $sql = G::replaceDataField($varInfo["VAR_SQL"], $this->aFields);
                                 $rs = $stmt->executeQuery($sql, \ResultSet::FETCHMODE_NUM);
                                 while ($rs->next()) {
                                     $row = $rs->getRow();
                                     if ($row[0] === $this->aFields[$var]) {
                                         $this->aFields[$var . "_label"] = isset($row[1]) ? $row[1] : $row[0];
                                     }
                                 }
                             } catch (Exception $e) {
                             }
                         }
                     }
                 }
             }
         }
     }
 }
while ($rsSql->next()) {
    $row = $rsSql->getRow();

    $processUid  = $row["PRO_UID"];
    $proTitle    = $row["PROCESS_TITLE"];
    $taskUid     = $row["TAS_UID"];
    $taskTitle   = $row["TASK_TITLE"];
    $dynaformUid = $row["DYN_UID"];

    $tabTitle = $taskTitle . " (" . (($activeNumRows > 0)? $row["NUMREC"] : 0) . ")";

    $grdTitle = htmlentities($proTitle . " / " . $tabTitle, ENT_QUOTES, "UTF-8");
    $tabTitle = htmlentities(substr($proTitle, 0, 25) . ((strlen($proTitle) > 25)? "..." : null) . " / " . $tabTitle, ENT_QUOTES, "UTF-8");

    $oProcess = new Process();
    $isBpmn   = $oProcess->isBpmnProcess($processUid);
    if($isBpmn){
        $arrayTabItem[] = "
        {
            title: \"<span onmouseover=\\\"toolTipTab('$grdTitle', 1);\\\" onmouseout=\\\"toolTipTab('', 0);\\\">$tabTitle</span>\",
            listeners: {
                activate: function ()
                {
                      generateGrid(\"$processUid\", \"$taskUid\", \"$dynaformUid\");
                }
            }
        }";
    }else{
        $arrayTabItem[] = "
        {
            title: \"<span onmouseover=\\\"toolTipTab('$grdTitle', 1);\\\" onmouseout=\\\"toolTipTab('', 0);\\\">$tabTitle</span>\",
Ejemplo n.º 3
0
 /**
  * edit pmtable
  *
  * @param string $httpData->id
  */
 public function edit($httpData)
 {
     require_once PATH_CONTROLLERS . 'pmTablesProxy.php';
     require_once 'classes/model/AdditionalTables.php';
     G::loadClass('pmTable');
     $additionalTables = new AdditionalTables();
     $table = false;
     $addTabUid = isset($httpData->id) ? $httpData->id : false;
     $dataNumRows = 0;
     $repTabPluginPermissions = false;
     $columnsTypes = PmTable::getPropelSupportedColumnTypes();
     $jsFile = isset($httpData->tableType) && $httpData->tableType == 'report' ? 'editReport' : 'edit';
     $columnsTypesList = array();
     foreach ($columnsTypes as $columnTypeName => $columnType) {
         $columnsTypesList[] = array($columnTypeName, $columnType);
     }
     if ($addTabUid) {
         $tableData = $additionalTables->getAllData($httpData->id, 0, 2);
         $dataNumRows = $tableData['count'];
     }
     if ($addTabUid !== false) {
         // if it is a edit request
         $tableFields = array();
         $fieldsList = array();
         $table = $additionalTables->load($addTabUid, true);
         //fix for backware compatibility
         $table['DBS_UID'] = $table['DBS_UID'] == null || $table['DBS_UID'] == '' ? 'workflow' : $table['DBS_UID'];
         $_SESSION['ADD_TAB_UID'] = $addTabUid;
         //list dynaform fields
         if ($table['ADD_TAB_TYPE'] == 'NORMAL' || $table['ADD_TAB_TYPE'] == 'GRID') {
             $repTabPluginPermissions = $this->_getSimpleReportPluginDef();
         }
     }
     $this->includeExtJS('pmTables/' . $jsFile);
     $this->setJSVar('flagProcessmap', isset($_REQUEST['flagProcessmap']) ? $_REQUEST['flagProcessmap'] : 0);
     $this->setJSVar('ADD_TAB_UID', $addTabUid);
     $this->setJSVar('PRO_UID', isset($_GET['PRO_UID']) ? $_GET['PRO_UID'] : false);
     $this->setJSVar('TABLE', $table);
     $this->setJSVar('dbg', isset($httpData->dbg));
     $this->setJSVar('columnsTypes', $columnsTypesList);
     $this->setJSVar('dataNumRows', $dataNumRows);
     $this->setJSVar('_plugin_permissions', $repTabPluginPermissions);
     $this->setJSVar('sizeTableName', $this->getSizeTableName());
     $isBpmn = 0;
     if (isset($_GET['PRO_UID'])) {
         $process = new Process();
         $isBpmn = $process->isBpmnProcess($_GET['PRO_UID']);
     }
     $this->setJSVar('isBpmn', $isBpmn);
     G::RenderPage('publish', 'extJs');
 }