示例#1
0
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY user_name';
        }
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('SalesOrder', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
///Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $list_query = fixPostgresQuery($list_query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($list_query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
    $noofrows = null;
}
$queryMode = isset($_REQUEST['query']) && $_REQUEST['query'] == 'true';
$start = ListViewSession::getRequestCurrentPage($currentModule, $list_query, $viewid, $queryMode);
$navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
$limit_start_rec = ($start - 1) * $list_max_entries_per_page;
if ($adb->dbType == "pgsql") {
    $list_result = $adb->pquery($list_query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array());
} else {
    $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
示例#2
0
/** Function to check permission to access a vtiger_field for a given user
 * @param $fld_module -- Module :: Type String
 * @param $userid -- User Id :: Type integer
 * @param $fieldname -- Field Name :: Type varchar
 * @returns $rolename -- Role Name :: Type varchar
 *
 */
function getFieldVisibilityPermission($fld_module, $userid, $fieldname, $accessmode = 'readonly')
{
    $log = vglobal('log');
    $log->debug("Entering getFieldVisibilityPermission(" . $fld_module . "," . $userid . "," . $fieldname . ") method ...");
    $adb = PearDatabase::getInstance();
    $current_user = vglobal('current_user');
    // Check if field is in-active
    $fieldActive = isFieldActive($fld_module, $fieldname);
    if ($fieldActive == false) {
        return '1';
    }
    require 'user_privileges/user_privileges_' . $userid . '.php';
    /* Asha: Fix for ticket #4508. Users with View all and Edit all permission will also have visibility permission for all fields */
    if ($is_admin || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
        $log->debug("Exiting getFieldVisibilityPermission method ...");
        return '0';
    } else {
        //get vtiger_profile list using userid
        $profilelist = getCurrentUserProfileList();
        //get tabid
        $tabid = getTabid($fld_module);
        if (count($profilelist) > 0) {
            if ($accessmode == 'readonly') {
                $query = "SELECT vtiger_profile2field.visible FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=? AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0  AND vtiger_profile2field.profileid in (" . generateQuestionMarks($profilelist) . ") AND vtiger_field.fieldname= ? and vtiger_field.presence in (0,2) GROUP BY vtiger_field.fieldid";
            } else {
                $query = "SELECT vtiger_profile2field.visible FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=? AND vtiger_profile2field.visible=0 AND vtiger_profile2field.readonly=0 AND vtiger_def_org_field.visible=0  AND vtiger_profile2field.profileid in (" . generateQuestionMarks($profilelist) . ") AND vtiger_field.fieldname= ? and vtiger_field.presence in (0,2) GROUP BY vtiger_field.fieldid";
            }
            $params = array($tabid, $profilelist, $fieldname);
        } else {
            if ($accessmode == 'readonly') {
                $query = "SELECT vtiger_profile2field.visible FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=? AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0  AND vtiger_field.fieldname= ? and vtiger_field.presence in (0,2) GROUP BY vtiger_field.fieldid";
            } else {
                $query = "SELECT vtiger_profile2field.visible FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=? AND vtiger_profile2field.visible=0 AND vtiger_profile2field.readonly=0 AND vtiger_def_org_field.visible=0  AND vtiger_field.fieldname= ? and vtiger_field.presence in (0,2) GROUP BY vtiger_field.fieldid";
            }
            $params = array($tabid, $fieldname);
        }
        //Postgres 8 fixes
        if ($adb->isPostgres()) {
            $query = fixPostgresQuery($query, $log, 0);
        }
        $result = $adb->pquery($query, $params);
        $log->debug("Exiting getFieldVisibilityPermission method ...");
        // Returns value as a string
        if ($adb->num_rows($result) == 0) {
            return '1';
        }
        return $adb->query_result($result, "0", "visible") . "";
    }
}
示例#3
0
/**	Function used to get all the price details for different currencies which are associated to the given product
 *	@param int $productid - product id to which we want to get all the associated prices
 *  @param decimal $unit_price - Unit price of the product
 *  @param string $available - available or available_associated where as default is available, if available then the prices in the currencies which are available now will be returned, otherwise if the value is available_associated then prices of all the associated currencies will be retruned
 *	@return array $price_details - price details as a array with productid, curid, curname
 */
function getPriceDetailsForProduct($productid, $unit_price, $available = 'available', $itemtype = 'Products')
{
    global $log, $adb;
    $log->debug("Entering into function getPriceDetailsForProduct({$productid})");
    if ($productid != '') {
        $product_currency_id = getProductBaseCurrency($productid, $itemtype);
        $product_base_conv_rate = getBaseConversionRateForProduct($productid, 'edit', $itemtype);
        // Detail View
        if ($available == 'available_associated') {
            $query = "select vtiger_currency_info.*, vtiger_productcurrencyrel.converted_price, vtiger_productcurrencyrel.actual_price\n\t\t\t\t\tfrom vtiger_currency_info\n\t\t\t\t\tinner join vtiger_productcurrencyrel on vtiger_currency_info.id = vtiger_productcurrencyrel.currencyid\n\t\t\t\t\twhere vtiger_currency_info.currency_status = 'Active' and vtiger_currency_info.deleted=0\n\t\t\t\t\tand vtiger_productcurrencyrel.productid = ? and vtiger_currency_info.id != ?";
            $params = array($productid, $product_currency_id);
        } else {
            // Edit View
            $query = "select vtiger_currency_info.*, vtiger_productcurrencyrel.converted_price, vtiger_productcurrencyrel.actual_price\n\t\t\t\t\tfrom vtiger_currency_info\n\t\t\t\t\tleft join vtiger_productcurrencyrel\n\t\t\t\t\ton vtiger_currency_info.id = vtiger_productcurrencyrel.currencyid and vtiger_productcurrencyrel.productid = ?\n\t\t\t\t\twhere vtiger_currency_info.currency_status = 'Active' and vtiger_currency_info.deleted=0";
            $params = array($productid);
        }
        //Postgres 8 fixes
        if ($adb->dbType == "pgsql") {
            $query = fixPostgresQuery($query, $log, 0);
        }
        $res = $adb->pquery($query, $params);
        for ($i = 0; $i < $adb->num_rows($res); $i++) {
            $price_details[$i]['productid'] = $productid;
            $price_details[$i]['currencylabel'] = $adb->query_result($res, $i, 'currency_name');
            $price_details[$i]['currencycode'] = $adb->query_result($res, $i, 'currency_code');
            $price_details[$i]['currencysymbol'] = $adb->query_result($res, $i, 'currency_symbol');
            $currency_id = $adb->query_result($res, $i, 'id');
            $price_details[$i]['curid'] = $currency_id;
            $price_details[$i]['curname'] = 'curname' . $adb->query_result($res, $i, 'id');
            $cur_value = $adb->query_result($res, $i, 'actual_price');
            // Get the conversion rate for the given currency, get the conversion rate of the product currency to base currency.
            // Both together will be the actual conversion rate for the given currency.
            $conversion_rate = $adb->query_result($res, $i, 'conversion_rate');
            $actual_conversion_rate = $product_base_conv_rate * $conversion_rate;
            if ($cur_value == null || $cur_value == '') {
                $price_details[$i]['check_value'] = false;
                if ($unit_price != null) {
                    $cur_value = convertFromMasterCurrency($unit_price, $actual_conversion_rate);
                } else {
                    $cur_value = '0';
                }
            } else {
                $price_details[$i]['check_value'] = true;
            }
            $price_details[$i]['curvalue'] = CurrencyField::convertToUserFormat($cur_value, null, true);
            $price_details[$i]['conversionrate'] = $actual_conversion_rate;
            $is_basecurrency = false;
            if ($currency_id == $product_currency_id) {
                $is_basecurrency = true;
            }
            $price_details[$i]['is_basecurrency'] = $is_basecurrency;
        }
    } else {
        if ($available == 'available') {
            // Create View
            global $current_user;
            $user_currency_id = fetchCurrency($current_user->id);
            $query = "select vtiger_currency_info.* from vtiger_currency_info\n\t\t\t\t\twhere vtiger_currency_info.currency_status = 'Active' and vtiger_currency_info.deleted=0";
            $params = array();
            $res = $adb->pquery($query, $params);
            for ($i = 0; $i < $adb->num_rows($res); $i++) {
                $price_details[$i]['currencylabel'] = $adb->query_result($res, $i, 'currency_name');
                $price_details[$i]['currencycode'] = $adb->query_result($res, $i, 'currency_code');
                $price_details[$i]['currencysymbol'] = $adb->query_result($res, $i, 'currency_symbol');
                $currency_id = $adb->query_result($res, $i, 'id');
                $price_details[$i]['curid'] = $currency_id;
                $price_details[$i]['curname'] = 'curname' . $adb->query_result($res, $i, 'id');
                // Get the conversion rate for the given currency, get the conversion rate of the product currency(logged in user's currency) to base currency.
                // Both together will be the actual conversion rate for the given currency.
                $conversion_rate = $adb->query_result($res, $i, 'conversion_rate');
                $user_cursym_convrate = getCurrencySymbolandCRate($user_currency_id);
                $product_base_conv_rate = 1 / $user_cursym_convrate['rate'];
                $actual_conversion_rate = $product_base_conv_rate * $conversion_rate;
                $price_details[$i]['check_value'] = false;
                $price_details[$i]['curvalue'] = '0';
                $price_details[$i]['conversionrate'] = $actual_conversion_rate;
                $is_basecurrency = false;
                if ($currency_id == $user_currency_id) {
                    $is_basecurrency = true;
                }
                $price_details[$i]['is_basecurrency'] = $is_basecurrency;
            }
        } else {
            $log->debug("Product id is empty. we cannot retrieve the associated prices.");
        }
    }
    $log->debug("Exit from function getPriceDetailsForProduct({$productid})");
    return $price_details;
}
示例#4
0
function getSearchListHeaderValues($focus, $module, $sort_qry = '', $sorder = '', $order_by = '', $relatedlist = '', $oCv = '')
{
    global $log;
    $log->debug("Entering getSearchListHeaderValues(" . (is_object($focus) ? get_class($focus) : '') . "," . $module . "," . $sort_qry . "," . $sorder . "," . $order_by . "," . $relatedlist . "," . (is_object($oCV) ? get_class($oCV) : '') . ") method ...");
    global $adb;
    global $theme;
    global $app_strings;
    global $mod_strings, $current_user;
    $arrow = '';
    $qry = getURLstring($focus);
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $search_header = array();
    //Get the vtiger_tabid of the module
    //require_once('include/utils/UserInfoUtil.php')
    $tabid = getTabid($module);
    //added for vtiger_customview 27/5
    if ($oCv) {
        if (isset($oCv->list_fields)) {
            $focus->list_fields = $oCv->list_fields;
        }
    }
    //Added to reduce the no. of queries logging for non-admin vtiger_users -- by Minnie-start
    $field_list = array();
    $j = 0;
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    foreach ($focus->list_fields as $name => $tableinfo) {
        $fieldname = $focus->list_fields_name[$name];
        if ($oCv) {
            if (isset($oCv->list_fields_name)) {
                $fieldname = $oCv->list_fields_name[$name];
            }
        }
        if ($fieldname == "accountname" && $module != "Accounts") {
            $fieldname = "account_id";
        }
        if ($fieldname == "productname" && $module == "Campaigns") {
            $fieldname = "product_id";
        }
        if ($fieldname == "lastname" && $module != "Leads" && $module != "Contacts") {
            $fieldname = "contact_id";
        }
        if ($fieldname == 'folderid' && $module == 'Documents') {
            $fieldname = 'foldername';
        }
        array_push($field_list, $fieldname);
        $j++;
    }
    //Getting the Entries from Profile2 vtiger_field vtiger_table
    if ($is_admin == false) {
        $profileList = getCurrentUserProfileList();
        //changed to get vtiger_field.fieldname
        $query = "SELECT vtiger_profile2field.*,vtiger_field.fieldname FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=? AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ") AND vtiger_field.fieldname IN (" . generateQuestionMarks($field_list) . ") and vtiger_field.presence in (0,2) GROUP BY vtiger_field.fieldid";
        if ($adb->dbType == "pgsql") {
            $query = fixPostgresQuery($query, $log, 0);
        }
        $result = $adb->pquery($query, array($tabid, $profileList, $field_list));
        $field = array();
        for ($k = 0; $k < $adb->num_rows($result); $k++) {
            $field[] = $adb->query_result($result, $k, "fieldname");
        }
        //if this field array is empty and the user don't have any one of the admin, view all, edit all permissions then the search picklist options will be empty and we cannot navigate the users list - js error will thrown in function getListViewEntries_js in Smarty\templates\Popup.tpl
        if ($module == 'Users' && empty($field)) {
            $field = array("last_name", "email1");
        }
    }
    // Remove fields which are made inactive
    $focus->filterInactiveFields($module);
    //modified for vtiger_customview 27/5 - $app_strings change to $mod_strings
    foreach ($focus->list_fields as $name => $tableinfo) {
        //added for vtiger_customview 27/5
        if ($oCv) {
            if (isset($oCv->list_fields_name)) {
                if ($oCv->list_fields_name[$name] == '') {
                    $fieldname = 'crmid';
                } else {
                    $fieldname = $oCv->list_fields_name[$name];
                }
            } else {
                if ($focus->list_fields_name[$name] == '') {
                    $fieldname = 'crmid';
                } else {
                    $fieldname = $focus->list_fields_name[$name];
                }
            }
            if ($fieldname == "lastname" && $module != "Leads" && $module != "Contacts") {
                $fieldname = "contact_id";
            }
            if ($fieldname == "accountname" && $module != "Accounts") {
                $fieldname = "account_id";
            }
            if ($fieldname == "productname" && $module == "Campaigns") {
                $fieldname = "product_id";
            }
        } else {
            if ($focus->list_fields_name[$name] == '') {
                $fieldname = 'crmid';
            } else {
                $fieldname = $focus->list_fields_name[$name];
            }
            if ($fieldname == "lastname" && $module != "Leads" && $module != "Contacts") {
                $fieldname = "contact_id";
            }
        }
        if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || in_array($fieldname, $field)) {
            if ($fieldname != 'parent_id') {
                $fld_name = $fieldname;
                if ($fieldname == 'contact_id' && $module != "Contacts") {
                    $name = $app_strings['LBL_CONTACT_LAST_NAME'];
                } elseif ($fieldname == 'contact_id' && $module == "Contacts") {
                    $name = $mod_strings['Reports To'] . " - " . $mod_strings['LBL_LIST_LAST_NAME'];
                }
                //assign the translated string
                //added to fix #5205
                //Added condition to hide the close column in calendar search header
                if ($name != $app_strings['Close']) {
                    $search_header[$fld_name] = getTranslatedString($name);
                }
            }
        }
        if ($module == 'HelpDesk' && $fieldname == 'crmid') {
            $fld_name = $fieldname;
            $search_header[$fld_name] = getTranslatedString($name);
        }
    }
    $log->debug("Exiting getSearchListHeaderValues method ...");
    return $search_header;
}
示例#5
0
文件: calendarLayout.php 项目: p6/VF
/**
 * Function to get todos list scheduled between specified dates
 * @param array   $calendar              -  collection of objects and strings
 * @param string  $start_date            -  date string
 * @param string  $end_date              -  date string
 * @param string  $info                  -  string 'listcnt' or empty string. if 'listcnt' means it returns no. of todos and no. of pending todos in array format else it returns todos list in array format
 * return array   $Entries               -  todolists in array format
 */
