Ejemplo n.º 1
0
    /**
     * Get list All dashboards
     *
     * @access public
     * @param array $options, Data for list
     * @return array
     *
     * @author Marco Antonio Nina <*****@*****.**>
     * @copyright Colosa - Bolivia
     */
    public function getListDashboards($options = array())
    {
        Validator::isArray($options, '$options');
        
        G::LoadClass("dashboards");
        $dir = isset( $options["dir"] ) ? $options["dir"] : "DESC";
        $sort = isset( $options["sort"] ) ? $options["sort"] : "DASHBOARD.DAS_TITLE";
        $start = isset( $options["start"] ) ? $options["start"] : "0";
        $limit = isset( $options["limit"] ) ? $options["limit"] : "";
        $search = isset( $options["search"] ) ? $options["search"] : "";
        $paged = isset( $options["paged"] ) ? $options["paged"] : true;
        $type = "extjs";

        $start = (int)$start;
        $start = abs($start);
        if ($start != 0) {
            $start--;
        }
        $limit = (int)$limit;
        $limit = abs($limit);
        if ($limit == 0) {
            G::LoadClass("configuration");
            $conf = new \Configurations();
            $configList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');
            if (isset($configList['casesListRowNumber'])) {
                $limit = (int)$configList['casesListRowNumber'];
            } else {
                $limit = 25;
            }
        } else {
            $limit = (int)$limit;
        }

        if ($sort != 'DASHBOARD.DAS_TITLE') {
            $sort = G::toUpper($sort);
            $columnsAppCacheView = DashboardPeer::getFieldNames(\BasePeer::TYPE_FIELDNAME);
            if (!(in_array($sort, $columnsAppCacheView))) {
                $sort = 'APP_CACHE_VIEW.APP_NUMBER';
            }
        }
        $dir = G::toUpper($dir);
        if (!($dir == 'DESC' || $dir == 'ASC')) {
            $dir = 'DESC';
        }

        $dashboards = new \Dashboards();
        $result = $dashboards->getListDashboards($start, $limit, $sort, $dir, $search);

        if ($paged == false) {
            $response = $result['data'];
        } else {
            $response['total'] = $result['totalCount'];
            $response['start'] = $start+1;
            $response['limit'] = $limit;
            $response['sort']  = G::toLower($sort);
            $response['dir']   = G::toLower($dir);
            $response['search']   = $search;

            $response['data'] = $result['data'];
        }
        return $response;
    }
