debug("Entering getListViewHeader(" . $module . "," . $sort_qry . "," . $sorder . "," . $order_by . "," . $relatedlist . "," . (is_object($oCv) ? get_class($oCv) : $oCv) . ") method ...");
global $adb;
global $theme;
global $app_strings;
global $mod_strings;
global $counter;
$arrow = '';
$qry = getURLstring($focus);
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$list_header = Array();
//Get the vtiger_tabid of the module
$tabid = getTabid($module);
$tabname = getParentTab();
global $current_user;
//added for vtiger_customview 27/5
if ($oCv) {
if (isset($oCv->list_fields)) {
$focus->list_fields = $oCv->list_fields;
}
}
// Remove fields which are made inactive
$focus->filterInactiveFields($module);
//Added to reduce the no. of queries logging for non-admin user -- 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 == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar' )) {
$fieldname = 'contact_id';
}
if ($fieldname == 'productname' && $module != 'Products') {
$fieldname = 'product_id';
}
array_push($field_list, $fieldname);
$j++;
}
$field = Array();
if ($is_admin == false) {
if ($module == 'Emails') {
$query = "SELECT fieldname FROM vtiger_field WHERE tabid = ? and vtiger_field.presence in (0,2)";
$params = array($tabid);
} else {
$profileList = getCurrentUserProfileList();
$params = array();
$query = "SELECT DISTINCT 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";
if ($module == "Calendar") {
$query .=" WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)";
} else {
$query .=" WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)";
array_push($params, $tabid);
}
$query.=" 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) . ")";
array_push($params, $profileList, $field_list);
}
$result = $adb->pquery($query, $params);
for ($k = 0; $k < $adb->num_rows($result); $k++) {
$field[] = $adb->query_result($result, $k, "fieldname");
}
}
//end
//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)) {
$fieldname = $oCv->list_fields_name[$name];
if ($fieldname == 'accountname' && $module != 'Accounts') {
$fieldname = 'account_id';
}
if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) {
$fieldname = 'contact_id';
}
if ($fieldname == 'productname' && $module != 'Products') {
$fieldname = 'product_id';
}
} else {
$fieldname = $focus->list_fields_name[$name];
}
} else {
$fieldname = $focus->list_fields_name[$name];
if ($fieldname == 'accountname' && $module != 'Accounts') {
$fieldname = 'account_id';
}
if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) {
$fieldname = 'contact_id';
}
if ($fieldname == 'productname' && $module != 'Products') {
$fieldname = 'product_id';
}
}
if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || in_array($fieldname, $field) || $fieldname == '' || ($name == 'Close' && $module == 'Calendar')) {
if (isset($focus->sortby_fields) && $focus->sortby_fields != '') {
//Added on 14-12-2005 to avoid if and else check for every list vtiger_field for arrow image and change order
$change_sorder = array('ASC' => 'DESC', 'DESC' => 'ASC');
$arrow_gif = array('ASC' => 'arrow_down.gif', 'DESC' => 'arrow_up.gif');
foreach ($focus->list_fields[$name] as $tab => $col) {
if (in_array($col, $focus->sortby_fields)) {
if ($order_by == $col) {
$temp_sorder = $change_sorder[$sorder];
$arrow = " ";
} else {
$temp_sorder = 'ASC';
}
$lbl_name = getTranslatedString(decode_html($name), $module);
//added to display vtiger_currency symbol in listview header
if ($lbl_name == 'Amount') {
$lbl_name .=' (' . $app_strings['LBL_IN'] . ' ' . $user_info['currency_symbol'] . ')';
}
if ($relatedlist != '' && $relatedlist != 'global') {
$relationURL = '';
if (!empty($_REQUEST['relation_id'])) {
$relationURL = '&relation_id=' . vtlib_purify(
$_REQUEST['relation_id']);
}
$actionsURL = '';
if (!empty($_REQUEST['actions'])) {
$actionsURL = '&actions=' . vtlib_purify($_REQUEST['actions']);
}
if (empty($_REQUEST['header'])) {
$moduleLabel = getTranslatedString($module, $module);
} else {
$moduleLabel = $_REQUEST['header'];
}
$moduleLabel = str_replace(' ', '', $moduleLabel);
$name = "" . $lbl_name . "" . $arrow . "";
} elseif ($module == 'Users' && $name == 'User Name')
$name = "" . getTranslatedString('LBL_LIST_USER_NAME_ROLE', $module) . "" . $arrow . "";
elseif ($relatedlist == "global")
$name = $lbl_name;
else
$name = "" . $lbl_name . "" . $arrow . "";
$arrow = '';
}
else {
if (stripos($col, 'cf_') === 0) {
$tablenameArray = array_keys($tableinfo, $col);
$tablename = $tablenameArray[0];
$cf_columns = $adb->getColumnNames($tablename);
if (array_search($col, $cf_columns) != null) {
$pquery = "select fieldlabel,typeofdata from vtiger_field where tablename = ? and fieldname = ? and vtiger_field.presence in (0,2)";
$cf_res = $adb->pquery($pquery, array($tablename, $col));
if (count($cf_res) > 0) {
$cf_fld_label = $adb->query_result($cf_res, 0, "fieldlabel");
$typeofdata = explode("~", $adb->query_result($cf_res, 0, "typeofdata"));
$new_field_label = $tablename . ":" . $col . ":" . $col . ":" . $module . "_" . str_replace(" ", "_", $cf_fld_label) . ":" . $typeofdata[0];
$name = $cf_fld_label;
// Update the existing field name in the database with new field name.
$upd_query = "update vtiger_cvcolumnlist set columnname = ? where columnname like '" . $tablename . ":" . $col . ":" . $col . "%'";
$upd_params = array($new_field_label);
$adb->pquery($upd_query, $upd_params);
}
}
} else {
$name = getTranslatedString($name, $module);
}
}
}
}
//added to display vtiger_currency symbol in related listview header
if ($name == 'Amount' && $relatedlist != '') {
$name .=' (' . $app_strings['LBL_IN'] . ' ' . $user_info['currency_symbol'] . ')';
}
if ($module == "Calendar" && $name == $app_strings['Close']) {
if (isPermitted("Calendar", "EditView") == 'yes') {
if ((getFieldVisibilityPermission('Events', $current_user->id, 'eventstatus') == '0') || (getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0')) {
array_push($list_header, $name);
}
}
} else {
$list_header[] = $name;
}
}
}
//Added for Action - edit and delete link header in listview
if (!$skipActions && (isPermitted($module, "EditView", "") == 'yes' || isPermitted($module, "Delete", "") == 'yes'))
$list_header[] = $app_strings["LBL_ACTION"];
$log->debug("Exiting getListViewHeader method ...");
return $list_header;
}
/* * This function is used to get the list view header in popup
* Param $focus - module object
* Param $module - module name
* Param $sort_qry - sort by value
* Param $sorder - sorting order (asc/desc)
* Param $order_by - order by
* Returns the listview header values in an array
*/
function getSearchListViewHeader($focus, $module, $sort_qry = '', $sorder = '', $order_by = '') {
global $log;
$log->debug("Entering getSearchListViewHeader(" . get_class($focus) . "," . $module . "," . $sort_qry . "," . $sorder . "," . $order_by . ") method ...");
global $adb;
global $theme;
global $app_strings;
global $mod_strings, $current_user;
$arrow = '';
$list_header = Array();
$tabid = getTabid($module);
if (isset($_REQUEST['task_relmod_id'])) {
$task_relmod_id = vtlib_purify($_REQUEST['task_relmod_id']);
$pass_url .="&task_relmod_id=" . $task_relmod_id;
}
if (isset($_REQUEST['relmod_id'])) {
$relmod_id = vtlib_purify($_REQUEST['relmod_id']);
$pass_url .="&relmod_id=" . $relmod_id;
}
if (isset($_REQUEST['task_parent_module'])) {
$task_parent_module = vtlib_purify($_REQUEST['task_parent_module']);
$pass_url .="&task_parent_module=" . $task_parent_module;
}
if (isset($_REQUEST['parent_module'])) {
$parent_module = vtlib_purify($_REQUEST['parent_module']);
$pass_url .="&parent_module=" . $parent_module;
}
if (isset($_REQUEST['fromPotential']) && (isset($_REQUEST['acc_id']) && $_REQUEST['acc_id'] != '')) {
$pass_url .="&parent_module=Accounts&relmod_id=" . vtlib_purify($_REQUEST['acc_id']);
}
// vtlib Customization : For uitype 10 popup during paging
if ($_REQUEST['form'] == 'vtlibPopupView') {
$pass_url .= '&form=vtlibPopupView&forfield=' . vtlib_purify($_REQUEST['forfield']) . '&srcmodule=' . vtlib_purify($_REQUEST['srcmodule']) . '&forrecord=' . vtlib_purify($_REQUEST['forrecord']);
}
// END
//Added to reduce the no. of queries logging for non-admin user -- by Minnie-start
$field_list = array();
$j = 0;
require('user_privileges/user_privileges_' . $current_user->id . '.php');
foreach ($focus->search_fields as $name => $tableinfo) {
$fieldname = $focus->search_fields_name[$name];
array_push($field_list, $fieldname);
$j++;
}
$field = Array();
if ($is_admin == false && $module != 'Users') {
if ($module == 'Emails') {
$query = "SELECT fieldname FROM vtiger_field WHERE tabid = ? and vtiger_field.presence in (0,2)";
$params = array($tabid);
} else {
$profileList = getCurrentUserProfileList();
$query = "SELECT DISTINCT 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)";
$params = array($tabid, $profileList, $field_list);
}
$result = $adb->pquery($query, $params);
for ($k = 0; $k < $adb->num_rows($result); $k++) {
$field[] = $adb->query_result($result, $k, "fieldname");
}
}
//end
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$focus->filterInactiveFields($module);
foreach ($focus->search_fields as $name => $tableinfo) {
$fieldname = $focus->search_fields_name[$name];
$tabid = getTabid($module);
global $current_user;
require('user_privileges/user_privileges_' . $current_user->id . '.php');
if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || in_array($fieldname, $field) || $module == 'Users') {
if (isset($focus->sortby_fields) && $focus->sortby_fields != '') {
foreach ($focus->search_fields[$name] as $tab => $col) {
if (in_array($col, $focus->sortby_fields)) {
if ($order_by == $col) {
if ($sorder == 'ASC') {
$sorder = "DESC";
$arrow = "";
} else {
$sorder = 'ASC';
$arrow = "";
}
}
// vtlib customization: If translation is not available use the given name
$tr_name = getTranslatedString($name, $module);
$name = "" . $tr_name . " " . $arrow . "";
// END
$arrow = '';
} else {
// vtlib customization: If translation is not available use the given name
$tr_name = getTranslatedString($name, $module);
$name = $tr_name;
// END
}
}
}
$list_header[] = $name;
}
}
$log->debug("Exiting getSearchListViewHeader method ...");
return $list_header;
}
/* * This function generates the navigation array in a listview
* Param $display - start value of the navigation
* Param $noofrows - no of records
* Param $limit - no of entries per page
* Returns an array type
*/
//code contributed by raju for improved pagination
function getNavigationValues($display, $noofrows, $limit) {
global $log;
$log->debug("Entering getNavigationValues(" . $display . "," . $noofrows . "," . $limit . ") method ...");
$navigation_array = Array();
global $limitpage_navigation;
if (isset($_REQUEST['allflag']) && $_REQUEST['allflag'] == 'All') {
$navigation_array['start'] = 1;
$navigation_array['first'] = 1;
$navigation_array['end'] = 1;
$navigation_array['prev'] = 0;
$navigation_array['next'] = 0;
$navigation_array['end_val'] = $noofrows;
$navigation_array['current'] = 1;
$navigation_array['allflag'] = 'Normal';
$navigation_array['verylast'] = 1;
$log->debug("Exiting getNavigationValues method ...");
return $navigation_array;
}
if ($noofrows != 0) {
if (((($display * $limit) - $limit) + 1) > $noofrows) {
$display = floor($noofrows / $limit);
}
$start = ((($display * $limit) - $limit) + 1);
} else {
$start = 0;
}
$end = $start + ($limit - 1);
if ($end > $noofrows) {
$end = $noofrows;
}
$paging = ceil($noofrows / $limit);
// Display the navigation
if ($display > 1) {
$previous = $display - 1;
} else {
$previous = 0;
}
if ($noofrows < $limit) {
$first = '';
} elseif ($noofrows != $limit) {
$last = $paging;
$first = 1;
if ($paging > $limitpage_navigation) {
$first = $display - floor(($limitpage_navigation / 2));
if ($first < 1)
$first = 1;
$last = ($limitpage_navigation - 1) + $first;
}
if ($last > $paging) {
$first = $paging - ($limitpage_navigation - 1);
$last = $paging;
}
}
if ($display < $paging) {
$next = $display + 1;
} else {
$next = 0;
}
$navigation_array['start'] = $start;
$navigation_array['first'] = $first;
$navigation_array['end'] = $last;
$navigation_array['prev'] = $previous;
$navigation_array['next'] = $next;
$navigation_array['end_val'] = $end;
$navigation_array['current'] = $display;
$navigation_array['allflag'] = 'All';
$navigation_array['verylast'] = $paging;
$log->debug("Exiting getNavigationValues method ...");
return $navigation_array;
}
//End of code contributed by raju for improved pagination
/* * This function generates the List view entries in a list view
* Param $focus - module object
* Param $list_result - resultset of a listview query
* Param $navigation_array - navigation values in an array
* Param $relatedlist - check for related list flag
* Param $returnset - list query parameters in url string
* Param $edit_action - Edit action value
* Param $del_action - delete action value
* Param $oCv - vtiger_customview object
* Returns an array type
*/
//parameter added for vtiger_customview $oCv 27/5
function getListViewEntries($focus, $module, $list_result, $navigation_array, $relatedlist = '', $returnset = '', $edit_action = 'EditView', $del_action = 'Delete', $oCv = '', $page = '', $selectedfields = '', $contRelatedfields = '', $skipActions = false) {
global $log;
global $mod_strings;
$log->debug("Entering getListViewEntries(" . get_class($focus) . "," . $module . "," . $list_result . "," . $navigation_array . "," . $relatedlist . "," . $returnset . "," . $edit_action . "," . $del_action . "," . (is_object($oCv) ? get_class($oCv) : $oCv) . ") method ...");
$tabname = getParentTab();
global $adb, $current_user;
global $app_strings;
$noofrows = $adb->num_rows($list_result);
$list_block = Array();
global $theme;
$evt_status = '';
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
//getting the vtiger_fieldtable entries from database
$tabid = getTabid($module);
//added for vtiger_customview 27/5
if ($oCv) {
if (isset($oCv->list_fields)) {
$focus->list_fields = $oCv->list_fields;
}
}
if (is_array($selectedfields) && $selectedfields != '') {
$focus->list_fields = $selectedfields;
}
// Remove fields which are made inactive
$focus->filterInactiveFields($module);
//Added to reduce the no. of queries logging for non-admin user -- 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 == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar'))
$fieldname = 'contact_id';
if ($fieldname == 'productname' && $module != 'Products') {
$fieldname = 'product_id';
}
array_push($field_list, $fieldname);
$j++;
}
$field = Array();
if ($is_admin == false) {
if ($module == 'Emails') {
$query = "SELECT fieldname FROM vtiger_field WHERE tabid = ? and vtiger_field.presence in (0,2)";
$params = array($tabid);
} else {
$profileList = getCurrentUserProfileList();
$params = array();
$query = "SELECT DISTINCT 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";
if ($module == "Calendar")
$query .=" WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)";
else {
$query .=" WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)";
array_push($params, $tabid);
}
$query .=" AND vtiger_profile2field.visible = 0
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) . ")";
array_push($params, $profileList, $field_list);
}
$result = $adb->pquery($query, $params);
for ($k = 0; $k < $adb->num_rows($result); $k++) {
$field[] = $adb->query_result($result, $k, "fieldname");
}
}
//constructing the uitype and columnname array
$ui_col_array = Array();
$params = array();
$query = "SELECT uitype, columnname, fieldname FROM vtiger_field ";
if ($module == "Calendar")
$query .=" WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)";
else {
$query .=" WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)";
array_push($params, $tabid);
}
$query .= " AND fieldname IN (" . generateQuestionMarks($field_list) . ") ";
array_push($params, $field_list);
$result = $adb->pquery($query, $params);
$num_rows = $adb->num_rows($result);
for ($i = 0; $i < $num_rows; $i++) {
$tempArr = array();
$uitype = $adb->query_result($result, $i, 'uitype');
$columnname = $adb->query_result($result, $i, 'columnname');
$field_name = $adb->query_result($result, $i, 'fieldname');
$tempArr[$uitype] = $columnname;
$ui_col_array[$field_name] = $tempArr;
}
//end
if ($navigation_array['start'] != 0)
for ($i = 1; $i <= $noofrows; $i++) {
$list_header = Array();
//Getting the entityid
if ($module != 'Users') {
$entity_id = $adb->query_result($list_result, $i - 1, "crmid");
$owner_id = $adb->query_result($list_result, $i - 1, "smownerid");
} else {
$entity_id = $adb->query_result($list_result, $i - 1, "id");
}
// Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
// begin: Armando Lüscher 05.07.2005 -> §priority
// Code contri buted by fredy Desc: Set Priority color
$priority = $adb->query_result($list_result, $i - 1, "priority");
$font_color_high = "color:#00DD00;";
$font_color_medium = "color:#DD00DD;";
$P_FONT_COLOR = "";
switch ($priority) {
case 'High':
$P_FONT_COLOR = $font_color_high;
break;
case 'Medium':
$P_FONT_COLOR = $font_color_medium;
break;
default:
$P_FONT_COLOR = "";
}
//end: Armando Lüscher 05.07.2005 -> §priority
foreach ($focus->list_fields as $name => $tableinfo) {
$fieldname = $focus->list_fields_name[$name];
//added for vtiger_customview 27/5
if ($oCv) {
if (isset($oCv->list_fields_name)) {
$fieldname = $oCv->list_fields_name[$name];
if ($fieldname == 'accountname' && $module != 'Accounts') {
$fieldname = 'account_id';
}
if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar' )) {
$fieldname = 'contact_id';
}
if ($fieldname == 'productname' && $module != 'Products') {
$fieldname = 'product_id';
}
} else {
$fieldname = $focus->list_fields_name[$name];
}
} else {
$fieldname = $focus->list_fields_name[$name];
if ($fieldname == 'accountname' && $module != 'Accounts') {
$fieldname = 'account_id';
}
if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) {
$fieldname = 'contact_id';
}
if ($fieldname == 'productname' && $module != 'Products') {
$fieldname = 'product_id';
}
}
if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || in_array($fieldname, $field) || $fieldname == '' || ($name == 'Close' && $module == 'Calendar')) {
if ($fieldname == '') {
$table_name = '';
$column_name = '';
foreach ($tableinfo as $tablename => $colname) {
$table_name = $tablename;
$column_name = $colname;
}
$value = $adb->query_result($list_result, $i - 1, $colname);
} else {
if ($module == 'Calendar') {
$act_id = $adb->query_result($list_result, $i - 1, "activityid");
$activitytype = $adb->query_result($list_result, $i - 1, 'activitytype');
if (empty($activitytype)) {
$cal_sql = "select activitytype from vtiger_activity where activityid=?";
$cal_res = $adb->pquery($cal_sql, array($act_id));
if ($adb->num_rows($cal_res) >= 0)
$activitytype = $adb->query_result($cal_res, 0, "activitytype");
}
}
if (($module == 'Calendar' || $module == 'Emails' || $module == 'HelpDesk' || $module == 'Invoice' || $module == 'Leads' || $module == 'Contacts') && (($fieldname == 'parent_id') || ($name == 'Contact Name') || ($name == 'Close') || ($fieldname == 'firstname'))) {
if ($module == 'Calendar') {
if ($fieldname == 'status') {
if ($activitytype == 'Task') {
$fieldname = 'taskstatus';
} else {
$fieldname = 'eventstatus';
}
}
if ($activitytype == 'Task') {
if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') {
$has_permission = 'yes';
} else {
$has_permission = 'no';
}
} else {
if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') {
$has_permission = 'yes';
} else {
$has_permission = 'no';
}
}
}
if ($module != 'Calendar' || ($module == 'Calendar' && $has_permission == 'yes')) {
if ($fieldname == 'parent_id') {
$value = getRelatedTo($module, $list_result, $i - 1);
}
if ($name == 'Contact Name') {
$contact_id = $adb->query_result($list_result, $i - 1, "contactid");
$contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts");
$value = "";
//Added to get the contactname for activities custom view - t=2190
if ($contact_id != '' && !empty($contact_name)) {
$displayValueArray = getEntityName('Contacts', $contact_id);
if (!empty($displayValueArray)) {
foreach ($displayValueArray as $key => $field_value) {
$contact_name = $field_value;
}
}
}
if (($contact_name != "") && ($contact_id != 'NULL')) {
// Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
$value = "" . textlength_check($contact_name) . ""; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR"
}
}
if ($fieldname == "firstname") {
$first_name = textlength_check($adb->query_result($list_result, $i - 1, "firstname"));
$value = '' . $first_name . '';
}
if ($name == 'Close') {
$status = $adb->query_result($list_result, $i - 1, "status");
$activityid = $adb->query_result($list_result, $i - 1, "activityid");
if (empty($activityid)) {
$activityid = $adb->query_result($list_result, $i - 1, "tmp_activity_id");
}
if ($activitytype != 'Task' && $activitytype != 'Emails') {
$eventstatus = $adb->query_result($list_result, $i - 1, "eventstatus");
if (isset($eventstatus)) {
$status = $eventstatus;
}
}
if ($status == 'Deferred' || $status == 'Completed' || $status == 'Held' || $status == '') {
$value = "";
} else {
if ($activitytype == 'Task')
$evt_status = '&status=Completed';
else
$evt_status = '&eventstatus=Held';
if (isPermitted("Calendar", 'EditView', $activityid) == 'yes') {
if ($returnset == '') {
$returnset = '&return_module=Calendar&return_action=ListView&return_id=' . $activityid . '&return_viewname=' . $oCv->setdefaultviewid;
}
// Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
$value = "X"; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR"
} else {
$value = "";
}
}
}
} else {
$value = "";
}
} elseif ($module == "Documents" && ($fieldname == 'filelocationtype' || $fieldname == 'filename' || $fieldname == 'filesize' || $fieldname == 'filestatus' || $fieldname == 'filetype')) {
$value = $adb->query_result($list_result, $i - 1, $fieldname);
if ($fieldname == 'filelocationtype') {
if ($value == 'I')
$value = getTranslatedString('LBL_INTERNAL', $module);
elseif ($value == 'E')
$value = getTranslatedString('LBL_EXTERNAL', $module);
else
$value = ' --';
}
if ($fieldname == 'filename') {
$downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype');
if ($downloadtype == 'I') {
$fld_value = $value;
$ext_pos = strrpos($fld_value, ".");
$ext = substr($fld_value, $ext_pos + 1);
$ext = strtolower($ext);
if ($value != '') {
if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm')
$fileicon = "";
elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp')
$fileicon = "";
elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls')
$fileicon = "";
elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar')
$fileicon = "";
else
$fileicon = "";
}
} elseif ($downloadtype == 'E') {
if (trim($value) != '') {
$fld_value = $value;
$fileicon = "";
} else {
$fld_value = '--';
$fileicon = '';
}
} else {
$fld_value = ' --';
$fileicon = '';
}
$file_name = $adb->query_result($list_result, $i - 1, 'filename');
$notes_id = $adb->query_result($list_result, $i - 1, 'crmid');
$folder_id = $adb->query_result($list_result, $i - 1, 'folderid');
$download_type = $adb->query_result($list_result, $i - 1, 'filelocationtype');
$file_status = $adb->query_result($list_result, $i - 1, 'filestatus');
$fileidQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?";
$fileidres = $adb->pquery($fileidQuery, array($notes_id));
$fileid = $adb->query_result($fileidres, 0, 'attachmentsid');
if ($file_name != '' && $file_status == 1) {
if ($download_type == 'I') {
$fld_value = "" . textlength_check($fld_value) . "";
} elseif ($download_type == 'E') {
$fld_value = "" . textlength_check($fld_value) . "";
} else {
$fld_value = ' --';
}
}
$value = $fileicon . $fld_value;
}
if ($fieldname == 'filesize') {
$downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype');
if ($downloadtype == 'I') {
$filesize = $value;
if ($filesize < 1024)
$value = $filesize . ' B';
elseif ($filesize > 1024 && $filesize < 1048576)
$value = round($filesize / 1024, 2) . ' KB';
else if ($filesize > 1048576)
$value = round($filesize / (1024 * 1024), 2) . ' MB';
} else {
$value = ' --';
}
}
if ($fieldname == 'filestatus') {
$filestatus = $value;
if ($filestatus == 1)
$value = getTranslatedString('yes', $module);
elseif ($filestatus == 0)
$value = getTranslatedString('no', $module);
else
$value = ' --';
}
if ($fieldname == 'filetype') {
$downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype');
$filetype = $adb->query_result($list_result, $i - 1, 'filetype');
if ($downloadtype == 'E' || $downloadtype != 'I') {
$value = ' --';
} else
$value = $filetype;
}
if ($fieldname == 'notecontent') {
$value = decode_html($value);
$value = textlength_check($value);
}
} elseif ($module == "Products" && $name == "Related to") {
$value = getRelatedTo($module, $list_result, $i - 1);
$value = textlength_check($value);
} elseif ($name == 'Contact Name' && ($module == 'SalesOrder' || $module == 'Quotes' || $module == 'PurchaseOrder')) {
if ($name == 'Contact Name') {
$contact_id = $adb->query_result($list_result, $i - 1, "contactid");
$contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts");
$value = "";
if (($contact_name != "") && ($contact_id != 'NULL'))
$value = "" . textlength_check($contact_name) . "";
}
} elseif ($name == 'Product') {
$product_id = textlength_check($adb->query_result($list_result, $i - 1, "productname"));
$value = $product_id;
} elseif ($name == 'Account Name') {
//modified for vtiger_customview 27/5
if ($module == 'Accounts') {
$account_id = $adb->query_result($list_result, $i - 1, "crmid");
//$account_name = getAccountName($account_id);
$account_name = textlength_check($adb->query_result($list_result, $i - 1, "accountname"));
// Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
$value = '' . $account_name . ''; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR"
} elseif ($module == 'Potentials' || $module == 'Contacts' || $module == 'Invoice' || $module == 'SalesOrder' || $module == 'Quotes') { //Potential,Contacts,Invoice,SalesOrder & Quotes records sort by Account Name
$accountname = textlength_check($adb->query_result($list_result, $i - 1, "accountname"));
$accountid = $adb->query_result($list_result, $i - 1, "accountid");
if (empty($accountname))
$accountname = getAccountName($accountid);
$value = '' . $accountname . '';
} else {
$account_id = $adb->query_result($list_result, $i - 1, "accountid");
$account_name = getAccountName($account_id);
$acc_name = textlength_check($account_name);
// Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
$value = '' . $acc_name . ''; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR"
}
} elseif (( $module == 'HelpDesk' || $module == 'PriceBook' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'Faq') && $name == 'Product Name') {
if ($module == 'HelpDesk' || $module == 'Faq')
$product_id = $adb->query_result($list_result, $i - 1, "product_id");
else
$product_id = $adb->query_result($list_result, $i - 1, "productid");
if ($product_id != '')
$product_name = getProductName($product_id);
else
$product_name = '';
$value = '' . textlength_check($product_name) . '';
} elseif (($module == 'Quotes' && $name == 'Potential Name') || ($module == 'SalesOrder' && $name == 'Potential Name')) {
$potential_id = $adb->query_result($list_result, $i - 1, "potentialid");
$potential_name = getPotentialName($potential_id);
$value = '' . textlength_check($potential_name) . '';
} elseif ($module == 'Emails' && $relatedlist != '' && ($name == 'Subject' || $name == 'Date Sent' || $name == 'To')) {
$list_result_count = $i - 1;
$tmp_value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid);
$value = '' . textlength_check($tmp_value) . '';
if ($name == 'Date Sent') {
$sql = "select email_flag from vtiger_emaildetails where emailid=?";
$result = $adb->pquery($sql, array($entity_id));
$email_flag = $adb->query_result($result, 0, "email_flag");
if ($email_flag != 'SAVED')
$value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid);
else
$value = '';
}
} elseif ($module == 'Calendar' && ($fieldname != 'taskstatus' && $fieldname != 'eventstatus')) {
if ($activitytype == 'Task') {
if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') {
$list_result_count = $i - 1;
$value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid);
} else {
$value = '';
}
} else {
if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') {
$list_result_count = $i - 1;
$value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid);
} else {
$value = '';
}
}
} else {
$list_result_count = $i - 1;
$value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid);
}
}
// vtlib customization: For listview javascript triggers
$value = "$value ";
// END
if ($module == "Calendar" && $name == $app_strings['Close']) {
if (isPermitted("Calendar", "EditView") == 'yes') {
if ((getFieldVisibilityPermission('Events', $current_user->id, 'eventstatus') == '0') || (getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0')) {
array_push($list_header, $value);
}
}
}
else
$list_header[] = $value;
}
}
$varreturnset = '';
if ($returnset == '')
$varreturnset = '&return_module=' . $module . '&return_action=index';
else
$varreturnset = $returnset;
if ($module == 'Calendar') {
$actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype');
if ($actvity_type == 'Task')
$varreturnset .= '&activity_mode=Task';
else
$varreturnset .= '&activity_mode=Events';
}
//Added for Actions ie., edit and delete links in listview
$links_info = "";
if (!(is_array($selectedfields) && $selectedfields != '')) {
if (isPermitted($module, "EditView", "") == 'yes') {
$edit_link = getListViewEditLink($module, $entity_id, $relatedlist, $varreturnset, $list_result, $list_result_count);
if (isset($_REQUEST['start']) && $_REQUEST['start'] > 1 && $module != 'Emails')
$links_info .= "" . $app_strings["LNK_EDIT"] . " ";
else
$links_info .= "" . $app_strings["LNK_EDIT"] . " ";
}
if (isPermitted($module, "Delete", "") == 'yes') {
$del_link = getListViewDeleteLink($module, $entity_id, $relatedlist, $varreturnset);
if ($links_info != "" && $del_link != "")
$links_info .= " | ";
if ($del_link != "")
$links_info .= "" . $app_strings["LNK_DELETE"] . "";
}
}
// Record Change Notification
if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) {
if (!$focus->isViewed($entity_id)) {
$links_info .= " | ";
}
}
// END
if ($links_info != "" && !$skipActions)
$list_header[] = $links_info;
$list_block[$entity_id] = $list_header;
}
$log->debug("Exiting getListViewEntries method ...");
return $list_block;
}
/* * This function generates the List view entries in a popup list view
* Param $focus - module object
* Param $list_result - resultset of a listview query
* Param $navigation_array - navigation values in an array
* Param $relatedlist - check for related list flag
* Param $returnset - list query parameters in url string
* Param $edit_action - Edit action value
* Param $del_action - delete action value
* Param $oCv - vtiger_customview object
* Returns an array type
*/
function getSearchListViewEntries($focus, $module, $list_result, $navigation_array, $form = '') {
global $log;
$log->debug("Entering getSearchListViewEntries(" . get_class($focus) . "," . $module . "," . $list_result . "," . $navigation_array . ") method ...");
global $adb, $app_strings, $theme, $current_user, $list_max_entries_per_page;
$noofrows = $adb->num_rows($list_result);
$list_header = '';
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$list_block = Array();
//getting the vtiger_fieldtable entries from database
$tabid = getTabid($module);
require('user_privileges/user_privileges_' . $current_user->id . '.php');
//Added to reduce the no. of queries logging for non-admin user -- by Minnie-start
$field_list = array();
$j = 0;
foreach ($focus->search_fields as $name => $tableinfo) {
$fieldname = $focus->search_fields_name[$name];
array_push($field_list, $fieldname);
$j++;
}
$field = Array();
if ($is_admin == false && $module != 'Users') {
if ($module == 'Emails') {
$query = "SELECT fieldname FROM vtiger_field WHERE tabid = ? and vtiger_field.presence in (0,2)";
$params = array($tabid);
} else {
$profileList = getCurrentUserProfileList();
$query = "SELECT DISTINCT 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)";
$params = array($tabid, $profileList, $field_list);
}
$result = $adb->pquery($query, $params);
for ($k = 0; $k < $adb->num_rows($result); $k++) {
$field[] = $adb->query_result($result, $k, "fieldname");
}
}
//constructing the uitype and columnname array
$ui_col_array = Array();
$query = "SELECT uitype, columnname, fieldname
FROM vtiger_field
WHERE tabid=?
AND fieldname IN (" . generateQuestionMarks($field_list) . ") and vtiger_field.presence in (0,2)";
$result = $adb->pquery($query, array($tabid, $field_list));
$num_rows = $adb->num_rows($result);
for ($i = 0; $i < $num_rows; $i++) {
$tempArr = array();
$uitype = $adb->query_result($result, $i, 'uitype');
$columnname = $adb->query_result($result, $i, 'columnname');
$field_name = $adb->query_result($result, $i, 'fieldname');
$tempArr[$uitype] = $columnname;
$ui_col_array[$field_name] = $tempArr;
}
//end
if ($navigation_array['end_val'] > 0) {
for ($i = 1; $i <= $noofrows; $i++) {
//Getting the entityid
if ($module != 'Users') {
$entity_id = $adb->query_result($list_result, $i - 1, "crmid");
} else {
$entity_id = $adb->query_result($list_result, $i - 1, "id");
}
$list_header = Array();
foreach ($focus->search_fields as $name => $tableinfo) {
$fieldname = $focus->search_fields_name[$name];
if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || in_array($fieldname, $field) || $module == 'Users') {
if ($fieldname == '') {
$table_name = '';
$column_name = '';
foreach ($tableinfo as $tablename => $colname) {
$table_name = $tablename;
$column_name = $colname;
}
$value = $adb->query_result($list_result, $i - 1, $colname);
} else {
if (($module == 'Calls' || $module == 'Tasks' || $module == 'Meetings' || $module == 'Emails') && (($name == 'Related to') || ($name == 'Contact Name') || ($name == 'Vendor Name'))) {
if ($name == 'Related to')
$value = getRelatedTo($module, $list_result, $i - 1);
if ($name == 'Contact Name') {
$contact_id = $adb->query_result($list_result, $i - 1, "contactid");
$contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts");
$value = "";
if (($contact_name != "") && ($contact_id != 'NULL'))
$value = "" . $contact_name . "";
}
}
elseif (($module == 'Faq' || $module == 'Documents') && $name == 'Related to') {
$value = getRelatedToEntity($module, $list_result, $i - 1);
} elseif ($name == 'Account Name' && ($module == 'Potentials' || $module == 'SalesOrder' || $module == 'Quotes')) {
$account_id = $adb->query_result($list_result, $i - 1, "accountid");
$account_name = getAccountName($account_id);
$value = textlength_check($account_name);
} elseif ($name == 'Quote Name' && $module == 'SalesOrder') {
$quote_id = $adb->query_result($list_result, $i - 1, "quoteid");
$quotename = getQuoteName($quote_id);
$value = textlength_check($quotename);
} elseif ($name == 'Account Name' && $module == 'Contacts') {
$account_id = $adb->query_result($list_result, $i - 1, "accountid");
$account_name = getAccountName($account_id);
$value = textlength_check($account_name);
}
// vtlib customization: Generic popup handling
elseif (isset($focus->popup_fields) && in_array($fieldname, $focus->popup_fields)) {
global $default_charset;
$forfield = htmlspecialchars($_REQUEST['forfield'], ENT_QUOTES, $default_charset);
$list_result_count = $i - 1;
$value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "search", $focus->popup_type);
if (isset($forfield) && $forfield != '' && $focus->popup_type != 'detailview') {
$value1 = strip_tags($value);
$value = htmlspecialchars(addslashes(html_entity_decode(strip_tags($value), ENT_QUOTES, $default_charset)), ENT_QUOTES, $default_charset); // Remove any previous html conversion
$count = counterValue();
$value = "$value1";
}
}
// END
else {
$list_result_count = $i - 1;
$value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "search", $focus->popup_type, $form);
}
}
$list_header[] = $value;
}
}
if ($module == 'Products' && ($focus->popup_type == 'inventory_prod' || $focus->popup_type == 'inventory_prod_po')) {
global $default_charset;
require('user_privileges/user_privileges_' . $current_user->id . '.php');
$row_id = $_REQUEST['curr_row'];
//To get all the tax types and values and pass it to product details
$tax_str = '';
$tax_details = getAllTaxes();
for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
$tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ',';
}
$tax_str = trim($tax_str, ',');
$rate = $user_info['conv_rate'];
if (getFieldVisibilityPermission($module, $current_user->id, 'unit_price') == '0') {
$unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price');
if ($_REQUEST['currencyid'] != null) {
$prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id));
$unitprice = $prod_prices[$entity_id];
}
} else {
$unitprice = '';
}
$sub_products = '';
$sub_prod = '';
$sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id));
for ($k = 0; $k < $adb->num_rows($sub_prod_query); $k++) {
//$sub_prod=array();
$id = $adb->query_result($sub_prod_query, $k, "productid");
$str_sep = '';
if ($k > 0)
$str_sep = ":";
$sub_products .= $str_sep . $id;
$sub_prod .= $str_sep . " - " . $adb->query_result($sub_prod_query, $k, "productname");
}
$sub_det = $sub_products . "::" . str_replace(":", "
", $sub_prod);
$qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock');
$slashes_temp_val = popup_from_html(getProductName($entity_id));
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$description = $adb->query_result($list_result, $list_result_count, 'description');
$slashes_desc = htmlspecialchars($description, ENT_QUOTES, $default_charset);
$sub_products_link = ' Sub Products';
if (!isset($_REQUEST['record_id'])) {
$sub_products_query = $adb->pquery("SELECT * from vtiger_seproductsrel WHERE productid=? AND setype='Products'", array($entity_id));
if ($adb->num_rows($sub_products_query) > 0)
$list_header[] = $sub_products_link;
else
$list_header[] = $app_strings['LBL_NO_SUB_PRODUCTS'];
}
}
if ($module == 'Services' && $focus->popup_type == 'inventory_service') {
global $default_charset;
require('user_privileges/user_privileges_' . $current_user->id . '.php');
$row_id = $_REQUEST['curr_row'];
//To get all the tax types and values and pass it to product details
$tax_str = '';
$tax_details = getAllTaxes();
for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
$tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ',';
}
$tax_str = trim($tax_str, ',');
$rate = $user_info['conv_rate'];
if (getFieldVisibilityPermission($module, $current_user->id, 'unit_price') == '0') {
$unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price');
if ($_REQUEST['currencyid'] != null) {
$prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module);
$unitprice = $prod_prices[$entity_id];
}
} else {
$unitprice = '';
}
$slashes_temp_val = popup_from_html($adb->query_result($list_result, $list_result_count, 'servicename'));
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$description = $adb->query_result($list_result, $list_result_count, 'description');
$slashes_desc = htmlspecialchars($description, ENT_QUOTES, $default_charset);
}
$list_block[$entity_id] = $list_header;
}
}
$list = $list_block;
$log->debug("Exiting getSearchListViewEntries method ...");
return $list;
}
/* * This function generates the value for a given vtiger_field namee
* Param $field_result - vtiger_field result in array
* Param $list_result - resultset of a listview query
* Param $fieldname - vtiger_field name
* Param $focus - module object
* Param $module - module name
* Param $entity_id - entity id
* Param $list_result_count - list result count
* Param $mode - mode type
* Param $popuptype - popup type
* Param $returnset - list query parameters in url string
* Param $viewid - custom view id
* Returns an string value
*/
function getValue($field_result, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, $mode, $popuptype, $returnset = '', $viewid = '') {
global $log, $listview_max_textlength, $app_strings, $current_language, $currentModule;
$log->debug("Entering getValue(" . $field_result . "," . $list_result . "," . $fieldname . "," . get_class($focus) . "," . $module . "," . $entity_id . "," . $list_result_count . "," . $mode . "," . $popuptype . "," . $returnset . "," . $viewid . ") method ...");
global $adb, $current_user, $default_charset;
require('user_privileges/user_privileges_' . $current_user->id . '.php');
$tabname = getParentTab();
$tabid = getTabid($module);
$current_module_strings = return_module_language($current_language, $module);
$uicolarr = $field_result[$fieldname];
foreach ($uicolarr as $key => $value) {
$uitype = $key;
$colname = $value;
}
//added for getting event status in Custom view - Jaguar
if ($module == 'Calendar' && ($colname == "status" || $colname == "eventstatus")) {
$colname = "activitystatus";
}
//Ends
$field_val = $adb->query_result($list_result, $list_result_count, $colname);
if ($uitype != 8) {
$temp_val = html_entity_decode($field_val, ENT_QUOTES, $default_charset);
} else {
$temp_val = $field_val;
}
// vtlib customization: New uitype to handle relation between modules
if ($uitype == '10') {
$parent_id = $field_val;
if (!empty($parent_id)) {
$parent_module = getSalesEntityType($parent_id);
$valueTitle = $parent_module;
if ($app_strings[$valueTitle])
$valueTitle = $app_strings[$valueTitle];
$displayValueArray = getEntityName($parent_module, $parent_id);
if (!empty($displayValueArray)) {
foreach ($displayValueArray as $key => $value) {
$value = $value;
}
}
$value = "" . textlength_check($value) . "";
} else {
$value = '';
}
} // END
else if ($uitype == 53) {
$value = $adb->query_result($list_result, $list_result_count, 'user_name');
// When Assigned To field is used in Popup window
if ($value == '') {
$user_id = $adb->query_result($list_result, $list_result_count, 'smownerid');
if ($user_id != null && $user_id != '') {
$value = getOwnerName($user_id);
$value = textlength_check($value);
}
}
} elseif ($uitype == 52) {
$value = getOwnerName($adb->query_result($list_result, $list_result_count, $colname));
$value = textlength_check($value);
} elseif ($uitype == 51) {//Accounts - Member Of
$parentid = $adb->query_result($list_result, $list_result_count, "parentid");
if ($module == 'Accounts')
$entity_name = textlength_check(getAccountName($parentid));
elseif ($module == 'Products')
$entity_name = textlength_check(getProductName($parentid));
$value = '' . $entity_name . '';
}
elseif ($uitype == 77) {
$value = getOwnerName($adb->query_result($list_result, $list_result_count, 'inventorymanager'));
$value = textlength_check($value);
} elseif ($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) {
$temp_val = trim($temp_val);
$timeField = 'time_start';
if ($fieldname == 'due_date') {
$timeField = 'time_end';
}
if ($temp_val != '' && $module == 'Calendar' && ($uitype == 23 || $uitype == 6) &&
$timeField != '' && ($fieldname == 'date_start' || $fieldname == 'due_date' )) {
$time = $adb->query_result($list_result, $list_result_count, $timeField);
if (empty($time)) {
$time = getSingleFieldValue('vtiger_activity', $timeField, 'activityid', $entity_id);
}
}
if ($temp_val == '0000-00-00' || empty($temp_val)) {
$value = '';
} else {
if (empty($time) && strpos($temp_val, ' ') == false) {
$value = DateTimeField::convertToUserFormat($temp_val);
} else {
if (!empty($time)) {
$date = new DateTimeField($temp_val . ' ' . $time);
$value = $date->getDisplayDate();
} else {
$date = new DateTimeField($temp_val);
$value = $date->getDisplayDateTimeValue();
}
}
}
} elseif ($uitype == 15 || ($uitype == 55 && $fieldname == "salutationtype")) {
$temp_val = decode_html($adb->query_result($list_result, $list_result_count, $colname));
if (($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) && $temp_val != '') {
$temp_acttype = $adb->query_result($list_result, $list_result_count, 'activitytype');
if (($temp_acttype != 'Task') && $fieldname == "taskstatus")
$temptable = "eventstatus";
else
$temptable = $fieldname;
$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_$temptable where $temptable=?";
$res = $adb->pquery($sql, array(decode_html($temp_val)));
$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 || ($temp_acttype == 'Task' && $fieldname == 'activitytype'))
$temp_val = $temp_val;
else
$temp_val = "" . $app_strings['LBL_NOT_ACCESSIBLE'] . "";
}
$value = ($current_module_strings[$temp_val] != '') ? $current_module_strings[$temp_val] : (($app_strings[$temp_val] != '') ? ($app_strings[$temp_val]) : $temp_val);
if ($value != "" . $app_strings['LBL_NOT_ACCESSIBLE'] . "") {
$value = textlength_check($value);
}
} elseif ($uitype == 16) {
$value = getTranslatedString($temp_val, $currentModule);
$value = textlength_check($value);
} elseif ($uitype == 71 || $uitype == 72) {
if ($temp_val != '') {
// Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
if ($uitype == 72) {
if ($fieldname == 'unit_price') {
$currency_id = getProductBaseCurrency($entity_id, $module);
$cursym_convrate = getCurrencySymbolandCRate($currency_id);
$currency_symbol = $cursym_convrate['symbol'];
} else {
$currency_info = getInventoryCurrencyInfo($module, $entity_id);
$currency_symbol = $currency_info['currency_symbol'];
}
$currencyValue = CurrencyField::convertToUserFormat($temp_val, null, true);
$value = CurrencyField::appendCurrencySymbol($currencyValue, $currency_symbol);
} else {
//changes made to remove vtiger_currency symbol infront of each vtiger_potential amount
if ($temp_val != 0)
$value = CurrencyField::convertToUserFormat($temp_val);
else
$value = $temp_val;
}
}
else {
$value = '';
}
} elseif ($uitype == 17) {
$matchPattern = "^[\w]+:\/\/^";
preg_match($matchPattern, $field_val, $matches);
if (!empty($matches[0])) {
$value = '' . textlength_check($temp_val) . '';
} else {
$value = '' . textlength_check($temp_val) . '';
}
} elseif ($uitype == 13 || $uitype == 104 && ($_REQUEST['action'] != 'Popup' && $_REQUEST['file'] != 'Popup')) {
if ($_SESSION['internal_mailer'] == 1) {
//check added for email link in user detailview
if ($module == 'Calendar') {
if (getActivityType($entity_id) == 'Task') {
$tabid = 9;
} else {
$tabid = 16;
}
} else {
$tabid = getTabid($module);
}
$fieldid = getFieldid($tabid, $fieldname);
if (empty($popuptype)) {
$value = '' . textlength_check($temp_val) . '';
} else {
$value = $temp_val;
$value = textlength_check($value);
}
}
else
$value = '' . textlength_check($temp_val) . '';
}
elseif ($uitype == 56) {
if ($temp_val == 1) {
$value = $app_strings['yes'];
} elseif ($temp_val == 0) {
$value = $app_strings['no'];
} else {
$value = '';
}
} elseif ($uitype == 57) {
if ($temp_val != '') {
$sql = "SELECT * FROM vtiger_contactdetails WHERE contactid=?";
$result = $adb->pquery($sql, array($temp_val));
$value = '';
if ($adb->num_rows($result)) {
$name = getFullNameFromQResult($result, 0, "Contacts");
$value = '' . textlength_check($name) . '';
}
}
else
$value = '';
}
//Added by Minnie to get Campaign Source
elseif ($uitype == 58) {
if ($temp_val != '') {
$sql = "SELECT * FROM vtiger_campaign WHERE campaignid=?";
$result = $adb->pquery($sql, array($temp_val));
$campaignname = $adb->query_result($result, 0, "campaignname");
$value = '' . textlength_check($campaignname) . '';
}
else
$value = '';
}
//End
//Added By *Raj* for the Issue ProductName not displayed in CustomView of HelpDesk
elseif ($uitype == 59) {
if ($temp_val != '') {
$value = getProductName($temp_val);
} else {
$value = '';
}
}
//End
elseif ($uitype == 61) {
$attachmentid = $adb->query_result($adb->pquery("SELECT * FROM vtiger_seattachmentsrel WHERE crmid = ?", array($entity_id)), 0, 'attachmentsid');
$value = '' . textlength_check($temp_val) . '';
} elseif ($uitype == 62) {
$parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
$parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
if ($parenttype == "Leads") {
$tablename = "vtiger_leaddetails";
$fieldname = "lastname";
$idname = "leadid";
}
if ($parenttype == "Accounts") {
$tablename = "vtiger_account";
$fieldname = "accountname";
$idname = "accountid";
}
if ($parenttype == "Products") {
$tablename = "vtiger_products";
$fieldname = "productname";
$idname = "productid";
}
if ($parenttype == "HelpDesk") {
$tablename = "vtiger_troubletickets";
$fieldname = "title";
$idname = "ticketid";
}
if ($parenttype == "Invoice") {
$tablename = "vtiger_invoice";
$fieldname = "subject";
$idname = "invoiceid";
}
if ($parentid != '') {
$sql = "SELECT * FROM $tablename WHERE $idname = ?";
$fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
$value = '' . textlength_check($fieldvalue) . '';
}
else
$value = '';
}
elseif ($uitype == 66) {
$parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
$parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
if ($parenttype == "Leads") {
$tablename = "vtiger_leaddetails";
$fieldname = "lastname";
$idname = "leadid";
}
if ($parenttype == "Accounts") {
$tablename = "vtiger_account";
$fieldname = "accountname";
$idname = "accountid";
}
if ($parenttype == "HelpDesk") {
$tablename = "vtiger_troubletickets";
$fieldname = "title";
$idname = "ticketid";
}
if ($parentid != '') {
$sql = "SELECT * FROM $tablename WHERE $idname = ?";
$fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
$value = '' . textlength_check($fieldvalue) . '';
}
else
$value = '';
}
elseif ($uitype == 67) {
$parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
$parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
if ($parenttype == "Leads") {
$tablename = "vtiger_leaddetails";
$fieldname = "lastname";
$idname = "leadid";
}
if ($parenttype == "Contacts") {
$tablename = "vtiger_contactdetails";
$fieldname = "contactname";
$idname = "contactid";
}
if ($parentid != '') {
$sql = "SELECT * FROM $tablename WHERE $idname = ?";
$fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
$value = '' . textlength_check($fieldvalue) . '';
}
else
$value = '';
}
elseif ($uitype == 68) {
$parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
$parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
if ($parenttype == '' && $parentid != '')
$parenttype = getSalesEntityType($parentid);
if ($parenttype == "Contacts") {
$tablename = "vtiger_contactdetails";
$fieldname = "contactname";
$idname = "contactid";
}
if ($parenttype == "Accounts") {
$tablename = "vtiger_account";
$fieldname = "accountname";
$idname = "accountid";
}
if ($parentid != '') {
$sql = "SELECT * FROM $tablename WHERE $idname = ?";
$fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
$value = '' . textlength_check($fieldvalue) . '';
}
else
$value = '';
}
elseif ($uitype == 78) {
if ($temp_val != '') {
$quote_name = getQuoteName($temp_val);
$value = '' . textlength_check($quote_name) . '';
}
else
$value = '';
}
elseif ($uitype == 79) {
if ($temp_val != '') {
$purchaseorder_name = getPoName($temp_val);
$value = '' . textlength_check($purchaseorder_name) . '';
}
else
$value = '';
}
elseif ($uitype == 80) {
if ($temp_val != '') {
$salesorder_name = getSoName($temp_val);
$value = "" . textlength_check($salesorder_name) . '';
}
else
$value = '';
}
elseif ($uitype == 75 || $uitype == 81) {
if ($temp_val != '') {
$vendor_name = getVendorName($temp_val);
$value = '' . textlength_check($vendor_name) . '';
}
else
$value = '';
}
elseif ($uitype == 98) {
$value = '' . textlength_check(getRoleName($temp_val)) . '';
} elseif ($uitype == 33) {
$value = ($temp_val != "") ? str_ireplace(' |##| ', ', ', $temp_val) : "";
if (!$is_admin && $value != '') {
$value = ($field_val != "") ? str_ireplace(' |##| ', ', ', $field_val) : "";
if ($value != '') {
$value_arr = explode(',', trim($value));
$roleid = $current_user->roleid;
$subrole = getRoleSubordinates($roleid);
if (count($subrole) > 0) {
$roleids = $subrole;
array_push($roleids, $roleid);
} else {
$roleids = $roleid;
}
if (count($roleids) > 0) {
$pick_query = "select distinct $fieldname from vtiger_$fieldname inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_$fieldname.picklist_valueid where roleid in (" . generateQuestionMarks($roleids) . ") and picklistid in (select picklistid from vtiger_$fieldname) order by $fieldname asc";
$params = array($roleids);
} else {
$pick_query = "select distinct $fieldname from vtiger_$fieldname inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_$fieldname.picklist_valueid where picklistid in (select picklistid from vtiger_$fieldname) order by $fieldname asc";
$params = array();
}
$pickListResult = $adb->pquery($pick_query, $params);
$picklistval = Array();
for ($i = 0; $i < $adb->num_rows($pickListResult); $i++) {
$picklistarr[] = $adb->query_result($pickListResult, $i, $fieldname);
}
$value_temp = Array();
$string_temp = '';
$str_c = 0;
foreach ($value_arr as $ind => $val) {
$notaccess = '' . $app_strings['LBL_NOT_ACCESSIBLE'] . "";
if (!$listview_max_textlength || !(strlen(preg_replace("/(<\/?)(\w+)([^>]*>)/i", "", $string_temp)) > $listview_max_textlength)) {
$value_temp1 = (in_array(trim($val), $picklistarr)) ? $val : $notaccess;
if ($str_c != 0)
$string_temp .= ' , ';
$string_temp .= $value_temp1;
$str_c++;
}
else
$string_temp .='...';
}
$value = $string_temp;
}
}
}
elseif ($uitype == 85) {
$value = ($temp_val != "") ? "{$temp_val}" : "";
} elseif ($uitype == 116) {
$value = ($temp_val != "") ? getCurrencyName($temp_val) : "";
} elseif ($uitype == 117) {
// NOTE: Without symbol the value could be used for filtering/lookup hence avoiding the translation
$value = ($temp_val != "") ? getCurrencyName($temp_val, false) : "";
} elseif ($uitype == 26) {
$sql = "select foldername from vtiger_attachmentsfolder where folderid = ?";
$res = $adb->pquery($sql, array($temp_val));
$foldername = $adb->query_result($res, 0, 'foldername');
$value = $foldername;
}
//added for asterisk integration
elseif ($uitype == 11) {
// Fix added for Trac Id: 6139
if (vtlib_isModuleActive('PBXManager')) {
$value = "" . textlength_check($temp_val) . "";
} else {
$value = $temp_val;
}
}
//asterisk changes end here
//Added for email status tracking
elseif ($uitype == 25) {
$contactid = $_REQUEST['record'];
$emailid = $adb->query_result($list_result, $list_result_count, "activityid");
$result = $adb->pquery("SELECT access_count FROM vtiger_email_track WHERE crmid=? AND mailid=?", array($contactid, $emailid));
$value = $adb->query_result($result, 0, "access_count");
if (!$value) {
$value = 0;
}
} elseif ($uitype == 8) {
if (!empty($temp_val)) {
$temp_val = html_entity_decode($temp_val, ENT_QUOTES, $default_charset);
$json = new Zend_Json();
$value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val)));
}
}
//end email status tracking
else {
if ($fieldname == $focus->list_link_field) {
if ($mode == "search") {
if ($popuptype == "specific" || $popuptype == "toDospecific") {
// Added for get the first name of contact in Popup window
if ($colname == "lastname" && $module == 'Contacts') {
$temp_val = getFullNameFromQResult($list_result, $list_result_count, "Contacts");
}
$slashes_temp_val = popup_from_html($temp_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
//Added to avoid the error when select SO from Invoice through AjaxEdit
if ($module == 'SalesOrder') {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} elseif ($module == 'Contacts') {
require_once('modules/Contacts/Contacts.php');
$cntct_focus = new Contacts();
$cntct_focus->retrieve_entity_info($entity_id, "Contacts");
$slashes_temp_val = popup_from_html($temp_val);
//ADDED TO CHECK THE FIELD PERMISSIONS FOR
$xyz = array('mailingstreet', 'mailingcity', 'mailingzip', 'mailingpobox', 'mailingcountry', 'mailingstate', 'otherstreet', 'othercity', 'otherzip', 'otherpobox', 'othercountry', 'otherstate');
for ($i = 0; $i < 12; $i++) {
if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') {
$cntct_focus->column_fields[$xyz[$i]] = $cntct_focus->column_fields[$xyz[$i]];
}
else
$cntct_focus->column_fields[$xyz[$i]] = '';
}
// For ToDo creation the underlying form is not named as EditView
$form = !empty($_REQUEST['form']) ? $_REQUEST['form'] : '';
if (!empty($form))
$form = htmlspecialchars($form, ENT_QUOTES, $default_charset);
$count = counterValue();
$value = 'column_fields['mailingstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcity']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercity']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcountry']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercountry']) . '","' . popup_decode_html($cntct_focus->column_fields['mailingpobox']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherpobox']) . '","' . $form . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '';
}
else
if ($popuptype == 'toDospecific') {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} else {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
}
} elseif ($popuptype == "detailview") {
if ($colname == "lastname" && ($module == 'Contacts' || $module == 'Leads')) {
$temp_val = getFullNameFromQResult($list_result, $list_result_count, $module);
}
$slashes_temp_val = popup_from_html($temp_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$focus->record_id = $_REQUEST['recordid'];
$popupMode = $_REQUEST['popupmode'];
$callBack = $_REQUEST['callback'];
if ($_REQUEST['return_module'] == "Calendar") {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} else {
$count = counterValue();
if (empty($callBack)) {
$value = 'record_id . '","' . $module . '","' . $popupMode . '");\'>' . textlength_check($temp_val) . '';
} else {
$value = 'record_id . '","' . $module . '","' . $popupMode . '",' . $callBack . ');\'>' . textlength_check($temp_val) . '';
}
}
} elseif ($popuptype == "formname_specific") {
$slashes_temp_val = popup_from_html($temp_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} elseif ($popuptype == "inventory_prod") {
$row_id = $_REQUEST['curr_row'];
//To get all the tax types and values and pass it to product details
$tax_str = '';
$tax_details = getAllTaxes();
for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
$tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ',';
}
$tax_str = trim($tax_str, ',');
$rate = $user_info['conv_rate'];
if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') {
$unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price');
if ($_REQUEST['currencyid'] != null) {
$prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id));
$unitprice = $prod_prices[$entity_id];
}
} else {
$unitprice = '';
}
$sub_products = '';
$sub_prod = '';
$sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id));
for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) {
//$sub_prod=array();
$id = $adb->query_result($sub_prod_query, $i, "productid");
$str_sep = '';
if ($i > 0)
$str_sep = ":";
$sub_products .= $str_sep . $id;
$sub_prod .= $str_sep . " - " . $adb->query_result($sub_prod_query, $i, "productname");
}
$sub_det = $sub_products . "::" . str_replace(":", "
", $sub_prod);
$qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock');
//fix for T6943
$slashes_temp_val = popup_from_html($field_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description'));
$slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset));
$slashes_desc = str_replace(array("\r", "\n"), array('\r', '\n'), $slashes_temp_desc);
$tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "$unitprice", "qtyinstk" => "$qty_stock", "taxstring" => "$tax_str", "rowid" => "$row_id", "desc" => "$slashes_desc", "subprod_ids" => "$sub_det");
require_once('include/Zend/Json.php');
$prod_arr = Zend_Json::encode($tmp_arr);
$value = '' . textlength_check($temp_val) . '';
}
elseif ($popuptype == "inventory_prod_po") {
$row_id = $_REQUEST['curr_row'];
//To get all the tax types and values and pass it to product details
$tax_str = '';
$tax_details = getAllTaxes();
for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
$tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ',';
}
$tax_str = trim($tax_str, ',');
$rate = $user_info['conv_rate'];
if (getFieldVisibilityPermission($module, $current_user->id, 'unit_price') == '0') {
$unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price');
if ($_REQUEST['currencyid'] != null) {
$prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module);
$unitprice = $prod_prices[$entity_id];
}
} else {
$unitprice = '';
}
$sub_products = '';
$sub_prod = '';
$sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id));
for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) {
//$sub_prod=array();
$id = $adb->query_result($sub_prod_query, $i, "productid");
$str_sep = '';
if ($i > 0)
$str_sep = ":";
$sub_products .= $str_sep . $id;
$sub_prod .= $str_sep . " - $id." . $adb->query_result($sub_prod_query, $i, "productname");
}
$sub_det = $sub_products . "::" . str_replace(":", "
", $sub_prod);
$slashes_temp_val = popup_from_html($field_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description'));
$slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset));
$slashes_desc = str_replace(array("\r", "\n"), array('\r', '\n'), $slashes_temp_desc);
$tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "$unitprice", "qtyinstk" => "$qty_stock", "taxstring" => "$tax_str", "rowid" => "$row_id", "desc" => "$slashes_desc", "subprod_ids" => "$sub_det");
require_once('include/Zend/Json.php');
$prod_arr = Zend_Json::encode($tmp_arr);
$value = '' . textlength_check($temp_val) . '';
}
elseif ($popuptype == "inventory_service") {
$row_id = $_REQUEST['curr_row'];
//To get all the tax types and values and pass it to product details
$tax_str = '';
$tax_details = getAllTaxes();
for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
$tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ',';
}
$tax_str = trim($tax_str, ',');
$rate = $user_info['conv_rate'];
if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') {
$unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price');
if ($_REQUEST['currencyid'] != null) {
$prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module);
$unitprice = $prod_prices[$entity_id];
}
} else {
$unitprice = '';
}
$slashes_temp_val = popup_from_html($field_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description'));
$slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset));
$slashes_desc = str_replace(array("\r", "\n"), array('\r', '\n'), $slashes_temp_desc);
$tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "$unitprice", "taxstring" => "$tax_str", "rowid" => "$row_id", "desc" => "$slashes_desc");
require_once('include/Zend/Json.php');
$prod_arr = Zend_Json::encode($tmp_arr);
$value = '' . textlength_check($temp_val) . '';
} elseif ($popuptype == "inventory_pb") {
$prod_id = $_REQUEST['productid'];
$flname = $_REQUEST['fldname'];
$listprice = getListPrice($prod_id, $entity_id);
$temp_val = popup_from_html($temp_val);
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} elseif ($popuptype == "specific_account_address") {
require_once('modules/Accounts/Accounts.php');
$acct_focus = new Accounts();
$acct_focus->retrieve_entity_info($entity_id, "Accounts");
$slashes_temp_val = popup_from_html($temp_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state');
for ($i = 0; $i < 12; $i++) {
if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') {
$acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]];
}
else
$acct_focus->column_fields[$xyz[$i]] = '';
}
$bill_street = str_replace(array("\r", "\n"), array('\r', '\n'), popup_decode_html($acct_focus->column_fields['bill_street']));
$ship_street = str_replace(array("\r", "\n"), array('\r', '\n'), popup_decode_html($acct_focus->column_fields['ship_street']));
$count = counterValue();
$value = 'column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '';
}
elseif ($popuptype == "specific_contact_account_address") {
require_once('modules/Accounts/Accounts.php');
$acct_focus = new Accounts();
$acct_focus->retrieve_entity_info($entity_id, "Accounts");
$slashes_temp_val = popup_from_html($temp_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$bill_street = str_replace(array("\r", "\n"), array('\r', '\n'), popup_decode_html($acct_focus->column_fields['bill_street']));
$ship_street = str_replace(array("\r", "\n"), array('\r', '\n'), popup_decode_html($acct_focus->column_fields['ship_street']));
$count = counterValue();
$value = 'column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '';
} elseif ($popuptype == "specific_potential_account_address") {
$slashes_temp_val = popup_from_html($temp_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
// For B2C support, Potential was enabled to be linked to Contacts also.
// Hence we need case handling for it.
$relatedid = $adb->query_result($list_result, $list_result_count, "related_to");
$relatedentity = getSalesEntityType($relatedid);
if ($relatedentity == 'Accounts') {
require_once('modules/Accounts/Accounts.php');
$acct_focus = new Accounts();
$acct_focus->retrieve_entity_info($relatedid, "Accounts");
$account_name = getAccountName($relatedid);
$slashes_account_name = popup_from_html($account_name);
$slashes_account_name = htmlspecialchars($slashes_account_name, ENT_QUOTES, $default_charset);
$xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state');
for ($i = 0; $i < 12; $i++) {
if (getFieldVisibilityPermission('Accounts', $current_user->id, $xyz[$i]) == '0') {
$acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]];
}
else
$acct_focus->column_fields[$xyz[$i]] = '';
}
$bill_street = str_replace(array("\r", "\n"), array('\r', '\n'), popup_decode_html($acct_focus->column_fields['bill_street']));
$ship_street = str_replace(array("\r", "\n"), array('\r', '\n'), popup_decode_html($acct_focus->column_fields['ship_street']));
$count = counterValue();
$value = 'column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '';
} else if ($relatedentity == 'Contacts') {
require_once('modules/Contacts/Contacts.php');
$displayValueArray = getEntityName('Contacts', $relatedid);
if (!empty($displayValueArray)) {
foreach ($displayValueArray as $key => $field_value) {
$contact_name = $field_value;
}
} else {
$contact_name = '';
}
$slashes_contact_name = popup_from_html($contact_name);
$slashes_contact_name = htmlspecialchars($slashes_contact_name, ENT_QUOTES, $default_charset);
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} else {
$value = $temp_val;
}
}
//added by rdhital/Raju for better emails
elseif ($popuptype == "set_return_emails") {
if ($module == 'Accounts') {
$name = $adb->query_result($list_result, $list_result_count, 'accountname');
$accid = $adb->query_result($list_result, $list_result_count, 'accountid');
if (CheckFieldPermission('email1', $module) == "true") {
$emailaddress = $adb->query_result($list_result, $list_result_count, "email1");
$email_check = 1;
}
else
$email_check = 0;
if ($emailaddress == '') {
if (CheckFieldPermission('email2', $module) == 'true') {
$emailaddress2 = $adb->query_result($list_result, $list_result_count, "email2");
$email_check = 2;
} else {
if ($email_check == 1)
$email_check = 4;
else
$email_check = 3;
}
}
$querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
$queryres = $adb->pquery($querystr, array(getTabid($module)));
//Change this index 0 - to get the vtiger_fieldid based on email1 or email2
$fieldid = $adb->query_result($queryres, 0, 'fieldid');
$slashes_name = popup_from_html($name);
$slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
$count = counterValue();
$value = '' . textlength_check($name) . '';
}elseif ($module == 'Vendors') {
$name = $adb->query_result($list_result, $list_result_count, 'vendorname');
$venid = $adb->query_result($list_result, $list_result_count, 'vendorid');
if (CheckFieldPermission('email', $module) == "true") {
$emailaddress = $adb->query_result($list_result, $list_result_count, "email");
$email_check = 1;
}
else
$email_check = 0;
$querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
$queryres = $adb->pquery($querystr, array(getTabid($module)));
//Change this index 0 - to get the vtiger_fieldid based on email1 or email2
$fieldid = $adb->query_result($queryres, 0, 'fieldid');
$slashes_name = popup_from_html($name);
$slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
$count = counterValue();
$value = '' . textlength_check($name) . '';
}elseif ($module == 'Contacts' || $module == 'Leads') {
$name = getFullNameFromQResult($list_result, $list_result_count, $module);
if (CheckFieldPermission('email', $module) == "true") {
$emailaddress = $adb->query_result($list_result, $list_result_count, "email");
$email_check = 1;
}
else
$email_check = 0;
if ($emailaddress == '') {
if (CheckFieldPermission('secondaryemail', $module) == 'true') {
$emailaddress2 = $adb->query_result($list_result, $list_result_count, "secondaryemail");
$email_check = 2;
} else {
if ($email_check == 1)
$email_check = 4;
else
$email_check = 3;
}
}
$querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
$queryres = $adb->pquery($querystr, array(getTabid($module)));
//Change this index 0 - to get the vtiger_fieldid based on email or secondaryemail
$fieldid = $adb->query_result($queryres, 0, 'fieldid');
$slashes_name = popup_from_html($name);
$slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
$count = counterValue();
$value = '' . $name . '';
}else {
$name = getFullNameFromQResult($list_result, $list_result_count, $module);
$emailaddress = $adb->query_result($list_result, $list_result_count, "email1");
$slashes_name = popup_from_html($name);
$slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
$email_check = 1;
$count = counterValue();
$value = '' . textlength_check($name) . '';
}
} elseif ($popuptype == "specific_vendor_address") {
require_once('modules/Vendors/Vendors.php');
$acct_focus = new Vendors();
$acct_focus->retrieve_entity_info($entity_id, "Vendors");
$slashes_temp_val = popup_from_html($temp_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$xyz = array('street', 'city', 'postalcode', 'pobox', 'country', 'state');
for ($i = 0; $i < 6; $i++) {
if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') {
$acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]];
}
else
$acct_focus->column_fields[$xyz[$i]] = '';
}
$bill_street = str_replace(array("\r", "\n"), array('\r', '\n'), popup_decode_html($acct_focus->column_fields['street']));
$count = counterValue();
$value = 'column_fields['city']) . '", "' . popup_decode_html($acct_focus->column_fields['state']) . '", "' . popup_decode_html($acct_focus->column_fields['postalcode']) . '", "' . popup_decode_html($acct_focus->column_fields['country']) . '","' . popup_decode_html($acct_focus->column_fields['pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '';
}
elseif ($popuptype == "specific_campaign") {
$slashes_temp_val = popup_from_html($temp_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} else {
if ($colname == "lastname") {
$temp_val = getFullNameFromQResult($list_result, $list_result_count, $module);
} elseif ($module == 'Users' && $fieldname == 'last_name') {
$temp_val = getFullNameFromQResult($list_result, $list_result_count, $module);
}
$slashes_temp_val = popup_from_html($temp_val);
$slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
$log->debug("Exiting getValue method ...");
if ($_REQUEST['maintab'] == 'Calendar') {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} else {
$value = 'popup_type != 'detailview') {
$count = counterValue();
$value .= " id='$count' ";
}
$value .= '>' . textlength_check($temp_val) . '';
}
}
} else {
if (($module == "Leads" && $colname == "lastname") || ($module == "Contacts" && $colname == "lastname")) {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} elseif ($module == "Calendar") {
$actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype');
$actvity_type = ($actvity_type != '') ? $actvity_type : $adb->query_result($list_result, $list_result_count, 'type');
if ($actvity_type == "Task") {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} else {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
}
} elseif ($module == "Vendors") {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} elseif ($module == "PriceBooks") {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} elseif ($module == "SalesOrder") {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
} elseif ($module == 'Emails') {
$value = $temp_val;
} elseif (($module == "Users" && $colname == "last_name")) {
$temp_val = getFullNameFromQResult($list_result, $list_result_count, $module);
$value = '' . textlength_check($temp_val) . '';
} else {
$count = counterValue();
$value = '' . textlength_check($temp_val) . '';
}
}
} elseif ($module == 'Calendar' && ($fieldname == 'time_start' ||
$fieldname == 'time_end')) {
$dateField = 'date_start';
if ($fieldname == 'time_end') {
$dateField = 'due_date';
}
$type = $adb->query_result($list_result, $list_result_count, 'activitytype');
if (empty($type)) {
$type = $adb->query_result($list_result, $list_result_count, 'type');
}
if ($type == 'Task' && $fieldname == 'time_end') {
$value = '--';
} else {
$date_val = $adb->query_result($list_result, $list_result_count, $dateField);
$date = new DateTimeField($date_val . ' ' . $temp_val);
$value = $date->getDisplayTime();
$value = textlength_check($value);
}
} else {
$value = $temp_val;
$value = textlength_check($value);
}
}
// Mike Crowe Mod --------------------------------------------------------Make right justified and vtiger_currency value
if (in_array($uitype, array(71, 72, 7, 9, 90))) {
$value = '' . $value . '';
}
$log->debug("Exiting getValue method ...");
return $value;
}
/** Function to get the list query for a module
* @param $module -- module name:: Type string
* @param $where -- where:: Type string
* @returns $query -- query:: Type query
*/
function getListQuery($module, $where = '') {
global $log;
$log->debug("Entering getListQuery(" . $module . "," . $where . ") method ...");
global $current_user;
require('user_privileges/user_privileges_' . $current_user->id . '.php');
require('user_privileges/sharing_privileges_' . $current_user->id . '.php');
$tab_id = getTabid($module);
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' =>
'vtiger_users.last_name'), 'Users');
switch ($module) {
Case "HelpDesk":
$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
vtiger_troubletickets.title, vtiger_troubletickets.status,
vtiger_troubletickets.priority, vtiger_troubletickets.parent_id,
vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,
vtiger_contactdetails.lastname, vtiger_account.accountid,
vtiger_account.accountname, vtiger_ticketcf.*, vtiger_troubletickets.ticket_no
FROM vtiger_troubletickets
INNER JOIN vtiger_ticketcf
ON vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_contactdetails
ON vtiger_troubletickets.parent_id = vtiger_contactdetails.contactid
LEFT JOIN vtiger_account
ON vtiger_account.accountid = vtiger_troubletickets.parent_id
LEFT JOIN vtiger_users
ON vtiger_crmentity.smownerid = vtiger_users.id
LEFT JOIN vtiger_products
ON vtiger_products.productid = vtiger_troubletickets.product_id";
$query .= ' ' . getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Accounts":
//Query modified to sort by assigned to
$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
vtiger_account.accountname, vtiger_account.email1,
vtiger_account.email2, vtiger_account.website, vtiger_account.phone,
vtiger_accountbillads.bill_city,
vtiger_accountscf.*
FROM vtiger_account
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_account.accountid
INNER JOIN vtiger_accountbillads
ON vtiger_account.accountid = vtiger_accountbillads.accountaddressid
INNER JOIN vtiger_accountshipads
ON vtiger_account.accountid = vtiger_accountshipads.accountaddressid
INNER JOIN vtiger_accountscf
ON vtiger_account.accountid = vtiger_accountscf.accountid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid
LEFT JOIN vtiger_account vtiger_account2
ON vtiger_account.parentid = vtiger_account2.accountid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Potentials":
//Query modified to sort by assigned to
$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
vtiger_account.accountname,
vtiger_potential.related_to, vtiger_potential.potentialname,
vtiger_potential.sales_stage, vtiger_potential.amount,
vtiger_potential.currency, vtiger_potential.closingdate,
vtiger_potential.typeofrevenue,
vtiger_potentialscf.*
FROM vtiger_potential
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_potential.potentialid
INNER JOIN vtiger_potentialscf
ON vtiger_potentialscf.potentialid = vtiger_potential.potentialid
LEFT JOIN vtiger_account
ON vtiger_potential.related_to = vtiger_account.accountid
LEFT JOIN vtiger_contactdetails
ON vtiger_potential.related_to = vtiger_contactdetails.contactid
LEFT JOIN vtiger_campaign
ON vtiger_campaign.campaignid = vtiger_potential.campaignid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Leads":
$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
vtiger_leaddetails.firstname, vtiger_leaddetails.lastname,
vtiger_leaddetails.company, vtiger_leadaddress.phone,
vtiger_leadsubdetails.website, vtiger_leaddetails.email,
vtiger_leadscf.*
FROM vtiger_leaddetails
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid
INNER JOIN vtiger_leadsubdetails
ON vtiger_leadsubdetails.leadsubscriptionid = vtiger_leaddetails.leadid
INNER JOIN vtiger_leadaddress
ON vtiger_leadaddress.leadaddressid = vtiger_leadsubdetails.leadsubscriptionid
INNER JOIN vtiger_leadscf
ON vtiger_leaddetails.leadid = vtiger_leadscf.leadid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 AND vtiger_leaddetails.converted = 0 " . $where;
break;
Case "Products":
$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.description, vtiger_products.*, vtiger_productcf.*
FROM vtiger_products
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_products.productid
INNER JOIN vtiger_productcf
ON vtiger_products.productid = vtiger_productcf.productid
LEFT JOIN vtiger_vendor
ON vtiger_vendor.vendorid = vtiger_products.vendor_id
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid";
if ((isset($_REQUEST["from_dashboard"]) && $_REQUEST["from_dashboard"] == true) && (isset($_REQUEST["type"]) && $_REQUEST["type"] == "dbrd"))
$query .= " INNER JOIN vtiger_inventoryproductrel on vtiger_inventoryproductrel.productid = vtiger_products.productid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= " WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Documents":
$query = "SELECT case when (vtiger_users.user_name not like '') then $userNameSql else vtiger_groups.groupname end as user_name,vtiger_crmentity.crmid, vtiger_crmentity.modifiedtime,
vtiger_crmentity.smownerid,vtiger_attachmentsfolder.*,vtiger_notes.*
FROM vtiger_notes
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_notes.notesid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid
LEFT JOIN vtiger_attachmentsfolder
ON vtiger_notes.folderid = vtiger_attachmentsfolder.folderid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Contacts":
//Query modified to sort by assigned to
$query = "SELECT vtiger_contactdetails.firstname, vtiger_contactdetails.lastname,
vtiger_contactdetails.title, vtiger_contactdetails.accountid,
vtiger_contactdetails.email, vtiger_contactdetails.phone,
vtiger_crmentity.smownerid, vtiger_crmentity.crmid
FROM vtiger_contactdetails
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
INNER JOIN vtiger_contactaddress
ON vtiger_contactaddress.contactaddressid = vtiger_contactdetails.contactid
INNER JOIN vtiger_contactsubdetails
ON vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid
INNER JOIN vtiger_contactscf
ON vtiger_contactscf.contactid = vtiger_contactdetails.contactid
LEFT JOIN vtiger_account
ON vtiger_account.accountid = vtiger_contactdetails.accountid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid
LEFT JOIN vtiger_contactdetails vtiger_contactdetails2
ON vtiger_contactdetails.reportsto = vtiger_contactdetails2.contactid
LEFT JOIN vtiger_customerdetails
ON vtiger_customerdetails.customerid = vtiger_contactdetails.contactid";
if ((isset($_REQUEST["from_dashboard"]) && $_REQUEST["from_dashboard"] == true) &&
(isset($_REQUEST["type"]) && $_REQUEST["type"] == "dbrd")) {
$query .= " INNER JOIN vtiger_campaigncontrel on vtiger_campaigncontrel.contactid = " .
"vtiger_contactdetails.contactid";
}
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Calendar":
$query = "SELECT vtiger_activity.activityid as act_id,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.setype,
vtiger_activity.*,
vtiger_contactdetails.lastname, vtiger_contactdetails.firstname,
vtiger_contactdetails.contactid,
vtiger_account.accountid, vtiger_account.accountname
FROM vtiger_activity
LEFT JOIN vtiger_activitycf
ON vtiger_activitycf.activityid = vtiger_activity.activityid
LEFT JOIN vtiger_cntactivityrel
ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
LEFT JOIN vtiger_contactdetails
ON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
LEFT JOIN vtiger_seactivityrel
ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
LEFT OUTER JOIN vtiger_activity_reminder
ON vtiger_activity_reminder.activity_id = vtiger_activity.activityid
LEFT JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_activity.activityid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users vtiger_users2
ON vtiger_crmentity.modifiedby = vtiger_users2.id
LEFT JOIN vtiger_groups vtiger_groups2
ON vtiger_crmentity.modifiedby = vtiger_groups2.groupid
LEFT OUTER JOIN vtiger_account
ON vtiger_account.accountid = vtiger_contactdetails.accountid
LEFT OUTER JOIN vtiger_leaddetails
ON vtiger_leaddetails.leadid = vtiger_seactivityrel.crmid
LEFT OUTER JOIN vtiger_account vtiger_account2
ON vtiger_account2.accountid = vtiger_seactivityrel.crmid
LEFT OUTER JOIN vtiger_potential
ON vtiger_potential.potentialid = vtiger_seactivityrel.crmid
LEFT OUTER JOIN vtiger_troubletickets
ON vtiger_troubletickets.ticketid = vtiger_seactivityrel.crmid
LEFT OUTER JOIN vtiger_salesorder
ON vtiger_salesorder.salesorderid = vtiger_seactivityrel.crmid
LEFT OUTER JOIN vtiger_purchaseorder
ON vtiger_purchaseorder.purchaseorderid = vtiger_seactivityrel.crmid
LEFT OUTER JOIN vtiger_quotes
ON vtiger_quotes.quoteid = vtiger_seactivityrel.crmid
LEFT OUTER JOIN vtiger_invoice
ON vtiger_invoice.invoiceid = vtiger_seactivityrel.crmid
LEFT OUTER JOIN vtiger_campaign
ON vtiger_campaign.campaignid = vtiger_seactivityrel.crmid";
//added to fix #5135
if (isset($_REQUEST['from_homepage']) && ($_REQUEST['from_homepage'] ==
"upcoming_activities" || $_REQUEST['from_homepage'] == "pending_activities")) {
$query.=" LEFT OUTER JOIN vtiger_recurringevents
ON vtiger_recurringevents.activityid=vtiger_activity.activityid";
}
//end
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query.=" WHERE vtiger_crmentity.deleted = 0 AND activitytype != 'Emails' " . $where;
break;
Case "Emails":
$query = "SELECT DISTINCT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
vtiger_activity.activityid, vtiger_activity.subject,
vtiger_activity.date_start,
vtiger_contactdetails.lastname, vtiger_contactdetails.firstname,
vtiger_contactdetails.contactid
FROM vtiger_activity
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_activity.activityid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid
LEFT JOIN vtiger_seactivityrel
ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
LEFT JOIN vtiger_contactdetails
ON vtiger_contactdetails.contactid = vtiger_seactivityrel.crmid
LEFT JOIN vtiger_cntactivityrel
ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
AND vtiger_cntactivityrel.contactid = vtiger_cntactivityrel.contactid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_salesmanactivityrel
ON vtiger_salesmanactivityrel.activityid = vtiger_activity.activityid
LEFT JOIN vtiger_emaildetails
ON vtiger_emaildetails.emailid = vtiger_activity.activityid
WHERE vtiger_activity.activitytype = 'Emails'";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "AND vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Faq":
$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.createdtime, vtiger_crmentity.modifiedtime,
vtiger_faq.*
FROM vtiger_faq
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_faq.id
LEFT JOIN vtiger_products
ON vtiger_faq.product_id = vtiger_products.productid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Vendors":
$query = "SELECT vtiger_crmentity.crmid, vtiger_vendor.*
FROM vtiger_vendor
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_vendor.vendorid
INNER JOIN vtiger_vendorcf
ON vtiger_vendor.vendorid = vtiger_vendorcf.vendorid
WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "PriceBooks":
$query = "SELECT vtiger_crmentity.crmid, vtiger_pricebook.*, vtiger_currency_info.currency_name
FROM vtiger_pricebook
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_pricebook.pricebookid
INNER JOIN vtiger_pricebookcf
ON vtiger_pricebook.pricebookid = vtiger_pricebookcf.pricebookid
LEFT JOIN vtiger_currency_info
ON vtiger_pricebook.currency_id = vtiger_currency_info.id
WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Quotes":
//Query modified to sort by assigned to
$query = "SELECT vtiger_crmentity.*,
vtiger_quotes.*,
vtiger_quotesbillads.*,
vtiger_quotesshipads.*,
vtiger_potential.potentialname,
vtiger_account.accountname,
vtiger_currency_info.currency_name
FROM vtiger_quotes
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_quotes.quoteid
INNER JOIN vtiger_quotesbillads
ON vtiger_quotes.quoteid = vtiger_quotesbillads.quotebilladdressid
INNER JOIN vtiger_quotesshipads
ON vtiger_quotes.quoteid = vtiger_quotesshipads.quoteshipaddressid
LEFT JOIN vtiger_quotescf
ON vtiger_quotes.quoteid = vtiger_quotescf.quoteid
LEFT JOIN vtiger_currency_info
ON vtiger_quotes.currency_id = vtiger_currency_info.id
LEFT OUTER JOIN vtiger_account
ON vtiger_account.accountid = vtiger_quotes.accountid
LEFT OUTER JOIN vtiger_potential
ON vtiger_potential.potentialid = vtiger_quotes.potentialid
LEFT JOIN vtiger_contactdetails
ON vtiger_contactdetails.contactid = vtiger_quotes.contactid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users as vtiger_usersQuotes
ON vtiger_usersQuotes.id = vtiger_quotes.inventorymanager";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "PurchaseOrder":
//Query modified to sort by assigned to
$query = "SELECT vtiger_crmentity.*,
vtiger_purchaseorder.*,
vtiger_pobillads.*,
vtiger_poshipads.*,
vtiger_vendor.vendorname,
vtiger_currency_info.currency_name
FROM vtiger_purchaseorder
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid
LEFT OUTER JOIN vtiger_vendor
ON vtiger_purchaseorder.vendorid = vtiger_vendor.vendorid
LEFT JOIN vtiger_contactdetails
ON vtiger_purchaseorder.contactid = vtiger_contactdetails.contactid
INNER JOIN vtiger_pobillads
ON vtiger_purchaseorder.purchaseorderid = vtiger_pobillads.pobilladdressid
INNER JOIN vtiger_poshipads
ON vtiger_purchaseorder.purchaseorderid = vtiger_poshipads.poshipaddressid
LEFT JOIN vtiger_purchaseordercf
ON vtiger_purchaseordercf.purchaseorderid = vtiger_purchaseorder.purchaseorderid
LEFT JOIN vtiger_currency_info
ON vtiger_purchaseorder.currency_id = vtiger_currency_info.id
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "SalesOrder":
//Query modified to sort by assigned to
$query = "SELECT vtiger_crmentity.*,
vtiger_salesorder.*,
vtiger_sobillads.*,
vtiger_soshipads.*,
vtiger_quotes.subject AS quotename,
vtiger_account.accountname,
vtiger_currency_info.currency_name
FROM vtiger_salesorder
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid
INNER JOIN vtiger_sobillads
ON vtiger_salesorder.salesorderid = vtiger_sobillads.sobilladdressid
INNER JOIN vtiger_soshipads
ON vtiger_salesorder.salesorderid = vtiger_soshipads.soshipaddressid
LEFT JOIN vtiger_salesordercf
ON vtiger_salesordercf.salesorderid = vtiger_salesorder.salesorderid
LEFT JOIN vtiger_currency_info
ON vtiger_salesorder.currency_id = vtiger_currency_info.id
LEFT OUTER JOIN vtiger_quotes
ON vtiger_quotes.quoteid = vtiger_salesorder.quoteid
LEFT OUTER JOIN vtiger_account
ON vtiger_account.accountid = vtiger_salesorder.accountid
LEFT JOIN vtiger_contactdetails
ON vtiger_salesorder.contactid = vtiger_contactdetails.contactid
LEFT JOIN vtiger_potential
ON vtiger_potential.potentialid = vtiger_salesorder.potentialid
LEFT JOIN vtiger_invoice_recurring_info
ON vtiger_invoice_recurring_info.salesorderid = vtiger_salesorder.salesorderid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Invoice":
//Query modified to sort by assigned to
//query modified -Code contribute by Geoff(http://forums.vtiger.com/viewtopic.php?t=3376)
$query = "SELECT vtiger_crmentity.*,
vtiger_invoice.*,
vtiger_invoicebillads.*,
vtiger_invoiceshipads.*,
vtiger_salesorder.subject AS salessubject,
vtiger_account.accountname,
vtiger_currency_info.currency_name
FROM vtiger_invoice
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_invoice.invoiceid
INNER JOIN vtiger_invoicebillads
ON vtiger_invoice.invoiceid = vtiger_invoicebillads.invoicebilladdressid
INNER JOIN vtiger_invoiceshipads
ON vtiger_invoice.invoiceid = vtiger_invoiceshipads.invoiceshipaddressid
LEFT JOIN vtiger_currency_info
ON vtiger_invoice.currency_id = vtiger_currency_info.id
LEFT OUTER JOIN vtiger_salesorder
ON vtiger_salesorder.salesorderid = vtiger_invoice.salesorderid
LEFT OUTER JOIN vtiger_account
ON vtiger_account.accountid = vtiger_invoice.accountid
LEFT JOIN vtiger_contactdetails
ON vtiger_contactdetails.contactid = vtiger_invoice.contactid
INNER JOIN vtiger_invoicecf
ON vtiger_invoice.invoiceid = vtiger_invoicecf.invoiceid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Campaigns":
//Query modified to sort by assigned to
//query modified -Code contribute by Geoff(http://forums.vtiger.com/viewtopic.php?t=3376)
$query = "SELECT vtiger_crmentity.*,
vtiger_campaign.*
FROM vtiger_campaign
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_campaign.campaignid
INNER JOIN vtiger_campaignscf
ON vtiger_campaign.campaignid = vtiger_campaignscf.campaignid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid
LEFT JOIN vtiger_products
ON vtiger_products.productid = vtiger_campaign.product_id";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
break;
Case "Users":
$query = "SELECT id,user_name,first_name,last_name,email1,phone_mobile,phone_work,is_admin,status,email2,
vtiger_user2role.roleid as roleid,vtiger_role.depth as depth
FROM vtiger_users
INNER JOIN vtiger_user2role ON vtiger_users.id = vtiger_user2role.userid
INNER JOIN vtiger_role ON vtiger_user2role.roleid = vtiger_role.roleid
WHERE deleted=0 " . $where;
break;
default:
// vtlib customization: Include the module file
$focus = CRMEntity::getInstance($module);
$query = $focus->getListQuery($module, $where);
// END
}
if ($module != 'Users') {
$query = listQueryNonAdminChange($query, $module);
}
$log->debug("Exiting getListQuery method ...");
return $query;
}
/* * Function returns the list of records which an user is entiled to view
* Param $module - module name
* Returns a database query - type string
*/
function getReadEntityIds($module) {
global $log;
$log->debug("Entering getReadEntityIds(" . $module . ") method ...");
global $current_user;
require('user_privileges/user_privileges_' . $current_user->id . '.php');
require('user_privileges/sharing_privileges_' . $current_user->id . '.php');
$tab_id = getTabid($module);
if ($module == "Leads") {
$query = "SELECT vtiger_crmentity.crmid
FROM vtiger_leaddetails
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0
AND vtiger_leaddetails.converted = 0 ";
} elseif ($module == "Accounts") {
//Query modified to sort by assigned to
$query = "SELECT vtiger_crmentity.crmid
FROM vtiger_account
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_account.accountid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 ";
} elseif ($module == "Potentials") {
//Query modified to sort by assigned to
$query = "SELECT vtiger_crmentity.crmid
FROM vtiger_potential
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_potential.potentialid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 ";
} elseif ($module == "Contacts") {
//Query modified to sort by assigned to
$query = "SELECT vtiger_crmentity.crmid
FROM vtiger_contactdetails
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 ";
} elseif ($module == "Products") {
$query = "SELECT DISTINCT vtiger_crmentity.crmid
FROM vtiger_products
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_products.productid
LEFT JOIN vtiger_seproductsrel
ON vtiger_seproductsrel.productid = vtiger_products.productid
WHERE vtiger_crmentity.deleted = 0
AND (vtiger_seproductsrel.crmid IS NULL
OR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Leads') . ")
OR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Accounts') . ")
OR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Potentials') . ")
OR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Contacts') . ")) ";
} elseif ($module == "PurchaseOrder") {
//Query modified to sort by assigned to
$query = "SELECT vtiger_crmentity.crmid
FROM vtiger_purchaseorder
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 ";
} elseif ($module == "SalesOrder") {
//Query modified to sort by assigned to
$query = "SELECT vtiger_crmentity.crmid
FROM vtiger_salesorder
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 ";
} elseif ($module == "Invoice") {
$query = "SELECT vtiger_crmentity.crmid
FROM vtiger_invoice
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_invoice.invoiceid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 ";
} elseif ($module == "Quotes") {
$query = "SELECT vtiger_crmentity.crmid
FROM vtiger_quotes
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_quotes.quoteid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 ";
} elseif ($module == "HelpDesk") {
$query = "SELECT vtiger_crmentity.crmid
FROM vtiger_troubletickets
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid
LEFT JOIN vtiger_groups
ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= getNonAdminAccessControlQuery($module, $current_user);
$query .= "WHERE vtiger_crmentity.deleted = 0 ";
}
$log->debug("Exiting getReadEntityIds method ...");
return $query;
}
/** Function to get alphabetical search links
* Param $module - module name
* Param $action - action
* Param $fieldname - vtiger_field name
* Param $query - query
* Param $type - search type
* Param $popuptype - popup type
* Param $recordid - record id
* Param $return_module - return module
* Param $append_url - url string to be appended
* Param $viewid - custom view id
* Param $groupid - group id
* Returns an string value
*/
function AlphabeticalSearch($module, $action, $fieldname, $query, $type, $popuptype = '', $recordid = '', $return_module = '', $append_url = '', $viewid = '', $groupid = '') {
global $log;
$log->debug("Entering AlphabeticalSearch(" . $module . "," . $action . "," . $fieldname . "," . $query . "," . $type . "," . $popuptype . "," . $recordid . "," . $return_module . "," . $append_url . "," . $viewid . "," . $groupid . ") method ...");
if ($type == 'advanced')
$flag = '&advanced=true';
if ($popuptype != '')
$popuptypevalue = "&popuptype=" . $popuptype;
if ($recordid != '')
$returnvalue = '&recordid=' . $recordid;
if ($return_module != '')
$returnvalue .= '&return_module=' . $return_module;
// vtlib Customization : For uitype 10 popup during paging
if ($_REQUEST['form'] == 'vtlibPopupView') {
$returnvalue .= '&form=vtlibPopupView&forfield=' . vtlib_purify($_REQUEST['forfield']) . '&srcmodule=' . vtlib_purify($_REQUEST['srcmodule']) . '&forrecord=' . vtlib_purify($_REQUEST['forrecord']);
}
// END
for ($var = 'A', $i = 1; $i <= 26; $i++, $var++)
// Mike Crowe Mod --------------------------------------------------------added groupid to url
$list .= '