Esempio n. 1
0
    /**
     * Create List Inbox Table
     *
     * @param type $data
     * @return type
     *
     */
    public function create($data, $isSelfService = false)
    {
        $con = Propel::getConnection( ListInboxPeer::DATABASE_NAME );
        try {
            $this->fromArray( $data, BasePeer::TYPE_FIELDNAME );
            if ($this->validate()) {
                $result = $this->save();
            } else {
                $e = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
                $e->aValidationFailures = $this->getValidationFailures();
                throw ($e);
            }
            $con->commit();

            // create participated history
            $listParticipatedHistory = new ListParticipatedHistory();
            $listParticipatedHistory->remove($data['APP_UID'],$data['DEL_INDEX']);
            $listParticipatedHistory = new ListParticipatedHistory();
            $listParticipatedHistory->create($data);

            // create participated history
            $listMyInbox = new ListMyInbox();
            $listMyInbox->refresh($data);

            // remove and create participated last
            if (!$isSelfService) {
                $oCriteria = new Criteria('workflow');
                $oCriteria->add(ListParticipatedLastPeer::APP_UID, $data['APP_UID']);
                $oCriteria->add(ListParticipatedLastPeer::USR_UID, $data['USR_UID']);
                $exit = ListParticipatedLastPeer::doCount($oCriteria);
                if ($exit) {
                    $oCriteria = new Criteria('workflow');
                    $oCriteria->add(ListParticipatedLastPeer::APP_UID, $data['APP_UID']);
                    $oCriteria->add(ListParticipatedLastPeer::USR_UID, $data['USR_UID']);
                    ListParticipatedLastPeer::doDelete($oCriteria);
                    $users = new Users();
                    $users->refreshTotal($data['USR_UID'], 'removed', 'participated');
                }

                $listParticipatedLast = new ListParticipatedLast();
                $listParticipatedLast->create($data);
                $listParticipatedLast = new ListParticipatedLast();
                $listParticipatedLast->refresh($data);
            } else {
                $data['USR_UID'] = $data['DEL_PREVIOUS_USR_UID'];
                $data['DEL_CURRENT_USR_LASTNAME'] = '';
                $data['DEL_CURRENT_USR_USERNAME'] = '';
                $data['DEL_CURRENT_USR_FIRSTNAME'] = '';

                $listParticipatedLast = new ListParticipatedLast();
                $listParticipatedLast->refresh($data, $isSelfService);
                $data['USR_UID'] = 'SELF_SERVICES';
                $listParticipatedLast = new ListParticipatedLast();
                $listParticipatedLast->create($data);
                $listParticipatedLast = new ListParticipatedLast();
                $listParticipatedLast->refresh($data, $isSelfService);
            }

            return $result;
        } catch(Exception $e) {
            $con->rollback();
            throw ($e);
        }
    }
 /**
  * Retrieve object using using composite pkey values.
  * @param string $app_uid
  * @param string $usr_uid
  * @param int $del_index
  * @param      Connection $con
  * @return     ListParticipatedLast
  */
 public static function retrieveByPK($app_uid, $usr_uid, $del_index, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $criteria = new Criteria();
     $criteria->add(ListParticipatedLastPeer::APP_UID, $app_uid);
     $criteria->add(ListParticipatedLastPeer::USR_UID, $usr_uid);
     $criteria->add(ListParticipatedLastPeer::DEL_INDEX, $del_index);
     $v = ListParticipatedLastPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
Esempio n. 3
0
    public function loadList($usr_uid, $filters = array(), $callbackRecord = null)
    {
        $criteria = new Criteria();

        $criteria->addSelectColumn(ListParticipatedLastPeer::APP_UID);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_INDEX);
        $criteria->addSelectColumn(ListParticipatedLastPeer::USR_UID);
        $criteria->addSelectColumn(ListParticipatedLastPeer::TAS_UID);
        $criteria->addSelectColumn(ListParticipatedLastPeer::PRO_UID);
        $criteria->addSelectColumn(ListParticipatedLastPeer::APP_NUMBER);
        $criteria->addSelectColumn(ListParticipatedLastPeer::APP_TITLE);
        $criteria->addSelectColumn(ListParticipatedLastPeer::APP_PRO_TITLE);
        $criteria->addSelectColumn(ListParticipatedLastPeer::APP_TAS_TITLE);
        $criteria->addSelectColumn(ListParticipatedLastPeer::APP_STATUS);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_PREVIOUS_USR_UID);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_PREVIOUS_USR_USERNAME);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_PREVIOUS_USR_FIRSTNAME);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_PREVIOUS_USR_LASTNAME);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_CURRENT_USR_USERNAME);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_CURRENT_USR_FIRSTNAME);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_CURRENT_USR_LASTNAME);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_DELEGATE_DATE);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_INIT_DATE);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_DUE_DATE);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_PRIORITY);
        $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_THREAD_STATUS);
        $criteria->add( ListParticipatedLastPeer::USR_UID, $usr_uid, Criteria::EQUAL );
        self::loadFilters($criteria, $filters);

        $sort  = (!empty($filters['sort'])) ? $filters['sort'] : "DEL_DELEGATE_DATE";
        $dir   = isset($filters['dir']) ? $filters['dir'] : "ASC";
        $start = isset($filters['start']) ? $filters['start'] : "0";
        $limit = isset($filters['limit']) ? $filters['limit'] : "25";
        $paged = isset($filters['paged']) ? $filters['paged'] : 1;

        if ($dir == "DESC") {
            $criteria->addDescendingOrderByColumn($sort);
        } else {
            $criteria->addAscendingOrderByColumn($sort);
        }

        if ($paged == 1) {
            $criteria->setLimit( $limit );
            $criteria->setOffset( $start );
        }

        $dataset = ListParticipatedLastPeer::doSelectRS($criteria, Propel::getDbConnection('workflow_ro') );
        $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        $data = array();
        $aPriorities = array ('1' => 'VL','2' => 'L','3' => 'N','4' => 'H','5' => 'VH');
        while ($dataset->next()) {
            $aRow = (is_null($callbackRecord))? $dataset->getRow() : $callbackRecord($dataset->getRow());

            $aRow['DEL_PRIORITY'] = G::LoadTranslation( "ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}" );
            $data[] = $aRow;
        }

        return $data;
    }
