public function getExtObjectsPermissions($start, $limit, $sProcessUID) { G::LoadClass('case'); Cases::verifyTable(); $aObjectsPermissions = array(); //$aObjectsPermissions [] = array('OP_UID' => 'char', 'TASK_TARGET' => 'char', 'GROUP_USER' => 'char', 'TASK_SOURCE' => 'char', 'OBJECT_TYPE' => 'char', 'OBJECT' => 'char', 'PARTICIPATED' => 'char', 'ACTION' => 'char', 'OP_CASE_STATUS' => 'char'); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_UID); $oCriteria->addSelectColumn(ObjectPermissionPeer::TAS_UID); $oCriteria->addSelectColumn(ObjectPermissionPeer::USR_UID); $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_USER_RELATION); $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_TASK_SOURCE); $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_PARTICIPATE); $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_OBJ_TYPE); $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_OBJ_UID); $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_ACTION); $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_CASE_STATUS); $oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID); $this->tmpCriteria = clone $oCriteria; if ($start != '') { $oCriteria->setOffset($start); } if ($limit != '') { $oCriteria->setLimit($limit); } $oDataset = ObjectPermissionPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { //Obtain task target if ($aRow['TAS_UID'] != '' && $aRow['TAS_UID'] != '0') { try { $oTask = new Task(); $aFields = $oTask->load($aRow['TAS_UID']); $sTaskTarget = $aFields['TAS_TITLE']; } catch (Exception $oError) { $sTaskTarget = 'All Tasks'; } } else { $sTaskTarget = G::LoadTranslation('ID_ANY_TASK'); } //Obtain user or group if ($aRow['OP_USER_RELATION'] == 1) { $oUser = new Users(); $aFields = $oUser->load($aRow['USR_UID']); $sUserGroup = $aFields['USR_FIRSTNAME'] . ' ' . $aFields['USR_LASTNAME'] . ' (' . $aFields['USR_USERNAME'] . ')'; } else { $oGroup = new Groupwf(); if ($aRow['USR_UID'] != '') { try { $aFields = $oGroup->load($aRow['USR_UID']); $sUserGroup = $aFields['GRP_TITLE']; } catch (Exception $oError) { $sUserGroup = '(GROUP DELETED)'; } } else { $sUserGroup = G::LoadTranslation('ID_ANY'); } } //Obtain task source if ($aRow['OP_TASK_SOURCE'] != '' && $aRow['OP_TASK_SOURCE'] != '0') { try { $oTask = new Task(); $aFields = $oTask->load($aRow['OP_TASK_SOURCE']); $sTaskSource = $aFields['TAS_TITLE']; } catch (Exception $oError) { $sTaskSource = 'All Tasks'; } } else { $sTaskSource = G::LoadTranslation('ID_ANY_TASK'); } //Obtain object and type switch ($aRow['OP_OBJ_TYPE']) { case 'ALL': $sObjectType = G::LoadTranslation('ID_ALL'); $sObject = G::LoadTranslation('ID_ALL'); break; case 'DYNAFORM': $sObjectType = G::LoadTranslation('ID_DYNAFORM'); if ($aRow['OP_OBJ_UID'] != '' && $aRow['OP_OBJ_UID'] != '0') { $oDynaform = new Dynaform(); $aFields = $oDynaform->load($aRow['OP_OBJ_UID']); $sObject = $aFields['DYN_TITLE']; } else { $sObject = G::LoadTranslation('ID_ALL'); } break; case 'INPUT': $sObjectType = G::LoadTranslation('ID_INPUT_DOCUMENT'); if ($aRow['OP_OBJ_UID'] != '' && $aRow['OP_OBJ_UID'] != '0') { $oInputDocument = new InputDocument(); $aFields = $oInputDocument->load($aRow['OP_OBJ_UID']); $sObject = $aFields['INP_DOC_TITLE']; } else { $sObject = G::LoadTranslation('ID_ALL'); } break; case 'OUTPUT': $sObjectType = G::LoadTranslation('ID_OUTPUT_DOCUMENT'); if ($aRow['OP_OBJ_UID'] != '' && $aRow['OP_OBJ_UID'] != '0') { $oOutputDocument = new OutputDocument(); $aFields = $oOutputDocument->load($aRow['OP_OBJ_UID']); $sObject = $aFields['OUT_DOC_TITLE']; } else { $sObject = G::LoadTranslation('ID_ALL'); } break; } //Participated if ($aRow['OP_PARTICIPATE'] == 0) { $sParticipated = G::LoadTranslation('ID_NO'); } else { $sParticipated = G::LoadTranslation('ID_YES'); } //Obtain action (permission) $sAction = G::LoadTranslation('ID_' . $aRow['OP_ACTION']); //Add to array $aObjectsPermissions[] = array('OP_UID' => $aRow['OP_UID'], 'TASK_TARGET' => $sTaskTarget, 'GROUP_USER' => $sUserGroup, 'TASK_SOURCE' => $sTaskSource, 'OBJECT_TYPE' => $sObjectType, 'OBJECT' => $sObject, 'PARTICIPATED' => $sParticipated, 'ACTION' => $sAction, 'OP_CASE_STATUS' => $aRow['OP_CASE_STATUS']); $oDataset->next(); } return $aObjectsPermissions; }
public function getDirectoryContentSortedBy ($folderID, $docIdFilter = array(), $keyword = null, $searchType = null, $limit = 0, $start = 0, $user = '', $onlyActive = false, $direction = 'ASC', $ColumnSort = 'appDocCreateDate', $search = null) { G::LoadClass( 'case' ); $oCase = new Cases(); G::LoadClass( 'process' ); $oProcess = new Process(); $oAppDocument = new AppDocument(); $oCriteria = new Criteria(); $oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_UID); $oCriteria->addSelectColumn( AppDocumentPeer::DOC_VERSION); $oCriteria->addSelectColumn( AppDocumentPeer::APP_UID); $oCriteria->addSelectColumn( AppDocumentPeer::DEL_INDEX); $oCriteria->addSelectColumn( AppDocumentPeer::DOC_UID); $oCriteria->addSelectColumn( AppDocumentPeer::USR_UID); $oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_TYPE); $oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_CREATE_DATE); $oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_INDEX); $oCriteria->addSelectColumn( AppDocumentPeer::FOLDER_UID); $oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_PLUGIN); $oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_TAGS); $oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_STATUS); $oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_STATUS_DATE); $oCriteria->addSelectColumn( AppDocumentPeer::APP_DOC_FIELDNAME); if ((is_array( $docIdFilter )) && (count( $docIdFilter ) > 0)) { //Search by App Doc UID no matter what Folder it is $oCriteria->add( AppDocumentPeer::APP_DOC_UID, $docIdFilter, CRITERIA::IN ); } elseif ($folderID != null) { if ($folderID == "/") { $oCriteria->add( AppDocumentPeer::FOLDER_UID, array ('root','',null), CRITERIA::IN ); } else { $oCriteria->add( AppDocumentPeer::FOLDER_UID, $folderID ); } } elseif ($searchType == "TAG") { $oCriteria->add( AppDocumentPeer::APP_DOC_TAGS, "%" . $keyword . "%", CRITERIA::LIKE ); } require_once ("classes/model/AppDelegation.php"); if ($user != '') { require_once ("classes/model/AppDelegation.php"); $criteria = new Criteria(); $criteria->addSelectColumn( AppDelegationPeer::APP_UID ); $criteria->setDistinct(); $conditions = array (); $conditions[] = array (AppDelegationPeer::APP_UID,AppDocumentPeer::APP_UID); $conditions[] = array (AppDelegationPeer::DEL_INDEX,AppDocumentPeer::DEL_INDEX); $criteria->addJoinMC( $conditions, Criteria::LEFT_JOIN ); $criteria->add( AppDelegationPeer::USR_UID, $user ); $rs2 = AppDocumentPeer::doSelectRS( $criteria ); $rs2->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $data = array (); while ($rs2->next()) { $row = $rs2->getRow(); $data[] = $row['APP_UID']; } $oCriteria->add( AppDocumentPeer::APP_UID, $data, CRITERIA::IN ); } if ($onlyActive) { $oCriteria->add( AppDocumentPeer::APP_DOC_STATUS, 'ACTIVE' ); } $oCriteria->addSelectColumn( ContentPeer::CON_VALUE . ' AS NAME'); $oCriteria->add( ContentPeer::CON_CATEGORY, "APP_DOC_FILENAME"); $oCriteria->add( ContentPeer::CON_LANG, SYS_LANG); $oCriteria->addJoin( AppDocumentPeer::APP_DOC_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN ); $oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME); $oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME); $oCriteria->addJoin( AppDocumentPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN ); if ($search) { $oCriteria->add( $oCriteria->getNewCriterion( ContentPeer::CON_VALUE, '%' . $search . '%', Criteria::LIKE )-> addOr( $oCriteria->getNewCriterion( UsersPeer::USR_FIRSTNAME, '%' . $search . '%', Criteria::LIKE )-> addOr( $oCriteria->getNewCriterion( UsersPeer::USR_LASTNAME, '%' . $search . '%', Criteria::LIKE ))) ); } $numRecTotal = AppDocumentPeer::doCount($oCriteria); $oCase->verifyTable(); //Need to review hot to get the Column Type name switch($ColumnSort) { case 'appDocCreateDate' : $ColumnSort = AppDocumentPeer::APP_DOC_CREATE_DATE; break; case 'name' : $ColumnSort = 'NAME'; break; default: break; } if($direction == 'ASC') { $oCriteria->addAscendingOrderByColumn( $ColumnSort ); } else { $oCriteria->addDescendingOrderByColumn( $ColumnSort ); } $response['documents'] = array (); $oCriteria->setLimit( $limit ); $oCriteria->setOffset( $start ); $rs = AppDocumentPeer::doSelectRS( $oCriteria ); $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $rs->next(); $filesResult = array (); while (is_array( $row = $rs->getRow() )) { //**** start get Doc Info $oApp = new Application(); if (($oApp->exists( $row['APP_UID'] )) || ($row['APP_UID'] == "00000000000000000000000000000000")) { //$completeInfo = array("APP_DOC_FILENAME" => $row ["APP_DOC_UID"],"APP_DOC_UID"=>$row ['APP_UID']); $completeInfo = $this->getCompleteDocumentInfo( $row['APP_UID'], $row['APP_DOC_UID'], $row['DOC_VERSION'], $row['DOC_UID'], $row['USR_UID'] ); $oAppDocument = new AppDocument(); $lastVersion = $oAppDocument->getLastAppDocVersion( $row['APP_DOC_UID'], $row['APP_UID'] ); if ($completeInfo['APP_DOC_STATUS'] != "DELETED") { if (in_array($row["APP_DOC_UID"], $completeInfo["INPUT_DOCUMENTS"]) || in_array($row["APP_DOC_UID"], $completeInfo["OUTPUT_DOCUMENTS"]) || in_array($completeInfo["USR_UID"], array($_SESSION["USER_LOGGED"], "-1")) || $user == "") { if (count( $docIdFilter ) > 0) { if (in_array( $row['APP_DOC_UID'], $docIdFilter )) { $response['documents'][] = $completeInfo; } } else { if ($lastVersion == $row["DOC_VERSION"]) { //Only Last Document version if ($searchType == "ALL") { //If search in name of docs is active then filter if (stripos($completeInfo["APP_DOC_FILENAME"], $keyword) !== false || stripos($completeInfo["APP_DOC_TAGS"], $keyword) !== false) { $response["documents"][] = $completeInfo; } } else { //No search filter active $response["documents"][] = $completeInfo; } } } } } } $rs->next(); } $response["totalDocumentsCount"] = $numRecTotal; return $response; }
public function getFolderContent($folderID, $docIdFilter = array(), $keyword = null, $searchType = null, $limit = 0, $start = 0, $user = '', $onlyActive = false) { require_once "classes/model/AppDocument.php"; require_once "classes/model/InputDocument.php"; require_once "classes/model/OutputDocument.php"; require_once "classes/model/Users.php"; G::LoadClass('case'); $oCase = new Cases(); G::LoadClass('process'); $oProcess = new Process(); $oAppDocument = new AppDocument(); $oCriteria = new Criteria(); if (is_array($docIdFilter) && count($docIdFilter) > 0) { //Search by App Doc UID no matter what Folder it is $oCriteria->add(AppDocumentPeer::APP_DOC_UID, $docIdFilter, CRITERIA::IN); } elseif ($folderID != null) { if ($folderID == "/") { $oCriteria->add(AppDocumentPeer::FOLDER_UID, array('root', '', null), CRITERIA::IN); } else { $oCriteria->add(AppDocumentPeer::FOLDER_UID, $folderID); } } elseif ($searchType == "TAG") { $oCriteria->add(AppDocumentPeer::APP_DOC_TAGS, "%" . $keyword . "%", CRITERIA::LIKE); } if ($user != '') { require_once "classes/model/AppDelegation.php"; $criteria = new Criteria(); $criteria->addSelectColumn(AppDelegationPeer::APP_UID); $criteria->setDistinct(); $conditions = array(); $conditions[] = array(AppDelegationPeer::APP_UID, AppDocumentPeer::APP_UID); $conditions[] = array(AppDelegationPeer::DEL_INDEX, AppDocumentPeer::DEL_INDEX); $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN); $criteria->add(AppDelegationPeer::USR_UID, $user); $rs2 = AppDocumentPeer::doSelectRS($criteria); $rs2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $data = array(); while ($rs2->next()) { $row = $rs2->getRow(); $data[] = $row['APP_UID']; } $oCriteria->add(AppDocumentPeer::APP_UID, $data, CRITERIA::IN); } if ($onlyActive) { $oCriteria->add(AppDocumentPeer::APP_DOC_STATUS, 'ACTIVE'); } $numRecTotal = AppDocumentPeer::doCount($oCriteria); $auxCriteria = clone $oCriteria; $auxCriteria->addJoin(AppDocumentPeer::DOC_UID, OutputDocumentPeer::OUT_DOC_UID); $auxCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT'); $auxCriteria->add(OutputDocumentPeer::OUT_DOC_UID, '-1', Criteria::NOT_EQUAL); $auxCriteria->add(OutputDocumentPeer::OUT_DOC_GENERATE, 'BOTH'); $numRecTotal += AppDocumentPeer::doCount($auxCriteria); $oCase->verifyTable(); $oCriteria->addAscendingOrderByColumn(AppDocumentPeer::APP_DOC_INDEX); $oCriteria->addDescendingOrderByColumn(AppDocumentPeer::DOC_VERSION); $response['documents'] = array(); $oCriteria->setLimit($limit); $oCriteria->setOffset($start); $rs = AppDocumentPeer::doSelectRS($oCriteria); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->next(); $filesResult = array(); while (is_array($row = $rs->getRow())) { //**** start get Doc Info $oApp = new Application(); if ($oApp->exists($row['APP_UID']) || $row['APP_UID'] == "00000000000000000000000000000000") { //$completeInfo = array("APP_DOC_FILENAME" => $row ["APP_DOC_UID"],"APP_DOC_UID"=>$row ['APP_UID']); $completeInfo = $this->getCompleteDocumentInfo($row['APP_UID'], $row['APP_DOC_UID'], $row['DOC_VERSION'], $row['DOC_UID'], $row['USR_UID']); $oAppDocument = new AppDocument(); $lastVersion = $oAppDocument->getLastAppDocVersion($row['APP_DOC_UID'], $row['APP_UID']); //$filesResult [] = $completeInfo; if ($completeInfo['APP_DOC_STATUS'] != "DELETED") { if (in_array($row['APP_DOC_UID'], $completeInfo['INPUT_DOCUMENTS']) || in_array($row['APP_DOC_UID'], $completeInfo['OUTPUT_DOCUMENTS']) || in_array($completeInfo['USR_UID'], array($_SESSION['USER_LOGGED'], '-1'))) { if (count($docIdFilter) > 0) { if (in_array($row['APP_DOC_UID'], $docIdFilter)) { $response['documents'][] = $completeInfo; } } elseif ($lastVersion == $row['DOC_VERSION']) { //Only Last Document version if ($searchType == "ALL") { // If search in name of docs is active then filter if (stripos($completeInfo['APP_DOC_FILENAME'], $keyword) !== false || stripos($completeInfo['APP_DOC_TAGS'], $keyword) !== false) { $response['documents'][] = $completeInfo; } } else { //No search filter active $response['documents'][] = $completeInfo; } } } } } $rs->next(); } $response["totalDocumentsCount"] = $numRecTotal; return $response; }
function getFolderContent($folderID, $docIdFilter = array(), $keyword = NULL, $searchType = NULL, $limit = 0, $start = 0) { require_once "classes/model/AppDocument.php"; require_once "classes/model/InputDocument.php"; require_once "classes/model/OutputDocument.php"; require_once "classes/model/Users.php"; G::LoadClass('case'); $oCase = new Cases(); G::LoadClass('process'); $oProcess = new Process(); $oAppDocument = new AppDocument(); $oCriteria = new Criteria(); if (is_array($docIdFilter) && count($docIdFilter) > 0) { //Search by App Doc UID no matter what Folder it is $oCriteria->add(AppDocumentPeer::APP_DOC_UID, $docIdFilter, CRITERIA::IN); } elseif ($folderID != NULL) { if ($folderID == "/") { $oCriteria->add(AppDocumentPeer::FOLDER_UID, array('root', '', NULL), CRITERIA::IN); } else { $oCriteria->add(AppDocumentPeer::FOLDER_UID, $folderID); } } elseif ($searchType == "TAG") { $oCriteria->add(AppDocumentPeer::APP_DOC_TAGS, "%" . $keyword . "%", CRITERIA::LIKE); } $oCase->verifyTable(); $oCriteria->addAscendingOrderByColumn(AppDocumentPeer::APP_DOC_INDEX); $oCriteria->addDescendingOrderByColumn(AppDocumentPeer::DOC_VERSION); $response['totalDocumentsCount'] = AppDocumentPeer::doCount($oCriteria); $response['documents'] = array(); $oCriteria->setLimit($limit); $oCriteria->setOffset($start); $rs = AppDocumentPeer::doSelectRS($oCriteria); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->next(); $filesResult = array(); while (is_array($row = $rs->getRow())) { //**** start get Doc Info $oApp = new Application(); if ($oApp->exists($row['APP_UID']) || $row['APP_UID'] == "00000000000000000000000000000000") { //$completeInfo = array("APP_DOC_FILENAME" => $row ["APP_DOC_UID"],"APP_DOC_UID"=>$row ['APP_UID']); $completeInfo = $this->getCompleteDocumentInfo($row['APP_UID'], $row['APP_DOC_UID'], $row['DOC_VERSION'], $row['DOC_UID'], $row['USR_UID']); $oAppDocument = new AppDocument(); $lastVersion = $oAppDocument->getLastAppDocVersion($row['APP_DOC_UID'], $row['APP_UID']); //$filesResult [] = $completeInfo; if ($completeInfo['APP_DOC_STATUS'] != "DELETED") { if (in_array($row['APP_DOC_UID'], $completeInfo['INPUT_DOCUMENTS']) || in_array($row['APP_DOC_UID'], $completeInfo['OUTPUT_DOCUMENTS']) || in_array($completeInfo['USR_UID'], array($_SESSION['USER_LOGGED'], '-1'))) { if (count($docIdFilter) > 0) { if (in_array($row['APP_DOC_UID'], $docIdFilter)) { $response['documents'][] = $completeInfo; } } elseif ($lastVersion == $row['DOC_VERSION']) { //Only Last Document version if ($searchType == "ALL") { // If search in name of docs is active then filter if (stripos($completeInfo['APP_DOC_FILENAME'], $keyword) !== false || stripos($completeInfo['APP_DOC_TAGS'], $keyword) !== false) { $response['documents'][] = $completeInfo; } } else { //No search filter active $response['documents'][] = $completeInfo; } } } } } $rs->next(); } return $response; }
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 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); } } $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::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(AppHistoryPeer::DYN_UID, $aObjectPermissions['DYNAFORMS'], Criteria::IN); $c->add(AppHistoryPeer::PRO_UID, $PRO_UID); $c->add(AppHistoryPeer::APP_UID, $APP_UID); if (isset($DYN_UID) && $DYN_UID != "") { $c->add(AppHistoryPeer::DYN_UID, $DYN_UID); } //ORDER BY $c->clearOrderByColumns(); $c->addDescendingOrderByColumn(AppHistoryPeer::HISTORY_DATE); //Execute $oDataset = AppHistoryPeer::doSelectRS($c); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aDynHistory = array(); $aDynHistory[] = array('DYN_TITLE' => 'char'); while ($aRow = $oDataset->getRow()) { $o = new Dynaform(); $o->setDynUid($aRow['DYN_UID']); $aRow['DYN_TITLE'] = $o->getDynTitle(); $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; } $oDataset->next(); } global $_DBArray; $_DBArray['DynaformsHistory'] = $aDynHistory; $_SESSION['_DBArray'] = $_DBArray; G::LoadClass('ArrayPeer'); $oCriteria = new Criteria('dbarray'); $oCriteria->setDBArrayTable('DynaformsHistory'); $oCriteria->addDescendingOrderByColumn(AppHistoryPeer::HISTORY_DATE); return $oCriteria; }