Exemplo n.º 1
0
 /**
  * post Note Action
  *
  * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION'])
  * @return array containg the case notes
  */
 function postNote($httpData)
 {
     require_once "classes/model/AppNotes.php";
     //extract(getExtJSParams());
     if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
         $appUid = $httpData->appUid;
     } else {
         $appUid = $_SESSION['APPLICATION'];
     }
     if (!isset($appUid)) {
         throw new Exception('Can\'t resolve the Apllication ID for this request.');
     }
     $usrUid = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : "";
     $noteContent = addslashes($httpData->noteText);
     //Disabling the controller response because we handle a special behavior
     $this->setSendResponse(false);
     //Add note case
     $appNote = new AppNotes();
     $response = $appNote->addCaseNote($appUid, $usrUid, $noteContent, intval($httpData->swSendMail));
     //Send the response to client
     @ini_set("implicit_flush", 1);
     ob_start();
     echo G::json_encode($response);
     @ob_flush();
     @flush();
     @ob_end_flush();
     ob_implicit_flush(1);
 }
Exemplo n.º 2
0
    /**

     * Add case note

     *

     * @param string caseUid : ID of the case.

     * @param string processUid : ID of the process.

     * @param string taskUid : ID of the task.

     * @param string userUid : The unique ID of the user who will add note case.

     * @param string note : Note of the case.

     * @param int sendMail : Optional parameter. If set to 1, will send an email to all participants in the case.

     * @return $result will return an object

     */

    public function addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1)

    {

        try {

            if (empty($caseUid)) {

                $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " caseUid");



                return $result;

            }



            if (empty($processUid)) {

                $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " processUid");



                return $result;

            }



            if (empty($taskUid)) {

                $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " taskUid");



                return $result;

            }



            if (empty($userUid)) {

                $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " userUid");



                return $result;

            }



            if (empty($note)) {

                $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " note");



                return $result;

            }



            $case = new Cases();



            $respView = $case->getAllObjectsFrom($processUid, $caseUid, $taskUid, $userUid, "VIEW");

            $respBlock = $case->getAllObjectsFrom($processUid, $caseUid, $taskUid, $userUid, "BLOCK");



            if ($respView["CASES_NOTES"] == 0 && $respBlock["CASES_NOTES"] == 0) {

                $result = new wsResponse(100, G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS"));



                return $result;

            }



            //Add note case

            $appNote = new AppNotes();

            $response = $appNote->addCaseNote($caseUid, $userUid, $note, $sendMail);



            //Response

            $result = new wsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY"));



            return $result;

        } catch (Exception $e) {

            $result = new wsResponse(100, $e->getMessage());



            return $result;

        }

    }
Exemplo n.º 3
0
 /**
  * post Note Action
  *
  * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION'])
  * @return array containg the case notes
  */
 function postNote($httpData)
 {
     //require_once ("classes/model/AppNotes.php");
     //extract(getExtJSParams());
     if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
         $appUid = $httpData->appUid;
     } else {
         $appUid = $_SESSION['APPLICATION'];
     }
     if (!isset($appUid)) {
         throw new Exception(G::LoadTranslation("ID_CANT_RESOLVE_APPLICATION"));
     }
     $usrUid = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : "";
     $noteContent = addslashes($httpData->noteText);
     //Disabling the controller response because we handle a special behavior
     $this->setSendResponse(false);
     //Add note case
     $appNote = new AppNotes();
     try {
         $response = $appNote->addCaseNote($appUid, $usrUid, $noteContent, intval($httpData->swSendMail));
     } catch (Exception $error) {
         $response = new stdclass();
         $response->success = 'success';
         $response->message = G::LoadTranslation('ID_ERROR_SEND_NOTIFICATIONS');
         $response->message .= '<br /><br />' . $error->getMessage() . '<br /><br />';
         $response->message .= G::LoadTranslation('ID_CONTACT_ADMIN');
         die(G::json_encode($response));
     }
     //Send the response to client
     @ini_set("implicit_flush", 1);
     ob_start();
     if (!isset($_SESSION['USER_LOGGED'])) {
         $response = new stdclass();
         $response->message = G::LoadTranslation('ID_LOGIN_AGAIN');
         $response->lostSession = true;
         print G::json_encode($response);
         die;
     }
     echo G::json_encode($response);
     @ob_flush();
     @flush();
     @ob_end_flush();
     ob_implicit_flush(1);
 }
Exemplo n.º 4
0
    /**
     * 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));
    }