Example #1
0
 public function post($user, $password)
 {
     $wsBase = new wsBase();
     $result = $wsBase->login($user, $password);
     if ($result->status_code == 0) {
         return array('auth_key' => $result->message);
     } else {
         throw new RestException(401, $result->message);
     }
 }
Example #2
0
function wsBaseProcessList($studentName)
{
    G::LoadClass('wsBase');
    $ws = new wsBase();
    $result = $ws->processList();
    //$result[] = array ( 'guid' => 'a' . $studentName , 'name' => 'bc' );
    //$result[] = array ( 'guid' => '2a' , 'name' => '2bc' .  $studentName );
    //$result[] = array ( 'guid' => '2a' , 'name' => '2bc' .  $studentName );
    return array("processes" => $result);
    //return array ( "status_code" => 12, "message" => 'abx', "timestamp" => 'aa' );
}
Example #3
0
 protected function get($id = '', $start = null, $limit = null, $type = null, $filter = null, $search = null, $process = null, $user = null, $status = null, $typeResource = null, $dateFrom = null, $dateTo = null)
 {
     if (empty($id)) {
         // getting all records.
         G::loadClass('applications');
         $app = new Applications();
         $userUid = Services_Rest_Auth::$userId;
         return $app->getAll($userUid, $start, $limit, $type, $filter, $search, $process, $status, $typeResource, $dateFrom, $dateTo);
     } else {
         // get a specific record.
         G::loadClass('wsBase');
         $wsBase = new wsBase();
         return $wsBase->getCaseInfo($id);
     }
 }
Example #4
0
    /**
     * Put Data Generate
     *
     * @access public
     * @param string $app_uid, Process Uid
     * @param string $app_number, Task Uid
     * @param string $del_index, Task Uid
     * @param string $usr_uid, Task Uid
     * @param string $fieldName, Field Name
     * @param string $fieldValue, Field Value
     * @return string
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
    */
    public function postDerivate ($app_uid, $app_number, $del_index, $usr_uid, $fieldName='', $fieldValue='')
    {
        G::LoadClass("library");
        G::LoadClass("wsBase");
        G::LoadClass("case");
        $ws = new \wsBase();
        $oCase = new \Cases();

        if (!isset($Fields["DEL_INIT_DATE"])) {
            $oCase->setDelInitDate($app_uid, $del_index);
            $aFields = $oCase->loadCase($app_uid, $del_index);
            //Update data grid
            $aData = $aFields['APP_DATA'];
            foreach ($aData as $k => $dataField) {
               if(is_array($dataField)){
                   $pos = count($dataField);
                   if(isset($aData[$k][$pos][$fieldName])){
                      $aData[$k][$pos][$fieldName] = $fieldValue;
                   }
               }
            }
            $aFields['APP_DATA'] = $aData;
            $oCase->updateCase($app_uid, $aFields);
            //End update
        }

        $res = $ws->derivateCase($usr_uid, $app_uid, $del_index, true);
        $messageDerivateCase = null;

        if (is_array($res)) {
            $messageDerivateCase = "<ul type='square'>";

            if (count($res["routing"]) > 0) {
                foreach ($res["routing"] as $k => $field) {
                    $messageDerivateCase = $messageDerivateCase . "<li>" . $res["routing"][$k]->taskName . " - " . $res["routing"][$k]->userName;
                }
            } else {
                $messageDerivateCase = explode("-", $res["message"]);
                $messageDerivateCase = "<li>" . $messageDerivateCase[0];
            }

            $messageDerivateCase = $messageDerivateCase . "</ul>";
        }

        $response = array();

        $response["casesNumRec"] = \Library::getCasesNumRec($usr_uid);

        if (is_array($res)) {
            $response ["message"] = "<b>" . G::LoadTranslation("ID_CASE") . " " . $app_number . "</b> Summary of Derivations: <br> " . $messageDerivateCase;
        } else {
            $response ["message"] = G::LoadTranslation("ID_CASE") . " " . $app_number . " " . $res->message;
        }
        return $response;
    }
         $currentUsrName = $row["USR_USERNAME"];
 
         $casesFields["APP_DATA"]["USER_LOGGED"]  = $current_user_uid;
         $casesFields["APP_DATA"]["USR_USERNAME"] = $currentUsrName;
     }
 
     foreach ($casesFields["APP_DATA"] as $index => $value) {
         $_SESSION[$index] = $value;
     }
 
     //Update case info
     $case->updateCase($_REQUEST['APP_UID'], $casesFields);
 
     G::LoadClass('wsBase');
 
     $wsBaseInstance = new wsBase();
     $result = $wsBaseInstance->derivateCase($casesFields['CURRENT_USER_UID'], $_REQUEST['APP_UID'], $_REQUEST ['DEL_INDEX'], true);
     $code = (is_array($result) ? $result['status_code'] : $result->status_code);
 
     $dataResponses = array();
     $dataResponses['ABE_REQ_UID'] = $_REQUEST['ABER'];
     $dataResponses['ABE_RES_CLIENT_IP'] = $_SERVER['REMOTE_ADDR'];
     $dataResponses['ABE_RES_DATA'] = serialize($_REQUEST['form']);
     $dataResponses['ABE_RES_STATUS'] = 'PENDING';
     $dataResponses['ABE_RES_MESSAGE'] = '';
 
     try {
         set_include_path(PATH_PLUGINS . 'actionsByEmail' . PATH_SEPARATOR . get_include_path());
         require_once 'classes/model/AbeResponses.php';
 
         $abeAbeResponsesInstance = new AbeResponses();
 $dataResponses = array();
 $dataResponses['ABE_REQ_UID'] = $_REQUEST['ABER'];
 $dataResponses['ABE_RES_CLIENT_IP'] = $_SERVER['REMOTE_ADDR'];
 $dataResponses['ABE_RES_DATA'] = serialize($_REQUEST['VALUE']);
 $dataResponses['ABE_RES_STATUS'] = 'PENDING';
 $dataResponses['ABE_RES_MESSAGE'] = '';
 try {
     require_once 'classes/model/AbeResponses.php';
     $abeAbeResponsesInstance = new AbeResponses();
     $dataResponses['ABE_RES_UID'] = $abeAbeResponsesInstance->createOrUpdate($dataResponses);
 } catch (Exception $error) {
     throw $error;
 }
 $cases->updateCase($_REQUEST['APP_UID'], $caseFieldsABE);
 G::LoadClass('wsBase');
 $ws = new wsBase();
 $result = $ws->derivateCase($caseFieldsABE['CURRENT_USER_UID'], $_REQUEST['APP_UID'], $_REQUEST['DEL_INDEX'], true);
 $code = is_array($result) ? $result['status_code'] : $result->status_code;
 if ($code != 0) {
     throw new Exception('An error occurred while the application was being processed.<br /><br />
              Error code: ' . $result->status_code . '<br />
              Error message: ' . $result->message . '<br /><br />');
 }
 // Update
 $dataResponses['ABE_RES_STATUS'] = $code == 0 ? 'SENT' : 'ERROR';
 $dataResponses['ABE_RES_MESSAGE'] = $code == 0 ? '-' : $result->message;
 try {
     $abeAbeResponsesInstance = new AbeResponses();
     $abeAbeResponsesInstance->createOrUpdate($dataResponses);
 } catch (Exception $error) {
     throw $error;
/**
 *
 * @method
 *
 * Add case note.
 *
 * @name PMFAddCaseNote
 * @label PMF Add case note
 * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFAddCaseNote.28.29
 *
 * @param string(32) | $caseUid | ID of the case | The unique ID of the case.
 * @param string(32) | $processUid | ID of the process | The unique ID of the process.
 * @param string(32) | $taskUid | ID of the task | The unique ID of the task.
 * @param string(32) | $userUid | ID user | The unique ID of the user who will add note case.
 * @param string | $note | Note of the case | Note of the case.
 * @param int | $sendMail = 1 | Send mail | Optional parameter. If set to 1, will send an email to all participants in the case.
 * @return int | $result | Result of the add case note | Returns 1 if the note has been added to the case.; otherwise, returns 0 if an error occurred.
 *
 */
function PMFAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1)
{
    G::LoadClass("wsBase");
    $ws = new wsBase();
    $result = $ws->addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail);
    if ($result->status_code == 0) {
        return 1;
    } else {
        return 0;
    }
}
Example #8
0
function removeUserFromGroup($params)
{
    $vsResult = isValidSession($params->sessionId);
    if ($vsResult->status_code !== 0) {
        return $vsResult;
    }
    $ws = new wsBase();
    $res = $ws->removeUserFromGroup($params->userId, $params->groupId);
    return $res;
}
Example #9
0
 /**
  * Delete InputDocument
  *
  * @param string $inputDocumentUid
  *
  * return array Return an array with data of an InputDocument
  */
 public function removeInputDocument($inputDocumentUid)
 {
     try {
         $oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 );
         if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
             throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_DOES_NOT_EXIST", array($inputDocumentUid)));
         }
         \G::LoadClass('wsBase');
         $ws = new \wsBase();
         $ws->removeDocument($inputDocumentUid);
     } catch (\Exception $e) {
         throw $e;
     }
 }
