function getListViewRecords($focus, $module, $result) { global $listview_max_textlength, $theme, $default_charset; require 'user_privileges/user_privileges_' . $this->user->id . '.php'; $fields = $this->queryGenerator->getFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $this->queryGenerator->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $field->getColumnName()); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { //array_merge API loses key information so need to merge the arrays // manually. $newOwnerList = getOwnerNameList($idList); foreach ($newOwnerList as $id => $name) { $this->ownerNameList[$fieldName][$id] = $name; } } } } } foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } } $useAsterisk = get_use_asterisk($this->user->id); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; $uitype = $field->getUIType(); $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); if (in_array($uitype, array(15, 33, 16))) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename') { $downloadtype = $db->query_result($result, $i, 'filelocationtype'); $fileName = $db->query_result($result, $i, 'filename'); $downloadType = $db->query_result($result, $i, 'filelocationtype'); $status = $db->query_result($result, $i, 'filestatus'); $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($recordId)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($fileName != '' && $status == 1) { if ($downloadType == 'I') { $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="index.php?module=Documents&action=DownloadFile&record=' . $recordId . '&fileid=' . $fileId . '"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>'; } elseif ($downloadType == 'E') { $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="' . $fileName . '" target="_blank"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>'; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($module == 'OSSTimeControl' && $fieldName == 'sum_time') { $value = Vtiger_Functions::decimalTimeFormat($value); $value = $value['short']; } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } $value = Vtiger_Functions::textLength($value); } elseif ($field->getFieldDataType() == 'picklist') { $value = Vtiger_Language_Handler::getTranslatedString($value, $module); $value = textlength_check($value); } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $fieldDataType = $field->getFieldDataType(); if ($module == 'Calendar' && ($fieldName == 'date_start' || $fieldName == 'due_date')) { if ($fieldName == 'date_start') { $timeField = 'time_start'; } else { if ($fieldName == 'due_date') { $timeField = 'time_end'; } } $timeFieldValue = $this->db->query_result($result, $i, $timeField); if (!empty($timeFieldValue)) { $value .= ' ' . $timeFieldValue; //TO make sure it takes time value as well $fieldDataType = 'datetime'; } } if ($fieldDataType == 'datetime') { $value = Vtiger_Datetime_UIType::getDateTimeValue($value); } else { if ($fieldDataType == 'date') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); } } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'time') { if (!empty($value)) { $userModel = Users_Privileges_Model::getCurrentUserModel(); if ($userModel->get('hour_format') == '12') { $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value); } } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = CurrencyField::convertToUserFormat($value, null, true); $row['currencySymbol'] = $currencySymbol; $value = CurrencyField::appendCurrencySymbol($value, $currencySymbol); } else { if (!empty($value)) { $value = CurrencyField::convertToUserFormat($value); $currencyModal = new CurrencyField($value); $currencyModal->initialize(); $value = $currencyModal->appendCurrencySymbol($value, $currencyModal->currencySymbol); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a class="urlField cursorPointer" title="' . $rawValue . '" href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a class="urlField cursorPointer" title="' . $rawValue . '" href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { $current_user = vglobal('current_user'); if ($current_user->internal_mailer == 1) { //check added for email link in user detailview $value = "<a class='emailField' onclick=\"Vtiger_Helper_Js.getInternalMailer({$recordId}," . "'{$fieldName}','{$module}');\">" . textlength_check($value) . "</a>"; } else { $value = '<a class="emailField" href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value === 'on') { $value = 1; } else { if ($value == 'off') { $value = 0; } } if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?module=Roles&parent=Settings&view=Edit&record=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { $tmpArray[] = $val; $tmp .= ', ' . $val; } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getUIType() == 11) { $outgoingCallPermission = Vtiger_Mobile_Model::checkPermissionForOutgoingCall(); if ($outgoingCallPermission && !empty($value)) { $phoneNumber = preg_replace('/[-()\\s]/', '', $value); $value = '<a class="phoneField" data-phoneNumber="' . $phoneNumber . '" record="' . $recordId . '" onclick="Vtiger_Mobile_Js.registerOutboundCall(\'' . $phoneNumber . '\', ' . $recordId . ')">' . textlength_check($value) . '</a>'; $callUsers = Vtiger_Mobile_Model::getPrivilegesUsers(); if ($callUsers) { $value .= ' <a class="btn btn-xs noLinkBtn" onclick="Vtiger_Mobile_Js.registerOutboundCallToUser(this,\'' . $phoneNumber . '\',' . $recordId . ')" data-placement="right" data-original-title="' . vtranslate('LBL_SELECT_USER_TO_CALL', $module) . '" data-content=\'<select class="select sesectedUser" name="sesectedUser">'; foreach ($callUsers as $key => $item) { $value .= '<option value="' . $key . '">' . $item . '</option>'; } $value .= '</select><br /><a class="btn btn-success popoverCallOK">' . vtranslate('LBL_BTN_CALL', $module) . '</a> <a class="btn btn-inverse popoverCallCancel">' . vtranslate('LBL_CANCEL', $module) . '</a>\' data-trigger="manual"><i class="icon-user"></i></a>'; } } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = reset($moduleList); } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a class='moduleColor_{$parentModule}' href='?module={$parentModule}&view=Detail&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif ($field->getFieldDataType() == 'taxes') { if (!empty($value)) { $valueArray = $value != "" ? explode(',', $value) : []; $tmp = ''; $tmpArray = []; $taxs = Vtiger_Taxes_UIType::getTaxes(); foreach ($valueArray as $index => $tax) { if (isset($taxs[$tax])) { $tmpArray[] = $taxs[$tax]['value'] . '% - ' . $taxs[$tax]['name']; } } $value = implode(', ', $tmpArray); $value = Vtiger_Functions::textLength($value); } } elseif ($field->getFieldDataType() == 'inventoryLimit') { if (!empty($value)) { $valueArray = $value != "" ? explode(',', $value) : []; $tmp = ''; $tmpArray = []; $limits = Vtiger_InventoryLimit_UIType::getLimits(); foreach ($valueArray as $index => $limit) { if (isset($limits[$limit])) { $tmpArray[] = $limits[$limit]['value'] . ' - ' . $limits[$limit]['name']; } } $value = implode(', ', $tmpArray); $value = Vtiger_Functions::textLength($value); } } elseif ($field->getFieldDataType() == 'multiReferenceValue') { $params = $field->getFieldParams(); $fieldModel = Vtiger_Field_Model::getInstanceFromFieldId($params['field']); $valueTmp = trim($value, '|#|'); $valueTmp = $valueTmp != "" ? explode('|#|', $valueTmp) : []; foreach ($valueTmp as $index => $tmp) { $valueTmp[$index] = $fieldModel->getUITypeModel()->getDisplayValue($tmp); } $value = implode(', ', $valueTmp); $value = Vtiger_Functions::textLength($value); } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } else { $value = Vtiger_Functions::textLength($value); } // // vtlib customization: For listview javascript triggers // $value = "$value <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=". // "'{$fieldName}' vtmodule='$module' style='display:none;'></span>"; // // END $row[$fieldName] = $value; } $data[$recordId] = $row; } return $data; }
function getListViewRecords($focus, $module, $result) { global $listview_max_textlength, $theme, $default_charset; require 'user_privileges/user_privileges_' . $this->user->id . '.php'; $fields = $this->queryGenerator->getFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $meta->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $field->getColumnName()); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { //array_merge API loses key information so need to merge the arrays // manually. $newOwnerList = getOwnerNameList($idList); foreach ($newOwnerList as $id => $name) { $this->ownerNameList[$fieldName][$id] = $name; } } } } } foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } } $useAsterisk = get_use_asterisk($this->user->id); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; $uitype = $field->getUIType(); $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); if ($uitype != 8) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename') { $downloadtype = $db->query_result($result, $i, 'filelocationtype'); $fileName = $db->query_result($result, $i, 'filename'); $downloadType = $db->query_result($result, $i, 'filelocationtype'); $status = $db->query_result($result, $i, 'filestatus'); $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($recordId)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($fileName != '' && $status == 1) { if ($downloadType == 'I') { $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="index.php?module=Documents&action=DownloadFile&record=' . $recordId . '&fileid=' . $fileId . '"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>'; } elseif ($downloadType == 'E') { $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="' . $fileName . '" target="_blank"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>'; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } elseif ($field->getFieldDataType() == 'picklist') { //not check for permissions for non admin users for status and activity type field if ($module == 'Calendar' && ($fieldName == 'taskstatus' || $fieldName == 'eventstatus' || $fieldName == 'activitytype')) { $value = Vtiger_Language_Handler::getTranslatedString($value, $module); $value = textlength_check($value); } else { if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName]) && strtolower($value) != '--none--' && strtolower($value) != 'none') { $value = "<font color='red'>" . Vtiger_Language_Handler::getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; } else { $value = Vtiger_Language_Handler::getTranslatedString($value, $module); $value = textlength_check($value); } } } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $fieldDataType = $field->getFieldDataType(); if ($module == 'Calendar' && ($fieldName == 'date_start' || $fieldName == 'due_date')) { if ($fieldName == 'date_start') { $timeField = 'time_start'; } else { if ($fieldName == 'due_date') { $timeField = 'time_end'; } } $timeFieldValue = $this->db->query_result($result, $i, $timeField); if (!empty($timeFieldValue)) { $value .= ' ' . $timeFieldValue; //TO make sure it takes time value as well $fieldDataType = 'datetime'; } } if ($fieldDataType == 'datetime') { $value = Vtiger_Datetime_UIType::getDateTimeValue($value); } else { if ($fieldDataType == 'date') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); } } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'time') { if (!empty($value)) { $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value); } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = CurrencyField::convertToUserFormat($value, null, true); $row['currencySymbol'] = $currencySymbol; // $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol); } else { if (!empty($value)) { $value = CurrencyField::convertToUserFormat($value); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a class="urlField cursorPointer" href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a class="urlField cursorPointer" href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { global $current_user; if ($current_user->internal_mailer == 1) { //check added for email link in user detailview $value = "<a class='emailField' onclick=\"Vtiger_Helper_Js.getInternalMailer({$recordId}," . "'{$fieldName}');\">" . textlength_check($value) . "</a>"; } else { $value = '<a class="emailField" href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value === 'on') { $value = 1; } else { if ($value == 'off') { $value = 0; } } if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?module=Roles&parent=Settings&view=Edit&record=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim($val), $this->picklistValueMap[$fieldName])) { $tmpArray[] = $notaccess; $tmp .= ', ' . $notaccess; } else { $tmpArray[] = $val; $tmp .= ', ' . $val; } } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getFieldDataType() == 'phone') { if ($useAsterisk == 'true') { $value = "<a href='javascript:;' onclick='startCall("{$value}", " . ""{$recordId}")'>" . textlength_check($value) . "</a>"; } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = $moduleList[0]; } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a href='?module={$parentModule}&view=Detail&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } else { $value = textlength_check($value); } // // vtlib customization: For listview javascript triggers // $value = "$value <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=". // "'{$fieldName}' vtmodule='$module' style='display:none;'></span>"; // // END $row[$fieldName] = $value; } $data[$recordId] = $row; } return $data; }
function getListViewEntries($focus, $module, $result, $navigationInfo, $skipActions = false) { require 'user_privileges/user_privileges_' . $this->user->id . '.php'; global $listview_max_textlength, $theme, $default_charset; $fields = $this->queryGenerator->getFields(); $whereFields = $this->queryGenerator->getWhereFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $meta->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $field->getColumnName()); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { //array_merge API loses key information so need to merge the arrays // manually. $newOwnerList = getOwnerNameList($idList); foreach ($newOwnerList as $id => $name) { $this->ownerNameList[$fieldName][$id] = $name; } } } } } foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } } $useAsterisk = get_use_asterisk($this->user->id); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); $ownerId = $db->query_result($result, $i, "smownerid"); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; $uitype = $field->getUIType(); $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); if ($module == 'Calendar') { $activityType = $this->db->query_result($result, $i, 'activitytype'); } if ($uitype != 8) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename') { $downloadtype = $db->query_result($result, $i, 'filelocationtype'); if ($downloadtype == 'I') { $ext = substr($value, strrpos($value, ".") + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $value = '--'; $fileicon = ''; } } else { $value = ' --'; $fileicon = ''; } $fileName = $db->query_result($result, $i, 'filename'); $downloadType = $db->query_result($result, $i, 'filelocationtype'); $status = $db->query_result($result, $i, 'filestatus'); $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($recordId)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($fileName != '' && $status == 1) { if ($downloadType == 'I') { $value = "<a href='index.php?module=uploads&action=downloadfile&" . "entityid={$recordId}&fileid={$fileId}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$recordId});'>" . textlength_check($value) . "</a>"; } elseif ($downloadType == 'E') { $value = "<a target='_blank' href='{$fileName}' onclick='javascript:" . "dldCntIncrease({$recordId});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . textlength_check($value) . "</a>"; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } elseif ($field->getFieldDataType() == 'picklist') { if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName])) { $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; } else { $value = getTranslatedString($value, $module); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); if ($field->getFieldDataType() == 'datetime') { $value .= ' ' . $date->getDisplayTime(); } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = number_format($value, 2, '.', ''); $currencyValue = CurrencyField::convertToUserFormat($value, null, true); $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol); } else { //changes made to remove vtiger_currency symbol infront of each //vtiger_potential amount if ($value != 0) { $value = CurrencyField::convertToUserFormat($value); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { if ($_SESSION['internal_mailer'] == 1) { //check added for email link in user detailview $fieldId = $field->getFieldId(); $value = "<a href=\"javascript:InternalMailer({$recordId},{$fieldId}," . "'{$fieldName}','{$module}','record_id');\">" . textlength_check($value) . "</a>"; } else { $value = '<a href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=' . 'Settings&roleid=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim($val), $this->picklistValueMap[$fieldName])) { $tmpArray[] = $notaccess; $tmp .= ', ' . $notaccess; } else { $tmpArray[] = $val; $tmp .= ', ' . $val; } } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getFieldDataType() == 'phone') { if ($useAsterisk == 'true') { $value = "<a href='javascript:;' onclick='startCall("{$value}", " . ""{$recordId}")'>" . textlength_check($value) . "</a>"; } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = $moduleList[0]; } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a href='index.php?module={$parentModule}&action=DetailView&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } elseif ($field->getUIType() == 55) { $value = getTranslatedString($value, $currentModule); } else { $value = textlength_check($value); } $parenttab = getParentTab(); $nameFields = $this->queryGenerator->getModuleNameFields($module); $nameFieldList = explode(',', $nameFields); if (in_array($fieldName, $nameFieldList) && $module != 'Emails') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } elseif ($fieldName == $focus->list_link_field && $module != 'Emails') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=" . "'{$fieldName}' vtmodule='{$module}' style='display:none;'></span>"; // END $row[] = $value; } //Added for Actions ie., edit and delete links in listview $actionLinkInfo = ""; if (isPermitted($module, "EditView", "") == 'yes') { $edit_link = $this->getListViewEditLink($module, $recordId); if (isset($navigationInfo['start']) && $navigationInfo['start'] > 1 && $module != 'Emails') { $actionLinkInfo .= "<a href=\"{$edit_link}&start=" . $navigationInfo['start'] . "\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } else { $actionLinkInfo .= "<a href=\"{$edit_link}\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } } if (isPermitted($module, "Delete", "") == 'yes') { $del_link = $this->getListViewDeleteLink($module, $recordId); if ($actionLinkInfo != "" && $del_link != "") { $actionLinkInfo .= " | "; } if ($del_link != "") { $actionLinkInfo .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . getTranslatedString("LNK_DELETE", $module) . "</a>"; } } // Record Change Notification if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) { if (!$focus->isViewed($recordId)) { $actionLinkInfo .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>"; } } // END if ($actionLinkInfo != "" && !$skipActions) { $row[] = $actionLinkInfo; } $data[$recordId] = $row; } return $data; }
function getListViewEntries($focus, $module, $result, $navigationInfo, $skipActions = false) { require 'user_privileges/user_privileges_' . $this->user->id . '.php'; global $listview_max_textlength, $theme, $default_charset, $current_user, $currentModule, $adb; $fields = $this->queryGenerator->getFields(); $whereFields = $this->queryGenerator->getWhereFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $meta->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); if ($this->queryGenerator->getReferenceFieldInfoList()) { $accessibleFieldList = array_merge($this->queryGenerator->getReferenceFieldNameList(), $accessibleFieldList); } $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $listviewcolumns = $db->getFieldsArray($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } $fldcolname = $field->getColumnName(); $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $fldcolname); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!isset($this->ownerNameList[$fieldName]) or !is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { $newOwnerList = getOwnerNameList($idList); $this->ownerNameList[$fieldName] = $this->ownerNameList[$fieldName] + $newOwnerList; } } } } foreach ($listViewFields as $fieldName) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } $idList = array(); if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $modrel = getTabModuleName($field->getTabId()); $fldcolname = 'smowner' . strtolower($modrel); $j = $rowCount * $k; $k++; for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $fldcolname); if (!isset($this->ownerNameListrel[$fieldName][$id])) { $idList[$j] = $id; $j++; } } } else { if (getTabid($currentModule) != $field->getTabId() && $field->getFieldDataType() == 'reference') { $this->fetchNameList($field, $result, 1); } } if (count($idList) > 0) { if (!isset($this->ownerNameListrel[$fieldName]) or !is_array($this->ownerNameListrel[$fieldName])) { $this->ownerNameListrel[$fieldName] = getOwnerNameList($idList); } else { $newOwnerList = getOwnerNameList($idList); $this->ownerNameListrel[$fieldName] = $this->ownerNameListrel[$fieldName] + $newOwnerList; } } } $useAsterisk = get_use_asterisk($this->user->id); $wfs = new VTWorkflowManager($adb); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); $ownerId = $db->query_result($result, $i, "smownerid"); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } $uitype = $field->getUIType(); if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $modrel = getTabModuleName($field->getTabId()); $rawValue = $this->db->query_result($result, $i, "smowner" . strtolower($modrel)); } else { if (getTabid($currentModule) != $field->getTabId()) { $modrel = getTabModuleName($field->getTabId()); $relfieldname = strtolower($modrel) . $field->getColumnName(); if (in_array($relfieldname, $listviewcolumns)) { $rawValue = $this->db->query_result($result, $i, $relfieldname); } else { $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); } } else { $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); } } if ($module == 'Calendar') { $activityType = $this->db->query_result($result, $i, 'activitytype'); } if ($uitype != 8) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename' or $fieldName == 'Documents.filename') { if ($fieldName == 'Documents.filename') { $docrs = $db->pquery('select filename,filelocationtype,filestatus,notesid from vtiger_notes where note_no=?', array($db->query_result($result, $i, 'documentsnote_no'))); $downloadtype = $db->query_result($docrs, 0, 'filelocationtype'); $fileName = $db->query_result($docrs, 0, 'filename'); $status = $db->query_result($docrs, 0, 'filestatus'); $docid = $db->query_result($docrs, 0, 'notesid'); } else { $docid = $recordId; $downloadtype = $db->query_result($result, $i, 'filelocationtype'); $fileName = $db->query_result($result, $i, 'filename'); $status = $db->query_result($result, $i, 'filestatus'); } $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($docid)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($downloadtype == 'I') { $ext = substr($value, strrpos($value, ".") + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $value = '--'; $fileicon = ''; } } else { $value = ' --'; $fileicon = ''; } if ($fileName != '' && $status == 1) { if ($downloadtype == 'I') { $value = "<a href='index.php?module=uploads&action=downloadfile&" . "entityid={$docid}&fileid={$fileId}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$docid});'>" . textlength_check($value) . "</a>"; } elseif ($downloadtype == 'E') { $value = "<a target='_blank' href='{$fileName}' onclick='javascript:" . "dldCntIncrease({$docid});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . textlength_check($value) . "</a>"; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } elseif ($field->getFieldDataType() == 'picklist') { if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName])) { $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; } else { $value = getTranslatedString($value, $module); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); if ($field->getFieldDataType() == 'datetime') { $value .= ' ' . $date->getDisplayTime(); } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = number_format($value, 2, '.', ''); $currencyValue = CurrencyField::convertToUserFormat($value, null, true); $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol); } else { //changes made to remove vtiger_currency symbol in front of each potential amount if ($value != 0) { $value = CurrencyField::convertToUserFormat($value); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { if ($_SESSION['internal_mailer'] == 1) { //check added for email link in user detailview $fieldId = $field->getFieldId(); $value = "<a href=\"javascript:InternalMailer({$recordId},{$fieldId}," . "'{$fieldName}','{$module}','record_id');\">" . textlength_check($value) . "</a>"; } else { $value = '<a href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=' . 'Settings&roleid=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getUIType() == 69) { if ($module == 'Products') { $queryPrdt = 'SELECT vtiger_attachments.path,vtiger_attachments.attachmentsid,vtiger_attachments.`name` FROM vtiger_attachments INNER JOIN vtiger_seattachmentsrel ON vtiger_attachments.attachmentsid = vtiger_seattachmentsrel.attachmentsid INNER JOIN vtiger_products ON vtiger_seattachmentsrel.crmid = vtiger_products.productid where vtiger_seattachmentsrel.crmid=?'; $resultprdt = $this->db->pquery($queryPrdt, array($recordId)); if ($resultprdt and $this->db->num_rows($resultprdt) > 0) { $imgpath = $this->db->query_result($resultprdt, 0, 'path'); $attid = $this->db->query_result($resultprdt, 0, 'attachmentsid'); $imgfilename = $this->db->query_result($resultprdt, 0, 'name'); $value = "<div style='text-align:center;width:100%;'><img src='./" . $imgpath . $attid . '_' . $imgfilename . "' height='50'></div>"; } else { $value = ''; } } else { if ($module == 'Contacts') { $imageattachment = 'Image'; } else { $imageattachment = 'Attachment'; } //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t\t\t\t from vtiger_attachments\n\t\t\t\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t\t\t\t and vtiger_attachments.name = ?\n\t\t\t\t\t\t and vtiger_seattachmentsrel.crmid=?"; $image_res = $this->db->pquery($sql, array(str_replace(' ', '_', $value), $recordId)); $image_id = $this->db->query_result($image_res, 0, 'attachmentsid'); $image_path = $this->db->query_result($image_res, 0, 'path'); $image_name = urlencode(decode_html($this->db->query_result($image_res, 0, 'name'))); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { $ftype = $this->db->query_result($image_res, 0, 'type'); $isimage = stripos($ftype, 'image') !== false; if ($isimage) { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image'); $value = '<div style="width:100%;text-align:center;"><img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 50px;"></div>'; } else { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents'); $value = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>'; } } else { $value = ''; } } } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim(decode_html($val)), $this->picklistValueMap[$fieldName])) { $tmpArray[] = $notaccess; $tmp .= ', ' . $notaccess; } else { $tmpArray[] = $val; $tmp .= ', ' . $val; } } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getUIType() == 1024) { $content = array(); if ($value != '') { $arr_evo_actions = explode(' |##| ', $value); for ($fvalues = 0; $fvalues < sizeof($arr_evo_actions); $fvalues++) { $roleid = $arr_evo_actions[$fvalues]; $rolename = getRoleName($roleid); $content[$fvalues] = $rolename; } } $value = textlength_check(implode(', ', $content)); } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getFieldDataType() == 'phone') { if ($useAsterisk == 'true') { $value = "<a href='javascript:;' onclick='startCall("{$value}", " . ""{$recordId}")'>" . textlength_check($value) . "</a>"; } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); if (getTabid($currentModule) != $field->getTabId()) { $modrel = getTabModuleName($field->getTabId()); $fieldName = str_replace($modrel . '.', "", $fieldName); } $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = $moduleList[0]; } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a href='index.php?module={$parentModule}&action=DetailView&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; $modMetaInfo = getEntityFieldNames($parentModule); $fieldName = is_array($modMetaInfo['fieldname']) ? $modMetaInfo['fieldname'][0] : $modMetaInfo['fieldname']; // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$rawValue}' vtfieldname=" . "'{$fieldName}' vtmodule='{$parentModule}' style='display:none;'></span>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $value = textlength_check($this->ownerNameListrel[$fieldName][$value]); } else { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } elseif ($field->getUIType() == 55) { $value = getTranslatedString($value, $currentModule); } elseif ($module == 'Emails' && $fieldName == 'subject') { $value = '<a href="javascript:;" onClick="ShowEmail(\'' . $recordId . '\');">' . textlength_check($value) . '</a>'; } else { $value = textlength_check($value); } if ($field->getFieldDataType() != 'reference') { $parenttab = getParentTab(); $nameFields = $this->queryGenerator->getModuleNameFields($module); $nameFieldList = explode(',', $nameFields); if (($fieldName == $focus->list_link_field or in_array($fieldName, $nameFieldList)) && $module != 'Emails') { $opennewtab = GlobalVariable::getVariable('Application_OpenRecordInNewXOnListView', '', $module); if ($opennewtab == '') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } elseif ($opennewtab == 'window') { $value = "<a href='#' onclick='window.open(\"index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}\", \"{$module}-{$entity_id}\", \"width=1300, height=900, scrollbars=yes\"); return false;' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } else { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "' target='_blank'>{$value}</a>"; } } // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=" . "'{$fieldName}' vtmodule='{$module}' style='display:none;'></span>"; } $row[] = $value; } //Added for Actions ie., edit and delete links in listview $actionLinkInfo = ""; if (isPermitted($module, "EditView", "") == 'yes') { $racbr = $wfs->getRACRuleForRecord($currentModule, $recordId); if (!$racbr or $racbr->hasListViewPermissionTo('edit')) { $edit_link = $this->getListViewEditLink($module, $recordId); if (isset($navigationInfo['start']) && $navigationInfo['start'] > 1 && $module != 'Emails') { $actionLinkInfo .= "<a href=\"{$edit_link}&start=" . $navigationInfo['start'] . "\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } else { $actionLinkInfo .= "<a href=\"{$edit_link}\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } } } if (isPermitted($module, "Delete", "") == 'yes') { $racbr = $wfs->getRACRuleForRecord($currentModule, $recordId); if (!$racbr or $racbr->hasListViewPermissionTo('delete')) { $del_link = $this->getListViewDeleteLink($module, $recordId); if ($actionLinkInfo != "" && $del_link != "") { $actionLinkInfo .= ' | '; } if ($del_link != "") { $actionLinkInfo .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . getTranslatedString('LNK_DELETE', $module) . '</a>'; } } } // Record Change Notification if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) { if (!$focus->isViewed($recordId)) { $actionLinkInfo .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>"; } } // END if ($actionLinkInfo != "" && !$skipActions) { $row[] = $actionLinkInfo; } list($row, $unused, $unused2) = cbEventHandler::do_filter('corebos.filter.listview.render', array($row, $this->db->query_result_rowdata($result, $i), $recordId)); $data[$recordId] = $row; } return $data; }