Esempio n. 4
0
    /**

     * Migrate all cases to New list

     *

     * return all LIST TABLES with data

     */

    public function migrateList ($workSpace)

    {

        if ($this->listFirstExecution('check')) {

            return 1;

        }

        $this->initPropel(true);

        $appCache = new AppCacheView();

        $users    = new Users();

        G::LoadClass("case");

        $case = new Cases();



        //Select data CANCELLED

        $canCriteria = $appCache->getSelAllColumns();

        $canCriteria->add(AppCacheViewPeer::APP_STATUS, "CANCELLED", CRITERIA::EQUAL);

        $canCriteria->add(AppCacheViewPeer::DEL_LAST_INDEX, "1", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($canCriteria);

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

        //Insert data LIST_CANCELED

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $listCanceled = new ListCanceled();

              $listCanceled->remove($row["APP_UID"]);

              $listCanceled->setDeleted(false);

              $listCanceled->create($row);

        }

        CLI::logging("> Completed table LIST_CANCELED\n");



        //Select data COMPLETED

        $comCriteria = $appCache->getSelAllColumns();

        $comCriteria->add(AppCacheViewPeer::APP_STATUS, "COMPLETED", CRITERIA::EQUAL);

        $comCriteria->add(AppCacheViewPeer::DEL_LAST_INDEX, "1", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($comCriteria);

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

        //Insert new data LIST_COMPLETED

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $listCompleted = new ListCompleted();

              $listCompleted->remove($row["APP_UID"]);

              $listCompleted->setDeleted(false);

              $listCompleted->create($row);

        }

        CLI::logging("> Completed table LIST_COMPLETED\n");



        //Select data TO_DO OR DRAFT

        $inbCriteria = $appCache->getSelAllColumns();

        $rsCriteria = AppCacheViewPeer::doSelectRS($inbCriteria);

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



        $criteriaUser = new Criteria();

        $criteriaUser->addSelectColumn( UsersPeer::USR_UID );

        $criteriaUser->addSelectColumn( UsersPeer::USR_FIRSTNAME );

        $criteriaUser->addSelectColumn( UsersPeer::USR_LASTNAME );

        $criteriaUser->addSelectColumn( UsersPeer::USR_USERNAME );

        //Insert new data LIST_INBOX

        while ($rsCriteria->next()) {

            $row = $rsCriteria->getRow();

            $isSelfService = ($row['USR_UID'] == '') ? true : false;

            if($row["DEL_THREAD_STATUS"] == 'OPEN'){

                //Update information about the previous_user

                $row["DEL_PREVIOUS_USR_UID"] = $row["PREVIOUS_USR_UID"];

                $criteriaUser->add( UsersPeer::USR_UID, $row["PREVIOUS_USR_UID"] );

                $datasetU = UsersPeer::doSelectRS($criteriaUser);

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

                $datasetU->next();

                $arrayUsers = $datasetU->getRow();

                $row["DEL_PREVIOUS_USR_USERNAME"] = $arrayUsers["USR_USERNAME"];

                $row["DEL_PREVIOUS_USR_FIRSTNAME"]= $arrayUsers["USR_FIRSTNAME"];

                $row["DEL_PREVIOUS_USR_LASTNAME"] = $arrayUsers["USR_LASTNAME"];

                //Update the due date

                $row["DEL_DUE_DATE"]         = $row["DEL_TASK_DUE_DATE"];

                $listInbox = new ListInbox();

                $listInbox->remove($row["APP_UID"],$row["DEL_INDEX"]);

                $listInbox->setDeleted(false);

                $listInbox->create($row, $isSelfService);

            } else {

                // create participated List when the thread is CLOSED

                $listParticipatedHistory = new ListParticipatedHistory();

                $listParticipatedHistory->remove($row['APP_UID'], $row['DEL_INDEX']);

                $listParticipatedHistory = new ListParticipatedHistory();

                $listParticipatedHistory->create($row);



                $oCriteria = new Criteria('workflow');

                $oCriteria->add(ListParticipatedLastPeer::APP_UID, $row['APP_UID']);

                $oCriteria->add(ListParticipatedLastPeer::USR_UID, $row['USR_UID']);

                ListParticipatedLastPeer::doDelete($oCriteria);



                $listParticipatedLast = new ListParticipatedLast();

                $listParticipatedLast->create($row);

                $listParticipatedLast = new ListParticipatedLast();

                $listParticipatedLast->refresh($row);

            }



        }



        CLI::logging("> Completed table LIST_INBOX\n");

        //With this List is populated the LIST_PARTICIPATED_HISTORY and LIST_PARTICIPATED_LAST

        CLI::logging("> Completed table LIST_PARTICIPATED_HISTORY\n");

        CLI::logging("> Completed table LIST_PARTICIPATED_LAST\n");



        //Select data TO_DO OR DRAFT CASES CREATED BY AN USER

        $myiCriteria = $appCache->getSelAllColumns();

        $myiCriteria->add(AppCacheViewPeer::DEL_INDEX, "1", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($myiCriteria);

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

        //Insert new data LIST_MY_INBOX

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $listMyInbox = new ListMyInbox();

              $listMyInbox ->remove($row["APP_UID"],$row["USR_UID"]);

              $listMyInbox->setDeleted(false);

              $listMyInbox->create($row);

        }

        CLI::logging("> Completed table LIST_MY_INBOX\n");



        //Select data PAUSED

        $delaycriteria = new Criteria("workflow");

        $delaycriteria->addSelectColumn(AppDelayPeer::APP_UID);

        $delaycriteria->addSelectColumn(AppDelayPeer::PRO_UID);

        $delaycriteria->addSelectColumn(AppDelayPeer::APP_DEL_INDEX);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::APP_NUMBER);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::USR_UID);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::APP_STATUS);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::TAS_UID);



        $delaycriteria->addJoin( AppCacheViewPeer::APP_UID, AppDelayPeer::APP_UID . ' AND ' . AppCacheViewPeer::DEL_INDEX . ' = ' . AppDelayPeer::APP_DEL_INDEX, Criteria::INNER_JOIN );

        $delaycriteria->add(AppDelayPeer::APP_DISABLE_ACTION_USER, "0", CRITERIA::EQUAL);

        $delaycriteria->add(AppDelayPeer::APP_TYPE, "PAUSE", CRITERIA::EQUAL);

        $rsCriteria = AppDelayPeer::doSelectRS($delaycriteria);

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

        //Insert new data LIST_PAUSED

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $data = $row;

              $data["DEL_INDEX"] = $row["APP_DEL_INDEX"];

              $listPaused = new ListPaused();

              $listPaused ->remove($row["APP_UID"],$row["APP_DEL_INDEX"],$data);

              $listPaused->setDeleted(false);

              $listPaused->create($data);

        }

        CLI::logging("> Completed table LIST_PAUSED\n");



        //Select and Insert LIST_UNASSIGNED

        $unaCriteria = $appCache->getSelAllColumns();

        $unaCriteria->add(AppCacheViewPeer::USR_UID, "", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($unaCriteria);

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

        $del = new ListUnassignedPeer();

        $del->doDeleteAll();

        $del = new ListUnassignedGroupPeer();

        $del->doDeleteAll();

        while ($rsCriteria->next()) {

            $row = $rsCriteria->getRow();

            $listUnassigned = new ListUnassigned();

            $unaUid = $listUnassigned->generateData($row["APP_UID"],$row["PREVIOUS_USR_UID"]);

        }

        CLI::logging("> Completed table LIST_UNASSIGNED\n");

        CLI::logging("> Completed table LIST_UNASSIGNED_GROUP\n");



        // ADD LISTS COUNTS

        $aTypes = array(

            'to_do',

            'draft',

            'cancelled',

            'sent',

            'paused',

            'completed',

            'selfservice'

        );



        $users = new Users();

        $criteria = new Criteria();

        $criteria->addSelectColumn(UsersPeer::USR_UID);

        $dataset = UsersPeer::doSelectRS($criteria);

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

        while($dataset->next()) {

            $aRow = $dataset->getRow();

            $oAppCache = new AppCacheView();

            $aCount = $oAppCache->getAllCounters( $aTypes, $aRow['USR_UID'] );

            $newData = array(

                'USR_UID'                   => $aRow['USR_UID'],

                'USR_TOTAL_INBOX'           => $aCount['to_do'],

                'USR_TOTAL_DRAFT'           => $aCount['draft'],

                'USR_TOTAL_CANCELLED'       => $aCount['cancelled'],

                'USR_TOTAL_PARTICIPATED'    => $aCount['sent'],

                'USR_TOTAL_PAUSED'          => $aCount['paused'],

                'USR_TOTAL_COMPLETED'       => $aCount['completed'],

                'USR_TOTAL_UNASSIGNED'      => $aCount['selfservice']

            );

            $users->update($newData);

        }

        $this->listFirstExecution('insert');

        return true;

    }
 public function getRowFromList($data)
 {
     $criteria = new Criteria("workflow");
     $criteria->add(ListParticipatedLastPeer::APP_UID, $data['APP_UID']);
     $criteria->add(ListParticipatedLastPeer::USR_UID, $data['USR_UID']);
     $dataset = ListParticipatedLastPeer::doSelectRS($criteria);
     $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $dataset->next();
     $aRow = $dataset->getRow();
     if (is_array($aRow)) {
         if (sizeof($aRow)) {
             return $aRow;
         }
     }
     return false;
 }
    /**
     * Populates the object using an array.
     *
     * This is particularly useful when populating an object from one of the
     * request arrays (e.g. $_POST).  This method goes through the column
     * names, checking to see whether a matching key exists in populated
     * array. If so the setByName() method is called for that column.
     *
     * You can specify the key type of the array by additionally passing one
     * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
     * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
     *
     * @param      array  $arr     An array to populate the object from.
     * @param      string $keyType The type of keys the array uses.
     * @return     void
     */
    public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
    {
        $keys = ListParticipatedLastPeer::getFieldNames($keyType);

        if (array_key_exists($keys[0], $arr)) {
            $this->setAppUid($arr[$keys[0]]);
        }

        if (array_key_exists($keys[1], $arr)) {
            $this->setUsrUid($arr[$keys[1]]);
        }

        if (array_key_exists($keys[2], $arr)) {
            $this->setDelIndex($arr[$keys[2]]);
        }

        if (array_key_exists($keys[3], $arr)) {
            $this->setTasUid($arr[$keys[3]]);
        }

        if (array_key_exists($keys[4], $arr)) {
            $this->setProUid($arr[$keys[4]]);
        }

        if (array_key_exists($keys[5], $arr)) {
            $this->setAppNumber($arr[$keys[5]]);
        }

        if (array_key_exists($keys[6], $arr)) {
            $this->setAppTitle($arr[$keys[6]]);
        }

        if (array_key_exists($keys[7], $arr)) {
            $this->setAppProTitle($arr[$keys[7]]);
        }

        if (array_key_exists($keys[8], $arr)) {
            $this->setAppTasTitle($arr[$keys[8]]);
        }

        if (array_key_exists($keys[9], $arr)) {
            $this->setAppStatus($arr[$keys[9]]);
        }

        if (array_key_exists($keys[10], $arr)) {
            $this->setDelPreviousUsrUid($arr[$keys[10]]);
        }

        if (array_key_exists($keys[11], $arr)) {
            $this->setDelPreviousUsrUsername($arr[$keys[11]]);
        }

        if (array_key_exists($keys[12], $arr)) {
            $this->setDelPreviousUsrFirstname($arr[$keys[12]]);
        }

        if (array_key_exists($keys[13], $arr)) {
            $this->setDelPreviousUsrLastname($arr[$keys[13]]);
        }

        if (array_key_exists($keys[14], $arr)) {
            $this->setDelCurrentUsrUsername($arr[$keys[14]]);
        }

        if (array_key_exists($keys[15], $arr)) {
            $this->setDelCurrentUsrFirstname($arr[$keys[15]]);
        }

        if (array_key_exists($keys[16], $arr)) {
            $this->setDelCurrentUsrLastname($arr[$keys[16]]);
        }

        if (array_key_exists($keys[17], $arr)) {
            $this->setDelDelegateDate($arr[$keys[17]]);
        }

        if (array_key_exists($keys[18], $arr)) {
            $this->setDelInitDate($arr[$keys[18]]);
        }

        if (array_key_exists($keys[19], $arr)) {
            $this->setDelDueDate($arr[$keys[19]]);
        }

        if (array_key_exists($keys[20], $arr)) {
            $this->setDelPriority($arr[$keys[20]]);
        }

        if (array_key_exists($keys[21], $arr)) {
            $this->setDelThreadStatus($arr[$keys[21]]);
        }

    }