Example #1
0
 /**
  * Function to get the display value in detail view
  * @param <Integer> crmid of record
  * @return <String>
  */
 public function getEditViewDisplayValue($value)
 {
     if ($value) {
         $userName = getRoleName($value);
         return $userName;
     }
 }
Example #2
0
 /**
  * Function to get the display value in detail view
  * @param <Integer> crmid of record
  * @return <String>
  */
 public function getEditViewDisplayValue($value)
 {
     global $log;
     $log->debug("Entering ./uitypes/UserRole.php::getEditViewDisplayValue");
     if ($value) {
         $userName = getRoleName($value);
         return $userName;
     }
 }
Example #3
0
		/**
		 * Draw the ACLInfoPanel
		 */
		function draw() {
			global $lang;

			// make sure to get the latest data.
			$this->acl->load();
			echo "<td class=\"standard\" colspan=\"" . $this->cols . "\">";
			echo '<table width="100%" cellpadding="2" cellspacing="2" border="0" class="standardlight">';
			// Parent Node
			echo '<tr><td class="standard" width="33%"><b>';
			echo $lang->get("acl_parent", "Permissions inherited from");
			echo '</b></td><td  width="66%">';
			echo $this->acl->getParentName();
			echo '</td></tr>';

			// Owner
			echo '<tr><td class="standard" width="33%"><b>';
			echo $lang->get("acl_owner");
			echo '</b></td><td  width="66%">';
			echo getAccessorName($this->acl->owner);
			echo '</td></tr>';

			// Groups & roles
			echo '<tr><td class="standard" valign="top"><b>';
			echo $lang->get("acl_groupsroles", "Foreign Access"). "<br></b>";
			echo '</td>';
			echo "<td>";

			if (!$this->acl->accessors == 0) {
				foreach ($this->acl->accessors as $key => $value) {
					echo "<b>" . getAccessorName($value["ACCESSOR"]). "</b>";

					echo " =&gt; ";
					echo getRoleName($value["ROLE"]);
					br();
				}
			}

			echo "</td></tr>";

			echo '</table>';
			echo "</td>";
			return $this->cols;
		}
<?php

/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 *
 ********************************************************************************/
require_once 'modules/PickList/PickListUtils.php';
require_once 'include/utils/utils.php';
require_once 'Smarty_setup.php';
global $mod_strings, $current_language, $adb;
$roleid = $_REQUEST['roleid'];
if (empty($roleid)) {
    echo "role id cannot be empty";
    exit;
}
$otherRoles = getrole2picklist();
$otherRoles = array_diff($otherRoles, array($roleid => getRoleName($roleid)));
$smarty = new vtigerCRM_Smarty();
$smarty->assign("ROLES", $otherRoles);
$smarty->assign("MOD", return_module_language($current_language, 'PickList'));
$smarty->assign("APP", $app_strings);
$str = $smarty->fetch("modules/PickList/ShowRoleSelect.tpl");
echo $str;
Example #5
0
/** This function returns the vtiger_field details for a given vtiger_fieldname.
 * Param $uitype - UI type of the vtiger_field
 * Param $fieldname - Form vtiger_field name
 * Param $fieldlabel - Form vtiger_field label name
 * Param $maxlength - maximum length of the vtiger_field
 * Param $col_fields - array contains the vtiger_fieldname and values
 * Param $generatedtype - Field generated type (default is 1)
 * Param $module_name - module name
 * Return type is an array
 */
