/** * Get Dynaform Rows from a Process * * @param string $sProUid * @return $aDynaform array */ public function getDynaformRows ($sProUid) { try { $aDynaform = array (); $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( DynaformPeer::PRO_UID, $sProUid ); $oDataset = DynaformPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oDynaform = new Dynaform(); $aDynaform[] = $oDynaform->Load( $aRow['DYN_UID'] ); $oDataset->next(); } return $aDynaform; } catch (Exception $oError) { throw ($oError); } }
$tree->showSign = false; G::LoadClass('case'); $o = new Cases(); $steps = $o->getAllDynaformsStepsToRevise($_GET['APP_UID']); $APP_UID = $_GET['APP_UID']; $DEL_INDEX = $_GET['DEL_INDEX']; $html = "\r\n <table cellspacing='0' cellpadding='0' border='1' style='border:0px;'>\r\n <tr>\r\n <td class='treeNode' style='border:0px;background-color:transparent;'><b>Dynaforms<b></td>\r\n </tr>\r\n </table>"; $ch =& $tree->addChild("", $html, array('nodeType' => 'child')); $ch->point = '</span><img src="/images/plus.gif" />'; $i = 1; $PRO_UID = ''; $DYN_UID = ''; foreach ($steps as $step) { require_once 'classes/model/Dynaform.php'; $od = new Dynaform(); $dynaformF = $od->Load($step['STEP_UID_OBJ']); $n = $step['STEP_POSITION']; $TITLE = " - " . $dynaformF['DYN_TITLE']; $DYN_UID = $dynaformF['DYN_UID']; $PRO_UID = $step['PRO_UID']; $html = "\r\n <table cellspacing='0' cellpadding='0' border='1' style='border:0px;'>\r\n <tr>\r\n <td class='treeNode' style='border:0px;background-color:transparent;'><span id='focus{$i}'></td>\r\n <td class='treeNode' style='border:0px;background-color:transparent;'> {$n} </td>\r\n <td class='treeNode' style='border:0px;background-color:transparent;'>\r\n\t\t \t<a href=\"cases_StepToRevise?type=DYNAFORM&ex={$i}&PRO_UID={$PRO_UID}&DYN_UID={$DYN_UID}&APP_UID={$APP_UID}&position=" . $step['STEP_POSITION'] . "&DEL_INDEX={$DEL_INDEX}\">{$TITLE}</a>\r\n\t\t </td>\r\n </tr>\r\n </table>"; $ch =& $tree->addChild("", $html, array('nodeType' => 'child')); $ch->point = '<img src="/images/ftv2mnode.gif" />'; $i++; } $html = "\r\n <table cellspacing='0' cellpadding='0' border='1' style='border:0px;'>\r\n <tr>\r\n <td class='treeNode' style='border:0px;background-color:transparent;'><span id='focus{$i}'></td>\r\n <td class='treeNode' style='border:0px;background-color:transparent;'>\r\n\t\t \t<a href=\"cases_StepToReviseInputs?PRO_UID={$PRO_UID}&APP_UID={$APP_UID}&DEL_INDEX={$DEL_INDEX}\"> Input Documents</a>\r\n\t\t </td>\r\n </tr>\r\n </table>"; $ch =& $tree->addChild("", $html, array('nodeType' => 'child')); $ch->point = '</span><img src="/images/plus.gif" />'; $steps = $o->getAllInputsStepsToRevise($_GET['APP_UID']); //$i=1; foreach ($steps as $step) {
$G_ID_MENU_SELECTED = 'DYNADOC'; global $G_PUBLISH; switch ($_GET['CTO_TYPE_OBJ']) { case 'DYNAFORM': G::LoadClass('case'); $oCase = new Cases(); $Fields = $oCase->loadCase($_SESSION['APPLICATION']); $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = ''; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP_LABEL'] = ''; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP'] = '#'; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'alert("Sample"); return false;'; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PRINT_PREVIEW'] = '#'; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PRINT_PREVIEW_ACTION'] = 'tracker_PrintView?CTO_UID_OBJ=' . $_GET['CTO_UID_OBJ'] . '&CTO_TYPE_OBJ=PRINT_PREVIEW'; $_SESSION['CTO_UID_OBJ'] = $_GET['CTO_UID_OBJ']; $dynaForm = new Dynaform(); $arrayDynaFormData = $dynaForm->Load($_GET["CTO_UID_OBJ"]); if (isset($arrayDynaFormData["DYN_VERSION"]) && $arrayDynaFormData["DYN_VERSION"] == 2) { G::LoadClass("pmDynaform"); $Fields["PRO_UID"] = $_SESSION["PROCESS"]; $Fields["CURRENT_DYNAFORM"] = $_GET["CTO_UID_OBJ"]; $pmDynaForm = new pmDynaform($Fields); if ($pmDynaForm->isResponsive()) { $pmDynaForm->printTracker(); } } else { $G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent("dynaform", "xmlform", $_SESSION["PROCESS"] . "/" . $_GET["CTO_UID_OBJ"], "", $Fields["APP_DATA"], "", "", "view"); G::RenderPage("publish"); } break; case 'INPUT_DOCUMENT':
/** * Copy/Import a DynaForm * * @param string $processUid Unique id of Process * @param array $arrayData Data * * return array Return data of the new DynaForm created */ public function copyImport($processUid, $arrayData) { try { $arrayData = \G::array_change_key_case2($arrayData, CASE_UPPER); unset($arrayData["DYN_UID"]); unset($arrayData["PMTABLE"]); //Verify data $process = new \ProcessMaker\BusinessModel\Process(); $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); if (!isset($arrayData["COPY_IMPORT"])) { throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->getFieldNameByFormatFieldName("COPY_IMPORT")))); } if (!isset($arrayData["COPY_IMPORT"]["PRJ_UID"])) { throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID")))); } $arrayData["COPY_IMPORT"]["PRJ_UID"] = trim($arrayData["COPY_IMPORT"]["PRJ_UID"]); if ($arrayData["COPY_IMPORT"]["PRJ_UID"] == "") { throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID")))); } if (!isset($arrayData["COPY_IMPORT"]["DYN_UID"])) { throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID")))); } $arrayData["COPY_IMPORT"]["DYN_UID"] = trim($arrayData["COPY_IMPORT"]["DYN_UID"]); if ($arrayData["COPY_IMPORT"]["DYN_UID"] == "") { throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID")))); } $this->throwExceptionIfExistsTitle($processUid, $arrayData["DYN_TITLE"], $this->arrayFieldNameForException["dynaFormTitle"]); //Copy/Import Uids $processUidCopyImport = $arrayData["COPY_IMPORT"]["PRJ_UID"]; $dynaFormUidCopyImport = $arrayData["COPY_IMPORT"]["DYN_UID"]; //Verify data $process->throwExceptionIfNotExistsProcess($processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID")); $this->throwExceptionIfNotExistsDynaForm($dynaFormUidCopyImport, $processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID")); //Copy/Import //Copy content if version is 2 if ($arrayData["DYN_VERSION"] === 2) { $dynaFormOld = new \Dynaform(); $arrayDynaFormData = $dynaFormOld->Load($dynaFormUidCopyImport); $arrayData["DYN_CONTENT"] = $arrayDynaFormData["DYN_CONTENT"]; } //Create $arrayData = $this->create($processUid, $arrayData); $dynaFormUid = $arrayData[$this->getFieldNameByFormatFieldName("DYN_UID")]; //Copy files of the DynaForm $umaskOld = umask(0); $fileXml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormUidCopyImport . ".xml"; if (file_exists($fileXml)) { $fileXmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormUid . ".xml"; $fhXml = fopen($fileXml, "r"); $fhXmlCopy = fopen($fileXmlCopy, "w"); while (!feof($fhXml)) { $strLine = fgets($fhXml, 4096); $strLine = str_replace($processUidCopyImport . "/" . $dynaFormUidCopyImport, $processUid . "/" . $dynaFormUid, $strLine); //DynaForm Grid preg_match_all("/<.*type\\s*=\\s*[\"\\']grid[\"\\'].*xmlgrid\\s*=\\s*[\"\\']\\w{32}\\/(\\w{32})[\"\\'].*\\/>/", $strLine, $arrayMatch, PREG_SET_ORDER); foreach ($arrayMatch as $value) { $dynaFormGridUidCopyImport = $value[1]; //Get data $criteria = new \Criteria(); $criteria->addSelectColumn(\ContentPeer::CON_VALUE); $criteria->add(\ContentPeer::CON_ID, $dynaFormGridUidCopyImport); $criteria->add(\ContentPeer::CON_CATEGORY, "DYN_TITLE"); $criteria->add(\ContentPeer::CON_LANG, SYS_LANG); $rsCriteria = \ContentPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $rsCriteria->next(); $row = $rsCriteria->getRow(); $dynGrdTitleCopyImport = $row["CON_VALUE"]; $criteria = new \Criteria(); $criteria->addSelectColumn(\ContentPeer::CON_VALUE); $criteria->add(\ContentPeer::CON_ID, $dynaFormGridUidCopyImport); $criteria->add(\ContentPeer::CON_CATEGORY, "DYN_DESCRIPTION"); $criteria->add(\ContentPeer::CON_LANG, SYS_LANG); $rsCriteria = \ContentPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $rsCriteria->next(); $row = $rsCriteria->getRow(); $dynGrdDescriptionCopyImport = $row["CON_VALUE"]; //Create Grid $dynaFormGrid = new \Dynaform(); $arrayDataAux = array("PRO_UID" => $processUid, "DYN_TITLE" => $dynGrdTitleCopyImport . ($this->existsTitle($processUid, $dynGrdTitleCopyImport) ? " (" . $arrayData["DYN_TITLE"] . ")" : ""), "DYN_DESCRIPTION" => $dynGrdDescriptionCopyImport, "DYN_TYPE" => "grid"); $dynaFormGridUid = $dynaFormGrid->create($arrayDataAux); //Copy files of the DynaForm Grid $fileGridXml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormGridUidCopyImport . ".xml"; if (file_exists($fileGridXml)) { $fileGridXmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormGridUid . ".xml"; $fhGridXml = fopen($fileGridXml, "r"); $fhGridXmlCopy = fopen($fileGridXmlCopy, "w"); while (!feof($fhGridXml)) { $strLineAux = fgets($fhGridXml, 4096); $strLineAux = str_replace($processUidCopyImport . "/" . $dynaFormGridUidCopyImport, $processUid . "/" . $dynaFormGridUid, $strLineAux); fwrite($fhGridXmlCopy, $strLineAux); } fclose($fhGridXmlCopy); fclose($fhGridXml); chmod($fileGridXmlCopy, 0777); } $fileGridHtml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormGridUidCopyImport . ".html"; if (file_exists($fileGridHtml)) { $fileGridHtmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormGridUid . ".html"; copy($fileGridHtml, $fileGridHtmlCopy); chmod($fileGridHtmlCopy, 0777); } $strLine = str_replace($processUidCopyImport . "/" . $dynaFormGridUidCopyImport, $processUid . "/" . $dynaFormGridUid, $strLine); } fwrite($fhXmlCopy, $strLine); } fclose($fhXmlCopy); fclose($fhXml); chmod($fileXmlCopy, 0777); } $fileHtml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormUidCopyImport . ".html"; if (file_exists($fileHtml)) { $fileHtmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormUid . ".html"; copy($fileHtml, $fileHtmlCopy); chmod($fileHtmlCopy, 0777); } //Copy if there are conditions attached to the DynaForm $fieldCondition = new \FieldCondition(); $arrayCondition = $fieldCondition->getAllByDynUid($dynaFormUidCopyImport); foreach ($arrayCondition as $condition) { $condition["FCD_UID"] = ""; $condition["FCD_DYN_UID"] = $dynaFormUid; $fieldCondition->quickSave($condition); } umask($umaskOld); //Return return $arrayData; } catch (\Exception $e) { throw $e; } }
/** * Set value in WE_DATA * * @param string $webEntryUid Unique id of Web Entry * * return void */ public function setWeData($webEntryUid) { try { //Verify data $this->throwExceptionIfNotExistsWebEntry($webEntryUid, $this->arrayFieldNameForException["webEntryUid"]); //Set variables $arrayWebEntryData = $this->getWebEntry($webEntryUid, true); $processUid = $arrayWebEntryData["PRO_UID"]; $taskUid = $arrayWebEntryData["TAS_UID"]; $dynaFormUid = $arrayWebEntryData["DYN_UID"]; $webEntryMethod = $arrayWebEntryData["WE_METHOD"]; $webEntryInputDocumentAccess = $arrayWebEntryData["WE_INPUT_DOCUMENT_ACCESS"]; $webEntryData = ""; $wsRoundRobin = 0; //0, 1 //0 - Cyclical Assignment $pathDataPublicProcess = PATH_DATA_PUBLIC . $processUid; //Delete previous files if (trim($arrayWebEntryData["WE_DATA"]) != "") { $fileName = str_replace(".php", "", trim($arrayWebEntryData["WE_DATA"])); $file = $pathDataPublicProcess . PATH_SEP . $fileName . ".php"; if (is_file($file) && file_exists($file)) { unlink($file); unlink($pathDataPublicProcess . PATH_SEP . $fileName . "Post.php"); } } //Create files \G::mk_dir($pathDataPublicProcess, 0777); $http = \G::is_https() ? "https://" : "http://"; switch ($webEntryMethod) { case "WS": require_once PATH_RBAC . "model" . PATH_SEP . "RbacUsers.php"; $user = new \RbacUsers(); $arrayUserData = $user->load($arrayWebEntryData["USR_UID"]); $usrUsername = $arrayUserData["USR_USERNAME"]; $usrPassword = $arrayUserData["USR_PASSWORD"]; $dynaForm = new \Dynaform(); $arrayDynaFormData = $dynaForm->Load($arrayWebEntryData["DYN_UID"]); //Creating sys.info; $sitePublicPath = ""; if (file_exists($sitePublicPath . "")) { } //Creating the first file $weTitle = $this->sanitizeFilename($arrayWebEntryData["WE_TITLE"]); $fileName = $weTitle; $fileContent = "<?php\n"; $fileContent .= "global \$_DBArray;\n"; $fileContent .= "if (!isset(\$_DBArray)) {\n"; $fileContent .= " \$_DBArray = array();\n"; $fileContent .= "}\n"; $fileContent .= "\$_SESSION[\"PROCESS\"] = \"" . $processUid . "\";\n"; $fileContent .= "\$_SESSION[\"CURRENT_DYN_UID\"] = \"" . $dynaFormUid . "\";\n"; $fileContent .= "\$G_PUBLISH = new Publisher();\n"; $fileContent .= "G::LoadClass(\"pmDynaform\");\n"; $fileContent .= "\$a = new pmDynaform(array(\"CURRENT_DYNAFORM\" => \"" . $arrayWebEntryData["DYN_UID"] . "\"));\n"; $fileContent .= "if (\$a->isResponsive()) {"; $fileContent .= " \$a->printWebEntry(\"" . $fileName . "Post.php\");"; $fileContent .= "} else {"; $fileContent .= " \$G_PUBLISH->AddContent(\"dynaform\", \"xmlform\", \"" . $processUid . PATH_SEP . $dynaFormUid . "\", \"\", array(), \"" . $fileName . "Post.php\");\n"; $fileContent .= " G::RenderPage(\"publish\", \"blank\");"; $fileContent .= "}"; file_put_contents($pathDataPublicProcess . PATH_SEP . $fileName . ".php", $fileContent); //Creating the second file, the post file who receive the post form. $pluginTpl = PATH_TPL . "processes" . PATH_SEP . "webentryPost.tpl"; $template = new \TemplatePower($pluginTpl); $template->prepare(); $template->assign("wsdlUrl", $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/wsdl2"); $template->assign("wsUploadUrl", $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/upload"); $template->assign("processUid", $processUid); $template->assign("dynaformUid", $dynaFormUid); $template->assign("taskUid", $taskUid); $template->assign("wsUser", $usrUsername); $template->assign("wsPass", \Bootstrap::getPasswordHashType() . ':' . $usrPassword); $template->assign("wsRoundRobin", $wsRoundRobin); if ($webEntryInputDocumentAccess == 0) { //Restricted to process permissions $template->assign("USR_VAR", "\$cInfo = ws_getCaseInfo(\$caseId);\n\t \$USR_UID = \$cInfo->currentUsers->userId;"); } else { //No Restriction $template->assign("USR_VAR", "\$USR_UID = -1;"); } $template->assign("dynaform", $arrayDynaFormData["DYN_TITLE"]); $template->assign("timestamp", date("l jS \\of F Y h:i:s A")); $template->assign("ws", SYS_SYS); $template->assign("version", \System::getVersion()); $fileName = $pathDataPublicProcess . PATH_SEP . $weTitle . "Post.php"; file_put_contents($fileName, $template->getOutputContent()); //Creating the third file, only if this wsClient.php file doesn't exist. $fileName = $pathDataPublicProcess . PATH_SEP . "wsClient.php"; $pluginTpl = PATH_CORE . "templates" . PATH_SEP . "processes" . PATH_SEP . "wsClient.php"; if (file_exists($fileName)) { if (filesize($fileName) != filesize($pluginTpl)) { copy($fileName, $pathDataPublicProcess . PATH_SEP . "wsClient.php.bak"); unlink($fileName); $template = new \TemplatePower($pluginTpl); $template->prepare(); file_put_contents($fileName, $template->getOutputContent()); } } else { $template = new \TemplatePower($pluginTpl); $template->prepare(); file_put_contents($fileName, $template->getOutputContent()); } //Event $task = new \Task(); $arrayTaskData = $task->load($arrayWebEntryData["TAS_UID"]); $weEventUid = $task->getStartingEvent(); if ($weEventUid != "") { $event = new \Event(); $arrayEventData = array(); $arrayEventData["EVN_UID"] = $weEventUid; $arrayEventData["EVN_RELATED_TO"] = "MULTIPLE"; $arrayEventData["EVN_ACTION"] = $dynaFormUid; $arrayEventData["EVN_CONDITIONS"] = $usrUsername; $result = $event->update($arrayEventData); } //WE_DATA $webEntryData = $weTitle . ".php"; break; case "HTML": global $G_FORM; if (!class_exists("Smarty")) { $loader = \Maveriks\Util\ClassLoader::getInstance(); $loader->addClass("Smarty", PATH_THIRDPARTY . "smarty" . PATH_SEP . "libs" . PATH_SEP . "Smarty.class.php"); } $G_FORM = new \Form($processUid . "/" . $dynaFormUid, PATH_DYNAFORM, SYS_LANG, false); $G_FORM->action = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/cases_StartExternal.php"; $scriptCode = ""; $scriptCode = $G_FORM->render(PATH_TPL . "xmlform" . ".html", $scriptCode); $scriptCode = str_replace("/controls/", $http . $_SERVER["HTTP_HOST"] . "/controls/", $scriptCode); $scriptCode = str_replace("/js/maborak/core/images/", $http . $_SERVER["HTTP_HOST"] . "/js/maborak/core/images/", $scriptCode); //Render the template $pluginTpl = PATH_TPL . "processes" . PATH_SEP . "webentry.tpl"; $template = new \TemplatePower($pluginTpl); $template->prepare(); $step = new \Step(); $sUidGrids = $step->lookingforUidGrids($processUid, $dynaFormUid); $template->assign("URL_MABORAK_JS", \G::browserCacheFilesUrl("/js/maborak/core/maborak.js")); $template->assign("URL_TRANSLATION_ENV_JS", \G::browserCacheFilesUrl("/jscore/labels/" . SYS_LANG . ".js")); $template->assign("siteUrl", $http . $_SERVER["HTTP_HOST"]); $template->assign("sysSys", SYS_SYS); $template->assign("sysLang", SYS_LANG); $template->assign("sysSkin", SYS_SKIN); $template->assign("processUid", $processUid); $template->assign("dynaformUid", $dynaFormUid); $template->assign("taskUid", $taskUid); $template->assign("dynFileName", $processUid . "/" . $dynaFormUid); $template->assign("formId", $G_FORM->id); $template->assign("scriptCode", $scriptCode); if (sizeof($sUidGrids) > 0) { foreach ($sUidGrids as $k => $v) { $template->newBlock("grid_uids"); $template->assign("siteUrl", $http . $_SERVER["HTTP_HOST"]); $template->assign("gridFileName", $processUid . "/" . $v); } } //WE_DATA $html = str_replace("</body>", "</form></body>", str_replace("</form>", "", $template->getOutputContent())); $webEntryData = $html; break; } //Update //Update where $criteriaWhere = new \Criteria("workflow"); $criteriaWhere->add(\WebEntryPeer::WE_UID, $webEntryUid); //Update set $criteriaSet = new \Criteria("workflow"); $criteriaSet->add(\WebEntryPeer::WE_DATA, $webEntryData); \BasePeer::doUpdate($criteriaWhere, $criteriaSet, \Propel::getConnection("workflow")); } catch (\Exception $e) { throw $e; } }
public function getDynaformHistory($PRO_UID, $TAS_UID, $APP_UID, $DYN_UID = "") { G::LoadClass('case'); $oCase = new Cases(); $oCase->verifyTable(); $aObjectPermissions = $oCase->getAllObjects($PRO_UID, $APP_UID, $TAS_UID, $_SESSION['USER_LOGGED']); if (!is_array($aObjectPermissions)) { $aObjectPermissions = array('DYNAFORMS' => array(-1), 'INPUT_DOCUMENTS' => array(-1), 'OUTPUT_DOCUMENTS' => array(-1)); } if (!isset($aObjectPermissions['DYNAFORMS'])) { $aObjectPermissions['DYNAFORMS'] = array(-1); } else { if (!is_array($aObjectPermissions['DYNAFORMS'])) { $aObjectPermissions['DYNAFORMS'] = array(-1); } } if (!isset($aObjectPermissions['INPUT_DOCUMENTS'])) { $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1); } else { if (!is_array($aObjectPermissions['INPUT_DOCUMENTS'])) { $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1); } } if (!isset($aObjectPermissions['OUTPUT_DOCUMENTS'])) { $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1); } else { if (!is_array($aObjectPermissions['OUTPUT_DOCUMENTS'])) { $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1); } } $appDocument = new AppDocument(); foreach (array("INPUT_DOCUMENTS", "OUTPUT_DOCUMENTS") as $value) { $key = $value; if ($aObjectPermissions[$key]) { foreach ($aObjectPermissions[$key] as $key2 => $value2) { $appDocumentUid = $value2; try { $arrayAppDocumentData = $appDocument->load($appDocumentUid); $aObjectPermissions[$key][$key2] = $arrayAppDocumentData["DOC_UID"]; } catch (Exception $e) { } } } } $dynaForm = new Dynaform(); $inputDocument = new InputDocument(); $outputDocument = new OutputDocument(); $c = new Criteria('workflow'); $c->addSelectColumn(AppHistoryPeer::APP_UID); $c->addSelectColumn(AppHistoryPeer::DEL_INDEX); $c->addSelectColumn(AppHistoryPeer::PRO_UID); $c->addSelectColumn(AppHistoryPeer::TAS_UID); $c->addSelectColumn(AppHistoryPeer::DYN_UID); $c->addSelectColumn(AppHistoryPeer::OBJ_TYPE); $c->addSelectColumn(AppHistoryPeer::USR_UID); $c->addSelectColumn(AppHistoryPeer::APP_STATUS); $c->addSelectColumn(AppHistoryPeer::HISTORY_DATE); $c->addSelectColumn(AppHistoryPeer::HISTORY_DATA); $c->addSelectColumn(UsersPeer::USR_FIRSTNAME); $c->addSelectColumn(UsersPeer::USR_LASTNAME); $c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)"); $c->addJoin(AppHistoryPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); //WHERE $c->add($c->getNewCriterion(AppHistoryPeer::DYN_UID, $aObjectPermissions["DYNAFORMS"], Criteria::IN)->addOr($c->getNewCriterion(AppHistoryPeer::DYN_UID, $aObjectPermissions["INPUT_DOCUMENTS"], Criteria::IN))->addOr($c->getNewCriterion(AppHistoryPeer::DYN_UID, $aObjectPermissions["OUTPUT_DOCUMENTS"], Criteria::IN))); $c->add(AppHistoryPeer::PRO_UID, $PRO_UID); $c->add(AppHistoryPeer::APP_UID, $APP_UID); $c->add(AppHistoryPeer::TAS_UID, $TAS_UID); if (isset($DYN_UID) && $DYN_UID != "") { $c->add(AppHistoryPeer::DYN_UID, $DYN_UID); } //Execute $oDataset = AppHistoryPeer::doSelectRS($c); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $aDynHistory = array(); $aDynHistory[] = array('DYN_TITLE' => 'char'); while ($oDataset->next()) { $aRow = $oDataset->getRow(); $title = ""; switch ($aRow["OBJ_TYPE"]) { case "DYNAFORM": $arrayDynaFormData = $dynaForm->Load($aRow["DYN_UID"]); $title = $arrayDynaFormData["DYN_TITLE"] . " (" . G::LoadTranslation("ID_DYNAFORM") . ")"; break; case "INPUT_DOCUMENT": $arrayInputDocumentData = $inputDocument->load($aRow["DYN_UID"]); $title = $arrayInputDocumentData["INP_DOC_TITLE"] . " (" . G::LoadTranslation("ID_INPUT_DOCUMENT") . ")"; break; case "OUTPUT_DOCUMENT": $arrayOutputDocumentData = $outputDocument->load($aRow["DYN_UID"]); $title = $arrayOutputDocumentData["OUT_DOC_TITLE"] . " (" . G::LoadTranslation("ID_OUTPUT_DOCUMENT") . ")"; break; case "ASSIGN_TASK": $title = G::LoadTranslation("ID_ASSIGN_TASK") . " (" . G::LoadTranslation("ID_TRIGGERS") . ")"; break; } $aRow["DYN_TITLE"] = $title; $changedValues = unserialize($aRow['HISTORY_DATA']); $html = "<table border='0' cellpadding='0' cellspacing='0'>"; $sw_add = false; foreach ($changedValues as $key => $value) { if ($value != null && !is_array($value)) { $sw_add = true; $html .= "<tr>"; $html .= "<td><b>{$key}:</b> </td>"; $html .= "<td>{$value}</td>"; $html .= "</tr>"; } if (is_array($value)) { $html .= "<tr>"; $html .= "<td><b>{$key} (grid):</b> </td>"; $html .= "<td>"; $html .= "<table>"; foreach ($value as $key1 => $value1) { $html .= "<tr>"; $html .= "<td><b>{$key1}</b></td>"; $html .= "<td>"; if (is_array($value1)) { $sw_add = true; $html .= "<table>"; foreach ($value1 as $key2 => $value2) { $html .= "<tr>"; $html .= "<td><b>{$key2}</b></td>"; $html .= "<td>{$value2}</td>"; $html .= "</tr>"; } $html .= "</table>"; } $html .= "</td>"; $html .= "</tr>"; } $html .= "</table>"; $html .= "</td>"; $html .= "</tr>"; $html .= "</td>"; } } $html .= "</table>"; $aRow['FIELDS'] = $html; if ($sw_add) { $aDynHistory[] = $aRow; } } global $_DBArray; $_DBArray['DynaformsHistory'] = $aDynHistory; $_SESSION['_DBArray'] = $_DBArray; G::LoadClass('ArrayPeer'); $oCriteria = new Criteria('dbarray'); $oCriteria->setDBArrayTable('DynaformsHistory'); $oCriteria->addAscendingOrderByColumn(AppHistoryPeer::HISTORY_DATE); return $oCriteria; }
public function showObjects($pro_uid, $app_uid, $obj_uid, $typeObject) { switch ($typeObject) { case 'DYNAFORM': $oCase = new \Cases(); $Fields = $oCase->loadCase($app_uid); $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = ''; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP_LABEL'] = ''; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP'] = '#'; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'alert("Sample"); return false;'; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PRINT_PREVIEW'] = '#'; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PRINT_PREVIEW_ACTION'] = 'tracker_PrintView?CTO_UID_OBJ=' . $obj_uid . '&CTO_TYPE_OBJ=PRINT_PREVIEW'; $dynaForm = new \Dynaform(); $arrayDynaFormData = $dynaForm->Load($obj_uid); if (isset($arrayDynaFormData["DYN_VERSION"]) && $arrayDynaFormData["DYN_VERSION"] == 2) { \G::LoadClass("pmDynaform"); $Fields["PRO_UID"] = $pro_uid; $Fields["CURRENT_DYNAFORM"] = $obj_uid; $pmDynaForm = new \pmDynaform($Fields); // if ($pmDynaForm->isResponsive()) { // $pmDynaForm->printTracker(); // } $response = $pmDynaForm; } break; case 'INPUT_DOCUMENT': //G::LoadClass( 'case' ); $oCase = new \Cases(); $c = $oCase->getAllUploadedDocumentsCriteriaTracker($pro_uid, $app_uid, $obj_uid); // $response = array(); if ($c->getDbName() == 'dbarray') { $rs = \ArrayBasePeer::doSelectRs($c); $rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $rs->next(); $doc = array(); while ($row = $rs->getRow()) { $doc[] = $row; $rs->next(); } //$response = $this->parserObjects($objects); } $response = $doc; break; case 'OUTPUT_DOCUMENT': //G::LoadClass( 'case' ); $oCase = new \Cases(); $c = $oCase->getAllGeneratedDocumentsCriteriaTracker($pro_uid, $app_uid, $obj_uid); $response = $c; break; } return $response; }
public function updateCase($sAppUid, $Fields = array()) { try { $oApplication = new Application(); if (!$oApplication->exists($sAppUid)) { return false; } $aApplicationFields = $Fields['APP_DATA']; $Fields['APP_UID'] = $sAppUid; $Fields['APP_UPDATE_DATE'] = 'now'; $Fields['APP_DATA'] = serialize($Fields['APP_DATA']); /* $oApp = new Application; $appFields = $oApp->load($sAppUid); */ $oApp = ApplicationPeer::retrieveByPk($sAppUid); $appFields = $oApp->toArray(BasePeer::TYPE_FIELDNAME); if (isset($Fields['APP_TITLE'])) { $appFields['APP_TITLE'] = $Fields['APP_TITLE']; } if (isset($Fields['APP_DESCRIPTION'])) { $appFields['APP_DESCRIPTION'] = $Fields['APP_DESCRIPTION']; } $arrayNewCaseTitleAndDescription = $this->newRefreshCaseTitleAndDescription($sAppUid, $appFields, $aApplicationFields); //Start: Save History --By JHL if (isset($Fields['CURRENT_DYNAFORM'])) { //only when that variable is set.. from Save $FieldsBefore = $this->loadCase($sAppUid); $FieldsDifference = $this->arrayRecursiveDiff($FieldsBefore['APP_DATA'], $aApplicationFields); $fieldsOnBoth = @array_intersect_assoc($FieldsBefore['APP_DATA'], $aApplicationFields); //Add fields that weren't in previous version foreach ($aApplicationFields as $key => $value) { if (!isset($fieldsOnBoth[$key])) { $FieldsDifference[$key] = $value; } } if (is_array($FieldsDifference) && count($FieldsDifference) > 0) { $oCurrentDynaform = new Dynaform(); try { $currentDynaform = $oCurrentDynaform->Load($Fields['CURRENT_DYNAFORM']); } catch (Exception $e) { $currentDynaform["DYN_CONTENT"] = ""; } //There are changes $Fields['APP_STATUS'] = isset($Fields['APP_STATUS']) ? $Fields['APP_STATUS'] : $FieldsBefore['APP_STATUS']; $appHistory = new AppHistory(); $aFieldsHistory = $Fields; $FieldsDifference['DYN_CONTENT_HISTORY'] = base64_encode($currentDynaform["DYN_CONTENT"]); $aFieldsHistory['APP_DATA'] = serialize($FieldsDifference); $appHistory->insertHistory($aFieldsHistory); } } //End Save History //we are removing the app_title and app_description from this array, //because they already be updated in newRefreshCaseTitleAndDescription function if (isset($Fields['APP_TITLE'])) { unset($Fields['APP_TITLE']); } if (isset($Fields['APP_DESCRIPTION'])) { unset($Fields['APP_DESCRIPTION']); } if (isset($Fields["APP_STATUS"]) && $Fields["APP_STATUS"] == "COMPLETED") { if (isset($Fields['CURRENT_USER_UID'])) { $Fields['USR_UID'] = $Fields['CURRENT_USER_UID']; } /*----------------------------------********---------------------------------*/ } $oApp->update($Fields); $DEL_INDEX = isset($Fields['DEL_INDEX']) ? $Fields['DEL_INDEX'] : ''; $TAS_UID = isset($Fields['TAS_UID']) ? $Fields['TAS_UID'] : ''; G::LoadClass('reportTables'); require_once 'classes/model/AdditionalTables.php'; $oReportTables = new ReportTables(); $addtionalTables = new additionalTables(); if (!isset($Fields['APP_NUMBER'])) { $Fields['APP_NUMBER'] = $appFields['APP_NUMBER']; } if (!isset($Fields['APP_STATUS'])) { $Fields['APP_STATUS'] = $appFields['APP_STATUS']; } $oReportTables->updateTables($appFields['PRO_UID'], $sAppUid, $Fields['APP_NUMBER'], $aApplicationFields); $addtionalTables->updateReportTables($appFields['PRO_UID'], $sAppUid, $Fields['APP_NUMBER'], $aApplicationFields, $Fields['APP_STATUS']); //now update the priority in appdelegation table, using the defined variable in task if (trim($DEL_INDEX) != '' && trim($TAS_UID) != '') { //optimized code to avoid load task content row. $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(TaskPeer::TAS_PRIORITY_VARIABLE); $c->add(TaskPeer::TAS_UID, $TAS_UID); $rs = TaskPeer::doSelectRS($c); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->next(); $row = $rs->getRow(); $VAR_PRI = substr($row['TAS_PRIORITY_VARIABLE'], 2); //end optimized code. $x = unserialize($Fields['APP_DATA']); if (isset($x[$VAR_PRI])) { if (trim($x[$VAR_PRI]) != '') { $oDel = new AppDelegation(); $array = array(); $array['APP_UID'] = $sAppUid; $array['DEL_INDEX'] = $DEL_INDEX; $array['TAS_UID'] = $TAS_UID; $array['DEL_PRIORITY'] = isset($x[$VAR_PRI]) ? $x[$VAR_PRI] >= 1 && $x[$VAR_PRI] <= 5 ? $x[$VAR_PRI] : '3' : '3'; $oDel->update($array); } } } //Update Solr Index if ($this->appSolr != null) { $this->appSolr->updateApplicationSearchIndex($sAppUid); } if ($Fields["APP_STATUS"] == "COMPLETED") { //Delete records of the table APP_ASSIGN_SELF_SERVICE_VALUE $appAssignSelfServiceValue = new AppAssignSelfServiceValue(); $appAssignSelfServiceValue->remove($sAppUid); } /*----------------------------------********---------------------------------*/ //Return return $Fields; } catch (exception $e) { throw $e; } }