Ejemplo n.º 1
0
 public function calculateDuration($cron = 0)
 {
     try {
         if ($cron == 1) {
             $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
             $arrayCron["processcTimeStart"] = time();
             @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
         }
         //patch  rows with initdate = null and finish_date
         $c = new Criteria();
         $c->clearSelectColumns();
         $c->addSelectColumn(AppDelegationPeer::APP_UID);
         $c->addSelectColumn(AppDelegationPeer::DEL_INDEX);
         $c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
         $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
         $c->add(AppDelegationPeer::DEL_INIT_DATE, null, Criteria::ISNULL);
         $c->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNOTNULL);
         //$c->add(AppDelegationPeer::DEL_INDEX, 1);
         $rs = AppDelegationPeer::doSelectRS($c);
         $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $rs->next();
         $row = $rs->getRow();
         while (is_array($row)) {
             $oAppDel = AppDelegationPeer::retrieveByPk($row['APP_UID'], $row['DEL_INDEX']);
             if (isset($row['DEL_FINISH_DATE'])) {
                 $oAppDel->setDelInitDate($row['DEL_FINISH_DATE']);
             } else {
                 $oAppDel->setDelInitDate($row['DEL_INIT_DATE']);
             }
             $oAppDel->save();
             $rs->next();
             $row = $rs->getRow();
         }
         //walk in all rows with DEL_STARTED = 0 or DEL_FINISHED = 0
         $c = new Criteria('workflow');
         $c->clearSelectColumns();
         $c->addSelectColumn(AppDelegationPeer::APP_UID);
         $c->addSelectColumn(AppDelegationPeer::DEL_INDEX);
         $c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
         $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
         $c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
         $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
         $c->addSelectColumn(AppDelegationPeer::DEL_DURATION);
         $c->addSelectColumn(AppDelegationPeer::DEL_QUEUE_DURATION);
         $c->addSelectColumn(AppDelegationPeer::DEL_DELAY_DURATION);
         $c->addSelectColumn(AppDelegationPeer::DEL_STARTED);
         $c->addSelectColumn(AppDelegationPeer::DEL_FINISHED);
         $c->addSelectColumn(AppDelegationPeer::DEL_DELAYED);
         $c->addSelectColumn(TaskPeer::TAS_DURATION);
         $c->addSelectColumn(TaskPeer::TAS_TIMEUNIT);
         $c->addSelectColumn(TaskPeer::TAS_TYPE_DAY);
         $c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
         //$c->add(AppDelegationPeer::DEL_INIT_DATE, NULL, Criteria::ISNULL);
         //$c->add(AppDelegationPeer::APP_UID, '7694483844a37bfeb0931b1063501289');
         //$c->add(AppDelegationPeer::DEL_STARTED, 0);
         $cton1 = $c->getNewCriterion(AppDelegationPeer::DEL_STARTED, 0);
         $cton2 = $c->getNewCriterion(AppDelegationPeer::DEL_FINISHED, 0);
         $cton1->addOR($cton2);
         $c->add($cton1);
         $rs = AppDelegationPeer::doSelectRS($c);
         $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $rs->next();
         $row = $rs->getRow();
         $i = 0;
         //print "<table colspacing='2' border='1'>";
         //print "<tr><td>iDelegateDate </td><td>iInitDate </td><td>iDueDate </td><td>iFinishDate </td><td>isStarted </td><td>isFinished </td><td>isDelayed </td><td>queueDuration </td><td>delDuration </td><td>delayDuration</td></tr>";
         $now = strtotime('now');
         while (is_array($row)) {
             $fTaskDuration = $row['TAS_DURATION'];
             $iDelegateDate = strtotime($row['DEL_DELEGATE_DATE']);
             $iInitDate = strtotime($row['DEL_INIT_DATE']);
             $iDueDate = strtotime($row['DEL_TASK_DUE_DATE']);
             $iFinishDate = strtotime($row['DEL_FINISH_DATE']);
             $isStarted = intval($row['DEL_STARTED']);
             $isFinished = intval($row['DEL_FINISHED']);
             $isDelayed = intval($row['DEL_DELAYED']);
             $queueDuration = $this->getDiffDate($iInitDate, $iDelegateDate);
             $delDuration = 0;
             $delayDuration = 0;
             $overduePercentage = 0.0;
             //get the object,
             $oAppDel = AppDelegationPeer::retrieveByPk($row['APP_UID'], $row['DEL_INDEX']);
             //if the task is not started
             if ($isStarted == 0) {
                 if ($row['DEL_INIT_DATE'] != null && $row['DEL_INIT_DATE'] != '') {
                     $oAppDel->setDelStarted(1);
                     $queueDuration = $this->getDiffDate($iInitDate, $iDelegateDate);
                     $oAppDel->setDelQueueDuration($queueDuration);
                 } else {
                     //the task was not started
                     $queueDuration = $this->getDiffDate($now, $iDelegateDate);
                     $oAppDel->setDelQueueDuration($queueDuration);
                     //we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
                     $delayDuration = $this->getDiffDate($now, $iDueDate);
                     $oAppDel->setDelDelayDuration($delayDuration);
                     if ($fTaskDuration != 0) {
                         $overduePercentage = $delayDuration / $fTaskDuration;
                         $oAppDel->setAppOverduePercentage($overduePercentage);
                         if ($iDueDate < $now) {
                             $oAppDel->setDelDelayed(1);
                         }
                     }
                 }
             }
             //if the task was not finished
             if ($isFinished == 0) {
                 if ($row['DEL_FINISH_DATE'] != null && $row['DEL_FINISH_DATE'] != '') {
                     $oAppDel->setAppOverduePercentage($overduePercentage);
                     $oAppDel->setDelFinished(1);
                     $delDuration = $this->getDiffDate($iFinishDate, $iInitDate);
                     $oAppDel->setDelDuration($delDuration);
                     //calculate due date if correspond
                     if ($iDueDate < $iFinishDate) {
                         $oAppDel->setDelDelayed(1);
                         $delayDuration = $this->getDiffDate($iFinishDate, $iDueDate);
                     } else {
                         $oAppDel->setDelDelayed(0);
                         $delayDuration = 0;
                     }
                 } else {
                     //the task was not completed
                     if ($row['DEL_INIT_DATE'] != null && $row['DEL_INIT_DATE'] != '') {
                         $delDuration = $this->getDiffDate($now, $iInitDate);
                     } else {
                         $delDuration = $this->getDiffDate($now, $iDelegateDate);
                     }
                     $oAppDel->setDelDuration($delDuration);
                     //we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
                     $delayDuration = $this->getDiffDate($now, $iDueDate);
                     $oAppDel->setDelDelayDuration($delayDuration);
                     if ($fTaskDuration != 0) {
                         $overduePercentage = $delayDuration / $fTaskDuration;
                         $oAppDel->setAppOverduePercentage($overduePercentage);
                         if ($iDueDate < $now) {
                             $oAppDel->setDelDelayed(1);
                         }
                     }
                 }
             }
             //and finally save the record
             $RES = $oAppDel->save();
             $rs->next();
             $row = $rs->getRow();
         }
         if ($cron == 1) {
             $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
             $arrayCron["processcTimeStart"] = time();
             @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
         }
     } catch (Exception $oError) {
         error_log($oError->getMessage());
     }
 }