function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module_name, $mode = '', $typeofdata = null)
{
    global $log, $app_strings, $adb, $default_charset, $theme, $mod_strings, $current_user;
    $log->debug("Entering getOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $maxlength . "," . print_r($col_fields, true) . "," . $generatedtype . "," . $module_name . ") method ...");
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $fieldlabel = from_html($fieldlabel);
    $fieldvalue = array();
    $final_arr = array();
    $value = $col_fields[$fieldname];
    $custfld = '';
    $ui_type[] = $uitype;
    $editview_fldname[] = $fieldname;
    // vtlib customization: Related type field
    if ($uitype == '10') {
        global $adb;
        $fldmod_result = $adb->pquery('SELECT relmodule, status FROM vtiger_fieldmodulerel WHERE fieldid=
			(SELECT fieldid FROM vtiger_field, vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid AND fieldname=? AND name=? and vtiger_field.presence in (0,2)) order by sequence', array($fieldname, $module_name));
        $entityTypes = array();
        $parent_id = $value;
        for ($index = 0; $index < $adb->num_rows($fldmod_result); ++$index) {
            $entityTypes[] = $adb->query_result($fldmod_result, $index, 'relmodule');
        }
        if (!empty($value)) {
            if ($adb->num_rows($fldmod_result) == 1) {
                $valueType = $adb->query_result($fldmod_result, 0, 0);
            } else {
                $valueType = getSalesEntityType($value);
            }
            $displayValueArray = getEntityName($valueType, $value);
            if (!empty($displayValueArray)) {
                foreach ($displayValueArray as $key => $value) {
                    $displayValue = $value;
                }
            }
        } else {
            $displayValue = '';
            $valueType = '';
            $value = '';
        }
        $editview_label[] = array('options' => $entityTypes, 'selected' => $valueType, 'displaylabel' => getTranslatedString($fieldlabel, $module_name));
        $fieldvalue[] = array('displayvalue' => $displayValue, 'entityid' => $parent_id);
    } else {
        if ($uitype == 5 || $uitype == 6 || $uitype == 23) {
            $log->info("uitype is " . $uitype);
            if ($value == '') {
                //modified to fix the issue in trac(http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/1469)
                if ($fieldname != 'birthday' && $generatedtype != 2 && getTabid($module_name) != 14) {
                    $disp_value = getNewDisplayDate();
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 6) {
                    $curr_time = date('H:i', strtotime('+5 minutes'));
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) {
                    $curr_time = date('H:i', strtotime('+10 minutes'));
                }
                //Added to display the Contact - Support End Date as one year future instead of
                //today's date -- 30-11-2005
                if ($fieldname == 'support_end_date' && $_REQUEST['module'] == 'Contacts') {
                    $addyear = strtotime("+1 year");
                    $disp_value = DateTimeField::convertToUserFormat(date('Y-m-d', $addyear));
                } elseif ($fieldname == 'validtill' && $_REQUEST['module'] == 'Quotes') {
                    $disp_value = '';
                }
            } else {
                if ($uitype == 6) {
                    if ($col_fields['time_start'] != '' && ($module_name == 'Events' || $module_name == 'Calendar')) {
                        $curr_time = $col_fields['time_start'];
                        $value = $value . ' ' . $curr_time;
                    } else {
                        $curr_time = date('H:i', strtotime('+5 minutes'));
                    }
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) {
                    if ($col_fields['time_end'] != '') {
                        $curr_time = $col_fields['time_end'];
                        $value = $value . ' ' . $curr_time;
                    } else {
                        $curr_time = date('H:i', strtotime('+10 minutes'));
                    }
                }
                $disp_value = getValidDisplayDate($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
            if (!empty($curr_time)) {
                if (($module_name == 'Events' || $module_name == 'Calendar') && ($uitype == 23 || $uitype == 6)) {
                    $curr_time = DateTimeField::convertToUserTimeZone($curr_time);
                    $curr_time = $curr_time->format('H:i');
                }
            } else {
                $curr_time = '';
            }
            if (empty($disp_value)) {
                $disp_value = '';
            }
            $fieldvalue[] = array($disp_value => $curr_time);
            if ($uitype == 5 || $uitype == 23) {
                if ($module_name == 'Events' && $uitype == 23) {
                    $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']);
                } else {
                    $fieldvalue[] = array($date_format => $current_user->date_format);
                }
            } else {
                $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']);
            }
        } elseif ($uitype == 16) {
            require_once 'modules/PickList/PickListUtils.php';
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldname = $adb->sql_escape_string($fieldname);
            $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid";
            $params = array();
            $pickListResult = $adb->pquery($pick_query, $params);
            $noofpickrows = $adb->num_rows($pickListResult);
            $options = array();
            $pickcount = 0;
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $value = decode_html($value);
                $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname)));
                if ($value == trim($pickListValue)) {
                    $chk_val = "selected";
                    $pickcount++;
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $pickListValue = to_html($pickListValue);
                if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                    $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                } else {
                    $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                }
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == 1613) {
            require_once 'modules/PickList/PickListUtils.php';
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldname = $adb->sql_escape_string($fieldname);
            $pickListResult = getAllowedPicklistModules();
            $options = array();
            $options[] = "";
            $pickcount = 0;
            $found = false;
            foreach ($pickListResult as $pKey => $pValue) {
                $value = decode_html($value);
                $pickListValue = decode_html($pValue);
                if ($value == trim($pickListValue)) {
                    $chk_val = "selected";
                    $pickcount++;
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $pickListValue = to_html($pickListValue);
                if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                    $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                } else {
                    $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val);
                }
            }
            uasort($options, function ($a, $b) {
                return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1;
            });
            $fieldvalue[] = $options;
        } elseif ($uitype == 15 || $uitype == 33) {
            require_once 'modules/PickList/PickListUtils.php';
            $roleid = $current_user->roleid;
            $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
            $valueArr = explode("|##|", $value);
            foreach ($valueArr as $key => $value) {
                $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset));
            }
            $pickcount = 0;
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    if (in_array(trim($pickListValue), $valueArr)) {
                        $chk_val = "selected";
                        $pickcount++;
                    } else {
                        $chk_val = '';
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected');
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $options;
        } elseif ($uitype == 3313) {
            require_once 'modules/PickList/PickListUtils.php';
            $picklistValues = getAllowedPicklistModules();
            $valueArr = explode("|##|", $value);
            foreach ($valueArr as $key => $value) {
                $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset));
            }
            $pickcount = 0;
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    if (in_array(trim($pickListValue), $valueArr)) {
                        $chk_val = "selected";
                        $pickcount++;
                    } else {
                        $chk_val = '';
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected');
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            uasort($options, function ($a, $b) {
                return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1;
            });
            $fieldvalue[] = $options;
        } elseif ($uitype == 1024) {
            $options = array();
            $arr_evo = explode(' |##| ', $value);
            $roleid = $current_user->roleid;
            $subrole = getRoleSubordinates($roleid);
            $uservalues = array_merge($subrole, array($roleid));
            for ($i = 0; $i < sizeof($uservalues); $i++) {
                $currentValId = $uservalues[$i];
                $currentValName = getRoleName($currentValId);
                if (in_array(trim($currentValId), $arr_evo)) {
                    $chk_val = 'selected';
                } else {
                    $chk_val = '';
                }
                $options[] = array($currentValName, $currentValId, $chk_val);
            }
            $fieldvalue[] = $options;
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
        } elseif ($uitype == 17) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 85) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 14) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 19 || $uitype == 20) {
            if (isset($_REQUEST['body'])) {
                $value = $_REQUEST['body'];
            }
            if ($fieldname == 'terms_conditions') {
                //Assign the value from focus->column_fields (if we create Invoice from SO the SO's terms and conditions will be loaded to Invoice's terms and conditions, etc.,)
                $value = $col_fields['terms_conditions'];
                //if the value is empty then only we should get the default Terms and Conditions
                if ($value == '' && $mode != 'edit') {
                    $value = getTermsandConditions();
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 21 || $uitype == 24) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 22) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 52 || $uitype == 77) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            global $current_user;
            if ($value != '') {
                $assigned_user_id = $value;
            } else {
                $assigned_user_id = $current_user->id;
            }
            if ($uitype == 52) {
                $combo_lbl_name = 'assigned_user_id';
            } elseif ($uitype == 77) {
                $combo_lbl_name = 'assigned_user_id1';
            }
            //Control will come here only for Products - Handler and Quotes - Inventory Manager
            if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
            }
            $fieldvalue[] = $users_combo;
        } elseif ($uitype == 53) {
            global $noof_group_rows;
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            //Security Checks
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $result = get_current_user_access_groups($module_name);
            } else {
                $result = get_group_options();
            }
            if ($result) {
                $nameArray = $adb->fetch_array($result);
            }
            $assigned_user_id = empty($value) ? $current_user->id : $value;
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
            }
            if ($noof_group_rows != 0) {
                if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
                } else {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
                }
            }
            $fieldvalue[] = $users_combo;
            $fieldvalue[] = $groups_combo;
        } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) {
            if (!isset($_REQUEST['convertmode']) || $_REQUEST['convertmode'] != 'update_quote_val' && $_REQUEST['convertmode'] != 'update_so_val') {
                if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') {
                    $value = vtlib_purify($_REQUEST['account_id']);
                }
            }
            if ($value != '') {
                $account_name = getAccountName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $account_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 54) {
            $options = array();
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_groups";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, "name");
                if ($value == $pickListValue) {
                    $chk_val = "selected";
                } else {
                    $chk_val = '';
                }
                $options[] = array($pickListValue => $chk_val);
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == 55 || $uitype == 255) {
            require_once 'modules/PickList/PickListUtils.php';
            if ($uitype == 255) {
                $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'firstname', 'readwrite');
            }
            if ($uitype == 255 && $fieldpermission == '0') {
                $fieldvalue[] = '';
            } else {
                $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'salutationtype', 'readwrite');
                if ($fieldpermission == '0') {
                    $roleid = $current_user->roleid;
                    $picklistValues = getAssignedPicklistValues('salutationtype', $roleid, $adb);
                    $pickcount = 0;
                    $salt_value = $col_fields["salutationtype"];
                    foreach ($picklistValues as $order => $pickListValue) {
                        if ($salt_value == trim($pickListValue)) {
                            $chk_val = "selected";
                            $pickcount++;
                        } else {
                            $chk_val = '';
                        }
                        if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                            $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                        } else {
                            $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                        }
                    }
                    if ($pickcount == 0 && $salt_value != '') {
                        $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $salt_value, 'selected');
                    }
                    $fieldvalue[] = $options;
                } else {
                    $fieldvalue[] = '';
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 59) {
            if ($_REQUEST['module'] == 'HelpDesk') {
                if (isset($_REQUEST['product_id']) & $_REQUEST['product_id'] != '') {
                    $value = $_REQUEST['product_id'];
                }
            } elseif (isset($_REQUEST['parent_id']) & $_REQUEST['parent_id'] != '') {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $product_name = getProductName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $product_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 63) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($value == '') {
                $value = 1;
            }
            $options = array();
            $pick_query = "select * from vtiger_duration_minutes order by sortorderid";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            $salt_value = $col_fields["duration_minutes"];
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, "duration_minutes");
                if ($salt_value == $pickListValue) {
                    $chk_val = "selected";
                } else {
                    $chk_val = '';
                }
                $options[$pickListValue] = $chk_val;
            }
            $fieldvalue[] = $value;
            $fieldvalue[] = $options;
        } elseif ($uitype == 64) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
            $fieldvalue[] = $value;
        } elseif ($uitype == 156) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 56) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 57) {
            if ($value != '') {
                $displayValueArray = getEntityName('Contacts', $value);
                if (!empty($displayValueArray)) {
                    foreach ($displayValueArray as $key => $field_value) {
                        $contact_name = $field_value;
                    }
                }
            } elseif (isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') {
                if ($_REQUEST['module'] == 'Contacts' && ($fieldname = 'contact_id')) {
                    $contact_name = '';
                } else {
                    $value = $_REQUEST['contact_id'];
                    $displayValueArray = getEntityName('Contacts', $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $contact_name = $field_value;
                        }
                    } else {
                        $contact_name = '';
                    }
                }
            }
            //Checking for contacts duplicate
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $contact_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 58) {
            if ($value != '') {
                $campaign_name = getCampaignName($value);
            } elseif (isset($_REQUEST['campaignid']) && $_REQUEST['campaignid'] != '') {
                if ($_REQUEST['module'] == 'Campaigns' && ($fieldname = 'campaignid')) {
                    $campaign_name = '';
                } else {
                    $value = $_REQUEST['campaignid'];
                    $campaign_name = getCampaignName($value);
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $campaign_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 61) {
            if ($value != '') {
                $assigned_user_id = $value;
            } else {
                $assigned_user_id = $current_user->id;
            }
            if ($module_name == 'Emails' && $col_fields['record_id'] != '') {
                $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id']));
                //to fix the issue in mail attachment on forwarding mails
                if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') {
                    global $att_id_list;
                }
                for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) {
                    $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid');
                    if ($attachmentid != '') {
                        $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                        $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                        if ($attachmentsname != '') {
                            $fieldvalue[$attachmentid] = '[ ' . $attachmentsname . ' ]';
                        }
                        if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') {
                            $att_id_list .= $attachmentid . ';';
                        }
                    }
                }
            } else {
                if ($col_fields['record_id'] != '') {
                    $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
                    if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                        $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                        $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                    }
                }
                if ($value != '') {
                    $filename = ' [ ' . $value . ' ]';
                }
                if ($filename != '') {
                    $fieldvalue[] = $filename;
                }
                if ($value != '') {
                    $fieldvalue[] = $value;
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
        } elseif ($uitype == 28) {
            if ($col_fields['record_id'] != '') {
                $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
                if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                    $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                    $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                }
            }
            if ($value != '' && $module_name != 'Documents') {
                $filename = ' [ ' . $value . ' ]';
            } elseif ($value != '' && $module_name == 'Documents') {
                $filename = $value;
            }
            if ($filename != '') {
                $fieldvalue[] = $filename;
            }
            if ($value != '') {
                $fieldvalue[] = $value;
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
        } elseif ($uitype == 69) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($col_fields['record_id'] != "") {
                if ($module_name == 'Products') {
                    $query = 'select vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name ,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?';
                    $params = array($col_fields['record_id']);
                } else {
                    if ($module_name == 'Contacts') {
                        $imageattachment = 'Image';
                    } else {
                        $imageattachment = 'Attachment';
                    }
                    $query = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t\t from vtiger_attachments\n\t\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid\n\t\t\t\t where vtiger_crmentity.setype='{$module_name} {$imageattachment}'\n\t\t\t\t  and vtiger_attachments.name = ?\n\t\t\t\t  and vtiger_seattachmentsrel.crmid=?";
                    $params = array($col_fields[$fieldname], $col_fields['record_id']);
                }
                $result_image = $adb->pquery($query, $params);
                for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) {
                    $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid');
                    //decode_html  - added to handle UTF-8   characters in file names
                    //urlencode    - added to handle special characters like #, %, etc.,
                    $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name')));
                    $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name'));
                    $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path');
                }
                if (is_array($image_array)) {
                    for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) {
                        $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr] . $image_id_array[$img_itr] . "_", "orgname" => $image_orgname_array[$img_itr]);
                    }
                } else {
                    $fieldvalue[] = '';
                }
            } else {
                $fieldvalue[] = '';
            }
        } elseif ($uitype == 62) {
            if (isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
            }
            if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') {
                $parent_module = "Accounts";
                $value = $_REQUEST['account_id'];
            }
            if ($parent_module != 'Contacts') {
                if ($parent_module == "Leads") {
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $parent_name = $field_value;
                        }
                    }
                    $lead_selected = "selected";
                } elseif ($parent_module == "Accounts") {
                    $sql = "select * from vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "accountname");
                    $account_selected = "selected";
                } elseif ($parent_module == "Potentials") {
                    $sql = "select * from vtiger_potential where potentialid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "potentialname");
                    $potential_selected = "selected";
                } elseif ($parent_module == "Products") {
                    $sql = "select * from vtiger_products where productid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "productname");
                    $product_selected = "selected";
                } elseif ($parent_module == "PurchaseOrder") {
                    $sql = "select * from vtiger_purchaseorder where purchaseorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $porder_selected = "selected";
                } elseif ($parent_module == "SalesOrder") {
                    $sql = "select * from vtiger_salesorder where salesorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $sorder_selected = "selected";
                } elseif ($parent_module == "Invoice") {
                    $sql = "select * from vtiger_invoice where invoiceid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $invoice_selected = "selected";
                } elseif ($parent_module == "Quotes") {
                    $sql = "select * from vtiger_quotes where quoteid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $quote_selected = "selected";
                } elseif ($parent_module == "HelpDesk") {
                    $sql = "select * from vtiger_troubletickets where ticketid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "title");
                    $ticket_selected = "selected";
                }
            }
            $editview_label[] = array($app_strings['COMBO_LEADS'], $app_strings['COMBO_ACCOUNTS'], $app_strings['COMBO_POTENTIALS'], $app_strings['COMBO_PRODUCTS'], $app_strings['COMBO_INVOICES'], $app_strings['COMBO_PORDER'], $app_strings['COMBO_SORDER'], $app_strings['COMBO_QUOTES'], $app_strings['COMBO_HELPDESK']);
            $editview_label[] = array($lead_selected, $account_selected, $potential_selected, $product_selected, $invoice_selected, $porder_selected, $sorder_selected, $quote_selected, $ticket_selected);
            $editview_label[] = array("Leads&action=Popup", "Accounts&action=Popup", "Potentials&action=Popup", "Products&action=Popup", "Invoice&action=Popup", "PurchaseOrder&action=Popup", "SalesOrder&action=Popup", "Quotes&action=Popup", "HelpDesk&action=Popup");
            $fieldvalue[] = $parent_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 66) {
            if (!empty($_REQUEST['parent_id'])) {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if (!empty($value)) {
                $parent_module = getSalesEntityType($value);
                if ($parent_module != "Contacts") {
                    $entity_names = getEntityName($parent_module, $value);
                    $parent_name = $entity_names[$value];
                    $fieldvalue[] = $parent_name;
                    $fieldvalue[] = $value;
                }
            }
            // Check for vtiger_activity type if task orders to be added in select option
            $act_mode = $_REQUEST['activity_mode'];
            $parentModulesList = array('Leads' => $app_strings['COMBO_LEADS'], 'Accounts' => $app_strings['COMBO_ACCOUNTS'], 'Potentials' => $app_strings['COMBO_POTENTIALS'], 'HelpDesk' => $app_strings['COMBO_HELPDESK'], 'Campaigns' => $app_strings['COMBO_CAMPAIGNS'], 'Vendors' => $app_strings['COMBO_VENDORS']);
            if ($act_mode == "Task") {
                $parentModulesList['Quotes'] = $app_strings['COMBO_QUOTES'];
                $parentModulesList['PurchaseOrder'] = $app_strings['COMBO_PORDER'];
                $parentModulesList['SalesOrder'] = $app_strings['COMBO_SORDER'];
                $parentModulesList['Invoice'] = $app_strings['COMBO_INVOICES'];
            }
            $parentModuleNames = array_keys($parentModulesList);
            $parentModuleLabels = array_values($parentModulesList);
            $editview_label[0] = $parentModuleLabels;
            $editview_label[1] = array_fill(0, count($parentModulesList), '');
            $selectedModuleIndex = array_search($parent_module, $parentModuleNames);
            if ($selectedModuleIndex > -1) {
                $editview_label[1][$selectedModuleIndex] = 'selected';
            }
            $parentModulePopupUrl = array();
            foreach ($parentModuleNames as $parentModule) {
                $parentModulePopupUrl[] = $parentModule . '&action=Popup';
            }
            $editview_label[2] = $parentModulePopupUrl;
        } elseif ($uitype == 357) {
            $pmodule = $_REQUEST['pmodule'];
            if (empty($pmodule)) {
                $pmodule = $_REQUEST['par_module'];
            }
            if ($pmodule == 'Contacts') {
                $contact_selected = 'selected';
            } elseif ($pmodule == 'Accounts') {
                $account_selected = 'selected';
            } elseif ($pmodule == 'Leads') {
                $lead_selected = 'selected';
            } elseif ($pmodule == 'Vendors') {
                $vendor_selected = 'selected';
            } elseif ($pmodule == 'Users') {
                $user_selected = 'selected';
            } elseif ($pmodule == 'Project') {
                $project_selected = 'selected';
            } elseif ($pmodule == 'ProjectTask') {
                $projecttask_selected = 'selected';
            } elseif ($pmodule == 'Potentials') {
                $potentials_selected = 'selected';
            } elseif ($pmodule == 'HelpDesk') {
                $helpdesk_selected = 'selected';
            }
            if (isset($_REQUEST['emailids']) && $_REQUEST['emailids'] != '') {
                $parent_id = $_REQUEST['emailids'];
                $parent_name = '';
                $myids = explode("|", $parent_id);
                for ($i = 0; $i < count($myids) - 1; $i++) {
                    $realid = explode("@", $myids[$i]);
                    $entityid = $realid[0];
                    $nemail = count($realid);
                    if ($pmodule == 'Accounts') {
                        require_once 'modules/Accounts/Accounts.php';
                        $myfocus = new Accounts();
                        $myfocus->retrieve_entity_info($entityid, "Accounts");
                        $fullname = br2nl($myfocus->column_fields['accountname']);
                        $account_selected = 'selected';
                    } elseif ($pmodule == 'Contacts') {
                        require_once 'modules/Contacts/Contacts.php';
                        $myfocus = new Contacts();
                        $myfocus->retrieve_entity_info($entityid, "Contacts");
                        $fname = br2nl($myfocus->column_fields['firstname']);
                        $lname = br2nl($myfocus->column_fields['lastname']);
                        $fullname = $lname . ' ' . $fname;
                        $contact_selected = 'selected';
                    } elseif ($pmodule == 'Leads') {
                        require_once 'modules/Leads/Leads.php';
                        $myfocus = new Leads();
                        $myfocus->retrieve_entity_info($entityid, "Leads");
                        $fname = br2nl($myfocus->column_fields['firstname']);
                        $lname = br2nl($myfocus->column_fields['lastname']);
                        $fullname = $lname . ' ' . $fname;
                        $lead_selected = 'selected';
                    } elseif ($pmodule == 'Project') {
                        require_once 'modules/Project/Project.php';
                        $myfocus = new Project();
                        $myfocus->retrieve_entity_info($entityid, "Project");
                        $fname = br2nl($myfocus->column_fields['projectname']);
                        $lname = br2nl($myfocus->column_fields['projectid']);
                        $fullname = $fname;
                        $project_selected = 'selected';
                    } elseif ($pmodule == 'ProjectTask') {
                        require_once 'modules/ProjectTask/ProjectTask.php';
                        $myfocus = new ProjectTask();
                        $myfocus->retrieve_entity_info($entityid, "ProjectTask");
                        $fname = br2nl($myfocus->column_fields['projecttaskname']);
                        $lname = br2nl($myfocus->column_fields['projecttaskid']);
                        $fullname = $fname;
                        $projecttask_selected = 'selected';
                    } elseif ($pmodule == 'Potentials') {
                        require_once 'modules/Potentials/Potentials.php';
                        $myfocus = new Potentials();
                        $myfocus->retrieve_entity_info($entityid, "Potentials");
                        $fname = br2nl($myfocus->column_fields['potentialname']);
                        $lname = br2nl($myfocus->column_fields['potentialid']);
                        $fullname = $fname;
                        $potentials_selected = 'selected';
                    } elseif ($pmodule == 'HelpDesk') {
                        require_once 'modules/HelpDesk/HelpDesk.php';
                        $myfocus = new HelpDesk();
                        $myfocus->retrieve_entity_info($entityid, "HelpDesk");
                        $fname = br2nl($myfocus->column_fields['title']);
                        $lname = br2nl($myfocus->column_fields['ticketid']);
                        $fullname = $fname;
                        $helpdesk_selected = 'selected';
                    }
                    for ($j = 1; $j < $nemail; $j++) {
                        $querystr = 'select columnname from vtiger_field where fieldid=? and vtiger_field.presence in (0,2)';
                        $result = $adb->pquery($querystr, array($realid[$j]));
                        $temp = $adb->query_result($result, 0, 'columnname');
                        $temp1 = br2nl($myfocus->column_fields[$temp]);
                        //Modified to display the entities in red which don't have email id
                        if (!empty($temp_parent_name) && strlen($temp_parent_name) > 150) {
                            $parent_name .= '<br>';
                            $temp_parent_name = '';
                        }
                        if ($temp1 != '') {
                            $parent_name .= $fullname . '&lt;' . $temp1 . '&gt;; ';
                            $temp_parent_name .= $fullname . '&lt;' . $temp1 . '&gt;; ';
                        } else {
                            $parent_name .= "<b style='color:red'>" . $fullname . '&lt;' . $temp1 . '&gt;; ' . "</b>";
                            $temp_parent_name .= "<b style='color:red'>" . $fullname . '&lt;' . $temp1 . '&gt;; ' . "</b>";
                        }
                    }
                }
            } else {
                if ($_REQUEST['record'] != '' && $_REQUEST['record'] != NULL) {
                    $parent_name = '';
                    $parent_id = '';
                    $myemailid = $_REQUEST['record'];
                    $mysql = "select crmid from vtiger_seactivityrel where activityid=?";
                    $myresult = $adb->pquery($mysql, array($myemailid));
                    $mycount = $adb->num_rows($myresult);
                    if ($mycount > 0) {
                        for ($i = 0; $i < $mycount; $i++) {
                            $mycrmid = $adb->query_result($myresult, $i, 'crmid');
                            $parent_module = getSalesEntityType($mycrmid);
                            if ($parent_module == "Leads") {
                                $sql = "select firstname,lastname,email from vtiger_leaddetails where leadid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $full_name = getFullNameFromQResult($result, 0, "Leads");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $full_name . '<' . $myemail . '>; ';
                                $lead_selected = 'selected';
                            } elseif ($parent_module == "Contacts") {
                                $sql = "select * from vtiger_contactdetails where contactid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $full_name = getFullNameFromQResult($result, 0, "Contacts");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $full_name . '<' . $myemail . '>; ';
                                $contact_selected = 'selected';
                            } elseif ($parent_module == "Accounts") {
                                $sql = "select * from vtiger_account where accountid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $account_name = $adb->query_result($result, 0, "accountname");
                                $myemail = $adb->query_result($result, 0, "email1");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $account_name . '<' . $myemail . '>; ';
                                $account_selected = 'selected';
                            } elseif ($parent_module == "Users") {
                                $sql = "select user_name,email1 from vtiger_users where id=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $account_name = $adb->query_result($result, 0, "user_name");
                                $myemail = $adb->query_result($result, 0, "email1");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $account_name . '<' . $myemail . '>; ';
                                $user_selected = 'selected';
                            } elseif ($parent_module == "Vendors") {
                                $sql = "select * from vtiger_vendor where vendorid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $vendor_name = $adb->query_result($result, 0, "vendorname");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $vendor_name . '<' . $myemail . '>; ';
                                $vendor_selected = 'selected';
                            }
                        }
                    }
                }
                $custfld .= '<td width="20%" class="dataLabel">' . $app_strings['To'] . '&nbsp;</td>';
                $custfld .= '<td width="90%" colspan="3"><input name="parent_id" type="hidden" value="' . $parent_id . '"><textarea readonly name="parent_name" cols="70" rows="2">' . $parent_name . '</textarea>&nbsp;<select name="parent_type" >';
                $custfld .= '<OPTION value="Contacts" selected>' . $app_strings['COMBO_CONTACTS'] . '</OPTION>';
                $custfld .= '<OPTION value="Accounts" >' . $app_strings['COMBO_ACCOUNTS'] . '</OPTION>';
                $custfld .= '<OPTION value="Leads" >' . $app_strings['COMBO_LEADS'] . '</OPTION>';
                $custfld .= '<OPTION value="Vendors" >' . $app_strings['COMBO_VENDORS'] . '</OPTION></select><img src="' . vtiger_imageurl('select.gif', $theme) . '" alt="Select" title="Select" LANGUAGE=javascript onclick=\'$log->debug("Exiting getOutputHtml method ..."); return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&popuptype=set_$log->debug("Exiting getOutputHtml method ..."); return_emails&form=EmailEditView&form_submit=false","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");\' align="absmiddle" style=\'cursor:hand;cursor:pointer\'>&nbsp;<input type="image" src="' . vtiger_imageurl('clear_field.gif', $theme) . '" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=\'\';this.form.parent_name.value=\'\';$log->debug("Exiting getOutputHtml method ..."); return false;" align="absmiddle" style=\'cursor:hand;cursor:pointer\'></td>';
                $editview_label[] = array('Contacts' => $contact_selected, 'Accounts' => $account_selected, 'Vendors' => $vendor_selected, 'Leads' => $lead_selected, 'Users' => $user_selected);
                $fieldvalue[] = $parent_name;
                $fieldvalue[] = $parent_id;
            }
        } elseif ($uitype == 68) {
            if (empty($value) && isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Contacts") {
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $parent_name = $field_value;
                        }
                    }
                    $contact_selected = "selected";
                } elseif ($parent_module == "Accounts") {
                    $sql = "select * from vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "accountname");
                    $account_selected = "selected";
                } else {
                    $parent_name = "";
                    $value = "";
                }
            }
            $editview_label[0] = array();
            $editview_label[1] = array();
            $editview_label[2] = array();
            if (vtlib_isModuleActive('Accounts')) {
                array_push($editview_label[0], $app_strings['COMBO_ACCOUNTS']);
                array_push($editview_label[1], $account_selected);
                array_push($editview_label[2], "Accounts");
            }
            if (vtlib_isModuleActive('Contacts')) {
                array_push($editview_label[0], $app_strings['COMBO_CONTACTS']);
                array_push($editview_label[1], $contact_selected);
                array_push($editview_label[2], "Contacts");
            }
            $fieldvalue[] = $parent_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 9 || $uitype == 7) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fldrs = $adb->pquery('select typeofdata from vtiger_field
			where vtiger_field.fieldname=? and vtiger_field.tabid=?', array($fieldname, getTabid($module_name)));
            $typeofdata = $adb->query_result($fldrs, 0, 0);
            $typeinfo = explode('~', $typeofdata);
            if ($typeinfo[0] == 'I') {
                $fieldvalue[] = $value;
            } else {
                $currencyField = new CurrencyField($value);
                $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata);
                $currencyField->initialize($current_user);
                $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces()));
                $fieldvalue[] = $currencyField->getDisplayValue(null, false, true);
            }
        } elseif ($uitype == 71 || $uitype == 72) {
            $currencyField = new CurrencyField($value);
            // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
            if ($col_fields['record_id'] != '' && $uitype == 72) {
                if ($fieldname == 'unit_price') {
                    $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module_name));
                    $currencySymbol = $rate_symbol['symbol'];
                } else {
                    $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']);
                    $currencySymbol = $currency_info['currency_symbol'];
                }
                $fieldvalue[] = $currencyField->getDisplayValue(null, true);
            } else {
                $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata);
                $currencyField->initialize($current_user);
                $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces()));
                $fieldvalue[] = $currencyField->getDisplayValue(null, false, true);
                $currencySymbol = $currencyField->getCurrencySymbol();
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name) . ': (' . $currencySymbol . ')';
        } elseif ($uitype == 75 || $uitype == 81) {
            if ($value != '') {
                $vendor_name = getVendorName($value);
            } elseif (isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id'] != '') {
                $value = $_REQUEST['vendor_id'];
                $vendor_name = getVendorName($value);
            }
            $pop_type = 'specific';
            if ($uitype == 81) {
                $pop_type = 'specific_vendor_address';
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $vendor_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 76) {
            if ($value != '') {
                $potential_name = getPotentialName($value);
            } elseif (isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') {
                $value = $_REQUEST['potental_id'];
                $potential_name = getPotentialName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $potential_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 78) {
            if ($value != '') {
                $quote_name = getQuoteName($value);
            } elseif (isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '') {
                $value = $_REQUEST['quote_id'];
                $potential_name = getQuoteName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $quote_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 79) {
            if ($value != '') {
                $purchaseorder_name = getPoName($value);
            } elseif (isset($_REQUEST['purchaseorder_id']) && $_REQUEST['purchaseorder_id'] != '') {
                $value = $_REQUEST['purchaseorder_id'];
                $purchaseorder_name = getPoName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $purchaseorder_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 80) {
            if ($value != '') {
                $salesorder_name = getSoName($value);
            } elseif (isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') {
                $value = $_REQUEST['salesorder_id'];
                $salesorder_name = getSoName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $salesorder_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 30) {
            $rem_days = 0;
            $rem_hrs = 0;
            $rem_min = 0;
            if ($value != '') {
                $SET_REM = 'CHECKED';
            } else {
                $SET_REM = '';
            }
            $rem_days = floor($col_fields[$fieldname] / (24 * 60));
            $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60);
            $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60;
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $day_options = getReminderSelectOption(0, 31, 'remdays', $rem_days);
            $hr_options = getReminderSelectOption(0, 23, 'remhrs', $rem_hrs);
            $min_options = getReminderSelectOption(10, 59, 'remmin', $rem_min);
            $fieldvalue[] = array(array(0, 32, 'remdays', getTranslatedString('LBL_DAYS', 'Calendar'), $rem_days), array(0, 24, 'remhrs', getTranslatedString('LBL_HOURS', 'Calendar'), $rem_hrs), array(10, 60, 'remmin', getTranslatedString('LBL_MINUTES', 'Calendar') . '&nbsp;&nbsp;' . getTranslatedString('LBL_BEFORE_EVENT', 'Calendar'), $rem_min));
            $fieldvalue[] = array($SET_REM, getTranslatedString('LBL_YES'), getTranslatedString('LBL_NO'));
            $SET_REM = '';
        } elseif ($uitype == 115) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname);
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname));
                if ($value == $pickListValue) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
            }
            $fieldvalue[] = $options;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 116 || $uitype == 117) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name');
                $currency_id = $adb->query_result($pickListResult, $j, 'id');
                if ($value == $currency_id) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[$currency_id] = array($pickListValue => $chk_val);
            }
            $fieldvalue[] = $options;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 98) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = getRoleName($value);
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 105) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if (isset($col_fields['record_id']) && $col_fields['record_id'] != '') {
                $query = "select vtiger_attachments.path, vtiger_attachments.name from vtiger_contactdetails left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_contactdetails.contactid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where vtiger_contactdetails.imagename=vtiger_attachments.name and contactid=?";
                $result_image = $adb->pquery($query, array($col_fields['record_id']));
                for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) {
                    $image_array[] = $adb->query_result($result_image, $image_iter, 'name');
                    $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path');
                }
            }
            if (is_array($image_array)) {
                for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) {
                    $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr]);
                }
            } else {
                $fieldvalue[] = '';
            }
        } elseif ($uitype == 101) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = getOwnerName($value);
            $fieldvalue[] = $value;
        } elseif ($uitype == 26) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $folderid = $col_fields['folderid'];
            $foldername_query = 'select foldername from vtiger_attachmentsfolder where folderid = ?';
            $res = $adb->pquery($foldername_query, array($folderid));
            $foldername = $adb->query_result($res, 0, 'foldername');
            if ($foldername != '' && $folderid != '') {
                $fldr_name[$folderid] = $foldername;
            }
            $sql = "select foldername,folderid from vtiger_attachmentsfolder order by foldername";
            $res = $adb->pquery($sql, array());
            for ($i = 0; $i < $adb->num_rows($res); $i++) {
                $fid = $adb->query_result($res, $i, "folderid");
                $fldr_name[$fid] = $adb->query_result($res, $i, "foldername");
            }
            $fieldvalue[] = $fldr_name;
        } elseif ($uitype == 27) {
            if ($value == 'E') {
                $external_selected = "selected";
                $filename = $col_fields['filename'];
            } else {
                $internal_selected = "selected";
                $filename = $col_fields['filename'];
            }
            $editview_label[] = array(getTranslatedString('Internal'), getTranslatedString('External'));
            $editview_label[] = array($internal_selected, $external_selected);
            $editview_label[] = array("I", "E");
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = $filename;
        } elseif ($uitype == '31') {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $options = array();
            $themeList = get_themes();
            foreach ($themeList as $theme) {
                if ($value == $theme) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($theme), $theme, $selected);
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == '32') {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $options = array();
            $languageList = Vtiger_Language::getAll();
            foreach ($languageList as $prefix => $label) {
                if ($value == $prefix) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($label), $prefix, $selected);
            }
            $fieldvalue[] = $options;
        } else {
            //Added condition to set the subject if click Reply All from web mail
            if ($_REQUEST['module'] == 'Emails' && $_REQUEST['mg_subject'] != '') {
                $value = $_REQUEST['mg_subject'];
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($fieldname == 'fileversion') {
                if (empty($value)) {
                    $value = '';
                } else {
                    $fieldvalue[] = $value;
                }
            } else {
                $fieldvalue[] = $value;
            }
        }
    }
    // Mike Crowe Mod --------------------------------------------------------force numerics right justified.
    if (!preg_match("/id=/i", $custfld)) {
        $custfld = preg_replace("/<input/iS", "<input id='{$fieldname}' ", $custfld);
    }
    if (in_array($uitype, array(71, 72, 7, 9, 90))) {
        $custfld = preg_replace("/<input/iS", "<input align=right ", $custfld);
    }
    $final_arr[] = $ui_type;
    $final_arr[] = $editview_label;
    $final_arr[] = $editview_fldname;
    $final_arr[] = $fieldvalue;
    $type_of_data = explode('~', $typeofdata);
    $final_arr[] = $type_of_data[1];
    $log->debug('Exiting getOutputHtml method ...');
    return $final_arr;
}
 function getListViewRecords($focus, $module, $result)
 {
     global $listview_max_textlength, $theme, $default_charset;
     require 'user_privileges/user_privileges_' . $this->user->id . '.php';
     $fields = $this->queryGenerator->getFields();
     $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule());
     $moduleFields = $this->queryGenerator->getModuleFields();
     $accessibleFieldList = array_keys($moduleFields);
     $listViewFields = array_intersect($fields, $accessibleFieldList);
     $referenceFieldList = $this->queryGenerator->getReferenceFieldList();
     foreach ($referenceFieldList as $fieldName) {
         if (in_array($fieldName, $listViewFields)) {
             $field = $moduleFields[$fieldName];
             $this->fetchNameList($field, $result);
         }
     }
     $db = PearDatabase::getInstance();
     $rowCount = $db->num_rows($result);
     $ownerFieldList = $this->queryGenerator->getOwnerFieldList();
     foreach ($ownerFieldList as $fieldName) {
         if (in_array($fieldName, $listViewFields)) {
             $field = $moduleFields[$fieldName];
             $idList = array();
             for ($i = 0; $i < $rowCount; $i++) {
                 $id = $this->db->query_result($result, $i, $field->getColumnName());
                 if (!isset($this->ownerNameList[$fieldName][$id])) {
                     $idList[] = $id;
                 }
             }
             if (count($idList) > 0) {
                 if (!is_array($this->ownerNameList[$fieldName])) {
                     $this->ownerNameList[$fieldName] = getOwnerNameList($idList);
                 } else {
                     //array_merge API loses key information so need to merge the arrays
                     // manually.
                     $newOwnerList = getOwnerNameList($idList);
                     foreach ($newOwnerList as $id => $name) {
                         $this->ownerNameList[$fieldName][$id] = $name;
                     }
                 }
             }
         }
     }
     foreach ($listViewFields as $fieldName) {
         $field = $moduleFields[$fieldName];
         if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) {
             $this->setupAccessiblePicklistValueList($fieldName);
         }
     }
     $useAsterisk = get_use_asterisk($this->user->id);
     $data = array();
     for ($i = 0; $i < $rowCount; ++$i) {
         //Getting the recordId
         if ($module != 'Users') {
             $baseTable = $meta->getEntityBaseTable();
             $moduleTableIndexList = $meta->getEntityTableIndexList();
             $baseTableIndex = $moduleTableIndexList[$baseTable];
             $recordId = $db->query_result($result, $i, $baseTableIndex);
         } else {
             $recordId = $db->query_result($result, $i, "id");
         }
         $row = array();
         foreach ($listViewFields as $fieldName) {
             $field = $moduleFields[$fieldName];
             $uitype = $field->getUIType();
             $rawValue = $this->db->query_result($result, $i, $field->getColumnName());
             if (in_array($uitype, array(15, 33, 16))) {
                 $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset);
             } else {
                 $value = $rawValue;
             }
             if ($module == 'Documents' && $fieldName == 'filename') {
                 $downloadtype = $db->query_result($result, $i, 'filelocationtype');
                 $fileName = $db->query_result($result, $i, 'filename');
                 $downloadType = $db->query_result($result, $i, 'filelocationtype');
                 $status = $db->query_result($result, $i, 'filestatus');
                 $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?";
                 $fileIdRes = $db->pquery($fileIdQuery, array($recordId));
                 $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid');
                 if ($fileName != '' && $status == 1) {
                     if ($downloadType == 'I') {
                         $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="index.php?module=Documents&action=DownloadFile&record=' . $recordId . '&fileid=' . $fileId . '"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>';
                     } elseif ($downloadType == 'E') {
                         $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="' . $fileName . '" target="_blank"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>';
                     } else {
                         $value = ' --';
                     }
                 }
                 $value = $fileicon . $value;
             } elseif ($module == 'Documents' && $fieldName == 'filesize') {
                 $downloadType = $db->query_result($result, $i, '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 = ' --';
                 }
             } elseif ($module == 'Documents' && $fieldName == 'filestatus') {
                 if ($value == 1) {
                     $value = getTranslatedString('yes', $module);
                 } elseif ($value == 0) {
                     $value = getTranslatedString('no', $module);
                 } else {
                     $value = '--';
                 }
             } elseif ($module == 'Documents' && $fieldName == 'filetype') {
                 $downloadType = $db->query_result($result, $i, 'filelocationtype');
                 if ($downloadType == 'E' || $downloadType != 'I') {
                     $value = '--';
                 }
             } elseif ($module == 'OSSTimeControl' && $fieldName == 'sum_time') {
                 $value = Vtiger_Functions::decimalTimeFormat($value);
                 $value = $value['short'];
             } elseif ($field->getUIType() == '27') {
                 if ($value == 'I') {
                     $value = getTranslatedString('LBL_INTERNAL', $module);
                 } elseif ($value == 'E') {
                     $value = getTranslatedString('LBL_EXTERNAL', $module);
                 } else {
                     $value = ' --';
                 }
                 $value = Vtiger_Functions::textLength($value);
             } elseif ($field->getFieldDataType() == 'picklist') {
                 $value = Vtiger_Language_Handler::getTranslatedString($value, $module);
                 $value = textlength_check($value);
             } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') {
                 if ($value != '' && $value != '0000-00-00') {
                     $fieldDataType = $field->getFieldDataType();
                     if ($module == 'Calendar' && ($fieldName == 'date_start' || $fieldName == 'due_date')) {
                         if ($fieldName == 'date_start') {
                             $timeField = 'time_start';
                         } else {
                             if ($fieldName == 'due_date') {
                                 $timeField = 'time_end';
                             }
                         }
                         $timeFieldValue = $this->db->query_result($result, $i, $timeField);
                         if (!empty($timeFieldValue)) {
                             $value .= ' ' . $timeFieldValue;
                             //TO make sure it takes time value as well
                             $fieldDataType = 'datetime';
                         }
                     }
                     if ($fieldDataType == 'datetime') {
                         $value = Vtiger_Datetime_UIType::getDateTimeValue($value);
                     } else {
                         if ($fieldDataType == 'date') {
                             $date = new DateTimeField($value);
                             $value = $date->getDisplayDate();
                         }
                     }
                 } elseif ($value == '0000-00-00') {
                     $value = '';
                 }
             } elseif ($field->getFieldDataType() == 'time') {
                 if (!empty($value)) {
                     $userModel = Users_Privileges_Model::getCurrentUserModel();
                     if ($userModel->get('hour_format') == '12') {
                         $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value);
                     }
                 }
             } elseif ($field->getFieldDataType() == 'currency') {
                 if ($value != '') {
                     if ($field->getUIType() == 72) {
                         if ($fieldName == 'unit_price') {
                             $currencyId = getProductBaseCurrency($recordId, $module);
                             $cursym_convrate = getCurrencySymbolandCRate($currencyId);
                             $currencySymbol = $cursym_convrate['symbol'];
                         } else {
                             $currencyInfo = getInventoryCurrencyInfo($module, $recordId);
                             $currencySymbol = $currencyInfo['currency_symbol'];
                         }
                         $value = CurrencyField::convertToUserFormat($value, null, true);
                         $row['currencySymbol'] = $currencySymbol;
                         $value = CurrencyField::appendCurrencySymbol($value, $currencySymbol);
                     } else {
                         if (!empty($value)) {
                             $value = CurrencyField::convertToUserFormat($value);
                             $currencyModal = new CurrencyField($value);
                             $currencyModal->initialize();
                             $value = $currencyModal->appendCurrencySymbol($value, $currencyModal->currencySymbol);
                         }
                     }
                 }
             } elseif ($field->getFieldDataType() == 'url') {
                 $matchPattern = "^[\\w]+:\\/\\/^";
                 preg_match($matchPattern, $rawValue, $matches);
                 if (!empty($matches[0])) {
                     $value = '<a class="urlField cursorPointer" title="' . $rawValue . '" href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>';
                 } else {
                     $value = '<a class="urlField cursorPointer" title="' . $rawValue . '" href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>';
                 }
             } elseif ($field->getFieldDataType() == 'email') {
                 $current_user = vglobal('current_user');
                 if ($current_user->internal_mailer == 1) {
                     //check added for email link in user detailview
                     $value = "<a class='emailField' onclick=\"Vtiger_Helper_Js.getInternalMailer({$recordId}," . "'{$fieldName}','{$module}');\">" . textlength_check($value) . "</a>";
                 } else {
                     $value = '<a class="emailField" href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>';
                 }
             } elseif ($field->getFieldDataType() == 'boolean') {
                 if ($value === 'on') {
                     $value = 1;
                 } else {
                     if ($value == 'off') {
                         $value = 0;
                     }
                 }
                 if ($value == 1) {
                     $value = getTranslatedString('yes', $module);
                 } elseif ($value == 0) {
                     $value = getTranslatedString('no', $module);
                 } else {
                     $value = '--';
                 }
             } elseif ($field->getUIType() == 98) {
                 $value = '<a href="index.php?module=Roles&parent=Settings&view=Edit&record=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>';
             } elseif ($field->getFieldDataType() == 'multipicklist') {
                 $value = $value != "" ? str_replace(' |##| ', ', ', $value) : "";
                 if (!$is_admin && $value != '') {
                     $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array();
                     $tmp = '';
                     $tmpArray = array();
                     foreach ($valueArray as $index => $val) {
                         if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) {
                             $tmpArray[] = $val;
                             $tmp .= ', ' . $val;
                         } else {
                             $tmpArray[] = '...';
                             $tmp .= '...';
                         }
                     }
                     $value = implode(', ', $tmpArray);
                     $value = textlength_check($value);
                 }
             } elseif ($field->getFieldDataType() == 'skype') {
                 $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : "";
             } elseif ($field->getUIType() == 11) {
                 $outgoingCallPermission = Vtiger_Mobile_Model::checkPermissionForOutgoingCall();
                 if ($outgoingCallPermission && !empty($value)) {
                     $phoneNumber = preg_replace('/[-()\\s]/', '', $value);
                     $value = '<a class="phoneField" data-phoneNumber="' . $phoneNumber . '" record="' . $recordId . '" onclick="Vtiger_Mobile_Js.registerOutboundCall(\'' . $phoneNumber . '\', ' . $recordId . ')">' . textlength_check($value) . '</a>';
                     $callUsers = Vtiger_Mobile_Model::getPrivilegesUsers();
                     if ($callUsers) {
                         $value .= '  <a class="btn btn-xs noLinkBtn" onclick="Vtiger_Mobile_Js.registerOutboundCallToUser(this,\'' . $phoneNumber . '\',' . $recordId . ')" data-placement="right" data-original-title="' . vtranslate('LBL_SELECT_USER_TO_CALL', $module) . '" data-content=\'<select class="select sesectedUser" name="sesectedUser">';
                         foreach ($callUsers as $key => $item) {
                             $value .= '<option value="' . $key . '">' . $item . '</option>';
                         }
                         $value .= '</select><br /><a class="btn btn-success popoverCallOK">' . vtranslate('LBL_BTN_CALL', $module) . '</a>   <a class="btn btn-inverse popoverCallCancel">' . vtranslate('LBL_CANCEL', $module) . '</a>\' data-trigger="manual"><i class="icon-user"></i></a>';
                     }
                 } else {
                     $value = textlength_check($value);
                 }
             } elseif ($field->getFieldDataType() == 'reference') {
                 $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList();
                 $moduleList = $referenceFieldInfoList[$fieldName];
                 if (count($moduleList) == 1) {
                     $parentModule = reset($moduleList);
                 } else {
                     $parentModule = $this->typeList[$value];
                 }
                 if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) {
                     $parentMeta = $this->queryGenerator->getMeta($parentModule);
                     $value = textlength_check($this->nameList[$fieldName][$value]);
                     if ($parentMeta->isModuleEntity() && $parentModule != "Users") {
                         $value = "<a class='moduleColor_{$parentModule}' href='?module={$parentModule}&view=Detail&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>";
                     }
                 } else {
                     $value = '--';
                 }
             } elseif ($field->getFieldDataType() == 'owner') {
                 $value = textlength_check($this->ownerNameList[$fieldName][$value]);
             } elseif ($field->getUIType() == 25) {
                 //TODO clean request object reference.
                 $contactId = $_REQUEST['record'];
                 $emailId = $this->db->query_result($result, $i, "activityid");
                 $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId));
                 $value = $this->db->query_result($result1, 0, "access_count");
                 if (!$value) {
                     $value = 0;
                 }
             } elseif ($field->getUIType() == 8) {
                 if (!empty($value)) {
                     $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset);
                     $json = new Zend_Json();
                     $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val)));
                 }
             } elseif ($field->getFieldDataType() == 'taxes') {
                 if (!empty($value)) {
                     $valueArray = $value != "" ? explode(',', $value) : [];
                     $tmp = '';
                     $tmpArray = [];
                     $taxs = Vtiger_Taxes_UIType::getTaxes();
                     foreach ($valueArray as $index => $tax) {
                         if (isset($taxs[$tax])) {
                             $tmpArray[] = $taxs[$tax]['value'] . '% - ' . $taxs[$tax]['name'];
                         }
                     }
                     $value = implode(', ', $tmpArray);
                     $value = Vtiger_Functions::textLength($value);
                 }
             } elseif ($field->getFieldDataType() == 'inventoryLimit') {
                 if (!empty($value)) {
                     $valueArray = $value != "" ? explode(',', $value) : [];
                     $tmp = '';
                     $tmpArray = [];
                     $limits = Vtiger_InventoryLimit_UIType::getLimits();
                     foreach ($valueArray as $index => $limit) {
                         if (isset($limits[$limit])) {
                             $tmpArray[] = $limits[$limit]['value'] . ' - ' . $limits[$limit]['name'];
                         }
                     }
                     $value = implode(', ', $tmpArray);
                     $value = Vtiger_Functions::textLength($value);
                 }
             } elseif ($field->getFieldDataType() == 'multiReferenceValue') {
                 $params = $field->getFieldParams();
                 $fieldModel = Vtiger_Field_Model::getInstanceFromFieldId($params['field']);
                 $valueTmp = trim($value, '|#|');
                 $valueTmp = $valueTmp != "" ? explode('|#|', $valueTmp) : [];
                 foreach ($valueTmp as $index => $tmp) {
                     $valueTmp[$index] = $fieldModel->getUITypeModel()->getDisplayValue($tmp);
                 }
                 $value = implode(', ', $valueTmp);
                 $value = Vtiger_Functions::textLength($value);
             } elseif (in_array($uitype, array(7, 9, 90))) {
                 $value = "<span align='right'>" . textlength_check($value) . "</div>";
             } else {
                 $value = Vtiger_Functions::textLength($value);
             }
             //				// vtlib customization: For listview javascript triggers
             //				$value = "$value <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=".
             //					"'{$fieldName}' vtmodule='$module' style='display:none;'></span>";
             //				// END
             $row[$fieldName] = $value;
         }
         $data[$recordId] = $row;
     }
     return $data;
 }
        $m++;
    }
}
if ($mode == 'edit') {
    $member = array();
    $groupMemberArr = $groupInfo[2];
    foreach ($groupMemberArr as $memberType => $memberValue) {
        foreach ($memberValue as $memberId) {
            if ($memberType == 'groups') {
                $memberName = fetchGroupName($memberId);
                $memberDisplay = "Group::";
            } elseif ($memberType == 'roles') {
                $memberName = getRoleName($memberId);
                $memberDisplay = "Roles::";
            } elseif ($memberType == 'rs') {
                $memberName = getRoleName($memberId);
                $memberDisplay = "RoleAndSubordinates::";
            } elseif ($memberType == 'users') {
                $memberName = getUserFullName($memberId);
                $memberDisplay = "User::";
            }
            $member[] = $memberType . '::' . $memberId;
            $member[] = $memberDisplay . $memberName;
        }
    }
    $smarty->assign("MEMBER", array_chunk($member, 2));
}
$smarty->assign("MOD", return_module_language($current_language, 'Settings'));
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("APP", $app_strings);
$smarty->assign("CMOD", $mod_strings);
Example #8
0
function userTable($row)
{
    ?>
          <form action="{{BASE}}admin/<?php 
    if (empty($row)) {
        echo "adduser";
    } else {
        echo "edituser";
    }
    ?>
" method="post">
          
          <input type="hidden" name="which" value="<?php 
    if (!empty($row)) {
        echo $row["idhost"];
    }
    ?>
">
          
          <div class="table-desc" style="background-image:url({{BASE}}img/user.png)"><label for="hostname">Name:</label></div>
          <div class="table-item"><input name="hostname" id="hostname" type="text" value="<?php 
    echo htmlspecialchars($row["hostname"]);
    ?>
" maxlength="<?php 
    echo MAX_USERNAME_LENGTH;
    ?>
" required style="width:50%"></div>

          <div class="table-desc" style="background-image:url({{BASE}}img/key.png)"><label for="password">Password:</label></div>
          <div class="table-item"><input name="password" id="password" type="password" required style="width:50%"></div>

          <div class="table-desc" style="background-image:url({{BASE}}img/key.png)"><label for="password_rep">Again:</label></div>
          <div class="table-item"><input name="password_rep" id="password_rep" type="password" required style="width:50%"></div>

          <div class="table-desc" style="background-image:url({{BASE}}img/vcard.png)"><label for="role">User Role:</label></div>
          <div class="table-item">
            <select name="role" id="role" size="1">
            <?php 
    $roles = array(ACCESS_HOST, ACCESS_USERDB, ACCESS_FULLADMIN);
    foreach ($roles as $role) {
        if (canAddRole($role) || !empty($row) && $role == $row["access_level"]) {
            echo '<option value="', $role, '"', $role == $row["access_level"] ? ' selected="selected"' : '', '>', htmlspecialchars(getRoleName($role)), '</option>';
        }
    }
    ?>
            </select>
          </div>

          <div class="table-desc">&nbsp;</div>
          <div class="table-item"><input type="submit"></div>
          </form>
    <?php 
}
 function getListViewRecords($focus, $module, $result)
 {
     global $listview_max_textlength, $theme, $default_charset;
     require 'user_privileges/user_privileges_' . $this->user->id . '.php';
     $fields = $this->queryGenerator->getFields();
     $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule());
     $moduleFields = $meta->getModuleFields();
     $accessibleFieldList = array_keys($moduleFields);
     $listViewFields = array_intersect($fields, $accessibleFieldList);
     $referenceFieldList = $this->queryGenerator->getReferenceFieldList();
     foreach ($referenceFieldList as $fieldName) {
         if (in_array($fieldName, $listViewFields)) {
             $field = $moduleFields[$fieldName];
             $this->fetchNameList($field, $result);
         }
     }
     $db = PearDatabase::getInstance();
     $rowCount = $db->num_rows($result);
     $ownerFieldList = $this->queryGenerator->getOwnerFieldList();
     foreach ($ownerFieldList as $fieldName) {
         if (in_array($fieldName, $listViewFields)) {
             $field = $moduleFields[$fieldName];
             $idList = array();
             for ($i = 0; $i < $rowCount; $i++) {
                 $id = $this->db->query_result($result, $i, $field->getColumnName());
                 if (!isset($this->ownerNameList[$fieldName][$id])) {
                     $idList[] = $id;
                 }
             }
             if (count($idList) > 0) {
                 if (!is_array($this->ownerNameList[$fieldName])) {
                     $this->ownerNameList[$fieldName] = getOwnerNameList($idList);
                 } else {
                     //array_merge API loses key information so need to merge the arrays
                     // manually.
                     $newOwnerList = getOwnerNameList($idList);
                     foreach ($newOwnerList as $id => $name) {
                         $this->ownerNameList[$fieldName][$id] = $name;
                     }
                 }
             }
         }
     }
     foreach ($listViewFields as $fieldName) {
         $field = $moduleFields[$fieldName];
         if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) {
             $this->setupAccessiblePicklistValueList($fieldName);
         }
     }
     $useAsterisk = get_use_asterisk($this->user->id);
     $data = array();
     for ($i = 0; $i < $rowCount; ++$i) {
         //Getting the recordId
         if ($module != 'Users') {
             $baseTable = $meta->getEntityBaseTable();
             $moduleTableIndexList = $meta->getEntityTableIndexList();
             $baseTableIndex = $moduleTableIndexList[$baseTable];
             $recordId = $db->query_result($result, $i, $baseTableIndex);
         } else {
             $recordId = $db->query_result($result, $i, "id");
         }
         $row = array();
         foreach ($listViewFields as $fieldName) {
             $field = $moduleFields[$fieldName];
             $uitype = $field->getUIType();
             $rawValue = $this->db->query_result($result, $i, $field->getColumnName());
             if ($uitype != 8) {
                 $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset);
             } else {
                 $value = $rawValue;
             }
             if ($module == 'Documents' && $fieldName == 'filename') {
                 $downloadtype = $db->query_result($result, $i, 'filelocationtype');
                 $fileName = $db->query_result($result, $i, 'filename');
                 $downloadType = $db->query_result($result, $i, 'filelocationtype');
                 $status = $db->query_result($result, $i, 'filestatus');
                 $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?";
                 $fileIdRes = $db->pquery($fileIdQuery, array($recordId));
                 $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid');
                 if ($fileName != '' && $status == 1) {
                     if ($downloadType == 'I') {
                         $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="index.php?module=Documents&action=DownloadFile&record=' . $recordId . '&fileid=' . $fileId . '"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>';
                     } elseif ($downloadType == 'E') {
                         $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="' . $fileName . '" target="_blank"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>';
                     } else {
                         $value = ' --';
                     }
                 }
                 $value = $fileicon . $value;
             } elseif ($module == 'Documents' && $fieldName == 'filesize') {
                 $downloadType = $db->query_result($result, $i, '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 = ' --';
                 }
             } elseif ($module == 'Documents' && $fieldName == 'filestatus') {
                 if ($value == 1) {
                     $value = getTranslatedString('yes', $module);
                 } elseif ($value == 0) {
                     $value = getTranslatedString('no', $module);
                 } else {
                     $value = '--';
                 }
             } elseif ($module == 'Documents' && $fieldName == 'filetype') {
                 $downloadType = $db->query_result($result, $i, 'filelocationtype');
                 if ($downloadType == 'E' || $downloadType != 'I') {
                     $value = '--';
                 }
             } elseif ($field->getUIType() == '27') {
                 if ($value == 'I') {
                     $value = getTranslatedString('LBL_INTERNAL', $module);
                 } elseif ($value == 'E') {
                     $value = getTranslatedString('LBL_EXTERNAL', $module);
                 } else {
                     $value = ' --';
                 }
             } elseif ($field->getFieldDataType() == 'picklist') {
                 //not check for permissions for non admin users for status and activity type field
                 if ($module == 'Calendar' && ($fieldName == 'taskstatus' || $fieldName == 'eventstatus' || $fieldName == 'activitytype')) {
                     $value = Vtiger_Language_Handler::getTranslatedString($value, $module);
                     $value = textlength_check($value);
                 } else {
                     if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName]) && strtolower($value) != '--none--' && strtolower($value) != 'none') {
                         $value = "<font color='red'>" . Vtiger_Language_Handler::getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>";
                     } else {
                         $value = Vtiger_Language_Handler::getTranslatedString($value, $module);
                         $value = textlength_check($value);
                     }
                 }
             } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') {
                 if ($value != '' && $value != '0000-00-00') {
                     $fieldDataType = $field->getFieldDataType();
                     if ($module == 'Calendar' && ($fieldName == 'date_start' || $fieldName == 'due_date')) {
                         if ($fieldName == 'date_start') {
                             $timeField = 'time_start';
                         } else {
                             if ($fieldName == 'due_date') {
                                 $timeField = 'time_end';
                             }
                         }
                         $timeFieldValue = $this->db->query_result($result, $i, $timeField);
                         if (!empty($timeFieldValue)) {
                             $value .= ' ' . $timeFieldValue;
                             //TO make sure it takes time value as well
                             $fieldDataType = 'datetime';
                         }
                     }
                     if ($fieldDataType == 'datetime') {
                         $value = Vtiger_Datetime_UIType::getDateTimeValue($value);
                     } else {
                         if ($fieldDataType == 'date') {
                             $date = new DateTimeField($value);
                             $value = $date->getDisplayDate();
                         }
                     }
                 } elseif ($value == '0000-00-00') {
                     $value = '';
                 }
             } elseif ($field->getFieldDataType() == 'time') {
                 if (!empty($value)) {
                     $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value);
                 }
             } elseif ($field->getFieldDataType() == 'currency') {
                 if ($value != '') {
                     if ($field->getUIType() == 72) {
                         if ($fieldName == 'unit_price') {
                             $currencyId = getProductBaseCurrency($recordId, $module);
                             $cursym_convrate = getCurrencySymbolandCRate($currencyId);
                             $currencySymbol = $cursym_convrate['symbol'];
                         } else {
                             $currencyInfo = getInventoryCurrencyInfo($module, $recordId);
                             $currencySymbol = $currencyInfo['currency_symbol'];
                         }
                         $value = CurrencyField::convertToUserFormat($value, null, true);
                         $row['currencySymbol'] = $currencySymbol;
                         //							$value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol);
                     } else {
                         if (!empty($value)) {
                             $value = CurrencyField::convertToUserFormat($value);
                         }
                     }
                 }
             } elseif ($field->getFieldDataType() == 'url') {
                 $matchPattern = "^[\\w]+:\\/\\/^";
                 preg_match($matchPattern, $rawValue, $matches);
                 if (!empty($matches[0])) {
                     $value = '<a class="urlField cursorPointer" href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>';
                 } else {
                     $value = '<a class="urlField cursorPointer" href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>';
                 }
             } elseif ($field->getFieldDataType() == 'email') {
                 global $current_user;
                 if ($current_user->internal_mailer == 1) {
                     //check added for email link in user detailview
                     $value = "<a class='emailField' onclick=\"Vtiger_Helper_Js.getInternalMailer({$recordId}," . "'{$fieldName}');\">" . textlength_check($value) . "</a>";
                 } else {
                     $value = '<a class="emailField" href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>';
                 }
             } elseif ($field->getFieldDataType() == 'boolean') {
                 if ($value === 'on') {
                     $value = 1;
                 } else {
                     if ($value == 'off') {
                         $value = 0;
                     }
                 }
                 if ($value == 1) {
                     $value = getTranslatedString('yes', $module);
                 } elseif ($value == 0) {
                     $value = getTranslatedString('no', $module);
                 } else {
                     $value = '--';
                 }
             } elseif ($field->getUIType() == 98) {
                 $value = '<a href="index.php?module=Roles&parent=Settings&view=Edit&record=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>';
             } elseif ($field->getFieldDataType() == 'multipicklist') {
                 $value = $value != "" ? str_replace(' |##| ', ', ', $value) : "";
                 if (!$is_admin && $value != '') {
                     $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array();
                     $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>";
                     $tmp = '';
                     $tmpArray = array();
                     foreach ($valueArray as $index => $val) {
                         if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) {
                             if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim($val), $this->picklistValueMap[$fieldName])) {
                                 $tmpArray[] = $notaccess;
                                 $tmp .= ', ' . $notaccess;
                             } else {
                                 $tmpArray[] = $val;
                                 $tmp .= ', ' . $val;
                             }
                         } else {
                             $tmpArray[] = '...';
                             $tmp .= '...';
                         }
                     }
                     $value = implode(', ', $tmpArray);
                     $value = textlength_check($value);
                 }
             } elseif ($field->getFieldDataType() == 'skype') {
                 $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : "";
             } elseif ($field->getFieldDataType() == 'phone') {
                 if ($useAsterisk == 'true') {
                     $value = "<a href='javascript:;' onclick='startCall(&quot;{$value}&quot;, " . "&quot;{$recordId}&quot;)'>" . textlength_check($value) . "</a>";
                 } else {
                     $value = textlength_check($value);
                 }
             } elseif ($field->getFieldDataType() == 'reference') {
                 $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList();
                 $moduleList = $referenceFieldInfoList[$fieldName];
                 if (count($moduleList) == 1) {
                     $parentModule = $moduleList[0];
                 } else {
                     $parentModule = $this->typeList[$value];
                 }
                 if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) {
                     $parentMeta = $this->queryGenerator->getMeta($parentModule);
                     $value = textlength_check($this->nameList[$fieldName][$value]);
                     if ($parentMeta->isModuleEntity() && $parentModule != "Users") {
                         $value = "<a href='?module={$parentModule}&view=Detail&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>";
                     }
                 } else {
                     $value = '--';
                 }
             } elseif ($field->getFieldDataType() == 'owner') {
                 $value = textlength_check($this->ownerNameList[$fieldName][$value]);
             } elseif ($field->getUIType() == 25) {
                 //TODO clean request object reference.
                 $contactId = $_REQUEST['record'];
                 $emailId = $this->db->query_result($result, $i, "activityid");
                 $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId));
                 $value = $this->db->query_result($result1, 0, "access_count");
                 if (!$value) {
                     $value = 0;
                 }
             } elseif ($field->getUIType() == 8) {
                 if (!empty($value)) {
                     $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset);
                     $json = new Zend_Json();
                     $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val)));
                 }
             } elseif (in_array($uitype, array(7, 9, 90))) {
                 $value = "<span align='right'>" . textlength_check($value) . "</div>";
             } else {
                 $value = textlength_check($value);
             }
             //				// vtlib customization: For listview javascript triggers
             //				$value = "$value <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=".
             //					"'{$fieldName}' vtmodule='$module' style='display:none;'></span>";
             //				// END
             $row[$fieldName] = $value;
         }
         $data[$recordId] = $row;
     }
     return $data;
 }