/**
 *@method
 *
 * Sends an array of case variables to a specified case.
 *
 * @name PMFSaveCurrentData
 * @label PMF Save Current Data
 *
 * @return int | $result | Result of send variables | Returns 1 if the variables were sent successfully to the case; otherwise, returns 0 if an error occurred.
 *
 */

function PMFSaveCurrentData ()
{
    global $oPMScript;
    $result = 0;

    if (isset($_SESSION['APPLICATION']) && isset($oPMScript->aFields)) {
        G::LoadClass( 'wsBase' );
        $ws = new wsBase();
        $result = $ws->sendVariables( $_SESSION['APPLICATION'], $oPMScript->aFields );
    }

    return $result;
}
Example #11
0
 /**
  * Start/Continue case by Timer-Event
  *
  * @param string $datetime Datetime (yyyy-mm-dd hh:ii:ss)
  * @param bool   $frontEnd Flag to represent the terminal front-end
  *
  * return void
  */
 public function startContinueCaseByTimerEvent($datetime, $frontEnd = false)
 {
     try {
         \G::LoadClass("wsBase");
         //Set variables
         $ws = new \wsBase();
         $case = new \Cases();
         $common = new \ProcessMaker\Util\Common();
         $common->setFrontEnd($frontEnd);
         list($year, $month, $day, $hour, $minute) = $this->getYearMonthDayHourMinuteSecondByDatetime($datetime);
         $date = "{$year}-{$month}-{$day}";
         $dateIni = "{$year}-{$month}-{$day} 00:00:00";
         $dateEnd = "{$year}-{$month}-{$day} 23:59:59";
         //Start Timer-Event (start new case) ///////////////////////////////////////////////////////////////////////
         $common->frontEndShow("START");
         $this->log("START-NEW-CASES", "Date \"{$datetime}\": Start new cases");
         //Query
         $criteria = $this->getTimerEventCriteria();
         $criteria->addSelectColumn(\BpmnEventPeer::EVN_NAME);
         $criteria->addSelectColumn(\ElementTaskRelationPeer::TAS_UID);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \ProcessPeer::PRO_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\ProcessPeer::PRO_STATUS, "ACTIVE", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \ElementTaskRelationPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TimerEventPeer::EVN_UID, \ElementTaskRelationPeer::ELEMENT_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\ElementTaskRelationPeer::ELEMENT_TYPE, "bpmnEvent", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\ElementTaskRelationPeer::PRJ_UID, \TaskPeer::PRO_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\ElementTaskRelationPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\TaskPeer::TAS_TYPE, "START-TIMER-EVENT", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \BpmnEventPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TimerEventPeer::EVN_UID, \BpmnEventPeer::EVN_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\BpmnEventPeer::EVN_TYPE, "START", \Criteria::EQUAL);
         $criteria->add(\BpmnEventPeer::EVN_MARKER, "TIMER", \Criteria::EQUAL);
         $criteria->add(\TimerEventPeer::TMREVN_OPTION, array("HOURLY", "DAILY", "MONTHLY", "EVERY", "ONE-DATE-TIME"), \Criteria::IN);
         $criteria->add(\TimerEventPeer::TMREVN_STATUS, "ACTIVE", \Criteria::EQUAL);
         $criteria->add($criteria->getNewCriterion(\TimerEventPeer::TMREVN_NEXT_RUN_DATE, $dateIni, \Criteria::GREATER_EQUAL)->addAnd($criteria->getNewCriterion(\TimerEventPeer::TMREVN_NEXT_RUN_DATE, $dateEnd, \Criteria::LESS_EQUAL))->addOr($criteria->getNewCriterion(\TimerEventPeer::TMREVN_NEXT_RUN_DATE, $dateIni, \Criteria::LESS_THAN)));
         $criteria->add($criteria->getNewCriterion(\TimerEventPeer::TMREVN_END_DATE, $date, \Criteria::GREATER_EQUAL)->addOr($criteria->getNewCriterion(\TimerEventPeer::TMREVN_END_DATE, null, \Criteria::EQUAL)));
         $rsCriteria = \TimerEventPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $flagRecord = false;
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $row["TMREVN_CONFIGURATION_DATA"] = unserialize($row["TMREVN_CONFIGURATION_DATA"]);
             //Set variables
             $arrayTimerEventData = $row;
             $bpmnEventName = $row["EVN_NAME"];
             $taskUid = $row["TAS_UID"];
             //Create the new case
             $timerEventNextRunDate = $arrayTimerEventData["TMREVN_NEXT_RUN_DATE"];
             $timerEventNextRunDateNew = "";
             $flagCase = false;
             if (strtotime($timerEventNextRunDate) < strtotime($dateIni)) {
                 $timerEventNextRunDateNew = $this->getNextRunDateByDataAndDatetime($arrayTimerEventData, $datetime);
                 //Generate new date for old TMREVN_NEXT_RUN_DATE
                 $flagCase = true;
                 //Create the old case
             } else {
                 list(, , , $hourCase, $minuteCase) = $this->getYearMonthDayHourMinuteSecondByDatetime($timerEventNextRunDate);
                 if ((int) ($hour . $minute) <= (int) ($hourCase . $minuteCase)) {
                     $flagCase = $hourCase == $hour && $minuteCase == $minute;
                 } else {
                     $timerEventNextRunDateNew = $this->getNextRunDateByDataAndDatetime($arrayTimerEventData, $datetime);
                     //Generate new date for old TMREVN_NEXT_RUN_DATE
                     $flagCase = true;
                     //Create the old case
                 }
             }
             if ($flagCase) {
                 if ($flagRecord) {
                     $common->frontEndShow("TEXT", "");
                 }
                 if ($bpmnEventName != "") {
                     $common->frontEndShow("TEXT", "> Name Timer-Event: {$bpmnEventName}");
                 }
                 $common->frontEndShow("TEXT", "> Creating the new case...");
                 //Start new case
                 $result = $ws->newCase($arrayTimerEventData["PRJ_UID"], "", $taskUid, array());
                 $arrayResult = json_decode(json_encode($result), true);
                 if ($arrayResult["status_code"] == 0) {
                     $applicationUid = $arrayResult["caseId"];
                     $applicationNumber = $arrayResult["caseNumber"];
                     $common->frontEndShow("TEXT", "    - OK case #{$applicationNumber} was created");
                     $common->frontEndShow("TEXT", "> Routing the case #{$applicationNumber}...");
                     $this->log("CREATED-NEW-CASE", "Case #{$applicationNumber} created, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                     //Derivate new case
                     $result = $ws->derivateCase("", $applicationUid, 1);
                     $arrayResult = json_decode(json_encode($result), true);
                     if ($arrayResult["status_code"] == 0) {
                         $common->frontEndShow("TEXT", "    - OK");
                         $this->log("ROUTED-NEW-CASE", "Case #{$applicationNumber} routed, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                     } else {
                         $common->frontEndShow("TEXT", "    - Failed: " . $arrayResult["message"]);
                         $this->log("ROUTED-NEW-CASE", "Failed: " . $arrayResult["message"] . ", Case: #{$applicationNumber}, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                     }
                 } else {
                     $common->frontEndShow("TEXT", "    - Failed: " . $arrayResult["message"]);
                     $this->log("CREATED-NEW-CASE", "Failed: " . $arrayResult["message"] . ", PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                 }
                 //Update Timer-Event
                 $arrayData = array();
                 switch ($arrayTimerEventData["TMREVN_OPTION"]) {
                     case "HOURLY":
                     case "DAILY":
                     case "MONTHLY":
                     case "EVERY":
                         if ($timerEventNextRunDateNew == "") {
                             $timerEventNextRunDateNew = $this->getNextRunDateByDataAndDatetime($arrayTimerEventData, $timerEventNextRunDate, false);
                         }
                         if ($arrayTimerEventData["TMREVN_OPTION"] != "EVERY" && $arrayTimerEventData["TMREVN_END_DATE"] . "" != "" && strtotime($timerEventNextRunDateNew) > strtotime($arrayTimerEventData["TMREVN_END_DATE"] . " 23:59:59")) {
                             $arrayData["TMREVN_STATUS"] = "PROCESSED";
                         } else {
                             $arrayData["TMREVN_NEXT_RUN_DATE"] = $timerEventNextRunDateNew;
                         }
                         break;
                     case "ONE-DATE-TIME":
                         $arrayData["TMREVN_STATUS"] = "PROCESSED";
                         break;
                 }
                 $arrayData["TMREVN_LAST_RUN_DATE"] = $timerEventNextRunDate;
                 $arrayData["TMREVN_LAST_EXECUTION_DATE"] = date("Y-m-d H:i:s");
                 $result = $this->singleUpdate($arrayTimerEventData["TMREVN_UID"], $arrayData);
                 $flagRecord = true;
             }
         }
         if (!$flagRecord) {
             $common->frontEndShow("TEXT", "Not exists any record to start a new case, on date \"{$datetime}\"");
             $this->log("NO-RECORDS", "Not exists any record to start a new case");
         }
         $common->frontEndShow("END");
         $this->log("END-NEW-CASES", "Date \"{$datetime}\": End new cases");
         //Intermediate Catch Timer-Event (continue the case) ///////////////////////////////////////////////////////
         $this->log("START-CONTINUE-CASES", "Date \"{$datetime}\": Start continue the cases");
         //Query
         $criteriaMain = $this->getTimerEventCriteria();
         $criteriaMain->addSelectColumn(\AppDelegationPeer::APP_UID);
         $criteriaMain->addSelectColumn(\AppDelegationPeer::DEL_INDEX);
         $criteriaMain->addSelectColumn(\AppDelegationPeer::DEL_DELEGATE_DATE);
         $criteriaMain->addSelectColumn(\BpmnEventPeer::EVN_NAME);
         $arrayCondition = array();
         $arrayCondition[] = array(\AppDelegationPeer::PRO_UID, \ProcessPeer::PRO_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\ProcessPeer::PRO_STATUS, "ACTIVE", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\AppDelegationPeer::APP_UID, \ApplicationPeer::APP_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\ApplicationPeer::APP_STATUS, "DRAFT", \Criteria::NOT_EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\AppDelegationPeer::PRO_UID, \TaskPeer::PRO_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\AppDelegationPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\TaskPeer::TAS_TYPE, "INTERMEDIATE-CATCH-TIMER-EVENT", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\TaskPeer::PRO_UID, \ElementTaskRelationPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TaskPeer::TAS_UID, \ElementTaskRelationPeer::TAS_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\ElementTaskRelationPeer::ELEMENT_TYPE, "bpmnEvent", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\ElementTaskRelationPeer::PRJ_UID, \TimerEventPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\ElementTaskRelationPeer::ELEMENT_UID, \TimerEventPeer::EVN_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \BpmnEventPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TimerEventPeer::EVN_UID, \BpmnEventPeer::EVN_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\BpmnEventPeer::EVN_TYPE, "INTERMEDIATE", \Criteria::EQUAL);
         $criteriaMain->add(\BpmnEventPeer::EVN_MARKER, "TIMER", \Criteria::EQUAL);
         $criteriaMain->add(\TimerEventPeer::TMREVN_OPTION, array("WAIT-FOR", "WAIT-UNTIL-SPECIFIED-DATE-TIME"), \Criteria::IN);
         $criteriaMain->add(\TimerEventPeer::TMREVN_STATUS, "ACTIVE", \Criteria::EQUAL);
         $criteriaMain->add(\AppDelegationPeer::DEL_THREAD_STATUS, "OPEN", \Criteria::EQUAL);
         $criteriaMain->add(\AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL);
         //Number records total
         $criteriaCount = clone $criteriaMain;
         $criteriaCount->clearSelectColumns();
         $criteriaCount->addSelectColumn("COUNT(" . \AppDelegationPeer::APP_UID . ") AS NUM_REC");
         $rsCriteriaCount = \AppDelegationPeer::doSelectRS($criteriaCount);
         $rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $result = $rsCriteriaCount->next();
         $row = $rsCriteriaCount->getRow();
         $numRecTotal = $row["NUM_REC"];
         //Query
         $total = $numRecTotal;
         $counter = 0;
         $start = 0;
         $limit = 1000;
         $flagRecord = false;
         do {
             $flagNextRecord = false;
             $criteria = clone $criteriaMain;
             $criteria->setOffset($start);
             $criteria->setLimit($limit);
             $rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
             $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             while ($rsCriteria->next()) {
                 if ($counter + 1 > $total) {
                     $flagNextRecord = false;
                     break;
                 }
                 $row = $rsCriteria->getRow();
                 $row["TMREVN_CONFIGURATION_DATA"] = unserialize($row["TMREVN_CONFIGURATION_DATA"]);
                 //Set variables
                 $arrayTimerEventData = $row;
                 $arrayApplicationData = $case->loadCase($row["APP_UID"]);
                 $applicationUid = $row["APP_UID"];
                 $applicationNumber = $arrayApplicationData["APP_NUMBER"];
                 $delIndex = $row["DEL_INDEX"];
                 $delDelegateDate = $row["DEL_DELEGATE_DATE"];
                 $bpmnEventName = $row["EVN_NAME"];
                 //Continue the case
                 $continueCaseDate = $delDelegateDate;
                 switch ($arrayTimerEventData["TMREVN_OPTION"]) {
                     case "WAIT-FOR":
                         if ($arrayTimerEventData["TMREVN_DAY"] . "" != "") {
                             $continueCaseDate = date("Y-m-d H:i:s", strtotime("{$continueCaseDate} +" . (int) $arrayTimerEventData["TMREVN_DAY"] . " days"));
                         }
                         if ($arrayTimerEventData["TMREVN_HOUR"] . "" != "") {
                             $continueCaseDate = date("Y-m-d H:i:s", strtotime("{$continueCaseDate} +" . (int) $arrayTimerEventData["TMREVN_HOUR"] . " hours"));
                         }
                         if ($arrayTimerEventData["TMREVN_MINUTE"] . "" != "") {
                             $continueCaseDate = date("Y-m-d H:i:s", strtotime("{$continueCaseDate} +" . (int) $arrayTimerEventData["TMREVN_MINUTE"] . " minutes"));
                         }
                         break;
                     case "WAIT-UNTIL-SPECIFIED-DATE-TIME":
                         $continueCaseDate = \G::replaceDataField($arrayTimerEventData["TMREVN_CONFIGURATION_DATA"], $arrayApplicationData["APP_DATA"]);
                         break;
                 }
                 $arrayContinueCaseDateData = $this->getYearMonthDayHourMinuteSecondByDatetime($continueCaseDate);
                 if (!empty($arrayContinueCaseDateData)) {
                     $flagCase = false;
                     if (strtotime($continueCaseDate) < strtotime($dateIni)) {
                         $flagCase = true;
                         //Continue the old case
                     } else {
                         $yearCase = $arrayContinueCaseDateData[0];
                         $monthCase = $arrayContinueCaseDateData[1];
                         $dayCase = $arrayContinueCaseDateData[2];
                         $hourCase = $arrayContinueCaseDateData[3];
                         $minuteCase = $arrayContinueCaseDateData[4];
                         if ("{$yearCase}-{$monthCase}-{$dayCase}" == "{$year}-{$month}-{$day}") {
                             if ((int) ($hour . $minute) <= (int) ($hourCase . $minuteCase)) {
                                 $flagCase = $hourCase == $hour && $minuteCase == $minute;
                             } else {
                                 $flagCase = true;
                                 //Continue the old case
                             }
                         }
                     }
                     if ($flagCase) {
                         if ($flagRecord) {
                             $common->frontEndShow("TEXT", "");
                         }
                         if ($bpmnEventName != "") {
                             $common->frontEndShow("TEXT", "> Name Timer-Event: {$bpmnEventName}");
                         }
                         $common->frontEndShow("TEXT", "> Continue the case #{$applicationNumber}");
                         $common->frontEndShow("TEXT", "> Routing the case #{$applicationNumber}...");
                         //Continue the case
                         //Derivate case
                         $result = $ws->derivateCase("", $applicationUid, $delIndex);
                         $arrayResult = json_decode(json_encode($result), true);
                         if ($arrayResult["status_code"] == 0) {
                             $common->frontEndShow("TEXT", "    - OK");
                             $this->log("CONTINUED-CASE", "Case #{$applicationNumber} continued, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                         } else {
                             $common->frontEndShow("TEXT", "    - Failed: " . $arrayResult["message"]);
                             $this->log("CONTINUED-CASE", "Failed: " . $arrayResult["message"] . ", Case: #{$applicationNumber}, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                         }
                         $flagRecord = true;
                     }
                 } else {
                     $this->log("INVALID-CONTINUE-DATE", "Continue date: {$continueCaseDate}, Case: #{$applicationNumber}, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                 }
                 $counter++;
                 $flagNextRecord = true;
             }
             $start = $start + $limit;
         } while ($flagNextRecord);
         if (!$flagRecord) {
             $common->frontEndShow("TEXT", "Not exists any record to continue a case, on date \"{$datetime}\"");
             $this->log("NO-RECORDS", "Not exists any record to continue a case");
         }
         $common->frontEndShow("END");
         $this->log("END-CONTINUE-CASES", "Date \"{$datetime}\": End continue the cases");
     } catch (\Exception $e) {
         throw $e;
     }
 }
Example #12
0
 /**
  * Route Case
  *
  * @param string $applicationUid Unique id of Case
  * @param string $userUid Unique id of User
  * @param string $delIndex
  * @param array $tasks
  * @param string $bExecuteTriggersBeforeAssignment
  *
  * return array Return an array with Task Case
  */
 public function updateRouteCase($applicationUid, $userUid, $delIndex, $tasks)
 {
     try {
         if (!$delIndex) {
             $delIndex = \AppDelegation::getCurrentIndex($applicationUid);
         }
         \G::LoadClass('wsBase');
         $ws = new \wsBase();
         $fields = $ws->derivateCase($userUid, $applicationUid, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks);
         $fields['message'] = trim(strip_tags($fields['message']));
         $array = json_decode(json_encode($fields), true);
         if ($array ["status_code"] != 0) {
             throw (new \Exception($array ["message"]));
         } else {
             unset($array['status_code']);
             unset($array['message']);
             unset($array['timestamp']);
         }
     } catch (\Exception $e) {
         throw $e;
     }
     return $fields;
 }
Example #13
0
function addCaseNote($params)
{
    $result = isValidSession($params->sessionId);
    if ($result->status_code != 0) {
        return $result;
    }
    if (ifPermission($params->sessionId, "PM_CASES") == 0) {
        $result = new wsResponse(2, G::LoadTranslation('ID_NOT_PRIVILEGES'));
        return $result;
    }
    $ws = new wsBase();
    $result = $ws->addCaseNote($params->caseUid, $params->processUid, $params->taskUid, $params->userUid, $params->note, isset($params->sendMail) ? $params->sendMail : 1);
    return $result;
}
Example #14
0
 /**
  * Send email using appUid and mail
  *
  * @param string $app_uid Unique id of the app
  * @param string $mail
  *
  * return uid
  *
  */
 public function sendEmail($app_uid, $mail, $index)
 {
     require_once PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Application.php";
     $oApplication = new \Application();
     $formData = $oApplication->Load($app_uid);
     $frmData = unserialize($formData['APP_DATA']);
     $dataFormToShowString = "";
     foreach ($frmData as $field => $value) {
         if ($field != 'SYS_LANG' && $field != 'SYS_SKIN' && $field != 'SYS_SYS' && $field != 'APPLICATION' && $field != 'PROCESS' && $field != 'TASK' && $field != 'INDEX' && $field != 'USER_LOGGED' && $field != 'USR_USERNAME' && $field != 'DYN_CONTENT_HISTORY' && $field != 'PIN') {
             $dataFormToShowString .= " " . $field . " " . $value;
         }
     }
     $appData = $this->getDraftApp($app_uid, $index);
     foreach ($appData as $application) {
         $appNumber = $application['APP_NUMBER'];
         $appStatus = $application['APP_STATUS'];
         $index = $application['DEL_INDEX'];
         $prvUsr = $application['APP_DEL_PREVIOUS_USER'];
         $delegateDate = $application['DEL_DELEGATE_DATE'];
         $nextUsr = $application['USR_UID'];
         $proUid = $application['PRO_UID'];
         $proName = $application['APP_PRO_TITLE'];
         $tasName = $application['APP_TAS_TITLE'];
         $threadStatus = $application['DEL_THREAD_STATUS'];
         $tasUid = $application['TAS_UID'];
         $lastIndex = $application['DEL_LAST_INDEX'];
         if ($appStatus == "DRAFT") {
             $labelID = "PMDRFT";
         } else {
             $labelID = "PMIBX";
         }
         if ($mail == "") {
             require_once PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php";
             $oUsers = new \Users();
             if ($nextUsr == "") {
                 //Unassigned:
                 $mail = "";
                 require_once PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "TaskUser.php";
                 $oTaskUsers = new \TaskUser();
                 $taskUsers = $oTaskUsers->getAllUsersTask($tasUid);
                 foreach ($taskUsers as $user) {
                     $usrData = $oUsers->loadDetails($user['USR_UID']);
                     $nextMail = $usrData['USR_EMAIL'];
                     $mail .= $mail == '' ? $nextMail : ',' . $nextMail;
                 }
                 $labelID = "PMUASS";
             } else {
                 $usrData = $oUsers->loadDetails($nextUsr);
                 $mail = $usrData['USR_EMAIL'];
             }
         }
         //first template
         $pathTemplate = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . "pmGmail.html";
         if (!file_exists($pathTemplate)) {
             $file = @fopen($pathTemplate, "w");
             fwrite($file, '<div>');
             fwrite($file, '<span style="display: none !important;">');
             fwrite($file, '-**- Process Name: @#proName<br/>');
             fwrite($file, '-**- Case Number: @#appNumber<br/>');
             fwrite($file, '-**- Case UID: @#caseUid<br/>');
             fwrite($file, '-**- Task Name: @#taskName<br/>');
             fwrite($file, '-**- Index: @#index<br/>');
             fwrite($file, '-**- Action: @#action<br/>');
             fwrite($file, '-**- Previous User: @#prevUser<br/>');
             fwrite($file, '-**- Delegate Date: @#delDate<br/>');
             fwrite($file, '-**- Process Id: @#proUid<br/>');
             fwrite($file, '-**- Type: @#type<br/>');
             fwrite($file, '-**- FormFields: @@oform<br/>');
             fwrite($file, '</span>');
             fwrite($file, '</div>');
             fclose($file);
         }
         $change = array('[', ']', '"');
         $fdata = str_replace($change, ' ', $dataFormToShowString);
         $aFields = array('proName' => $proName, 'appNumber' => $appNumber, 'caseUid' => $app_uid, 'taskName' => $tasName, 'index' => $index, 'action' => $appStatus, 'prevUser' => $prvUsr, 'delDate' => $delegateDate, 'proUid' => $proUid, 'type' => $labelID, 'oform' => $fdata);
         $subject = "[PM] " . $proName . " (" . $index . ") Case: " . $appNumber;
         require_once PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.wsBase.php";
         $ws = new \wsBase();
         $resultMail = $ws->sendMessage($app_uid, '*****@*****.**', $mail, '', '', $subject, 'pmGmail.html', $aFields, array(), true, 0, array(), 1);
         return $resultMail;
     }
     return 'The appUid cant be founded';
 }
Example #15
0
function addCaseNote($params)
{
    $result = isValidSession($params->sessionId);
    if ($result->status_code != 0) {
        return $result;
    }
    if (ifPermission($params->sessionId, "PM_CASES") == 0) {
        $result = new wsResponse(2, "You do not have privileges");
        return $result;
    }
    $ws = new wsBase();
    $result = $ws->addCaseNote($params->caseUid, $params->processUid, $params->taskUid, $params->userUid, $params->note, isset($params->sendMail) ? $params->sendMail : 1);
    return $result;
}
Example #16
0
function ReassignCase($params)
{
    ifSessionExpiredBreakThis($params->sessionId);
    //G::LoadClass('wsResponse');
    //return new wsResponse (1, print_r($params,1));
    G::LoadClass('wsBase');
    $ws = new wsBase();
    $res = $ws->reassignCase($params->sessionId, $params->caseId, $params->delIndex, $params->userIdSource, $params->userIdTarget);
    return $res;
}
Example #17
0
function claimCase($params)
{
    $vsResult = isValidSession($params->sessionId);
    if ($vsResult->status_code !== 0) {
        return $vsResult;
    }
    if (ifPermission($params->sessionId, 'PM_CASES') == 0) {
        $result = new wsResponse(2, G::LoadTranslation('ID_NOT_PRIVILEGES'));
        return $result;
    }
    G::LoadClass('sessions');
    $oSessions = new Sessions();
    $session = $oSessions->getSessionUser($params->sessionId);
    $ws = new wsBase();
    $res = $ws->claimCase($session['USR_UID'], $params->guid, $params->delIndex);
    return $res;
}
 /**
  * Catch Message-Events for the Cases
  *
  * @param bool $frontEnd Flag to represent progress bar
  *
  * @return void
  */
 public function catchMessageEvent($frontEnd = false)
 {
     try {
         \G::LoadClass("wsBase");
         //Set variables
         $ws = new \wsBase();
         $case = new \Cases();
         $common = new \ProcessMaker\Util\Common();
         $common->setFrontEnd($frontEnd);
         //Get data
         $totalMessageEvent = 0;
         $counterStartMessageEvent = 0;
         $counterIntermediateCatchMessageEvent = 0;
         $counter = 0;
         $flagFirstTime = false;
         $common->frontEndShow("START");
         do {
             $flagNextRecords = false;
             $arrayMessageApplicationUnread = $this->getMessageApplications(array("messageApplicationStatus" => "UNREAD"), null, null, 0, 1000);
             if (!$flagFirstTime) {
                 $totalMessageEvent = $arrayMessageApplicationUnread["total"];
                 $flagFirstTime = true;
             }
             foreach ($arrayMessageApplicationUnread["data"] as $value) {
                 if ($counter + 1 > $totalMessageEvent) {
                     $flagNextRecords = false;
                     break;
                 }
                 $arrayMessageApplicationData = $value;
                 $processUid = $arrayMessageApplicationData["PRJ_UID"];
                 $taskUid = $arrayMessageApplicationData["TAS_UID"];
                 $messageApplicationUid = $arrayMessageApplicationData["MSGAPP_UID"];
                 $messageApplicationCorrelation = $arrayMessageApplicationData["MSGAPP_CORRELATION"];
                 $messageEventDefinitionUserUid = $arrayMessageApplicationData["MSGED_USR_UID"];
                 $messageEventDefinitionCorrelation = $arrayMessageApplicationData["MSGED_CORRELATION"];
                 $arrayVariable = $this->mergeVariables($arrayMessageApplicationData["MSGED_VARIABLES"], $arrayMessageApplicationData["MSGAPP_VARIABLES"]);
                 $flagCatched = false;
                 switch ($arrayMessageApplicationData["EVN_TYPE"]) {
                     case "START":
                         if ($messageEventDefinitionCorrelation == $messageApplicationCorrelation && $messageEventDefinitionUserUid != "") {
                             //Start and derivate new Case
                             $result = $ws->newCase($processUid, $messageEventDefinitionUserUid, $taskUid, $arrayVariable);
                             $arrayResult = json_decode(json_encode($result), true);
                             if ($arrayResult["status_code"] == 0) {
                                 $applicationUid = $arrayResult["caseId"];
                                 $result = $ws->derivateCase($messageEventDefinitionUserUid, $applicationUid, 1);
                                 $flagCatched = true;
                                 //Counter
                                 $counterStartMessageEvent++;
                             }
                         }
                         break;
                     case "INTERMEDIATE":
                         $criteria = new \Criteria("workflow");
                         $criteria->addSelectColumn(\AppDelegationPeer::APP_UID);
                         $criteria->addSelectColumn(\AppDelegationPeer::DEL_INDEX);
                         $criteria->addSelectColumn(\AppDelegationPeer::USR_UID);
                         $criteria->add(\AppDelegationPeer::PRO_UID, $processUid, \Criteria::EQUAL);
                         $criteria->add(\AppDelegationPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
                         $criteria->add(\AppDelegationPeer::DEL_THREAD_STATUS, "OPEN", \Criteria::EQUAL);
                         $criteria->add(\AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL);
                         $rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
                         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
                         while ($rsCriteria->next()) {
                             $row = $rsCriteria->getRow();
                             $applicationUid = $row["APP_UID"];
                             $delIndex = $row["DEL_INDEX"];
                             $userUid = $row["USR_UID"];
                             $arrayApplicationData = $case->loadCase($applicationUid);
                             if (\G::replaceDataField($messageEventDefinitionCorrelation, $arrayApplicationData["APP_DATA"]) == $messageApplicationCorrelation) {
                                 //"Unpause" and derivate Case
                                 $arrayApplicationData["APP_DATA"] = array_merge($arrayApplicationData["APP_DATA"], $arrayVariable);
                                 $arrayResult = $case->updateCase($applicationUid, $arrayApplicationData);
                                 $result = $ws->derivateCase($userUid, $applicationUid, $delIndex);
                                 $flagCatched = true;
                             }
                         }
                         //Counter
                         if ($flagCatched) {
                             $counterIntermediateCatchMessageEvent++;
                         }
                         break;
                 }
                 //Message-Application catch
                 if ($flagCatched) {
                     $result = $this->update($messageApplicationUid, array("MSGAPP_STATUS" => "READ"));
                 }
                 $counter++;
                 //Progress bar
                 $common->frontEndShow("BAR", "Message-Events (unread): " . $counter . "/" . $totalMessageEvent . " " . $common->progressBar($totalMessageEvent, $counter));
                 $flagNextRecords = true;
             }
         } while ($flagNextRecords);
         $common->frontEndShow("TEXT", "Total Message-Events unread: " . $totalMessageEvent);
         $common->frontEndShow("TEXT", "Total cases started: " . $counterStartMessageEvent);
         $common->frontEndShow("TEXT", "Total cases continued: " . $counterIntermediateCatchMessageEvent);
         $common->frontEndShow("TEXT", "Total Message-Events pending: " . ($totalMessageEvent - ($counterStartMessageEvent + $counterIntermediateCatchMessageEvent)));
         $common->frontEndShow("END");
     } catch (\Exception $e) {
         throw $e;
     }
 }
    public function sendActionsByEmail($data)
    {
        try {
            // Validations
            try {
                if (!is_object($data)) {
                    throw new Exception('The parameter $data is null.');
                }
                if (!isset($data->TAS_UID)) {
                    throw new Exception('The parameter $data->TAS_UID is null.');
                }

                if (!isset($data->APP_UID)) {
                    throw new Exception('The parameter $data->APP_UID is null.');
                }

                if (!isset($data->DEL_INDEX)) {
                    throw new Exception('The parameter $data->DEL_INDEX is null.');
                }

                if (!isset($data->USR_UID)) {
                    throw new Exception('The parameter $data->USR_UID is null.');
                }

                if ($data->TAS_UID == '') {
                    throw new Exception('The parameter $data->TAS_UID is empty.');
                }

                if ($data->APP_UID == '') {
                    throw new Exception('The parameter $data->APP_UID is empty.');
                }

                if ($data->DEL_INDEX == '') {
                    throw new Exception('The parameter $data->DEL_INDEX is empty.');
                }

                if ($data->USR_UID == '') {
                    throw new Exception('The parameter $data->USR_UID is empty.');
                }
            } catch(Exception $e) {
                echo $e->getMessage().' Please contact to your system administrator.';
                die;
            }

            G::LoadClass('pmFunctions');

            $emailSetup = getEmailConfiguration();

            if (!empty($emailSetup)) {
                require_once 'classes/model/AbeConfiguration.php';
                G::LoadClass('case');

                $cases = new Cases();
                $caseFields = $cases->loadCase($data->APP_UID);
                $criteria = new Criteria();
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::PRO_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_TYPE);
                $criteria->addSelectColumn(AbeConfigurationPeer::TAS_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_TEMPLATE);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_DYN_TYPE);
                $criteria->addSelectColumn(AbeConfigurationPeer::DYN_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_EMAIL_FIELD);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_ACTION_FIELD);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_SUBJECT_FIELD);
                $criteria->addSelectColumn(DynaformPeer::DYN_CONTENT);
                $criteria->addJoin( AbeConfigurationPeer::DYN_UID, DynaformPeer::DYN_UID, Criteria::LEFT_JOIN );
                $criteria->add(AbeConfigurationPeer::PRO_UID, $caseFields['PRO_UID']);
                $criteria->add(AbeConfigurationPeer::TAS_UID, $data->TAS_UID);
                $result = AbeConfigurationPeer::doSelectRS($criteria);
                $result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                $result->next();
                if ($configuration = $result->getRow()) {
                    $configuration['ABE_EMAIL_FIELD'] = str_replace('@@', '', $configuration['ABE_EMAIL_FIELD']);
                    if ($configuration['ABE_EMAIL_FIELD'] != '' && isset($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']])) {
                        $email = trim($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']]);
                    } else {
                        require_once 'classes/model/Users.php';

                        $userInstance = new Users();
                        $userInfo     = $userInstance->getAllInformation($data->USR_UID);
                        $email        = $userInfo['mail'];
                    }

                    if ($email != '') {
                        $subject = G::replaceDataField( $configuration['ABE_SUBJECT_FIELD'], $caseFields['APP_DATA'] );
                        if($subject == ''){
                            $subject = $caseFields['APP_TITLE'];
                        }

                        // Create
                        require_once 'classes/model/AbeRequests.php';

                        $abeRequest = array();
                        $abeRequest['ABE_REQ_UID']      = '';
                        $abeRequest['ABE_UID']          = $configuration['ABE_UID'];
                        $abeRequest['APP_UID']          = $data->APP_UID;
                        $abeRequest['DEL_INDEX']        = $data->DEL_INDEX;
                        $abeRequest['ABE_REQ_SENT_TO']  = $email;
                        $abeRequest['ABE_REQ_SUBJECT']  = $subject;
                        $abeRequest['ABE_REQ_BODY']     = '';
                        $abeRequest['ABE_REQ_ANSWERED'] = 0;
                        $abeRequest['ABE_REQ_STATUS']   = 'PENDING';

                        try {
                            $abeRequestsInstance = new AbeRequests();
                            $abeRequest['ABE_REQ_UID'] = $abeRequestsInstance->createOrUpdate($abeRequest);
                        } catch (Exception $error) {
                            throw $error;
                        }

                        if ($configuration['ABE_TYPE'] != '') {
                            // Email
                            $_SESSION['CURRENT_DYN_UID'] = $configuration['DYN_UID'];

                            $scriptCode = '';
//                            foreach ($dynaform->fields as $fieldName => $field) {
//                                if ($field->type == 'submit') {
//                                    unset($dynaform->fields[$fieldName]);
//                                }
//                            }

                            $__ABE__ = '';
                            $link = (G::is_https() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/ActionsByEmail';

                            switch ($configuration['ABE_TYPE']) {
                                case 'LINK':
                                    // $__ABE__ .= $dynaform->render(PATH_FEATURES . 'actionsByEmail/xmlform.html', $scriptCode) . '<br />';
                                    $__ABE__ .= '<a href="' . $link . 'DataForm?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&DYN_UID=' . G::encrypt($configuration['DYN_UID'], URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Please complete this form</a>';
                                    break;
                                // coment
                                case 'FIELD':
                                        $variableService = new \ProcessMaker\Services\Api\Project\Variable();
                                        $variables = $variableService->doGetVariables($caseFields['PRO_UID']);
                                        $field = new stdClass();
                                        $field->label = 'Test';
                                        $field->type = 'dropdown';
                                        $field->options = array();
                                        $actionField = str_replace('@@', '', $configuration['ABE_ACTION_FIELD']);
                                        $dynaform = $configuration['DYN_UID'];
                                        $variables = G::json_decode($configuration['DYN_CONTENT'], true);
                                        if(isset($variables['items'][0]['items'])){
                                            $fields = $variables['items'][0]['items'];
                                            foreach ($fields as $key => $value) {
                                                foreach($value as $var){ G::pr($var);
                                                    if(isset($var['variable'])){
                                                        if ($var['variable'] == $actionField) {
                                                             $field->label = $var['label'];
                                                             $field->type  = $var['type'];
                                                             $values = $var['options'];
                                                             foreach ($values as $val){
                                                               $field->options[$val['value']] = $val['value'];
                                                             }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        G::LoadClass('pmDynaform');
                                        $obj = new pmDynaform($configuration['DYN_UID']);
                                        $configuration['CURRENT_DYNAFORM'] = $configuration['DYN_UID'];
                                        $file = $obj->printPmDynaformAbe($configuration);
                                        $__ABE__ .= $file;
                                        $__ABE__ .= '<strong>' . $field->label . '</strong><br /><table align="left" border="0"><tr>';
                                        switch ($field->type) {
                                            case 'dropdown':
                                            case 'radiogroup':
                                                $index = 1;
                                                $__ABE__.='<br /><td><table align="left" cellpadding="2"><tr>';
                                                foreach ($field->options as $optValue => $optName) {
                                                    $__ABE__ .= '<td align="center"><a style="text-decoration: none; color: #000; background-color: #E5E5E5; ';
                                                    $__ABE__ .= 'filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#EFEFEF, endColorstr=#BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -webkit-gradient(linear, left top, left bottom, from(#EFEFEF), #BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -webkit-linear-gradient(top, #EFEFEF, #BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -moz-linear-gradient(top, #EFEFEF, #BCBCBC); background-image: -ms-linear-gradient(top, #EFEFEF, #BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -o-linear-gradient(top, #EFEFEF, #BCBCBC); border: 1px solid #AAAAAA; ';
                                                    $__ABE__ .= 'border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); ';
                                                    $__ABE__ .= 'font-family: Arial,serif; font-size: 9pt; font-weight: 400; line-height: 14px; margin: 2px 0; padding: 2px 7px; ';
                                                    $__ABE__ .= 'text-decoration: none; text-transform: capitalize;" href="' .urldecode(urlencode($link)). '?ACTION='.G::encrypt('processABE', URL_KEY).'&APP_UID=';
                                                    $__ABE__ .= G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY);
                                                    $__ABE__ .= '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($optValue, URL_KEY);
                                                    $__ABE__ .= '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank" >' . $optName;
                                                    $__ABE__ .= '</a></td>' . (($index % 5 == 0) ? '</tr><tr>' : '  ');
                                                    $index++;
                                                }

                                                $__ABE__.='</tr></table></td>';
                                                break;
                                            case 'yesno':
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . urlencode(G::encrypt($data->APP_UID, URL_KEY)) . '&DEL_INDEX=' . urlencode(G::encrypt($data->DEL_INDEX, URL_KEY)). '&FIELD=' . urlencode(G::encrypt($actionField, URL_KEY)) . '&VALUE=' . urlencode(G::encrypt(1, URL_KEY)) . '&ABER=' . urlencode(G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY)) . '" target="_blank">' . G::LoadTranslation('ID_YES_VALUE') . '</a></td>';
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . urlencode(G::encrypt($data->APP_UID, URL_KEY)) . '&DEL_INDEX=' . urlencode(G::encrypt($data->DEL_INDEX, URL_KEY)) . '&FIELD=' . urlencode(G::encrypt($actionField, URL_KEY)) . '&VALUE=' . urlencode(G::encrypt(0, URL_KEY)) . '&ABER=' . urlencode(G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY)) . '" target="_blank">' . G::LoadTranslation('ID_NO_VALUE') . '</a></td>';
                                                break;
                                            case 'checkbox':
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($field->value, URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Check</a></td>';
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($field->value, URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Uncheck</a></td>';
                                                break;
                                        }
                                        $__ABE__ .= '</tr></table>';
                                    break;
                            }

                            $__ABE__ = preg_replace('/\<img src=\"\/js\/maborak\/core\/images\/(.+?)\>/', '' , $__ABE__);
                            $__ABE__ = preg_replace('/\<input\b[^>]*\/>/', '' , $__ABE__);
                            $__ABE__ = preg_replace('/<select\b[^>]*>(.*?)<\/select>/is', "", $__ABE__);
                            $__ABE__ = preg_replace('/align=\"center\"/', '' , $__ABE__);
                            $__ABE__ = preg_replace('/class="tableGrid_view" /', 'class="tableGrid_view" width="100%" ', $__ABE__);
                            $caseFields['APP_DATA']['__ABE__'] = $__ABE__;

                            G::LoadClass("Users");

                            $user = new Users();
                            $userDetails = $user->loadDetails($data->PREVIOUS_USR_UID);
                            $emailFrom = $userDetails["USR_EMAIL"];

                            G::LoadClass('wsBase');

                            $wsBaseInstance = new wsBase();
                            $result = $wsBaseInstance->sendMessage($data->APP_UID,
                                                                   $emailFrom,
                                                                   $email,
                                                                   '',
                                                                   '',
                                                                   $subject,
                                                                   $configuration['ABE_TEMPLATE'],
                                                                   $caseFields['APP_DATA'],
                                                                   '');
                            $abeRequest['ABE_REQ_STATUS'] = ($result->status_code == 0 ? 'SENT' : 'ERROR');

                            $body = '';
                            $messageSent = executeQuery('SELECT `APP_MSG_BODY` FROM `APP_MESSAGE` ORDER BY `APP_MSG_SEND_DATE` DESC LIMIT 1');

                            if (!empty($messageSent) && is_array($messageSent)) {
                                $body = $messageSent[1]['APP_MSG_BODY'];
                            }

                            $abeRequest['ABE_REQ_BODY'] = $body;

                            // Update 
                            try {
                                $abeRequestsInstance = new AbeRequests();
                                $abeRequestsInstance->createOrUpdate($abeRequest);
                            } catch (Exception $error) {
                                throw $error;
                            }
                        }
                    }
                }
            }
        } catch (Exception $error) {
            throw $error;
        }
    }
Example #20
0
/**
 * @method
 *
 * Creates a new user with the given data.
 *
 * @name PMFCreateUser
 * @label PMF Create User
 * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFCreateUser.28.29
 *
 * @param string(32) | $userId | User ID | The username for the new user.
 * @param string(32) | $password | Password of the new user  | The password of the new user, which can be up to 32 characters long.
 * @param string(32) | $firstname | Firstname of the new user | The first name of the user, which can be up to 50 characters long.
 * @param string(32) | $lastname | Lastname of the new user | The last name of the user, which can be up to 50 characters long.
 * @param string(32) | $email | Email the new user | The email of the new user, which can be up to 100 characters long.
 * @param string(32) | $role | Rol of the new user | The role of the new user such as 'PROCESSMAKER_ADMIN' or 'PROCESSMAKER_OPERATOR'.
 * @param string(32) | $dueDate=null | Expiration date | Optional parameter. The expiration date must be a string in the format 'yyyy-mm-dd'.
 * @param string(32) | $status=null | Status of the new user | Optional parameter. The user's status, such as 'ACTIVE', 'INACTIVE' or 'VACATION'.
 * @return int | $result | Result of the creation | Returns 1 if the new user was created successfully; otherwise, returns 0 if an error occurred.
 *
 */
function PMFCreateUser($userId, $password, $firstname, $lastname, $email, $role, $dueDate = null, $status = null)
{
    G::LoadClass('wsBase');
    $ws = new wsBase();
    $result = $ws->createUser($userId, $firstname, $lastname, $email, $role, $password, $dueDate, $status);
    if ($result->status_code == 0) {
        return 1;
    } else {
        return 0;
    }
}