Ejemplo n.º 2
0
    public function setCatchUser($sAppUid, $iDelIndex, $usrId)

    {

        try {

            $oAppDel = AppDelegationPeer::retrieveByPk($sAppUid, $iDelIndex);

            $oAppDel->setDelInitDate("now");

            $oAppDel->setUsrUid($usrId);

            $oAppDel->save();



            //update searchindex

            if ($this->appSolr != null) {

                $this->appSolr->updateApplicationSearchIndex($sAppUid);

            }



            //Delete record of the table APP_ASSIGN_SELF_SERVICE_VALUE

            $appAssignSelfServiceValue = new AppAssignSelfServiceValue();



            $appAssignSelfServiceValue->remove($sAppUid, $iDelIndex);

            /*----------------------------------********---------------------------------*/

        } catch (exception $e) {

            throw ($e);

        }

    }
Ejemplo n.º 3
0
 $oUser = new Users();
 $aUser = $oUser->load($_SESSION['USER_LOGGED']);
 if (trim($aUser['USR_EMAIL']) == '') {
     $aUser['USR_EMAIL'] = 'info@' . $_SERVER['HTTP_HOST'];
 }
 $sFromName = '"' . $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . '" <' . $aUser['USR_EMAIL'] . '>';
 try {
     $oCase->sendNotifications($_SESSION['TASK'], $_POST['form']['TASKS'], $appFields['APP_DATA'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $sFromName);
 } catch (Exception $e) {
     G::SendTemporalMessage(G::loadTranslation('ID_NOTIFICATION_ERROR') . ' - ' . $e->getMessage(), 'warning', 'string', null, '100%');
 }
 // Send notifications - End
 // Events - Start
 $oEvent = new Event();
 $oEvent->closeAppEvents($_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['TASK']);
 $oCurrentAppDel = AppDelegationPeer::retrieveByPk($_SESSION['APPLICATION'], $_SESSION['INDEX'] + 1);
 $multipleDelegation = false;
 // check if there are multiple derivations
 if (count($_POST['form']['TASKS']) > 1) {
     $multipleDelegation = true;
 }
 // If the case has been delegated
 if (isset($oCurrentAppDel)) {
     // if there is just a single derivation the TASK_UID can be set by the delegation data
     if (!$multipleDelegation) {
         $aCurrentAppDel = $oCurrentAppDel->toArray(BasePeer::TYPE_FIELDNAME);
         $oEvent->createAppEvents($aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $aCurrentAppDel['TAS_UID']);
     } else {
         // else we need to check every task and create the events if it have any
         foreach ($_POST['form']['TASKS'] as $taskDelegated) {
             $aCurrentAppDel = $oCurrentAppDel->toArray(BasePeer::TYPE_FIELDNAME);
Ejemplo n.º 4
0
 public function setCatchUser($sAppUid, $iDelIndex, $usrId)
 {
     try {
         $oAppDel = AppDelegationPeer::retrieveByPk($sAppUid, $iDelIndex);
         $oAppDel->setDelInitDate("now");
         $oAppDel->setUsrUid($usrId);
         $oAppDel->save();
         //update searchindex
         if ($this->appSolr != null) {
             $this->appSolr->updateApplicationSearchIndex($sAppUid);
         }
     } catch (exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 5
0
	private function patchDataWithValuesForCalculateDuration() 

	{

		//patch  rows with initdate = null and finish_date

		$c = new Criteria();

		$c->clearSelectColumns();

		$c->addSelectColumn( AppDelegationPeer::APP_UID );

		$c->addSelectColumn( AppDelegationPeer::DEL_INDEX );

		$c->addSelectColumn( AppDelegationPeer::DEL_DELEGATE_DATE );

		$c->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );

		$c->add( AppDelegationPeer::DEL_INIT_DATE, null, Criteria::ISNULL );

		$c->add( AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNOTNULL );

		//$c->add(AppDelegationPeer::DEL_INDEX, 1);





		$rs = AppDelegationPeer::doSelectRS( $c );

		$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );

		$rs->next();

		$row = $rs->getRow();



		while (is_array( $row )) {

			$oAppDel = AppDelegationPeer::retrieveByPk( $row['APP_UID'], $row['DEL_INDEX'] );

			if (isset( $row['DEL_FINISH_DATE'] )) {

				$oAppDel->setDelInitDate( $row['DEL_FINISH_DATE'] );

			} else {

				$oAppDel->setDelInitDate( $row['DEL_INIT_DATE'] );

			}

			$oAppDel->save();



			$rs->next();

			$row = $rs->getRow();

		}

	}