/** * Save new case note * * @access public * @param string $app_uid, Uid for case * @param array $app_data, Data for case variables * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia */ public function saveCaseNote($app_uid, $usr_uid, $note_content, $send_mail = false) { 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::isString($note_content, '$note_content'); if (strlen($note_content) > 500) { throw (new \Exception(\G::LoadTranslation("ID_INVALID_MAX_PERMITTED", array($note_content,'500')))); } Validator::isBoolean($send_mail, '$send_mail'); $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"))); } $note_content = addslashes($note_content); $appNote = new \AppNotes(); $appNote->addCaseNote($app_uid, $usr_uid, $note_content, intval($send_mail)); }
/** * Save Department * @var string $dep_data. Data for Process * @var string $create. Flag for create or update * * @access public * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia * * @return array */ public function saveDepartment($dep_data, $create = true) { Validator::isArray($dep_data, '$dep_data'); Validator::isNotEmpty($dep_data, '$dep_data'); Validator::isBoolean($create, '$create'); $dep_data = array_change_key_case($dep_data, CASE_UPPER); if ($create) { unset($dep_data["DEP_UID"]); } $oDepartment = new \Department(); if (isset($dep_data['DEP_UID']) && $dep_data['DEP_UID'] != '') { Validator::depUid($dep_data['DEP_UID']); } if (isset($dep_data['DEP_PARENT']) && $dep_data['DEP_PARENT'] != '') { Validator::depUid($dep_data['DEP_PARENT'], 'dep_parent'); } if (isset($dep_data['DEP_MANAGER']) && $dep_data['DEP_MANAGER'] != '') { Validator::usrUid($dep_data['DEP_MANAGER'], 'dep_manager'); } if (isset($dep_data['DEP_STATUS'])) { Validator::depStatus($dep_data['DEP_STATUS']); } if (!$create) { if (isset($dep_data["DEP_TITLE"])) { $this->throwExceptionIfExistsTitle($dep_data["DEP_TITLE"], strtolower("DEP_TITLE"), $dep_data["DEP_UID"]); $dep_data["DEPO_TITLE"] = $dep_data["DEP_TITLE"]; } $oDepartment->update($dep_data); $oDepartment->updateDepartmentManager($dep_data['DEP_UID']); } else { if (isset($dep_data['DEP_TITLE'])) { $this->throwExceptionIfExistsTitle($dep_data["DEP_TITLE"], strtolower("DEP_TITLE")); } else { throw new \Exception(\G::LoadTranslation("ID_FIELD_REQUIRED", array('dep_title'))); } $dep_uid = $oDepartment->create($dep_data); $response = $this->getDepartment($dep_uid); return $response; } }