[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /*+******************************************************************************* 3 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 ******************************************************************************** */ 10 11 /** 12 * Function to get the field information from module name and field label 13 */ 14 function getFieldByReportLabel($module, $label) { 15 $cacheLabel = VTCacheUtils::getReportFieldByLabel($module, $label); 16 if($cacheLabel) return $cacheLabel; 17 18 // this is required so the internal cache is populated or reused. 19 getColumnFields($module); 20 //lookup all the accessible fields 21 $cachedModuleFields = VTCacheUtils::lookupFieldInfo_Module($module); 22 $label = decode_html($label); 23 24 if($module == 'Calendar') { 25 $cachedEventsFields = VTCacheUtils::lookupFieldInfo_Module('Events'); 26 if ($cachedEventsFields) { 27 if(empty($cachedModuleFields)) $cachedModuleFields = $cachedEventsFields; 28 else $cachedModuleFields = array_merge($cachedModuleFields, $cachedEventsFields); 29 } 30 if($label == 'Start_Date_and_Time') { 31 $label = 'Start_Date_&_Time'; 32 } 33 } 34 35 if(empty($cachedModuleFields)) { 36 return null; 37 } 38 39 foreach ($cachedModuleFields as $fieldInfo) { 40 $fieldLabel = str_replace(' ', '_', $fieldInfo['fieldlabel']); 41 $fieldLabel = decode_html($fieldLabel); 42 if($label == $fieldLabel) { 43 VTCacheUtils::setReportFieldByLabel($module, $label, $fieldInfo); 44 return $fieldInfo; 45 } 46 } 47 return null; 48 } 49 50 function isReferenceUIType($uitype) { 51 static $options = array('101', '116', '117', '26', '357', 52 '50', '51', '52', '53', '57', '58', '59', '66', '68', 53 '73', '75', '76', '77', '78', '80', '81' 54 ); 55 56 if(in_array($uitype, $options)) { 57 return true; 58 } 59 return false; 60 } 61 62 function IsDateField($reportColDetails) { 63 list($tablename, $colname, $module_field, $fieldname, $typeOfData) = split(":", $reportColDetails); 64 if ($typeOfData == "D") { 65 return true; 66 } else { 67 return false; 68 } 69 } 70 71 /** 72 * 73 * @global Users $current_user 74 * @param ReportRun $report 75 * @param Array $picklistArray 76 * @param ADOFieldObject $dbField 77 * @param Array $valueArray 78 * @param String $fieldName 79 * @return String 80 */ 81 function getReportFieldValue ($report, $picklistArray, $dbField, $valueArray, $fieldName) { 82 global $current_user, $default_charset; 83 84 $db = PearDatabase::getInstance(); 85 $value = $valueArray[$fieldName]; 86 $fld_type = $dbField->type; 87 list($module, $fieldLabel) = explode('_', $dbField->name, 2); 88 $fieldInfo = getFieldByReportLabel($module, $fieldLabel); 89 $fieldType = null; 90 $fieldvalue = $value; 91 if(!empty($fieldInfo)) { 92 $field = WebserviceField::fromArray($db, $fieldInfo); 93 $fieldType = $field->getFieldDataType(); 94 } 95 96 if ($fieldType == 'currency' && $value != '') { 97 // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion 98 if($field->getUIType() == '72') { 99 $curid_value = explode("::", $value); 100 $currency_id = $curid_value[0]; 101 $currency_value = $curid_value[1]; 102 $cur_sym_rate = getCurrencySymbolandCRate($currency_id); 103 if($value!='') { 104 if(($dbField->name == 'Products_Unit_Price')) { // need to do this only for Products Unit Price 105 if ($currency_id != 1) { 106 $currency_value = (float)$cur_sym_rate['rate'] * (float)$currency_value; 107 } 108 } 109 110 $formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true); 111 $fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']); 112 } 113 } else { 114 $currencyField = new CurrencyField($value); 115 $fieldvalue = $currencyField->getDisplayValue(); 116 } 117 118 } elseif ($dbField->name == "PurchaseOrder_Currency" || $dbField->name == "SalesOrder_Currency" 119 || $dbField->name == "Invoice_Currency" || $dbField->name == "Quotes_Currency" || $dbField->name == "PriceBooks_Currency") { 120 if($value!='') { 121 $fieldvalue = getTranslatedCurrencyString($value); 122 } 123 } elseif (in_array($dbField->name,$report->ui101_fields) && !empty($value)) { 124 $entityNames = getEntityName('Users', $value); 125 $fieldvalue = $entityNames[$value]; 126 } elseif( $fieldType == 'date' && !empty($value)) { 127 if($module == 'Calendar' && $field->getFieldName() == 'due_date') { 128 $endTime = $valueArray['calendar_end_time']; 129 if(empty($endTime)) { 130 $recordId = $valueArray['calendar_id']; 131 $endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId); 132 } 133 $date = new DateTimeField($value.' '.$endTime); 134 $fieldvalue = $date->getDisplayDate(); 135 } else { 136 $date = new DateTimeField($fieldvalue); 137 $fieldvalue = $date->getDisplayDateTimeValue(); 138 } 139 } elseif( $fieldType == "datetime" && !empty($value)) { 140 $date = new DateTimeField($value); 141 $fieldvalue = $date->getDisplayDateTimeValue(); 142 } elseif( $fieldType == 'time' && !empty($value) && $field->getFieldName() 143 != 'duration_hours') { 144 if($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") { 145 $date = new DateTimeField($value); 146 $fieldvalue = $date->getDisplayTime(); 147 } else { 148 $userModel = Users_Privileges_Model::getCurrentUserModel(); 149 if($userModel->get('hour_format') == '12'){ 150 $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value); 151 } 152 $fieldvalue = $value; 153 } 154 } elseif( $fieldType == "picklist" && !empty($value) ) { 155 if(is_array($picklistArray)) { 156 if(is_array($picklistArray[$dbField->name]) && 157 $field->getFieldName() != 'activitytype' && !in_array( 158 $value, $picklistArray[$dbField->name])){ 159 $fieldvalue =$app_strings['LBL_NOT_ACCESSIBLE']; 160 } else { 161 $fieldvalue = getTranslatedString($value, $module); 162 } 163 } else { 164 $fieldvalue = getTranslatedString($value, $module); 165 } 166 } elseif( $fieldType == "multipicklist" && !empty($value) ) { 167 if(is_array($picklistArray[1])) { 168 $valueList = explode(' |##| ', $value); 169 $translatedValueList = array(); 170 foreach ( $valueList as $value) { 171 if(is_array($picklistArray[1][$dbField->name]) && !in_array( 172 $value, $picklistArray[1][$dbField->name])) { 173 $translatedValueList[] = 174 $app_strings['LBL_NOT_ACCESSIBLE']; 175 } else { 176 $translatedValueList[] = getTranslatedString($value, 177 $module); 178 } 179 } 180 } 181 if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) { 182 $fieldvalue = str_replace(' |##| ', ', ', $value); 183 } else { 184 implode(', ', $translatedValueList); 185 } 186 } elseif ($fieldType == 'double') { 187 if($current_user->truncate_trailing_zeros == true) 188 $fieldvalue = decimalFormat($fieldvalue); 189 } 190 if($fieldvalue == "") { 191 return "-"; 192 } 193 $fieldvalue = str_replace("<", "<", $fieldvalue); 194 $fieldvalue = str_replace(">", ">", $fieldvalue); 195 $fieldvalue = decode_html($fieldvalue); 196 197 if (stristr($fieldvalue, "|##|") && empty($fieldType)) { 198 $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); 199 } elseif ($fld_type == "date" && empty($fieldType)) { 200 $fieldvalue = DateTimeField::convertToUserFormat($fieldvalue); 201 } elseif ($fld_type == "datetime" && empty($fieldType)) { 202 $date = new DateTimeField($fieldvalue); 203 $fieldvalue = $date->getDisplayDateTimeValue(); 204 } 205 206 // Added to render html tag for description fields 207 if($fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) { 208 return $fieldvalue; 209 } 210 return htmlentities($fieldvalue, ENT_QUOTES, $default_charset); 211 } 212 213 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |