/** * 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]]); } }
/** * 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; }