コード例 #1
0
function getValuesforColumns($column_name, $search_string, $criteria = 'cts', $input = '')
{
    global $log, $current_user;
    $log->debug("Entering getValuesforColumns(" . $column_name . "," . $search_string . ") method ...");
    global $column_array, $table_col_array;
    if (empty($input)) {
        $input = $_REQUEST;
    }
    if ($input['type'] == "entchar") {
        $criteria = "is";
    }
    for ($i = 0; $i < count($column_array); $i++) {
        if ($column_name == $column_array[$i]) {
            $val = $table_col_array[$i];
            $explode_column = explode(",", $val);
            $x = count($explode_column);
            if ($x == 1) {
                $where = getSearch_criteria($criteria, $search_string, $val);
            } else {
                if ($column_name == "contact_id" && $input['type'] == "entchar") {
                    $concatSql = getSqlForNameInDisplayFormat(array('lastname' => 'vtiger_contactdetails.lastname', 'firstname' => 'vtiger_contactdetails.firstname'), 'Contacts');
                    $where = "{$concatSql} = '{$search_string}'";
                } else {
                    $where = "(";
                    for ($j = 0; $j < count($explode_column); $j++) {
                        $where .= getSearch_criteria($criteria, $search_string, $explode_column[$j]);
                        if ($j != $x - 1) {
                            if ($criteria == 'dcts' || $criteria == 'isn') {
                                $where .= " and ";
                            } else {
                                $where .= " or ";
                            }
                        }
                    }
                    $where .= ")";
                }
            }
            break 1;
        }
    }
    $log->debug("Exiting getValuesforColumns method ...");
    return $where;
}
コード例 #2
0
ファイル: SearchUtils.php プロジェクト: honj51/taobaocrm
function getWhereCondition($currentModule)
{
    global $log;
    $column_array = getColumnOrTableArr();
    $table_col_array = getColumnOrTableArr(false);
    $log->debug("Entering getWhereCondition(" . $currentModule . ") method ...");
    if ($_REQUEST['searchtype'] != 'advance') {
        $where = Search($currentModule);
    } else {
        $adv_string = '';
        $url_string = '';
        if (isset($_REQUEST['search_cnt'])) {
            $tot_no_criteria = $_REQUEST['search_cnt'];
        }
        if ($_REQUEST['matchtype'] == 'all') {
            $matchtype = "and";
        } else {
            $matchtype = "or";
        }
        for ($i = 0; $i < $tot_no_criteria; $i++) {
            if ($i == $tot_no_criteria - 1) {
                $matchtype = "";
            }
            $table_colname = 'Fields' . $i;
            $search_condition = 'Condition' . $i;
            $search_value = 'Srch_value' . $i;
            $tab_col = '';
            $tab_col = str_replace('\'', '', stripslashes($_REQUEST[$table_colname]));
            $tab_col = str_replace('\\', '', $tab_col);
            $srch_cond = str_replace('\'', '', stripslashes($_REQUEST[$search_condition]));
            $srch_cond = str_replace('\\', '', $srch_cond);
            $srch_val = $_REQUEST[$search_value];
            list($tab_name, $column_name) = split("[.]", $tab_col);
            $url_string .= "&Fields" . $i . "=" . $tab_col . "&Condition" . $i . "=" . $srch_cond . "&Srch_value" . $i . "=" . $srch_val;
            if ($tab_col == "smownerid") {
                $adv_string .= getSearch_criteria($srch_cond, $srch_val, 'ec_users.user_name') . $matchtype;
            } elseif ($tab_col == "smcreatorid") {
                $user_id = getUserId_Ol($srch_val);
                $adv_string .= " smcreatorid='" . $user_id . "' " . $matchtype;
            } elseif ($tab_col == "approvedby") {
                $user_id = getUserId_Ol($srch_val);
                $adv_string .= " approvedby='" . $user_id . "' " . $matchtype;
            } elseif ($tab_col == "approved") {
                $srch_val = getApproveIdByStatus($srch_val);
                $adv_string .= " approved='" . $srch_val . "' " . $matchtype;
            } elseif ($tab_col == "ec_activity.status") {
                $adv_string .= " (" . getSearch_criteria($srch_cond, $srch_val, 'ec_activity.status') . " or";
                $adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, 'ec_activity.eventstatus') . " )" . $matchtype;
            } elseif ($tab_col == "ec_cntactivityrel.contactid") {
                $adv_string .= " (" . getSearch_criteria($srch_cond, $srch_val, 'ec_contactdetails.firstname') . " or";
                $adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, 'ec_contactdetails.lastname') . " )" . $matchtype;
            } elseif ($tab_col == "ec_products.catalogid") {
                $adv_string .= getSearch_criteria($srch_cond, $srch_val, 'ec_catalog.catalogname') . " " . $matchtype;
            } elseif ($tab_col == "ec_faq.faqcategoryid") {
                $adv_string .= getSearch_criteria($srch_cond, $srch_val, 'ec_faqcategory.faqcategoryname') . " " . $matchtype;
            } elseif (in_array($column_name, $column_array)) {
                $adv_string .= getValuesforColumns($column_name, $srch_val) . " " . $matchtype;
            } else {
                $adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, $tab_col) . " " . $matchtype;
            }
        }
        $where = "(" . $adv_string . ")#@@#" . $url_string . "&searchtype=advance&search_cnt=" . $tot_no_criteria . "&matchtype=" . $_REQUEST['matchtype'];
    }
    /*
    elseif($_REQUEST['type']=='dbrd')
    {
    	$where = getdashboardcondition();
    }
    
    else
    {
     		$where=Search($currentModule);
    }
    */
    $log->info("getWhereCondition method where condition:" . $where);
    $log->debug("Exiting getWhereCondition method ...");
    return $where;
}
コード例 #3
0
function getValuesforColumns($column_name, $search_string, $criteria = 'cts')
{
    global $log, $current_user;
    $log->debug("Entering getValuesforColumns(" . $column_name . "," . $search_string . ") method ...");
    global $column_array, $table_col_array;
    if ($_REQUEST['type'] == "entchar") {
        $criteria = "is";
    }
    for ($i = 0; $i < count($column_array); $i++) {
        if ($column_name == $column_array[$i]) {
            $val = $table_col_array[$i];
            $explode_column = explode(",", $val);
            $x = count($explode_column);
            if ($x == 1) {
                $where = getSearch_criteria($criteria, $search_string, $val);
            } else {
                if ($column_name == "contact_id" && $_REQUEST['type'] == "entchar") {
                    if (getFieldVisibilityPermission('Contacts', $current_user->id, 'firstname') == '0') {
                        $where = "concat(vtiger_contactdetails.lastname, ' ', vtiger_contactdetails.firstname) = '{$search_string}'";
                    } else {
                        $where = "vtiger_contactdetails.lastname = '{$search_string}'";
                    }
                } else {
                    $where = "(";
                    for ($j = 0; $j < count($explode_column); $j++) {
                        $where .= getSearch_criteria($criteria, $search_string, $explode_column[$j]);
                        if ($j != $x - 1) {
                            if ($criteria == 'dcts' || $criteria == 'isn') {
                                $where .= " and ";
                            } else {
                                $where .= " or ";
                            }
                        }
                    }
                    $where .= ")";
                }
            }
            break 1;
        }
    }
    $log->debug("Exiting getValuesforColumns method ...");
    return $where;
}
コード例 #4
0
ファイル: SearchUtils.php プロジェクト: latechdirect/vtiger
function getWhereCondition($currentModule)
{
    global $log, $default_charset, $adb;
    global $column_array, $table_col_array, $mod_strings, $current_user;
    $log->debug("Entering getWhereCondition(" . $currentModule . ") method ...");
    if ($_REQUEST['searchtype'] == 'advance') {
        $adv_string = '';
        $url_string = '';
        if (isset($_REQUEST['search_cnt'])) {
            $tot_no_criteria = vtlib_purify($_REQUEST['search_cnt']);
        }
        if ($_REQUEST['matchtype'] == 'all') {
            $matchtype = "and";
        } else {
            $matchtype = "or";
        }
        for ($i = 0; $i < $tot_no_criteria; $i++) {
            if ($i == $tot_no_criteria - 1) {
                $matchtype = "";
            }
            $table_colname = 'Fields' . $i;
            $search_condition = 'Condition' . $i;
            $search_value = 'Srch_value' . $i;
            list($tab_col_val, $typeofdata) = split("::::", $_REQUEST[$table_colname]);
            $tab_col = str_replace('\'', '', stripslashes($tab_col_val));
            $srch_cond = str_replace('\'', '', stripslashes($_REQUEST[$search_condition]));
            $srch_val = $_REQUEST[$search_value];
            $srch_val = function_exists(iconv) ? @iconv("UTF-8", $default_charset, $srch_val) : $srch_val;
            $url_string .= "&Fields" . $i . "=" . $tab_col . "&Condition" . $i . "=" . $srch_cond . "&Srch_value" . $i . "=" . urlencode($srch_val);
            $srch_val = $adb->sql_escape_string($srch_val);
            list($tab_name, $column_name) = split("[.]", $tab_col);
            $uitype = getUItype($currentModule, $column_name);
            //added to allow  search in check box type fields(ex: product active. it will contain 0 or 1) using yes or no instead of 0 or 1
            if ($uitype == 56) {
                if (strtolower($srch_val) == 'yes') {
                    $adv_string .= " " . getSearch_criteria($srch_cond, "1", $tab_name . '.' . $column_name) . " " . $matchtype;
                } elseif (strtolower($srch_val) == 'no') {
                    $adv_string .= " " . getSearch_criteria($srch_cond, "0", $tab_name . '.' . $column_name) . " " . $matchtype;
                } else {
                    $adv_string .= " " . getSearch_criteria($srch_cond, "-1", $tab_name . '.' . $column_name) . " " . $matchtype;
                }
            } elseif ($uitype == 15 || $uitype == 16) {
                if (is_uitype($uitype, '_picklist_')) {
                    // Get all the keys for the for the Picklist value
                    $mod_keys = array_keys($mod_strings, $srch_val);
                    if (sizeof($mod_keys) >= 1) {
                        // Iterate on the keys, to get the first key which doesn't start with LBL_      (assuming it is not used in PickList)
                        foreach ($mod_keys as $mod_idx => $mod_key) {
                            $stridx = strpos($mod_key, 'LBL_');
                            // Use strict type comparision, refer strpos for more details
                            if ($stridx !== 0) {
                                $srch_val = $mod_key;
                                if (getFieldVisibilityPermission("Calendar", $current_user->id, 'taskstatus') == '0' && ($tab_col == "vtiger_activity.status" || $tab_col == "vtiger_activity.eventstatus")) {
                                    if ($srch_cond == 'dcts' || $srch_cond == 'isn' || $srch_cond == 'is') {
                                        $re_cond = "and";
                                    } else {
                                        $re_cond = "or";
                                    }
                                    if ($srch_cond == 'is' && $srch_val != '') {
                                        $re_cond = "or";
                                    }
                                    $adv_string .= " (" . getSearch_criteria($srch_cond, $srch_val, 'vtiger_activity.status') . " " . $re_cond;
                                    $adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, 'vtiger_activity.eventstatus') . " )" . $matchtype;
                                } else {
                                    $adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, $tab_name . '.' . $column_name) . " " . $matchtype;
                                }
                                break;
                            } else {
                                //if the key contains the LBL, then return the original srch_val.
                                $adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, $tab_name . '.' . $column_name) . " " . $matchtype;
                            }
                        }
                    } else {
                        if (getFieldVisibilityPermission("Calendar", $current_user->id, 'taskstatus') == '0' && ($tab_col == "vtiger_activity.status" || $tab_col == "vtiger_activity.eventstatus")) {
                            if ($srch_cond == 'dcts' || $srch_cond == 'isn' || $srch_cond == 'is') {
                                $re_cond = "and";
                            } else {
                                $re_cond = "or";
                            }
                            if ($srch_cond == 'is' && $srch_val != '') {
                                $re_cond = "or";
                            }
                            $adv_string .= " (" . getSearch_criteria($srch_cond, $srch_val, 'vtiger_activity.status') . " " . $re_cond;
                            $adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, 'vtiger_activity.eventstatus') . " )" . $matchtype;
                        } else {
                            $adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, $tab_col) . " " . $matchtype;
                        }
                    }
                }
            } elseif ($tab_col == "vtiger_crmentity.smownerid") {
                $adv_string .= " (" . getSearch_criteria($srch_cond, $srch_val, 'vtiger_users.user_name') . " or";
                $adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, 'vtiger_groups.groupname') . " )" . $matchtype;
            } elseif ($tab_col == "vtiger_cntactivityrel.contactid") {
                $adv_string .= " (" . getSearch_criteria($srch_cond, $srch_val, 'vtiger_contactdetails.firstname') . " or";
                $adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, 'vtiger_contactdetails.lastname') . " )" . $matchtype;
            } elseif (in_array($column_name, $column_array)) {
                $adv_string .= " " . getValuesforColumns($column_name, $srch_val, $srch_cond) . " " . $matchtype;
            } else {
                $adv_string .= " " . getSearch_criteria($srch_cond, $srch_val, $tab_col) . " " . $matchtype;
            }
        }
        $where = "(" . $adv_string . ")#@@#" . $url_string . "&searchtype=advance&search_cnt=" . $tot_no_criteria . "&matchtype=" . vtlib_purify($_REQUEST['matchtype']);
    } elseif ($_REQUEST['type'] == 'dbrd') {
        $where = getdashboardcondition();
    } else {
        $where = Search($currentModule);
    }
    $log->debug("Exiting getWhereCondition method ...");
    return $where;
}