public function getNotesList($appUid, $usrUid = '', $start = '', $limit = 25, $sort = 'APP_NOTES.NOTE_DATE', $dir = 'DESC', $dateFrom = '', $dateTo = '', $search = '') { $Criteria = new Criteria('workflow'); $Criteria->clearSelectColumns(); $Criteria->addSelectColumn(AppNotesPeer::APP_UID); $Criteria->addSelectColumn(AppNotesPeer::USR_UID); $Criteria->addSelectColumn(AppNotesPeer::NOTE_DATE); $Criteria->addSelectColumn(AppNotesPeer::NOTE_CONTENT); $Criteria->addSelectColumn(AppNotesPeer::NOTE_TYPE); $Criteria->addSelectColumn(AppNotesPeer::NOTE_AVAILABILITY); $Criteria->addSelectColumn(AppNotesPeer::NOTE_ORIGIN_OBJ); $Criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ1); $Criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ2); $Criteria->addSelectColumn(AppNotesPeer::NOTE_RECIPIENTS); $Criteria->addSelectColumn(UsersPeer::USR_USERNAME); $Criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $Criteria->addSelectColumn(UsersPeer::USR_LASTNAME); $Criteria->addSelectColumn(UsersPeer::USR_EMAIL); $Criteria->addJoin(AppNotesPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); $Criteria->add(AppNotesPeer::APP_UID, $appUid, Criteria::EQUAL); if ($usrUid != '') { $Criteria->add(AppNotesPeer::USR_UID, $usrUid, Criteria::EQUAL); } if ($dateFrom != '') { $Criteria->add(AppNotesPeer::NOTE_DATE, $dateFrom, Criteria::GREATER_EQUAL); } if ($dateTo != '') { $Criteria->add(AppNotesPeer::NOTE_DATE, $dateTo, Criteria::LESS_EQUAL); } if ($search != '') { $Criteria->add(AppNotesPeer::NOTE_CONTENT, '%' . $search . '%', Criteria::LIKE); } if ($dir == 'DESC') { $Criteria->addDescendingOrderByColumn($sort); } else { $Criteria->addAscendingOrderByColumn($sort); } $response = array(); $totalCount = AppNotesPeer::doCount($Criteria); $response['totalCount'] = $totalCount; $response['notes'] = array(); if ($start != '') { $Criteria->setLimit($limit); $Criteria->setOffset($start); } $oDataset = appNotesPeer::doSelectRS($Criteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aRow['NOTE_CONTENT'] = htmlentities(stripslashes($aRow['NOTE_CONTENT']), ENT_QUOTES, 'UTF-8'); $response['notes'][] = $aRow; $oDataset->next(); } $result['criteria'] = $Criteria; $result['array'] = $response; return $result; }
/** * Implementation for 'GET' method for Rest API * * @param mixed Primary key * * @return array $result Returns array within multiple records or a single record depending if * a single selection was requested passing id(s) as param */ protected function get() { $result = array(); try { $noArguments = true; $argumentList = func_get_args(); foreach ($argumentList as $arg) { if (!is_null($arg)) { $noArguments = false; } } if ($noArguments) { $criteria = new Criteria('workflow'); $criteria->addSelectColumn(AppNotesPeer::APP_UID); $criteria->addSelectColumn(AppNotesPeer::USR_UID); $criteria->addSelectColumn(AppNotesPeer::NOTE_DATE); $criteria->addSelectColumn(AppNotesPeer::NOTE_CONTENT); $criteria->addSelectColumn(AppNotesPeer::NOTE_TYPE); $criteria->addSelectColumn(AppNotesPeer::NOTE_AVAILABILITY); $criteria->addSelectColumn(AppNotesPeer::NOTE_ORIGIN_OBJ); $criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ1); $criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ2); $criteria->addSelectColumn(AppNotesPeer::NOTE_RECIPIENTS); $dataset = AppEventPeer::doSelectRS($criteria); $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($dataset->next()) { $result[] = $dataset->getRow(); } } else { $record = AppNotesPeer::retrieveByPK(); if ($record) { $result = $record->toArray(BasePeer::TYPE_FIELDNAME); } else { $paramValues = ""; foreach ($argumentList as $arg) { $paramValues .= strlen($paramValues) ? ', ' : ''; if (!is_null($arg)) { $paramValues .= "{$arg}"; } else { $paramValues .= "NULL"; } } throw new RestException(417, "table AppNotes ({$paramValues})"); } } } catch (RestException $e) { throw new RestException($e->getCode(), $e->getMessage()); } catch (Exception $e) { throw new RestException(412, $e->getMessage()); } return $result; }
public function getNotesList($appUid, $usrUid = '', $start = '', $limit = '') { require_once "classes/model/Users.php"; G::LoadClass('ArrayPeer'); $Criteria = new Criteria('workflow'); $Criteria->clearSelectColumns(); $Criteria->addSelectColumn(AppNotesPeer::APP_UID); $Criteria->addSelectColumn(AppNotesPeer::USR_UID); $Criteria->addSelectColumn(AppNotesPeer::NOTE_DATE); $Criteria->addSelectColumn(AppNotesPeer::NOTE_CONTENT); $Criteria->addSelectColumn(AppNotesPeer::NOTE_TYPE); $Criteria->addSelectColumn(AppNotesPeer::NOTE_AVAILABILITY); $Criteria->addSelectColumn(AppNotesPeer::NOTE_ORIGIN_OBJ); $Criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ1); $Criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ2); $Criteria->addSelectColumn(AppNotesPeer::NOTE_RECIPIENTS); $Criteria->addSelectColumn(UsersPeer::USR_USERNAME); $Criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $Criteria->addSelectColumn(UsersPeer::USR_LASTNAME); $Criteria->addSelectColumn(UsersPeer::USR_EMAIL); $Criteria->addJoin(AppNotesPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); $Criteria->add(appNotesPeer::APP_UID, $appUid, CRITERIA::EQUAL); if ($usrUid != '') { $Criteria->add(appNotesPeer::USR_UID, $usrUid, CRITERIA::EQUAL); } $Criteria->addDescendingOrderByColumn(AppNotesPeer::NOTE_DATE); $response = array(); $totalCount = AppNotesPeer::doCount($Criteria); $response['totalCount'] = $totalCount; $response['notes'] = array(); if ($start != '') { $Criteria->setLimit($limit); $Criteria->setOffset($start); } $oDataset = appNotesPeer::doSelectRS($Criteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aRow['NOTE_CONTENT'] = htmlentities(stripslashes($aRow['NOTE_CONTENT']), ENT_QUOTES, 'UTF-8'); $response['notes'][] = $aRow; $oDataset->next(); } $result['criteria'] = $Criteria; $result['array'] = $response; return $result; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = AppNotesPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setAppUid($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setUsrUid($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setNoteDate($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setNoteContent($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setNoteType($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setNoteAvailability($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setNoteOriginObj($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setNoteAffectedObj1($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setNoteAffectedObj2($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setNoteRecipients($arr[$keys[9]]); } }
public function removeCase($sAppUid) { try { $this->getExecuteTriggerProcess($sAppUid, 'DELETED'); $oAppDelegation = new AppDelegation(); $oAppDocument = new AppDocument(); //Delete the delegations of a application $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(AppDelegationPeer::APP_UID, $sAppUid); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); while ($aRow2 = $oDataset2->getRow()) { $oAppDelegation->remove($sAppUid, $aRow2['DEL_INDEX']); $oDataset2->next(); } //Delete the documents assigned to a application $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(AppDocumentPeer::APP_UID, $sAppUid); $oDataset2 = AppDocumentPeer::doSelectRS($oCriteria2); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); while ($aRow2 = $oDataset2->getRow()) { $oAppDocument->remove($aRow2['APP_DOC_UID'], $aRow2['DOC_VERSION']); $oDataset2->next(); } //Delete the actions from a application $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(AppDelayPeer::APP_UID, $sAppUid); AppDelayPeer::doDelete($oCriteria2); //Delete the messages from a application $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(AppMessagePeer::APP_UID, $sAppUid); AppMessagePeer::doDelete($oCriteria2); //Delete the threads from a application $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(AppThreadPeer::APP_UID, $sAppUid); AppThreadPeer::doDelete($oCriteria2); //Delete the events from a application $criteria = new Criteria("workflow"); $criteria->add(AppEventPeer::APP_UID, $sAppUid); AppEventPeer::doDelete($criteria); //Delete the histories from a application $criteria = new Criteria("workflow"); $criteria->add(AppHistoryPeer::APP_UID, $sAppUid); AppHistoryPeer::doDelete($criteria); //Delete the notes from a application $criteria = new Criteria("workflow"); $criteria->add(AppNotesPeer::APP_UID, $sAppUid); AppNotesPeer::doDelete($criteria); //Delete the owners from a application $criteria = new Criteria("workflow"); $criteria->add(AppOwnerPeer::APP_UID, $sAppUid); AppOwnerPeer::doDelete($criteria); //Delete the SolrQueue from a application $criteria = new Criteria("workflow"); $criteria->add(AppSolrQueuePeer::APP_UID, $sAppUid); AppSolrQueuePeer::doDelete($criteria); //Before delete verify if is a child case $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(SubApplicationPeer::APP_UID, $sAppUid); $oCriteria2->add(SubApplicationPeer::SA_STATUS, 'ACTIVE'); if (SubApplicationPeer::doCount($oCriteria2) > 0) { G::LoadClass('derivation'); $oDerivation = new Derivation(); $oDerivation->verifyIsCaseChild($sAppUid); } //Delete the registries in the table SUB_APPLICATION $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(SubApplicationPeer::APP_UID, $sAppUid); SubApplicationPeer::doDelete($oCriteria2); $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(SubApplicationPeer::APP_PARENT, $sAppUid); SubApplicationPeer::doDelete($oCriteria2); //Delete records of the table APP_ASSIGN_SELF_SERVICE_VALUE $appAssignSelfServiceValue = new AppAssignSelfServiceValue(); $appAssignSelfServiceValue->remove($sAppUid); //Delete records of the Report Table $this->reportTableDeleteRecord($sAppUid); //Delete record of the APPLICATION table (trigger: delete records of the APP_CACHE_VIEW table) $application = new Application(); $result = $application->remove($sAppUid); //delete application from index if ($this->appSolr != null) { $this->appSolr->deleteApplicationSearchIndex($sAppUid); } /*----------------------------------********---------------------------------*/ return $result; } catch (exception $e) { throw ($e); } }
/** * The returned array will contain objects of the default type or * objects that inherit from the default. * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function populateObjects(ResultSet $rs) { $results = array(); // set the class once to avoid overhead in the loop $cls = AppNotesPeer::getOMClass(); $cls = Propel::import($cls); // populate the object(s) while ($rs->next()) { $obj = new $cls(); $obj->hydrate($rs); $results[] = $obj; } return $results; }
/** * Get Case Notes * * @access public * @param string $app_uid, Uid for case * @return array * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia */ public function getCaseNotes($app_uid, $usr_uid, $data_get) { Validator::isString($app_uid, '$app_uid'); Validator::appUid($app_uid, '$app_uid'); Validator::isString($usr_uid, '$usr_uid'); Validator::usrUid($usr_uid, '$usr_uid'); Validator::isArray($data_get, '$data_get'); Validator::isArray($data_get, '$data_get'); $start = isset( $data_get["start"] ) ? $data_get["start"] : "0"; $limit = isset( $data_get["limit"] ) ? $data_get["limit"] : ""; $sort = isset( $data_get["sort"] ) ? $data_get["sort"] : "APP_NOTES.NOTE_DATE"; $dir = isset( $data_get["dir"] ) ? $data_get["dir"] : "DESC"; $user = isset( $data_get["user"] ) ? $data_get["user"] : ""; $dateFrom = (!empty( $data_get["dateFrom"] )) ? substr( $data_get["dateFrom"], 0, 10 ) : ""; $dateTo = (!empty( $data_get["dateTo"] )) ? substr( $data_get["dateTo"], 0, 10 ) : ""; $search = isset( $data_get["search"] ) ? $data_get["search"] : ""; $paged = isset( $data_get["paged"] ) ? $data_get["paged"] : true; $case = new \Cases(); $caseLoad = $case->loadCase($app_uid); $pro_uid = $caseLoad['PRO_UID']; $tas_uid = \AppDelegation::getCurrentTask($app_uid); $respView = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW' ); $respBlock = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK' ); if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) { throw (new \Exception(\G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS"))); } if ($sort != 'APP_NOTE.NOTE_DATE') { $sort = G::toUpper($sort); $columnsAppCacheView = \AppNotesPeer::getFieldNames(\BasePeer::TYPE_FIELDNAME); if (!(in_array($sort, $columnsAppCacheView))) { $sort = 'APP_NOTES.NOTE_DATE'; } else { $sort = 'APP_NOTES.'.$sort; } } if ((int)$start == 1 || (int)$start == 0) { $start = 0; } $dir = G::toUpper($dir); if (!($dir == 'DESC' || $dir == 'ASC')) { $dir = 'DESC'; } if ($user != '') { Validator::usrUid($user, '$usr_uid'); } if ($dateFrom != '') { Validator::isDate($dateFrom, 'Y-m-d', '$date_from'); } if ($dateTo != '') { Validator::isDate($dateTo, 'Y-m-d', '$date_to'); } $appNote = new \AppNotes(); $note_data = $appNote->getNotesList($app_uid, $user, $start, $limit, $sort, $dir, $dateFrom, $dateTo, $search); $response = array(); if ($paged === true) { $response['total'] = $note_data['array']['totalCount']; $response['start'] = $start; $response['limit'] = $limit; $response['sort'] = $sort; $response['dir'] = $dir; $response['usr_uid'] = $user; $response['date_to'] = $dateTo; $response['date_from'] = $dateFrom; $response['search'] = $search; $response['data'] = array(); $con = 0; foreach ($note_data['array']['notes'] as $value) { $response['data'][$con]['app_uid'] = $value['APP_UID']; $response['data'][$con]['usr_uid'] = $value['USR_UID']; $response['data'][$con]['note_date'] = $value['NOTE_DATE']; $response['data'][$con]['note_content'] = $value['NOTE_CONTENT']; $con++; } } else { $con = 0; foreach ($note_data['array']['notes'] as $value) { $response[$con]['app_uid'] = $value['APP_UID']; $response[$con]['usr_uid'] = $value['USR_UID']; $response[$con]['note_date'] = $value['NOTE_DATE']; $response[$con]['note_content'] = $value['NOTE_CONTENT']; $con++; } } return $response; }