/** Gives the group info and the group member info array 
  * @param $groupInfoArr -- Group Info Array got by calling getGroupInfo($groupId):: Type array
  * @param $groupID -- group id::Type integer
  * @param $mod_strings -- i18n mod strings array::Type array
  * @returns $returndata:: Type array, Example array format given below
	Array
	(
    	[0] => Array
        	(
            		[groupname] => vtiger grp
            		[description] => 
        	)

    	[1] => Array
        (
            [Role] => Array
                (
                    [0] => Array
                        (
                            [membername] => CEO
                            [memberid] => H2
                            [membertype] => Role
                            [memberaction] => RoleDetailView
                            [actionparameter] => roleid
                        )

                )

            [Role and Subordinates] => Array
                (
                    [0] => Array
                        (
                            [membername] => Vice President
                            [memberid] => H3
                            [membertype] => Role and Subordinates
                            [memberaction] => RoleDetailView
                            [actionparameter] => roleid
                        )

                )

            [User] => Array
                (
                    [0] => Array
                        (
                            [membername] => standarduser
                            [memberid] => 2
                            [membertype] => User
                            [memberaction] => DetailView
                            [actionparameter] => record
                        )

                )

        )

	)
  *
  *
 */
function getStdOutput($groupInfoArr, $groupId, $mod_strings)
{
    global $adb;
    $groupfields['groupname'] = $groupInfoArr[0];
    $groupfields['description'] = $groupInfoArr[1];
    $row = 1;
    $groupMember = $groupInfoArr[2];
    $information = array();
    foreach ($groupMember as $memberType => $memberValue) {
        $memberinfo = array();
        foreach ($memberValue as $memberId) {
            $groupmembers = array();
            if ($memberType == 'roles') {
                $memberName = getRoleName($memberId);
                $memberAction = "RoleDetailView";
                $memberActionParameter = "roleid";
                $memberDisplayType = "Role";
            } elseif ($memberType == 'rs') {
                $memberName = getRoleName($memberId);
                $memberAction = "RoleDetailView";
                $memberActionParameter = "roleid";
                $memberDisplayType = "Role and Subordinates";
            } elseif ($memberType == 'groups') {
                $memberName = fetchGroupName($memberId);
                $memberAction = "GroupDetailView";
                $memberActionParameter = "groupId";
                $memberDisplayType = "Group";
            } elseif ($memberType == 'users') {
                $memberName = getUserName($memberId);
                $memberAction = "DetailView";
                $memberActionParameter = "record";
                $memberDisplayType = "User";
            }
            $groupmembers['membername'] = $memberName;
            $groupmembers['memberid'] = $memberId;
            $groupmembers['membertype'] = $memberDisplayType;
            $groupmembers['memberaction'] = $memberAction;
            $groupmembers['actionparameter'] = $memberActionParameter;
            $row++;
            $memberinfo[] = $groupmembers;
        }
        if (sizeof($memberinfo) > 0) {
            $information[$memberDisplayType] = $memberinfo;
        }
    }
    $returndata = array($groupfields, $information);
    return $returndata;
}
Example #11
0
    function getListViewEntries($focus, $module, $result, $navigationInfo, $skipActions = false)
    {
        require 'user_privileges/user_privileges_' . $this->user->id . '.php';
        global $listview_max_textlength, $theme, $default_charset, $current_user, $currentModule, $adb;
        $fields = $this->queryGenerator->getFields();
        $whereFields = $this->queryGenerator->getWhereFields();
        $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule());
        $moduleFields = $meta->getModuleFields();
        $accessibleFieldList = array_keys($moduleFields);
        if ($this->queryGenerator->getReferenceFieldInfoList()) {
            $accessibleFieldList = array_merge($this->queryGenerator->getReferenceFieldNameList(), $accessibleFieldList);
        }
        $listViewFields = array_intersect($fields, $accessibleFieldList);
        $referenceFieldList = $this->queryGenerator->getReferenceFieldList();
        foreach ($referenceFieldList as $fieldName) {
            if (in_array($fieldName, $listViewFields)) {
                $field = $moduleFields[$fieldName];
                $this->fetchNameList($field, $result);
            }
        }
        $db = PearDatabase::getInstance();
        $rowCount = $db->num_rows($result);
        $listviewcolumns = $db->getFieldsArray($result);
        $ownerFieldList = $this->queryGenerator->getOwnerFieldList();
        foreach ($ownerFieldList as $fieldName) {
            if (in_array($fieldName, $listViewFields)) {
                if (!empty($moduleFields[$fieldName])) {
                    $field = $moduleFields[$fieldName];
                } else {
                    $field = $this->queryGenerator->getReferenceField($fieldName, false);
                    if (is_null($field)) {
                        continue;
                    }
                }
                $fldcolname = $field->getColumnName();
                $idList = array();
                for ($i = 0; $i < $rowCount; $i++) {
                    $id = $this->db->query_result($result, $i, $fldcolname);
                    if (!isset($this->ownerNameList[$fieldName][$id])) {
                        $idList[] = $id;
                    }
                }
                if (count($idList) > 0) {
                    if (!isset($this->ownerNameList[$fieldName]) or !is_array($this->ownerNameList[$fieldName])) {
                        $this->ownerNameList[$fieldName] = getOwnerNameList($idList);
                    } else {
                        $newOwnerList = getOwnerNameList($idList);
                        $this->ownerNameList[$fieldName] = $this->ownerNameList[$fieldName] + $newOwnerList;
                    }
                }
            }
        }
        foreach ($listViewFields as $fieldName) {
            if (!empty($moduleFields[$fieldName])) {
                $field = $moduleFields[$fieldName];
            } else {
                $field = $this->queryGenerator->getReferenceField($fieldName, false);
                if (is_null($field)) {
                    continue;
                }
            }
            if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) {
                $this->setupAccessiblePicklistValueList($fieldName);
            }
            $idList = array();
            if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) {
                $modrel = getTabModuleName($field->getTabId());
                $fldcolname = 'smowner' . strtolower($modrel);
                $j = $rowCount * $k;
                $k++;
                for ($i = 0; $i < $rowCount; $i++) {
                    $id = $this->db->query_result($result, $i, $fldcolname);
                    if (!isset($this->ownerNameListrel[$fieldName][$id])) {
                        $idList[$j] = $id;
                        $j++;
                    }
                }
            } else {
                if (getTabid($currentModule) != $field->getTabId() && $field->getFieldDataType() == 'reference') {
                    $this->fetchNameList($field, $result, 1);
                }
            }
            if (count($idList) > 0) {
                if (!isset($this->ownerNameListrel[$fieldName]) or !is_array($this->ownerNameListrel[$fieldName])) {
                    $this->ownerNameListrel[$fieldName] = getOwnerNameList($idList);
                } else {
                    $newOwnerList = getOwnerNameList($idList);
                    $this->ownerNameListrel[$fieldName] = $this->ownerNameListrel[$fieldName] + $newOwnerList;
                }
            }
        }
        $useAsterisk = get_use_asterisk($this->user->id);
        $wfs = new VTWorkflowManager($adb);
        $data = array();
        for ($i = 0; $i < $rowCount; ++$i) {
            //Getting the recordId
            if ($module != 'Users') {
                $baseTable = $meta->getEntityBaseTable();
                $moduleTableIndexList = $meta->getEntityTableIndexList();
                $baseTableIndex = $moduleTableIndexList[$baseTable];
                $recordId = $db->query_result($result, $i, $baseTableIndex);
                $ownerId = $db->query_result($result, $i, "smownerid");
            } else {
                $recordId = $db->query_result($result, $i, "id");
            }
            $row = array();
            foreach ($listViewFields as $fieldName) {
                if (!empty($moduleFields[$fieldName])) {
                    $field = $moduleFields[$fieldName];
                } else {
                    $field = $this->queryGenerator->getReferenceField($fieldName, false);
                    if (is_null($field)) {
                        continue;
                    }
                }
                $uitype = $field->getUIType();
                if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) {
                    $modrel = getTabModuleName($field->getTabId());
                    $rawValue = $this->db->query_result($result, $i, "smowner" . strtolower($modrel));
                } else {
                    if (getTabid($currentModule) != $field->getTabId()) {
                        $modrel = getTabModuleName($field->getTabId());
                        $relfieldname = strtolower($modrel) . $field->getColumnName();
                        if (in_array($relfieldname, $listviewcolumns)) {
                            $rawValue = $this->db->query_result($result, $i, $relfieldname);
                        } else {
                            $rawValue = $this->db->query_result($result, $i, $field->getColumnName());
                        }
                    } else {
                        $rawValue = $this->db->query_result($result, $i, $field->getColumnName());
                    }
                }
                if ($module == 'Calendar') {
                    $activityType = $this->db->query_result($result, $i, 'activitytype');
                }
                if ($uitype != 8) {
                    $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset);
                } else {
                    $value = $rawValue;
                }
                if ($module == 'Documents' && $fieldName == 'filename' or $fieldName == 'Documents.filename') {
                    if ($fieldName == 'Documents.filename') {
                        $docrs = $db->pquery('select filename,filelocationtype,filestatus,notesid from vtiger_notes where note_no=?', array($db->query_result($result, $i, 'documentsnote_no')));
                        $downloadtype = $db->query_result($docrs, 0, 'filelocationtype');
                        $fileName = $db->query_result($docrs, 0, 'filename');
                        $status = $db->query_result($docrs, 0, 'filestatus');
                        $docid = $db->query_result($docrs, 0, 'notesid');
                    } else {
                        $docid = $recordId;
                        $downloadtype = $db->query_result($result, $i, 'filelocationtype');
                        $fileName = $db->query_result($result, $i, 'filename');
                        $status = $db->query_result($result, $i, 'filestatus');
                    }
                    $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?";
                    $fileIdRes = $db->pquery($fileIdQuery, array($docid));
                    $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid');
                    if ($downloadtype == 'I') {
                        $ext = substr($value, strrpos($value, ".") + 1);
                        $ext = strtolower($ext);
                        if ($value != '') {
                            if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') {
                                $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                            } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') {
                                $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                            } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') {
                                $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                            } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') {
                                $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>";
                            } else {
                                $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                            }
                        }
                    } elseif ($downloadtype == 'E') {
                        if (trim($value) != '') {
                            $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>";
                        } else {
                            $value = '--';
                            $fileicon = '';
                        }
                    } else {
                        $value = ' --';
                        $fileicon = '';
                    }
                    if ($fileName != '' && $status == 1) {
                        if ($downloadtype == 'I') {
                            $value = "<a href='index.php?module=uploads&action=downloadfile&" . "entityid={$docid}&fileid={$fileId}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$docid});'>" . textlength_check($value) . "</a>";
                        } elseif ($downloadtype == 'E') {
                            $value = "<a target='_blank' href='{$fileName}' onclick='javascript:" . "dldCntIncrease({$docid});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . textlength_check($value) . "</a>";
                        } else {
                            $value = ' --';
                        }
                    }
                    $value = $fileicon . $value;
                } elseif ($module == 'Documents' && $fieldName == 'filesize') {
                    $downloadType = $db->query_result($result, $i, '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 = ' --';
                    }
                } elseif ($module == 'Documents' && $fieldName == 'filestatus') {
                    if ($value == 1) {
                        $value = getTranslatedString('yes', $module);
                    } elseif ($value == 0) {
                        $value = getTranslatedString('no', $module);
                    } else {
                        $value = '--';
                    }
                } elseif ($module == 'Documents' && $fieldName == 'filetype') {
                    $downloadType = $db->query_result($result, $i, 'filelocationtype');
                    if ($downloadType == 'E' || $downloadType != 'I') {
                        $value = '--';
                    }
                } elseif ($field->getUIType() == '27') {
                    if ($value == 'I') {
                        $value = getTranslatedString('LBL_INTERNAL', $module);
                    } elseif ($value == 'E') {
                        $value = getTranslatedString('LBL_EXTERNAL', $module);
                    } else {
                        $value = ' --';
                    }
                } elseif ($field->getFieldDataType() == 'picklist') {
                    if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName])) {
                        $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>";
                    } else {
                        $value = getTranslatedString($value, $module);
                        $value = textlength_check($value);
                    }
                } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') {
                    if ($value != '' && $value != '0000-00-00') {
                        $date = new DateTimeField($value);
                        $value = $date->getDisplayDate();
                        if ($field->getFieldDataType() == 'datetime') {
                            $value .= ' ' . $date->getDisplayTime();
                        }
                    } elseif ($value == '0000-00-00') {
                        $value = '';
                    }
                } elseif ($field->getFieldDataType() == 'currency') {
                    if ($value != '') {
                        if ($field->getUIType() == 72) {
                            if ($fieldName == 'unit_price') {
                                $currencyId = getProductBaseCurrency($recordId, $module);
                                $cursym_convrate = getCurrencySymbolandCRate($currencyId);
                                $currencySymbol = $cursym_convrate['symbol'];
                            } else {
                                $currencyInfo = getInventoryCurrencyInfo($module, $recordId);
                                $currencySymbol = $currencyInfo['currency_symbol'];
                            }
                            $value = number_format($value, 2, '.', '');
                            $currencyValue = CurrencyField::convertToUserFormat($value, null, true);
                            $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol);
                        } else {
                            //changes made to remove vtiger_currency symbol in front of each potential amount
                            if ($value != 0) {
                                $value = CurrencyField::convertToUserFormat($value);
                            }
                        }
                    }
                } elseif ($field->getFieldDataType() == 'url') {
                    $matchPattern = "^[\\w]+:\\/\\/^";
                    preg_match($matchPattern, $rawValue, $matches);
                    if (!empty($matches[0])) {
                        $value = '<a href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>';
                    } else {
                        $value = '<a href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>';
                    }
                } elseif ($field->getFieldDataType() == 'email') {
                    if ($_SESSION['internal_mailer'] == 1) {
                        //check added for email link in user detailview
                        $fieldId = $field->getFieldId();
                        $value = "<a href=\"javascript:InternalMailer({$recordId},{$fieldId}," . "'{$fieldName}','{$module}','record_id');\">" . textlength_check($value) . "</a>";
                    } else {
                        $value = '<a href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>';
                    }
                } elseif ($field->getFieldDataType() == 'boolean') {
                    if ($value == 1) {
                        $value = getTranslatedString('yes', $module);
                    } elseif ($value == 0) {
                        $value = getTranslatedString('no', $module);
                    } else {
                        $value = '--';
                    }
                } elseif ($field->getUIType() == 98) {
                    $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=' . 'Settings&roleid=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>';
                } elseif ($field->getUIType() == 69) {
                    if ($module == 'Products') {
                        $queryPrdt = 'SELECT vtiger_attachments.path,vtiger_attachments.attachmentsid,vtiger_attachments.`name`
							FROM vtiger_attachments
							INNER JOIN vtiger_seattachmentsrel ON vtiger_attachments.attachmentsid = vtiger_seattachmentsrel.attachmentsid
							INNER JOIN vtiger_products ON vtiger_seattachmentsrel.crmid = vtiger_products.productid
							where vtiger_seattachmentsrel.crmid=?';
                        $resultprdt = $this->db->pquery($queryPrdt, array($recordId));
                        if ($resultprdt and $this->db->num_rows($resultprdt) > 0) {
                            $imgpath = $this->db->query_result($resultprdt, 0, 'path');
                            $attid = $this->db->query_result($resultprdt, 0, 'attachmentsid');
                            $imgfilename = $this->db->query_result($resultprdt, 0, 'name');
                            $value = "<div style='text-align:center;width:100%;'><img src='./" . $imgpath . $attid . '_' . $imgfilename . "' height='50'></div>";
                        } else {
                            $value = '';
                        }
                    } else {
                        if ($module == 'Contacts') {
                            $imageattachment = 'Image';
                        } else {
                            $imageattachment = 'Attachment';
                        }
                        //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname];
                        $sql = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t\t\t\t from vtiger_attachments\n\t\t\t\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t\t\t\t  and vtiger_attachments.name = ?\n\t\t\t\t\t\t  and vtiger_seattachmentsrel.crmid=?";
                        $image_res = $this->db->pquery($sql, array(str_replace(' ', '_', $value), $recordId));
                        $image_id = $this->db->query_result($image_res, 0, 'attachmentsid');
                        $image_path = $this->db->query_result($image_res, 0, 'path');
                        $image_name = urlencode(decode_html($this->db->query_result($image_res, 0, 'name')));
                        $imgpath = $image_path . $image_id . "_" . $image_name;
                        if ($image_name != '') {
                            $ftype = $this->db->query_result($image_res, 0, 'type');
                            $isimage = stripos($ftype, 'image') !== false;
                            if ($isimage) {
                                $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image');
                                $value = '<div style="width:100%;text-align:center;"><img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 50px;"></div>';
                            } else {
                                $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents');
                                $value = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>';
                            }
                        } else {
                            $value = '';
                        }
                    }
                } elseif ($field->getFieldDataType() == 'multipicklist') {
                    $value = $value != "" ? str_replace(' |##| ', ', ', $value) : "";
                    if (!$is_admin && $value != '') {
                        $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array();
                        $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>";
                        $tmp = '';
                        $tmpArray = array();
                        foreach ($valueArray as $index => $val) {
                            if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) {
                                if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim(decode_html($val)), $this->picklistValueMap[$fieldName])) {
                                    $tmpArray[] = $notaccess;
                                    $tmp .= ', ' . $notaccess;
                                } else {
                                    $tmpArray[] = $val;
                                    $tmp .= ', ' . $val;
                                }
                            } else {
                                $tmpArray[] = '...';
                                $tmp .= '...';
                            }
                        }
                        $value = implode(', ', $tmpArray);
                        $value = textlength_check($value);
                    }
                } elseif ($field->getUIType() == 1024) {
                    $content = array();
                    if ($value != '') {
                        $arr_evo_actions = explode(' |##| ', $value);
                        for ($fvalues = 0; $fvalues < sizeof($arr_evo_actions); $fvalues++) {
                            $roleid = $arr_evo_actions[$fvalues];
                            $rolename = getRoleName($roleid);
                            $content[$fvalues] = $rolename;
                        }
                    }
                    $value = textlength_check(implode(', ', $content));
                } elseif ($field->getFieldDataType() == 'skype') {
                    $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : "";
                } elseif ($field->getFieldDataType() == 'phone') {
                    if ($useAsterisk == 'true') {
                        $value = "<a href='javascript:;' onclick='startCall(&quot;{$value}&quot;, " . "&quot;{$recordId}&quot;)'>" . textlength_check($value) . "</a>";
                    } else {
                        $value = textlength_check($value);
                    }
                } elseif ($field->getFieldDataType() == 'reference') {
                    $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList();
                    if (getTabid($currentModule) != $field->getTabId()) {
                        $modrel = getTabModuleName($field->getTabId());
                        $fieldName = str_replace($modrel . '.', "", $fieldName);
                    }
                    $moduleList = $referenceFieldInfoList[$fieldName];
                    if (count($moduleList) == 1) {
                        $parentModule = $moduleList[0];
                    } else {
                        $parentModule = $this->typeList[$value];
                    }
                    if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) {
                        $parentMeta = $this->queryGenerator->getMeta($parentModule);
                        $value = textlength_check($this->nameList[$fieldName][$value]);
                        if ($parentMeta->isModuleEntity() && $parentModule != "Users") {
                            $value = "<a href='index.php?module={$parentModule}&action=DetailView&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>";
                            $modMetaInfo = getEntityFieldNames($parentModule);
                            $fieldName = is_array($modMetaInfo['fieldname']) ? $modMetaInfo['fieldname'][0] : $modMetaInfo['fieldname'];
                            // vtlib customization: For listview javascript triggers
                            $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$rawValue}' vtfieldname=" . "'{$fieldName}' vtmodule='{$parentModule}' style='display:none;'></span>";
                        }
                    } else {
                        $value = '--';
                    }
                } elseif ($field->getFieldDataType() == 'owner') {
                    if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) {
                        $value = textlength_check($this->ownerNameListrel[$fieldName][$value]);
                    } else {
                        $value = textlength_check($this->ownerNameList[$fieldName][$value]);
                    }
                } elseif ($field->getUIType() == 25) {
                    //TODO clean request object reference.
                    $contactId = $_REQUEST['record'];
                    $emailId = $this->db->query_result($result, $i, "activityid");
                    $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId));
                    $value = $this->db->query_result($result1, 0, "access_count");
                    if (!$value) {
                        $value = 0;
                    }
                } elseif ($field->getUIType() == 8) {
                    if (!empty($value)) {
                        $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset);
                        $json = new Zend_Json();
                        $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val)));
                    }
                } elseif (in_array($uitype, array(7, 9, 90))) {
                    $value = "<span align='right'>" . textlength_check($value) . "</div>";
                } elseif ($field->getUIType() == 55) {
                    $value = getTranslatedString($value, $currentModule);
                } elseif ($module == 'Emails' && $fieldName == 'subject') {
                    $value = '<a href="javascript:;" onClick="ShowEmail(\'' . $recordId . '\');">' . textlength_check($value) . '</a>';
                } else {
                    $value = textlength_check($value);
                }
                if ($field->getFieldDataType() != 'reference') {
                    $parenttab = getParentTab();
                    $nameFields = $this->queryGenerator->getModuleNameFields($module);
                    $nameFieldList = explode(',', $nameFields);
                    if (($fieldName == $focus->list_link_field or in_array($fieldName, $nameFieldList)) && $module != 'Emails') {
                        $opennewtab = GlobalVariable::getVariable('Application_OpenRecordInNewXOnListView', '', $module);
                        if ($opennewtab == '') {
                            $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>";
                        } elseif ($opennewtab == 'window') {
                            $value = "<a href='#' onclick='window.open(\"index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}\", \"{$module}-{$entity_id}\", \"width=1300, height=900, scrollbars=yes\"); return false;' title='" . getTranslatedString($module, $module) . "'>{$value}</a>";
                        } else {
                            $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "' target='_blank'>{$value}</a>";
                        }
                    }
                    // vtlib customization: For listview javascript triggers
                    $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=" . "'{$fieldName}' vtmodule='{$module}' style='display:none;'></span>";
                }
                $row[] = $value;
            }
            //Added for Actions ie., edit and delete links in listview
            $actionLinkInfo = "";
            if (isPermitted($module, "EditView", "") == 'yes') {
                $racbr = $wfs->getRACRuleForRecord($currentModule, $recordId);
                if (!$racbr or $racbr->hasListViewPermissionTo('edit')) {
                    $edit_link = $this->getListViewEditLink($module, $recordId);
                    if (isset($navigationInfo['start']) && $navigationInfo['start'] > 1 && $module != 'Emails') {
                        $actionLinkInfo .= "<a href=\"{$edit_link}&start=" . $navigationInfo['start'] . "\">" . getTranslatedString("LNK_EDIT", $module) . "</a> ";
                    } else {
                        $actionLinkInfo .= "<a href=\"{$edit_link}\">" . getTranslatedString("LNK_EDIT", $module) . "</a> ";
                    }
                }
            }
            if (isPermitted($module, "Delete", "") == 'yes') {
                $racbr = $wfs->getRACRuleForRecord($currentModule, $recordId);
                if (!$racbr or $racbr->hasListViewPermissionTo('delete')) {
                    $del_link = $this->getListViewDeleteLink($module, $recordId);
                    if ($actionLinkInfo != "" && $del_link != "") {
                        $actionLinkInfo .= ' | ';
                    }
                    if ($del_link != "") {
                        $actionLinkInfo .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . getTranslatedString('LNK_DELETE', $module) . '</a>';
                    }
                }
            }
            // Record Change Notification
            if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) {
                if (!$focus->isViewed($recordId)) {
                    $actionLinkInfo .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>";
                }
            }
            // END
            if ($actionLinkInfo != "" && !$skipActions) {
                $row[] = $actionLinkInfo;
            }
            list($row, $unused, $unused2) = cbEventHandler::do_filter('corebos.filter.listview.render', array($row, $this->db->query_result_rowdata($result, $i), $recordId));
            $data[$recordId] = $row;
        }
        return $data;
    }
