/**
  * Create Case Tracker Object for a Process
  *
  * @param string $processUid Unique id of Process
  * @param array  $arrayData  Data
  *
  * return array Return data of the new Case Tracker Object created
  */
 public function create($processUid, $arrayData)
 {
     try {
         $arrayData = array_change_key_case($arrayData, CASE_UPPER);
         unset($arrayData["CTO_UID"]);
         //Verify data
         $process = new \ProcessMaker\BusinessModel\Process();
         $process->throwExceptionIfNotExistsProcess($processUid, "prj_uid");
         if (!isset($arrayData["CTO_TYPE_OBJ"])) {
             throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array(strtolower("CTO_TYPE_OBJ"))));
         }
         if (!isset($arrayData["CTO_UID_OBJ"])) {
             throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array(strtolower("CTO_UID_OBJ"))));
         }
         $step = new \ProcessMaker\BusinessModel\Step();
         $msg = $step->existsObjectUid($arrayData["CTO_TYPE_OBJ"], $arrayData["CTO_UID_OBJ"], strtolower("CTO_UID_OBJ"));
         if ($msg != "") {
             throw new \Exception($msg);
         }
         if ($this->existsRecord($processUid, $arrayData["CTO_TYPE_OBJ"], $arrayData["CTO_UID_OBJ"])) {
             throw new \Exception(\G::LoadTranslation("ID_RECORD_EXISTS_IN_TABLE", array($processUid . ", " . $arrayData["CTO_TYPE_OBJ"] . ", " . $arrayData["CTO_UID_OBJ"], "CASE_TRACKER_OBJECT")));
         }
         $ctoPosition = $arrayData["CTO_POSITION"];
         $criteria = new \Criteria("workflow");
         $criteria->add(\CaseTrackerObjectPeer::PRO_UID, $processUid);
         $arrayData["CTO_POSITION"] = \CaseTrackerObjectPeer::doCount($criteria) + 1;
         //Create
         $caseTrackerObject = new \CaseTrackerObject();
         $arrayData["PRO_UID"] = $processUid;
         $caseTrackerObjectUid = $caseTrackerObject->create($arrayData);
         $arrayData["CTO_POSITION"] = $ctoPosition;
         $arrayData["CTO_UID"] = $caseTrackerObjectUid;
         $arrayDataUpdate = array_change_key_case($arrayData, CASE_LOWER);
         $this->update($caseTrackerObjectUid, $arrayDataUpdate);
         //Return
         unset($arrayData["PRO_UID"]);
         $arrayData = array_change_key_case($arrayData, CASE_LOWER);
         unset($arrayData["cto_uid"]);
         return array_merge(array("cto_uid" => $caseTrackerObjectUid), $arrayData);
     } catch (\Exception $e) {
         throw $e;
     }
 }
Example #2
0
    public function caseTrackerPermissions($PRO_UID)

    {

        $newCaseTracker = new CaseTracker();

        $caseTracker = $newCaseTracker->load($PRO_UID);

        if (is_array($caseTracker)) {

            $caseTracker['CT_MAP_TYPE'] = ($caseTracker['CT_MAP_TYPE'] != 'NONE') ? true : false;

            //$caseTracker['CT_DERIVATION_HISTORY']  = ($caseTracker['CT_DERIVATION_HISTORY'] == 1)? true : false;

            //$caseTracker['CT_MESSAGE_HISTORY']     = ($caseTracker['CT_MESSAGE_HISTORY'] == 1)? true : false;



            $criteria = new Criteria();

            $criteria->add(CaseTrackerObjectPeer::PRO_UID, $PRO_UID);

            $caseTracker['DYNADOC'] = (CaseTrackerObjectPeer::doCount($criteria) > 0) ? true : false;

        }

        return $caseTracker;

    }
 /**
  * assignCaseTrackerObject
  *
  * @param string $sProcessUID
  * @param string $sObjType
  * @param string $sObjUID
  * @return void
  */
 public function assignCaseTrackerObject($sProcessUID, $sObjType, $sObjUID)
 {
     $oCriteria = new Criteria('workflow');
     $oCriteria->add(CaseTrackerObjectPeer::PRO_UID, $sProcessUID);
     $iPosition = CaseTrackerObjectPeer::doCount($oCriteria) + 1;
     $oCaseTrackerObject = new CaseTrackerObject();
     $ctoUID = $oCaseTrackerObject->create(array('PRO_UID' => $sProcessUID, 'CTO_TYPE_OBJ' => $sObjType, 'CTO_UID_OBJ' => $sObjUID, 'CTO_POSITION' => $iPosition, 'CTO_CONDITION' => ''));
     return $ctoUID;
 }