function getTodoList(&$calendar, $start_date, $end_date, $info = '')
{
    global $log, $app_strings, $theme;
    $Entries = array();
    $category = getParentTab();
    global $adb, $current_user, $mod_strings, $cal_log, $list_max_entries_per_page;
    $cal_log->debug("Entering getTodoList() method...");
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $count_qry = "SELECT count(*) as count FROM vtiger_activity\n\t\tINNER JOIN vtiger_crmentity\n\t\tON vtiger_crmentity.crmid = vtiger_activity.activityid\n\t\tLEFT JOIN vtiger_cntactivityrel\n\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\tLEFT JOIN vtiger_groups\n\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\tLEFT JOIN vtiger_users\n\t\tON vtiger_users.id = vtiger_crmentity.smownerid\n\t\tWHERE vtiger_crmentity.deleted = 0\n\t\tAND vtiger_activity.activitytype = 'Task'\n\t\tAND (vtiger_activity.date_start BETWEEN ? AND ?) AND vtiger_crmentity.smownerid = " . $current_user->id;
    $query = "SELECT vtiger_groups.groupname, vtiger_users.user_name, vtiger_crmentity.crmid, vtiger_cntactivityrel.contactid, \n\t\t\t\tvtiger_activity.* FROM vtiger_activity\n                INNER JOIN vtiger_crmentity\n\t\t\t\t\tON vtiger_crmentity.crmid = vtiger_activity.activityid\n                LEFT JOIN vtiger_cntactivityrel\n\t\t\t\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users\n\t\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid\n                WHERE vtiger_crmentity.deleted = 0\n\t\t\t\t\tAND vtiger_activity.activitytype = 'Task'\n\t\t\t\t\tAND (vtiger_activity.date_start BETWEEN ? AND ?) AND vtiger_crmentity.smownerid = " . $current_user->id;
    $list_query = $query;
    // User Select Customization
    /*$only_for_user = calendarview_getSelectedUserId();
    	if($only_for_user != 'ALL') {
    		$query .= " AND vtiger_crmentity.smownerid = "  . $only_for_user;
    		$count_qry .= " AND vtiger_crmentity.smownerid = "  . $only_for_user;
    	}*/
    // END
    $params = $info_params = array($start_date, $end_date);
    if ($info != '') {
        //added to fix #4816
        $groupids = explode(",", fetchUserGroupids($current_user->id));
        if (count($groupids) > 0) {
            $com_q = " AND (vtiger_crmentity.smownerid = ?\n\t\t\t\t\tOR vtiger_groups.groupid in (" . generateQuestionMarks($groupids) . "))";
        } else {
            $com_q = " AND vtiger_crmentity.smownerid = ?";
        }
        //end
        $pending_query = $query . " AND (vtiger_activity.status != 'Completed')" . $com_q;
        $total_q = $query . "" . $com_q;
        array_push($info_params, $current_user->id);
        if (count($groupids) > 0) {
            array_push($info_params, $groupids);
        }
        if ($adb->dbType == "pgsql") {
            $pending_query = fixPostgresQuery($pending_query, $log, 0);
            $total_q = fixPostgresQuery($total_q, $log, 0);
        }
        $total_res = $adb->pquery($total_q, $info_params);
        $total = $adb->num_rows($total_res);
        $res = $adb->pquery($pending_query, $info_params);
        $pending_rows = $adb->num_rows($res);
        $cal_log->debug("Exiting getTodoList() method...");
        return array('totaltodo' => $total, 'pendingtodo' => $pending_rows);
    }
    if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[9] == 3) {
        $sec_parameter = getListViewSecurityParameter('Calendar');
        $query .= $sec_parameter;
        $list_query .= $sec_parameter;
        $count_qry .= $sec_parameter;
    }
    $group_cond = '';
    $count_res = $adb->pquery($count_qry, $params);
    $total_rec_count = $adb->query_result($count_res, 0, 'count');
    $group_cond .= " ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC";
    if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
        $start = vtlib_purify($_REQUEST['start']);
    } else {
        $start = 1;
    }
    $navigation_array = getNavigationValues($start, $total_rec_count, $list_max_entries_per_page);
    $start_rec = $navigation_array['start'];
    $end_rec = $navigation_array['end_val'];
    if ($start_rec <= 1) {
        $start_rec = 0;
    } else {
        $start_rec = $start_rec - 1;
    }
    $query .= $group_cond . " limit {$start_rec},{$list_max_entries_per_page}";
    $list_query .= $group_cond;
    if ($adb->dbType == "pgsql") {
        $query = fixPostgresQuery($query, $log, 0);
        $list_query = fixPostgresQuery($list_query, $log, 0);
    }
    $list_query = $adb->convert2Sql($list_query, $params);
    $_SESSION['Calendar_listquery'] = $list_query;
    $result = $adb->pquery($query, $params);
    $rows = $adb->num_rows($result);
    $c = 0;
    if ($start > 1) {
        $c = ($start - 1) * $list_max_entries_per_page;
    }
    for ($i = 0; $i < $rows; $i++) {
        $element = array();
        $contact_name = '';
        $element['no'] = $c + 1;
        $more_link = "";
        $start_time = $adb->query_result($result, $i, "time_start");
        $format = $calendar['calendar']->hour_format;
        $value = getaddEventPopupTime($start_time, $start_time, $format);
        $element['starttime'] = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt'];
        $date_start = $adb->query_result($result, $i, "date_start");
        $due_date = $adb->query_result($result, $i, "due_date");
        if ($calendar['view'] != 'day') {
            $element['startdate'] = getDisplayDate($date_start);
        }
        $element['duedate'] = getDisplayDate($due_date);
        $id = $adb->query_result($result, $i, "activityid");
        $subject = $adb->query_result($result, $i, "subject");
        //CHANGE : TO IMPROVE PERFORMANCE
        /*$contact_id = $adb->query_result($result,$i,"contactid");
        		if($contact_id!='')
        		{
        			$contact_name = getContactName($contact_id);
        		}*/
        $more_link = "<a href='index.php?action=DetailView&module=Calendar&record=" . $id . "&activity_mode=Task&viewtype=calendar&parenttab=" . $category . "' class='webMnu'>" . $subject . "</a>";
        $element['tododetail'] = $more_link;
        /*if(getFieldVisibilityPermission('Calendar',$current_user->id,'parent_id') == '0')
        		{
        			$element['task_relatedto'] = getRelatedTo('Calendar',$result,$i);
        		}
        		if(getFieldVisibilityPermission('Calendar',$current_user->id,'contact_id') == '0')
        		{
        			$element['task_contact'] = "<a href=\"index.php?module=Contacts&action=DetailView&record=".$contact_id."\">".$contact_name."</a>";
        		}*/
        if (getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') {
            $taskstatus = $adb->query_result($result, $i, "status");
            if (!$is_admin && $taskstatus != '') {
                $roleid = $current_user->roleid;
                $roleids = array();
                $subrole = getRoleSubordinates($roleid);
                if (count($subrole) > 0) {
                    $roleids = $subrole;
                }
                array_push($roleids, $roleid);
                //here we are checking wheather the table contains the sortorder column .If  sortorder is present in the main picklist table, then the role2picklist will be applicable for this table...
                $sql = "select * from vtiger_taskstatus where taskstatus=?";
                $res = $adb->pquery($sql, array(decode_html($taskstatus)));
                $picklistvalueid = $adb->query_result($res, 0, 'picklist_valueid');
                if ($picklistvalueid != null) {
                    $pick_query = "select * from vtiger_role2picklist where picklistvalueid={$picklistvalueid} and roleid in (" . generateQuestionMarks($roleids) . ")";
                    $res_val = $adb->pquery($pick_query, array($roleids));
                    $num_val = $adb->num_rows($res_val);
                }
                if ($num_val > 0) {
                    $element['status'] = getTranslatedString(decode_html($taskstatus));
                } else {
                    $element['status'] = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                }
            } else {
                $element['status'] = getTranslatedString(decode_html($taskstatus));
            }
        }
        if (isPermitted("Calendar", "EditView") == "yes" || isPermitted("Calendar", "Delete") == "yes") {
            $element['action'] = "<img onClick='getcalAction(this,\"taskcalAction\"," . $id . ",\"" . $calendar['view'] . "\",\"" . $calendar['calendar']->date_time->hour . "\",\"" . $calendar['calendar']->date_time->get_formatted_date() . "\",\"todo\");' src='" . vtiger_imageurl('cal_event.jpg', $theme) . "' border='0'>";
        }
        $assignedto = $adb->query_result($result, $i, "user_name");
        if (!empty($assignedto)) {
            $element['assignedto'] = $assignedto;
        } else {
            $element['assignedto'] = $adb->query_result($result, $i, "groupname");
        }
        $c++;
        $Entries[] = $element;
    }
    $ret_arr[0] = $Entries;
    $ret_arr[1] = $navigation_array;
    $cal_log->debug("Exiting getTodoList() method...");
    return $ret_arr;
}
示例#6
0
        die("Record Id is not found, cannot merge the document");
    }
}
//<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>>
global $current_user;
require 'user_privileges/user_privileges_' . $current_user->id . '.php';
if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == "Users" || $module == "Emails") {
    $query1 = "select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (13,4,6) and vtiger_field.uitype <> 61 and block <> 75 and block <> 30 and vtiger_field.presence in (0,2) order by vtiger_field.tablename";
    $params1 = array();
} else {
    $profileList = getCurrentUserProfileList();
    $query1 = "select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid in (13,4,6) and vtiger_field.uitype <> 61 and block <> 75 and block <> 30 AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ") and vtiger_field.presence in (0,2) GROUP BY vtiger_field.fieldid order by vtiger_field.tablename";
    $params1 = array($profileList);
    //Postgres 8 fixes
    if ($adb->dbType == "pgsql") {
        $query1 = fixPostgresQuery($query1, $log, 0);
    }
}
$result = $adb->pquery($query1, $params1);
$y = $adb->num_rows($result);
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
$contactUserNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'usersContacts.first_name', 'last_name' => 'usersContacts.last_name'), 'Users');
$accountUserNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'usersAccounts.first_name', 'last_name' => 'usersAccounts.last_name'), 'Users');
for ($x = 0; $x < $y; $x++) {
    $tablename = $adb->query_result($result, $x, "tablename");
    $columnname = $adb->query_result($result, $x, "columnname");
    $modulename = $adb->query_result($result, $x, "name");
    $column_name = $tablename . "." . $columnname;
    if ($columnname == "parent_id") {
        $column_name = "case crmentityRelHelpDesk.setype when 'Accounts' then accountRelHelpDesk.accountname when 'Contacts' then concat(contactdetailsRelHelpDesk.firstname,' ',contactdetailsRelHelpDesk.lastname) End";
    }
示例#7
0
        if ($adb->dbType == "pgsql") {
            $query .= ' GROUP BY user_name';
        }
        $query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('Accounts', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
//Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $query = fixPostgresQuery($query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
    $noofrows = null;
}
$queryMode = isset($_REQUEST['query']) && $_REQUEST['query'] == 'true';
$start = ListViewSession::getRequestCurrentPage($currentModule, $query, $viewid, $queryMode);
$navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
$limit_start_rec = ($start - 1) * $list_max_entries_per_page;
if ($adb->dbType == "pgsql") {
    $list_result = $adb->pquery($query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array());
} else {
    $list_result = $adb->pquery($query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
示例#8
0
/**
 * This function is used to get the Quick create form vtiger_field parameters for a given module.
 * Param $module - module name
 * returns the value in array format
 */
function QuickCreate($module)
{
    global $log;
    $log->debug("Entering QuickCreate(" . $module . ") method ...");
    global $adb;
    global $current_user;
    global $mod_strings;
    $tabid = getTabid($module);
    //Adding Security Check
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
        $quickcreate_query = "select * from vtiger_field where quickcreate in (0,2) and tabid = ? and vtiger_field.presence in (0,2) and displaytype != 2 order by quickcreatesequence";
        $params = array($tabid);
    } else {
        $profileList = getCurrentUserProfileList();
        $quickcreate_query = "SELECT vtiger_field.* FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=? AND quickcreate in (0,2) AND vtiger_profile2field.visible=0 AND vtiger_profile2field.readonly = 0 AND vtiger_def_org_field.visible=0  AND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ") and vtiger_field.presence in (0,2) and displaytype != 2 GROUP BY vtiger_field.fieldid ORDER BY quickcreatesequence";
        $params = array($tabid, $profileList);
        //Postgres 8 fixes
        if ($adb->dbType == "pgsql") {
            $quickcreate_query = fixPostgresQuery($quickcreate_query, $log, 0);
        }
    }
    $category = getParentTab();
    $result = $adb->pquery($quickcreate_query, $params);
    $noofrows = $adb->num_rows($result);
    $fieldName_array = array();
    for ($i = 0; $i < $noofrows; $i++) {
        $fieldtablename = $adb->query_result($result, $i, 'tablename');
        $uitype = $adb->query_result($result, $i, "uitype");
        $fieldname = $adb->query_result($result, $i, "fieldname");
        $fieldlabel = $adb->query_result($result, $i, "fieldlabel");
        $maxlength = $adb->query_result($result, $i, "maximumlength");
        $generatedtype = $adb->query_result($result, $i, "generatedtype");
        $typeofdata = $adb->query_result($result, $i, "typeofdata");
        $defaultvalue = $adb->query_result($result, $i, "defaultvalue");
        $col_fields[$fieldname] = $defaultvalue;
        //to get validationdata
        $fldLabel_array = array();
        $fldLabel_array[getTranslatedString($fieldlabel)] = $typeofdata;
        $fieldName_array[$fieldname] = $fldLabel_array;
        // These fields should not be shown in the UI as they are already shown as part of other fields, but are required for validation.
        if ($fieldname == 'time_start' || $fieldname == 'time_end') {
            continue;
        }
        $custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module, '', $typeofdata);
        $qcreate_arr[] = $custfld;
    }
    for ($i = 0, $j = 0; $i < count($qcreate_arr); $i = $i + 2, $j++) {
        $key1 = $qcreate_arr[$i];
        if (is_array($qcreate_arr[$i + 1])) {
            $key2 = $qcreate_arr[$i + 1];
        } else {
            $key2 = array();
        }
        $return_data[$j] = array(0 => $key1, 1 => $key2);
    }
    $form_data['form'] = $return_data;
    $form_data['data'] = $fieldName_array;
    $log->debug("Exiting QuickCreate method ..." . print_r($form_data, true));
    return $form_data;
}
/**
 * Function to get todos list scheduled between specified dates
 * @param array   $calendar              -  collection of objects and strings
 * @param string  $start_date            -  date string
 * @param string  $end_date              -  date string
 * @param string  $info                  -  string 'listcnt' or empty string. if 'listcnt' means it returns no. of todos and no. of pending todos in array format else it returns todos list in array format
 * return array   $Entries               -  todolists in array format
 */
function getTodoList(&$calendar, $start_date, $end_date, $info = '')
{
    global $log, $app_strings, $theme;
    $Entries = array();
    $category = getParentTab();
    global $adb, $current_user, $mod_strings, $cal_log, $list_max_entries_per_page;
    $cal_log->debug("Entering getTodoList() method...");
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $userNameSql = getSqlForNameInDisplayFormat(array('f' => 'vtiger_users.first_name', 'l' => 'vtiger_users.last_name'));
    $query = "SELECT vtiger_groups.groupname, {$userNameSql} as user_name, vtiger_crmentity.crmid, vtiger_cntactivityrel.contactid,\n\t\t\t\tvtiger_activity.* FROM vtiger_activity\n                INNER JOIN vtiger_crmentity\n\t\t\t\t\tON vtiger_crmentity.crmid = vtiger_activity.activityid\n                LEFT JOIN vtiger_cntactivityrel\n\t\t\t\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users\n\t\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid";
    $query .= getNonAdminAccessControlQuery('Calendar', $current_user);
    $query .= "WHERE vtiger_crmentity.deleted = 0 AND vtiger_activity.activitytype = 'Task'" . " AND ((CAST(CONCAT(date_start,' ',time_start) AS DATETIME) >= ? AND CAST(CONCAT(date_start,' ',time_start) AS DATETIME) <= ?)\n\t\t\t\t\t\t\tOR\t(CAST(CONCAT(due_date,' ',time_end) AS DATETIME) >= ? AND CAST(CONCAT(due_date,' ',time_end) AS DATETIME) <= ? )\n\t\t\t\t\t\t\tOR\t(CAST(CONCAT(date_start,' ',time_start) AS DATETIME) <= ? AND CAST(CONCAT(due_date,' ',time_end) AS DATETIME) >= ?)\n\t\t\t\t\t\t)";
    $list_query = $query . " AND vtiger_crmentity.smownerid = " . $current_user->id;
    $startDate = new DateTimeField($start_date . ' 00:00');
    $endDate = new DateTimeField($end_date . ' 23:59');
    $params = $info_params = array($startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue(), $startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue(), $startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue());
    if ($info != '') {
        //added to fix #4816
        $groupids = explode(",", fetchUserGroupids($current_user->id));
        if (count($groupids) > 0 && !is_admin($current_user)) {
            $com_q = " AND (vtiger_crmentity.smownerid = ?\n\t\t\t\t\tOR vtiger_groups.groupid in (" . generateQuestionMarks($groupids) . "))";
            array_push($info_params, $current_user->id);
            array_push($info_params, $groupids);
        } elseif (!is_admin($current_user)) {
            $com_q = " AND vtiger_crmentity.smownerid = ?";
            array_push($info_params, $current_user->id);
        }
        //end
        $pending_query = $query . " AND (vtiger_activity.status != 'Completed')" . $com_q;
        $total_q = $query . "" . $com_q;
        if ($adb->dbType == "pgsql") {
            $pending_query = fixPostgresQuery($pending_query, $log, 0);
            $total_q = fixPostgresQuery($total_q, $log, 0);
        }
        $total_res = $adb->pquery($total_q, $info_params);
        $total = $adb->num_rows($total_res);
        $res = $adb->pquery($pending_query, $info_params);
        $pending_rows = $adb->num_rows($res);
        $cal_log->debug("Exiting getTodoList() method...");
        return array('totaltodo' => $total, 'pendingtodo' => $pending_rows);
    }
    $group_cond = '';
    $group_cond .= " ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC";
    if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
        $start = vtlib_purify($_REQUEST['start']);
    } else {
        $start = 1;
    }
    //T6477 changes
    if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
        $count_res = $adb->pquery(mkCountQuery($query), $params);
        $total_rec_count = $adb->query_result($count_res, 0, 'count');
    } else {
        $total_rec_count = null;
    }
    $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $total_rec_count);
    $start_rec = ($start - 1) * $list_max_entries_per_page;
    $end_rec = $navigation_array['end_val'];
    $list_query = $adb->convert2Sql($query, $params);
    $_SESSION['Calendar_listquery'] = $list_query;
    if ($start_rec < 0) {
        $start_rec = 0;
    }
    //ends
    $query .= $group_cond . " limit {$start_rec},{$list_max_entries_per_page}";
    if ($adb->dbType == "pgsql") {
        $query = fixPostgresQuery($query, $log, 0);
    }
    $result = $adb->pquery($query, $params);
    $rows = $adb->num_rows($result);
    $c = 0;
    if ($start > 1) {
        $c = ($start - 1) * $list_max_entries_per_page;
    }
    for ($i = 0; $i < $rows; $i++) {
        $element = array();
        $contact_name = '';
        $element['no'] = $c + 1;
        $more_link = "";
        $start_time = $adb->query_result($result, $i, "time_start");
        $date_start = $adb->query_result($result, $i, "date_start");
        $due_date = $adb->query_result($result, $i, "due_date");
        $date = new DateTimeField($date_start . ' ' . $start_time);
        $endDate = new DateTimeField($due_date);
        if (!empty($start_time)) {
            $start_time = $date->getDisplayTime();
        }
        $format = $calendar['calendar']->hour_format;
        $value = getaddEventPopupTime($start_time, $start_time, $format);
        $element['starttime'] = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt'];
        $element['startdate'] = $date->getDisplayDate();
        $element['duedate'] = $endDate->getDisplayDate();
        $id = $adb->query_result($result, $i, "activityid");
        $subject = $adb->query_result($result, $i, "subject");
        $more_link = "<a href='index.php?action=DetailView&module=Calendar&record=" . $id . "&activity_mode=Task&viewtype=calendar&parenttab=" . $category . "' class='webMnu'>" . $subject . "</a>";
        $element['tododetail'] = $more_link;
        if (getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') {
            $taskstatus = $adb->query_result($result, $i, "status");
            if (!$is_admin && $taskstatus != '') {
                $roleid = $current_user->roleid;
                $roleids = array();
                $subrole = getRoleSubordinates($roleid);
                if (count($subrole) > 0) {
                    $roleids = $subrole;
                }
                array_push($roleids, $roleid);
                //here we are checking wheather the table contains the sortorder column .If  sortorder is present in the main picklist table, then the role2picklist will be applicable for this table...
                $sql = "select * from vtiger_taskstatus where taskstatus=?";
                $res = $adb->pquery($sql, array(decode_html($taskstatus)));
                $picklistvalueid = $adb->query_result($res, 0, 'picklist_valueid');
                if ($picklistvalueid != null) {
                    $pick_query = "select * from vtiger_role2picklist where picklistvalueid={$picklistvalueid} and roleid in (" . generateQuestionMarks($roleids) . ")";
                    $res_val = $adb->pquery($pick_query, array($roleids));
                    $num_val = $adb->num_rows($res_val);
                }
                if ($num_val > 0) {
                    $element['status'] = getTranslatedString(decode_html($taskstatus));
                } else {
                    $element['status'] = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                }
            } else {
                $element['status'] = getTranslatedString(decode_html($taskstatus));
            }
        }
        if (isPermitted("Calendar", "EditView") == "yes" || isPermitted("Calendar", "Delete") == "yes") {
            $element['action'] = "<img onClick='getcalAction(this,\"taskcalAction\"," . $id . ",\"" . $calendar['view'] . "\",\"" . $calendar['calendar']->date_time->hour . "\",\"" . $calendar['calendar']->date_time->get_DB_formatted_date() . "\",\"todo\");' src='" . vtiger_imageurl('cal_event.jpg', $theme) . "' border='0'>";
        }
        $assignedto = $adb->query_result($result, $i, "user_name");
        if (!empty($assignedto)) {
            $element['assignedto'] = $assignedto;
        } else {
            $element['assignedto'] = $adb->query_result($result, $i, "groupname");
        }
        $c++;
        $Entries[] = $element;
    }
    $ret_arr[0] = $Entries;
    $ret_arr[1] = $navigation_array;
    $cal_log->debug("Exiting getTodoList() method...");
    return $ret_arr;
}
示例#10
0
 function getBlocksPortal1($module, $disp_view, $mode, $col_fields = '', $info_type = '', $profile)
 {
     global $log;
     $log->debug("Entering getBlocks(" . $module . "," . $disp_view . "," . $mode . "," . $col_fields . "," . $info_type . ") method ...");
     global $adb, $current_user;
     global $mod_strings;
     $tabid = getTabid($module);
     $block_detail = array();
     $getBlockinfo = "";
     $query = "select blockid,blocklabel,show_title,display_status from vtiger_blocks where tabid=? and {$disp_view}=0 and visible = 0 order by sequence";
     $result = $adb->pquery($query, array($tabid));
     $noofrows = $adb->num_rows($result);
     $prev_header = "";
     $blockid_list = array();
     for ($i = 0; $i < $noofrows; $i++) {
         $blockid = $adb->query_result($result, $i, "blockid");
         array_push($blockid_list, $blockid);
         $block_label[$blockid] = $adb->query_result($result, $i, "blocklabel");
         $sLabelVal = getTranslatedString($block_label[$blockid], $module);
         $aBlockStatus[$sLabelVal] = $adb->query_result($result, $i, "display_status");
     }
     if ($mode == 'edit') {
         $display_type_check = 'vtiger_field.displaytype = 1';
     } elseif ($mode == 'mass_edit') {
         $display_type_check = 'vtiger_field.displaytype = 1 AND vtiger_field.masseditable NOT IN (0,2)';
     } else {
         $display_type_check = 'vtiger_field.displaytype in (1,4)';
     }
     /* if($non_mass_edit_fields!='' && sizeof($non_mass_edit_fields)!=0){
     	  $mass_edit_query = "AND vtiger_field.fieldname NOT IN (". generateQuestionMarks($non_mass_edit_fields) .")";
     	  } */
     //retreive the vtiger_profileList from database
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     if ($disp_view == "detail_view") {
         $profileList = array($profile);
         $sql = "SELECT vtiger_field.*, vtiger_profile2field.readonly FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid WHERE vtiger_field.tabid=? AND vtiger_field.block IN (" . generateQuestionMarks($blockid_list) . ") AND vtiger_field.displaytype IN (1,2,4) and vtiger_field.presence in (0,2) AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ") GROUP BY vtiger_field.fieldid ORDER BY block,sequence";
         $params = array($tabid, $blockid_list, $profileList);
         //Postgres 8 fixes
         if ($adb->dbType == "pgsql") {
             $sql = fixPostgresQuery($sql, $log, 0);
         }
         $result = $adb->pquery($sql, $params);
         // Added to unset the previous record's related listview session values
         if (isset($_SESSION['rlvs'])) {
             unset($_SESSION['rlvs']);
         }
         $getBlockInfo = getDetailBlockInformation($module, $result, $col_fields, $tabid, $block_label);
     } else {
         if ($info_type != '') {
             $profileList = array($profile);
             $sql = "SELECT vtiger_field.* FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid  WHERE vtiger_field.tabid=? AND vtiger_field.block IN (" . generateQuestionMarks($blockid_list) . ") AND {$display_type_check} AND info_type = ? AND vtiger_profile2field.visible=0 AND vtiger_profile2field.readonly = 0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ") and vtiger_field.presence in (0,2) GROUP BY vtiger_field.fieldid ORDER BY block,sequence";
             $params = array($tabid, $blockid_list, $info_type, $profileList);
             //Postgres 8 fixes
             if ($adb->dbType == "pgsql") {
                 $sql = fixPostgresQuery($sql, $log, 0);
             }
         } else {
             $profileList = array("{$profile}");
             $sql = "SELECT vtiger_field.* FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid  WHERE vtiger_field.tabid=? AND vtiger_field.block IN (" . generateQuestionMarks($blockid_list) . ") AND {$display_type_check} AND vtiger_profile2field.visible=0 AND vtiger_profile2field.readonly = 0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ") and vtiger_field.presence in (0,2) GROUP BY vtiger_field.fieldid ORDER BY block,sequence";
             $params = array($tabid, $blockid_list, $profileList);
             //Postgres 8 fixes
             if ($adb->dbType == "pgsql") {
                 $sql = fixPostgresQuery($sql, $log, 0);
             }
         }
         $result = $adb->pquery($sql, $params);
         $getBlockInfo = getBlockInformation($module, $result, $col_fields, $tabid, $block_label, $mode);
     }
     $log->debug("Exiting getBlocks method ...");
     if (count($getBlockInfo) > 0) {
         foreach ($getBlockInfo as $label => $contents) {
             if (empty($getBlockInfo[$label])) {
                 unset($getBlockInfo[$label]);
             }
         }
     }
     return $getBlockInfo;
 }