function isInterfaceForRole($interface, $roleNr)
{
    return $roleNr == -1 || count($interface['interfaceRoles']) == 0 || in_array(getRoleName($roleNr), $interface['interfaceRoles']);
    // an interface is visible if: no role is selected; the interface does not specify roles; or the interface roles contain $role
}
Example #13
0
    public function getSelectedValuesToSmarty($smarty_obj = "", $step_name = "")
    {
        if ($smarty_obj != "" && $step_name != "") {
            global $app_strings;
            global $mod_strings;
            global $default_charset;
            global $current_language;
            global $image_path;
            global $theme;
            $theme_path = "themes/" . $theme . "/";
            $image_path = $theme_path . "images/";
            $smarty_obj->assign("THEME", $theme_path);
            $smarty_obj->assign("IMAGE_PATH", $image_path);
            $adb = PEARDatabase::getInstance();
            $get_all_steps = "all";
            if (isset($_REQUEST["record"]) && $_REQUEST['record'] != '') {
                $recordid = vtlib_purify($_REQUEST["record"]);
            } else {
                $recordid = "";
            }
            $smarty_obj->assign("RECORDID", $recordid);
            $smarty_obj->assign("DISPLAY_FILTER_HEADER", false);
            if (in_array($step_name, array("ReportsStep1"))) {
                if (isset($_REQUEST["reportname"]) && $_REQUEST["reportname"] != "") {
                    $reportname = htmlspecialchars(vtlib_purify($_REQUEST["reportname"]));
                } else {
                    $reportname = $this->reportinformations["reports4youname"];
                }
                $smarty_obj->assign("REPORTNAME", $reportname);
                if (isset($_REQUEST["reportdesc"]) && $_REQUEST["reportdesc"] != "") {
                    $reportdesc = htmlspecialchars(vtlib_purify($_REQUEST["reportdesc"]));
                } else {
                    $reportdesc = $this->reportinformations["reportdesc"];
                }
                $smarty_obj->assign("REPORTDESC", $reportdesc);
                $smarty_obj->assign("REP_MODULE", $this->reportinformations["primarymodule"]);
                $smarty_obj->assign("PRIMARYMODULES", $this->getPrimaryModules());
                $smarty_obj->assign("REP_FOLDERS", $this->getReportFolders());
                if (isset($this->primarymodule) && $this->primarymodule != '') {
                    $rel_modules = $this->getReportRelatedModules($this->primarymoduleid);
                    foreach ($rel_modules as $key => $relmodule) {
                        $restricted_modules .= $relmodule['id'] . ":";
                    }
                    $smarty_obj->assign("REL_MODULES_STR", trim($restricted_modules, ":"));
                    $smarty_obj->assign("RELATEDMODULES", $rel_modules);
                }
                $smarty_obj->assign("FOLDERID", vtlib_purify($_REQUEST['folder']));
            }
            if (in_array($step_name, array("ReportsStep2", $get_all_steps))) {
                if (isset($this->primarymodule) && $this->primarymodule != '') {
                    $rel_modules = $this->getReportRelatedModules($this->primarymoduleid);
                    foreach ($rel_modules as $key => $relmodule) {
                        $restricted_modules .= $relmodule['id'] . ":";
                    }
                    $smarty_obj->assign("REL_MODULES_STR", trim($restricted_modules, ":"));
                    $smarty_obj->assign("RELATEDMODULES", $rel_modules);
                }
            }
            if (in_array($step_name, array("ReportGrouping", $get_all_steps))) {
                // TIMELINE COLUMNS DEFINITION CHANGED New Code 13.5.2014 11:58
                // ITS4YOU-CR SlOl | 13.5.2014 11:53
                if (isset($_REQUEST["primarymodule"]) && $_REQUEST["primarymodule"] != "") {
                    $primary_moduleid = $_REQUEST["primarymodule"];
                    $primary_module = vtlib_getModuleNameById($_REQUEST["primarymodule"]);
                    if (vtlib_isModuleActive($primary_module)) {
                        $primary_df_arr = getPrimaryTLStdFilter($primary_module, $this);
                    }
                } else {
                    $primary_module = $this->primarymodule;
                    $primary_moduleid = $this->primarymoduleid;
                    $primary_df_arr = getPrimaryTLStdFilter($primary_module, $this);
                }
                $date_options = array();
                if (!empty($primary_df_arr)) {
                    foreach ($primary_df_arr as $val_arr) {
                        foreach ($val_arr as $val_dtls) {
                            $date_options[] = $val_dtls["value"];
                        }
                    }
                }
                $date_options_json = Zend_JSON::encode($date_options);
                $smarty_obj->assign("date_options_json", $date_options_json);
                $timelinecolumn = $this->getTimeLineColumnHTML();
                $smarty_obj->assign("timelinecolumn", $timelinecolumn);
                // ITS4YOU-END 13.5.2014 11:53
                if (isset($_REQUEST["record"]) && $_REQUEST['record'] != '') {
                    $reportid = vtlib_purify($_REQUEST["record"]);
                    $secondarymodule = '';
                    $secondarymodules = array();
                    if (!empty($this->related_modules[$primary_module])) {
                        foreach ($this->related_modules[$primary_module] as $key => $value) {
                            if (isset($_REQUEST["secondarymodule_" . $value])) {
                                $secondarymodules[] = vtlib_purify($_REQUEST["secondarymodule_" . $value]);
                            }
                        }
                    }
                    if ($primary_moduleid == getTabid('Invoice')) {
                        $secondarymodules[] = getTabid('Products');
                        $secondarymodules[] = getTabid('Services');
                    }
                    $secondarymodule = implode(":", $secondarymodules);
                    if ($secondarymodule != '') {
                        $this->secondarymodules .= $secondarymodule;
                    }
                    if (isset($_REQUEST["summaries_limit"])) {
                        $summaries_limit = vtlib_purify($_REQUEST["summaries_limit"]);
                    } else {
                        $summaries_limit = $this->reportinformations["summaries_limit"];
                    }
                } else {
                    $secondarymodule = '';
                    $secondarymodules = array();
                    $this->getPriModuleColumnsList($primary_module);
                    foreach ($this->secondarymodules as $key => $secmodid) {
                        $this->getSecModuleColumnsList(vtlib_getModuleNameById($secmodid));
                    }
                    $summaries_limit = "20";
                }
                $smarty_obj->assign("SUMMARIES_MAX_LIMIT", $summaries_limit);
                for ($tc_i = 1; $tc_i < 4; $tc_i++) {
                    $timelinecol = $selected_timeline_column = "";
                    if (isset($_REQUEST["group{$tc_i}"]) && $_REQUEST["group{$tc_i}"] != "" && $step_name != "ReportGrouping") {
                        $group = vtlib_purify($_REQUEST["group{$tc_i}"]);
                        if (isset($_REQUEST["timeline_column{$tc_i}"]) && $_REQUEST["timeline_column{$tc_i}"] != "") {
                            $selected_timeline_column = vtlib_purify($_REQUEST["timeline_column{$tc_i}"]);
                        }
                    } else {
                        $group = $this->reportinformations["Group{$tc_i}"];
                        $selected_timeline_column = $this->reportinformations["timeline_columnstr{$tc_i}"];
                    }
                    if (isset($selected_timeline_column) && !in_array($selected_timeline_column, array("", "none", "@vlv@"))) {
                        $timelinecol = $this->getTimeLineColumnHTML($tc_i, $selected_timeline_column);
                        $smarty_obj->assign("timelinecolumn" . $tc_i . "_html", $timelinecol);
                    }
                    $RG_BLOCK = getPrimaryColumns_GroupingHTML($primary_module, $group, $this);
                    $smarty_obj->assign("RG_BLOCK{$tc_i}", $RG_BLOCK);
                    if ($tc_i > 1) {
                        if (isset($_REQUEST["timeline_type{$tc_i}"]) && $_REQUEST["timeline_type{$tc_i}"] != "") {
                            $timeline_type = vtlib_purify($_REQUEST["timeline_type{$tc_i}"]);
                        } else {
                            $timeline_type = $this->reportinformations["timeline_type{$tc_i}"];
                        }
                        $smarty_obj->assign("timeline_type{$tc_i}", $timeline_type);
                    }
                }
                for ($sci = 1; $sci < 4; $sci++) {
                    if (isset($_REQUEST["sort" . $sci]) && $_REQUEST["sort" . $sci] != "") {
                        $sortorder = vtlib_purify($_REQUEST["sort" . $sci]);
                    } else {
                        $sortorder = $this->reportinformations["Sort" . $sci];
                    }
                    $sa = $sd = "";
                    if ($sortorder != "Descending") {
                        $sa = "checked";
                    } else {
                        $sd = "checked";
                    }
                    $shtml = '<input type="radio" id="Sort' . $sci . 'a" name="Sort' . $sci . '" value="Ascending" ' . $sa . '>' . vtranslate('Ascending') . ' &nbsp; 
				              <input type="radio" id="Sort' . $sci . 'd" name="Sort' . $sci . '" value="Descending" ' . $sd . '>' . vtranslate('Descending');
                    $smarty_obj->assign("ASCDESC" . $sci, $shtml);
                }
                // ITS4YOU-CR SlOl 5. 3. 2014 14:50:45 SUMMARIES START
                $module_id = $primary_moduleid;
                $modulename_prefix = "";
                $module_array["module"] = $primary_module;
                $module_array["id"] = $module_id;
                $selectedmodule = $module_array["id"];
                $modulename = $module_array["module"];
                $modulename_lbl = vtranslate($modulename, $modulename);
                $availModules[$module_array["id"]] = $modulename_lbl;
                $modulename_id = $module_array["id"];
                if (isset($selectedmodule)) {
                    $secondarymodule_arr = $this->getReportRelatedModules($module_array["id"]);
                    $this->getSecModuleColumnsList($selectedmodule);
                    $RG_BLOCK4 = sgetSummariesHTMLOptions($module_array["id"], $module_id);
                    $available_modules[] = array("id" => $module_id, "name" => $modulename_lbl, "checked" => "checked");
                    foreach ($secondarymodule_arr as $key => $value) {
                        $exploded_mid = explode("x", $value["id"]);
                        if (strtolower($exploded_mid[1]) != "mif") {
                            $available_modules[] = array("id" => $value["id"], "name" => "- " . $value["name"], "checked" => "");
                        }
                    }
                    $smarty_obj->assign("RG_BLOCK4", $RG_BLOCK4);
                }
                $smarty_obj->assign("SummariesModules", $available_modules);
                $SumOptions = sgetSummariesOptions($selectedmodule);
                if (empty($SumOptions)) {
                    $SumOptions = vtranslate("NO_SUMMARIES_COLUMNS", $this->currentModule);
                }
                $SPSumOptions[$module_array["id"]][$module_array["id"]] = $SumOptions;
                $smarty_obj->assign("SUMOPTIONS", $SPSumOptions);
                if (isset($_REQUEST["selectedSummariesString"])) {
                    $selectedSummariesString = vtlib_purify($_REQUEST["selectedSummariesString"]);
                    $selectedSummariesArr = explode(";", $selectedSummariesString);
                    $summaries_orderby = vtlib_purify($_REQUEST["summaries_orderby"]);
                    $RG_BLOCK6 = sgetSelectedSummariesHTMLOptions($selectedSummariesArr, $summaries_orderby);
                } else {
                    if (!empty($this->reportinformations["summaries_columns"])) {
                        foreach ($this->reportinformations["summaries_columns"] as $key => $summaries_columns_arr) {
                            $selectedSummariesArr[] = $summaries_columns_arr["columnname"];
                        }
                    }
                    $selectedSummariesString = implode(";", $selectedSummariesString);
                    $summaries_orderby = "";
                    if (isset($this->reportinformations["summaries_orderby_columns"][0]) && $this->reportinformations["summaries_orderby_columns"][0] != "") {
                        $summaries_orderby = $this->reportinformations["summaries_orderby_columns"][0];
                    }
                    $RG_BLOCK6 = sgetSelectedSummariesHTMLOptions($selectedSummariesArr, $summaries_orderby);
                }
                // sum_group_columns for group filters start
                $sm_arr = sgetSelectedSummariesOptions($selectedSummariesArr);
                $sm_str = "";
                foreach ($sm_arr as $key => $opt_arr) {
                    if ($sm_str != "") {
                        $sm_str .= "(|@!@|)";
                    }
                    $sm_str .= $opt_arr["value"] . "(|@|)" . $opt_arr["text"];
                }
                $smarty_obj->assign("sum_group_columns", $sm_str);
                // sum_group_columns for group filters end
                $smarty_obj->assign("selectedSummariesString", $selectedSummariesString);
                $smarty_obj->assign("RG_BLOCK6", $RG_BLOCK6);
                $RG_BLOCKx2 = array();
                $all_fields_str = "";
                foreach ($SPSumOptions as $module_key => $SumOptions) {
                    $RG_BLOCKx2 = "";
                    $r_modulename = vtlib_getModuleNameById($module_key);
                    $r_modulename_lbl = vtranslate($r_modulename, $r_modulename);
                    foreach ($SumOptions as $SumOptions_key => $SumOptions_value) {
                        if (is_array($SumOptions_value)) {
                            foreach ($SumOptions_value as $optgroup => $optionsdata) {
                                if ($RG_BLOCKx2 != "") {
                                    $RG_BLOCKx2 .= "(|@!@|)";
                                }
                                $RG_BLOCKx2 .= $optgroup;
                                $RG_BLOCKx2 .= "(|@|)";
                                $RG_BLOCKx2 .= Zend_JSON::encode($optionsdata);
                            }
                        } else {
                            $RG_BLOCKx2 .= $SumOptions_value;
                            $RG_BLOCKx2 .= "(|@|)";
                            $optionsdata[] = array("value" => "none", "text" => vtranslate("LBL_NONE", $this->currentModule));
                            $RG_BLOCKx2 .= Zend_JSON::encode($optionsdata);
                        }
                        $all_fields_str .= $module_key . "(!#_ID@ID_#!)" . $r_modulename_lbl . "(!#_ID@ID_#!)" . $RG_BLOCKx2;
                    }
                }
                $smarty_obj->assign("ALL_FIELDS_STRING", $all_fields_str);
                // ITS4YOU-END 5. 3. 2014 14:50:47  SUMMARIES END
                if (isset($_REQUEST["summaries_orderby"]) && $_REQUEST["summaries_orderby"] != "" && isset($_REQUEST["summaries_orderby_type"]) && $_REQUEST["summaries_orderby_type"] != "") {
                    $summaries_orderby = vtlib_purify($_REQUEST["summaries_orderby"]);
                    $summaries_orderby_type = vtlib_purify($_REQUEST["summaries_orderby_type"]);
                } elseif (isset($this->reportinformations["summaries_orderby_columns"]) && !empty($this->reportinformations["summaries_orderby_columns"])) {
                    $summaries_orderby = $this->reportinformations["summaries_orderby_columns"][0]["column"];
                    $summaries_orderby_type = $this->reportinformations["summaries_orderby_columns"][0]["type"];
                } else {
                    $summaries_orderby = "none";
                    $summaries_orderby_type = "ASC";
                }
                $smarty_obj->assign("summaries_orderby", $summaries_orderby);
                $smarty_obj->assign("summaries_orderby_type", $summaries_orderby_type);
            }
            if (in_array($step_name, array("ReportColumns", $get_all_steps))) {
                if (isset($_REQUEST["record"]) && $_REQUEST['record'] != '') {
                    $RC_BLOCK1 = getPrimaryColumnsHTML($this->primarymodule);
                    $secondarymodule = '';
                    $secondarymodules = array();
                    if (!empty($this->related_modules[$this->primarymodule])) {
                        foreach ($this->related_modules[$this->primarymodule] as $key => $value) {
                            if (isset($_REQUEST["secondarymodule_" . $value])) {
                                $secondarymodules[] = $_REQUEST["secondarymodule_" . $value];
                            }
                        }
                    }
                    $secondarymodule = implode(":", $secondarymodules);
                    $RC_BLOCK2 = $this->getSelectedColumnsList($this->selected_columns_list_arr);
                    $smarty_obj->assign("RC_BLOCK1", $RC_BLOCK1);
                    $smarty_obj->assign("RC_BLOCK2", $RC_BLOCK2);
                    $sreportsortsql = "SELECT columnname, sortorder FROM  its4you_reports4you_sortcol WHERE reportid =? AND sortcolid = 4";
                    $result_sort = $adb->pquery($sreportsortsql, array($recordid));
                    $num_rows = $adb->num_rows($result_sort);
                    if ($num_rows > 0) {
                        $columnname = $adb->query_result($result_sort, 0, "columnname");
                        $sortorder = $adb->query_result($result_sort, 0, "sortorder");
                        $RC_BLOCK3 = $this->getSelectedColumnsList($this->selected_columns_list_arr, $columnname);
                    } else {
                        $RC_BLOCK3 = $RC_BLOCK2;
                    }
                    $smarty_obj->assign("RC_BLOCK3", $RC_BLOCK3);
                    $this->secmodule = $secondarymodule;
                    $RC_BLOCK4 = "";
                    $RC_BLOCK4 = getSecondaryColumnsHTML($this->relatedmodulesstring, $this);
                    $smarty_obj->assign("RC_BLOCK4", $RC_BLOCK4);
                } else {
                    $primarymodule = vtlib_purify($_REQUEST["primarymodule"]);
                    $RC_BLOCK1 = getPrimaryColumnsHTML($primarymodule);
                    if (!empty($this->related_modules[$primarymodule])) {
                        foreach ($this->related_modules[$primarymodule] as $key => $value) {
                            $RC_BLOCK1 .= getSecondaryColumnsHTML($_REQUEST["secondarymodule_" . $value], $this);
                        }
                    }
                    $smarty_obj->assign("RC_BLOCK1", $RC_BLOCK1);
                    $this->reportinformations["columns_limit"] = "20";
                }
                $smarty_obj->assign("MAX_LIMIT", $this->reportinformations["columns_limit"]);
                if ($sortorder != "DESC") {
                    $shtml = '<input type="radio" name="SortOrderColumn" value="ASC" checked>' . vtranslate('Ascending') . ' &nbsp; 
								<input type="radio" name="SortOrderColumn" value="DESC">' . vtranslate('Descending');
                } else {
                    $shtml = '<input type="radio" name="SortOrderColumn" value="ASC">' . vtranslate('Ascending') . ' &nbsp; 
								<input type="radio" name="SortOrderColumn" value="DESC" checked>' . vtranslate('Descending');
                }
                $smarty_obj->assign("COLUMNASCDESC", $shtml);
                $timelinecolumns .= '<input type="radio" name="TimeLineColumn" value="DAYS" checked>' . $mod_strings['TL_DAYS'] . ' ';
                $timelinecolumns .= '<input type="radio" name="TimeLineColumn" value="WEEK" >' . $mod_strings['TL_WEEKS'] . ' ';
                $timelinecolumns .= '<input type="radio" name="TimeLineColumn" value="MONTH" >' . $mod_strings['TL_MONTHS'] . ' ';
                $timelinecolumns .= '<input type="radio" name="TimeLineColumn" value="YEAR" >' . $mod_strings['TL_YEARS'] . ' ';
                $timelinecolumns .= '<input type="radio" name="TimeLineColumn" value="QUARTER" >' . $mod_strings['TL_QUARTERS'] . ' ';
                $smarty_obj->assign("TIMELINE_FIELDS", $timelinecolumns);
                // ITS4YOU-CR SlOl  19. 2. 2014 16:30:20
                $SPSumOptions = $availModules = array();
                $RC_BLOCK0 = "";
                $smarty_obj->assign("availModules", $availModules);
                $smarty_obj->assign("ALL_FIELDS_STRING", $RC_BLOCK0);
                // ITS4YOU-END 19. 2. 2014 16:30:23
                $smarty_obj->assign("currentModule", $this->currentModule);
            }
            if (in_array($step_name, array("ReportColumnsTotal", $get_all_steps))) {
                $Objects = array();
                $curl_array = array();
                if (isset($_REQUEST["curl"])) {
                    $curl = vtlib_purify($_REQUEST["curl"]);
                    $curl_array = explode('$_@_$', $curl);
                    $selectedColumnsString = str_replace("@AMPKO@", "&", $_REQUEST["selectedColumnsStr"]);
                    $R_Objects = explode("<_@!@_>", $selectedColumnsString);
                } else {
                    $curl_array = $this->getSelectedColumnsToTotal($this->record);
                    $curl = implode('$_@_$', $curl_array);
                    $selectedColumnsString = str_replace("@AMPKO@", "&", $this->reportinformations["selectedColumnsString"]);
                    $R_Objects = explode(";", $selectedColumnsString);
                }
                $smarty_obj->assign("CURL", $curl);
                $Objects = sgetNewColumnstoTotalHTMLScript($R_Objects);
                $this->columnssummary = $Objects;
                $CT_BLOCK1 = $this->sgetNewColumntoTotalSelected($recordid, $R_Objects, $curl_array);
                $smarty_obj->assign("CT_BLOCK1", $CT_BLOCK1);
                //added to avoid displaying "No data avaiable to total" when using related modules in report.
                $rows_count = 0;
                $rows_count = count($CT_BLOCK1);
                $smarty_obj->assign("ROWS_COUNT", $rows_count);
            }
            if (in_array($step_name, array("ReportLabels", $get_all_steps))) {
                // selected labels from url
                $lbl_url_string = html_entity_decode(vtlib_purify($_REQUEST["lblurl"]), ENT_QUOTES, $default_charset);
                if ($lbl_url_string != "") {
                    $lbl_url_arr = explode('$_@_$', $lbl_url_string);
                    foreach ($lbl_url_arr as $key => $lbl_value) {
                        if (strpos($lbl_value, 'hidden_') === false) {
                            if (strpos($lbl_value, '_SC_lLbLl_') !== false) {
                                $temp = explode('_SC_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = trim($temp_lbls[0]);
                                $lbl_value = trim($temp_lbls[1]);
                                $lbl_url_selected["SC"][$lbl_key] = $lbl_value;
                            }
                            if (strpos($lbl_value, '_SM_lLbLl_') !== false) {
                                $temp = explode('_SM_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = trim($temp_lbls[0]);
                                $lbl_value = trim($temp_lbls[1]);
                                $lbl_url_selected["SM"][$lbl_key] = $lbl_value;
                            }
                            if (strpos($lbl_value, '_CT_lLbLl_') !== false) {
                                $temp = explode('_CT_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = trim($temp_lbls[0]);
                                $lbl_value = trim($temp_lbls[1]);
                                $lbl_url_selected["CT"][$lbl_key] = $lbl_value;
                            }
                        }
                    }
                }
                // COLUMNS labeltype SC
                if (isset($_REQUEST["selectedColumnsStr"]) && $_REQUEST["selectedColumnsStr"] != "") {
                    $selectedColumnsString = vtlib_purify($_REQUEST["selectedColumnsStr"]);
                    $selectedColumnsString = html_entity_decode($selectedColumnsString, ENT_QUOTES, $default_charset);
                    $selected_columns_array = explode("<_@!@_>", $selectedColumnsString);
                    $decode_labels = true;
                } else {
                    $selectedColumnsString = html_entity_decode($this->reportinformations["selectedColumnsString"], ENT_QUOTES, $default_charset);
                    $selected_columns_array = explode(";", $selectedColumnsString);
                    $decode_labels = false;
                }
                $labels_html["SC"] = $this->getLabelsHTML($selected_columns_array, "SC", $lbl_url_selected, $decode_labels);
                // SUMMARIES labeltype SM
                $selectedSummariesString = vtlib_purify($_REQUEST["selectedSummariesString"]);
                if ($selectedSummariesString != "") {
                    $selectedSummaries_array = explode(";", trim($selectedSummariesString, ";"));
                } else {
                    foreach ($this->reportinformations["summaries_columns"] as $key => $sum_arr) {
                        $selectedSummaries_array[] = $sum_arr["columnname"];
                    }
                }
                $labels_html["SM"] = $this->getLabelsHTML($selectedSummaries_array, "SM", $lbl_url_selected, $decode_labels);
                $smarty_obj->assign("labels_html", $labels_html);
                $smarty_obj->assign("LABELS", $curl);
                //added to avoid displaying "No data avaiable to total" when using related modules in report.
                $rows_count = count($labels_html);
                foreach ($labels_html as $key => $labels_type_arr) {
                    $rows_count += count($labels_type_arr);
                }
                $smarty_obj->assign("ROWS_COUNT", $rows_count);
            }
            if (in_array($step_name, array("ReportFilters", $get_all_steps))) {
                require_once 'modules/ITS4YouReports/FilterUtils.php';
                if (isset($_REQUEST["primarymodule"]) && $_REQUEST["primarymodule"] != "") {
                    $primary_moduleid = $_REQUEST["primarymodule"];
                    $primary_module = vtlib_getModuleNameById($_REQUEST["primarymodule"]);
                } else {
                    $primary_module = $this->primarymodule;
                    $primary_moduleid = $this->primarymoduleid;
                }
                // NEW ADVANCE FILTERS START
                $this->getGroupFilterList($this->record);
                $this->getAdvancedFilterList($this->record);
                $this->getSummariesFilterList($this->record);
                $sel_fields = Zend_Json::encode($this->adv_sel_fields);
                $smarty_obj->assign("SEL_FIELDS", $sel_fields);
                if (isset($_REQUEST["reload"])) {
                    $criteria_groups = $this->getRequestCriteria($sel_fields);
                } else {
                    $criteria_groups = $this->advft_criteria;
                }
                $smarty_obj->assign("CRITERIA_GROUPS", $criteria_groups);
                $smarty_obj->assign("EMPTY_CRITERIA_GROUPS", empty($criteria_groups));
                $smarty_obj->assign("SUMMARIES_CRITERIA", $this->summaries_criteria);
                $FILTER_OPTION = getAdvCriteriaHTML();
                $smarty_obj->assign("FOPTION", $FILTER_OPTION);
                $COLUMNS_BLOCK_JSON = $this->getAdvanceFilterOptionsJSON($primary_module);
                $smarty_obj->assign("COLUMNS_BLOCK", $COLUMNS_BLOCK);
                if ($mode != "ajax") {
                    echo "<textarea style='display:none;' id='filter_columns'>" . $COLUMNS_BLOCK_JSON . "</textarea>";
                    $smarty_obj->assign("filter_columns", $COLUMNS_BLOCK_JSON);
                    $sel_fields = Zend_Json::encode($this->adv_sel_fields);
                    $smarty_obj->assign("SEL_FIELDS", $sel_fields);
                    global $default_charset;
                    $std_filter_columns = $this->getStdFilterColumns();
                    $std_filter_columns_js = implode("<%jsstdjs%>", $std_filter_columns);
                    $std_filter_columns_js = html_entity_decode($std_filter_columns_js, ENT_QUOTES, $default_charset);
                    $smarty_obj->assign("std_filter_columns", $std_filter_columns_js);
                    $std_filter_criteria = Zend_Json::encode($this->Date_Filter_Values);
                    $smarty_obj->assign("std_filter_criteria", $std_filter_criteria);
                }
                $rel_fields = $this->adv_rel_fields;
                $smarty_obj->assign("REL_FIELDS", Zend_Json::encode($rel_fields));
                // NEW ADVANCE FILTERS END
                $BLOCKJS = $this->getCriteriaJS();
                $smarty_obj->assign("BLOCKJS_STD", $BLOCKJS);
            }
            if (in_array($step_name, array("ReportSharing", $get_all_steps))) {
                $roleid = $this->current_user->column_fields['roleid'];
                $user_array = getRoleAndSubordinateUsers($roleid);
                $userIdStr = "";
                $userNameStr = "";
                $m = 0;
                foreach ($user_array as $userid => $username) {
                    if ($userid != $this->current_user->id) {
                        if ($m != 0) {
                            $userIdStr .= ",";
                            $userNameStr .= ",";
                        }
                        $userIdStr .= "'" . $userid . "'";
                        $userNameStr .= "'" . escape_single_quotes(decode_html($username)) . "'";
                        $m++;
                    }
                }
                require_once 'include/utils/GetUserGroups.php';
                // ITS4YOU-UP SlOl 26. 4. 2013 9:47:59
                $template_owners = get_user_array(false);
                if (isset($this->reportinformations["owner"]) && $this->reportinformations["owner"] != "") {
                    $selected_owner = $this->reportinformations["owner"];
                } else {
                    $selected_owner = $this->current_user->id;
                }
                $smarty_obj->assign("TEMPLATE_OWNERS", $template_owners);
                $owner = isset($_REQUEST['template_owner']) && $_REQUEST['template_owner'] != '' ? $_REQUEST['template_owner'] : $selected_owner;
                $smarty_obj->assign("TEMPLATE_OWNER", $owner);
                $sharing_types = array("public" => vtranslate("PUBLIC_FILTER"), "private" => vtranslate("PRIVATE_FILTER"), "share" => vtranslate("SHARE_FILTER"));
                $smarty_obj->assign("SHARINGTYPES", $sharing_types);
                $sharingtype = "public";
                if (isset($_REQUEST['sharing']) && $_REQUEST['sharing'] != '') {
                    $sharingtype = $_REQUEST['sharing'];
                } elseif (isset($this->reportinformations["sharingtype"]) && $this->reportinformations["sharingtype"] != "") {
                    $sharingtype = $this->reportinformations["sharingtype"];
                }
                $smarty_obj->assign("SHARINGTYPE", $sharingtype);
                $cmod = return_specified_module_language($current_language, "Settings");
                $smarty_obj->assign("CMOD", $cmod);
                $sharingMemberArray = array();
                if (isset($_REQUEST['sharingSelectedColumns']) && $_REQUEST['sharingSelectedColumns'] != '') {
                    $sharingMemberArray = explode("|", trim($_REQUEST['sharingSelectedColumns'], "|"));
                } elseif (isset($this->reportinformations["members_array"]) && !empty($this->reportinformations["members_array"])) {
                    $sharingMemberArray = $this->reportinformations["members_array"];
                }
                $sharingMemberArray = array_unique($sharingMemberArray);
                if (count($sharingMemberArray) > 0) {
                    $outputMemberArr = array();
                    foreach ($sharingMemberArray as $setype => $shareIdArr) {
                        $shareIdArr = explode("::", $shareIdArr);
                        $shareIdArray = array();
                        $shareIdArray[$shareIdArr[0]] = $shareIdArr[1];
                        foreach ($shareIdArray as $shareType => $shareId) {
                            switch ($shareType) {
                                case "groups":
                                    $memberName = fetchGroupName($shareId);
                                    $memberDisplay = "Group::";
                                    break;
                                case "roles":
                                    $memberName = getRoleName($shareId);
                                    $memberDisplay = "Roles::";
                                    break;
                                case "rs":
                                    $memberName = getRoleName($shareId);
                                    $memberDisplay = "RoleAndSubordinates::";
                                    break;
                                case "users":
                                    $memberName = getUserFullName($shareId);
                                    $memberDisplay = "User::";
                                    break;
                            }
                            $outputMemberArr[] = $shareType . "::" . $shareId;
                            $outputMemberArr[] = $memberDisplay . $memberName;
                        }
                    }
                    $smarty_obj->assign("MEMBER", array_chunk($outputMemberArr, 2));
                }
                // ITS4YOU-END
                $userGroups = new GetUserGroups();
                $userGroups->getAllUserGroups($this->current_user->id);
                $user_groups = $userGroups->user_groups;
                $groupIdStr = "";
                $groupNameStr = "";
                $l = 0;
                foreach ($user_groups as $i => $grpid) {
                    $grp_details = getGroupDetails($grpid);
                    if ($l != 0) {
                        $groupIdStr .= ",";
                        $groupNameStr .= ",";
                    }
                    $groupIdStr .= "'" . $grp_details[0] . "'";
                    $groupNameStr .= "'" . escape_single_quotes(decode_html($grp_details[1])) . "'";
                    $l++;
                }
                $visiblecriteria = getVisibleCriteria();
                $smarty_obj->assign("VISIBLECRITERIA", $visiblecriteria);
                $smarty_obj->assign("GROUPNAMESTR", $groupNameStr);
                $smarty_obj->assign("USERNAMESTR", $userNameStr);
                $smarty_obj->assign("GROUPIDSTR", $groupIdStr);
                $smarty_obj->assign("USERIDSTR", $userIdStr);
            }
            if (in_array($step_name, array("ReportScheduler", $get_all_steps))) {
                // SEE ReportScheduler.php for this step for a reason of problem with incomplemete ReportScheduler object
            }
            if (in_array($step_name, array("ReportGraphs", $get_all_steps))) {
                if (isset($_REQUEST["chart_type"]) && $_REQUEST["chart_type"] != "" && $_REQUEST["chart_type"] != "none") {
                    $selected_chart_type = vtlib_purify($_REQUEST["chart_type"]);
                } else {
                    $selected_chart_type = $this->reportinformations["charts"]["charttype"];
                }
                $smarty_obj->assign("IMAGE_PATH", $chart_type);
                if (isset($_REQUEST["data_series"]) && $_REQUEST["data_series"] != "" && $_REQUEST["data_series"] != "none") {
                    $selected_data_series = vtlib_purify($_REQUEST["data_series"]);
                } else {
                    $selected_data_series = $this->reportinformations["charts"]["dataseries"];
                }
                if (isset($_REQUEST["charttitle"]) && $_REQUEST["charttitle"] != "") {
                    $selected_charttitle = htmlspecialchars(vtlib_purify($_REQUEST["charttitle"]));
                } else {
                    $selected_charttitle = $this->reportinformations["charts"]["charttitle"];
                }
                $chart_type["horizontal"] = array("value" => vtranslate("LBL_CHART_horizontal", $this->currentModule), "selected" => $selected_chart_type == "horizontal" ? "selected" : "");
                $chart_type["vertical"] = array("value" => vtranslate("LBL_CHART_vertical", $this->currentModule), "selected" => $selected_chart_type == "vertical" ? "selected" : "");
                $chart_type["linechart"] = array("value" => vtranslate("LBL_CHART_linechart", $this->currentModule), "selected" => $selected_chart_type == "linechart" ? "selected" : "");
                $chart_type["pie"] = array("value" => vtranslate("LBL_CHART_pie", $this->currentModule), "selected" => $selected_chart_type == "pie" ? "selected" : "");
                $chart_type["pie3d"] = array("value" => vtranslate("LBL_CHART_pie3D", $this->currentModule), "selected" => $selected_chart_type == "pie3d" ? "selected" : "");
                $chart_type["funnel"] = array("value" => vtranslate("LBL_CHART_funnel", $this->currentModule), "selected" => $selected_chart_type == "funnel" ? "selected" : "");
                $smarty_obj->assign("CHART_TYPE", $chart_type);
                // selected labels from url
                if (isset($_REQUEST["lblurl"])) {
                    global $default_charset;
                    $lbl_url_string = html_entity_decode(vtlib_purify($_REQUEST["lblurl"]), ENT_QUOTES, $default_charset);
                }
                $lbl_url_string = str_replace("@AMPKO@", "&", $lbl_url_string);
                if ($lbl_url_string != "") {
                    $lbl_url_arr = explode('$_@_$', $lbl_url_string);
                    foreach ($lbl_url_arr as $key => $lbl_value) {
                        if (strpos($lbl_value, 'hidden_') === false) {
                            if (strpos($lbl_value, '_SC_lLbLl_') !== false) {
                                $temp = explode('_SC_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = $temp_lbls[0];
                                $lbl_value = $temp_lbls[1];
                                $lbl_url_selected["SC"][$lbl_key] = $lbl_value;
                            }
                            if (strpos($lbl_value, '_SM_lLbLl_') !== false) {
                                $temp = explode('_SM_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = $temp_lbls[0];
                                $lbl_value = $temp_lbls[1];
                                $lbl_url_selected["SM"][$lbl_key] = $lbl_value;
                            }
                            if (strpos($lbl_value, '_CT_lLbLl_') !== false) {
                                $temp = explode('_CT_lLbLl_', $lbl_value);
                                $temp_lbls = explode('_lLGbGLl_', $temp[1]);
                                $lbl_key = $temp_lbls[0];
                                $lbl_value = $temp_lbls[1];
                                $lbl_url_selected["CT"][$lbl_key] = $lbl_value;
                            }
                        }
                    }
                }
                $selectedSummariesString = vtlib_purify($_REQUEST["selectedSummariesString"]);
                if ($selectedSummariesString != "") {
                    $selectedSummariesArray = explode(";", $selectedSummariesString);
                    if (!empty($selectedSummariesArray)) {
                        foreach ($selectedSummariesArray as $column_str) {
                            if ($column_str != "") {
                                if (isset($lbl_url_selected["SM"][$column_str]) && $lbl_url_selected["SM"][$column_str] != "") {
                                    $column_lbl = $lbl_url_selected["SM"][$column_str];
                                } else {
                                    $column_str_arr = explode(":", $column_str);
                                    $translate_arr = explode("_", $column_str_arr[2]);
                                    $translate_module = $translate_arr[0];
                                    unset($translate_arr[0]);
                                    $translate_str = implode("_", $translate_arr);
                                    $translate_mod_str = return_module_language($current_language, $translate_module);
                                    if (isset($translate_mod_str[$translate_str])) {
                                        $column_lbl = $translate_mod_str[$translate_str];
                                    } else {
                                        $column_lbl = $translate_str;
                                    }
                                }
                                $data_series[$column_str] = array("value" => $column_lbl, "selected" => $column_str == $selected_data_series ? "selected" : "");
                            }
                        }
                    }
                }
                if (empty($data_series) && $selected_data_series != "") {
                    $column_lbl = $this->getColumnStr_Label($selected_data_series, "SM");
                    $data_series[$selected_data_series] = array("value" => $column_lbl, "selected" => "selected");
                }
                $smarty_obj->assign("DATA_SERIES", $data_series);
                $smarty_obj->assign("CHART_TITLE", $selected_charttitle);
            }
            return $smarty_obj;
        }
    }
Example #14
0
 public function process(Vtiger_Request $request)
 {
     PDFMaker_Debugger_Model::GetInstance()->Init();
     $PDFMaker = new PDFMaker_PDFMaker_Model();
     $viewer = $this->getViewer($request);
     if ($request->has('templateid') && !$request->isEmpty('templateid')) {
         $templateid = $request->get('templateid');
         $pdftemplateResult = $PDFMaker->GetEditViewData($templateid);
         $select_module = $pdftemplateResult["module"];
         $select_format = $pdftemplateResult["format"];
         $select_orientation = $pdftemplateResult["orientation"];
         $nameOfFile = $pdftemplateResult["file_name"];
         $is_portal = $pdftemplateResult["is_portal"];
         $is_listview = $pdftemplateResult["is_listview"];
         $is_active = $pdftemplateResult["is_active"];
         $is_default = $pdftemplateResult["is_default"];
         $order = $pdftemplateResult["order"];
         $owner = $pdftemplateResult["owner"];
         $sharingtype = $pdftemplateResult["sharingtype"];
         $sharingMemberArray = $PDFMaker->GetSharingMemberArray($templateid);
         $disp_header = $pdftemplateResult["disp_header"];
         $disp_footer = $pdftemplateResult["disp_footer"];
         if (!$pdftemplateResult["permissions"]["edit"]) {
             $PDFMaker->DieDuePermission();
         }
     } else {
         $templateid = "";
         if ($request->has("return_module") && !$request->isEmpty("return_module")) {
             $select_module = $request->get("return_module");
         } else {
             $select_module = "";
         }
         $select_format = "A4";
         $select_orientation = "portrait";
         //$select_encoding = "utf-8";
         $nameOfFile = "";
         $is_portal = "0";
         $is_listview = "0";
         $is_active = "1";
         $is_default = "0";
         $order = "1";
         $owner = $cu_model->id;
         $sharingtype = "public";
         $sharingMemberArray = array();
         $disp_header = "3";
         $disp_footer = "7";
         $PDFMaker->CheckTemplatePermissions($select_module, $templateid);
     }
     if ($PDFMaker->GetVersionType() == "professional") {
         $type = "professional";
     } else {
         $type = "basic";
     }
     $viewer->assign("TYPE", $type);
     if ($request->has("isDuplicate") && $request->get("isDuplicate") == "true") {
         $viewer->assign("FILENAME", "");
         $viewer->assign("DUPLICATE_FILENAME", $pdftemplateResult["filename"]);
     } else {
         $viewer->assign("FILENAME", $pdftemplateResult["filename"]);
     }
     $viewer->assign("DESCRIPTION", $pdftemplateResult["description"]);
     if (!$request->has("isDuplicate") or $request->has("isDuplicate") && $request->get("isDuplicate") != "true") {
         $viewer->assign("SAVETEMPLATEID", $templateid);
     }
     if ($templateid != "") {
         $viewer->assign("EMODE", "edit");
     }
     $viewer->assign("TEMPLATEID", $templateid);
     $viewer->assign("MODULENAME", vtranslate($select_module, $select_module));
     $viewer->assign("SELECTMODULE", $select_module);
     $viewer->assign("BODY", $pdftemplateResult["body"]);
     $cu_model = Users_Record_Model::getCurrentUserModel();
     $this->cu_language = $cu_model->get('language');
     $viewer->assign("THEME", $theme);
     $viewer->assign("IMAGE_PATH", $image_path);
     $app_strings_big = Vtiger_Language_Handler::getModuleStringsFromFile($this->cu_language);
     $app_strings = $app_strings_big['languageStrings'];
     $viewer->assign("APP", $app_strings);
     $viewer->assign("PARENTTAB", getParentTab());
     $modArr = $PDFMaker->GetAllModules();
     $Modulenames = $modArr[0];
     $ModuleIDS = $modArr[1];
     $viewer->assign("MODULENAMES", $Modulenames);
     // ******************************************   Company and User information: **********************************
     $CUI_BLOCKS["Account"] = vtranslate("LBL_COMPANY_INFO", 'PDFMaker');
     $CUI_BLOCKS["Assigned"] = vtranslate("LBL_USER_INFO", 'PDFMaker');
     $CUI_BLOCKS["Logged"] = vtranslate("LBL_LOGGED_USER_INFO", 'PDFMaker');
     $viewer->assign("CUI_BLOCKS", $CUI_BLOCKS);
     $adb = PearDatabase::getInstance();
     $sql = "SELECT * FROM vtiger_organizationdetails";
     $result = $adb->pquery($sql, array());
     $organization_logoname = decode_html($adb->query_result($result, 0, 'logoname'));
     $organization_header = decode_html($adb->query_result($result, 0, 'headername'));
     $organization_stamp_signature = $adb->query_result($result, 0, 'stamp_signature');
     global $site_URL;
     $path = $site_URL . "/test/logo/";
     if (isset($organization_logoname)) {
         $organization_logo_img = "<img src=\"" . $path . $organization_logoname . "\">";
         $viewer->assign("COMPANYLOGO", $organization_logo_img);
     }
     if (isset($organization_stamp_signature)) {
         $organization_stamp_signature_img = "<img src=\"" . $path . $organization_stamp_signature . "\">";
         $viewer->assign("COMPANY_STAMP_SIGNATURE", $organization_stamp_signature_img);
     }
     if (isset($organization_header)) {
         $organization_header_img = "<img src=\"" . $path . $organization_header . "\">";
         $viewer->assign("COMPANY_HEADER_SIGNATURE", $organization_header_img);
     }
     $Acc_Info = array('' => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "COMPANY_NAME" => vtranslate("LBL_COMPANY_NAME", 'PDFMaker'), "COMPANY_LOGO" => vtranslate("LBL_COMPANY_LOGO", 'PDFMaker'), "COMPANY_ADDRESS" => vtranslate("LBL_COMPANY_ADDRESS", 'PDFMaker'), "COMPANY_CITY" => vtranslate("LBL_COMPANY_CITY", 'PDFMaker'), "COMPANY_STATE" => vtranslate("LBL_COMPANY_STATE", 'PDFMaker'), "COMPANY_ZIP" => vtranslate("LBL_COMPANY_ZIP", 'PDFMaker'), "COMPANY_COUNTRY" => vtranslate("LBL_COMPANY_COUNTRY", 'PDFMaker'), "COMPANY_PHONE" => vtranslate("LBL_COMPANY_PHONE", "PDFMaker"), "COMPANY_FAX" => vtranslate("LBL_COMPANY_FAX", 'PDFMaker'), "COMPANY_WEBSITE" => vtranslate("LBL_COMPANY_WEBSITE", 'PDFMaker'));
     $viewer->assign("ACCOUNTINFORMATIONS", $Acc_Info);
     if (getTabId('MultiCompany4you') && vtlib_isModuleActive('MultiCompany4you')) {
         $MultiAcc_info = array('' => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "MULTICOMPANY_COMPANYNAME" => vtranslate("LBL_COMPANY_NAME", 'MultiCompany4you'), "MULTICOMPANY_STREET" => vtranslate("Street", 'MultiCompany4you'), "MULTICOMPANY_CITY" => vtranslate("City", 'MultiCompany4you'), "MULTICOMPANY_CODE" => vtranslate("Code", 'MultiCompany4you'), "MULTICOMPANY_STATE" => vtranslate("State", 'MultiCompany4you'), "MULTICOMPANY_COUNTRY" => vtranslate("Country", 'MultiCompany4you'), "MULTICOMPANY_PHONE" => vtranslate("phone", 'MultiCompany4you'), "MULTICOMPANY_FAX" => vtranslate("Fax", 'MultiCompany4you'), "MULTICOMPANY_EMAIL" => vtranslate("email", 'MultiCompany4you'), "MULTICOMPANY_WEBSITE" => vtranslate("Website", 'MultiCompany4you'), "MULTICOMPANY_LOGO" => vtranslate("Logo", 'MultiCompany4you'), "MULTICOMPANY_STAMP" => vtranslate("Stamp", 'MultiCompany4you'), "MULTICOMPANY_BANKNAME" => vtranslate("BankName", 'MultiCompany4you'), "MULTICOMPANY_BANKACCOUNTNO" => vtranslate("BankAccountNo", 'MultiCompany4you'), "MULTICOMPANY_IBAN" => vtranslate("IBAN", 'MultiCompany4you'), "MULTICOMPANY_SWIFT" => vtranslate("SWIFT", 'MultiCompany4you'), "MULTICOMPANY_REGISTRATIONNO" => vtranslate("RegistrationNo", 'MultiCompany4you'), "MULTICOMPANY_VATNO" => vtranslate("VATNo", 'MultiCompany4you'), "MULTICOMPANY_TAXID" => vtranslate("TaxId", 'MultiCompany4you'), "MULTICOMPANY_ADDITIONALINFORMATIONS" => vtranslate("AdditionalInformations", 'MultiCompany4you'));
         $viewer->assign("MULTICOMPANYINFORMATIONS", $MultiAcc_info);
         $viewer->assign("LBL_MULTICOMPANY", vtranslate('MultiCompany', 'MultiCompany4you'));
     }
     $sql_user_block = "SELECT blockid, blocklabel FROM vtiger_blocks WHERE tabid = ? ORDER BY sequence ASC";
     $res_user_block = $adb->pquery($sql_user_block, array('29'));
     $user_block_info_arr = array();
     while ($row_user_block = $adb->fetch_array($res_user_block)) {
         $sql_user_field = "SELECT fieldid, uitype FROM vtiger_field WHERE block = ? and (displaytype != ? OR uitype = ?) ORDER BY sequence ASC";
         $res_user_field = $adb->pquery($sql_user_field, array($row_user_block['blockid'], '3', '55'));
         $num_user_field = $adb->num_rows($res_user_field);
         if ($num_user_field > 0) {
             $user_field_id_array = array();
             while ($row_user_field = $adb->fetch_array($res_user_field)) {
                 $user_field_id_array[] = $row_user_field['fieldid'];
             }
             $user_block_info_arr[$row_user_block['blocklabel']] = $user_field_id_array;
         }
     }
     $user_mod_strings = $this->getModuleLanguageArray("Users");
     $b = 0;
     foreach ($user_block_info_arr as $block_label => $block_fields) {
         $b++;
         if (isset($user_mod_strings[$block_label]) and $user_mod_strings[$block_label] != "") {
             $optgroup_value = $user_mod_strings[$block_label];
         } else {
             $optgroup_value = vtranslate($block_label, 'PDFMaker');
         }
         if (count($block_fields) > 0) {
             $sql1 = "SELECT * FROM vtiger_field WHERE fieldid IN (" . generateQuestionMarks($block_fields) . ")";
             $result1 = $adb->pquery($sql1, $block_fields);
             while ($row1 = $adb->fetchByAssoc($result1)) {
                 $fieldname = $row1['fieldname'];
                 $fieldlabel = $row1['fieldlabel'];
                 $option_key = strtoupper("Users" . "_" . $fieldname);
                 if (isset($current_mod_strings[$fieldlabel]) and $current_mod_strings[$fieldlabel] != "") {
                     $option_value = $current_mod_strings[$fieldlabel];
                 } elseif (isset($app_strings[$fieldlabel]) and $app_strings[$fieldlabel] != "") {
                     $option_value = $app_strings[$fieldlabel];
                 } else {
                     $option_value = $fieldlabel;
                 }
                 $User_Info[$optgroup_value][$option_key] = $option_value;
                 $Logged_User_Info[$optgroup_value]["R_" . $option_key] = $option_value;
             }
         }
         //variable RECORD ID added
         if ($b == 1) {
             $option_value = "Record ID";
             $option_key = strtoupper("USERS_CRMID");
             $User_Info[$optgroup_value][$option_key] = $option_value;
             $Logged_User_Info[$optgroup_value]["R_" . $option_key] = $option_value;
         }
         //end
     }
     // ****************************************** END: Company and User information **********************************
     $viewer->assign("USERINFORMATIONS", $User_Info);
     $viewer->assign("LOGGEDUSERINFORMATION", $Logged_User_Info);
     $Invterandcon = array("" => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "TERMS_AND_CONDITIONS" => vtranslate("LBL_TERMS_AND_CONDITIONS", 'PDFMaker'));
     $viewer->assign("INVENTORYTERMSANDCONDITIONS", $Invterandcon);
     //custom functions
     $customFunctions = $this->getCustomFunctionsList();
     $viewer->assign("CUSTOM_FUNCTIONS", $customFunctions);
     //labels
     $global_lang_labels = @array_flip($app_strings);
     $global_lang_labels = @array_flip($global_lang_labels);
     asort($global_lang_labels);
     $viewer->assign("GLOBAL_LANG_LABELS", $global_lang_labels);
     $module_lang_labels = array();
     if ($select_module != "") {
         $mod_lang = $this->getModuleLanguageArray($select_module);
         $module_lang_labels = @array_flip($mod_lang);
         $module_lang_labels = @array_flip($module_lang_labels);
         asort($module_lang_labels);
     } else {
         $module_lang_labels[""] = vtranslate("LBL_SELECT_MODULE_FIELD", 'PDFMaker');
     }
     $viewer->assign("MODULE_LANG_LABELS", $module_lang_labels);
     list($custom_labels, $languages) = $PDFMaker->GetCustomLabels();
     $currLangId = "";
     foreach ($languages as $langId => $langVal) {
         if ($langVal["prefix"] == $current_language) {
             $currLangId = $langId;
             break;
         }
     }
     $vcustom_labels = array();
     if (count($custom_labels) > 0) {
         foreach ($custom_labels as $oLbl) {
             $currLangVal = $oLbl->GetLangValue($currLangId);
             if ($currLangVal == "") {
                 $currLangVal = $oLbl->GetFirstNonEmptyValue();
             }
             $vcustom_labels[$oLbl->GetKey()] = $currLangVal;
         }
         asort($vcustom_labels);
     } else {
         $vcustom_labels = vtranslate("LBL_SELECT_MODULE_FIELD", 'PDFMaker');
     }
     $viewer->assign("CUSTOM_LANG_LABELS", $vcustom_labels);
     $Header_Footer_Strings = array("" => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "PAGE" => $app_strings["Page"], "PAGES" => $app_strings["Pages"]);
     $viewer->assign("HEADER_FOOTER_STRINGS", $Header_Footer_Strings);
     //PDF FORMAT SETTINGS
     $Formats = array("A3" => "A3", "A4" => "A4", "A5" => "A5", "A6" => "A6", "Letter" => "Letter", "Legal" => "Legal", "Custom" => "Custom");
     // ITS4YOU VlZa
     $viewer->assign("FORMATS", $Formats);
     if (strpos($select_format, ";") > 0) {
         $tmpArr = explode(";", $select_format);
         $select_format = "Custom";
         $custom_format["width"] = $tmpArr[0];
         $custom_format["height"] = $tmpArr[1];
         $viewer->assign("CUSTOM_FORMAT", $custom_format);
     }
     $viewer->assign("SELECT_FORMAT", $select_format);
     //PDF ORIENTATION SETTINGS
     $Orientations = array("portrait" => vtranslate("portrait", 'PDFMaker'), "landscape" => vtranslate("landscape", 'PDFMaker'));
     $viewer->assign("ORIENTATIONS", $Orientations);
     $viewer->assign("SELECT_ORIENTATION", $select_orientation);
     //PDF STATUS SETTINGS
     $Status = array("1" => $app_strings["Active"], "0" => vtranslate("Inactive", 'PDFMaker'));
     $viewer->assign("STATUS", $Status);
     $viewer->assign("IS_ACTIVE", $is_active);
     if ($is_active == "0") {
         $viewer->assign("IS_DEFAULT_DV_CHECKED", 'disabled="disabled"');
         $viewer->assign("IS_DEFAULT_LV_CHECKED", 'disabled="disabled"');
     } elseif ($is_default > 0) {
         $is_default_bin = str_pad(base_convert($is_default, 10, 2), 2, "0", STR_PAD_LEFT);
         $is_default_lv = substr($is_default_bin, 0, 1);
         $is_default_dv = substr($is_default_bin, 1, 1);
         if ($is_default_lv == "1") {
             $viewer->assign("IS_DEFAULT_LV_CHECKED", 'checked="checked"');
         }
         if ($is_default_dv == "1") {
             $viewer->assign("IS_DEFAULT_DV_CHECKED", 'checked="checked"');
         }
     }
     $viewer->assign("ORDER", $order);
     if ($is_portal == "1") {
         $viewer->assign("IS_PORTAL_CHECKED", 'checked="checked"');
     }
     if ($is_listview == "1") {
         $viewer->assign("IS_LISTVIEW_CHECKED", 'checked="checked"');
     }
     //PDF MARGIN SETTINGS
     if ($request->has("templateid") && !$request->isEmpty("templateid")) {
         $Margins = array("top" => $pdftemplateResult["margin_top"], "bottom" => $pdftemplateResult["margin_bottom"], "left" => $pdftemplateResult["margin_left"], "right" => $pdftemplateResult["margin_right"]);
         $Decimals = array("point" => $pdftemplateResult["decimal_point"], "decimals" => $pdftemplateResult["decimals"], "thousands" => $pdftemplateResult["thousands_separator"] != "sp" ? $pdftemplateResult["thousands_separator"] : " ");
     } else {
         $Margins = array("top" => "2", "bottom" => "2", "left" => "2", "right" => "2");
         $Decimals = array("point" => ",", "decimals" => "2", "thousands" => " ");
     }
     $viewer->assign("MARGINS", $Margins);
     $viewer->assign("DECIMALS", $Decimals);
     //PDF HEADER / FOOTER
     $header = "";
     $footer = "";
     if ($request->has("templateid") && !$request->isEmpty("templateid")) {
         $header = $pdftemplateResult["header"];
         $footer = $pdftemplateResult["footer"];
     }
     $viewer->assign("HEADER", $header);
     $viewer->assign("FOOTER", $footer);
     $hfVariables = array("##PAGE##" => vtranslate("LBL_CURRENT_PAGE", 'PDFMaker'), "##PAGES##" => vtranslate("LBL_ALL_PAGES", 'PDFMaker'), "##PAGE##/##PAGES##" => vtranslate("LBL_PAGE_PAGES", 'PDFMaker'));
     $viewer->assign("HEAD_FOOT_VARS", $hfVariables);
     $dateVariables = array("##DD.MM.YYYY##" => vtranslate("LBL_DATE_DD.MM.YYYY", 'PDFMaker'), "##DD-MM-YYYY##" => vtranslate("LBL_DATE_DD-MM-YYYY", 'PDFMaker'), "##MM-DD-YYYY##" => vtranslate("LBL_DATE_MM-DD-YYYY", 'PDFMaker'), "##YYYY-MM-DD##" => vtranslate("LBL_DATE_YYYY-MM-DD", 'PDFMaker'));
     $viewer->assign("DATE_VARS", $dateVariables);
     //PDF FILENAME FIELDS
     $filenameFields = array("#TEMPLATE_NAME#" => vtranslate("LBL_PDF_NAME", 'PDFMaker'), "#DD-MM-YYYY#" => vtranslate("LBL_CURDATE_DD-MM-YYYY", 'PDFMaker'), "#MM-DD-YYYY#" => vtranslate("LBL_CURDATE_MM-DD-YYYY", 'PDFMaker'), "#YYYY-MM-DD#" => vtranslate("LBL_CURDATE_YYYY-MM-DD", 'PDFMaker'));
     $viewer->assign("FILENAME_FIELDS", $filenameFields);
     $viewer->assign("NAME_OF_FILE", $nameOfFile);
     //Sharing
     $template_owners = get_user_array(false);
     $viewer->assign("TEMPLATE_OWNERS", $template_owners);
     $viewer->assign("TEMPLATE_OWNER", $owner);
     $sharing_types = array("public" => vtranslate("PUBLIC_FILTER", 'PDFMaker'), "private" => vtranslate("PRIVATE_FILTER", 'PDFMaker'), "share" => vtranslate("SHARE_FILTER", 'PDFMaker'));
     $viewer->assign("SHARINGTYPES", $sharing_types);
     $viewer->assign("SHARINGTYPE", $sharingtype);
     $cmod = $this->getModuleLanguageArray("Settings");
     //$cmod = return_specified_module_language($current_language, "Settings");
     $viewer->assign("CMOD", $cmod);
     //Constructing the Role Array
     $roleDetails = getAllRoleDetails();
     $i = 0;
     $roleIdStr = "";
     $roleNameStr = "";
     $userIdStr = "";
     $userNameStr = "";
     $grpIdStr = "";
     $grpNameStr = "";
     foreach ($roleDetails as $roleId => $roleInfo) {
         if ($i != 0) {
             if ($i != 1) {
                 $roleIdStr .= ", ";
                 $roleNameStr .= ", ";
             }
             $roleName = $roleInfo[0];
             $roleIdStr .= "'" . $roleId . "'";
             $roleNameStr .= "'" . addslashes(decode_html($roleName)) . "'";
         }
         $i++;
     }
     //Constructing the User Array
     $l = 0;
     $userDetails = getAllUserName();
     foreach ($userDetails as $userId => $userInfo) {
         if ($l != 0) {
             $userIdStr .= ", ";
             $userNameStr .= ", ";
         }
         $userIdStr .= "'" . $userId . "'";
         $userNameStr .= "'" . $userInfo . "'";
         $l++;
     }
     //Constructing the Group Array
     $parentGroupArray = array();
     $m = 0;
     $grpDetails = getAllGroupName();
     foreach ($grpDetails as $grpId => $grpName) {
         if (!in_array($grpId, $parentGroupArray)) {
             if ($m != 0) {
                 $grpIdStr .= ", ";
                 $grpNameStr .= ", ";
             }
             $grpIdStr .= "'" . $grpId . "'";
             $grpNameStr .= "'" . addslashes(decode_html($grpName)) . "'";
             $m++;
         }
     }
     $viewer->assign("ROLEIDSTR", $roleIdStr);
     $viewer->assign("ROLENAMESTR", $roleNameStr);
     $viewer->assign("USERIDSTR", $userIdStr);
     $viewer->assign("USERNAMESTR", $userNameStr);
     $viewer->assign("GROUPIDSTR", $grpIdStr);
     $viewer->assign("GROUPNAMESTR", $grpNameStr);
     if (count($sharingMemberArray) > 0) {
         $outputMemberArr = array();
         foreach ($sharingMemberArray as $setype => $shareIdArr) {
             foreach ($shareIdArr as $shareId) {
                 switch ($setype) {
                     case "groups":
                         $groupInfo = getGroupName($shareId);
                         $memberName = $groupInfo[0];
                         $memberDisplay = "Group::";
                         break;
                     case "roles":
                         $memberName = getRoleName($shareId);
                         $memberDisplay = "Roles::";
                         break;
                     case "rs":
                         $memberName = getRoleName($shareId);
                         $memberDisplay = "RoleAndSubordinates::";
                         break;
                     case "users":
                         $memberName = getUserName($shareId);
                         $memberDisplay = "User::";
                         break;
                 }
                 $outputMemberArr[] = $setype . "::" . $shareId;
                 $outputMemberArr[] = $memberDisplay . $memberName;
             }
         }
         $viewer->assign("MEMBER", array_chunk($outputMemberArr, 2));
     }
     //Ignored picklist values
     $pvsql = "SELECT value FROM vtiger_pdfmaker_ignorepicklistvalues";
     $pvresult = $adb->pquery($pvsql, array());
     $pvvalues = "";
     while ($pvrow = $adb->fetchByAssoc($pvresult)) {
         $pvvalues .= $pvrow["value"] . ", ";
     }
     $viewer->assign("IGNORE_PICKLIST_VALUES", rtrim($pvvalues, ", "));
     $More_Fields = array("CURRENCYNAME" => vtranslate("LBL_CURRENCY_NAME", 'PDFMaker'), "CURRENCYSYMBOL" => vtranslate("LBL_CURRENCY_SYMBOL", 'PDFMaker'), "CURRENCYCODE" => vtranslate("LBL_CURRENCY_CODE", 'PDFMaker'), "TOTALWITHOUTVAT" => vtranslate("LBL_VARIABLE_SUMWITHOUTVAT", 'PDFMaker'), "TOTALDISCOUNT" => vtranslate("LBL_VARIABLE_TOTALDISCOUNT", 'PDFMaker'), "TOTALDISCOUNTPERCENT" => vtranslate("LBL_VARIABLE_TOTALDISCOUNT_PERCENT", 'PDFMaker'), "TOTALAFTERDISCOUNT" => vtranslate("LBL_VARIABLE_TOTALAFTERDISCOUNT", 'PDFMaker'), "VAT" => vtranslate("LBL_VARIABLE_VAT", 'PDFMaker'), "VATPERCENT" => vtranslate("LBL_VARIABLE_VAT_PERCENT", 'PDFMaker'), "VATBLOCK" => vtranslate("LBL_VARIABLE_VAT_BLOCK", 'PDFMaker'), "TOTALWITHVAT" => vtranslate("LBL_VARIABLE_SUMWITHVAT", 'PDFMaker'), "SHTAXTOTAL" => vtranslate("LBL_SHTAXTOTAL", 'PDFMaker'), "SHTAXAMOUNT" => vtranslate("LBL_SHTAXAMOUNT", 'PDFMaker'), "ADJUSTMENT" => vtranslate("LBL_ADJUSTMENT", 'PDFMaker'), "TOTAL" => vtranslate("LBL_VARIABLE_TOTALSUM", 'PDFMaker'));
     //formatable VATBLOCK content
     $vatblock_table = '<table border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse;">
             		<tr>
                         <td>' . $app_strings["Name"] . '</td>
                         <td>' . vtranslate("LBL_VATBLOCK_VAT_PERCENT", 'PDFMaker') . '</td>
                         <td>' . vtranslate("LBL_VATBLOCK_SUM", 'PDFMaker') . '</td>
                         <td>' . vtranslate("LBL_VATBLOCK_VAT_VALUE", 'PDFMaker') . '</td>
                     </tr>
             		<tr>
                         <td colspan="4">#VATBLOCK_START#</td>
                     </tr>
             		<tr>
             			<td>$VATBLOCK_LABEL$</td>
             			<td>$VATBLOCK_VALUE$</td>
             			<td>$VATBLOCK_NETTO$</td>
             			<td>$VATBLOCK_VAT$</td>
             		</tr>
             		<tr>
                         <td colspan="4">#VATBLOCK_END#</td>
                     </tr>
                 </table>';
     $vatblock_table = str_replace(array("\r\n", "\r", "\n", "\t"), "", $vatblock_table);
     $vatblock_table = ereg_replace(" {2,}", ' ', $vatblock_table);
     $viewer->assign("VATBLOCK_TABLE", $vatblock_table);
     $ModCommentsModules = array();
     /*
             $ModComments = is_numeric(getTabId("ModComments"));
             if ($ModComments == true) {
                 $sql = "SELECT relmodule FROM vtiger_fieldmodulerel WHERE module='ModComments' AND relmodule != 'ModComments'";
                 $result = $adb->pquery($sql,array());
                 while ($row = $adb->fetchByAssoc($result))
                     $ModCommentsModules[$row["relmodule"]] = $row["relmodule"];
             }
     */
     foreach ($ModuleIDS as $module => $module_id) {
         $this->getModuleFields($module, $module_id);
     }
     //Permissions are taken into consideration when dealing with realted modules
     $AllowedRelMods = array();
     if (count($this->All_Related_Modules) > 0) {
         foreach ($this->All_Related_Modules as $Mod => $RelMods) {
             foreach ($RelMods as $RelModKey => $RelMod) {
                 $RelModName = $RelMod[2];
                 if (isPermitted($RelModName, '') == "yes") {
                     $AllowedRelMods[$Mod][$RelModKey] = $RelMod;
                 }
             }
         }
     }
     $this->All_Related_Modules = $AllowedRelMods;
     // Fix of emtpy selectbox in case of selected module does not have any related modules
     foreach ($Modulenames as $key => $value) {
         if (!isset($this->All_Related_Modules[$key])) {
             $this->All_Related_Modules[$key] = array();
         }
     }
     $viewer->assign("ALL_RELATED_MODULES", $this->All_Related_Modules);
     if ($select_module != "" && count($this->All_Related_Modules[$select_module]) > 0) {
         foreach ($this->All_Related_Modules[$select_module] as $RelModArr) {
             $Related_Modules[$RelModArr[2] . "|" . $RelModArr[0]] = vtranslate($RelModArr[2]) . " (" . $RelModArr[1] . ")";
         }
     }
     $viewer->assign("RELATED_MODULES", $Related_Modules);
     $tacModules = array();
     $tac4you = is_numeric(getTabId("Tac4you"));
     if ($tac4you == true) {
         $sql = "SELECT tac4you_module FROM vtiger_tac4you_module WHERE presence = ?";
         $result = $adb->pquery($sql, array('1'));
         while ($row = $adb->fetchByAssoc($result)) {
             $tacModules[$row["tac4you_module"]] = $row["tac4you_module"];
         }
     }
     $desc4youModules = array();
     $desc4you = is_numeric(getTabId("Descriptions4you"));
     if ($desc4you == true) {
         $sql = "SELECT b.name FROM vtiger_links AS a INNER JOIN vtiger_tab AS b USING (tabid) WHERE linktype = ? AND linkurl = ?";
         $result = $adb->pquery($sql, array('DETAILVIEWWIDGET', 'block://ModDescriptions4you:modules/Descriptions4you/ModDescriptions4you.php'));
         while ($row = $adb->fetchByAssoc($result)) {
             $desc4youModules[$row["name"]] = $row["name"];
         }
     }
     $Settings_Profiles_Record_Model = new Settings_Profiles_Record_Model();
     foreach ($this->ModuleFields as $module => $Blocks) {
         $Optgroupts = array();
         $current_mod_strings = $this->getModuleLanguageArray($module);
         $moduleModel = Vtiger_Module_Model::getInstance($module);
         $b = 0;
         if ($module == 'Calendar') {
             $b++;
             $Optgroupts[] = '"' . vtranslate('Calendar') . '","' . $b . '"';
             $Convert_ModuleFields['Calendar|1'] .= ',"Record ID","CALENDAR_CRMID"';
             $SelectModuleFields['Calendar'][vtranslate('Calendar')]["CALENDAR_CRMID"] = "Record ID";
             $EventModel = Vtiger_Module_Model::getInstance('Events');
         }
         foreach ($Blocks as $block_label => $block_fields) {
             $b++;
             $Options = array();
             if ($block_label != "TEMP_MODCOMMENTS_BLOCK") {
                 $optgroup_value = vtranslate($block_label, $module);
                 if ($optgroup_value == $block_label) {
                     $optgroup_value = vtranslate($block_label, 'PDFMaker');
                 }
             } else {
                 $optgroup_value = vtranslate("LBL_MODCOMMENTS_INFORMATION", 'PDFMaker');
             }
             $Optgroupts[] = '"' . $optgroup_value . '","' . $b . '"';
             if (count($block_fields) > 0) {
                 $sql1 = "SELECT * FROM vtiger_field WHERE fieldid IN (" . generateQuestionMarks($block_fields) . ")";
                 $result1 = $adb->pquery($sql1, $block_fields);
                 while ($row1 = $adb->fetchByAssoc($result1)) {
                     $fieldname = $row1['fieldname'];
                     $fieldlabel = $row1['fieldlabel'];
                     $fieldModel = Vtiger_Field_Model::getInstance($fieldname, $moduleModel);
                     if (!$fieldModel || !$fieldModel->getPermissions('readonly')) {
                         if ($module == 'Calendar') {
                             $eventFieldModel = Vtiger_Field_Model::getInstance($fieldname, $EventModel);
                             if (!$eventFieldModel || !$eventFieldModel->getPermissions('readonly')) {
                                 continue;
                             }
                         } else {
                             continue;
                         }
                     }
                     $option_key = strtoupper($module . "_" . $fieldname);
                     if (isset($current_mod_strings[$fieldlabel]) and $current_mod_strings[$fieldlabel] != "") {
                         $option_value = $current_mod_strings[$fieldlabel];
                     } elseif (isset($app_strings[$fieldlabel]) and $app_strings[$fieldlabel] != "") {
                         $option_value = $app_strings[$fieldlabel];
                     } else {
                         $option_value = $fieldlabel;
                     }
                     $option_value = nl2br($option_value);
                     if ($module == 'Calendar') {
                         if ($option_key == 'CALENDAR_ACTIVITYTYPE' || $option_key == 'CALENDAR_DUE_DATE') {
                             $Convert_ModuleFields['Calendar|1'] .= ',"' . $option_value . '","' . $option_key . '"';
                             $SelectModuleFields['Calendar'][vtranslate('Calendar')][$option_key] = $option_value;
                             continue;
                         } elseif (!isset($Existing_ModuleFields[$option_key])) {
                             $Existing_ModuleFields[$option_key] = $optgroup_value;
                         } else {
                             $Convert_ModuleFields['Calendar|1'] .= ',"' . $option_value . '","' . $option_key . '"';
                             $SelectModuleFields['Calendar'][vtranslate('Calendar')][$option_key] = $option_value;
                             $Unset_Module_Fields[] = '"' . $option_value . '","' . $option_key . '"';
                             unset($SelectModuleFields['Calendar'][$Existing_ModuleFields[$option_key]][$option_key]);
                             continue;
                         }
                     }
                     $Options[] = '"' . $option_value . '","' . $option_key . '"';
                     $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
                 }
             }
             //variable RECORD ID added
             if ($b == 1) {
                 $option_value = "Record ID";
                 $option_key = strtoupper($module . "_CRMID");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
                 $option_value = vtranslate('Created Time') . ' (' . vtranslate('Due Date & Time') . ')';
                 $option_key = strtoupper($module . "_CREATEDTIME_DATETIME");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
                 $option_value = vtranslate('Modified Time') . ' (' . vtranslate('Due Date & Time') . ')';
                 $option_key = strtoupper($module . "_MODIFIEDTIME_DATETIME");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
             }
             //end
             if ($block_label == "LBL_TERMS_INFORMATION" && isset($tacModules[$module])) {
                 $option_value = vtranslate("LBL_TAC4YOU", 'PDFMaker');
                 $option_key = strtoupper($module . "_TAC4YOU");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
             }
             if ($block_label == "LBL_DESCRIPTION_INFORMATION" && isset($desc4youModules[$module])) {
                 $option_value = vtranslate("LBL_DESC4YOU", 'PDFMaker');
                 $option_key = strtoupper($module . "_DESC4YOU");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
             }
             //ModComments support
             if ($block_label == "TEMP_MODCOMMENTS_BLOCK" && in_array($module, $ModCommentsModules) == true) {
                 $option_value = vtranslate("LBL_MODCOMMENTS", 'PDFMaker');
                 $option_key = strtoupper($module . "_MODCOMMENTS");
                 $Options[] = '"' . $option_value . '","' . $option_key . '"';
                 $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value;
             }
             $Convert_RelatedModuleFields[$module . "|" . $b] = implode(",", $Options);
             $OptionsRelMod = array();
             if (($block_label == "LBL_DETAILS_BLOCK" || $block_label == "LBL_ITEM_DETAILS") && ($module == "Quotes" || $module == "Invoice" || $module == "SalesOrder" || $module == "PurchaseOrder" || $module == "Issuecards" || $module == "Receiptcards" || $module == "Creditnote" || $module == "StornoInvoice")) {
                 $Set_More_Fields = $More_Fields;
                 if ($module == "Invoice") {
                     $Set_More_Fields[strtoupper($module) . "_RECEIVED"] = vtranslate("Received", $module);
                 }
                 if ($module == "Invoice" || $module == "PurchaseOrder") {
                     $Set_More_Fields[strtoupper($module) . "_BALANCE"] = vtranslate("Balance", $module);
                 }
                 foreach ($Set_More_Fields as $variable => $variable_name) {
                     $variable_key = strtoupper($variable);
                     $Options[] = '"' . $variable_name . '","' . $variable_key . '"';
                     $SelectModuleFields[$module][$optgroup_value][$variable_key] = $variable_name;
                     if ($variable_key != "VATBLOCK") {
                         $OptionsRelMod[] = '"' . $variable_name . '","' . strtoupper($module) . '_' . $variable_key . '"';
                     }
                 }
             }
             //this concatenation is because of need to have extra Details block in Inventory modules which are as related modules
             $Convert_RelatedModuleFields[$module . "|" . $b] .= implode(',', $OptionsRelMod);
             $Convert_ModuleFields[$module . "|" . $b] = implode(",", $Options);
         }
         if ($module == 'Calendar') {
             $Convert_ModuleFields['Calendar|1'] = str_replace(',"Record ID","CALENDAR_CRMID",', "", $Convert_ModuleFields['Calendar|1']);
             $Convert_ModuleFields['Calendar|1'] .= ',"Record ID","CALENDAR_CRMID"';
             unset($SelectModuleFields['Calendar'][vtranslate('Calendar')]["CALENDAR_CRMID"]);
             $SelectModuleFields['Calendar'][vtranslate('Calendar')]["CALENDAR_CRMID"] = "Record ID";
         }
         $Convert_ModuleBlocks[$module] = implode(",", $Optgroupts);
     }
     foreach ($Convert_ModuleFields as $cmf_key => $cmf_value) {
         if (substr($cmf_key, 0, 9) == 'Calendar|' && $cmf_key != 'Calendar|1') {
             foreach ($Unset_Module_Fields as $to_unset) {
                 $cmf_value = str_replace($to_unset, '', $cmf_value);
                 $cmf_value = str_replace(",,", ',', $cmf_value);
                 $Convert_ModuleFields[$cmf_key] = trim($cmf_value, ',');
             }
         }
     }
     $viewer->assign("MODULE_BLOCKS", $Convert_ModuleBlocks);
     $viewer->assign("RELATED_MODULE_FIELDS", $Convert_RelatedModuleFields);
     $viewer->assign("MODULE_FIELDS", $Convert_ModuleFields);
     //Product block fields start
     // Product bloc templates
     $sql = "SELECT * FROM vtiger_pdfmaker_productbloc_tpl";
     $result = $adb->pquery($sql, array());
     $Productbloc_tpl[""] = vtranslate("LBL_PLS_SELECT", 'PDFMaker');
     while ($row = $adb->fetchByAssoc($result)) {
         $Productbloc_tpl[$row["body"]] = $row["name"];
     }
     $viewer->assign("PRODUCT_BLOC_TPL", $Productbloc_tpl);
     $ProductBlockFields = $PDFMaker->GetProductBlockFields($select_module);
     foreach ($ProductBlockFields as $viewer_key => $pbFields) {
         $viewer->assign($viewer_key, $pbFields);
     }
     //Product block fields end
     //Related block postprocessing
     $Related_Blocks = $PDFMaker->GetRelatedBlocks($select_module);
     $viewer->assign("RELATED_BLOCKS", $Related_Blocks);
     //Related blocks end
     if ($templateid != "" || $select_module != "") {
         $viewer->assign("SELECT_MODULE_FIELD", $SelectModuleFields[$select_module]);
         $smf_filename = $SelectModuleFields[$select_module];
         if ($select_module == "Invoice" || $select_module == "Quotes" || $select_module == "SalesOrder" || $select_module == "PurchaseOrder" || $select_module == "Issuecards" || $select_module == "Receiptcards" || $select_module == "Creditnote" || $select_module == "StornoInvoice") {
             unset($smf_filename["Details"]);
         }
         $viewer->assign("SELECT_MODULE_FIELD_FILENAME", $smf_filename);
     }
     // header / footer display settings
     $disp_optionsArr = array("DH_FIRST", "DH_OTHER");
     $disp_header_bin = str_pad(base_convert($disp_header, 10, 2), 2, "0", STR_PAD_LEFT);
     for ($i = 0; $i < count($disp_optionsArr); $i++) {
         if (substr($disp_header_bin, $i, 1) == "1") {
             $viewer->assign($disp_optionsArr[$i], 'checked="checked"');
         }
     }
     if ($disp_header == "3") {
         $viewer->assign("DH_ALL", 'checked="checked"');
     }
     $disp_optionsArr = array("DF_FIRST", "DF_LAST", "DF_OTHER");
     $disp_footer_bin = str_pad(base_convert($disp_footer, 10, 2), 3, "0", STR_PAD_LEFT);
     for ($i = 0; $i < count($disp_optionsArr); $i++) {
         if (substr($disp_footer_bin, $i, 1) == "1") {
             $viewer->assign($disp_optionsArr[$i], 'checked="checked"');
         }
     }
     if ($disp_footer == "7") {
         $viewer->assign("DF_ALL", 'checked="checked"');
     }
     $ListView_Block = array("" => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "LISTVIEWBLOCK_START" => vtranslate("LBL_ARTICLE_START", 'PDFMaker'), "LISTVIEWBLOCK_END" => vtranslate("LBL_ARTICLE_END", 'PDFMaker'), "CRIDX" => vtranslate("LBL_COUNTER", 'PDFMaker'));
     $viewer->assign("LISTVIEW_BLOCK_TPL", $ListView_Block);
     $version_type = ucfirst($PDFMaker->GetVersionType());
     $viewer->assign("VERSION", $version_type . " " . PDFMaker_Version_Helper::$version);
     $category = getParentTab();
     $viewer->assign("CATEGORY", $category);
     $viewer->view('Edit.tpl', 'PDFMaker');
 }
<?php

/*+********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 ********************************************************************************/
require_once 'include/utils/utils.php';
require_once 'include/utils/UserInfoUtil.php';
require_once 'Smarty_setup.php';
$delete_role_id = vtlib_purify($_REQUEST['roleid']);
$delete_role_name = getRoleName($delete_role_id);
global $app_strings;
global $app_list_strings;
global $mod_strings;
$smarty = new vtigerCRM_Smarty();
$smarty->assign("APP", $app_strings);
$smarty->assign("MOD", return_module_language($current_language, 'Settings'));
$smarty->assign("THEME", $theme);
$smarty->assign("CMOD", $mod_strings);
global $theme;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("ROLEID", $delete_role_id);
$smarty->assign("ROLENAME", $delete_role_name);
$opt = '<a href="javascript:openPopup(\'' . $delete_role_id . '\');"><img src="' . vtiger_imageurl('select.gif', $theme) . '" border="0" align="absmiddle"></a>';
$smarty->assign("ROLEPOPUPBUTTON", $opt);
Example #16
0
 private function getFldFormatedValue($fld_uitype, $fld_value, $fld_alias, $fld_calculation_type = "", $currency_id = "", $skip_format = false)
 {
     global $log;
     $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getFldFormatedValue");
     global $log;
     $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getFldFormatedValue");
     global $log;
     $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getFldFormatedValue");
     global $log;
     $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getFldFormatedValue");
     global $default_charset;
     $trimed_fld_value = trim($fld_value);
     if ($fld_calculation_type != "") {
         $fld_calculation_type = strtolower($fld_calculation_type);
     }
     if (!isset($this->outputformat) || $this->outputformat != "HTML") {
         $skip_format = true;
     }
     if ($fld_alias == "crmid") {
         return $fld_value;
     }
     if ($trimed_fld_value != "") {
         switch ($fld_uitype) {
             case "10":
                 /* if (is_numeric($trimed_fld_value) && $skip_format!==true) {
                    $parent_module = getSalesEntityType($trimed_fld_value);
                    $displayValueArray = getEntityName($parent_module, $trimed_fld_value);
                    if (!empty($displayValueArray)) {
                    foreach ($displayValueArray as $key => $value) {
                    $displayValue = $value;
                    }
                    }
                    if ($skip_format===true) {
                    $fld_value = $displayValue;
                    } else {
                    $fld_value = "<a href='index.php?module=$parent_module&action=DetailView&record=$trimed_fld_value'>$displayValue</a>";
                    }
                    } */
                 break;
             case "15":
                 $fieldModule = "";
                 if (isset($this->columns_array[$fld_alias]) && $this->columns_array[$fld_alias] != "") {
                     list($tablename, $colname, $module_field, $fieldname, $single) = split(":", $this->columns_array[$fld_alias]);
                     $module_field_arr = explode("_", $module_field);
                     $fieldModule = $module_field_arr[0];
                 }
                 if ($fieldModule != "") {
                     $fld_value = getTranslatedString($trimed_fld_value, $fieldModule);
                 } else {
                     $fld_value = getTranslatedString($trimed_fld_value);
                 }
                 break;
             case "17":
                 if ($trimed_fld_value != "" && $trimed_fld_value != "-") {
                     if ($skip_format === true) {
                         $fld_value = $trimed_fld_value;
                     } else {
                         $fld_value = "<a href='http://{$trimed_fld_value}' target='_blank'>{$trimed_fld_value}</a>";
                     }
                 }
                 break;
             case "19":
                 if ($fld_alias == "notecontent") {
                     $fld_value = decode_html($trimed_fld_value);
                 } else {
                     $fld_value = nl2br($trimed_fld_value);
                 }
                 break;
             case "21":
                 $fld_value = nl2br($trimed_fld_value);
                 break;
             case "22":
                 $fld_value = nl2br($trimed_fld_value);
                 break;
             case "24":
                 $fld_value = nl2br($trimed_fld_value);
                 break;
             case "56":
                 if ($trimed_fld_value == 1) {
                     //Since "yes" is not been translated it is given as app strings here..
                     $fld_value = getTranslatedString('yes');
                 } else {
                     $fld_value = getTranslatedString('no');
                 }
                 break;
             case "66":
                 if (is_numeric($trimed_fld_value)) {
                     $parent_module = getSalesEntityType($trimed_fld_value);
                     $displayValueArray = getEntityName($parent_module, $trimed_fld_value);
                     if (!empty($displayValueArray)) {
                         foreach ($displayValueArray as $key => $value) {
                             $displayValue = $value;
                         }
                     }
                     if ($skip_format === true) {
                         $fld_value = $displayValue;
                     } else {
                         $fld_value = "<a href='index.php?module={$parent_module}&view=Detail&record={$trimed_fld_value}' >{$displayValue}</a>";
                         //$fld_value = "<a href='index.php?module=$parent_module&action=DetailView&record=$trimed_fld_value' >$displayValue</a>";
                     }
                 }
                 break;
             case "67":
                 if (is_numeric($trimed_fld_value)) {
                     $parent_module = getSalesEntityType($trimed_fld_value);
                     $displayValueArray = getEntityName($parent_module, $trimed_fld_value);
                     if (!empty($displayValueArray)) {
                         foreach ($displayValueArray as $key => $value) {
                             $displayValue = $value;
                         }
                     }
                     if ($skip_format === true) {
                         $fld_value = $displayValue;
                     } else {
                         $fld_value = "<a href='index.php?module={$parent_module}&view=Detail&record={$trimed_fld_value}' >{$displayValue}</a>";
                         //$fld_value = "<a href='index.php?module=$parent_module&action=DetailView&record=$trimed_fld_value' >$displayValue</a>";
                     }
                 }
                 break;
             case "68":
                 if (is_numeric($trimed_fld_value)) {
                     $parent_module = getSalesEntityType($trimed_fld_value);
                     $displayValueArray = getEntityName($parent_module, $trimed_fld_value);
                     if (!empty($displayValueArray)) {
                         foreach ($displayValueArray as $key => $value) {
                             $displayValue = $value;
                         }
                     }
                     if ($skip_format === true) {
                         $fld_value = $displayValue;
                     } else {
                         $fld_value = "<a href='index.php?module={$parent_module}&view=Detail&record={$trimed_fld_value}' >{$displayValue}</a>";
                         //$fld_value = "<a href='index.php?module=$parent_module&action=DetailView&record=$trimed_fld_value' >$displayValue</a>";
                     }
                 }
                 break;
             case "5":
                 if (!in_array($fld_alias, $this->g_flds)) {
                     $date = new DateTimeField($trimed_fld_value);
                     $fld_value = $date->getDisplayDate();
                 }
                 break;
             case "6":
                 if (!in_array($fld_alias, $this->g_flds)) {
                     $date = new DateTimeField($trimed_fld_value);
                     $fld_value = $date->getDisplayDate();
                 }
                 break;
             case "23":
                 if (!in_array($fld_alias, $this->g_flds)) {
                     $date = new DateTimeField($trimed_fld_value);
                     $fld_value = $date->getDisplayDate();
                 }
                 break;
             case "70":
                 if (!in_array($fld_alias, $this->g_flds)) {
                     $date = new DateTimeField($trimed_fld_value);
                     $fld_value = $date->getDisplayDate();
                 }
                 break;
             case "71":
                 if ($trimed_fld_value == "-") {
                     $trimed_fld_value = 0;
                 }
                 $fld_value = number_format($trimed_fld_value, "3", ".", "");
                 $currencyField = new CurrencyField($fld_value);
                 $fld_value = $currencyField->getDisplayValue(null, true);
                 if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) {
                     $fld_value = CurrencyField::appendCurrencySymbol($fld_value, $this->currency_symbols[$currency_id]);
                 } else {
                     $currencySymbol = $currencyField->getCurrencySymbol();
                     $fld_value = CurrencyField::appendCurrencySymbol($fld_value, $currencySymbol);
                 }
                 break;
             case "72":
                 if ($trimed_fld_value == "-") {
                     $trimed_fld_value = 0;
                 }
                 $fld_value = number_format($trimed_fld_value, "3", ".", "");
                 $currencyField = new CurrencyField($fld_value);
                 $fld_value = $currencyField->getDisplayValue(null, true);
                 if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) {
                     $fld_value = CurrencyField::appendCurrencySymbol($fld_value, $this->currency_symbols[$currency_id]);
                 } else {
                     $currencySymbol = $currencyField->getCurrencySymbol();
                     $fld_value = CurrencyField::appendCurrencySymbol($fld_value, $currencySymbol);
                 }
                 break;
             case "75":
                 if (is_numeric($trimed_fld_value)) {
                     $parent_module = getSalesEntityType($trimed_fld_value);
                     if (vtlib_isModuleActive($parent_module)) {
                         $displayValueArray = getEntityName($parent_module, $trimed_fld_value);
                         if (!empty($displayValueArray)) {
                             foreach ($displayValueArray as $key => $value) {
                                 $displayValue = $value;
                             }
                         }
                         if ($skip_format === true) {
                             $fld_value = $displayValue;
                         } else {
                             $fld_value = "<a href='index.php?module={$parent_module}&view=Detail&record={$trimed_fld_value}' >{$displayValue}</a>";
                             //$fld_value = "<a href='index.php?module=$parent_module&action=DetailView&record=$trimed_fld_value' >$displayValue</a>";
                         }
                     }
                 }
                 break;
             case "76":
                 if (is_numeric($trimed_fld_value)) {
                     $parent_module = getSalesEntityType($trimed_fld_value);
                     if (vtlib_isModuleActive($parent_module)) {
                         $displayValueArray = getEntityName($parent_module, $trimed_fld_value);
                         if (!empty($displayValueArray)) {
                             foreach ($displayValueArray as $key => $value) {
                                 $displayValue = $value;
                             }
                         }
                         if ($skip_format === true) {
                             $fld_value = $displayValue;
                         } else {
                             $fld_value = "<a href='index.php?module={$parent_module}&view=Detail&record={$trimed_fld_value}' >{$displayValue}</a>";
                             //$fld_value = "<a href='index.php?module=$parent_module&action=DetailView&record=$trimed_fld_value' >$displayValue</a>";
                         }
                     }
                 }
                 break;
             case "78":
                 if (is_numeric($trimed_fld_value)) {
                     $parent_module = getSalesEntityType($trimed_fld_value);
                     if (vtlib_isModuleActive($parent_module)) {
                         $displayValueArray = getEntityName($parent_module, $trimed_fld_value);
                         if (!empty($displayValueArray)) {
                             foreach ($displayValueArray as $key => $value) {
                                 $displayValue = $value;
                             }
                         }
                         if ($skip_format === true) {
                             $fld_value = $displayValue;
                         } else {
                             $fld_value = "<a href='index.php?module={$parent_module}&view=Detail&record={$trimed_fld_value}' >{$displayValue}</a>";
                             //$fld_value = "<a href='index.php?module=$parent_module&action=DetailView&record=$trimed_fld_value' >$displayValue</a>";
                         }
                     }
                 }
                 break;
             case "79":
                 if (is_numeric($trimed_fld_value)) {
                     $parent_module = getSalesEntityType($trimed_fld_value);
                     if (vtlib_isModuleActive($parent_module)) {
                         $displayValueArray = getEntityName($parent_module, $trimed_fld_value);
                         if (!empty($displayValueArray)) {
                             foreach ($displayValueArray as $key => $value) {
                                 $displayValue = $value;
                             }
                         }
                         if ($skip_format === true) {
                             $fld_value = $displayValue;
                         } else {
                             $fld_value = "<a href='index.php?module={$parent_module}&view=Detail&record={$trimed_fld_value}' >{$displayValue}</a>";
                             //$fld_value = "<a href='index.php?module=$parent_module&action=DetailView&record=$trimed_fld_value' >$displayValue</a>";
                         }
                     }
                 }
                 break;
             case "80":
                 if (is_numeric($trimed_fld_value)) {
                     $parent_module = getSalesEntityType($trimed_fld_value);
                     if (vtlib_isModuleActive($parent_module)) {
                         $displayValueArray = getEntityName($parent_module, $trimed_fld_value);
                         if (!empty($displayValueArray)) {
                             foreach ($displayValueArray as $key => $value) {
                                 $displayValue = $value;
                             }
                         }
                         if ($skip_format === true) {
                             $fld_value = $displayValue;
                         } else {
                             $fld_value = "<a href='index.php?module={$parent_module}&view=Detail&record={$trimed_fld_value}' >{$displayValue}</a>";
                             //$fld_value = "<a href='index.php?module=$parent_module&action=DetailView&record=$trimed_fld_value' >$displayValue</a>";
                         }
                     }
                 }
                 break;
             case "81":
                 if (is_numeric($trimed_fld_value)) {
                     $parent_module = getSalesEntityType($trimed_fld_value);
                     if (vtlib_isModuleActive($parent_module)) {
                         $displayValueArray = getEntityName($parent_module, $trimed_fld_value);
                         if (!empty($displayValueArray)) {
                             foreach ($displayValueArray as $key => $value) {
                                 $displayValue = $value;
                             }
                         }
                         if ($skip_format === true) {
                             $fld_value = $displayValue;
                         } else {
                             $fld_value = "<a href='index.php?module={$parent_module}&view=Detail&record={$trimed_fld_value}' >{$displayValue}</a>";
                             //$fld_value = "<a href='index.php?module=$parent_module&action=DetailView&record=$trimed_fld_value' >$displayValue</a>";
                         }
                     }
                 }
                 break;
             case "98":
                 $fld_value = getRoleName($fld_value);
                 break;
             default:
                 // ITS4YOU-UP SlOl | 26.8.2015 10:43
                 // assumption: all of fields contains uitype expext of inventory fields ! ...
                 if ($this->columns_array["uitype_{$fld_alias}"] == "") {
                     $fld_array = $clear_fld_array = explode("_", $fld_alias);
                     $relfieldid = $fld_array[count($fld_array) - 1];
                     if (is_numeric($relfieldid)) {
                         unset($clear_fld_array[count($fld_array) - 1]);
                         $adb = PearDatabase::getInstance();
                         $relfieldres = $adb->pquery("SELECT uitype FROM vtiger_field WHERE fieldid = ? ", array($relfieldid));
                         if ($adb->num_rows($relfieldres) > 0) {
                             $rel_field_row = $adb->fetchByAssoc($relfieldres, 0);
                             $rel_field_uitype = $rel_field_row["uitype"];
                             if ($rel_field_uitype == 10) {
                                 unset($clear_fld_array[count($fld_array) - 2]);
                             }
                         }
                         $fld_alias = implode("_", $clear_fld_array);
                     }
                 }
                 // ITS4YOU-END 26.8.2015 10:43
                 if ($fld_alias == "converted") {
                     if ($trimed_fld_value == 1) {
                         //Since "yes" is not been translated it is given as app strings here..
                         $fld_value = getTranslatedString('Converted');
                     } else {
                         $fld_value = getTranslatedString('Not Converted');
                     }
                     // oldo1
                 } elseif ($fld_alias == "quantity" && is_numeric($fld_value)) {
                     $fld_value = $this->formatFldNumberValue($fld_value, "", 0);
                 } elseif (in_array($fld_alias, ITS4YouReports::$intentory_fields) && is_numeric($fld_value) && $fld_calculation_type != "count") {
                     $fld_value = $this->formatFldNumberValue($fld_value, $currency_id);
                 } elseif (isset($fld_calculation_type) && !in_array($fld_calculation_type, array("", "count"))) {
                     $fld_value = $this->formatFldNumberValue($fld_value);
                 }
                 break;
         }
     } else {
         $fld_value = "";
     }
     if ($skip_format !== true && $this->report_obj->reportinformations["list_link_field"] === $fld_alias) {
         if ($this->data_record_id != "") {
             $parenttab = getParentTab();
             $data_module = $this->report_obj->primarymodule;
             $recordId = $this->data_record_id;
             $fld_value = "<a href='index.php?module={$data_module}&view=Detail&record={$recordId}' title='" . getTranslatedString($data_module, $data_module) . "' >{$fld_value}</a>";
             //$fld_value = "<a href='index.php?module=$data_module&parenttab=$parenttab&action=DetailView&record=$recordId' title='".getTranslatedString($data_module, $data_module)."'>$fld_value</a>";
         }
     }
     return $fld_value;
 }
Example #17
0
        } else {
            if (setUserGroup($userid, $group)) {
                setInfo("Gruppe erfolgreich zugewiesen!");
            } else {
                setError("Die Gruppe konnte nicht zugewiesen werden!");
            }
        }
        header("location: {$SETTINGS['url']}/user/{$userid}");
        exit;
    }
}
$userinfo = getUserInfo($userid);
$userstats = getUserStats($userid);
$username = htmlspecialchars($userinfo->username, 0, 'UTF-8');
$lastname = htmlspecialchars($userinfo->lastname, 0, 'UTF-8');
$group = getRoleName($userinfo->group);
$correct = $userinfo->correct;
$wrong = $userinfo->wrong;
$total = $correct + $wrong;
$ratio = $total == 0 ? 0 : round($correct * 100 / $total, 2);
$created = $userstats->add;
$modified = $userstats->mod;
$deleted = $userstats->del;
$selectedguest = $userinfo->group == 'guest' ? ' selected="selected"' : '';
$selecteduser = $userinfo->group == 'user' ? ' selected="selected"' : '';
$selectedadmin = $userinfo->group == 'admin' ? ' selected="selected"' : '';
$deletecode = sha1(rand());
$_SESSION['deletecode'] = $deletecode;
$groupcode = sha1(rand());
$_SESSION['groupcode'] = $groupcode;
$deleteenabled = $userid != $_SESSION['userid'] ? '' : ' disabled="disabled"';
 public static function generateRecipientOption($type, $value, $name = '')
 {
     switch ($type) {
         case "users":
             if (empty($name)) {
                 $name = getUserFullName($value);
             }
             $optionName = 'User::' . addslashes(decode_html($name));
             $optionValue = 'users::' . $value;
             break;
         case "groups":
             if (empty($name)) {
                 $groupInfo = getGroupName($value);
                 $name = $groupInfo[0];
             }
             $optionName = 'Group::' . addslashes(decode_html($name));
             $optionValue = 'groups::' . $value;
             break;
         case "roles":
             if (empty($name)) {
                 $name = getRoleName($value);
             }
             $optionName = 'Roles::' . addslashes(decode_html($name));
             $optionValue = 'roles::' . $value;
             break;
         case "rs":
             if (empty($name)) {
                 $name = getRoleName($value);
             }
             $optionName = 'RoleAndSubordinates::' . addslashes(decode_html($name));
             $optionValue = 'rs::' . $value;
             break;
     }
     return '<option value="' . $optionValue . '">' . $optionName . '</option>';
 }