Ejemplo n.º 2
0
    /**

     * Get list for Cases

     *

     * @access public

     * @param array $dataList, Data for list

     * @return array

     *

     * @author Brayan Pereyra (Cochalo) <*****@*****.**>

     * @copyright Colosa - Bolivia

    */

    public function getList($listName = 'inbox', $dataList = array(), $total = false)

    {

        Validator::isArray($dataList, '$dataList');

        if (!isset($dataList["userId"])) {

            throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('userId',''))));

        } else {

            Validator::usrUid($dataList["userId"], "userId");

        }



        $userUid = $dataList["userId"];

        $filters["paged"]    = isset( $dataList["paged"] ) ? $dataList["paged"] : true;

        $filters['count']    = isset( $dataList['count'] ) ? $dataList['count'] : true;

        $filters["category"] = isset( $dataList["category"] ) ? $dataList["category"] : "";

        $filters["process"]  = isset( $dataList["process"] ) ? $dataList["process"] : "";

        $filters["search"]   = isset( $dataList["search"] ) ? $dataList["search"] : "";

        $filters["filter"]   = isset( $dataList["filter"] ) ? $dataList["filter"] : "";

        $filters["dateFrom"] = (!empty( $dataList["dateFrom"] )) ? substr( $dataList["dateFrom"], 0, 10 ) : "";

        $filters["dateTo"]   = (!empty( $dataList["dateTo"] )) ? substr( $dataList["dateTo"], 0, 10 ) : "";



        $filters["start"]    = isset( $dataList["start"] ) ? $dataList["start"] : "0";

        $filters["limit"]    = isset( $dataList["limit"] ) ? $dataList["limit"] : "25";

        $filters["sort"]     = isset( $dataList["sort"] ) ? $dataList["sort"] : "";

        $filters["dir"]      = isset( $dataList["dir"] ) ? $dataList["dir"] : "DESC";



        $filters["action"]   = isset( $dataList["action"] ) ? $dataList["action"] : "";



        // Select list

        switch ($listName) {

            case 'inbox':

                $list = new \ListInbox();

                $listpeer = 'ListInboxPeer';

                break;

            case 'participated_history':

                $list = new \ListParticipatedHistory();

                $listpeer = 'ListParticipatedHistoryPeer';

                break;

            case 'participated_last':

                $list = new \ListParticipatedLast();

                $listpeer = 'ListParticipatedLastPeer';

                break;

            case 'completed':

                $list = new \ListCompleted();

                $listpeer = 'ListCompletedPeer';

                break;

            case 'paused':

                $list = new \ListPaused();

                $listpeer = 'ListPausedPeer';

                break;

            case 'canceled':

                $list = new \ListCanceled();

                $listpeer = 'ListCanceledPeer';

                break;

            case 'my_inbox':

                $list = new \ListMyInbox();

                $listpeer = 'ListMyInboxPeer';

                break;

            case 'unassigned':

                $list = new \ListUnassigned();

                $listpeer = 'ListUnassignedPeer';

                break;

        }





        // Validate filters

        $filters["start"] = (int)$filters["start"];

        $filters["start"] = abs($filters["start"]);

        if ($filters["start"] != 0) {

            $filters["start"]+1;

        }



        $filters["limit"] = (int)$filters["limit"];

        $filters["limit"] = abs($filters["limit"]);

        if ($filters["limit"] == 0) {

            G::LoadClass("configuration");

            $conf = new \Configurations();

            $generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');

            if (isset($generalConfCasesList['casesListRowNumber'])) {

                $filters["limit"] = (int)$generalConfCasesList['casesListRowNumber'];

            } else {

                $filters["limit"] = 25;

            }

        } else {

            $filters["limit"] = (int)$filters["limit"];

        }



        $filters["sort"] = G::toUpper($filters["sort"]);

        $columnsList = $listpeer::getFieldNames(\BasePeer::TYPE_FIELDNAME);

        if (!(in_array($filters["sort"], $columnsList))) {

            $filters["sort"] = '';

        }



        $filters["dir"] = G::toUpper($filters["dir"]);

        if (!($filters["dir"] == 'DESC' || $filters["dir"] == 'ASC')) {

            $filters["dir"] = 'DESC';

        }

        if ($filters["process"] != '') {

            Validator::proUid($filters["process"], '$pro_uid');

        }

        if ($filters["category"] != '') {

            Validator::catUid($filters["category"], '$cat_uid');

        }

        if ($filters["dateFrom"] != '') {

            Validator::isDate($filters["dateFrom"], 'Y-m-d', '$date_from');

        }

        if ($filters["dateTo"] != '') {

            Validator::isDate($filters["dateTo"], 'Y-m-d', '$date_to');

        }



        if ($total) {

            $total = $list->countTotal($userUid, $filters);

            return $total;

        }



        $result = $list->loadList($userUid, $filters);

        if (!empty($result)) {

            foreach ($result as &$value) {

                if (isset($value['DEL_PREVIOUS_USR_UID'])) {

                    $value['PREVIOUS_USR_UID']       = $value['DEL_PREVIOUS_USR_UID'];

                    $value['PREVIOUS_USR_USERNAME']  = $value['DEL_PREVIOUS_USR_USERNAME'];

                    $value['PREVIOUS_USR_FIRSTNAME'] = $value['DEL_PREVIOUS_USR_FIRSTNAME'];

                    $value['PREVIOUS_USR_LASTNAME']  = $value['DEL_PREVIOUS_USR_LASTNAME'];

                }

                if (isset($value['DEL_DUE_DATE'])) {

                    $value['DEL_TASK_DUE_DATE'] = $value['DEL_DUE_DATE'];

                }

                if (isset($value['APP_PAUSED_DATE'])) {

                    $value['APP_UPDATE_DATE']   = $value['APP_PAUSED_DATE'];

                }

                if (isset($value['DEL_CURRENT_USR_USERNAME'])) {

                    $value['USR_USERNAME']      = $value['DEL_CURRENT_USR_USERNAME'];

                    $value['USR_FIRSTNAME']     = $value['DEL_CURRENT_USR_FIRSTNAME'];

                    $value['USR_LASTNAME']      = $value['DEL_CURRENT_USR_LASTNAME'];

                    $value['APP_UPDATE_DATE']   = $value['DEL_DELEGATE_DATE'];

                }

                if (isset($value['APP_STATUS'])) {

                    $value['APP_STATUS_LABEL']  = G::LoadTranslation( "ID_{$value['APP_STATUS']}" );

                }





                //$value = array_change_key_case($value, CASE_LOWER);

            }

        }

        $response = array();

        if ($filters["paged"]) {

            $filtersData = array();

            $filtersData['start']       = $filters["start"];

            $filtersData['limit']       = $filters["limit"];

            $filtersData['sort']        = G::toLower($filters["sort"]);

            $filtersData['dir']         = G::toLower($filters["dir"]);

            $filtersData['cat_uid']     = $filters["category"];

            $filtersData['pro_uid']     = $filters["process"];

            $filtersData['search']      = $filters["search"];

            $filtersData['date_from']   = $filters["dateFrom"];

            $filtersData['date_to']     = $filters["dateTo"];

            $response['filters']        = $filtersData;

            $response['data']           = $result;

            $filtersData['action']      = $filters["action"];

            $response['totalCount']     = $list->countTotal($userUid, $filtersData);

        } else {

            $response = $result;

        }

        return $response;

    }
