当前位置: 首页>>代码示例>>PHP>>正文


PHP Option::getByFuzzyValue方法代码示例

本文整理汇总了PHP中Option::getByFuzzyValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Option::getByFuzzyValue方法的具体用法?PHP Option::getByFuzzyValue怎么用?PHP Option::getByFuzzyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Option的用法示例。


在下文中一共展示了Option::getByFuzzyValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAPISearchByCompanyIdAndArrayCriteria


//.........这里部分代码省略.........
        if (getTTProductEdition() >= TT_PRODUCT_CORPORATE) {
            $query .= '	LEFT JOIN ' . $jf->getTable() . ' as jf ON a.default_job_id = jf.id';
            $query .= '	LEFT JOIN ' . $jif->getTable() . ' as jif ON a.default_job_item_id = jif.id';
        }
        $query .= '		LEFT JOIN
						(
							SELECT g2.*,g1.user_id
							FROM ' . $puf->getTable() . ' as g1, ' . $pcf->getTable() . ' as g2
							WHERE ( g1.permission_control_id = g2.id AND g2.deleted = 0)
						) as g ON ( a.id = g.user_id )
						LEFT JOIN
						(
							SELECT h2.*, h1.user_id
							FROM ' . $ppsuf->getTable() . ' as h1, ' . $ppsf->getTable() . ' as h2
							WHERE ( h1.pay_period_schedule_id = h2.id AND h2.deleted = 0)
						) as h ON ( a.id = h.user_id )
						LEFT JOIN
						(
							SELECT i2.*, i1.user_id
							FROM ' . $pguf->getTable() . ' as i1, ' . $pgf->getTable() . ' as i2
							WHERE ( i1.policy_group_id = i2.id AND i2.deleted = 0)
						) as i ON ( a.id = i.user_id ) ';
        $query .= Permission::getPermissionHierarchySQL($company_id, isset($filter_data['permission_current_user_id']) ? $filter_data['permission_current_user_id'] : 0, 'a.id');
        $query .= '
						LEFT JOIN ' . $this->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $this->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	a.company_id = ?
					';
        $query .= Permission::getPermissionIsChildIsOwnerFilterSQL($filter_data, 'a.id');
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.id', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['status']) and trim($filter_data['status']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['status_id'] = Option::getByFuzzyValue($filter_data['status'], $this->getOptions('status'));
        }
        $query .= isset($filter_data['status_id']) ? $this->getWhereClauseSQL('a.status_id', $filter_data['status_id'], 'numeric_list', $ph) : NULL;
        if (isset($filter_data['include_subgroups']) and (bool) $filter_data['include_subgroups'] == TRUE) {
            $uglf = new UserGroupListFactory();
            $filter_data['user_group_id'] = $uglf->getByCompanyIdAndGroupIdAndSubGroupsArray($company_id, $filter_data['user_group_id'], TRUE);
        }
        $query .= isset($filter_data['user_group_id']) ? $this->getWhereClauseSQL('a.group_id', $filter_data['user_group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['user_group']) ? $this->getWhereClauseSQL('d.name', $filter_data['user_group'], 'text', $ph) : NULL;
        $query .= isset($filter_data['default_branch_id']) ? $this->getWhereClauseSQL('a.default_branch_id', $filter_data['default_branch_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['default_branch']) ? $this->getWhereClauseSQL('b.name', $filter_data['default_branch'], 'text', $ph) : NULL;
        $query .= isset($filter_data['default_department_id']) ? $this->getWhereClauseSQL('a.default_department_id', $filter_data['default_department_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['default_department']) ? $this->getWhereClauseSQL('c.name', $filter_data['default_department'], 'text', $ph) : NULL;
        $query .= isset($filter_data['title_id']) ? $this->getWhereClauseSQL('a.title_id', $filter_data['title_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['title']) ? $this->getWhereClauseSQL('e.name', $filter_data['title'], 'text', $ph) : NULL;
        $query .= isset($filter_data['ethnic_group_id']) ? $this->getWhereClauseSQL('a.ethnic_group_id', $filter_data['ethnic_group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['ethnic_group']) ? $this->getWhereClauseSQL('egf.name', $filter_data['ethnic_group'], 'text', $ph) : NULL;
        $query .= isset($filter_data['currency_id']) ? $this->getWhereClauseSQL('a.currency_id', $filter_data['currency_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['currency']) ? $this->getWhereClauseSQL('f.name', $filter_data['currency'], 'text', $ph) : NULL;
        $query .= isset($filter_data['permission_control_id']) ? $this->getWhereClauseSQL('g.id', $filter_data['permission_control_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['permission_control']) ? $this->getWhereClauseSQL('g.name', $filter_data['permission_control'], 'text', $ph) : NULL;
        $query .= isset($filter_data['pay_period_schedule_id']) ? $this->getWhereClauseSQL('i.pay_period_schedule_id', $filter_data['pay_period_schedule_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['pay_period_schedule']) ? $this->getWhereClauseSQL('h.name', $filter_data['pay_period_schedule'], 'text', $ph) : NULL;
        $query .= isset($filter_data['policy_group_id']) ? $this->getWhereClauseSQL('k.policy_group_id', $filter_data['policy_group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['policy_group']) ? $this->getWhereClauseSQL('i.name', $filter_data['policy_group'], 'text', $ph) : NULL;
        if (isset($filter_data['sex']) and trim($filter_data['sex']) != '' and !isset($filter_data['sex_id'])) {
            $filter_data['sex_id'] = Option::getByFuzzyValue($filter_data['sex'], $this->getOptions('sex'));
        }
        $query .= isset($filter_data['sex_id']) ? $this->getWhereClauseSQL('a.sex_id', $filter_data['sex_id'], 'text_list', $ph) : NULL;
        $query .= isset($filter_data['first_name']) ? $this->getWhereClauseSQL('a.first_name', $filter_data['first_name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['last_name']) ? $this->getWhereClauseSQL('a.last_name', $filter_data['last_name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['home_phone']) ? $this->getWhereClauseSQL('a.home_phone', $filter_data['home_phone'], 'phone', $ph) : NULL;
        $query .= isset($filter_data['work_phone']) ? $this->getWhereClauseSQL('a.work_phone', $filter_data['work_phone'], 'phone', $ph) : NULL;
开发者ID:alachaum,项目名称:timetrex,代码行数:67,代码来源:UserListFactory.class.php

示例2: getPunchSummaryReportByCompanyIdAndArrayCriteria


//.........这里部分代码省略.........
							sf.type_id as station_type_id,
							sf.station_id as station_station_id,
							sf.source as station_source,
							sf.description as station_description';
        if (getTTProductEdition() >= TT_PRODUCT_CORPORATE) {
            $query .= ',
						jf.name as job,
						jf.description as job_description,
						jf.status_id as job_status_id,
						jf.manual_id as job_manual_id,
						jf.branch_id as job_branch_id,
						jbf.name as job_branch,
						jf.department_id as job_department_id,
						jdf.name as job_department,
						jf.group_id as job_group_id,
						jgf.name as job_group,
						jf.other_id1 as job_other_id1,
						jf.other_id2 as job_other_id2,
						jf.other_id3 as job_other_id3,
						jf.other_id4 as job_other_id4,
						jf.other_id5 as job_other_id5,
						jif.name as job_item,
						jif.description as job_item_description,
						jif.manual_id as job_item_manual_id,
						jif.group_id as job_item_group_id,
						jigf.name as job_item_group
						';
        }
        $query .= ' from	' . $this->getTable() . ' as a
					LEFT JOIN ' . $pcf->getTable() . ' as pcf ON a.punch_control_id = pcf.id
					LEFT JOIN ' . $udf->getTable() . ' as b ON pcf.user_date_id = b.id
					LEFT JOIN ' . $ppf_b->getTable() . ' as ppf ON b.pay_period_id = ppf.id
					LEFT JOIN ' . $uf->getTable() . ' as uf ON b.user_id = uf.id

					LEFT JOIN ' . $uf->getTable() . ' as uf_b ON a.created_by = uf_b.id
					LEFT JOIN ' . $uf->getTable() . ' as uf_c ON a.updated_by = uf_c.id

					LEFT JOIN ' . $bf->getTable() . ' as bf ON pcf.branch_id = bf.id
					LEFT JOIN ' . $df->getTable() . ' as df ON pcf.department_id = df.id

					LEFT JOIN ' . $sf->getTable() . ' as sf ON a.station_id = sf.id

					LEFT JOIN ' . $uwf->getTable() . ' as z ON z.id = (select z.id
																		from ' . $uwf->getTable() . ' as z
																		where z.user_id = b.user_id
																			and z.effective_date <= b.date_stamp
																			and z.wage_group_id = 0
																			and z.deleted = 0
																			order by z.effective_date desc limit 1) ';
        if (getTTProductEdition() >= TT_PRODUCT_CORPORATE) {
            $query .= '	LEFT JOIN ' . $jf->getTable() . ' as jf ON pcf.job_id = jf.id
						LEFT JOIN ' . $jif->getTable() . ' as jif ON pcf.job_item_id = jif.id
						LEFT JOIN ' . $bf->getTable() . ' as jbf ON jf.branch_id = jbf.id
						LEFT JOIN ' . $df->getTable() . ' as jdf ON jf.department_id = jdf.id
						LEFT JOIN ' . $jgf->getTable() . ' as jgf ON jf.group_id = jgf.id
						LEFT JOIN ' . $jigf->getTable() . ' as jigf ON jif.group_id = jigf.id
						';
        }
        $query .= ' where 	uf.company_id = ? ';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('uf.id', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['include_user_id']) ? $this->getWhereClauseSQL('uf.id', $filter_data['include_user_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_user_id']) ? $this->getWhereClauseSQL('uf.id', $filter_data['exclude_user_id'], 'not_numeric_list', $ph) : NULL;
        $query .= isset($filter_data['user_status_id']) ? $this->getWhereClauseSQL('uf.status_id', $filter_data['user_status_id'], 'numeric_list', $ph) : NULL;
        if (isset($filter_data['include_user_subgroups']) and (bool) $filter_data['include_user_subgroups'] == TRUE) {
            $uglf = new UserGroupListFactory();
            $filter_data['user_group_id'] = $uglf->getByCompanyIdAndGroupIdAndSubGroupsArray($company_id, $filter_data['user_group_id'], TRUE);
        }
        $query .= isset($filter_data['user_group_id']) ? $this->getWhereClauseSQL('uf.group_id', $filter_data['user_group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['default_branch_id']) ? $this->getWhereClauseSQL('uf.default_branch_id', $filter_data['default_branch_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['default_department_id']) ? $this->getWhereClauseSQL('uf.default_department_id', $filter_data['default_department_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['user_title_id']) ? $this->getWhereClauseSQL('uf.title_id', $filter_data['user_title_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['punch_branch_id']) ? $this->getWhereClauseSQL('pcf.branch_id', $filter_data['punch_branch_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['punch_department_id']) ? $this->getWhereClauseSQL('pcf.department_id', $filter_data['punch_department_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['pay_period_id']) ? $this->getWhereClauseSQL('b.pay_period_id', $filter_data['pay_period_id'], 'numeric_list', $ph) : NULL;
        if (isset($filter_data['job_status']) and trim($filter_data['job_status']) != '' and !isset($filter_data['job_status_id'])) {
            $filter_data['job_status_id'] = Option::getByFuzzyValue($filter_data['job_status'], $jf->getOptions('status'));
        }
        $query .= isset($filter_data['job_status_id']) ? $this->getWhereClauseSQL('jf.status_id', $filter_data['job_status_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['job_group_id']) ? $this->getWhereClauseSQL('jf.group_id', $filter_data['job_group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['include_job_id']) ? $this->getWhereClauseSQL('pcf.job_id', $filter_data['include_job_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_job_id']) ? $this->getWhereClauseSQL('pcf.job_id', $filter_data['exclude_job_id'], 'not_numeric_list', $ph) : NULL;
        $query .= isset($filter_data['job_item_group_id']) ? $this->getWhereClauseSQL('jif.group_id', $filter_data['job_item_group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['include_job_item_id']) ? $this->getWhereClauseSQL('pcf.job_item_id', $filter_data['include_job_item_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_job_item_id']) ? $this->getWhereClauseSQL('pcf.job_item_id', $filter_data['exclude_job_item_id'], 'not_numeric_list', $ph) : NULL;
        $query .= isset($filter_data['tag']) ? $this->getWhereClauseSQL('uf.id', array('company_id' => $company_id, 'object_type_id' => 200, 'tag' => $filter_data['tag']), 'tag', $ph) : NULL;
        if (isset($filter_data['start_date']) and trim($filter_data['start_date']) != '') {
            $ph[] = $this->db->BindDate($filter_data['start_date']);
            $query .= ' AND b.date_stamp >= ?';
        }
        if (isset($filter_data['end_date']) and trim($filter_data['end_date']) != '') {
            $ph[] = $this->db->BindDate($filter_data['end_date']);
            $query .= ' AND b.date_stamp <= ?';
        }
        $query .= '
						AND ( a.deleted = 0 AND b.deleted = 0 AND pcf.deleted = 0 )
					';
        $query .= $this->getSortSQL($order, FALSE);
        $this->ExecuteSQL($query, $ph);
        return $this;
    }
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:PunchListFactory.class.php

示例3: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (isset($filter_data['include_user_id'])) {
            $filter_data['user_id'] = $filter_data['include_user_id'];
        }
        if (isset($filter_data['exclude_user_id'])) {
            $filter_data['exclude_id'] = $filter_data['exclude_user_id'];
        }
        if (isset($filter_data['qualification_group_id'])) {
            $filter_data['group_id'] = $filter_data['qualification_group_id'];
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('first_name', 'last_name', 'qualification', 'fluency_id', 'competency_id', 'qgf.name', 'default_branch', 'default_department', 'user_group', 'title');
        $sort_column_aliases = array('fluency' => 'fluency_id', 'competency' => 'competency_id');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('qualification' => 'asc', 'qgf.name' => 'asc');
            $strict = FALSE;
        } else {
            if (isset($order['group'])) {
                $order['qgf.name'] = $order['group'];
                unset($order['group']);
            }
            $strict = TRUE;
        }
        Debug::Arr($order, 'Order Data:', __FILE__, __LINE__, __METHOD__, 10);
        Debug::Arr($filter_data, 'Filter Data:', __FILE__, __LINE__, __METHOD__, 10);
        $uf = new UserFactory();
        $bf = new BranchFactory();
        $df = new DepartmentFactory();
        $ugf = new UserGroupFactory();
        $utf = new UserTitleFactory();
        $qf = new QualificationFactory();
        $usf = new UserSkillFactory();
        $umf = new UserMembershipFactory();
        $qgf = new QualificationGroupFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*,
                            uf.first_name as first_name,
                            uf.last_name as last_name,
                            qf.name as qualification,
                            qgf.name as "group",
                            
                            bf.id as default_branch_id,
							bf.name as default_branch,
							df.id as default_department_id,
							df.name as default_department,
							ugf.id as user_group_id,
							ugf.name as user_group,
							utf.id as user_title_id,
							utf.name as title,
                            
							y.first_name as created_by_first_name,
							y.middle_name as created_by_middle_name,
							y.last_name as created_by_last_name,
							z.first_name as updated_by_first_name,
							z.middle_name as updated_by_middle_name,
							z.last_name as updated_by_last_name
					from 	' . $this->getTable() . ' as a
                        LEFT JOIN ' . $uf->getTable() . ' as uf ON ( a.user_id = uf.id AND uf.deleted = 0)     
                        LEFT JOIN ' . $usf->getTable() . ' as usf ON  ( a.qualification_id = usf.qualification_id AND usf.deleted = 0)
                        LEFT JOIN ' . $umf->getTable() . ' as umf ON ( a.qualification_id = umf.qualification_id AND umf.deleted = 0 )                   
                        LEFT JOIN ' . $qf->getTable() . ' as qf ON ( a.qualification_id = qf.id  AND qf.deleted = 0 )
                        LEFT JOIN ' . $bf->getTable() . ' as bf ON ( uf.default_branch_id = bf.id AND bf.deleted = 0)
                        LEFT JOIN ' . $df->getTable() . ' as df ON ( uf.default_department_id = df.id AND df.deleted = 0)
                        LEFT JOIN ' . $ugf->getTable() . ' as ugf ON ( uf.group_id = ugf.id AND ugf.deleted = 0 )
                        LEFT JOIN ' . $utf->getTable() . ' as utf ON ( uf.title_id = utf.id AND utf.deleted = 0 )
                        LEFT JOIN ' . $qgf->getTable() . ' as qgf ON ( qf.group_id = qgf.id AND qgf.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	qf.company_id = ?';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['user_id']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['user_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['fluency']) and trim($filter_data['fluency']) != '' and !isset($filter_data['fluency_id'])) {
            $filter_data['fluency_id'] = Option::getByFuzzyValue($filter_data['fluency'], $this->getOptions('fluency'));
        }
        if (isset($filter_data['competency']) and trim($filter_data['competency']) != '' and !isset($filter_data['competency_id'])) {
            $filter_data['competency_id'] = Option::getByFuzzyValue($filter_data['competency'], $this->getOptions('competency'));
        }
        $query .= isset($filter_data['qualification_id']) ? $this->getWhereClauseSQL('a.qualification_id', $filter_data['qualification_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['qualification']) ? $this->getWhereClauseSQL('qf.name', $filter_data['qualification'], 'text', $ph) : NULL;
        $query .= isset($filter_data['proficiency_id']) ? $this->getWhereClauseSQL('usf.proficiency_id', $filter_data['proficiency_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['ownership_id']) ? $this->getWhereClauseSQL('umf.ownership_id', $filter_data['ownership_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['fluency_id']) ? $this->getWhereClauseSQL('a.fluency_id', $filter_data['fluency_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['competency_id']) ? $this->getWhereClauseSQL('a.competency_id', $filter_data['competency_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['description']) ? $this->getWhereClauseSQL('a.description', $filter_data['description'], 'text', $ph) : NULL;
        $query .= isset($filter_data['group_id']) ? $this->getWhereClauseSQL('qf.group_id', $filter_data['group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['group']) ? $this->getWhereClauseSQL('qgf.name', $filter_data['group'], 'text', $ph) : NULL;
        $query .= isset($filter_data['qualification_type_id']) ? $this->getWhereClauseSQL('qf.type_id', $filter_data['qualification_type_id'], 'numeric_list', $ph) : NULL;
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:UserLanguageListFactory.class.php

示例4: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('action_id', 'object_id', 'last_name', 'first_name');
        $sort_column_aliases = array('action' => 'action_id', 'object' => 'table_name');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('date' => 'desc', 'table_name' => 'asc', 'object_id' => 'asc');
            $strict = FALSE;
        } else {
            //Always try to order by status first so INACTIVE employees go to the bottom.
            if (!isset($order['date'])) {
                $order['date'] = 'desc';
            }
            $strict = TRUE;
        }
        //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $uf = new UserFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*,
							uf.first_name as first_name,
							uf.middle_name as middle_name,
							uf.last_name as last_name

					from 	' . $this->getTable() . ' as a
						LEFT JOIN ' . $uf->getTable() . ' as uf ON ( a.user_id = uf.id AND uf.deleted = 0 )
					where	uf.company_id = ?
					';
        if (isset($filter_data['permission_children_ids']) and isset($filter_data['permission_children_ids'][0]) and !in_array(-1, (array) $filter_data['permission_children_ids'])) {
            $query .= ' AND a.user_id in (' . $this->getListSQL($filter_data['permission_children_ids'], $ph) . ') ';
        }
        if (isset($filter_data['id']) and isset($filter_data['id'][0]) and !in_array(-1, (array) $filter_data['id'])) {
            $query .= ' AND a.id in (' . $this->getListSQL($filter_data['id'], $ph) . ') ';
        }
        if (isset($filter_data['exclude_id']) and isset($filter_data['exclude_id'][0]) and !in_array(-1, (array) $filter_data['exclude_id'])) {
            $query .= ' AND a.id not in (' . $this->getListSQL($filter_data['exclude_id'], $ph) . ') ';
        }
        if (isset($filter_data['user_id']) and isset($filter_data['user_id'][0]) and !in_array(-1, (array) $filter_data['user_id'])) {
            $query .= ' AND a.user_id in (' . $this->getListSQL($filter_data['user_id'], $ph) . ') ';
        }
        if (isset($filter_data['action']) and trim($filter_data['action']) != '' and !isset($filter_data['action_id'])) {
            $filter_data['action_id'] = Option::getByFuzzyValue($filter_data['action'], $this->getOptions('action'));
        }
        if (isset($filter_data['table_name']) and isset($filter_data['table_name'][0]) and !in_array(-1, (array) $filter_data['table_name'])) {
            $query .= ' AND a.table_name in (' . $this->getListSQL($filter_data['table_name'], $ph) . ') ';
        }
        if (isset($filter_data['object_id']) and isset($filter_data['object_id'][0]) and !in_array(-1, (array) $filter_data['object_id'])) {
            $query .= ' AND a.object_id in (' . $this->getListSQL($filter_data['object_id'], $ph) . ') ';
        }
        $query .= isset($filter_data['action_id']) ? $this->getWhereClauseSQL('a.action_id', $filter_data['action_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['date']) ? $this->getWhereClauseSQL('a.date', $filter_data['date'], 'date_range', $ph) : NULL;
        if (isset($filter_data['first_name']) and trim($filter_data['first_name']) != '') {
            $ph[] = $this->handleSQLSyntax(strtolower(trim($filter_data['first_name'])));
            $query .= ' AND (lower(uf.first_name) LIKE ? ) ';
        }
        if (isset($filter_data['last_name']) and trim($filter_data['last_name']) != '') {
            $ph[] = $this->handleSQLSyntax(strtolower(trim($filter_data['last_name'])));
            $query .= ' AND (lower(uf.last_name) LIKE ? ) ';
        }
        //Need to support table_name -> object_id pairs for including log entires from different tables/objects.
        if (isset($filter_data['table_name_object_id']) and is_array($filter_data['table_name_object_id']) and count($filter_data['table_name_object_id']) > 0) {
            foreach ($filter_data['table_name_object_id'] as $table_name => $object_id) {
                $ph[] = strtolower(trim($table_name));
                $sub_query[] = '(a.table_name = ? AND a.object_id in (' . $this->getListSQL($object_id, $ph) . ') )';
            }
            if (isset($sub_query)) {
                $query .= ' AND ( ' . implode(' OR ', $sub_query) . ' ) ';
            }
            unset($table_name, $object_id, $sub_query);
        }
        if (isset($filter_data['description']) and trim($filter_data['description']) != '') {
            $ph[] = strtolower(trim($filter_data['description']));
            $query .= ' AND lower(a.description) LIKE ?';
        }
        $query .= '';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order, $strict, $additional_order_fields);
        $this->ExecuteSQL($query, $ph, $limit, $page);
        return $this;
    }
开发者ID:alachaum,项目名称:timetrex,代码行数:90,代码来源:LogListFactory.class.php

示例5: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('status_id');
        $sort_column_aliases = array('status' => 'status_id');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('status_id' => 'asc', 'name' => 'asc');
            $strict = FALSE;
        } else {
            //Always try to order by status first so INACTIVE employees go to the bottom.
            if (!isset($order['status_id'])) {
                $order = Misc::prependArray(array('status_id' => 'asc'), $order);
            }
            //Always sort by last name,first name after other columns
            if (!isset($order['name'])) {
                $order['name'] = 'asc';
            }
            $strict = TRUE;
        }
        //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $uf = new UserFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*,
							y.first_name as created_by_first_name,
							y.middle_name as created_by_middle_name,
							y.last_name as created_by_last_name,
							z.first_name as updated_by_first_name,
							z.middle_name as updated_by_middle_name,
							z.last_name as updated_by_last_name
					from 	' . $this->getTable() . ' as a
						LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	a.company_id = ?';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.created_by', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['status']) and trim($filter_data['status']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['status_id'] = Option::getByFuzzyValue($filter_data['status'], $this->getOptions('status'));
        }
        $query .= isset($filter_data['status_id']) ? $this->getWhereClauseSQL('a.status_id', $filter_data['status_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['name']) ? $this->getWhereClauseSQL('a.name', $filter_data['name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['country']) ? $this->getWhereClauseSQL('a.country', $filter_data['country'], 'upper_text_list', $ph) : NULL;
        $query .= isset($filter_data['province']) ? $this->getWhereClauseSQL('a.province', $filter_data['province'], 'upper_text_list', $ph) : NULL;
        $query .= isset($filter_data['city']) ? $this->getWhereClauseSQL('a.city', $filter_data['city'], 'text', $ph) : NULL;
        $query .= isset($filter_data['manual_id']) ? $this->getWhereClauseSQL('a.manual_id', $this->Validator->stripNon32bitInteger($filter_data['manual_id']), 'numeric', $ph) : NULL;
        $query .= isset($filter_data['work_phone']) ? $this->getWhereClauseSQL('a.work_phone', $filter_data['work_phone'], 'phone', $ph) : NULL;
        $query .= isset($filter_data['fax_phone']) ? $this->getWhereClauseSQL('a.work_phone', $filter_data['fax_phone'], 'phone', $ph) : NULL;
        $query .= isset($filter_data['address1']) ? $this->getWhereClauseSQL('a.address1', $filter_data['address1'], 'text', $ph) : NULL;
        $query .= isset($filter_data['address2']) ? $this->getWhereClauseSQL('a.address2', $filter_data['address2'], 'text', $ph) : NULL;
        $query .= isset($filter_data['postal_code']) ? $this->getWhereClauseSQL('a.postal_code', $filter_data['postal_code'], 'text', $ph) : NULL;
        $query .= isset($filter_data['tag']) ? $this->getWhereClauseSQL('a.id', array('company_id' => $company_id, 'object_type_id' => 110, 'tag' => $filter_data['tag']), 'tag', $ph) : NULL;
        $query .= isset($filter_data['created_date']) ? $this->getWhereClauseSQL('a.created_date', $filter_data['created_date'], 'date_range', $ph) : NULL;
        $query .= isset($filter_data['updated_date']) ? $this->getWhereClauseSQL('a.updated_date', $filter_data['updated_date'], 'date_range', $ph) : NULL;
        /*
        $query .= ( isset($filter_data['created_by']) AND is_array($filter_data['created_by']) ) ? $this->getWhereClauseSQL( 'a.created_by', $filter_data['created_by'], 'numeric_list', $ph ) : NULL;
        
        $query .= ( isset($filter_data['updated_by']) AND is_array($filter_data['updated_by']) ) ? $this->getWhereClauseSQL( 'a.updated_by', $filter_data['updated_by'], 'numeric_list', $ph ) : NULL;
                
        		if ( isset($filter_data['created_by']) AND !is_array($filter_data['created_by']) AND trim($filter_data['created_by']) != '' ) {
        			$ph[] = $ph[] = $this->handleSQLSyntax(strtolower(trim($filter_data['created_by'])));
        			$query  .=	' AND (lower(y.first_name) LIKE ? OR lower(y.last_name) LIKE ? ) ';
        		}
        		if ( isset($filter_data['updated_by']) AND !is_array($filter_data['updated_by']) AND trim($filter_data['updated_by']) != '' ) {
        			$ph[] = $ph[] = $this->handleSQLSyntax(strtolower(trim($filter_data['updated_by'])));
        			$query  .=	' AND (lower(z.first_name) LIKE ? OR lower(z.last_name) LIKE ? ) ';
        		}
        */
        $query .= isset($filter_data['created_by']) ? $this->getWhereClauseSQL(array('a.created_by', 'y.first_name', 'y.last_name'), $filter_data['created_by'], 'user_id_or_name', $ph) : NULL;
        $query .= isset($filter_data['updated_by']) ? $this->getWhereClauseSQL(array('a.updated_by', 'z.first_name', 'z.last_name'), $filter_data['updated_by'], 'user_id_or_name', $ph) : NULL;
        $query .= '
						AND a.deleted = 0
					';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order, $strict, $additional_order_fields);
        $this->ExecuteSQL($query, $ph, $limit, $page);
        return $this;
    }
开发者ID:alachaum,项目名称:timetrex,代码行数:88,代码来源:BranchListFactory.class.php

示例6: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('accrual_policy', 'accrual_policy_type_id', 'first_name', 'last_name', 'name', 'default_branch', 'default_department');
        $sort_column_aliases = array('accrual_policy_type' => 'accrual_policy_type_id', 'group' => 'e.name');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('last_name' => 'asc', 'accrual_policy_id' => 'asc');
            $strict = FALSE;
        } else {
            //Always sort by last name,first name after other columns
            /*
            if ( !isset($order['effective_date']) ) {
            	$order['effective_date'] = 'desc';
            }
            */
            $strict = TRUE;
        }
        //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $uf = new UserFactory();
        $bf = new BranchFactory();
        $df = new DepartmentFactory();
        $ugf = new UserGroupFactory();
        $utf = new UserTitleFactory();
        $apf = new AccrualPolicyFactory();
        $af = new AccrualFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*,
							ab.name as accrual_policy,
							ab.type_id as accrual_policy_type_id,
							b.first_name as first_name,
							b.last_name as last_name,
							b.country as country,
							b.province as province,

							c.id as default_branch_id,
							c.name as default_branch,
							d.id as default_department_id,
							d.name as default_department,
							e.id as group_id,
							e.name as "group",
							f.id as title_id,
							f.name as title
					from 	' . $this->getTable() . ' as a
						LEFT JOIN ' . $apf->getTable() . ' as ab ON ( a.accrual_policy_id = ab.id AND ab.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as b ON ( a.user_id = b.id AND b.deleted = 0 )

						LEFT JOIN ' . $bf->getTable() . ' as c ON ( b.default_branch_id = c.id AND c.deleted = 0)
						LEFT JOIN ' . $df->getTable() . ' as d ON ( b.default_department_id = d.id AND d.deleted = 0)
						LEFT JOIN ' . $ugf->getTable() . ' as e ON ( b.group_id = e.id AND e.deleted = 0 )
						LEFT JOIN ' . $utf->getTable() . ' as f ON ( b.title_id = f.id AND f.deleted = 0 )
                        
					where	b.company_id = ?
						AND EXISTS ( select 1 from ' . $af->getTable() . ' as af WHERE af.accrual_policy_id = a.accrual_policy_id AND a.user_id = af.user_id AND af.deleted = 0 )
					';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['user_id']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['user_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['type']) and trim($filter_data['type']) != '' and !isset($filter_data['type_id'])) {
            $filter_data['type_id'] = Option::getByFuzzyValue($filter_data['type'], $this->getOptions('type'));
        }
        $query .= isset($filter_data['type_id']) ? $this->getWhereClauseSQL('ab.type_id', $filter_data['type_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['accrual_policy_id']) ? $this->getWhereClauseSQL('a.accrual_policy_id', $filter_data['accrual_policy_id'], 'numeric_list', $ph) : NULL;
        if (isset($filter_data['status']) and trim($filter_data['status']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['status_id'] = Option::getByFuzzyValue($filter_data['status'], $this->getOptions('status'));
        }
        $query .= isset($filter_data['status_id']) ? $this->getWhereClauseSQL('b.status_id', $filter_data['status_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['group_id']) ? $this->getWhereClauseSQL('b.group_id', $filter_data['group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['group']) ? $this->getWhereClauseSQL('e.name', $filter_data['group'], 'text', $ph) : NULL;
        $query .= isset($filter_data['default_branch_id']) ? $this->getWhereClauseSQL('b.default_branch_id', $filter_data['default_branch_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['default_branch']) ? $this->getWhereClauseSQL('c.name', $filter_data['default_branch'], 'text', $ph) : NULL;
        $query .= isset($filter_data['default_department_id']) ? $this->getWhereClauseSQL('b.default_department_id', $filter_data['default_department_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['default_department']) ? $this->getWhereClauseSQL('d.name', $filter_data['default_department'], 'text', $ph) : NULL;
        $query .= isset($filter_data['title_id']) ? $this->getWhereClauseSQL('a.title_id', $filter_data['title_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['title']) ? $this->getWhereClauseSQL('e.name', $filter_data['title'], 'text', $ph) : NULL;
        $query .= isset($filter_data['first_name']) ? $this->getWhereClauseSQL('b.first_name', $filter_data['first_name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['last_name']) ? $this->getWhereClauseSQL('b.last_name', $filter_data['last_name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['country']) ? $this->getWhereClauseSQL('b.country', $filter_data['country'], 'upper_text_list', $ph) : NULL;
        $query .= isset($filter_data['province']) ? $this->getWhereClauseSQL('b.province', $filter_data['province'], 'upper_text_list', $ph) : NULL;
        $query .= '
						AND a.deleted = 0
					';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order, $strict, $additional_order_fields);
        $this->ExecuteSQL($query, $ph, $limit, $page);
        return $this;
    }
开发者ID:alachaum,项目名称:timetrex,代码行数:98,代码来源:AccrualBalanceListFactory.class.php

示例7: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        if (isset($filter_data['include_user_id'])) {
            $filter_data['user_id'] = $filter_data['include_user_id'];
        }
        if (isset($filter_data['exclude_user_id'])) {
            $filter_data['exclude_id'] = $filter_data['exclude_user_id'];
        }
        $additional_order_fields = array('user_status_id', 'last_name', 'first_name', 'default_branch', 'default_department', 'user_group', 'title', 'city', 'province', 'country');
        $sort_column_aliases = array('user_status' => 'user_status_id', 'type' => 'type_id', 'language_display' => 'language', 'start_week_day_display' => 'start_week_day', 'date_format_display' => 'date_format', 'time_format_display' => 'time_format', 'time_unit_format_display' => 'time_unit_format', 'time_zone_display' => 'time_zone');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('last_name' => 'asc');
            $strict = FALSE;
        } else {
            //Always sort by last name,first name after other columns
            if (!isset($order['last_name'])) {
                $order['last_name'] = 'asc';
            }
            $strict = TRUE;
        }
        //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $uf = new UserFactory();
        $bf = new BranchFactory();
        $df = new DepartmentFactory();
        $ugf = new UserGroupFactory();
        $utf = new UserTitleFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*,
							b.first_name as first_name,
							b.last_name as last_name,
							b.user_name as user_name,
							b.status_id as user_status_id,

							b.default_branch_id as default_branch_id,
							bf.name as default_branch,
							b.default_department_id as default_department_id,
							df.name as default_department,
							b.group_id as group_id,
							ugf.name as user_group,
							b.title_id as title_id,
							utf.name as title,

							b.city as city,
							b.province as province,
							b.country as country,

							y.first_name as created_by_first_name,
							y.middle_name as created_by_middle_name,
							y.last_name as created_by_last_name,
							z.first_name as updated_by_first_name,
							z.middle_name as updated_by_middle_name,
							z.last_name as updated_by_last_name
					from 	' . $this->getTable() . ' as a
						LEFT JOIN ' . $uf->getTable() . ' as b ON ( a.user_id = b.id AND b.deleted = 0 )
						LEFT JOIN ' . $bf->getTable() . ' as bf ON ( b.default_branch_id = bf.id AND bf.deleted = 0)
						LEFT JOIN ' . $df->getTable() . ' as df ON ( b.default_department_id = df.id AND df.deleted = 0)
						LEFT JOIN ' . $ugf->getTable() . ' as ugf ON ( b.group_id = ugf.id AND ugf.deleted = 0 )
						LEFT JOIN ' . $utf->getTable() . ' as utf ON ( b.title_id = utf.id AND utf.deleted = 0 )

						LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	b.company_id = ?';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('b.id', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['user_id']) ? $this->getWhereClauseSQL('b.id', $filter_data['user_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['status']) and trim($filter_data['status']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['status_id'] = Option::getByFuzzyValue($filter_data['status'], $this->getOptions('status'));
        }
        $query .= isset($filter_data['status_id']) ? $this->getWhereClauseSQL('b.status_id', $filter_data['status_id'], 'numeric_list', $ph) : NULL;
        if (isset($filter_data['include_subgroups']) and (bool) $filter_data['include_subgroups'] == TRUE) {
            $uglf = new UserGroupListFactory();
            $filter_data['group_id'] = $uglf->getByCompanyIdAndGroupIdAndSubGroupsArray($company_id, $filter_data['group_id'], TRUE);
        }
        $query .= isset($filter_data['group_id']) ? $this->getWhereClauseSQL('b.group_id', $filter_data['group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['group']) ? $this->getWhereClauseSQL('ugf.name', $filter_data['group'], 'text', $ph) : NULL;
        $query .= isset($filter_data['default_branch_id']) ? $this->getWhereClauseSQL('b.default_branch_id', $filter_data['default_branch_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['default_branch']) ? $this->getWhereClauseSQL('bf.name', $filter_data['default_branch'], 'text', $ph) : NULL;
        $query .= isset($filter_data['default_department_id']) ? $this->getWhereClauseSQL('b.default_department_id', $filter_data['default_department_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['default_department']) ? $this->getWhereClauseSQL('df.name', $filter_data['default_department'], 'text', $ph) : NULL;
        $query .= isset($filter_data['title_id']) ? $this->getWhereClauseSQL('b.title_id', $filter_data['title_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['title']) ? $this->getWhereClauseSQL('utf.name', $filter_data['title'], 'text', $ph) : NULL;
        if (isset($filter_data['sex']) and trim($filter_data['sex']) != '' and !isset($filter_data['sex_id'])) {
            $filter_data['sex_id'] = Option::getByFuzzyValue($filter_data['sex'], $this->getOptions('sex'));
        }
        $query .= isset($filter_data['sex_id']) ? $this->getWhereClauseSQL('b.sex_id', $filter_data['sex_id'], 'text_list', $ph) : NULL;
        $query .= isset($filter_data['first_name']) ? $this->getWhereClauseSQL('b.first_name', $filter_data['first_name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['last_name']) ? $this->getWhereClauseSQL('b.last_name', $filter_data['last_name'], 'text_metaphone', $ph) : NULL;
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:UserPreferenceListFactory.class.php

示例8: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (isset($filter_data['qualification_group_id'])) {
            $filter_data['group_id'] = $filter_data['qualification_group_id'];
        }
        if (isset($filter_data['qualification_type_id'])) {
            $filter_data['type_id'] = $filter_data['qualification_type_id'];
        }
        if (isset($filter_data['qualification_id'])) {
            $filter_data['id'] = $filter_data['qualification_id'];
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('type_id', 'group');
        $sort_column_aliases = array('type' => 'type_id', 'group' => 'd.name');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('type_id' => 'asc', 'name' => 'asc');
            $strict = FALSE;
        } else {
            $strict = TRUE;
        }
        Debug::Arr($order, 'Order Data:', __FILE__, __LINE__, __METHOD__, 10);
        Debug::Arr($filter_data, 'Filter Data:', __FILE__, __LINE__, __METHOD__, 10);
        $uf = new UserFactory();
        $qgf = new QualificationGroupFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*,
                            d.name as "group",
							y.first_name as created_by_first_name,
							y.middle_name as created_by_middle_name,
							y.last_name as created_by_last_name,
							z.first_name as updated_by_first_name,
							z.middle_name as updated_by_middle_name,
							z.last_name as updated_by_last_name
					from 	' . $this->getTable() . ' as a
                        LEFT JOIN ' . $qgf->getTable() . ' as d ON ( a.group_id = d.id AND d.deleted = 0)
						LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	a.company_id = ?';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.created_by', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        //$query .= ( isset($filter_data['exclude_id']) ) ? $this->getWhereClauseSQL( 'a.id', $filter_data['exclude_id'], 'not_numeric_list', $ph ) : NULL;
        if (isset($filter_data['type']) and trim($filter_data['type']) != '' and !isset($filter_data['type_id'])) {
            $filter_data['type_id'] = Option::getByFuzzyValue($filter_data['type'], $this->getOptions('type'));
        }
        $query .= isset($filter_data['type_id']) ? $this->getWhereClauseSQL('a.type_id', $filter_data['type_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['name']) ? $this->getWhereClauseSQL('a.name', $filter_data['name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['description']) ? $this->getWhereClauseSQL('a.description', $filter_data['description'], 'text', $ph) : NULL;
        $query .= isset($filter_data['group_id']) ? $this->getWhereClauseSQL('a.group_id', $filter_data['group_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['group']) ? $this->getWhereClauseSQL('d.name', $filter_data['group'], 'text', $ph) : NULL;
        $query .= isset($filter_data['tag']) ? $this->getWhereClauseSQL('a.id', array('company_id' => $company_id, 'object_type_id' => 250, 'tag' => $filter_data['tag']), 'tag', $ph) : NULL;
        if (isset($filter_data['created_date']) and trim($filter_data['created_date']) != '') {
            $date_filter = $this->getDateRangeSQL($filter_data['created_date'], 'a.created_date');
            if ($date_filter != FALSE) {
                $query .= ' AND ' . $date_filter;
            }
            unset($date_filter);
        }
        if (isset($filter_data['updated_date']) and trim($filter_data['updated_date']) != '') {
            $date_filter = $this->getDateRangeSQL($filter_data['updated_date'], 'a.updated_date');
            if ($date_filter != FALSE) {
                $query .= ' AND ' . $date_filter;
            }
            unset($date_filter);
        }
        $query .= isset($filter_data['created_by']) ? $this->getWhereClauseSQL(array('a.created_by', 'y.first_name', 'y.last_name'), $filter_data['created_by'], 'user_id_or_name', $ph) : NULL;
        $query .= isset($filter_data['updated_by']) ? $this->getWhereClauseSQL(array('a.updated_by', 'z.first_name', 'z.last_name'), $filter_data['updated_by'], 'user_id_or_name', $ph) : NULL;
        $query .= '
						AND a.deleted = 0
					';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order, $strict, $additional_order_fields);
        //Debug::Arr( $ph, 'Query: '.$query, __FILE__, __LINE__, __METHOD__, 10 );
        $this->ExecuteSQL($query, $ph, $limit, $page);
        return $this;
    }
开发者ID:alachaum,项目名称:timetrex,代码行数:85,代码来源:QualificationListFactory.class.php

示例9: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('status_id', 'type_id', 'pay_period_schedule');
        $sort_column_aliases = array('status' => 'status_id', 'type' => 'type_id');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('transaction_date' => 'desc', 'end_date' => 'desc', 'start_date' => 'desc', 'pay_period_schedule_id' => 'asc');
            $strict = FALSE;
        } else {
            //Always try to order by status first so INACTIVE employees go to the bottom.
            if (!isset($order['transaction_date'])) {
                $order['transaction_date'] = 'desc';
            }
            $strict = TRUE;
        }
        //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $ppsf = new PayPeriodScheduleFactory();
        $uf = new UserFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*,
							b.name as pay_period_schedule,
							b.type_id as type_id,

							y.first_name as created_by_first_name,
							y.middle_name as created_by_middle_name,
							y.last_name as created_by_last_name,
							z.first_name as updated_by_first_name,
							z.middle_name as updated_by_middle_name,
							z.last_name as updated_by_last_name
					from 	' . $this->getTable() . ' as a
						LEFT JOIN ' . $ppsf->getTable() . ' as b ON ( a.pay_period_schedule_id = b.id AND b.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	a.company_id = ?
					';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.created_by', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['status']) and trim($filter_data['status']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['status_id'] = Option::getByFuzzyValue($filter_data['status'], $this->getOptions('status'));
        }
        $query .= isset($filter_data['status_id']) ? $this->getWhereClauseSQL('a.status_id', $filter_data['status_id'], 'numeric_list', $ph) : NULL;
        if (isset($filter_data['type']) and trim($filter_data['type']) != '' and !isset($filter_data['type_id'])) {
            $filter_data['type_id'] = Option::getByFuzzyValue($filter_data['type'], $ppsf->getOptions('type'));
        }
        $query .= isset($filter_data['type_id']) ? $this->getWhereClauseSQL('b.type_id', $filter_data['type_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['pay_period_schedule_id']) ? $this->getWhereClauseSQL('a.pay_period_schedule_id', $filter_data['pay_period_schedule_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['pay_period_schedule']) ? $this->getWhereClauseSQL('b.name', $filter_data['pay_period_schedule'], 'text', $ph) : NULL;
        $query .= isset($filter_data['name']) ? $this->getWhereClauseSQL('b.name', $filter_data['name'], 'text', $ph) : NULL;
        /*
        		if ( isset($filter_data['permission_children_ids']) AND isset($filter_data['permission_children_ids'][0]) AND !in_array(-1, (array)$filter_data['permission_children_ids']) ) {
        			$query  .=	' AND a.created_by in ('. $this->getListSQL($filter_data['permission_children_ids'], $ph) .') ';
        		}
        		if ( isset($filter_data['id']) AND isset($filter_data['id'][0]) AND !in_array(-1, (array)$filter_data['id']) ) {
        			$query  .=	' AND a.id in ('. $this->getListSQL($filter_data['id'], $ph) .') ';
        		}
        		if ( isset($filter_data['exclude_id']) AND isset($filter_data['exclude_id'][0]) AND !in_array(-1, (array)$filter_data['exclude_id']) ) {
        			$query  .=	' AND a.id not in ('. $this->getListSQL($filter_data['exclude_id'], $ph) .') ';
        		}
        		if ( isset($filter_data['pay_period_schedule_id']) AND isset($filter_data['pay_period_schedule_id'][0]) AND !in_array(-1, (array)$filter_data['pay_period_schedule_id']) ) {
        			$query  .=	' AND a.pay_period_schedule_id in ('. $this->getListSQL($filter_data['pay_period_schedule_id'], $ph) .') ';
        		}
        
        		if ( isset($filter_data['status_id']) AND isset($filter_data['status_id'][0]) AND !in_array(-1, (array)$filter_data['status_id']) ) {
        			$query  .=	' AND a.status_id in ('. $this->getListSQL($filter_data['status_id'], $ph) .') ';
        		}
        		if ( isset($filter_data['type_id']) AND isset($filter_data['type_id'][0]) AND !in_array(-1, (array)$filter_data['type_id']) ) {
        			$query  .=	' AND b.type_id in ('. $this->getListSQL($filter_data['type_id'], $ph) .') ';
        		}
        
        		if ( isset($filter_data['name']) AND trim($filter_data['name']) != '' ) {
        			$ph[] = strtolower(trim($filter_data['name']));
        			$query  .=	' AND lower(b.name) LIKE ?';
        		}
        */
        /*
        		if ( isset($filter_data['start_date']) AND trim($filter_data['start_date']) != '' ) {
        			$ph[] = $this->db->BindTimeStamp($filter_data['start_date']);
        			$query  .=	' AND a.start_date >= ?';
        		}
        
        		if ( isset($filter_data['end_date']) AND trim($filter_data['end_date']) != '' ) {
        			$ph[] = $this->db->BindTimeStamp($filter_data['end_date']);
        			$query  .=	' AND a.start_date <= ?';
        		}
        */
        $query .= isset($filter_data['start_date']) ? $this->getWhereClauseSQL('a.start_date', $filter_data['start_date'], 'date_range_timestamp', $ph) : NULL;
        $query .= isset($filter_data['end_date']) ? $this->getWhereClauseSQL('a.end_date', $filter_data['end_date'], 'date_range_timestamp', $ph) : NULL;
        $query .= isset($filter_data['transaction_date']) ? $this->getWhereClauseSQL('a.transaction_date', $filter_data['transaction_date'], 'date_range_timestamp', $ph) : NULL;
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:PayPeriodListFactory.class.php

示例10: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('status_id', 'last_login_date', 'total_active_days', 'last_login_days', 'this_month_max_active_users', 'this_month_avg_active_users', 'this_month_min_active_users', 'last_month_max_active_users', 'last_month_avg_active_users', 'last_month_min_active_users');
        $sort_column_aliases = array('status' => 'status_id', 'product_edition' => 'product_edition_id');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('status_id' => 'asc', 'name' => 'asc');
            $strict = FALSE;
        } else {
            //Always try to order by status first so INACTIVE employees go to the bottom.
            if (!isset($order['status_id'])) {
                $order = Misc::prependArray(array('status_id' => 'asc'), $order);
            }
            //Always sort by last name,first name after other columns
            if (!isset($order['name'])) {
                $order['name'] = 'asc';
            }
            $strict = TRUE;
        }
        //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $uf = new UserFactory();
        $cuff = new CompanyUserCountFactory();
        $ph = array();
        $query = '
					select 	a.*,
							_ADODB_COUNT
							(select max(last_login_date) from ' . $uf->getTable() . ' as uf where uf.company_id = a.id ) as last_login_date,
							((select max(last_login_date) from ' . $uf->getTable() . ' as uf where uf.company_id = a.id )-a.created_date) as total_active_days,
							(' . time() . '-(select max(last_login_date) from ' . $uf->getTable() . ' as uf where uf.company_id = a.id )) as last_login_days,
							(select min(active_users) as min_active_users from ' . $cuff->getTable() . ' as cuff where cuff.company_id = a.id AND date_stamp >= ' . $this->db->qstr($this->db->BindDate(TTDate::getBeginMonthEpoch())) . ' AND date_stamp <= ' . $this->db->qstr($this->db->BindDate(time())) . ' ) as this_month_min_active_users,
							(select avg(active_users) as avg_active_users from ' . $cuff->getTable() . ' as cuff where cuff.company_id = a.id AND date_stamp >= ' . $this->db->qstr($this->db->BindDate(TTDate::getBeginMonthEpoch())) . ' AND date_stamp <= ' . $this->db->qstr($this->db->BindDate(time())) . ' ) as this_month_avg_active_users,
							(select max(active_users) as max_active_users from ' . $cuff->getTable() . ' as cuff where cuff.company_id = a.id AND date_stamp >= ' . $this->db->qstr($this->db->BindDate(TTDate::getBeginMonthEpoch())) . ' AND date_stamp <= ' . $this->db->qstr($this->db->BindDate(time())) . ' ) as this_month_max_active_users,
							(select min(active_users) as min_active_users from ' . $cuff->getTable() . ' as cuff where cuff.company_id = a.id AND date_stamp >= ' . $this->db->qstr($this->db->BindDate(TTDate::getBeginMonthEpoch(TTDate::getBeginMonthEpoch() - 86400))) . ' AND date_stamp <= ' . $this->db->qstr($this->db->BindDate(TTDate::getEndMonthEpoch(TTDate::getBeginMonthEpoch() - 86400))) . ' ) as last_month_min_active_users,
							(select avg(active_users) as avg_active_users from ' . $cuff->getTable() . ' as cuff where cuff.company_id = a.id AND date_stamp >= ' . $this->db->qstr($this->db->BindDate(TTDate::getBeginMonthEpoch(TTDate::getBeginMonthEpoch() - 86400))) . ' AND date_stamp <= ' . $this->db->qstr($this->db->BindDate(TTDate::getEndMonthEpoch(TTDate::getBeginMonthEpoch() - 86400))) . ' ) as last_month_avg_active_users,
							(select max(active_users) as max_active_users from ' . $cuff->getTable() . ' as cuff where cuff.company_id = a.id AND date_stamp >= ' . $this->db->qstr($this->db->BindDate(TTDate::getBeginMonthEpoch(TTDate::getBeginMonthEpoch() - 86400))) . ' AND date_stamp <= ' . $this->db->qstr($this->db->BindDate(TTDate::getEndMonthEpoch(TTDate::getBeginMonthEpoch() - 86400))) . ' ) as last_month_max_active_users,
							y.first_name as created_by_first_name,
							y.middle_name as created_by_middle_name,
							y.last_name as created_by_last_name,
							z.first_name as updated_by_first_name,
							z.middle_name as updated_by_middle_name,
							z.last_name as updated_by_last_name
							_ADODB_COUNT
					from 	' . $this->getTable() . ' as a
						LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	1=1
					';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.created_by', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['status']) and trim($filter_data['status']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['status_id'] = Option::getByFuzzyValue($filter_data['status'], $this->getOptions('status'));
        }
        $query .= isset($filter_data['status_id']) ? $this->getWhereClauseSQL('a.status_id', $filter_data['status_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['name']) ? $this->getWhereClauseSQL('a.name', $filter_data['name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['short_name']) ? $this->getWhereClauseSQL('a.short_name', $filter_data['short_name'], 'text', $ph) : NULL;
        $query .= isset($filter_data['product_edition_id']) ? $this->getWhereClauseSQL('a.product_edition_id', $filter_data['product_edition_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['country']) ? $this->getWhereClauseSQL('a.country', $filter_data['country'], 'upper_text_list', $ph) : NULL;
        $query .= isset($filter_data['province']) ? $this->getWhereClauseSQL('a.province', $filter_data['province'], 'upper_text_list', $ph) : NULL;
        $query .= isset($filter_data['city']) ? $this->getWhereClauseSQL('a.city', $filter_data['city'], 'text', $ph) : NULL;
        $query .= isset($filter_data['address1']) ? $this->getWhereClauseSQL('a.address1', $filter_data['address1'], 'text', $ph) : NULL;
        $query .= isset($filter_data['address2']) ? $this->getWhereClauseSQL('a.address2', $filter_data['address2'], 'text', $ph) : NULL;
        $query .= isset($filter_data['postal_code']) ? $this->getWhereClauseSQL('a.postal_code', $filter_data['postal_code'], 'text', $ph) : NULL;
        $query .= isset($filter_data['work_phone']) ? $this->getWhereClauseSQL('a.work_phone', $filter_data['work_phone'], 'phone', $ph) : NULL;
        $query .= isset($filter_data['fax_phone']) ? $this->getWhereClauseSQL('a.fax_phone', $filter_data['fax_phone'], 'phone', $ph) : NULL;
        $query .= isset($filter_data['business_number']) ? $this->getWhereClauseSQL('a.business_number', $filter_data['businessnumber'], 'text', $ph) : NULL;
        $query .= isset($filter_data['created_by']) ? $this->getWhereClauseSQL(array('a.created_by', 'y.first_name', 'y.last_name'), $filter_data['created_by'], 'user_id_or_name', $ph) : NULL;
        $query .= isset($filter_data['updated_by']) ? $this->getWhereClauseSQL(array('a.updated_by', 'z.first_name', 'z.last_name'), $filter_data['updated_by'], 'user_id_or_name', $ph) : NULL;
        $query .= '
						AND a.deleted = 0
					';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order, $strict, $additional_order_fields);
        $this->ExecuteSQL($query, $ph, $limit, $page);
        return $this;
    }
开发者ID:alachaum,项目名称:timetrex,代码行数:86,代码来源:CompanyListFactory.class.php

示例11: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array();
        if ($order == NULL) {
            $order = array('name' => 'asc');
            $strict = FALSE;
        } else {
            //Always sort by last name,first name after other columns
            if (!isset($order['name'])) {
                $order['name'] = 'asc';
            }
            $strict = TRUE;
        }
        //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $uf = new UserFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*,
							y.first_name as created_by_first_name,
							y.middle_name as created_by_middle_name,
							y.last_name as created_by_last_name,
							z.first_name as updated_by_first_name,
							z.middle_name as updated_by_middle_name,
							z.last_name as updated_by_last_name
					from 	' . $this->getTable() . ' as a
						LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	a.company_id = ?
					';
        if (isset($filter_data['permission_children_ids']) and isset($filter_data['permission_children_ids'][0]) and !in_array(-1, (array) $filter_data['permission_children_ids'])) {
            $query .= ' AND a.created_by in (' . $this->getListSQL($filter_data['permission_children_ids'], $ph) . ') ';
        }
        if (isset($filter_data['id']) and isset($filter_data['id'][0]) and !in_array(-1, (array) $filter_data['id'])) {
            $query .= ' AND a.id in (' . $this->getListSQL($filter_data['id'], $ph) . ') ';
        }
        if (isset($filter_data['exclude_id']) and isset($filter_data['exclude_id'][0]) and !in_array(-1, (array) $filter_data['exclude_id'])) {
            $query .= ' AND a.id not in (' . $this->getListSQL($filter_data['exclude_id'], $ph) . ') ';
        }
        if (isset($filter_data['iso_code']) and isset($filter_data['iso_code'][0]) and !in_array(-1, (array) $filter_data['iso_code'])) {
            $query .= ' AND a.iso_code in (' . $this->getListSQL($filter_data['iso_code'], $ph) . ') ';
        }
        if (isset($filter_data['iso_code']) and !is_array($filter_data['iso_code']) and trim($filter_data['iso_code']) != '' and !is_array($filter_data['iso_code'])) {
            $ph[] = strtolower(trim($filter_data['iso_code']));
            $query .= ' AND lower(a.iso_code) LIKE ?';
        }
        if (isset($filter_data['name']) and trim($filter_data['name']) != '') {
            $ph[] = strtolower(trim($filter_data['name']));
            $query .= ' AND lower(a.name) LIKE ?';
        }
        if (isset($filter_data['status']) and trim($filter_data['status']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['status_id'] = Option::getByFuzzyValue($filter_data['status'], $this->getOptions('status'));
        }
        $query .= isset($filter_data['status_id']) ? $this->getWhereClauseSQL('a.status_id', $filter_data['status_id'], 'numeric_list', $ph) : NULL;
        //Returns the default currency of a specific user.
        if (isset($filter_data['user_id']) and trim($filter_data['user_id']) != '') {
            $ph[] = (int) $filter_data['user_id'];
            $query .= ' AND a.id = (select currency_id from ' . $uf->getTable() . ' as uf_tmp where uf_tmp.id = ? )';
        }
        $query .= isset($filter_data['created_by']) ? $this->getWhereClauseSQL(array('a.created_by', 'y.first_name', 'y.last_name'), $filter_data['created_by'], 'user_id_or_name', $ph) : NULL;
        $query .= isset($filter_data['updated_by']) ? $this->getWhereClauseSQL(array('a.updated_by', 'z.first_name', 'z.last_name'), $filter_data['updated_by'], 'user_id_or_name', $ph) : NULL;
        $query .= '
						AND a.deleted = 0
					';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order, $strict, $additional_order_fields);
        $this->ExecuteSQL($query, $ph, $limit, $page);
        return $this;
    }
开发者ID:alachaum,项目名称:timetrex,代码行数:78,代码来源:CurrencyListFactory.class.php

示例12: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (isset($filter_data['user_review_control_status_id'])) {
            $filter_data['status_id'] = $filter_data['user_review_control_status_id'];
        }
        if (isset($filter_data['user_review_control_type_id'])) {
            $filter_data['type_id'] = $filter_data['user_review_control_type_id'];
        }
        if (isset($filter_data['include_user_id'])) {
            $filter_data['user_id'] = $filter_data['include_user_id'];
        }
        if (isset($filter_data['exclude_user_id'])) {
            $filter_data['exclude_id'] = $filter_data['exclude_user_id'];
        }
        if (isset($filter_data['include_reviewer_user_id'])) {
            $filter_data['reviewer_user_id'] = $filter_data['include_reviewer_user_id'];
        }
        if (isset($filter_data['review_tag'])) {
            $filter_data['tag'] = $filter_data['review_tag'];
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('uf.first_name', 'u.first_name', 'status_id', 'type_id', 'term_id', 'severity_id');
        $sort_column_aliases = array('type' => 'type_id', 'status' => 'status_id', 'term' => 'term_id', 'severity' => 'severity_id');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('uf.first_name' => 'asc');
            $strict = FALSE;
        } else {
            if (isset($order['user'])) {
                $order['uf.first_name'] = $order['user'];
                unset($order['user']);
            }
            if (isset($order['first_name'])) {
                $order['uf.first_name'] = $order['first_name'];
                unset($order['first_name']);
            }
            if (isset($order['last_name'])) {
                $order['uf.last_name'] = $order['last_name'];
                unset($order['last_name']);
            }
            if (isset($order['reviewer_user'])) {
                $order['u.first_name'] = $order['reviewer_user'];
                unset($order['reviewer_user']);
            }
            $strict = TRUE;
        }
        Debug::Arr($order, 'Order Data:', __FILE__, __LINE__, __METHOD__, 10);
        Debug::Arr($filter_data, 'Filter Data:', __FILE__, __LINE__, __METHOD__, 10);
        $uf = new UserFactory();
        $urf = new UserReviewFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	distinct a.*,
                            uf.first_name as user_first_name,
                            uf.last_name as user_last_name,
                            u.first_name as reviewer_user_first_name,
                            u.last_name as reviewer_user_last_name,

							y.first_name as created_by_first_name,
							y.middle_name as created_by_middle_name,
							y.last_name as created_by_last_name,
							z.first_name as updated_by_first_name,
							z.middle_name as updated_by_middle_name,
							z.last_name as updated_by_last_name
					from 	' . $this->getTable() . ' as a
                        LEFT JOIN ' . $urf->getTable() . ' as urf ON ( urf.user_review_control_id = a.id AND urf.deleted = 0 )
                        LEFT JOIN ' . $uf->getTable() . ' as uf ON ( a.user_id = uf.id AND uf.deleted = 0)
                        LEFT JOIN ' . $uf->getTable() . ' as u ON ( a.reviewer_user_id = u.id AND u.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	uf.company_id = ? ';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['user_id']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['user_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['status']) and trim($filter_data['status']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['status_id'] = Option::getByFuzzyValue($filter_data['status'], $this->getOptions('status'));
        }
        if (isset($filter_data['type']) and trim($filter_data['type']) != '' and !isset($filter_data['type_id'])) {
            $filter_data['type_id'] = Option::getByFuzzyValue($filter_data['type'], $this->getOptions('type'));
        }
        if (isset($filter_data['term']) and trim($filter_data['term']) != '' and !isset($filter_data['term_id'])) {
            $filter_data['term_id'] = Option::getByFuzzyValue($filter_data['term'], $this->getOptions('term'));
        }
        if (isset($filter_data['severity']) and trim($filter_data['severity']) != '' and !isset($filter_data['severity_id'])) {
            $filter_data['severity_id'] = Option::getByFuzzyValue($filter_data['severity'], $this->getOptions('severity'));
        }
        $query .= isset($filter_data['reviewer_user_id']) ? $this->getWhereClauseSQL('a.reviewer_user_id', $filter_data['reviewer_user_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['reviewer_user']) ? $this->getWhereClauseSQL(array('a.reviewer_user_id', 'uf.first_name', 'uf.last_name'), $filter_data['reviewer_user'], 'user_id_or_name', $ph) : NULL;
        $query .= isset($filter_data['user']) ? $this->getWhereClauseSQL(array('a.user_id', 'uf.first_name', 'uf.last_name'), $filter_data['user'], 'user_id_or_name', $ph) : NULL;
        $query .= isset($filter_data['exclude_reviewer_user_id']) ? $this->getWhereClauseSQL('a.reviewer_user_id', $filter_data['exclude_reviewer_user_id'], 'not_numeric_list', $ph) : NULL;
        $query .= isset($filter_data['status_id']) ? $this->getWhereClauseSQL('a.status_id', $filter_data['status_id'], 'numeric_list', $ph) : NULL;
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:UserReviewControlListFactory.class.php

示例13: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('employee_first_name', 'employee_last_name', 'title', 'user_group', 'default_branch', 'default_department', 'type_id', 'sex_id', 'status_id');
        $sort_column_aliases = array('type' => 'type_id', 'status' => 'status_id', 'sex' => 'sex_id');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('employee_first_name' => 'asc', 'employee_last_name' => 'asc', 'last_name' => 'asc', 'first_name' => 'asc');
            $strict = FALSE;
        } else {
            if (!isset($order['last_name'])) {
                $order['last_name'] = 'asc';
            }
            if (!isset($order['first_name'])) {
                $order['first_name'] = 'asc';
            }
            $strict = TRUE;
        }
        Debug::Arr($order, 'Order Data:', __FILE__, __LINE__, __METHOD__, 10);
        Debug::Arr($filter_data, 'Filter Data:', __FILE__, __LINE__, __METHOD__, 10);
        $uf = TTnew('UserFactory');
        $bf = new BranchFactory();
        $df = new DepartmentFactory();
        $ugf = new UserGroupFactory();
        $utf = new UserTitleFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select
							a.*,
                            u.first_name as employee_first_name,
                            u.last_name as employee_last_name,
                            
                            bf.id as default_branch_id,
							bf.name as default_branch,
							df.id as default_department_id,
							df.name as default_department,
							ugf.id as group_id,
							ugf.name as user_group,
							utf.id as title_id,
							utf.name as title,
                            
							y.first_name as created_by_first_name,
							y.middle_name as created_by_middle_name,
							y.last_name as created_by_last_name,
							z.first_name as updated_by_first_name,
							z.middle_name as updated_by_middle_name,
							z.last_name as updated_by_last_name
					from 	' . $this->getTable() . ' as a
                        LEFT JOIN ' . $uf->getTable() . ' as u ON ( u.id = a.user_id AND u.deleted = 0 )
                        LEFT JOIN ' . $bf->getTable() . ' as bf ON ( u.default_branch_id = bf.id AND bf.deleted = 0)
                        LEFT JOIN ' . $df->getTable() . ' as df ON ( u.default_department_id = df.id AND df.deleted = 0)
                        LEFT JOIN ' . $ugf->getTable() . ' as ugf ON ( u.group_id = ugf.id AND ugf.deleted = 0 )
                        LEFT JOIN ' . $utf->getTable() . ' as utf ON ( u.title_id = utf.id AND utf.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
                        LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
                        where u.company_id = ?
                        ';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['user_id']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['user_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['status']) and trim($filter_data['status']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['status_id'] = Option::getByFuzzyValue($filter_data['status'], $this->getOptions('status'));
        }
        $query .= isset($filter_data['status_id']) ? $this->getWhereClauseSQL('a.status_id', $filter_data['status_id'], 'numeric_list', $ph) : NULL;
        if (isset($filter_data['type']) and trim($filter_data['type']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['type_id'] = Option::getByFuzzyValue($filter_data['type'], $this->getOptions('type'));
        }
        $query .= isset($filter_data['type_id']) ? $this->getWhereClauseSQL('a.type_id', $filter_data['type_id'], 'numeric_list', $ph) : NULL;
        if (isset($filter_data['sex']) and trim($filter_data['sex']) != '' and !isset($filter_data['sex_id'])) {
            $filter_data['sex_id'] = Option::getByFuzzyValue($filter_data['sex'], $this->getOptions('sex'));
        }
        $query .= isset($filter_data['sex_id']) ? $this->getWhereClauseSQL('a.sex_id', $filter_data['sex_id'], 'text_list', $ph) : NULL;
        $query .= isset($filter_data['first_name']) ? $this->getWhereClauseSQL('a.first_name', $filter_data['first_name'], 'text', $ph) : NULL;
        $query .= isset($filter_data['middle_name']) ? $this->getWhereClauseSQL('a.middle_name', $filter_data['middle_name'], 'text', $ph) : NULL;
        $query .= isset($filter_data['last_name']) ? $this->getWhereClauseSQL('a.last_name', $filter_data['last_name'], 'text', $ph) : NULL;
        $query .= isset($filter_data['home_phone']) ? $this->getWhereClauseSQL('a.home_phone', $filter_data['home_phone'], 'phone', $ph) : NULL;
        $query .= isset($filter_data['work_phone']) ? $this->getWhereClauseSQL('a.work_phone', $filter_data['work_phone'], 'phone', $ph) : NULL;
        $query .= isset($filter_data['country']) ? $this->getWhereClauseSQL('a.country', $filter_data['country'], 'upper_text_list', $ph) : NULL;
        $query .= isset($filter_data['province']) ? $this->getWhereClauseSQL('a.province', $filter_data['province'], 'upper_text_list', $ph) : NULL;
        $query .= isset($filter_data['city']) ? $this->getWhereClauseSQL('a.city', $filter_data['city'], 'text', $ph) : NULL;
        $query .= isset($filter_data['address1']) ? $this->getWhereClauseSQL('a.address1', $filter_data['address1'], 'text', $ph) : NULL;
        $query .= isset($filter_data['address2']) ? $this->getWhereClauseSQL('a.address2', $filter_data['address2'], 'text', $ph) : NULL;
        $query .= isset($filter_data['postal_code']) ? $this->getWhereClauseSQL('a.postal_code', $filter_data['postal_code'], 'text', $ph) : NULL;
        $query .= isset($filter_data['sin']) ? $this->getWhereClauseSQL('a.sin', $filter_data['sin'], 'numeric', $ph) : NULL;
        $query .= isset($filter_data['work_email']) ? $this->getWhereClauseSQL('a.work_email', $filter_data['work_email'], 'text', $ph) : NULL;
        $query .= isset($filter_data['home_email']) ? $this->getWhereClauseSQL('a.home_email', $filter_data['home_email'], 'text', $ph) : NULL;
        $query .= isset($filter_data['tag']) ? $this->getWhereClauseSQL('a.id', array('company_id' => $company_id, 'object_type_id' => 230, 'tag' => $filter_data['tag']), 'tag', $ph) : NULL;
        if (isset($filter_data['created_date']) and trim($filter_data['created_date']) != '') {
            $date_filter = $this->getDateRangeSQL($filter_data['created_date'], 'a.created_date');
            if ($date_filter != FALSE) {
                $query .= ' AND ' . $date_filter;
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:UserContactListFactory.class.php

示例14: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (isset($filter_data['roe_id'])) {
            $filter_data['id'] = $filter_data['roe_id'];
            unset($filter_data['roe_id']);
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('uf.first_name', 'uf.last_name', 'code_id', 'pay_period_type_id');
        $sort_column_aliases = array('code' => 'code_id', 'pay_period_type' => 'pay_period_type_id');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('last_date' => 'desc');
            //Order ROEs by last date for which paid.
            $strict = FALSE;
        } else {
            if (isset($order['first_name'])) {
                $order['uf.first_name'] = $order['first_name'];
                unset($order['first_name']);
            }
            if (isset($order['last_name'])) {
                $order['uf.last_name'] = $order['last_name'];
                unset($order['last_name']);
            }
            $strict = TRUE;
        }
        //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $uf = new UserFactory();
        //$ppsf = new PayPeriodScheduleFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*,
                            uf.first_name as first_name,
                            uf.last_name as last_name,
							y.first_name as created_by_first_name,
							y.middle_name as created_by_middle_name,
							y.last_name as created_by_last_name,
							z.first_name as updated_by_first_name,
							z.middle_name as updated_by_middle_name,
							z.last_name as updated_by_last_name
					from 	' . $this->getTable() . ' as a
                        LEFT JOIN ' . $uf->getTable() . ' as uf ON ( a.user_id = uf.id AND uf.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )
					where	uf.company_id = ?';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['code']) and trim($filter_data['code']) != '' and !isset($filter_data['code_id'])) {
            $filter_data['code_id'] = Option::getByFuzzyValue($filter_data['code'], $this->getOptions('code'));
        }
        $query .= isset($filter_data['first_name']) ? $this->getWhereClauseSQL('uf.first_name', $filter_data['first_name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['last_name']) ? $this->getWhereClauseSQL('uf.last_name', $filter_data['last_name'], 'text_metaphone', $ph) : NULL;
        $query .= isset($filter_data['user_id']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['user_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['code_id']) ? $this->getWhereClauseSQL('a.code_id', $filter_data['code_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['pay_period_type_id']) ? $this->getWhereClauseSQL('a.pay_period_type_id', $filter_data['pay_period_type_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['first_date']) ? $this->getWhereClauseSQL('a.first_date', $filter_data['first_date'], 'date_range', $ph) : NULL;
        $query .= isset($filter_data['last_date']) ? $this->getWhereClauseSQL('a.last_date', $filter_data['last_date'], 'date_range', $ph) : NULL;
        $query .= isset($filter_data['pay_period_end_date']) ? $this->getWhereClauseSQL('a.pay_period_end_date', $filter_data['pay_period_end_date'], 'date_range', $ph) : NULL;
        $query .= isset($filter_data['recall_date']) ? $this->getWhereClauseSQL('a.recall_date', $filter_data['recall_date'], 'date_range', $ph) : NULL;
        $query .= isset($filter_data['serial']) ? $this->getWhereClauseSQL('a.serial', $filter_data['serial'], 'text', $ph) : NULL;
        $query .= isset($filter_data['comments']) ? $this->getWhereClauseSQL('a.comments', $filter_data['comments'], 'text', $ph) : NULL;
        if (isset($filter_data['created_by']) and isset($filter_data['created_by'][0]) and !in_array(-1, (array) $filter_data['created_by'])) {
            $query .= ' AND a.created_by in (' . $this->getListSQL($filter_data['created_by'], $ph) . ') ';
        }
        if (isset($filter_data['updated_by']) and isset($filter_data['updated_by'][0]) and !in_array(-1, (array) $filter_data['updated_by'])) {
            $query .= ' AND a.updated_by in (' . $this->getListSQL($filter_data['updated_by'], $ph) . ') ';
        }
        $query .= '
						AND a.deleted = 0
					';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order, $strict, $additional_order_fields);
        $this->ExecuteSQL($query, $ph, $limit, $page);
        return $this;
    }
开发者ID:alachaum,项目名称:timetrex,代码行数:84,代码来源:ROEListFactory.class.php

示例15: getAPISearchByCompanyIdAndArrayCriteria

    function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (isset($filter_data['user_status_id'])) {
            $filter_data['status_id'] = $filter_data['user_status_id'];
        }
        if (isset($filter_data['user_group_id'])) {
            $filter_data['group_id'] = $filter_data['user_group_id'];
        }
        if (isset($filter_data['user_title_id'])) {
            $filter_data['title_id'] = $filter_data['user_title_id'];
        }
        if (isset($filter_data['include_user_id'])) {
            $filter_data['user_id'] = $filter_data['include_user_id'];
        }
        if (isset($filter_data['exclude_user_id'])) {
            $filter_data['exclude_id'] = $filter_data['exclude_user_id'];
        }
        if (isset($filter_data['accrual_type_id'])) {
            $filter_data['type_id'] = $filter_data['accrual_type_id'];
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        if (isset($filter_data['accrual_type_id'])) {
            $filter_data['type_id'] = $filter_data['accrual_type_id'];
        }
        $additional_order_fields = array('accrual_policy', 'accrual_policy_type_id', 'date_stamp');
        $sort_column_aliases = array('accrual_policy_type' => 'accrual_policy_type_id', 'type' => 'type_id');
        $order = $this->getColumnsFromAliases($order, $sort_column_aliases);
        if ($order == NULL) {
            $order = array('accrual_policy_id' => 'asc', 'date_stamp' => 'desc');
            $strict = FALSE;
        } else {
            $strict = TRUE;
        }
        //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $uf = new UserFactory();
        $udtf = new UserDateTotalFactory();
        $udf = new UserDateFactory();
        $bf = new BranchFactory();
        $df = new DepartmentFactory();
        $ugf = new UserGroupFactory();
        $utf = new UserTitleFactory();
        $apf = new AccrualPolicyFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*,
							ab.name as accrual_policy,
							ab.type_id as accrual_policy_type_id,
							CASE WHEN udf.date_stamp is NOT NULL THEN udf.date_stamp ELSE a.time_stamp END as date_stamp,
							b.first_name as first_name,
							b.last_name as last_name,
							b.country as country,
							b.province as province,

							c.id as default_branch_id,
							c.name as default_branch,
							d.id as default_department_id,
							d.name as default_department,
							e.id as group_id,
							e.name as "user_group",
							f.id as title_id,
							f.name as title
					from 	' . $this->getTable() . ' as a
						LEFT JOIN ' . $apf->getTable() . ' as ab ON ( a.accrual_policy_id = ab.id AND ab.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as b ON ( a.user_id = b.id AND b.deleted = 0 )

						LEFT JOIN ' . $udtf->getTable() . ' as udtf ON ( a.user_date_total_id = udtf.id AND udtf.deleted = 0 )
						LEFT JOIN ' . $udf->getTable() . ' as udf ON ( udtf.user_date_id = udf.id AND udf.deleted = 0 )

						LEFT JOIN ' . $bf->getTable() . ' as c ON ( b.default_branch_id = c.id AND c.deleted = 0)
						LEFT JOIN ' . $df->getTable() . ' as d ON ( b.default_department_id = d.id AND d.deleted = 0)
						LEFT JOIN ' . $ugf->getTable() . ' as e ON ( b.group_id = e.id AND e.deleted = 0 )
						LEFT JOIN ' . $utf->getTable() . ' as f ON ( b.title_id = f.id AND f.deleted = 0 )
                        LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 )
						LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 )

					where	b.company_id = ?
					';
        $query .= isset($filter_data['permission_children_ids']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['permission_children_ids'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['user_id']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['user_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['id']) ? $this->getWhereClauseSQL('a.id', $filter_data['id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['exclude_id']) ? $this->getWhereClauseSQL('a.user_id', $filter_data['exclude_id'], 'not_numeric_list', $ph) : NULL;
        if (isset($filter_data['type']) and trim($filter_data['type']) != '' and !isset($filter_data['type_id'])) {
            $filter_data['type_id'] = Option::getByFuzzyValue($filter_data['type'], $this->getOptions('type'));
        }
        $query .= isset($filter_data['type_id']) ? $this->getWhereClauseSQL('a.type_id', $filter_data['type_id'], 'numeric_list', $ph) : NULL;
        if (isset($filter_data['status']) and trim($filter_data['status']) != '' and !isset($filter_data['status_id'])) {
            $filter_data['status_id'] = Option::getByFuzzyValue($filter_data['status'], $this->getOptions('status'));
        }
        $query .= isset($filter_data['accrual_policy_type_id']) ? $this->getWhereClauseSQL('ab.type_id', $filter_data['accrual_policy_type_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['accrual_policy_id']) ? $this->getWhereClauseSQL('a.accrual_policy_id', $filter_data['accrual_policy_id'], 'numeric_list', $ph) : NULL;
        $query .= isset($filter_data['status_id']) ? $this->getWhereClauseSQL('b.status_id', $filter_data['status_id'], 'numeric_list', $ph) : NULL;
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:AccrualListFactory.class.php


注:本文中的Option::getByFuzzyValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。