Example #19
0
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 *********************************************************************************/
require_once 'include/utils/utils.php';
require_once 'modules/PickList/PickListUtils.php';
require_once 'Smarty_setup.php';
global $adb, $current_user, $app_strings, $current_language, $theme;
$smarty = new vtigerCRM_Smarty();
$smarty->assign("IMAGE_PATH", $image_path);
$fieldName = vtlib_purify($_REQUEST["fieldname"]);
$fieldLabel = vtlib_purify($_REQUEST['fieldlabel']);
$moduleName = vtlib_purify($_REQUEST["moduleName"]);
$roleid = vtlib_purify($_REQUEST['roleid']);
if (!empty($roleid)) {
    $roleName = getRoleName($roleid);
}
if ($moduleName == 'Events') {
    $temp_module_strings = return_module_language($current_language, 'Calendar');
} else {
    $temp_module_strings = return_module_language($current_language, $moduleName);
}
if (!empty($fieldName)) {
    foreach (getAllPickListValues($fieldName, $temp_module_strings) as $key => $value) {
        $values[$key] = $value;
    }
}
foreach (getAssignedPicklistValues($fieldName, $roleid, $adb, $temp_module_strings) as $key => $value) {
    $assignedValues[$key] = $value;
}
$smarty->assign("THEME", $theme);
Example #20
0
 function getListViewEntries($focus, $module, $result, $navigationInfo, $skipActions = false)
 {
     require 'user_privileges/user_privileges_' . $this->user->id . '.php';
     global $listview_max_textlength, $theme, $default_charset;
     $fields = $this->queryGenerator->getFields();
     $whereFields = $this->queryGenerator->getWhereFields();
     $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule());
     $moduleFields = $meta->getModuleFields();
     $accessibleFieldList = array_keys($moduleFields);
     $listViewFields = array_intersect($fields, $accessibleFieldList);
     $referenceFieldList = $this->queryGenerator->getReferenceFieldList();
     foreach ($referenceFieldList as $fieldName) {
         if (in_array($fieldName, $listViewFields)) {
             $field = $moduleFields[$fieldName];
             $this->fetchNameList($field, $result);
         }
     }
     $db = PearDatabase::getInstance();
     $rowCount = $db->num_rows($result);
     $ownerFieldList = $this->queryGenerator->getOwnerFieldList();
     foreach ($ownerFieldList as $fieldName) {
         if (in_array($fieldName, $listViewFields)) {
             $field = $moduleFields[$fieldName];
             $idList = array();
             for ($i = 0; $i < $rowCount; $i++) {
                 $id = $this->db->query_result($result, $i, $field->getColumnName());
                 if (!isset($this->ownerNameList[$fieldName][$id])) {
                     $idList[] = $id;
                 }
             }
             if (count($idList) > 0) {
                 if (!is_array($this->ownerNameList[$fieldName])) {
                     $this->ownerNameList[$fieldName] = getOwnerNameList($idList);
                 } else {
                     //array_merge API loses key information so need to merge the arrays
                     // manually.
                     $newOwnerList = getOwnerNameList($idList);
                     foreach ($newOwnerList as $id => $name) {
                         $this->ownerNameList[$fieldName][$id] = $name;
                     }
                 }
             }
         }
     }
     foreach ($listViewFields as $fieldName) {
         $field = $moduleFields[$fieldName];
         if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) {
             $this->setupAccessiblePicklistValueList($fieldName);
         }
     }
     $useAsterisk = get_use_asterisk($this->user->id);
     $data = array();
     for ($i = 0; $i < $rowCount; ++$i) {
         //Getting the recordId
         if ($module != 'Users') {
             $baseTable = $meta->getEntityBaseTable();
             $moduleTableIndexList = $meta->getEntityTableIndexList();
             $baseTableIndex = $moduleTableIndexList[$baseTable];
             $recordId = $db->query_result($result, $i, $baseTableIndex);
             $ownerId = $db->query_result($result, $i, "smownerid");
         } else {
             $recordId = $db->query_result($result, $i, "id");
         }
         $row = array();
         foreach ($listViewFields as $fieldName) {
             $field = $moduleFields[$fieldName];
             $uitype = $field->getUIType();
             $rawValue = $this->db->query_result($result, $i, $field->getColumnName());
             if ($module == 'Calendar') {
                 $activityType = $this->db->query_result($result, $i, 'activitytype');
             }
             if ($uitype != 8) {
                 $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset);
             } else {
                 $value = $rawValue;
             }
             if ($module == 'Documents' && $fieldName == 'filename') {
                 $downloadtype = $db->query_result($result, $i, 'filelocationtype');
                 if ($downloadtype == 'I') {
                     $ext = substr($value, strrpos($value, ".") + 1);
                     $ext = strtolower($ext);
                     if ($value != '') {
                         if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') {
                             $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                         } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') {
                             $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                         } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') {
                             $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                         } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') {
                             $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>";
                         } else {
                             $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                         }
                     }
                 } elseif ($downloadtype == 'E') {
                     if (trim($value) != '') {
                         $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>";
                     } else {
                         $value = '--';
                         $fileicon = '';
                     }
                 } else {
                     $value = ' --';
                     $fileicon = '';
                 }
                 $fileName = $db->query_result($result, $i, 'filename');
                 $downloadType = $db->query_result($result, $i, 'filelocationtype');
                 $status = $db->query_result($result, $i, 'filestatus');
                 $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?";
                 $fileIdRes = $db->pquery($fileIdQuery, array($recordId));
                 $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid');
                 if ($fileName != '' && $status == 1) {
                     if ($downloadType == 'I') {
                         $value = "<a href='index.php?module=uploads&action=downloadfile&" . "entityid={$recordId}&fileid={$fileId}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$recordId});'>" . textlength_check($value) . "</a>";
                     } elseif ($downloadType == 'E') {
                         $value = "<a target='_blank' href='{$fileName}' onclick='javascript:" . "dldCntIncrease({$recordId});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . textlength_check($value) . "</a>";
                     } else {
                         $value = ' --';
                     }
                 }
                 $value = $fileicon . $value;
             } elseif ($module == 'Documents' && $fieldName == 'filesize') {
                 $downloadType = $db->query_result($result, $i, '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 = ' --';
                 }
             } elseif ($module == 'Documents' && $fieldName == 'filestatus') {
                 if ($value == 1) {
                     $value = getTranslatedString('yes', $module);
                 } elseif ($value == 0) {
                     $value = getTranslatedString('no', $module);
                 } else {
                     $value = '--';
                 }
             } elseif ($module == 'Documents' && $fieldName == 'filetype') {
                 $downloadType = $db->query_result($result, $i, 'filelocationtype');
                 if ($downloadType == 'E' || $downloadType != 'I') {
                     $value = '--';
                 }
             } elseif ($field->getUIType() == '27') {
                 if ($value == 'I') {
                     $value = getTranslatedString('LBL_INTERNAL', $module);
                 } elseif ($value == 'E') {
                     $value = getTranslatedString('LBL_EXTERNAL', $module);
                 } else {
                     $value = ' --';
                 }
             } elseif ($field->getFieldDataType() == 'picklist') {
                 if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName])) {
                     $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>";
                 } else {
                     $value = getTranslatedString($value, $module);
                     $value = textlength_check($value);
                 }
             } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') {
                 if ($value != '' && $value != '0000-00-00') {
                     $date = new DateTimeField($value);
                     $value = $date->getDisplayDate();
                     if ($field->getFieldDataType() == 'datetime') {
                         $value .= ' ' . $date->getDisplayTime();
                     }
                 } elseif ($value == '0000-00-00') {
                     $value = '';
                 }
             } elseif ($field->getFieldDataType() == 'currency') {
                 if ($value != '') {
                     if ($field->getUIType() == 72) {
                         if ($fieldName == 'unit_price') {
                             $currencyId = getProductBaseCurrency($recordId, $module);
                             $cursym_convrate = getCurrencySymbolandCRate($currencyId);
                             $currencySymbol = $cursym_convrate['symbol'];
                         } else {
                             $currencyInfo = getInventoryCurrencyInfo($module, $recordId);
                             $currencySymbol = $currencyInfo['currency_symbol'];
                         }
                         $value = number_format($value, 2, '.', '');
                         $currencyValue = CurrencyField::convertToUserFormat($value, null, true);
                         $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol);
                     } else {
                         //changes made to remove vtiger_currency symbol infront of each
                         //vtiger_potential amount
                         if ($value != 0) {
                             $value = CurrencyField::convertToUserFormat($value);
                         }
                     }
                 }
             } elseif ($field->getFieldDataType() == 'url') {
                 $matchPattern = "^[\\w]+:\\/\\/^";
                 preg_match($matchPattern, $rawValue, $matches);
                 if (!empty($matches[0])) {
                     $value = '<a href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>';
                 } else {
                     $value = '<a href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>';
                 }
             } elseif ($field->getFieldDataType() == 'email') {
                 if ($_SESSION['internal_mailer'] == 1) {
                     //check added for email link in user detailview
                     $fieldId = $field->getFieldId();
                     $value = "<a href=\"javascript:InternalMailer({$recordId},{$fieldId}," . "'{$fieldName}','{$module}','record_id');\">" . textlength_check($value) . "</a>";
                 } else {
                     $value = '<a href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>';
                 }
             } elseif ($field->getFieldDataType() == 'boolean') {
                 if ($value == 1) {
                     $value = getTranslatedString('yes', $module);
                 } elseif ($value == 0) {
                     $value = getTranslatedString('no', $module);
                 } else {
                     $value = '--';
                 }
             } elseif ($field->getUIType() == 98) {
                 $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=' . 'Settings&roleid=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>';
             } elseif ($field->getFieldDataType() == 'multipicklist') {
                 $value = $value != "" ? str_replace(' |##| ', ', ', $value) : "";
                 if (!$is_admin && $value != '') {
                     $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array();
                     $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>";
                     $tmp = '';
                     $tmpArray = array();
                     foreach ($valueArray as $index => $val) {
                         if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) {
                             if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim($val), $this->picklistValueMap[$fieldName])) {
                                 $tmpArray[] = $notaccess;
                                 $tmp .= ', ' . $notaccess;
                             } else {
                                 $tmpArray[] = $val;
                                 $tmp .= ', ' . $val;
                             }
                         } else {
                             $tmpArray[] = '...';
                             $tmp .= '...';
                         }
                     }
                     $value = implode(', ', $tmpArray);
                     $value = textlength_check($value);
                 }
             } elseif ($field->getFieldDataType() == 'skype') {
                 $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : "";
             } elseif ($field->getFieldDataType() == 'phone') {
                 if ($useAsterisk == 'true') {
                     $value = "<a href='javascript:;' onclick='startCall(&quot;{$value}&quot;, " . "&quot;{$recordId}&quot;)'>" . textlength_check($value) . "</a>";
                 } else {
                     $value = textlength_check($value);
                 }
             } elseif ($field->getFieldDataType() == 'reference') {
                 $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList();
                 $moduleList = $referenceFieldInfoList[$fieldName];
                 if (count($moduleList) == 1) {
                     $parentModule = $moduleList[0];
                 } else {
                     $parentModule = $this->typeList[$value];
                 }
                 if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) {
                     $parentMeta = $this->queryGenerator->getMeta($parentModule);
                     $value = textlength_check($this->nameList[$fieldName][$value]);
                     if ($parentMeta->isModuleEntity() && $parentModule != "Users") {
                         $value = "<a href='index.php?module={$parentModule}&action=DetailView&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>";
                     }
                 } else {
                     $value = '--';
                 }
             } elseif ($field->getFieldDataType() == 'owner') {
                 $value = textlength_check($this->ownerNameList[$fieldName][$value]);
             } elseif ($field->getUIType() == 25) {
                 //TODO clean request object reference.
                 $contactId = $_REQUEST['record'];
                 $emailId = $this->db->query_result($result, $i, "activityid");
                 $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId));
                 $value = $this->db->query_result($result1, 0, "access_count");
                 if (!$value) {
                     $value = 0;
                 }
             } elseif ($field->getUIType() == 8) {
                 if (!empty($value)) {
                     $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset);
                     $json = new Zend_Json();
                     $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val)));
                 }
             } elseif (in_array($uitype, array(7, 9, 90))) {
                 $value = "<span align='right'>" . textlength_check($value) . "</div>";
             } elseif ($field->getUIType() == 55) {
                 $value = getTranslatedString($value, $currentModule);
             } else {
                 $value = textlength_check($value);
             }
             $parenttab = getParentTab();
             $nameFields = $this->queryGenerator->getModuleNameFields($module);
             $nameFieldList = explode(',', $nameFields);
             if (in_array($fieldName, $nameFieldList) && $module != 'Emails') {
                 $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>";
             } elseif ($fieldName == $focus->list_link_field && $module != 'Emails') {
                 $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>";
             }
             // vtlib customization: For listview javascript triggers
             $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=" . "'{$fieldName}' vtmodule='{$module}' style='display:none;'></span>";
             // END
             $row[] = $value;
         }
         //Added for Actions ie., edit and delete links in listview
         $actionLinkInfo = "";
         if (isPermitted($module, "EditView", "") == 'yes') {
             $edit_link = $this->getListViewEditLink($module, $recordId);
             if (isset($navigationInfo['start']) && $navigationInfo['start'] > 1 && $module != 'Emails') {
                 $actionLinkInfo .= "<a href=\"{$edit_link}&start=" . $navigationInfo['start'] . "\">" . getTranslatedString("LNK_EDIT", $module) . "</a> ";
             } else {
                 $actionLinkInfo .= "<a href=\"{$edit_link}\">" . getTranslatedString("LNK_EDIT", $module) . "</a> ";
             }
         }
         if (isPermitted($module, "Delete", "") == 'yes') {
             $del_link = $this->getListViewDeleteLink($module, $recordId);
             if ($actionLinkInfo != "" && $del_link != "") {
                 $actionLinkInfo .= " | ";
             }
             if ($del_link != "") {
                 $actionLinkInfo .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . getTranslatedString("LNK_DELETE", $module) . "</a>";
             }
         }
         // Record Change Notification
         if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) {
             if (!$focus->isViewed($recordId)) {
                 $actionLinkInfo .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>";
             }
         }
         // END
         if ($actionLinkInfo != "" && !$skipActions) {
             $row[] = $actionLinkInfo;
         }
         $data[$recordId] = $row;
     }
     return $data;
 }
