/** * Function to get picklist fields for the given module * @ param $fld_module * It gets the picklist details array for the given module in the given format * $fieldlist = Array(Array('fieldlabel'=>$fieldlabel,'generatedtype'=>$generatedtype,'columnname'=>$columnname,'fieldname'=>$fieldname,'value'=>picklistvalues)) */ function getUserFldArray($fld_module, $roleid) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); $user_fld = array(); $tabid = getTabid($fld_module); $query = "select vtiger_field.fieldlabel,vtiger_field.columnname,vtiger_field.fieldname, vtiger_field.uitype" . " FROM vtiger_field inner join vtiger_picklist on vtiger_field.fieldname = vtiger_picklist.name" . " where (displaytype=1 and vtiger_field.tabid=? and vtiger_field.uitype in ('15','55','33','16') " . " or (vtiger_field.tabid=? and fieldname='salutationtype' and fieldname !='vendortype')) " . " and vtiger_field.presence in (0,2) ORDER BY vtiger_picklist.picklistid ASC"; $result = $adb->pquery($query, array($tabid, $tabid)); $noofrows = $adb->num_rows($result); if ($noofrows > 0) { $fieldlist = array(); for ($i = 0; $i < $noofrows; $i++) { $user_fld = array(); $fld_name = $adb->query_result($result, $i, "fieldname"); $user_fld['fieldlabel'] = $adb->query_result($result, $i, "fieldlabel"); $user_fld['generatedtype'] = $adb->query_result($result, $i, "generatedtype"); $user_fld['columnname'] = $adb->query_result($result, $i, "columnname"); $user_fld['fieldname'] = $adb->query_result($result, $i, "fieldname"); $user_fld['uitype'] = $adb->query_result($result, $i, "uitype"); $user_fld['value'] = getAssignedPicklistValues($user_fld['fieldname'], $roleid, $adb); $fieldlist[] = $user_fld; } } return $fieldlist; }
public function setupAccessiblePicklistValueList($name) { $isRoleBased = vtws_isRoleBasedPicklist($name); $this->picklistRoleMap[$name] = $isRoleBased; if ($this->picklistRoleMap[$name]) { $this->picklistValueMap[$name] = getAssignedPicklistValues($name, $this->user->roleid, $this->db); } }
function gv_getGVVarNames() { global $current_user, $adb; require_once 'modules/PickList/PickListUtils.php'; $roleid = $current_user->roleid; $picklistValues = getAssignedPicklistValues('gvname', $roleid, $adb); if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { $options[$pickListValue] = getTranslatedString($pickListValue, 'GlobalVariable'); } } asort($options); $options = get_select_options_with_id($options, '--none--'); return $options; }
/** * this function takes in an array of values for an user and sanitizes it for export * @param array $arr - the array of values */ function sanitizeValues($arr) { global $current_user, $adb; $roleid = fetchUserRole($current_user->id); foreach ($arr as $fieldlabel => &$value) { $fieldInfo = $this->fieldsArr[$fieldlabel]; $uitype = $fieldInfo['uitype']; $fieldname = $fieldInfo['fieldname']; if ($uitype == 15 || $uitype == 16 || $uitype == 33) { //picklists if (empty($this->picklistValues[$fieldname])) { $this->picklistValues[$fieldname] = getAssignedPicklistValues($fieldname, $roleid, $adb); } $value = trim($value); } elseif ($uitype == 10) { //have to handle uitype 10 $value = trim($value); if (!empty($value)) { $parent_module = getSalesEntityType($value); $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $k => $v) { $displayValue = $v; } } if (!empty($parent_module) && !empty($displayValue)) { $value = $parent_module . "::::" . $displayValue; } else { $value = ""; } } else { $value = ''; } } } return $arr; }
/** * this function takes in an array of values for an user and sanitizes it for export * @param array $arr - the array of values */ function sanitizeValues($arr) { global $current_user, $adb; $roleid = fetchUserRole($current_user->id); $decimal = $current_user->currency_decimal_separator; $numsep = $current_user->currency_grouping_separator; foreach ($arr as $fieldlabel => &$value) { $fieldInfo = $this->fieldsArr[$fieldlabel]; $uitype = $fieldInfo['uitype']; $fieldname = $fieldInfo['fieldname']; if ($uitype == 15 || $uitype == 16 || $uitype == 33) { //picklists if (empty($this->picklistValues[$fieldname])) { $this->picklistValues[$fieldname] = getAssignedPicklistValues($fieldname, $roleid, $adb); } $value = trim($value); } elseif ($uitype == 10) { //have to handle uitype 10 $value = trim($value); if (!empty($value)) { $parent_module = getSalesEntityType($value); $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $k => $v) { $displayValue = $v; } } if (!empty($parent_module) && !empty($displayValue)) { $value = $parent_module . "::::" . $displayValue; } else { $value = ""; } } else { $value = ''; } } elseif ($uitype == 71 || $uitype == 72) { $value = CurrencyField::convertToUserFormat($value, null, true); } elseif ($uitype == 7 || $fieldInfo['typeofdata'] == 'N~O' || $uitype == 9) { $value = number_format($value, 2, $decimal, $numsep); } } return $arr; }
$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); $smarty->assign("FIELDNAME", $fieldName); $smarty->assign("FIELDLABEL", getTranslatedString($fieldLabel)); $smarty->assign("MODULE", $moduleName); $smarty->assign("PICKVAL", $values); $smarty->assign("ASSIGNED_VALUES", $assignedValues); $smarty->assign("ROLEID", $roleid); $smarty->assign("ROLENAME", $roleName); $smarty->assign("MOD", return_module_language($current_language, 'PickList')); $smarty->assign("APP", $app_strings); $data = $smarty->fetch("modules/PickList/AssignPicklistValues.tpl"); echo $data;
/** Function to insert values in the specifed table for the specified module * @param $table_name -- table name:: Type varchar * @param $module -- module:: Type varchar */ function insertIntoEntityTable($table_name, $module, $fileid = '') { global $log; global $current_user, $app_strings; $log->info("function insertIntoEntityTable " . $module . ' vtiger_table name ' . $table_name); global $adb; $insertion_mode = $this->mode; //Checkin whether an entry is already is present in the vtiger_table to update if ($insertion_mode == 'edit') { $tablekey = $this->tab_name_index[$table_name]; // Make selection on the primary key of the module table to check. $check_query = "select {$tablekey} from {$table_name} where {$tablekey}=?"; $check_result = $adb->pquery($check_query, array($this->id)); $num_rows = $adb->num_rows($check_result); if ($num_rows <= 0) { $insertion_mode = ''; } } $tabid = getTabid($module); if ($module == 'Calendar' && $this->column_fields["activitytype"] != null && $this->column_fields["activitytype"] != 'Task') { $tabid = getTabid('Events'); } if ($insertion_mode == 'edit') { $update = array(); $update_params = array(); checkFileAccessForInclusion('user_privileges/user_privileges_' . $current_user->id . '.php'); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $sql = "select * from vtiger_field where tabid in (" . generateQuestionMarks($tabid) . ") and tablename=? and displaytype in (1,3) and presence in (0,2) group by columnname"; $params = array($tabid, $table_name); } else { $profileList = getCurrentUserProfileList(); if (count($profileList) > 0) { $sql = "SELECT *\n\t\t\t\t\t\tFROM vtiger_field\n\t\t\t\t\t\tINNER JOIN vtiger_profile2field\n\t\t\t\t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t\t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t\t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t\t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t\t\t\tAND vtiger_profile2field.visible = 0 AND vtiger_profile2field.readonly = 0\n\t\t\t\t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\n\t\t\t\t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname"; $params = array($tabid, $profileList, $table_name); } else { $sql = "SELECT *\n\t\t\t\t\t\tFROM vtiger_field\n\t\t\t\t\t\tINNER JOIN vtiger_profile2field\n\t\t\t\t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t\t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t\t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t\t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t\t\t\tAND vtiger_profile2field.visible = 0 AND vtiger_profile2field.readonly = 0\n\t\t\t\t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname"; $params = array($tabid, $table_name); } } } else { $table_index_column = $this->tab_name_index[$table_name]; if ($table_index_column == 'id' && $table_name == 'vtiger_users') { $currentuser_id = $adb->getUniqueID("vtiger_users"); $this->id = $currentuser_id; } $column = array($table_index_column); $value = array($this->id); $sql = "select * from vtiger_field where tabid=? and tablename=? and displaytype in (1,3,4) and vtiger_field.presence in (0,2)"; $params = array($tabid, $table_name); } // Attempt to re-use the query-result to avoid reading for every save operation // TODO Need careful analysis on impact ... MEMORY requirement might be more static $_privatecache = array(); $cachekey = "{$insertion_mode}-" . implode(',', $params); if (!isset($_privatecache[$cachekey])) { $result = $adb->pquery($sql, $params); $noofrows = $adb->num_rows($result); if (CRMEntity::isBulkSaveMode()) { $cacheresult = array(); for ($i = 0; $i < $noofrows; ++$i) { $cacheresult[] = $adb->fetch_array($result); } $_privatecache[$cachekey] = $cacheresult; } } else { // Useful when doing bulk save $result = $_privatecache[$cachekey]; $noofrows = count($result); } for ($i = 0; $i < $noofrows; $i++) { $fieldname = $this->resolve_query_result_value($result, $i, "fieldname"); $columname = $this->resolve_query_result_value($result, $i, "columnname"); $uitype = $this->resolve_query_result_value($result, $i, "uitype"); $generatedtype = $this->resolve_query_result_value($result, $i, "generatedtype"); $typeofdata = $this->resolve_query_result_value($result, $i, "typeofdata"); $typeofdata_array = explode("~", $typeofdata); $datatype = $typeofdata_array[0]; $ajaxSave = false; if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'DetailViewAjax' && isset($_REQUEST['ajxaction']) && $_REQUEST['ajxaction'] == 'DETAILVIEW' && isset($_REQUEST["fldName"]) && $_REQUEST["fldName"] != $fieldname || $_REQUEST['action'] == 'MassEditSave' && !isset($_REQUEST[$fieldname . "_mass_edit_check"])) { $ajaxSave = true; } if ($uitype == 4 && $insertion_mode != 'edit') { $fldvalue = ''; // Bulk Save Mode: Avoid generation of module sequence number, take care later. if (!CRMEntity::isBulkSaveMode()) { $fldvalue = $this->setModuleSeqNumber("increment", $module); } $this->column_fields[$fieldname] = $fldvalue; } if (isset($this->column_fields[$fieldname])) { if ($uitype == 56) { if ($this->column_fields[$fieldname] == 'on' || $this->column_fields[$fieldname] == 1) { $fldvalue = '1'; } else { $fldvalue = '0'; } } elseif ($uitype == 15 || $uitype == 16 || $uitype == 1613) { if ($this->column_fields[$fieldname] == $app_strings['LBL_NOT_ACCESSIBLE']) { //If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value. $sql = "select {$columname} from {$table_name} where " . $this->tab_name_index[$table_name] . "=?"; $res = $adb->pquery($sql, array($this->id)); $pick_val = $adb->query_result($res, 0, $columname); $fldvalue = $pick_val; } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 33 || $uitype == 3313 || $uitype == 1024) { if (!is_array($this->column_fields[$fieldname])) { $this->column_fields[$fieldname] = array_map('trim', explode('|##|', $this->column_fields[$fieldname])); } $sql = "select columnname,tablename from vtiger_field where tabid=? and fieldname=?"; $res = $adb->pquery($sql, array($tabid, $fieldname)); $colj = $adb->query_result($res, 0, 0); $tabj = $adb->query_result($res, 0, 1); $sql1 = "select {$colj} from {$tabj} where " . $this->tab_name_index[$tabj] . "=?"; $res = $adb->pquery($sql1, array($this->id)); $vlera = $adb->query_result($res, 0, $colj); if (empty($vlera)) { $currentvalues = array(); } else { $currentvalues = array_map('trim', explode('|##|', decode_html($vlera))); } $selectedvalues = $this->column_fields[$fieldname]; if ($uitype == 3313) { $uservalues = getAllowedPicklistModules(); } elseif ($uitype == 1024) { $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); $uservalues = array_merge($subrole, array($roleid)); } else { $roleid = $current_user->roleid; $uservalues = getAssignedPicklistValues($fieldname, $roleid, $adb); } $vek = array_unique(array_merge(array_diff($currentvalues, $uservalues), $selectedvalues)); $fldvalue = implode(' |##| ', $vek); } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23) { //Added to avoid function call getDBInsertDateValue in ajax save if (isset($current_user->date_format) && !$ajaxSave) { $fldvalue = getValidDBInsertDateValue($this->column_fields[$fieldname]); } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 7) { //strip out the spaces and commas in numbers if given ie., in amounts there may be , $fldvalue = str_replace(",", "", $this->column_fields[$fieldname]); //trim($this->column_fields[$fieldname],","); } elseif ($uitype == 26) { if (empty($this->column_fields[$fieldname])) { $fldvalue = 1; //the documents will stored in default folder } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 28) { if ($this->column_fields[$fieldname] == null) { $fileQuery = $adb->pquery("SELECT filename from vtiger_notes WHERE notesid = ?", array($this->id)); $fldvalue = null; if (isset($fileQuery)) { $rowCount = $adb->num_rows($fileQuery); if ($rowCount > 0) { $fldvalue = $adb->query_result($fileQuery, 0, 'filename'); } } } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 8) { $this->column_fields[$fieldname] = rtrim($this->column_fields[$fieldname], ','); $ids = explode(',', $this->column_fields[$fieldname]); $json = new Zend_Json(); $fldvalue = $json->encode($ids); } elseif ($uitype == 12) { // Bulk Sae Mode: Consider the FROM email address as specified, if not lookup $fldvalue = $this->column_fields[$fieldname]; if (empty($fldvalue)) { $query = "SELECT email1 FROM vtiger_users WHERE id = ?"; $res = $adb->pquery($query, array($current_user->id)); $rows = $adb->num_rows($res); if ($rows > 0) { $fldvalue = $adb->query_result($res, 0, 'email1'); } } // END } elseif ($uitype == 72 && !$ajaxSave) { // Some of the currency fields like Unit Price, Totoal , Sub-total - doesn't need currency conversion during save $fldvalue = CurrencyField::convertToDBFormat($this->column_fields[$fieldname], null, true); } elseif ($uitype == 71 && !$ajaxSave) { $fldvalue = CurrencyField::convertToDBFormat($this->column_fields[$fieldname]); } else { $fldvalue = $this->column_fields[$fieldname]; } if ($uitype != 33 && $uitype != 8) { $fldvalue = from_html($fldvalue, $insertion_mode == 'edit' ? true : false); } } else { $fldvalue = ''; } if ($fldvalue == '') { $fldvalue = $this->get_column_value($columname, $fldvalue, $fieldname, $uitype, $datatype); } if ($insertion_mode == 'edit') { if ($table_name != 'vtiger_ticketcomments' && $uitype != 4) { array_push($update, $columname . "=?"); array_push($update_params, $fldvalue); } } else { array_push($column, $columname); array_push($value, $fldvalue); } } if ($insertion_mode == 'edit') { if ($module == 'Potentials') { $dbquery = 'select sales_stage from vtiger_potential where potentialid = ?'; $sales_stage = $adb->query_result($adb->pquery($dbquery, array($this->id)), 0, 'sales_stage'); if ($sales_stage != $_REQUEST['sales_stage'] && $_REQUEST['sales_stage'] != '') { $date_var = date("Y-m-d H:i:s"); $closingDateField = new DateTimeField($this->column_fields['closingdate']); $closingdate = $_REQUEST['ajxaction'] == 'DETAILVIEW' ? $this->column_fields['closingdate'] : $closingDateField->getDBInsertDateValue(); $sql = "insert into vtiger_potstagehistory values(?,?,?,?,?,?,?,?)"; $params = array('', $this->id, $this->column_fields['amount'], decode_html($sales_stage), $this->column_fields['probability'], 0, $adb->formatDate($closingdate, true), $adb->formatDate($date_var, true)); $adb->pquery($sql, $params); } } elseif ($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice') { //added to update the history for PO, SO, Quotes and Invoice $history_field_array = array("PurchaseOrder" => "postatus", "SalesOrder" => "sostatus", "Quotes" => "quotestage", "Invoice" => "invoicestatus"); $inventory_module = $module; if ($_REQUEST['ajxaction'] == 'DETAILVIEW') { //if we use ajax edit if ($inventory_module == "PurchaseOrder") { $relatedname = getVendorName($this->column_fields['vendor_id']); } else { $relatedname = getAccountName($this->column_fields['account_id']); } $total = $this->column_fields['hdnGrandTotal']; } else { //using edit button and save if ($inventory_module == "PurchaseOrder") { $relatedname = $_REQUEST["vendor_name"]; } else { $relatedname = $_REQUEST["account_name"]; } $total = $_REQUEST['total']; } if ($this->column_fields["{$history_field_array[$inventory_module]}"] == $app_strings['LBL_NOT_ACCESSIBLE']) { //If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value. $his_col = $history_field_array[$inventory_module]; $his_sql = "select {$his_col} from {$this->table_name} where " . $this->table_index . "=?"; $his_res = $adb->pquery($his_sql, array($this->id)); $status_value = $adb->query_result($his_res, 0, $his_col); $stat_value = $status_value; } else { $stat_value = $this->column_fields["{$history_field_array[$inventory_module]}"]; } $oldvalue = getSingleFieldValue($this->table_name, $history_field_array[$inventory_module], $this->table_index, $this->id); if ($this->column_fields["{$history_field_array[$inventory_module]}"] != '' && $oldvalue != $stat_value) { addInventoryHistory($inventory_module, $this->id, $relatedname, $total, $stat_value); } } //Check done by Don. If update is empty the the query fails if (count($update) > 0) { $sql1 = "update {$table_name} set " . implode(",", $update) . " where " . $this->tab_name_index[$table_name] . "=?"; array_push($update_params, $this->id); $adb->pquery($sql1, $update_params); } } else { $sql1 = "insert into {$table_name}(" . implode(",", $column) . ") values(" . generateQuestionMarks($value) . ")"; $adb->pquery($sql1, $value); } }
private function getUserValuesConditions($conditions, $columns_arr) { global $current_user; // kontrola picklist values permissions start $user_privileges_path = 'user_privileges/user_privileges_' . $current_user->id . '.php'; if (file_exists($user_privileges_path)) { require $user_privileges_path; } if (file_exists($user_privileges_path) && ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)) { return $conditions; } else { if (!empty($columns_arr)) { foreach ($columns_arr as $key_fld => $sc_fld_array) { $sc_fieldcolname = $sc_fld_array["fieldcolname"]; $sc_fld_as = $this->columns_array[$sc_fieldcolname]["fld_alias"]; $sc_fld_arr = explode("_", $sc_fld_as); $sc_lk = count($sc_fld_arr) - 1; $sc_lk_lc = strtolower($sc_fld_arr[$sc_lk]); if (in_array($sc_lk_lc, array("mif", "inv"))) { unset($sc_fld_arr[$sc_lk]); $sc_fld_name = implode("_", $sc_fld_arr); } else { $sc_fld_name = $sc_fld_as; } $sc_fld_cond = $this->columns_array[$sc_fieldcolname]["fld_cond"]; $sc_fld_ui_type = ""; if (array_key_exists($sc_fld_as, $this->columns_array) && isset($this->columns_array["uitype_{$sc_fld_as}"]) && $this->columns_array["uitype_{$sc_fld_as}"] != "") { $sc_fld_ui_type = $this->columns_array["uitype_{$sc_fld_as}"]; } /* elseif (array_key_exists($sc_fld_as, $this->result_columns_array) && isset($this->result_columns_array["uitype_$sc_fld_as"]) && $this->result_columns_array["uitype_$sc_fld_as"] != "") { $sc_fld_ui_type = $this->result_columns_array["uitype_$sc_fld_as"]; } */ if (in_array($sc_fld_ui_type, ITS4YouReports::$s_uitypes)) { require_once 'modules/PickList/PickListUtils.php'; $roleid = $current_user->roleid; $adb = PearDatabase::getInstance(); $picklistValues = getAssignedPicklistValues($sc_fld_name, $roleid, $adb); // ITS4YOU-UP SlOl 5. 12. 2014 8:38:10 long generation selectbox values fix // admin picklist values $admin_role_row = $adb->fetchByAssoc($adb->pquery("SELECT roleid FROM `vtiger_user2role` WHERE userid=1", array()), 0); $admin_roleid = ""; if (!empty($admin_role_row)) { $admin_roleid = $admin_role_row["roleid"]; } if ($admin_roleid == "") { $admin_roleid = "H1"; } $picklistValuesHA = getAssignedPicklistValues($sc_fld_name, $admin_roleid, $adb); if (!empty($picklistValues) && $picklistValues != $picklistValuesHA) { // ITS4YOU-END $w_picklistValues = implode("', '", $picklistValues); $conditions[] = " {$sc_fld_cond} IN ('{$w_picklistValues}') "; } } } } } // kontrola picklist values permissions end return $conditions; }
/** 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 . '<' . $temp1 . '>; '; $temp_parent_name .= $fullname . '<' . $temp1 . '>; '; } else { $parent_name .= "<b style='color:red'>" . $fullname . '<' . $temp1 . '>; ' . "</b>"; $temp_parent_name .= "<b style='color:red'>" . $fullname . '<' . $temp1 . '>; ' . "</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'] . ' </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> <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\'> <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') . ' ' . 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 getSalesStageList() { global $adb; require_once 'modules/PickList/PickListUtils.php'; global $adb; $sales_stage_list = array(); if (is_admin($this->current_user)) { $pick_list_values = getAllPickListValues('sales_stage'); } else { $pick_list_values = getAssignedPicklistValues('sales_stage', $this->current_user->roleid, $adb); } foreach ($pick_list_values as $value) { $sales_stage_list[$value]["value"] = $value; } return $sales_stage_list; }
function getFilterColHtml(Vtiger_Request $request) { require_once 'modules/ITS4YouReports/ITS4YouReports.php'; $return_html = ""; $n_c = 3; $n_r = 5; $n = $n_c * $n_r; $sfield_name = $request->get("sfield_name"); $r_sel_fields = $request->get("r_sel_fields"); $adb = PearDatabase::getInstance(); global $current_user; //$roleid = $current_user->roleid; //$sub = getSubordinateRoleAndUsers($roleid); $roleid = $current_user->roleid; $sub = getRoleSubordinates($roleid); $picklistGroupValues = array(); $currField = $request->get("currField"); $currField_arr = explode(":", $currField); // list($s_tablename,$columnname,$s_module_field_label_str,$fieldname) = explode(":",$currField); $s_tablename = $currField_arr[0]; $columnname = $currField_arr[1]; $s_module_field_label_str = $currField_arr[2]; $fieldname = $currField_arr[3]; $last_key = count($currField_arr) - 1; $s_tablename_clear = $s_tablename; if (is_numeric($currField_arr[$last_key]) || in_array($currField_arr[$last_key], array("INV", "MIF"))) { $s_tablename_clear = trim($s_tablename, "_" . $currField_arr[$last_key]); } $s_module_field_arr = explode("_", $s_module_field_label_str); $moduleName = $s_module_field_arr[0]; $moduleTabId = getTabid($moduleName); $uitypeSql = "SELECT uitype FROM vtiger_field WHERE tabid=? AND tablename=? AND columnname=?"; //$adb->setDebug(true); $uitypeParams = array($moduleTabId, $s_tablename_clear, $columnname); $uitypeResult = $adb->pquery($uitypeSql, $uitypeParams); $num_rowuitype = $adb->num_rows($uitypeResult); if ($num_rowuitype > 0) { $uitype_row = $adb->fetchByAssoc($uitypeResult); } elseif ($moduleName == "Leads" && $fieldname == "converted") { $uitype_row = array("uitype" => "56"); } else { $uitype_row = array("uitype" => "1"); } if (!empty($uitype_row) && in_array($uitype_row["uitype"], ITS4YouReports::$s_users_uitypes)) { $picklistValues = get_user_array(false); $groups = get_group_array(false); if (!empty($groups)) { foreach ($groups as $g_key => $g_name) { $picklistGroupValues[$g_key] = $g_name; } } $valueArr = explode("|##|", $value); } elseif (!empty($uitype_row) && $uitype_row['uitype'] == '56') { $picklistValues = array("0" => "LBL_NO", "1" => "LBL_YES"); //$valueArr = explode("|##|", $r_sel_fields); $valueArr = explode(",", $r_sel_fields); } elseif (!empty($uitype_row) && $uitype_row['uitype'] == '26') { $sql = "select foldername,folderid from vtiger_attachmentsfolder order by foldername asc "; $res = $adb->pquery($sql, array()); for ($i = 0; $i < $adb->num_rows($res); $i++) { $fid = $adb->query_result($res, $i, "folderid"); $picklistValues[$fid] = $adb->query_result($res, $i, "foldername"); } $valueArr = explode(",", $r_sel_fields); } elseif (!empty($uitype_row) && $uitype_row['uitype'] == '27') { $picklistValues = array("I" => "LBL_INTERNAL", "E" => "LBL_EXTERNAL"); $valueArr = explode(",", $r_sel_fields); } else { require_once 'modules/PickList/PickListUtils.php'; if ($uitype_row["uitype"] == "16") { $picklistValues = Vtiger_Util_Helper::getPickListValues($columnname); } else { $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); $valueArr = explode("|##|", $value); } } $pickcount = 0; $sel_fields = array(); $field_uitype = $uitype_row["uitype"]; if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { $pickListValue = trim($pickListValue); if ($uitype_row['uitype'] == '56') { $check_val = $pickListValue == "LBL_YES" ? "yes" : "no"; if (in_array(trim($order), array_map("trim", $valueArr)) || in_array($check_val, $valueArr)) { $chk_val = "selected"; } else { $chk_val = ""; } $pickcount++; } elseif (in_array(trim($pickListValue), array_map("trim", $valueArr))) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if ($uitype_row['uitype'] == '56') { $sel_fields[] = array(vtranslate($pickListValue, $s_module_field_arr[0]), $order, $chk_val); } else { $sel_fields[] = array(vtranslate($pickListValue, $s_module_field_arr[0]), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $sel_fields[] = array(vtranslate('LBL_NOT_ACCESSIBLE'), $value, 'selected'); } } if ($s_module_field_arr[0] == "Calendar") { if (in_array(trim("Task"), array_map("trim", $valueArr))) { $chk_val = "selected"; } else { $chk_val = ''; } $sel_fields[] = array("Task", getTranslatedString("Task"), $chk_val); if (in_array(trim("Emails"), array_map("trim", $valueArr))) { $chk_val = "selected"; } else { $chk_val = ''; } $sel_fields[] = array("Emails", getTranslatedString("Emails"), $chk_val); } if (!empty($sel_fields)) { require_once 'include/Zend/Json.php'; $count_sel_fields = count($sel_fields); $data_fieldinfo = Zend_Json::encode(array("type" => "picklist")); $return_html .= "<select name='s_" . $sfield_name . "' id='s_" . $sfield_name . "' style='display: none;' class='select2 row-fluid' data-value='value' name='columnname' data-fieldinfo='{$data_fieldinfo}' multiple='true' size='5'>"; $selected_vals = array(); $r_sel_fields = $request->get("r_sel_fields"); $default_charset = vglobal("default_charset"); $r_sel_fields = html_entity_decode($r_sel_fields, ENT_QUOTES, $default_charset); $record = $request->get("record"); if ($r_sel_fields != "") { $selected_vals = explode(",", $r_sel_fields); } elseif ($record != "") { $currField = $request->get("currField"); $sql = "SELECT value FROM its4you_reports4you_relcriteria WHERE queryid=? AND columnname=?"; $result = $adb->pquery($sql, array($record, $currField)); while ($row = $adb->fetchByAssoc($result)) { $selected_vals = explode(",", $row["value"]); } } if (!empty($uitype_row) && in_array($uitype_row["uitype"], ITS4YouReports::$s_users_uitypes)) { $return_html .= '<optgroup label="' . vtranslate('LBL_SPECIAL_OPTIONS') . '">'; $currentUserOptLbl = vtranslate("Current User"); if (in_array("Current User", $selected_vals)) { $selected = " selected='selected' "; } $return_html .= "<option id='0' value='Current User' {$selected}>{$currentUserOptLbl}</option>"; $return_html .= '</optgroup>'; $return_html .= '<optgroup label="' . vtranslate('LBL_USERS') . '">'; } $n_i = $n_ci = 0; $count_n = count($sel_fields); foreach ($sel_fields as $key => $sf_array) { $sf_text = $sf_array[0]; $sf_value = html_entity_decode($sf_array[1], ENT_QUOTES, $default_charset); $selected = ""; if ($uitype_row["uitype"] == "56") { $sf_value_str = $sf_value == '1' ? 'yes' : 'no'; if ($sf_array[2] == "selected") { $selected = " selected='selected' "; } } else { if (in_array($sf_value, $selected_vals)) { $selected = " selected='selected' "; } } $return_html .= "<option id='{$key}' value='{$sf_value}' {$selected}>{$sf_text}</option>"; } // OWNER GROUPS !!! if (!empty($uitype_row) && in_array($uitype_row["uitype"], ITS4YouReports::$s_users_uitypes)) { $return_html .= "</optgroup>\n <optgroup label='" . vtranslate('LBL_GROUPS') . "'>"; if (!empty($picklistGroupValues)) { foreach ($picklistGroupValues as $order => $pickListValue) { $pickListValue = trim($pickListValue); if (in_array(trim($pickListValue), array_map("trim", $valueArr))) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if ($uitype_row['uitype'] == '56') { $group_fields[] = array(vtranslate($pickListValue, $s_module_field_arr[0]), $order, $chk_val); } else { $group_fields[] = array(vtranslate($pickListValue, $s_module_field_arr[0]), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $group_fields[] = array(vtranslate('LBL_NOT_ACCESSIBLE'), $value, 'selected'); } } foreach ($group_fields as $key => $sf_array) { $sf_text = $sf_array[0]; $sf_value = html_entity_decode($sf_array[1], ENT_QUOTES, $default_charset); $selected = ""; if ($uitype_row["uitype"] == "56") { $sf_value_str = $sf_value == '1' ? 'yes' : 'no'; if ($sf_array[2] == "selected") { $selected = " selected='selected' "; } } else { if (in_array($sf_value, $selected_vals)) { $selected = " selected='selected' "; } } $return_html .= "<option id='{$key}' value='{$sf_value}' {$selected}>{$sf_text}</option>"; } $return_html .= "</optgroup>"; } $return_html .= "</select>"; } echo $return_html; }
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)) { $values = getAllPickListValues($fieldName); } $assignedValues = getAssignedPicklistValues($fieldName, $roleid, $adb); $smarty->assign("THEME", $theme); $smarty->assign("FIELDNAME", $fieldName); $smarty->assign("FIELDLABEL", getTranslatedString($fieldLabel)); $smarty->assign("MODULE", $moduleName); $smarty->assign("PICKVAL", $values); $smarty->assign("ASSIGNED_VALUES", $assignedValues); $smarty->assign("ROLEID", $roleid); $smarty->assign("ROLENAME", $roleName); $smarty->assign("MOD", return_module_language($current_language, 'PickList')); $smarty->assign("APP", $app_strings); $data = $smarty->fetch("modules/PickList/AssignPicklistValues.tpl"); echo $data;
function getFieldDisplayValue($moduleName, $recordId, $fieldInstance, $value) { global $current_user; $adb = PearDatabase::getInstance(); $fieldName = $fieldInstance->getFieldName(); $uitype = $fieldInstance->getUIType(); if ($moduleName == 'Documents') { if ($fieldName == 'filesize') { $filesize = $value; if (empty($fieldsize)) { $value = '--'; } elseif ($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'; } } } if ($fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $moduleName); } elseif ($value == 0) { $value = getTranslatedString('no', $moduleName); } else { $value = '--'; } } if ($fieldName == 'filetype') { if ($value == 1) { $value = getTranslatedString('yes', $moduleName); } elseif ($value == 0) { $value = getTranslatedString('no', $moduleName); } else { $value = '--'; } } } if ($fieldInstance->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $moduleName); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $moduleName); } else { $value = ' --'; } } if ($fieldInstance->getFieldDataType() == 'picklist') { $isRoleBased = vtws_isRoleBasedPicklist($fieldName); if ($isRoleBased && ($fieldName != 'activitytype' || $value != 'Task')) { $accessiblePicklistValues = getAssignedPicklistValues($fieldName, $current_user->roleid, $adb); if (!empty($value) && !is_admin($current_user) && !in_array($value, $accessiblePicklistValues)) { $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $moduleName) . "</font>"; } else { $value = getTranslatedString($value, $moduleName); } } else { $value = getTranslatedString($value, $moduleName); } } if ($fieldInstance->getFieldDataType() == 'date' || $fieldInstance->getFieldDataType() == 'datetime' || $fieldInstance->getFieldDataType() == 'time') { if ($value != '' && $value != '0000-00-00') { $date = new DateTimeField($value); if ($fieldInstance->getFieldDataType() == 'date') { $value = $date->getDisplayDate(); } if ($fieldInstance->getFieldDataType() == 'datetime') { $value = $date->getDisplayDateTimeValue(); } if ($fieldInstance->getFieldDataType() == 'time') { $value = $date->getDisplayTime(); } } else { $value = ''; } } if ($fieldInstance->getFieldDataType() == 'currency') { if ($value != '' && $value != 0) { if ($fieldInstance->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $moduleName); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($moduleName, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $currencyValue = CurrencyField::convertToUserFormat($value, null, true); $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol); } else { $currencyField = new CurrencyField($value); $value = $currencyField->getDisplayValueWithSymbol(); } } } if ($fieldInstance->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $value, $matches); if (!empty($matches[0])) { $value = '<a href="' . $value . '" target="_blank">' . $value . '</a>'; } else { $value = '<a href="http://' . $value . '" target="_blank">' . $value . '</a>'; } } if ($fieldInstance->getFieldDataType() == 'boolean') { if ($value == 1) { $value = getTranslatedString('yes', $moduleName); } elseif ($value == 0) { $value = getTranslatedString('no', $moduleName); } else { $value = '--'; } } if ($fieldInstance->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; $isRoleBased = vtws_isRoleBasedPicklist($fieldName); if (!is_admin($current_user) && $value != '' && $isRoleBased) { $accessiblePicklistValues = getAssignedPicklistValues($fieldName, $current_user->roleid, $adb); $valueArray = $value != "" ? explode(', ', $value) : array(); $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $moduleName) . "</font>"; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!in_array(trim($val), $accessiblePicklistValues)) { $tmpArray[] = $notaccess; } else { $tmpArray[] = $val; } } $value = implode(', ', $tmpArray); } } if ($fieldInstance->getFieldDataType() == 'reference') { if (!empty($value)) { $referenceList = $fieldInstance->getReferenceList(); if (count($referenceList) > 0) { $firstReferenceModule = $referenceList[0]; if ($firstReferenceModule == 'Users') { $value = getUserFullName($value); } elseif ($firstReferenceModule == 'DocumentFolders') { $wsFolderId = vtws_getWebserviceEntityId('DocumentFolders', $value); $value = vtws_getName($wsFolderId, $current_user); } elseif ($firstReferenceModule == 'Currency') { $value = getCurrencyName($value); } else { $referenceModule = getSalesEntityType($value); $entityNames = getEntityName($referenceModule, array($value)); $value = $entityNames[$value]; } } else { $value = '--'; } } else { $value = '--'; } } if ($fieldInstance->getFieldDataType() == 'owner') { $ownerName = trim(getUserFullName($value)); if (empty($ownerName)) { $ownerInfo = getGroupName($value); $ownerName = $ownerInfo[0]; } $value = $ownerName; } return $value; }
private function GenWithoutDashboard($data) { $js = NULL; $js .= $this->load_library() . "\n"; if ($this->open_js_tag === TRUE) { $js .= '<script type="text/javascript">' . "\n"; } // Load the Visualization API and the controls package. $js .= 'google.load("visualization", "1", {packages:["corechart"]});' . "\n"; // Set a callback to run when the Google Visualization API is loaded. $js .= 'google.setOnLoadCallback(drawChart);' . "\n"; // Callback that creates and populates a data table, // instantiates a dashboard, a range slider and a pie chart, // passes in the data and draws it. $js .= 'function drawChart() {' . "\n"; global $default_charset; if ($this->chart_type == "funnel") { // Create our data table. if (!empty($data)) { $values_array = $data_values_array = array(); $spacing_array = array(""); foreach ($data as $data_key => $data_arr) { // $data_arr[0] = x axis // $data_arr[1] = y axis if ($data_key == 0) { $values_label = $data_arr[1]; } else { // $data_arr[0] = label , $data_arr[1] = value $values_array[$data_arr[0]] = $data_arr[1]; } } $s_uitypes = ITS4YouReports::$s_uitypes; if (in_array($this->chart_column_uitype, $s_uitypes) && $this->chart_column_str != "") { global $current_user; require_once 'modules/PickList/PickListUtils.php'; $roleid = $current_user->roleid; $adb = PearDatabase::getInstance(); $column_str_arr = explode(":", $this->chart_column_str); $column_name = $column_str_arr[1]; $picklistValues = getAssignedPicklistValues($column_name, $roleid, $adb); $ordered_values_array = array(); foreach ($picklistValues as $picklistValuesKey => $picklistValuesVal) { if (array_key_exists($picklistValuesKey, $values_array)) { $ordered_values_array[$picklistValuesKey] = $values_array[$picklistValuesKey]; } } if (!empty($ordered_values_array)) { $values_array = $ordered_values_array; } } $data_values_array[] = $values_label; $max_data = max($values_array); foreach ($values_array as $dv_key => $data_value) { if ($max_data == $data_value) { $spacing_array[] = 0; } if ($max_data != $data_value && is_numeric($data_value)) { $spacing_array[] = ($max_data - $data_value) / 2; } $data_labels_array[] = $dv_key . " [{$data_value}]"; $data_values_array[] = $data_value; } } $spacing_array = $this->array_to_jsarray($spacing_array); $data_values_array = $this->array_to_jsarray($data_values_array); $data_labels_array = $this->array_to_jsarray($data_labels_array); $js_spacing_array = html_entity_decode($spacing_array, ENT_QUOTES, $default_charset); $js_data_values_array = html_entity_decode($data_values_array, ENT_QUOTES, $default_charset); $js_data_labels_array = html_entity_decode($data_labels_array, ENT_QUOTES, $default_charset); $js .= ' var data = new google.visualization.DataTable(); var raw_data = [' . $js_spacing_array . ', ' . $js_data_values_array . ']; var data_values = ' . $js_data_labels_array . '; data.addColumn("string", ""); for (var i = 0; i < raw_data.length; ++i) { data.addColumn("number", raw_data[i][0]); } data.addRows(data_values.length); for (var j = 0; j < data_values.length; ++j) { data.setValue(j, 0, data_values[j].toString()); } for (var i = 0; i < raw_data.length; ++i) { for (var j = 1; j < raw_data[i].length; ++j) { data.setValue(j-1, i+1, raw_data[i][j]); } } '; /* var colors=["#3366cc","#dc3912","#ff9900","#109618","#990099","#0099c6","#dd4477","#66aa00","#b82e2e","#316395","#994499","#22aa99","#aaaa11","#6633cc","#e67300","#8b0707","#651067","#329262","#5574a6","#3b3eac","#b77322","#16d620","#b91383","#f4359e","#9c5935","#a9c413","#2a778d","#668d1c","#bea413","#0c5922","#743411"]; //the code view.columns.sort(function (a, b) { return (a - b); }); chart.getOptions().series=[]; for(var i=1;i<view.columns.length;i++){ chart.getOptions().series.push({color:colors[view.columns[i]-1]}); } //the code */ $this->gen_options["isStacked"] = "true"; $this->gen_options["colors"] = array('ffffff', '3366CC'); } else { // Create our data table. $js_array = $this->array_to_jsarray($data); $js_array = html_entity_decode($js_array, ENT_QUOTES, $default_charset); $js .= 'var data = google.visualization.arrayToDataTable(' . $js_array . ');' . "\n"; } //Generate the options. $js .= 'var options = ' . "\n"; $js .= $this->array_to_jsobject($this->gen_options); $js .= ';' . "\n"; $js .= "var chart = new google.visualization." . $this->graphic_type . "(document.getElementById('" . $this->chart_div . "'));\n"; $js .= 'chart.draw(data, options);' . "\n"; // ITS4YOU-CR SlOl | 15.7.2014 9:46 $js .= 'var chart_image = chart.getImageURI();' . "\n"; if ($this->ch_image_name != "") { $file_path = 'test/ITS4YouReports/' . $this->ch_image_name . '.png'; //var aurl = "index.php?module=ITS4YouReports&action=ITS4YouReportsAjax&mode=ajax&file=SaveImage&filename='.$this->ch_image_name.'&filepath='.$file_path.'&report_filename='.$this->report_filename.'&export_pdf_format='.$this->export_pdf_format.'"; $js .= ' //var aurl = "index.php?module=ITS4YouReports&action=IndexAjax&mode=SaveImage&filename=' . $this->ch_image_name . '&filepath=' . $file_path . '&report_filename=' . $this->report_filename . '&export_pdf_format=' . $this->export_pdf_format . '"; var aurl = "modules/ITS4YouReports/SaveImage.php?filename=' . $this->ch_image_name . '&filepath=' . $file_path . '&report_filename=' . $this->report_filename . '&export_pdf_format=' . $this->export_pdf_format . '"; var ajax = new XMLHttpRequest(); ajax.open("POST",aurl,true); ajax.setRequestHeader("Content-Type", "canvas/upload"); var postData = "canvasData=" + chart_image; ajax.send(postData); ajax.onreadystatechange=function(){ if (ajax.readyState==4 && ajax.status==200){ //window.open(ajax.responseText); document.getElementById("chimgExport").setAttribute("onclick","SaveChartImg(\'' . $file_path . '\',\'' . $this->ch_image_name . '\')"); document.getElementById("chimgExport").style.visibility="visible"; var chartDivContent = document.getElementById("' . $this->chart_div . '").innerHTML; } } '; } // ITS4YOU-END 15.7.2014 9:46 $js .= '}'; /* $js .= "var my_div = document.getElementById('" . $this->chart_div . "_image');" . "\n"; $js .= "var my_chart = new google.visualization." . $this->graphic_type . "(document.getElementById('" . $this->chart_div . "'));" . "\n"; $js .= "alert(my_chart.getImageURI());" . "\n"; $js .= "google.visualization.events.addListener(my_chart, 'ready', function () {" . "\n"; $js .= " my_div.innerHTML = '<img src=\'' + my_chart.getImageURI() + '\'>';" . "\n"; $js .= "});" . "\n"; $js .= "my_chart.draw(data,options);" . "\n"; */ if ($this->open_js_tag === TRUE) { $js .= '</script>' . "\n"; } /* CRIA AS DIVS */ if ($this->create_div === TRUE) { /* CHART DIV */ if ($this->graphic_type == "PieChart") { $style_params = "width:30%;margin:auto;"; } else { $style_params = "width:90%;margin:auto;"; } $js .= '<div id="outerchdiv" style="' . $style_params . '"><div id="' . $this->chart_div . '" class="' . $this->class_chart_div . '" ></div></div>'; $js .= '<div id="' . $this->chart_div . '_image" class="' . $this->class_chart_div . '" style=border:1px solid red;"></div>'; } // FIM CREATE DIV $this->clean(); return $js; }
protected function transformRecordWithGrouping($resultRecord, $module, $isTemplateRecord = false) { $current_user = $this->getActiveUser(); $moduleFieldGroups = Mobile_WS_Utils::gatherModuleFieldGroupInfo($module); $modifiedResult = array(); $blocks = array(); $labelFields = false; foreach ($moduleFieldGroups as $blocklabel => $fieldgroups) { $fields = array(); foreach ($fieldgroups as $fieldname => $fieldinfo) { $value = $resultRecord[$fieldname]; $fieldlabel = $fieldinfo['label']; // get field information if (isset($resultRecord[$fieldname])) { //get standard content & perform special settings if ($fieldinfo['uitype'] == 17 && strlen($resultRecord[$fieldname])) { //www fields if ($_REQUEST['_operation'] == 'edit') { $resultRecord[$fieldname] = $resultRecord[$fieldname]; } else { $htmlstring = str_replace("http://", "", $resultRecord[$fieldname]); $resultRecord[$fieldname] = "<A HREF=\"#\" onclick=\"window.location.href ='http://" . $htmlstring . "';\" rel=external>" . $htmlstring . "</A>"; } } if ($fieldinfo['uitype'] == 13 && strlen($resultRecord[$fieldname])) { // email fields if ($_REQUEST['_operation'] == 'edit') { $resultRecord[$fieldname] = $resultRecord[$fieldname]; } else { $resultRecord[$fieldname] = "<A HREF=\"#\" onclick=\"window.location.href ='mailto:" . $resultRecord[$fieldname] . "';\">" . $resultRecord[$fieldname] . "</A>"; } } if ($fieldinfo['uitype'] == 72 && strlen($resultRecord[$fieldname])) { //currency fields $resultRecord[$fieldname] = round($resultRecord[$fieldname], 2); } $field = array('name' => $fieldname, 'value' => $resultRecord[$fieldname], 'label' => $fieldinfo['label'], 'uitype' => $fieldinfo['uitype'], 'typeofdata' => $fieldinfo['typeofdata']); // Template record requested, send more details if available if ($isTemplateRecord) { $describeFieldInfo = $this->cachedDescribeFieldInfo($fieldname); foreach ($describeFieldInfo as $k => $v) { if (isset($field[$k])) { continue; } $field[$k] = $v; } // Entity fieldnames $labelFields = $this->cachedEntityFieldnames($module); } //handling for special UI types: modify $field if ($field['uitype'] == '53') { //assigned user global $adb; $output = array_chunk($value, 1); $recordarray = explode('x', $output[0][0]); $recordprefix = $recordarray[0]; $value = $output[0][0]; if ($value != '' && $value != 0) { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } $fieldvalue = Mobile_WS_Utils::getassignedtoValues($current_user, $assigned_user_id); $field['type']['value'] = array('value' => $fieldvalue, 'name' => $fieldname); //end UI 53 } else { if ($field['uitype'] == '117') { $field['type']['defaultValue'] = $field['value']; } else { if ($field['uitype'] == '15' || $field['uitype'] == '16' || $field['uitype'] == '33') { //picklists global $adb; require_once 'modules/PickList/PickListUtils.php'; $fieldvalue = array(); $options = array(); $chk_val = ""; $roleid = $current_user->roleid; $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); $valueArr = explode("|##|", $value); $pickcount = 0; //get values 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('label' => htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), 'value' => $pickListValue, 'selected' => $chk_val); } else { $options[] = array('label' => getTranslatedString($pickListValue), 'value' => $pickListValue, 'selected' => $chk_val); } } if ($pickcount == 0 && !empty($value)) { $options[] = array('label' => $app_strings['LBL_NOT_ACCESSIBLE'], 'value' => $value, 'selected'); } } $editview_label[] = getTranslatedString($fieldlabel, $module); if ($field['uitype'] == '33') { $field['value'] = implode(',', $valueArr); } $fieldvalue[] = $options; $field['type']['value'] = array('value' => $options, 'name' => $fieldname); //end picklists } else { if ($field['uitype'] == '51' || $field['uitype'] == '59' || $field['uitype'] == '10') { $field['relatedmodule'] = Mobile_WS_Utils::getEntityName($field['name'], $module); } } } } $fields[] = $field; } } // build address for "open address in maps" button // array with all different address fieldnames for each module $fieldnamesByModule = array("Accounts" => array("bill_street", "ship_street", "bill_city", "ship_city", "bill_state", "ship_state", "bill_code", "ship_code", "bill_country", "ship_country", "ship_address", "bill_address"), "SalesOrder" => array("bill_street", "ship_street", "bill_city", "ship_city", "bill_state", "ship_state", "bill_code", "ship_code", "bill_country", "ship_country", "ship_address", "bill_address"), "Contacts" => array("mailingstreet", "otherstreet", "mailingcity", "othercity", "mailingstate", "otherstate", "mailingzip", "otherzip", "mailingcountry", "othercountry", "mailingaddress", "otheraddress"), "Leads" => array("lane", "", "city", "", "state", "", "code", "", "country", "", "mailingaddress", "")); // get the right array depending on current module $fieldnames = $fieldnamesByModule[$module]; /* 0 = appears if fieldgroup is not address information 1 = address values are set, show button -1 = city or street is missing, don't show the button and avoid set back to 1 */ $mailingAddressOK = 0; $otherAddressOK = 0; $mailingAddress = ""; $otherAddress = ""; // go through all fields foreach ($fieldgroups as $fieldname => $fieldinfo) { if (!is_array($resultRecord[$fieldname]) and !is_object($resultRecord[$fieldname])) { $value = trim($resultRecord[$fieldname]); // check street and city for first address if ($mailingAddressOK != -1 and ($fieldname == $fieldnames[0] or $fieldname == $fieldnames[2])) { $mailingAddressOK = 1; if (strlen($value) > 0) { $mailingAddress .= $value . " "; } else { $mailingAddressOK = -1; } } else { if ($otherAddressOK != -1 and ($fieldname == $fieldnames[1] or $fieldname == $fieldnames[3])) { $otherAddressOK = 1; if (strlen($value) > 0) { $otherAddress .= $value . " "; } else { $otherAddressOK = -1; } } else { if (in_array($fieldname, array($fieldnames[4], $fieldnames[6])) and strlen($value) > 0) { $mailingAddress .= $value . " "; } else { if (in_array($fieldname, array($fieldnames[5], $fieldnames[7])) and strlen($value) > 0) { $otherAddress .= $value . " "; } } } } } } if ($mailingAddressOK == 1) { if ($module == 'Contacts') { $label = getTranslatedString("address", "Mobile"); } else { $label = getTranslatedString("bill_address", "Mobile"); } $fields[] = array("name" => $fieldnames[10], "value" => $mailingAddress, "label" => $label, "uitype" => "crm_app_map", "typeofdata" => "O"); } if ($otherAddressOK == 1) { if ($module == 'Contacts') { $label = getTranslatedString("otheraddress", "Mobile"); } else { $label = getTranslatedString("ship_address", "Mobile"); } $fields[] = array("name" => $fieldnames[11], "value" => $otherAddress, "label" => $label, "uitype" => "crm_app_map", "typeofdata" => "O"); } $blocks[] = array('label' => $blocklabel, 'fields' => $fields); } $sections = array(); $moduleFieldGroupKeys = array_keys($moduleFieldGroups); foreach ($moduleFieldGroupKeys as $blocklabel) { // eliminate empty blocks if (isset($groups[$blocklabel]) && !empty($groups[$blocklabel])) { $sections[] = array('label' => $blocklabel, 'count' => count($groups[$blocklabel])); } } $modifiedResult = array('blocks' => $blocks, 'id' => $resultRecord['id']); if ($labelFields) { $modifiedResult['labelFields'] = $labelFields; } return $modifiedResult; }
/** 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("<br />", "<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 ' . $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 . ' ' . $mod_strings['LBL_DAYS'] . ' ' . $rem_hrs . ' ' . $mod_strings['LBL_HOURS'] . ' ' . $rem_min . ' ' . $mod_strings['LBL_MINUTES'] . ' ' . $mod_strings['LBL_BEFORE_EVENT']; } $label_fld[] = ' ' . $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; }