Ejemplo n.º 3
0
 /**
  * @covers G::toLower
  * @todo   Implement testToLower().
  */
 public function testToLower()
 {
     $name = 'BRAYAN';
     $this->assertEquals('brayan', G::toLower($name));
 }
Ejemplo n.º 4
0
    public function getSystemDate($dateTime, $type='dateFormat')
    {
        $oConf = new Configurations();
        $oConf->getFormats();
        $dateFormat = $oConf->UserConfig['dateFormat'];
        $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
        $creationDateMask = isset($oConf->aConfig[$type]) ? $oConf->aConfig[$type] : '';
        $creationDateMask = ($creationDateMask == '') ? $dateFormat : $creationDateMask;
        if ($creationDateMask != '') {
            if (strpos($dateTime, ' ') !== false) {
                list ($date, $time) = explode(' ', $dateTime);
                list ($y, $m, $d) = explode('-', $date);
                list ($h, $i, $s) = explode(':', $time);
                $newCreation = '';
                $maskTime = array('d' => '%d', 'D' => '%A', 'j' => '%d', 'l' => '%A', 'G' => '%I', 'g' => '%i', 'N' => '%u', 'S' => '%d', 'w' => '%w', 'z' => '%j', 'W' => '%W', 'F' => '%B', 'm' => '%m', 'M' => '%B', 'n' => '%m', 'o' => '%Y', 'Y' => '%Y', 'y' => '%g', 'a' => '%p', 'A' => '%p', 'g' => '%I', 'G' => '%H', 'h' => '%I', 'H' => '%H', 'i' => '%M', 's' => '%S');
                $creationDateMask = trim($creationDateMask);

                if (strpos($creationDateMask, ' \\d\\e ') !== false) {
                    $creationDateMask = str_replace(' \\d\\e ', ' [xx] ', $creationDateMask);
                }

                for ($j = 0; $j < strlen($creationDateMask); $j++) {
                    if ($creationDateMask[$j] != ' ' && isset($maskTime[$creationDateMask[$j]])) {
                        $newCreation .= $maskTime[$creationDateMask[$j]];
                    } else {
                        $newCreation .= $creationDateMask[$j];
                    }
                }

                $langLocate = SYS_LANG;

                require_once 'model/Language.php';
                $language = new language();
                $lanLocation = $language->findLocationByLanId(SYS_LANG);
                $location = isset($lanLocation['LAN_LOCATION']) ? $lanLocation['LAN_LOCATION'] : '';    

                if (G::toLower(PHP_OS) == 'linux' || G::toLower(PHP_OS) == 'darwin') {
                    if (SYS_LANG == 'es') {
                        $langLocate = 'es_ES';
                    } else if (strlen(SYS_LANG) > 2) {
                        $langLocate = str_replace('-', '_', SYS_LANG);
                    } else if ($location != '') {
                        $langLocate = SYS_LANG.'_'.$location;
                    } else {
                        $langLocate = 'en_US';
                    }
                } else {
                    switch (SYS_LANG) {
                        case 'es':
                        case 'es_ES':
                            $langLocate = 'ESN';
                            break;
                        case 'pt':
                        case 'pt-BR':
                            $langLocate = 'PTB';
                            break;
                        case 'en':
                        case 'en-US':
                        default:
                            $langLocate = 'EST';
                            break;
                    }
                }
                
                if (defined('PARTNER_FLAG')) {
                    setlocale(LC_TIME, $langLocate);
                    $dateTime = utf8_encode(strftime($newCreation, mktime($h, $i, $s, $m, $d, $y)));
                } else {
                    setlocale(LC_TIME, $langLocate . ".utf8");
                    $dateTime = strftime($newCreation, mktime($h, $i, $s, $m, $d, $y));
                }

                if (strpos($dateTime, ' ') !== false) {
                    $dateTime = ucwords($dateTime);
                }

                if (strpos($dateTime, ' [xx] ') !== false) {
                    $dateTime = str_replace('[xx]', ' de ', $dateTime);
                }
            }
        }

        return $dateTime;
    }