Example #21
0
/** Function to get the Entity Display Link
 *  @param $entityid -- Entity Id
 *  @params $entityType --  The entity type may be vtiger_groups or vtiger_roles or rs -- Type Varchar
 *  @returns the Entity Display link
 */
function getEntityDisplayLink($entityType, $entityid)
{
    global $log;
    $log->debug("Entering getEntityDisplayLink(" . $entityType . "," . $entityid . ") method ...");
    if ($entityType == 'groups') {
        $groupNameArr = getGroupInfo($entityid);
        $display_out = "<a href='index.php?module=Settings&action=GroupDetailView&returnaction=OrgSharingDetailView&groupId=" . $entityid . "'>Group::" . $groupNameArr[0] . " </a>";
    } elseif ($entityType == 'roles') {
        $roleName = getRoleName($entityid);
        $display_out = "<a href='index.php?module=Settings&action=RoleDetailView&returnaction=OrgSharingDetailView&roleid=" . $entityid . "'>Role::" . $roleName . "</a>";
    } elseif ($entityType == 'rs') {
        $roleName = getRoleName($entityid);
        $display_out = "<a href='index.php?module=Settings&action=RoleDetailView&returnaction=OrgSharingDetailView&roleid=" . $entityid . "'>RoleAndSubordinate::" . $roleName . "</a>";
    }
    $log->debug("Exiting getEntityDisplayLink method ...");
    return $display_out;
}
Example #22
0
 public static function ReportSharing(Vtiger_Request $request, $viewer)
 {
     $moduleName = $request->getModule();
     $record = $request->get('record');
     $R_Data = $request->getAll();
     $viewer->assign("MODULE", $moduleName);
     $reportModel = ITS4YouReports_Record_Model::getCleanInstance($record);
     $primary_module = $reportModel->getPrimaryModule();
     $primary_moduleid = $reportModel->getPrimaryModuleId();
     $current_user = Users_Record_Model::getCurrentUserModel();
     //$Report_Informations = $reportModel->getReportInformations();
     $Report_Informations = $reportModel->report->reportinformations;
     $LBL_INFORMATIONS_4YOU = vtranslate("LBL_STEP8_INFO", $moduleName);
     $viewer->assign("LBL_INFORMATIONS_4YOU", $LBL_INFORMATIONS_4YOU);
     //require_once('include/utils/GetUserGroups.php');
     // ITS4YOU-UP SlOl 26. 4. 2013 9:47:59
     $template_owners = get_user_array(false);
     if (isset($Report_Informations["owner"]) && $Report_Informations["owner"] != "") {
         $selected_owner = $Report_Informations["owner"];
     } else {
         $selected_owner = $current_user->id;
     }
     $viewer->assign("TEMPLATE_OWNERS", $template_owners);
     $owner = isset($R_Data['template_owner']) && $R_Data['template_owner'] != '' ? $R_Data['template_owner'] : $selected_owner;
     $viewer->assign("TEMPLATE_OWNER", $owner);
     $sharing_types = array("public" => vtranslate("PUBLIC_FILTER", $moduleName), "private" => vtranslate("PRIVATE_FILTER", $moduleName), "share" => vtranslate("SHARE_FILTER", $moduleName));
     $viewer->assign("SHARINGTYPES", $sharing_types);
     if ($request->get('reporttype') == "custom_report") {
         $sharingtype = "private";
     } else {
         $sharingtype = "public";
     }
     if (isset($R_Data['sharing']) && $R_Data['sharing'] != '') {
         $sharingtype = $R_Data['sharing'];
     } elseif (isset($Report_Informations["sharing"]) && $Report_Informations["sharing"] != "") {
         $sharingtype = $Report_Informations["sharing"];
     }
     $viewer->assign("SHARINGTYPE", $sharingtype);
     //$cmod = return_specified_module_language($current_language, "Settings");
     //$viewer->assign("CMOD", $cmod);
     $sharingMemberArray = array();
     if (isset($R_Data['sharingSelectedColumns']) && $R_Data['sharingSelectedColumns'] != '') {
         $sharingMemberArray = explode("|", trim($R_Data['sharingSelectedColumns'], "|"));
     } elseif (isset($Report_Informations["members_array"]) && !empty($Report_Informations["members_array"])) {
         $sharingMemberArray = $Report_Informations["members_array"];
     }
     $sharingMemberArray = array_unique($sharingMemberArray);
     if (count($sharingMemberArray) > 0) {
         $outputMemberArr = array();
         foreach ($sharingMemberArray as $setype => $shareIdArr) {
             $shareIdArr = explode("::", $shareIdArr);
             $shareIdArray = array();
             $shareIdArray[$shareIdArr[0]] = $shareIdArr[1];
             foreach ($shareIdArray as $shareType => $shareId) {
                 switch ($shareType) {
                     case "groups":
                         $groupArray = getGroupName($shareId);
                         $memberName = $groupArray[0];
                         $memberDisplay = "Group::";
                         break;
                     case "roles":
                         $memberName = getRoleName($shareId);
                         $memberDisplay = "Roles::";
                         break;
                     case "rs":
                         $memberName = getRoleName($shareId);
                         $memberDisplay = "RoleAndSubordinates::";
                         break;
                     case "users":
                         $memberName = getUserFullName($shareId);
                         $memberDisplay = "User::";
                         break;
                 }
                 $outputMemberArr[] = $shareType . "::" . $shareId;
                 $outputMemberArr[] = $memberDisplay . $memberName;
             }
         }
         $viewer->assign("MEMBER", array_chunk($outputMemberArr, 2));
     }
     // ITS4YOU-END
     //Constructing the Role Array
     $roleDetails = getAllRoleDetails();
     $i = 0;
     $roleIdStr = "";
     $roleNameStr = "";
     $userIdStr = "";
     $userNameStr = "";
     $grpIdStr = "";
     $grpNameStr = "";
     foreach ($roleDetails as $roleId => $roleInfo) {
         if ($i != 0) {
             if ($i != 1) {
                 $roleIdStr .= ", ";
                 $roleNameStr .= ", ";
             }
             $roleName = $roleInfo[0];
             $roleIdStr .= "'" . $roleId . "'";
             $roleNameStr .= "'" . addslashes(decode_html($roleName)) . "'";
         }
         $i++;
     }
     //Constructing the User Array
     $l = 0;
     $userDetails = getAllUserName();
     foreach ($userDetails as $userId => $userInfo) {
         if ($l != 0) {
             $userIdStr .= ", ";
             $userNameStr .= ", ";
         }
         $userIdStr .= "'" . $userId . "'";
         $userNameStr .= "'" . $userInfo . "'";
         $l++;
     }
     //Constructing the Group Array
     $parentGroupArray = array();
     $m = 0;
     $grpDetails = getAllGroupName();
     foreach ($grpDetails as $grpId => $grpName) {
         if (!in_array($grpId, $parentGroupArray)) {
             if ($m != 0) {
                 $grpIdStr .= ", ";
                 $grpNameStr .= ", ";
             }
             $grpIdStr .= "'" . $grpId . "'";
             $grpNameStr .= "'" . addslashes(decode_html($grpName)) . "'";
             $m++;
         }
     }
     $viewer->assign("ROLEIDSTR", $roleIdStr);
     $viewer->assign("ROLENAMESTR", $roleNameStr);
     $viewer->assign("USERIDSTR", $userIdStr);
     $viewer->assign("USERNAMESTR", $userNameStr);
     $viewer->assign("GROUPIDSTR", $grpIdStr);
     $viewer->assign("GROUPNAMESTR", $grpNameStr);
     $visiblecriteria = $reportModel->getVisibleCriteria();
     $viewer->assign("VISIBLECRITERIA", $visiblecriteria);
     return $viewer->view('ReportSharing.tpl', $moduleName, true);
 }
Example #23
0
        } else {
            setError('Fehler beim speichern der Sortierreihenfolge!');
        }
        header("location: {$SETTINGS['url']}/statistics");
        exit;
    }
}
$stats = getStatistics($orderby);
if ($stats === false) {
    setError('Fehler beim laden der Statistik!');
}
$tablebody = '';
foreach ($stats as $user) {
    $username = htmlspecialchars($user->username, 0, 'UTF-8');
    $lastname = htmlspecialchars($user->lastname, 0, 'UTF-8');
    $group = getRoleName($user->group);
    $userid = $user->id;
    $ratio = intval($user->ratio);
    $name = $username;
    $extra = '';
    if ($isAdmin) {
        $name = "<a href=\"{$SETTINGS['path']}/user/{$userid}\">{$name}</a>";
        $extra = "<td>{$group}</td>";
    }
    $tablebody .= "<tr><td>{$name} ({$lastname})</td><td>{$user->total}</td><td>{$user->correct}</td><td>{$user->wrong}</td><td>{$ratio} %</td>{$extra}</tr>\n";
}
$xhdr = $isAdmin ? "<th>Gruppe</th>" : '';
$table = <<<EOT
<table class="list">
\t<thead>
\t\t<tr>
Example #24
0
}
if (isset($_POST['parenttab'])) {
    $parenttab = getParentTab();
}
$log->debug("Saved record with id of " . $return_id);
//Asha: Added Check to see if the mode is User Creation and if yes, then sending the email notification to the User with Login details.
if ($_REQUEST['mode'] == 'create') {
    global $app_strings, $mod_strings, $default_charset;
    require_once 'modules/Emails/mail.php';
    $user_emailid = $focus->column_fields['email1'];
    $subject = $mod_strings['User Login Details'];
    $email_body = $app_strings['MSG_DEAR'] . " " . $focus->column_fields['last_name'] . ",<br><br>";
    $email_body .= $app_strings['LBL_PLEASE_CLICK'] . " <a href='" . $site_URL . "' target='_blank'>" . $app_strings['LBL_HERE'] . "</a> " . $mod_strings['LBL_TO_LOGIN'] . "<br><br>";
    $email_body .= $mod_strings['LBL_USER_NAME'] . " : " . $focus->column_fields['user_name'] . "<br>";
    $email_body .= $mod_strings['LBL_PASSWORD'] . " : " . $focus->column_fields['user_password'] . "<br>";
    $email_body .= $mod_strings['LBL_ROLE_NAME'] . " : " . getRoleName($_POST['user_role']) . "<br>";
    $email_body .= "<br>" . $app_strings['MSG_THANKS'] . "<br>" . $current_user->user_name;
    $email_body = htmlentities($email_body, ENT_QUOTES, $default_charset);
    $mail_status = send_mail('Users', $user_emailid, $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID, $subject, $email_body);
    if ($mail_status != 1) {
        $mail_status_str = $user_emailid . "=" . $mail_status . "&&&";
        $error_str = getMailErrorString($mail_status_str);
    }
}
$location = "Location: index.php?action=" . vtlib_purify($return_action) . "&module=" . vtlib_purify($return_module) . "&record=" . vtlib_purify($return_id);
if ($_REQUEST['modechk'] != 'prefview') {
    $location .= "&parenttab=" . vtlib_purify($parenttab);
}
if ($error_str != '') {
    $user = $focus->column_fields['user_name'];
    $location .= "&user={$user}&{$error_str}";
 /**
  * 返回所有用户json数据
  */
 public function getAllUser()
 {
     $page = $_POST['page'];
     $rows = $_POST['rows'];
     $user = M('user');
     $rsCount = $user->count();
     $rs = $user->limit(($page - 1) * $rows, $rows)->order('id asc')->select();
     // 向rs加入roleName属性
     for ($i = 0; $i < count($rs); $i++) {
         $rs[$i]['groupName'] = getRoleName($rs[$i]['id']);
     }
     $data['rows'] = $rs;
     $data['total'] = $rsCount;
     $data['rows'] = intval($data['total']) >= 1 ? $data['rows'] : '';
     $this->ajaxReturn($data);
 }
Example #26
0
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 (stristr(html_entity_decode($field_val), "<a href") === false && $uitype != 8) {
        $temp_val = textlength_check($field_val);
    } elseif ($uitype != 8) {
        $temp_val = html_entity_decode($field_val, ENT_QUOTES);
    } 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) {
                    $displayValue = $value;
                }
            }
            $value = "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>";
        } else {
            $value = '';
        }
    } else {
        if ($uitype == 53) {
            $value = textlength_check($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);
                }
            }
        } elseif ($uitype == 52) {
            $value = getUserName($adb->query_result($list_result, $list_result_count, $colname));
        } elseif ($uitype == 51) {
            $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 = '<a href="index.php?module=' . $module . '&action=DetailView&record=' . $parentid . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $entity_name . '</a>';
        } elseif ($uitype == 77) {
            $value = getUserName($adb->query_result($list_result, $list_result_count, 'inventorymanager'));
        } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) {
            if ($temp_val != '' && $temp_val != '0000-00-00') {
                $value = getDisplayDate($temp_val);
            } elseif ($temp_val == '0000-00-00') {
                $value = '';
            } else {
                $value = $temp_val;
            }
        } 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 = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                }
            }
            $value = $current_module_strings[$temp_val] != '' ? $current_module_strings[$temp_val] : ($app_strings[$temp_val] != '' ? $app_strings[$temp_val] : $temp_val);
            if ($value != "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>") {
                $value = textlength_check($value);
            }
        } elseif ($uitype == 16) {
            $value = getTranslatedString($temp_val, $currentModule);
        } elseif ($uitype == 71 || $uitype == 72) {
            if ($temp_val != '') {
                if ($fieldname == 'unit_price') {
                    $currency_id = getProductBaseCurrency($entity_id, $module);
                    $cursym_convrate = getCurrencySymbolandCRate($currency_id);
                    $value = "<font style='color:grey;'>" . $cursym_convrate['symbol'] . "</font> " . $temp_val;
                } else {
                    $rate = $user_info['conv_rate'];
                    //changes made to remove vtiger_currency symbol infront of each vtiger_potential amount
                    if ($temp_val != 0) {
                        $value = convertFromDollar($temp_val, $rate);
                    } else {
                        $value = $temp_val;
                    }
                }
            } else {
                $value = '';
            }
        } elseif ($uitype == 17) {
            $value = '<a href="http://' . $field_val . '" target="_blank">' . $temp_val . '</a>';
        } 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 = '<a href="javascript:InternalMailer(' . $entity_id . ',' . $fieldid . ',\'' . $fieldname . '\',\'' . $module . '\',\'record_id\');">' . $temp_val . '</a>';
                } else {
                    $value = $temp_val;
                }
            } else {
                $value = '<a href="mailto:' . $field_val . '">' . $temp_val . '</a>';
            }
        } 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 = '<a href=index.php?module=Contacts&action=DetailView&record=' . $temp_val . '>' . $name . '</a>';
                }
            } else {
                $value = '';
            }
        } 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 = '<a href=index.php?module=Campaigns&action=DetailView&record=' . $temp_val . '>' . $campaignname . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 59) {
            if ($temp_val != '') {
                $value = getProductName($temp_val);
            } else {
                $value = '';
            }
        } elseif ($uitype == 61) {
            $attachmentid = $adb->query_result($adb->pquery("SELECT * FROM vtiger_seattachmentsrel WHERE crmid = ?", array($entity_id)), 0, 'attachmentsid');
            $value = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $module . '&fileid=' . $attachmentid . '&filename=' . $temp_val . '">' . $temp_val . '</a>';
        } 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 = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>';
            } 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 = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>';
            } 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 = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>';
            } 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 = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 78) {
            if ($temp_val != '') {
                $quote_name = getQuoteName($temp_val);
                $value = '<a href=index.php?module=Quotes&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($quote_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 79) {
            if ($temp_val != '') {
                $purchaseorder_name = getPoName($temp_val);
                $value = '<a href=index.php?module=PurchaseOrder&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($purchaseorder_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 80) {
            if ($temp_val != '') {
                $salesorder_name = getSoName($temp_val);
                $value = "<a href=index.php?module=SalesOrder&action=DetailView&record={$temp_val}&parenttab=" . urlencode($tabname) . ">" . textlength_check($salesorder_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 75 || $uitype == 81) {
            if ($temp_val != '') {
                $vendor_name = getVendorName($temp_val);
                $value = '<a href=index.php?module=Vendors&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($vendor_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 98) {
            $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=Settings&roleid=' . $temp_val . '">' . textlength_check(getRoleName($temp_val)) . '</a>';
        } 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 = '<font color="red">' . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                        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 != "" ? "<a href='skype:{$temp_val}?call'>{$temp_val}</a>" : "";
        } 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;
        } elseif ($uitype == 11) {
            // Fix added for Trac Id: 6139
            if (vtlib_isModuleActive('PBXManager')) {
                $value = "<a href='javascript:;' onclick='startCall(&quot;{$temp_val}&quot;, &quot;{$entity_id}&quot;)'>" . $temp_val . "</a>";
            } else {
                $value = $temp_val;
            }
        } 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)));
            }
        } 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') {
                            $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '","' . $_REQUEST['form'] . '");\'>' . $temp_val . '</a>';
                        } 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);
                            }
                            $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . popup_decode_html($cntct_focus->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 . '");\'>' . $temp_val . '</a>';
                        } else {
                            if ($popuptype == 'toDospecific') {
                                $value = '<a href="javascript:window.close();" onclick=\'set_return_toDospecific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                            } else {
                                $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                            }
                        }
                    } 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'];
                        if ($_REQUEST['return_module'] == "Calendar") {
                            $value = '<a href="javascript:window.close();" id="calendarCont' . $entity_id . '" LANGUAGE=javascript onclick=\'add_data_to_relatedlist_incal("' . $entity_id . '","' . decode_html($slashes_temp_val) . '");\'>' . $temp_val . '</a>';
                        } else {
                            $value = '<a href="javascript:window.close();" onclick=\'add_data_to_relatedlist("' . $entity_id . '","' . $focus->record_id . '","' . $module . '");\'>' . $temp_val . '</a>';
                        }
                    } elseif ($popuptype == "formname_specific") {
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_formname_specific("' . $_REQUEST['form'] . '", "' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                    } 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 {
                            $unit_price = '';
                        }
                        $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(":", "<br>", $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 = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $qty_stock . '","' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '");\' vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>';
                    } 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 {
                            $unit_price = '';
                        }
                        $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(":", "<br>", $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 = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory_po("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '"); \'  vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>';
                    } 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 {
                            $unit_price = '';
                        }
                        $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 = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '");\'  vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>';
                    } elseif ($popuptype == "inventory_pb") {
                        $prod_id = $_REQUEST['productid'];
                        $flname = $_REQUEST['fldname'];
                        $listprice = getListPrice($prod_id, $entity_id);
                        $temp_val = popup_from_html($temp_val);
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_pb("' . $listprice . '", "' . $flname . '"); \'>' . $temp_val . '</a>';
                    } 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']));
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->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']) . '");\'>' . $temp_val . '</a>';
                    } 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']));
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->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']) . '");\'>' . $temp_val . '</a>';
                    } 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']));
                            $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_account_name)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->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']) . '");\'>' . $temp_val . '</a>';
                        } else {
                            if ($relatedentity == 'Contacts') {
                                require_once 'modules/Contacts/Contacts.php';
                                $contact_name = getContactName($relatedid);
                                $slashes_contact_name = popup_from_html($contact_name);
                                $slashes_contact_name = htmlspecialchars($slashes_contact_name, ENT_QUOTES, $default_charset);
                                $value = '<a href="javascript:window.close();" onclick=\'set_return_contact("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_contact_name)) . '");\'>' . $temp_val . '</a>';
                            } else {
                                $value = $temp_val;
                            }
                        }
                    } 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);
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>';
                        } 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);
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>';
                        } 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('yahooid', $module) == 'true') {
                                    $emailaddress2 = $adb->query_result($list_result, $list_result_count, "yahooid");
                                    $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 yahooid
                            $fieldid = $adb->query_result($queryres, 0, 'fieldid');
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . $name . '</a>';
                        } else {
                            $firstname = $adb->query_result($list_result, $list_result_count, "first_name");
                            $lastname = $adb->query_result($list_result, $list_result_count, "last_name");
                            $name = $lastname . ' ' . $firstname;
                            $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;
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',-1,"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>';
                        }
                    } 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']));
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . popup_decode_html($acct_focus->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']) . '");\'>' . $temp_val . '</a>';
                    } elseif ($popuptype == "specific_campaign") {
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_specific_campaign("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                    } else {
                        if ($colname == "lastname") {
                            $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') {
                            $value = '<a href="javascript:window.close();" onclick=\'set_return_todo("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                        } else {
                            $value = '<a href="javascript:window.close();" onclick=\'set_return("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>';
                        }
                    }
                } else {
                    if ($module == "Leads" && $colname == "lastname" || $module == "Contacts" && $colname == "lastname") {
                        $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                    } 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") {
                            $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&activity_mode=Task&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                        } else {
                            $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&activity_mode=Events&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                        }
                    } elseif ($module == "Vendors") {
                        $value = '<a href="index.php?action=DetailView&module=Vendors&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                    } elseif ($module == "PriceBooks") {
                        $value = '<a href="index.php?action=DetailView&module=PriceBooks&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                    } elseif ($module == "SalesOrder") {
                        $value = '<a href="index.php?action=DetailView&module=SalesOrder&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                    } elseif ($module == 'Emails') {
                        $value = $temp_val;
                    } else {
                        $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>';
                    }
                }
            } elseif ($fieldname == 'expectedroi' || $fieldname == 'actualroi' || $fieldname == 'actualcost' || $fieldname == 'budgetcost' || $fieldname == 'expectedrevenue') {
                $rate = $user_info['conv_rate'];
                $value = convertFromDollar($temp_val, $rate);
            } elseif (($module == 'Invoice' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder') && ($fieldname == 'hdnGrandTotal' || $fieldname == 'hdnSubTotal' || $fieldname == 'txtAdjustment' || $fieldname == 'hdnDiscountAmount' || $fieldname == 'hdnS_H_Amount')) {
                $currency_info = getInventoryCurrencyInfo($module, $entity_id);
                $currency_id = $currency_info['currency_id'];
                $currency_symbol = $currency_info['currency_symbol'];
                $value = $currency_symbol . $temp_val;
            } else {
                $value = $temp_val;
            }
        }
    }
    // Mike Crowe Mod --------------------------------------------------------Make right justified and vtiger_currency value
    if (in_array($uitype, array(71, 72, 7, 9, 90))) {
        $value = '<span align="right">' . $value . '</div>';
    }
    $log->debug("Exiting getValue method ...");
    return $value;
}
    $userinfo = array_chunk($userinfo, 2);
    //Check for Current User
    global $current_user;
    $current_role = fetchUserRole($current_user->id);
    $return_data = array('profileinfo' => $profileinfo, 'userinfo' => $userinfo);
    return $return_data;
}
if (isset($_REQUEST['roleid']) && $_REQUEST['roleid'] != '') {
    $roleid = vtlib_purify($_REQUEST['roleid']);
    $mode = vtlib_purify($_REQUEST['mode']);
    $roleInfo = getRoleInformation($roleid);
    $thisRoleDet = $roleInfo[$roleid];
    $rolename = $thisRoleDet[0];
    $parent = $thisRoleDet[3];
    //retreiving the vtiger_profileid
    $roleRelatedProfiles = getRoleRelatedProfiles($roleid);
}
$parentname = getRoleName($parent);
//Retreiving the Role Info
$roleInfoArr = getRoleInformation($roleid);
$rolename = $roleInfoArr[$roleid][0];
$smarty->assign("ROLE_NAME", $rolename);
$smarty->assign("ROLEID", $roleid);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MOD", return_module_language($current_language, 'Settings'));
$smarty->assign("APP", $app_strings);
$smarty->assign("CMOD", $mod_strings);
$smarty->assign("ROLEINFO", getStdOutput($roleid));
$smarty->assign("PARENTNAME", $parentname);
$smarty->display("RoleDetailView.tpl");
function genSignalLogWindow($selectedRoleNr)
{
    echo "<div class=LogWindow id=SignalLog minimized=false><div class=MinMaxButton></div><div class=Title>" . ($selectedRoleNr == -1 ? "All signals" : "Signals for " . getRoleName($selectedRoleNr)) . "</div>";
    checkRoleRules($selectedRoleNr);
    echo "</div>";
}
Example #29
-1
/** This function returns the detail view form vtiger_field and and its properties in array format.
 * Param $uitype - UI type of the vtiger_field
 * Param $fieldname - Form vtiger_field name
 * Param $fieldlabel - Form vtiger_field label name
 * Param $col_fields - array contains the vtiger_fieldname and values
 * Param $generatedtype - Field generated type (default is 1)
 * Param $tabid - vtiger_tab id to which the Field belongs to (default is "")
 * Return type is an array
 */
function getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid = '', $module = '')
{
    global $log;
    $log->debug("Entering getDetailViewOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $col_fields . "," . $generatedtype . "," . $tabid . ") method ...");
    global $adb;
    global $mod_strings;
    global $app_strings;
    global $current_user;
    global $theme;
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $fieldlabel = from_html($fieldlabel);
    $custfld = '';
    $value = '';
    $arr_data = array();
    $label_fld = array();
    $data_fld = array();
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    // vtlib customization: New uitype to handle relation between modules
    if ($uitype == '10') {
        $fieldlabel = getTranslatedString($fieldlabel, $module);
        $parent_id = $col_fields[$fieldname];
        if (!empty($parent_id)) {
            $parent_module = getSalesEntityType($parent_id);
            $valueTitle = getTranslatedString($parent_module, $parent_module);
            $displayValueArray = getEntityName($parent_module, $parent_id);
            if (!empty($displayValueArray)) {
                foreach ($displayValueArray as $key => $value) {
                    $displayValue = $value;
                }
            }
            // vtlib customization: For listview javascript triggers
            $modMetaInfo = getEntityFieldNames($parent_module);
            $modEName = is_array($modMetaInfo['fieldname']) ? $modMetaInfo['fieldname'][0] : $modMetaInfo['fieldname'];
            $vtlib_metainfo = "<span type='vtlib_metainfo' vtrecordid='{$parent_id}' vtfieldname=" . "'{$modEName}' vtmodule='{$parent_module}' style='display:none;'></span>";
            // END
            $label_fld = array($fieldlabel, "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>{$vtlib_metainfo}");
        } else {
            $moduleSpecificMessage = 'MODULE_NOT_SELECTED';
            if ($mod_strings[$moduleSpecificMessage] != "") {
                $moduleSpecificMessage = $mod_strings[$moduleSpecificMessage];
            }
            $label_fld = array($fieldlabel, '');
        }
    } else {
        if ($uitype == 99) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
            if ($fieldname == 'confirm_password') {
                return null;
            }
        } elseif ($uitype == 116 || $uitype == 117) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = getCurrencyName($col_fields[$fieldname]);
            $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name');
                $currency_id = $adb->query_result($pickListResult, $j, 'id');
                if ($col_fields[$fieldname] == $currency_id) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[$currency_id] = array($pickListValue => $chk_val);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 13 || $uitype == 104) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 16) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = getTranslatedString($col_fields[$fieldname], $module);
            $fieldname = $adb->sql_escape_string($fieldname);
            $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid";
            $params = array();
            $pickListResult = $adb->pquery($pick_query, $params);
            $noofpickrows = $adb->num_rows($pickListResult);
            $options = array();
            $count = 0;
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname)));
                $col_fields[$fieldname] = decode_html($col_fields[$fieldname]);
                if ($col_fields[$fieldname] == $pickListValue) {
                    $chk_val = "selected";
                    $count++;
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $pickListValue = to_html($pickListValue);
                $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 15) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
            $roleid = $current_user->roleid;
            $valueArr = explode("|##|", $col_fields[$fieldname]);
            $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $count = 0;
            $found = false;
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    if (in_array(trim($pickListValue), array_map("trim", $valueArr))) {
                        $chk_val = "selected";
                        $pickcount++;
                    } else {
                        $chk_val = '';
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected');
                }
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 115) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = getTranslatedString($col_fields[$fieldname]);
            $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname);
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname));
                if ($col_fields[$fieldname] == $pickListValue) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[] = array($pickListValue => $chk_val);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 33) {
            //uitype 33 added for multiselector picklist - Jeri
            $roleid = $current_user->roleid;
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = str_ireplace(' |##| ', ', ', $col_fields[$fieldname]);
            $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
            $options = array();
            $selected_entries = array();
            $selected_entries = explode(' |##| ', $col_fields[$fieldname]);
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    foreach ($selected_entries as $selected_entries_value) {
                        if (trim($selected_entries_value) == trim(htmlentities($pickListValue, ENT_QUOTES, $default_charset))) {
                            $chk_val = 'selected';
                            $pickcount++;
                            break;
                        } else {
                            $chk_val = '';
                        }
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $not_access_lbl = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                    $options[] = array($not_access_lbl, trim($selected_entries_value), 'selected');
                }
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 17) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $matchPattern = "^[\\w]+:\\/\\/^";
            $value = $col_fields[$fieldname];
            preg_match($matchPattern, $value, $matches);
            if (!empty($matches[0])) {
                $fieldValue = str_replace($matches, "", $value);
                $label_fld[] = $value;
            } else {
                if ($value != null) {
                    $label_fld[] = 'http://' . $value;
                } else {
                    $label_fld[] = '';
                }
            }
        } elseif ($uitype == 19) {
            if ($fieldname == 'notecontent' or $module == 'Timecontrol') {
                $col_fields[$fieldname] = decode_html($col_fields[$fieldname]);
            } else {
                $col_fields[$fieldname] = str_replace("&lt;br /&gt;", "<br>", $col_fields[$fieldname]);
            }
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 20 || $uitype == 21 || $uitype == 22 || $uitype == 24) {
            // Armando LC<scher 11.08.2005 -> B'descriptionSpan -> Desc: removed $uitype == 19 and made an aditional elseif above
            if ($uitype == 20) {
                //Fix the issue #4680
                $col_fields[$fieldname] = $col_fields[$fieldname];
            } else {
                $col_fields[$fieldname] = nl2br($col_fields[$fieldname]);
            }
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) {
            $account_id = $col_fields[$fieldname];
            if ($account_id != '') {
                $account_name = getAccountName($account_id);
            }
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $account_name;
            $label_fld["secid"] = $account_id;
            $label_fld["link"] = "index.php?module=Accounts&action=DetailView&record=" . $account_id;
            //Account Name View
        } elseif ($uitype == 52 || $uitype == 77 || $uitype == 101) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $user_id = $col_fields[$fieldname];
            $user_name = getOwnerName($user_id);
            if ($user_id != '') {
                $assigned_user_id = $user_id;
            } else {
                $assigned_user_id = $current_user->id;
            }
            if (is_admin($current_user)) {
                $label_fld[] = '<a href="index.php?module=Users&action=DetailView&record=' . $user_id . '">' . $user_name . '</a>';
            } else {
                $label_fld[] = $user_name;
            }
            if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $user_id), $assigned_user_id);
            }
            $label_fld["options"] = $users_combo;
        } elseif ($uitype == 11) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 53) {
            global $noof_group_rows, $adb;
            $owner_id = $col_fields[$fieldname];
            $user = '******';
            $result = $adb->pquery("SELECT count(*) as count from vtiger_users where id = ?", array($owner_id));
            if ($adb->query_result($result, 0, 'count') > 0) {
                $user = '******';
            }
            $owner_name = getOwnerName($owner_id);
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $owner_name;
            if (is_admin($current_user)) {
                $label_fld["secid"][] = $owner_id;
                if ($user == 'no') {
                    $label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=" . $owner_id;
                } else {
                    $label_fld["link"][] = "index.php?module=Users&action=DetailView&record=" . $owner_id;
                }
                //$label_fld["secid"][] = $groupid;
                //$label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=".$groupid;
            }
            //Security Checks
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $result = get_current_user_access_groups($module_name);
            } else {
                $result = get_group_options();
            }
            if ($result) {
                $nameArray = $adb->fetch_array($result);
            }
            global $current_user;
            //$value = $user_id;
            if ($owner_id != '') {
                if ($user == 'yes') {
                    $label_fld["options"][] = 'User';
                    $assigned_user_id = $owner_id;
                    $user_checked = "checked";
                    $team_checked = '';
                    $user_style = 'display:block';
                    $team_style = 'display:none';
                } else {
                    //$record = $col_fields["record_id"];
                    //$module = $col_fields["record_module"];
                    $label_fld["options"][] = 'Group';
                    $assigned_group_id = $owner_id;
                    $user_checked = '';
                    $team_checked = 'checked';
                    $user_style = 'display:none';
                    $team_style = 'display:block';
                }
            } else {
                $label_fld["options"][] = 'User';
                $assigned_user_id = $current_user->id;
                $user_checked = "checked";
                $team_checked = '';
                $user_style = 'display:block';
                $team_style = 'display:none';
            }
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id), $assigned_user_id);
            }
            if ($noof_group_rows != 0) {
                if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id, 'private'), $current_user->id);
                } else {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id), $current_user->id);
                }
            }
            $label_fld["options"][] = $users_combo;
            $label_fld["options"][] = $groups_combo;
        } elseif ($uitype == 55 || $uitype == 255) {
            if ($tabid == 4) {
                $query = "select vtiger_contactdetails.imagename from vtiger_contactdetails where contactid=?";
                $result = $adb->pquery($query, array($col_fields['record_id']));
                $imagename = $adb->query_result($result, 0, 'imagename');
                if ($imagename != '') {
                    $imgpath = "test/contact/" . $imagename;
                    $label_fld[] = getTranslatedString($fieldlabel, $module);
                } else {
                    $label_fld[] = getTranslatedString($fieldlabel, $module);
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
            }
            $value = $col_fields[$fieldname];
            if ($uitype == 255) {
                global $currentModule;
                $fieldpermission = getFieldVisibilityPermission($currentModule, $current_user->id, 'firstname');
            }
            if ($uitype == 255 && $fieldpermission == 0 && $fieldpermission != '') {
                $fieldvalue[] = '';
            } else {
                $roleid = $current_user->roleid;
                $subrole = getRoleSubordinates($roleid);
                if (count($subrole) > 0) {
                    $roleids = implode("','", $subrole);
                    $roleids = $roleids . "','" . $roleid;
                } else {
                    $roleids = $roleid;
                }
                if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
                    $pick_query = "select salutationtype from vtiger_salutationtype order by salutationtype";
                    $params = array();
                } else {
                    $pick_query = "select * from vtiger_salutationtype left join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid=vtiger_salutationtype.picklist_valueid where picklistid in (select picklistid from vtiger_picklist where name='salutationtype') and roleid=? order by salutationtype";
                    $params = array($current_user->roleid);
                }
                $pickListResult = $adb->pquery($pick_query, $params);
                $noofpickrows = $adb->num_rows($pickListResult);
                $sal_value = $col_fields["salutationtype"];
                $salcount = 0;
                for ($j = 0; $j < $noofpickrows; $j++) {
                    $pickListValue = $adb->query_result($pickListResult, $j, "salutationtype");
                    if ($sal_value == $pickListValue) {
                        $chk_val = "selected";
                        $salcount++;
                    } else {
                        $chk_val = '';
                    }
                }
                if ($salcount == 0 && $sal_value != '') {
                    $notacc = $app_strings['LBL_NOT_ACCESSIBLE'];
                }
                $sal_value = $col_fields["salutationtype"];
                if ($sal_value == '--None--') {
                    $sal_value = '';
                }
                $label_fld["salut"] = getTranslatedString($sal_value);
                $label_fld["notaccess"] = $notacc;
            }
            $label_fld[] = $value;
        } elseif ($uitype == 56) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $value = $col_fields[$fieldname];
            if ($value == 1) {
                //Since "yes" is not been translated it is given as app strings here..
                $displayValue = $app_strings['yes'];
            } else {
                $displayValue = $app_strings['no'];
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 156) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $value = $col_fields[$fieldname];
            if ($value == 'on') {
                //Since "yes" is not been translated it is given as app strings here..
                $displayValue = $app_strings['yes'];
            } else {
                $displayValue = $app_strings['no'];
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 57) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $contact_id = $col_fields[$fieldname];
            if ($contact_id != '') {
                $displayValueArray = getEntityName('Contacts', $contact_id);
                if (!empty($displayValueArray)) {
                    foreach ($displayValueArray as $key => $field_value) {
                        $contact_name = $field_value;
                    }
                } else {
                    $contact_name = '';
                }
            }
            $label_fld[] = $contact_name;
            $label_fld["secid"] = $contact_id;
            $label_fld["link"] = "index.php?module=Contacts&action=DetailView&record=" . $contact_id;
        } elseif ($uitype == 58) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $campaign_id = $col_fields[$fieldname];
            if ($campaign_id != '') {
                $campaign_name = getCampaignName($campaign_id);
            }
            $label_fld[] = $campaign_name;
            $label_fld["secid"] = $campaign_id;
            $label_fld["link"] = "index.php?module=Campaigns&action=DetailView&record=" . $campaign_id;
        } elseif ($uitype == 59) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $product_id = $col_fields[$fieldname];
            if ($product_id != '') {
                $product_name = getProductName($product_id);
            }
            //Account Name View
            $label_fld[] = $product_name;
            $label_fld["secid"] = $product_id;
            $label_fld["link"] = "index.php?module=Products&action=DetailView&record=" . $product_id;
        } elseif ($uitype == 61) {
            global $adb;
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($tabid == 10) {
                $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id']));
                for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) {
                    $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid');
                    if ($attachmentid != '') {
                        $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                        $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                        if ($attachmentsname != '') {
                            $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '">' . $attachmentsname . '</a>';
                        } else {
                            $custfldval = '';
                        }
                    }
                    $label_fld['options'][] = $custfldval;
                }
            } else {
                $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
                if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                    $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                    $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                }
                //This is added to strip the crmid and _ from the file name and show the original filename
                //$org_filename = ltrim($col_fields[$fieldname],$col_fields['record_id'].'_');
                /* Above line is not required as the filename in the database is stored as it is and doesn't have crmid attached to it.
                	  This was the cause for the issue reported in ticket #4645 */
                $org_filename = $col_fields[$fieldname];
                // For Backward Compatibility version < 5.0.4
                $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_');
                if ($filename_pos === 0) {
                    $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_');
                    $org_filename = substr($org_filename, $start_idx);
                }
                if ($org_filename != '') {
                    if ($col_fields['filelocationtype'] == 'E') {
                        if ($col_fields['filestatus'] == 1) {
                            //&& strlen($col_fields['filename']) > 7  ){
                            $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                        } else {
                            $custfldval = $col_fields[$fieldname];
                        }
                    } elseif ($col_fields['filelocationtype'] == 'I') {
                        if ($col_fields['filestatus'] == 1) {
                            $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                        } else {
                            $custfldval = $col_fields[$fieldname];
                        }
                    } else {
                        $custfldval = '';
                    }
                }
                $label_fld[] = $custfldval;
            }
        } elseif ($uitype == 28) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
            if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
            }
            $org_filename = $col_fields[$fieldname];
            // For Backward Compatibility version < 5.0.4
            $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_');
            if ($filename_pos === 0) {
                $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_');
                $org_filename = substr($org_filename, $start_idx);
            }
            if ($org_filename != '') {
                if ($col_fields['filelocationtype'] == 'E') {
                    if ($col_fields['filestatus'] == 1) {
                        //&& strlen($col_fields['filename']) > 7  ){
                        $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                    } else {
                        $custfldval = $col_fields[$fieldname];
                    }
                } elseif ($col_fields['filelocationtype'] == 'I') {
                    if ($col_fields['filestatus'] == 1) {
                        $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                    } else {
                        $custfldval = $col_fields[$fieldname];
                    }
                } else {
                    $custfldval = '';
                }
            }
            $label_fld[] = $custfldval;
        } elseif ($uitype == 69) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($tabid == 14) {
                $images = array();
                $query = 'select productname, vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?';
                $result_image = $adb->pquery($query, array($col_fields['record_id']));
                for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) {
                    $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid');
                    //decode_html  - added to handle UTF-8   characters in file names
                    //urlencode    - added to handle special characters like #, %, etc.,
                    $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name')));
                    $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name'));
                    $imagepath_array[] = $adb->query_result($result_image, $image_iter, 'path');
                }
                if (count($image_array) > 1) {
                    if (count($image_array) < 4) {
                        $sides = count($image_array) * 2;
                    } else {
                        $sides = 8;
                    }
                    $image_lists = '<div id="Carousel" style="position:relative;vertical-align: middle;">
					<img src="modules/Products/placeholder.gif" width="571" height="117" style="position:relative;">
					</div><script>var Car_NoOfSides=' . $sides . '; Car_Image_Sources=new Array(';
                    for ($image_iter = 0; $image_iter < count($image_array); $image_iter++) {
                        $images[] = '"' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '","' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '"';
                    }
                    $image_lists .= implode(',', $images) . ');</script><script language="JavaScript" type="text/javascript" src="modules/Products/Productsslide.js"></script><script language="JavaScript" type="text/javascript">Carousel();</script>';
                    $label_fld[] = $image_lists;
                } elseif (count($image_array) == 1) {
                    list($pro_image_width, $pro_image_height) = getimagesize($imagepath_array[0] . $image_id_array[0] . "_" . $image_orgname_array[0]);
                    if ($pro_image_width > 450 || $pro_image_height > 300) {
                        $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="450" height="300">';
                    } else {
                        $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="' . $pro_image_width . '" height="' . $pro_image_height . '">';
                    }
                } else {
                    $label_fld[] = '';
                }
            } else {
                if ($module == 'Contacts') {
                    $imageattachment = 'Image';
                } else {
                    $imageattachment = 'Attachment';
                }
                //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname];
                $sql = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t from vtiger_attachments\n\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t  and vtiger_attachments.name = ?\n\t\t\t  and vtiger_seattachmentsrel.crmid=?";
                $image_res = $adb->pquery($sql, array($col_fields[$fieldname], $col_fields['record_id']));
                $image_id = $adb->query_result($image_res, 0, 'attachmentsid');
                $image_path = $adb->query_result($image_res, 0, 'path');
                //decode_html  - added to handle UTF-8   characters in file names
                //urlencode    - added to handle special characters like #, %, etc.,
                $image_name = urlencode(decode_html($adb->query_result($image_res, 0, 'name')));
                $imgpath = $image_path . $image_id . "_" . $image_name;
                if ($image_name != '') {
                    $ftype = $adb->query_result($image_res, 0, 'type');
                    $isimage = stripos($ftype, 'image') !== false;
                    if ($isimage) {
                        $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image');
                        $label_fld[] = '<img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 500px;">';
                    } else {
                        $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents');
                        $label_fld[] = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>';
                    }
                } else {
                    $label_fld[] = '';
                }
            }
        } elseif ($uitype == 62) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Leads") {
                    $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $lead_name = $field_value;
                        }
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                } elseif ($parent_module == "Accounts") {
                    $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                    $sql = "select * from  vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $account_name = $adb->query_result($result, 0, "accountname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>';
                } elseif ($parent_module == "Potentials") {
                    $label_fld[] = $app_strings['LBL_POTENTIAL_NAME'];
                    $sql = "select * from  vtiger_potential where potentialid=?";
                    $result = $adb->pquery($sql, array($value));
                    $potentialname = $adb->query_result($result, 0, "potentialname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>';
                } elseif ($parent_module == "Products") {
                    $label_fld[] = $app_strings['LBL_PRODUCT_NAME'];
                    $sql = "select * from  vtiger_products where productid=?";
                    $result = $adb->pquery($sql, array($value));
                    $productname = $adb->query_result($result, 0, "productname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $productname . '</a>';
                } elseif ($parent_module == "PurchaseOrder") {
                    $label_fld[] = $app_strings['LBL_PORDER_NAME'];
                    $sql = "select * from  vtiger_purchaseorder where purchaseorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $pordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>';
                } elseif ($parent_module == "SalesOrder") {
                    $label_fld[] = $app_strings['LBL_SORDER_NAME'];
                    $sql = "select * from  vtiger_salesorder where salesorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $sordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>';
                } elseif ($parent_module == "Invoice") {
                    $label_fld[] = $app_strings['LBL_INVOICE_NAME'];
                    $sql = "select * from  vtiger_invoice where invoiceid=?";
                    $result = $adb->pquery($sql, array($value));
                    $invoicename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>';
                } elseif ($parent_module == "Quotes") {
                    $label_fld[] = $app_strings['LBL_QUOTES_NAME'];
                    $sql = "select * from  vtiger_quotes where quoteid=?";
                    $result = $adb->pquery($sql, array($value));
                    $quotename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>';
                } elseif ($parent_module == "HelpDesk") {
                    $label_fld[] = $app_strings['LBL_HELPDESK_NAME'];
                    $sql = "select * from  vtiger_troubletickets where ticketid=?";
                    $result = $adb->pquery($sql, array($value));
                    $title = $adb->query_result($result, 0, "title");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $title . '</a>';
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 105) {
            //Added for user image
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname];
            $sql = "select vtiger_attachments.* from vtiger_attachments left join vtiger_salesmanattachmentsrel on vtiger_salesmanattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid where vtiger_salesmanattachmentsrel.smid=?";
            $image_res = $adb->pquery($sql, array($col_fields['record_id']));
            $image_id = $adb->query_result($image_res, 0, 'attachmentsid');
            $image_path = $adb->query_result($image_res, 0, 'path');
            $image_name = $adb->query_result($image_res, 0, 'name');
            $imgpath = $image_path . $image_id . "_" . $image_name;
            if ($image_name != '') {
                //Added the following check for the image to retain its in original size.
                list($pro_image_width, $pro_image_height) = getimagesize(decode_html($imgpath));
                $label_fld[] = '<a href="' . $imgpath . '" target="_blank"><img src="' . $imgpath . '" width="' . $pro_image_width . '" height="' . $pro_image_height . '" alt="' . $col_fields['user_name'] . '" title="' . $col_fields['user_name'] . '" border="0"></a>';
            } else {
                $label_fld[] = '';
            }
        } elseif ($uitype == 66) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Leads") {
                    $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $lead_name = $field_value;
                        }
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                } elseif ($parent_module == "Accounts") {
                    $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                    $sql = "select * from  vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $account_name = $adb->query_result($result, 0, "accountname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>';
                } elseif ($parent_module == "Potentials") {
                    $label_fld[] = $app_strings['LBL_POTENTIAL_NAME'];
                    $sql = "select * from  vtiger_potential where potentialid=?";
                    $result = $adb->pquery($sql, array($value));
                    $potentialname = $adb->query_result($result, 0, "potentialname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>';
                } elseif ($parent_module == "Quotes") {
                    $label_fld[] = $app_strings['LBL_QUOTE_NAME'];
                    $sql = "select * from  vtiger_quotes where quoteid=?";
                    $result = $adb->pquery($sql, array($value));
                    $quotename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>';
                } elseif ($parent_module == "PurchaseOrder") {
                    $label_fld[] = $app_strings['LBL_PORDER_NAME'];
                    $sql = "select * from  vtiger_purchaseorder where purchaseorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $pordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>';
                } elseif ($parent_module == "SalesOrder") {
                    $label_fld[] = $app_strings['LBL_SORDER_NAME'];
                    $sql = "select * from  vtiger_salesorder where salesorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $sordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>';
                } elseif ($parent_module == "Invoice") {
                    $label_fld[] = $app_strings['LBL_INVOICE_NAME'];
                    $sql = "select * from  vtiger_invoice where invoiceid=?";
                    $result = $adb->pquery($sql, array($value));
                    $invoicename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>';
                } elseif ($parent_module == "Campaigns") {
                    $label_fld[] = $app_strings['LBL_CAMPAIGN_NAME'];
                    $sql = "select * from  vtiger_campaign where campaignid=?";
                    $result = $adb->pquery($sql, array($value));
                    $campaignname = $adb->query_result($result, 0, "campaignname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $campaignname . '</a>';
                } elseif ($parent_module == "HelpDesk") {
                    $label_fld[] = $app_strings['LBL_HELPDESK_NAME'];
                    $sql = "select * from  vtiger_troubletickets where ticketid=?";
                    $result = $adb->pquery($sql, array($value));
                    $tickettitle = $adb->query_result($result, 0, "title");
                    if (strlen($tickettitle) > 25) {
                        $tickettitle = substr($tickettitle, 0, 25) . '...';
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $tickettitle . '</a>';
                } elseif ($parent_module == "Vendors") {
                    //MSL
                    $label_fld[] = $app_strings['LBL_VENDOR_NAME'];
                    $sql = "select vendorname from  vtiger_vendor where vendorid=?";
                    $result = $adb->pquery($sql, array($value));
                    $vendor_name = $adb->query_result($result, 0, "vendorname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $vendor_name . '</a>';
                }
                //MSL -------------------------------------------
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 67) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Leads") {
                    $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $lead_name = $field_value;
                        }
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                } elseif ($parent_module == "Contacts") {
                    $label_fld[] = $app_strings['LBL_CONTACT_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $contact_name = $field_value;
                        }
                    } else {
                        $contact_name = '';
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>';
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 357) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_name = '';
                $parent_id = '';
                $myemailid = $_REQUEST['record'];
                $mysql = "select crmid from vtiger_seactivityrel where activityid=?";
                $myresult = $adb->pquery($mysql, array($myemailid));
                $mycount = $adb->num_rows($myresult);
                if ($mycount > 1) {
                    $label_fld[] = $app_strings['LBL_RELATED_TO'];
                    $label_fld[] = $app_strings['LBL_MULTIPLE'];
                } else {
                    $parent_module = getSalesEntityType($value);
                    if ($parent_module == "Leads") {
                        $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                        $displayValueArray = getEntityName($parent_module, $value);
                        if (!empty($displayValueArray)) {
                            foreach ($displayValueArray as $key => $field_value) {
                                $lead_name = $field_value;
                            }
                        }
                        $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                    } elseif ($parent_module == "Contacts") {
                        $label_fld[] = $app_strings['LBL_CONTACT_NAME'];
                        $displayValueArray = getEntityName($parent_module, $value);
                        if (!empty($displayValueArray)) {
                            foreach ($displayValueArray as $key => $field_value) {
                                $contact_name = $field_value;
                            }
                        } else {
                            $contact_name = '';
                        }
                        $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>';
                    } elseif ($parent_module == "Accounts") {
                        $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                        $sql = "select * from  vtiger_account where accountid=?";
                        $result = $adb->pquery($sql, array($value));
                        $accountname = $adb->query_result($result, 0, "accountname");
                        $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $accountname . '</a>';
                    }
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 68) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Contacts") {
                    $label_fld[] = $app_strings['LBL_CONTACT_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $contact_name = $field_value;
                        }
                    } else {
                        $contact_name = '';
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>';
                } elseif ($parent_module == "Accounts") {
                    $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                    $sql = "select * from vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $account_name = $adb->query_result($result, 0, "accountname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>';
                } else {
                    $value = '';
                    $label_fld[] = getTranslatedString($fieldlabel, $module);
                    $label_fld[] = $value;
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 63) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname] . 'h&nbsp; ' . $col_fields['duration_minutes'] . 'm';
        } elseif ($uitype == 6) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($col_fields[$fieldname] == '0') {
                $col_fields[$fieldname] = '';
            }
            if ($col_fields['time_start'] != '') {
                $start_time = $col_fields['time_start'];
            }
            $dateValue = $col_fields[$fieldname];
            if ($col_fields[$fieldname] == '0000-00-00' || empty($dateValue)) {
                $displayValue = '';
            } else {
                if (empty($start_time) && strpos($col_fields[$fieldname], ' ') == false) {
                    $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]);
                } else {
                    if (!empty($start_time)) {
                        $date = new DateTimeField($col_fields[$fieldname] . ' ' . $start_time);
                    } else {
                        $date = new DateTimeField($col_fields[$fieldname]);
                    }
                    $displayValue = $date->getDisplayDateTimeValue();
                }
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 5 || $uitype == 23 || $uitype == 70) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $dateValue = $col_fields[$fieldname];
            if ($col_fields['time_end'] != '' && ($tabid == 9 || $tabid == 16) && $uitype == 23) {
                $end_time = $col_fields['time_end'];
            }
            if ($dateValue == '0000-00-00' || empty($dateValue)) {
                $displayValue = '';
            } else {
                if (empty($end_time) && strpos($dateValue, ' ') == false) {
                    $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]);
                } else {
                    if (!empty($end_time)) {
                        $date = new DateTimeField($col_fields[$fieldname] . ' ' . $end_time);
                    } else {
                        $date = new DateTimeField($col_fields[$fieldname]);
                    }
                    $displayValue = $date->getDisplayDateTimeValue();
                }
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 71 || $uitype == 72) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $currencyField = new CurrencyField($col_fields[$fieldname]);
            if ($uitype == 72) {
                // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
                if ($fieldname == 'unit_price') {
                    $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module));
                    $label_fld[] = $currencyField->getDisplayValue(null, true);
                    $label_fld["cursymb"] = $rate_symbol['symbol'];
                } else {
                    $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']);
                    $label_fld[] = $currencyField->getDisplayValue(null, true);
                    $label_fld["cursymb"] = $currency_info['currency_symbol'];
                }
            } else {
                $label_fld[] = $currencyField->getDisplayValue();
                $label_fld["cursymb"] = $currencyField->getCurrencySymbol();
            }
        } elseif ($uitype == 75 || $uitype == 81) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $vendor_id = $col_fields[$fieldname];
            if ($vendor_id != '') {
                $vendor_name = getVendorName($vendor_id);
            }
            $label_fld[] = $vendor_name;
            $label_fld["secid"] = $vendor_id;
            $label_fld["link"] = "index.php?module=Vendors&action=DetailView&record=" . $vendor_id;
        } elseif ($uitype == 76) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $potential_id = $col_fields[$fieldname];
            if ($potential_id != '') {
                $potential_name = getPotentialName($potential_id);
            }
            $label_fld[] = $potential_name;
            $label_fld["secid"] = $potential_id;
            $label_fld["link"] = "index.php?module=Potentials&action=DetailView&record=" . $potential_id;
        } elseif ($uitype == 78) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $quote_id = $col_fields[$fieldname];
            if ($quote_id != '') {
                $quote_name = getQuoteName($quote_id);
            }
            $label_fld[] = $quote_name;
            $label_fld["secid"] = $quote_id;
            $label_fld["link"] = "index.php?module=Quotes&action=DetailView&record=" . $quote_id;
        } elseif ($uitype == 79) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $purchaseorder_id = $col_fields[$fieldname];
            if ($purchaseorder_id != '') {
                $purchaseorder_name = getPoName($purchaseorder_id);
            }
            $label_fld[] = $purchaseorder_name;
            $label_fld["secid"] = $purchaseorder_id;
            $label_fld["link"] = "index.php?module=PurchaseOrder&action=DetailView&record=" . $purchaseorder_id;
        } elseif ($uitype == 80) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $salesorder_id = $col_fields[$fieldname];
            if ($salesorder_id != '') {
                $salesorder_name = getSoName($salesorder_id);
            }
            $label_fld[] = $salesorder_name;
            $label_fld["secid"] = $salesorder_id;
            $label_fld["link"] = "index.php?module=SalesOrder&action=DetailView&record=" . $salesorder_id;
        } elseif ($uitype == 30) {
            $rem_days = 0;
            $rem_hrs = 0;
            $rem_min = 0;
            $reminder_str = "";
            $rem_days = floor($col_fields[$fieldname] / (24 * 60));
            $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60);
            $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60;
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($col_fields[$fieldname]) {
                $reminder_str = $rem_days . '&nbsp;' . $mod_strings['LBL_DAYS'] . '&nbsp;' . $rem_hrs . '&nbsp;' . $mod_strings['LBL_HOURS'] . '&nbsp;' . $rem_min . '&nbsp;' . $mod_strings['LBL_MINUTES'] . '&nbsp;&nbsp;' . $mod_strings['LBL_BEFORE_EVENT'];
            }
            $label_fld[] = '&nbsp;' . $reminder_str;
        } elseif ($uitype == 98) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if (is_admin($current_user)) {
                $label_fld[] = '<a href="index.php?module=Settings&action=RoleDetailView&roleid=' . $col_fields[$fieldname] . '">' . getRoleName($col_fields[$fieldname]) . '</a>';
            } else {
                $label_fld[] = getRoleName($col_fields[$fieldname]);
            }
        } elseif ($uitype == 85) {
            //Added for Skype by Minnie
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 26) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $query = "select foldername from vtiger_attachmentsfolder where folderid = ?";
            $result = $adb->pquery($query, array($col_fields[$fieldname]));
            $folder_name = $adb->query_result($result, 0, "foldername");
            $label_fld[] = $folder_name;
        } elseif ($uitype == 27) {
            if ($col_fields[$fieldname] == 'I') {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $mod_strings['LBL_INTERNAL'];
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $mod_strings['LBL_EXTERNAL'];
            }
        } elseif ($uitype == 31) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
            $options = array();
            $themeList = get_themes();
            foreach ($themeList as $theme) {
                if ($current_user->theme == $theme) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($theme), $theme, $selected);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 32) {
            $options = array();
            $languageList = Vtiger_Language::getAll();
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = isset($languageList[$col_fields[$fieldname]]) ? $languageList[$col_fields[$fieldname]] : $col_fields[$fieldname];
            foreach ($languageList as $prefix => $label) {
                if ($current_user->language == $prefix) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($label), $prefix, $selected);
            }
            $label_fld["options"] = $options;
        } else {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($col_fields[$fieldname] == '0' && $fieldname != 'filedownloadcount' && $fieldname != 'filestatus' && $fieldname != 'filesize') {
                $col_fields[$fieldname] = '';
            }
            //code for Documents module :start
            if ($tabid == 8) {
                $downloadtype = $col_fields['filelocationtype'];
                if ($fieldname == 'filename') {
                    if ($downloadtype == 'I') {
                        //$file_value = $mod_strings['LBL_INTERNAL'];
                        $fld_value = $col_fields['filename'];
                        $ext_pos = strrpos($fld_value, ".");
                        $ext = substr($fld_value, $ext_pos + 1);
                        $ext = strtolower($ext);
                        if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') {
                            $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') {
                            $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') {
                            $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') {
                            $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>";
                        } else {
                            $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        }
                    } else {
                        $fld_value = $col_fields['filename'];
                        $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' title='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' hspace='3' align='absmiddle' border='0'>";
                    }
                    $label_fld[] = $fileicon . $fld_value;
                }
                if ($fieldname == 'filesize') {
                    if ($col_fields['filelocationtype'] == 'I') {
                        $filesize = $col_fields[$fieldname];
                        if ($filesize < 1024) {
                            $label_fld[] = $filesize . ' B';
                        } elseif ($filesize > 1024 && $filesize < 1048576) {
                            $label_fld[] = round($filesize / 1024, 2) . ' KB';
                        } else {
                            if ($filesize > 1048576) {
                                $label_fld[] = round($filesize / (1024 * 1024), 2) . ' MB';
                            }
                        }
                    } else {
                        $label_fld[] = ' --';
                    }
                }
                if ($fieldname == 'filetype' && $col_fields['filelocationtype'] == 'E') {
                    $label_fld[] = ' --';
                }
                /* if($fieldname == 'filestatus')
                	  {
                	  $filestatus = $col_fields[$fieldname];
                	  if($filestatus == 0)
                	  $label_fld[]=$mod_strings['LBL_ACTIVE'];
                	  else
                	  $label_fld[]=$mod_strings['LBL_INACTIVE'];
                	  } */
            }
            //code for Documents module :end
            $label_fld[] = $col_fields[$fieldname];
        }
    }
    $label_fld[] = $uitype;
    //sets whether the currenct user is admin or not
    if (is_admin($current_user)) {
        $label_fld["isadmin"] = 1;
    } else {
        $label_fld["isadmin"] = 0;
    }
    $log->debug("Exiting getDetailViewOutputHtml method ...");
    return $label_fld;
}