Ejemplo n.º 5
0
                $record["APP_UPDATE_DATE"] = $record["DEL_DELEGATE_DATE"];
            }
            if (isset($record["APP_STATUS"])) {
                $record["APP_STATUS_LABEL"] = G::LoadTranslation("ID_" . $record["APP_STATUS"]);
            }
            //Return
            return $record;
        } catch (Exception $e) {
            throw $e;
        }
    });
    $filtersData = array();
    $filtersData['start'] = $filters['start'];
    $filtersData['limit'] = $filters['limit'];
    $filtersData['sort'] = G::toLower($filters['sort']);
    $filtersData['dir'] = G::toLower($filters['dir']);
    $filtersData['cat_uid'] = $filters['category'];
    $filtersData['pro_uid'] = $filters['process'];
    $filtersData['search'] = $filters['search'];
    $filtersData['date_from'] = $filters['dateFrom'];
    $filtersData['date_to'] = $filters['dateTo'];
    $filtersData["action"] = $filters["action"];
    $filtersData["filterStatus"] = $filters['filterStatus'];
    $response = array();
    $response['filters'] = $filtersData;
    $response['totalCount'] = $list->countTotal($userUid, $filtersData);
    $response = $filter->xssFilterHard($response);
    $response['data'] = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($result);
    echo G::json_encode($response);
} catch (Exception $e) {
    $msg = array("error" => $e->getMessage());
Ejemplo n.º 6
0
 public function getSystemDate($dateTime)
 {
     $oConf = new Configurations();
     $dateFormat = 'M d, Y';
     $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
     $creationDateMask = isset($oConf->aConfig['dateFormat']) ? $oConf->aConfig['dateFormat'] : '';
     $creationDateMask = $creationDateMask == '' ? $dateFormat : $creationDateMask;
     if ($creationDateMask != '') {
         if (strpos($dateTime, ' ') !== false) {
             list($date, $time) = explode(' ', $dateTime);
             list($y, $m, $d) = explode('-', $date);
             list($h, $i, $s) = explode(':', $time);
             $dateTime = date($creationDateMask, mktime($h, $i, $s, $m, $d, $y));
         } else {
             list($y, $m, $d) = explode('-', $dateTime);
             $newCreation = '';
             $maskTime = array('d' => '%d', 'D' => '%A', 'j' => '%e', 'l' => '%A', 'N' => '%u', 'S' => '%d', 'w' => '%w', 'z' => '%j', 'W' => '%W', 'F' => '%B', 'm' => '%m', 'M' => '%B', 'n' => '%m', 'o' => '%Y', 'Y' => '%Y', 'y' => '%g', 'a' => '%P', 'A' => '%p', 'g' => '%l', 'G' => '%k', 'h' => '%I', 'H' => '%H', 'i' => '%M', 's' => '%S');
             $creationDateMask = trim($creationDateMask);
             if (strpos($creationDateMask, ' \\d\\e ') !== false) {
                 $creationDateMask = str_replace(' \\d\\e ', ' [xx] ', $creationDateMask);
             }
             for ($i = 0; $i < strlen($creationDateMask); $i++) {
                 if ($creationDateMask[$i] != ' ' && isset($maskTime[$creationDateMask[$i]])) {
                     $newCreation .= $maskTime[$creationDateMask[$i]];
                 } else {
                     $newCreation .= $creationDateMask[$i];
                 }
             }
             $langLocate = SYS_LANG;
             if (G::toLower(PHP_OS) == 'linux' || G::toLower(PHP_OS) == 'darwin') {
                 if (SYS_LANG == 'es') {
                     $langLocate = 'es_ES';
                 } else {
                     if (strlen(SYS_LANG) > 2) {
                         $langLocate = str_replace('-', '_', SYS_LANG);
                     } else {
                         $langLocate = 'en_US';
                     }
                 }
             } else {
                 switch (SYS_LANG) {
                     case 'es':
                     case 'es_ES':
                         $langLocate = 'ESN';
                         break;
                     case 'pt':
                     case 'pt-BR':
                         $langLocate = 'PTB';
                         break;
                     case 'en':
                     case 'en-US':
                     default:
                         $langLocate = 'EST';
                         break;
                 }
             }
             setlocale(LC_TIME, $langLocate);
             $dateTime = utf8_encode(strftime($newCreation, mktime(0, 0, 0, $m, $d, $y)));
             if (strpos($dateTime, ' ') !== false) {
                 $dateTime = ucwords($dateTime);
             }
             if (strpos($dateTime, ' [xx] ') !== false) {
                 $dateTime = str_replace('[xx]', ' de ', $dateTime);
             }
         }
     }
     return $dateTime;
 }
Ejemplo n.º 7
0
/**
 *
 * @method
 *
 * Returns a string with all the letters converted into lower case letters.
 *
 * @name lowerCase
 * @label Lower Case
 * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#lowerCase.28.29
 *
 * @param string(32) | $sText | Text To Convert | A string to convert to lower case letters.
 * @return string | $TextC | Text Converted | Returns a string with the text converted into lower case letters.
 *
 */
function lowerCase($sText)
{
    return G::toLower($sText);
}
Ejemplo n.º 8
0
    /**
     * Get list for Cases
     *
     * @access public
     * @param array $dataList, Data for list
     * @return array
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
     */
    public function getList($dataList = array())
    {
        Validator::isArray($dataList, '$dataList');
        if (!isset($dataList["userId"])) {
            throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('userId',''))));
        } else {
            Validator::usrUid($dataList["userId"], "userId");
        }

        $user = new \ProcessMaker\BusinessModel\User();

        if (!$user->checkPermission($dataList["userId"], "PM_ALLCASES")) {
            throw new \Exception(\G::LoadTranslation("ID_CASE_USER_NOT_HAVE_PERMISSION", array($dataList["userId"])));
        }

        G::LoadClass("applications");
        $solrEnabled = false;
        $userUid = $dataList["userId"];
        $callback = isset( $dataList["callback"] ) ? $dataList["callback"] : "stcCallback1001";
        $dir = isset( $dataList["dir"] ) ? $dataList["dir"] : "DESC";
        $sort = isset( $dataList["sort"] ) ? $dataList["sort"] : "APP_CACHE_VIEW.APP_NUMBER";
        $start = isset( $dataList["start"] ) ? $dataList["start"] : "0";
        $limit = isset( $dataList["limit"] ) ? $dataList["limit"] : "";
        $filter = isset( $dataList["filter"] ) ? $dataList["filter"] : "";
        $process = isset( $dataList["process"] ) ? $dataList["process"] : "";
        $category = isset( $dataList["category"] ) ? $dataList["category"] : "";
        $status = isset( $dataList["status"] ) ? strtoupper( $dataList["status"] ) : "";
        $user = isset( $dataList["user"] ) ? $dataList["user"] : "";
        $search = isset( $dataList["search"] ) ? $dataList["search"] : "";
        $action = isset( $dataList["action"] ) ? $dataList["action"] : "todo";
        $paged = isset( $dataList["paged"] ) ? $dataList["paged"] : true;
        $type = "extjs";
        $dateFrom = (!empty( $dataList["dateFrom"] )) ? substr( $dataList["dateFrom"], 0, 10 ) : "";
        $dateTo = (!empty( $dataList["dateTo"] )) ? substr( $dataList["dateTo"], 0, 10 ) : "";
        $first = isset( $dataList["first"] ) ? true :false;

        $valuesCorrect = array('todo', 'draft', 'paused', 'sent', 'selfservice', 'unassigned', 'search');
        if (!in_array($action, $valuesCorrect)) {
            throw (new \Exception(\G::LoadTranslation("ID_INCORRECT_VALUE_ACTION")));
        }

        $start = (int)$start;
        $start = abs($start);
        if ($start != 0) {
            $start--;
        }
        $limit = (int)$limit;
        $limit = abs($limit);
        if ($limit == 0) {
            G::LoadClass("configuration");
            $conf = new \Configurations();
            $generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');
            if (isset($generalConfCasesList['casesListRowNumber'])) {
                $limit = (int)$generalConfCasesList['casesListRowNumber'];
            } else {
                $limit = 25;
            }
        } else {
            $limit = (int)$limit;
        }
        if ($sort != 'APP_CACHE_VIEW.APP_NUMBER') {
            $sort = G::toUpper($sort);
            $columnsAppCacheView = \AppCacheViewPeer::getFieldNames(\BasePeer::TYPE_FIELDNAME);
            if (!(in_array($sort, $columnsAppCacheView))) {
                $sort = 'APP_CACHE_VIEW.APP_NUMBER';
            }
        }
        $dir = G::toUpper($dir);
        if (!($dir == 'DESC' || $dir == 'ASC')) {
            $dir = 'DESC';
        }
        if ($process != '') {
            Validator::proUid($process, '$pro_uid');
        }
        if ($category != '') {
            Validator::catUid($category, '$cat_uid');
        }
        $status = G::toUpper($status);
        $listStatus = array('TO_DO', 'DRAFT', 'COMPLETED', 'CANCEL', 'OPEN', 'CLOSE');
        if (!(in_array($status, $listStatus))) {
            $status = '';
        }
        if ($user != '') {
            Validator::usrUid($user, '$usr_uid');
        }
        if ($dateFrom != '') {
            Validator::isDate($dateFrom, 'Y-m-d', '$date_from');
        }
        if ($dateTo != '') {
            Validator::isDate($dateTo, 'Y-m-d', '$date_to');
        }

        if ($action == 'search' || $action == 'to_reassign') {
            $userUid = ($user == "CURRENT_USER") ? $userUid : $user;
            if ($first) {
                $result = array();
                $result['totalCount'] = 0;
                $result['data'] = array();
                return $result;
            }
        }

        if ((
                $action == "todo" || $action == "draft" || $action == "paused" || $action == "sent" ||
                $action == "selfservice" || $action == "unassigned" || $action == "search"
            ) &&
            (($solrConf = \System::solrEnv()) !== false)
        ) {
            G::LoadClass("AppSolr");

            $ApplicationSolrIndex = new \AppSolr(
                $solrConf["solr_enabled"],
                $solrConf["solr_host"],
                $solrConf["solr_instance"]
            );

            if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
                //Check if there are missing records to reindex and reindex them
                $ApplicationSolrIndex->synchronizePendingApplications();
                $solrEnabled = true;
            }
        }

        if ($solrEnabled) {
            $result = $ApplicationSolrIndex->getAppGridData(
                $userUid,
                $start,
                $limit,
                $action,
                $filter,
                $search,
                $process,
                $status,
                $type,
                $dateFrom,
                $dateTo,
                $callback,
                $dir,
                $sort,
                $category
            );
        } else {
            G::LoadClass("applications");
            $apps = new \Applications();
            $result = $apps->getAll(
                $userUid,
                $start,
                $limit,
                $action,
                $filter,
                $search,
                $process,
                $status,
                $type,
                $dateFrom,
                $dateTo,
                $callback,
                $dir,
                (strpos($sort, ".") !== false)? $sort : "APP_CACHE_VIEW." . $sort,
                $category,
                true,
                $paged
            );
        }
        if (!empty($result['data'])) {
            foreach ($result['data'] as &$value) {
                $value = array_change_key_case($value, CASE_LOWER);
            }
        }
        if ($paged == false) {
            $response = $result['data'];
        } else {
            $response['total'] = $result['totalCount'];
            $response['start'] = $start+1;
            $response['limit'] = $limit;
            $response['sort']  = G::toLower($sort);
            $response['dir']   = G::toLower($dir);
            $response['cat_uid']  = $category;
            $response['pro_uid']  = $process;
            $response['search']   = $search;
            if ($action == 'search') {
                $response['app_status'] = G::toLower($status);
                $response['usr_uid'] = $user;
                $response['date_from'] = $dateFrom;
                $response['date_to'] = $dateTo;
            }
            $response['data'] = $result['data'];
        }
        return $response;
    }
Ejemplo n.º 9
0
 /**
  * Delete Data for PmTable
  * @var string $pmt_uid. Uid for PmTable
  * @var string $rows. Data for rows of PmTable
  *
  * @author Brayan Pereyra (Cochalo) <*****@*****.**>
  * @copyright Colosa - Bolivia
  *
  * @return void
  */
 public function deleteTableData($pmt_uid, $rows)
 {
     $pmt_uid = $this->validateTabUid($pmt_uid, false);
     $rows = array_merge(array_change_key_case($rows, CASE_LOWER), array_change_key_case($rows, CASE_UPPER));
     $oAdditionalTables = new AdditionalTables();
     $table = $oAdditionalTables->load($pmt_uid, true);
     $primaryKeys = $oAdditionalTables->getPrimaryKeys('keys');
     foreach ($primaryKeys as $value) {
         if (!isset($rows[$value])) {
             throw new \Exception("The field for column '{$value}' is required");
         } else {
             $params[] = is_numeric($rows[$value]) ? $rows[$value] : "'" . $rows[$value] . "'";
         }
     }
     $className = $table['ADD_TAB_CLASS_NAME'];
     $classPeerName = $className . 'Peer';
     $sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
     if (!file_exists($sPath . $className . '.php')) {
         throw new \Exception('Update:: ' . G::loadTranslation('ID_PMTABLE_CLASS_DOESNT_EXIST', $className));
     }
     require_once $sPath . $className . '.php';
     $obj = null;
     eval('$obj = ' . $classPeerName . '::retrieveByPk(' . implode(',', $params) . ');');
     if (is_object($obj)) {
         foreach ($rows as $key => $value) {
             // validation, don't modify primary keys
             if (in_array(G::toUpper($key), $primaryKeys) || in_array(G::toLower($key), $primaryKeys)) {
                 unset($rows[$key]);
             }
             $action = 'set' . AdditionalTables::getPHPName($key);
             $obj->{$action}($value);
         }
         if ($r = $obj->validate()) {
             $obj->delete();
         } else {
             $msg = '';
             foreach ($obj->getValidationFailures() as $objValidationFailure) {
                 $msg .= $objValidationFailure->getMessage() . "\n";
             }
             throw new \Exception($msg);
         }
     } else {
         throw new \Exception("The key " . implode(',', $params) . " not exist");
     }
 }