コード例 #1
0
ファイル: SaveTodo.php プロジェクト: casati-dolibarr/corebos
function getRequestedToData()
{
    $mail_data = array();
    $mail_data['user_id'] = $_REQUEST["task_assigned_user_id"];
    $mail_data['subject'] = $_REQUEST['task_subject'];
    $mail_data['status'] = $_REQUEST['activity_mode'] == 'Task' ? $_REQUEST['taskstatus'] : $_REQUEST['eventstatus'];
    $mail_data['activity_mode'] = $_REQUEST['activity_mode'];
    $mail_data['taskpriority'] = $_REQUEST['taskpriority'];
    $mail_data['relatedto'] = $_REQUEST['task_parent_name'];
    $mail_data['contact_name'] = $_REQUEST['task_contact_name'];
    $mail_data['description'] = $_REQUEST['task_description'];
    $mail_data['assign_type'] = $_REQUEST['task_assigntype'];
    $mail_data['group_name'] = getGroupName($_REQUEST['task_assigned_group_id']);
    $mail_data['mode'] = $_REQUEST['task_mode'];
    $startTime = $_REQUEST['task_time_start'];
    $date = new DateTimeField($_REQUEST['task_date_start'] . " " . $startTime);
    $endTime = $_REQUEST['task_time_end'];
    $endDate = new DateTimeField($_REQUEST['task_due_date'] . " " . $startTime);
    $startTime = $date->getDisplayTime();
    $endTime = $endDate->getDisplayTime();
    $value = getaddEventPopupTime($startTime, $endTime, '24');
    $start_hour = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt'];
    $mail_data['st_date_time'] = $date->getDisplayDateTimeValue();
    $mail_data['end_date_time'] = $endDate->getDisplayDate();
    return $mail_data;
}
コード例 #2
0
ファイル: Calendar.php プロジェクト: rcrrich/UpdatePackages
 public function getEntity()
 {
     $db = PearDatabase::getInstance();
     $module = 'Calendar';
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $query = getListQuery($module);
     $params = array();
     if ($this->get('start') && $this->get('end')) {
         $dbStartDateOject = DateTimeField::convertToDBTimeZone($this->get('start'));
         $dbStartDateTime = $dbStartDateOject->format('Y-m-d H:i:s');
         $dbEndDateObject = DateTimeField::convertToDBTimeZone($this->get('end'));
         $dbEndDateTime = $dbEndDateObject->format('Y-m-d H:i:s');
         $query .= " AND (concat(date_start, ' ', time_start)  >= ? AND concat(due_date, ' ', time_end) <= ?) ";
         $params[] = $dbStartDateTime;
         $params[] = $dbEndDateTime;
     }
     if ($this->get('types')) {
         $query .= " AND vtiger_activity.activitytype IN ('" . implode("','", $this->get('types')) . "')";
     }
     if ($this->get('user')) {
         if (is_array($this->get('user'))) {
             $query .= ' AND vtiger_crmentity.smownerid IN (' . implode(",", $this->get('user')) . ')';
         } else {
             $query .= ' AND vtiger_crmentity.smownerid IN (' . $this->get('user') . ')';
         }
     }
     $query .= ' ORDER BY date_start,time_start ASC';
     $queryResult = $db->pquery($query, $params);
     $result = array();
     for ($i = 0; $i < $db->num_rows($queryResult); $i++) {
         $record = $db->raw_query_result_rowdata($queryResult, $i);
         $item = array();
         $crmid = $record['activityid'];
         $activitytype = $record['activitytype'];
         $item['id'] = $crmid;
         $item['title'] = $record['subject'];
         $item['url'] = 'index.php?module=' . $module . '&view=Detail&record=' . $crmid;
         $dateTimeFieldInstance = new DateTimeField($record['date_start'] . ' ' . $record['time_start']);
         $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser);
         $dateTimeComponents = explode(' ', $userDateTimeString);
         $dateComponent = $dateTimeComponents[0];
         $startTimeFormated = $dateTimeComponents[1];
         //Conveting the date format in to Y-m-d . since full calendar expects in the same format
         $startDateFormated = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format'));
         $dateTimeFieldInstance = new DateTimeField($record['due_date'] . ' ' . $record['time_end']);
         $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser);
         $dateTimeComponents = explode(' ', $userDateTimeString);
         $dateComponent = $dateTimeComponents[0];
         $endTimeFormated = $dateTimeComponents[1];
         //Conveting the date format in to Y-m-d . since full calendar expects in the same format
         $endDateFormated = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format'));
         $item['start'] = $startDateFormated . ' ' . $startTimeFormated;
         $item['end'] = $endDateFormated . ' ' . $endTimeFormated;
         $item['allDay'] = $record['allday'] == 1 ? true : false;
         $item['className'] = ' userCol_' . $record['smownerid'] . ' calCol_' . $activitytype;
         $result[] = $item;
     }
     return $result;
 }
コード例 #3
0
ファイル: Calendar.php プロジェクト: rcrrich/UpdatePackages
 public function getEntity()
 {
     $db = PearDatabase::getInstance();
     $module = 'Reservations';
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $query = getListQuery($module);
     $params = array();
     if ($this->get('start') && $this->get('end')) {
         $query .= ' AND vtiger_reservations.date_start >= ? AND vtiger_reservations.due_date <= ?';
         $params[] = $this->get('start');
         $params[] = $this->get('end');
     }
     if ($this->get('types')) {
         $query .= " AND vtiger_reservations.type IN ('" . implode("','", $this->get('types')) . "')";
     }
     if ($this->get('user')) {
         if (is_array($this->get('user'))) {
             $query .= ' AND vtiger_crmentity.smownerid IN (' . implode(",", $this->get('user')) . ')';
         } else {
             $query .= ' AND vtiger_crmentity.smownerid IN (' . $this->get('user') . ')';
         }
     }
     $instance = CRMEntity::getInstance($module);
     $securityParameter = $instance->getUserAccessConditionsQuerySR($module, $currentUser);
     if ($securityParameter != '') {
         $query .= ' AND ' . $securityParameter;
     }
     $query .= ' ORDER BY date_start,time_start ASC';
     $queryResult = $db->pquery($query, $params);
     $result = array();
     for ($i = 0; $i < $db->num_rows($queryResult); $i++) {
         $record = $db->raw_query_result_rowdata($queryResult, $i);
         $item = array();
         $crmid = $record['reservationsid'];
         $item['id'] = $crmid;
         $item['title'] = vtranslate($record['name'], $module);
         $item['url'] = 'index.php?module=Reservations&view=Detail&record=' . $crmid;
         $dateTimeFieldInstance = new DateTimeField($record['date_start'] . ' ' . $record['time_start']);
         $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser);
         $dateTimeComponents = explode(' ', $userDateTimeString);
         $dateComponent = $dateTimeComponents[0];
         //Conveting the date format in to Y-m-d . since full calendar expects in the same format
         $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format'));
         $item['start'] = $dataBaseDateFormatedString . ' ' . $dateTimeComponents[1];
         $dateTimeFieldInstance = new DateTimeField($record['due_date'] . ' ' . $record['time_end']);
         $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser);
         $dateTimeComponents = explode(' ', $userDateTimeString);
         $dateComponent = $dateTimeComponents[0];
         //Conveting the date format in to Y-m-d . since full calendar expects in the same format
         $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format'));
         $item['end'] = $dataBaseDateFormatedString . ' ' . $dateTimeComponents[1];
         $item['className'] = ' userCol_' . $record['smownerid'] . ' calCol_' . $record['type'];
         $result[] = $item;
     }
     return $result;
 }
コード例 #4
0
ファイル: Datetime.php プロジェクト: rcrrich/YetiForceCRM
 /**
  * Function to get Date and Time value for Display
  * @param <type> $date
  * @return <String>
  */
 public static function getDisplayDateTimeValue($date)
 {
     $date = new DateTimeField($date);
     $dateValue = $date->getDisplayDateTimeValue();
     list($dateInUserFormat, $timeInUserFormat) = explode(' ', $dateValue);
     $currentUser = Users_Record_Model::getCurrentUserModel();
     if ($currentUser->get('hour_format') == '12') {
         $timeInUserFormat = Vtiger_Time_UIType::getTimeValueInAMorPM($timeInUserFormat);
     }
     return $dateInUserFormat . ' ' . $timeInUserFormat;
 }
コード例 #5
0
ファイル: SaveAjax.php プロジェクト: rcrrich/UpdatePackages
 public function process(Vtiger_Request $request)
 {
     $user = Users_Record_Model::getCurrentUserModel();
     $allDay = $request->get('allday');
     if ('on' == $allDay) {
         $request->set('time_start', NULL);
         $request->set('time_end', NULL);
     }
     $recordModel = $this->saveRecord($request);
     $fieldModelList = $recordModel->getModule()->getFields();
     $result = array();
     foreach ($fieldModelList as $fieldName => $fieldModel) {
         $fieldValue = Vtiger_Util_Helper::toSafeHTML($recordModel->get($fieldName));
         $result[$fieldName] = array();
         if ($fieldName == 'date_start') {
             $timeStart = $recordModel->get('time_start');
             $dateTimeFieldInstance = new DateTimeField($fieldValue . ' ' . $timeStart);
             $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue();
             $dateTimeComponents = explode(' ', $userDateTimeString);
             $dateComponent = $dateTimeComponents[0];
             //Conveting the date format in to Y-m-d . since full calendar expects in the same format
             $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $user->get('date_format'));
             $result[$fieldName]['value'] = $fieldValue;
             $result[$fieldName]['display_value'] = $dataBaseDateFormatedString;
         } else {
             if ($fieldName == 'due_date') {
                 $timeEnd = $recordModel->get('time_end');
                 $dateTimeFieldInstance = new DateTimeField($fieldValue . ' ' . $timeEnd);
                 $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue();
                 $dateTimeComponents = explode(' ', $userDateTimeString);
                 $dateComponent = $dateTimeComponents[0];
                 //Conveting the date format in to Y-m-d . since full calendar expects in the same format
                 $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $user->get('date_format'));
                 $result[$fieldName]['value'] = $fieldValue;
                 $result[$fieldName]['display_value'] = $dataBaseDateFormatedString;
             } else {
                 if ($fieldName == 'time_end') {
                     $dueDate = $recordModel->get('due_date');
                     $dateTimeFieldInstance = new DateTimeField($dueDate . ' ' . $fieldValue);
                     $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue();
                     $dateTimeComponents = explode(' ', $userDateTimeString);
                     $result[$fieldName]['value'] = $fieldValue;
                     $result[$fieldName]['display_value'] = $dateTimeComponents[1];
                 } else {
                     if ($fieldName == 'time_start') {
                         $startDate = $recordModel->get('date_start');
                         $dateTimeFieldInstance = new DateTimeField($startDate . ' ' . $fieldValue);
                         $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue();
                         $dateTimeComponents = explode(' ', $userDateTimeString);
                         $result[$fieldName]['value'] = $fieldValue;
                         $result[$fieldName]['display_value'] = $dateTimeComponents[1];
                     } else {
                         if ('time_start' != $fieldName && 'time_end' != $fieldName && 'duration_hours' != $fieldName) {
                             $result[$fieldName]['value'] = $fieldValue;
                             $result[$fieldName]['display_value'] = decode_html($fieldModel->getDisplayValue($fieldValue));
                         } else {
                             $result[$fieldName]['value'] = $result[$fieldName]['display_value'] = $fieldValue;
                         }
                     }
                 }
             }
         }
     }
     $result['_recordLabel'] = $recordModel->getName();
     $result['_recordId'] = $recordModel->getId();
     // Handled to save follow up event
     $followupMode = $request->get('followup');
     if ($followupMode == 'on') {
         //Start Date and Time values
         $startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('followup_time_start'));
         $startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('followup_date_start') . " " . $startTime);
         list($startDate, $startTime) = explode(' ', $startDateTime);
         $subject = $request->get('subject');
         if ($startTime != '' && $startDate != '') {
             $recordModel->set('eventstatus', 'Planned');
             $recordModel->set('subject', '[Followup] ' . $subject);
             $recordModel->set('date_start', $startDate);
             $recordModel->set('time_start', $startTime);
             $currentUser = Users_Record_Model::getCurrentUserModel();
             $activityType = $recordModel->get('activitytype');
             if ($activityType == 'Call') {
                 $minutes = $currentUser->get('callduration');
             } else {
                 $minutes = $currentUser->get('othereventduration');
             }
             $dueDateTime = date('Y-m-d H:i:s', strtotime("{$startDateTime}+{$minutes} minutes"));
             list($endDate, $endTime) = explode(' ', $dueDateTime);
             $recordModel->set('due_date', $endDate);
             $recordModel->set('time_end', $endTime);
             $recordModel->set('mode', 'create');
             $recordModel->save();
         }
     }
     $response = new Vtiger_Response();
     $response->setEmitType(Vtiger_Response::$EMIT_JSON);
     $response->setResult($result);
     $response->emit();
 }
コード例 #6
0
ファイル: RelBlockRun.php プロジェクト: cin-system/cinrepo
 public function getPDFMakerFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName)
 {
     global $current_user, $default_charset;
     $db = PearDatabase::getInstance();
     $value = $valueArray[$fieldName];
     $fld_type = $dbField->type;
     list($module, $fieldLabel) = explode('_', $dbField->name, 2);
     $fieldInfo = $this->getFieldByPDFMakerLabel($module, $fieldLabel);
     $fieldType = null;
     $fieldvalue = $value;
     if (!empty($fieldInfo)) {
         $field = WebserviceField::fromArray($db, $fieldInfo);
         $fieldType = $field->getFieldDataType();
     }
     if ($fieldType == 'currency' && $value != '') {
         // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
         if ($field->getUIType() == '72') {
             $curid_value = explode("::", $value);
             $currency_id = $curid_value[0];
             $currency_value = $curid_value[1];
             $cur_sym_rate = getCurrencySymbolandCRate($currency_id);
             if ($value != '') {
                 if ($dbField->name == 'Products_Unit_Price') {
                     // need to do this only for Products Unit Price
                     if ($currency_id != 1) {
                         $currency_value = (double) $cur_sym_rate['rate'] * (double) $currency_value;
                     }
                 }
                 $formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true);
                 $fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']);
             }
         } else {
             $currencyField = new CurrencyField($value);
             $fieldvalue = $currencyField->getDisplayValue();
         }
     } elseif ($dbField->name == "PurchaseOrder_Currency" || $dbField->name == "SalesOrder_Currency" || $dbField->name == "Invoice_Currency" || $dbField->name == "Quotes_Currency" || $dbField->name == "PriceBooks_Currency") {
         if ($value != '') {
             $fieldvalue = getTranslatedCurrencyString($value);
         }
     } elseif (in_array($dbField->name, $this->ui101_fields) && !empty($value)) {
         $entityNames = getEntityName('Users', $value);
         $fieldvalue = $entityNames[$value];
     } elseif ($fieldType == 'date' && !empty($value)) {
         if ($module == 'Calendar' && $field->getFieldName() == 'due_date') {
             $endTime = $valueArray['calendar_end_time'];
             if (empty($endTime)) {
                 $recordId = $valueArray['calendar_id'];
                 $endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId);
             }
             $date = new DateTimeField($value . ' ' . $endTime);
             $fieldvalue = $date->getDisplayDate();
         } else {
             $fieldvalue = DateTimeField::convertToUserFormat($value);
         }
     } elseif ($fieldType == "datetime" && !empty($value)) {
         $date = new DateTimeField($value);
         $fieldvalue = $date->getDisplayDateTimeValue();
     } elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours') {
         if ($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") {
             $date = new DateTimeField($value);
             $fieldvalue = $date->getDisplayTime();
         } else {
             $fieldvalue = $value;
         }
     } elseif ($fieldType == "picklist" && !empty($value)) {
         if (is_array($picklistArray)) {
             if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) {
                 $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE'];
             } else {
                 $fieldvalue = $this->getTranslatedString($value, $module);
             }
         } else {
             $fieldvalue = $this->getTranslatedString($value, $module);
         }
     } elseif ($fieldType == "multipicklist" && !empty($value)) {
         if (is_array($picklistArray[1])) {
             $valueList = explode(' |##| ', $value);
             $translatedValueList = array();
             foreach ($valueList as $value) {
                 if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) {
                     $translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE'];
                 } else {
                     $translatedValueList[] = $this->getTranslatedString($value, $module);
                 }
             }
         }
         if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) {
             $fieldvalue = str_replace(' |##| ', ', ', $value);
         } else {
             implode(', ', $translatedValueList);
         }
     } elseif ($fieldType == 'double') {
         if ($current_user->truncate_trailing_zeros == true) {
             $fieldvalue = decimalFormat($fieldvalue);
         }
     }
     if ($fieldvalue == "") {
         return "-";
     }
     $fieldvalue = str_replace("<", "&lt;", $fieldvalue);
     $fieldvalue = str_replace(">", "&gt;", $fieldvalue);
     $fieldvalue = decode_html($fieldvalue);
     if (stristr($fieldvalue, "|##|") && empty($fieldType)) {
         $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue);
     } elseif ($fld_type == "date" && empty($fieldType)) {
         $fieldvalue = DateTimeField::convertToUserFormat($fieldvalue);
     } elseif ($fld_type == "datetime" && empty($fieldType)) {
         $date = new DateTimeField($fieldvalue);
         $fieldvalue = $date->getDisplayDateTimeValue();
     }
     // Added to render html tag for description fields
     if ($fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) {
         return $fieldvalue;
     }
     return htmlentities($fieldvalue, ENT_QUOTES, $default_charset);
 }
コード例 #7
0
 /**	Function used to get the Status history of the Purchase Order
  *	@param $id - purchaseorder id
  *	@return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are arrays which contains header values and all column values of all entries
  */
 function get_postatushistory($id)
 {
     $log = vglobal('log');
     $log->debug("Entering get_postatushistory(" . $id . ") method ...");
     $adb = PearDatabase::getInstance();
     global $mod_strings;
     global $app_strings;
     $query = 'select vtiger_postatushistory.*, vtiger_purchaseorder.purchaseorder_no from vtiger_postatushistory inner join vtiger_purchaseorder on vtiger_purchaseorder.purchaseorderid = vtiger_postatushistory.purchaseorderid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid where vtiger_crmentity.deleted = 0 and vtiger_purchaseorder.purchaseorderid = ?';
     $result = $adb->pquery($query, array($id));
     $noofrows = $adb->num_rows($result);
     $header[] = $app_strings['Order No'];
     $header[] = $app_strings['Vendor Name'];
     $header[] = $app_strings['LBL_AMOUNT'];
     $header[] = $app_strings['LBL_PO_STATUS'];
     $header[] = $app_strings['LBL_LAST_MODIFIED'];
     //Getting the field permission for the current user. 1 - Not Accessible, 0 - Accessible
     //Vendor, Total are mandatory fields. So no need to do security check to these fields.
     $current_user = vglobal('current_user');
     //If field is accessible then getFieldVisibilityPermission function will return 0 else return 1
     $postatus_access = getFieldVisibilityPermission('PurchaseOrder', $current_user->id, 'postatus') != '0' ? 1 : 0;
     $picklistarray = getAccessPickListValues('PurchaseOrder');
     $postatus_array = $postatus_access != 1 ? $picklistarray['postatus'] : array();
     //- ==> picklist field is not permitted in profile
     //Not Accessible - picklist is permitted in profile but picklist value is not permitted
     $error_msg = $postatus_access != 1 ? 'Not Accessible' : '-';
     while ($row = $adb->fetch_array($result)) {
         $entries = array();
         //Module Sequence Numbering
         //$entries[] = $row['purchaseorderid'];
         $entries[] = $row['purchaseorder_no'];
         // END
         $entries[] = $row['vendorname'];
         $entries[] = $row['total'];
         $entries[] = in_array($row['postatus'], $postatus_array) ? $row['postatus'] : $error_msg;
         $date = new DateTimeField($row['lastmodified']);
         $entries[] = $date->getDisplayDateTimeValue();
         $entries_list[] = $entries;
     }
     $return_data = array('header' => $header, 'entries' => $entries_list);
     $log->debug("Exiting get_postatushistory method ...");
     return $return_data;
 }
コード例 #8
0
$userName = getFullNameFromArray('Users', $current_user->column_fields);
$smarty_obj = new vtigerCRM_Smarty();
$header_array = getHeaderArray();
$smarty_obj->assign("HEADERS", $header_array);
$smarty_obj->assign("THEME", $theme);
$smarty_obj->assign("IMAGEPATH", $image_path);
$smarty_obj->assign("USER", $userName);
$qc_modules = getQuickCreateModules();
$smarty_obj->assign("QCMODULE", $qc_modules);
$smarty_obj->assign("APP", $app_strings);
$cnt = count($qc_modules);
$smarty_obj->assign("CNT", $cnt);
$smarty_obj->assign("PRINT_URL", "phprint.php?jt=" . session_id() . $GLOBALS['request_string']);
$smarty_obj->assign("MODULE_NAME", $currentModule);
$date = new DateTimeField(null);
$smarty_obj->assign("DATE", $date->getDisplayDateTimeValue());
$smarty_obj->assign("CURRENT_USER_MAIL", $current_user->email1);
$smarty_obj->assign("CURRENT_USER", $current_user->user_name);
$smarty_obj->assign("CURRENT_USER_ID", $current_user->id);
$smarty_obj->assign("MODULELISTS", $app_list_strings['moduleList']);
$smarty_obj->assign("CATEGORY", getParentTab());
$smarty_obj->assign("CALC", get_calc($image_path));
$smarty_obj->assign("MENUSTRUCTURE", getMenuStructure($currentModule));
$smarty_obj->assign("ANNOUNCEMENT", get_announcements());
$smarty_obj->assign("USE_ASTERISK", get_use_asterisk($current_user->id));
if (is_admin($current_user)) {
    $smarty_obj->assign("ADMIN_LINK", "<a href='index.php?module=Settings&action=index'>" . $app_strings['LBL_SETTINGS'] . "</a>");
}
$module_path = "modules/" . $currentModule . "/";
require_once 'include/Menu.php';
//Assign the entered global search string to a variable and display it again
コード例 #9
0
ファイル: CustomView.php プロジェクト: kikojover/corebos
    /** to get the Advanced filter for the given customview Id
     * @param $cvid :: Type Integer
     * @returns  $advfilterlist Array
     */
    function getAdvFilterByCvid($cvid)
    {
        global $adb, $log, $default_charset, $current_user, $currentModule, $mod_strings;
        $advft_criteria = array();
        $sql = 'SELECT * FROM vtiger_cvadvfilter_grouping WHERE cvid = ? ORDER BY groupid';
        $groupsresult = $adb->pquery($sql, array($cvid));
        $i = 1;
        $j = 0;
        while ($relcriteriagroup = $adb->fetch_array($groupsresult)) {
            $groupId = $relcriteriagroup["groupid"];
            $groupCondition = $relcriteriagroup["group_condition"];
            $ssql = 'select vtiger_cvadvfilter.* from vtiger_customview
						inner join vtiger_cvadvfilter on vtiger_cvadvfilter.cvid = vtiger_customview.cvid
						left join vtiger_cvadvfilter_grouping on vtiger_cvadvfilter.cvid = vtiger_cvadvfilter_grouping.cvid
								and vtiger_cvadvfilter.groupid = vtiger_cvadvfilter_grouping.groupid';
            $ssql .= " where vtiger_customview.cvid = ? AND vtiger_cvadvfilter.groupid = ? order by vtiger_cvadvfilter.columnindex";
            $result = $adb->pquery($ssql, array($cvid, $groupId));
            $noOfColumns = $adb->num_rows($result);
            if ($noOfColumns <= 0) {
                continue;
            }
            while ($relcriteriarow = $adb->fetch_array($result)) {
                $columnIndex = $relcriteriarow["columnindex"];
                $criteria = array();
                $criteria['columnname'] = html_entity_decode($relcriteriarow["columnname"], ENT_QUOTES, $default_charset);
                $criteria['comparator'] = $relcriteriarow["comparator"];
                $advfilterval = html_entity_decode($relcriteriarow["value"], ENT_QUOTES, $default_charset);
                $col = explode(":", $relcriteriarow["columnname"]);
                $uitype_value = getUItypeByFieldName($this->customviewmodule, $col[2]);
                if ($uitype_value == '15' || $uitype_value == '16' || $uitype_value == '33') {
                    if (!isValueInPicklist($advfilterval, $col[2])) {
                        $advfilterval = getTranslationKeyFromTranslatedValue($this->customviewmodule, $advfilterval);
                    }
                }
                $temp_val = explode(",", $relcriteriarow["value"]);
                if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') {
                    $val = array();
                    for ($x = 0; $x < count($temp_val); $x++) {
                        if ($col[4] == 'D') {
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayDate();
                        } elseif ($col[4] == 'DT') {
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayDateTimeValue();
                        } else {
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayTime();
                        }
                    }
                    $advfilterval = implode(",", $val);
                }
                if (($col[1] == 'smownerid' || $col[1] == 'smcreatorid' || $col[1] == 'modifiedby') && $advfilterval == 'current_user' && $_REQUEST['action'] != 'CustomView' && empty($_REQUEST['record'])) {
                    $advfilterval = trim($current_user->first_name . ' ' . $current_user->last_name);
                }
                $criteria['value'] = $advfilterval;
                $criteria['column_condition'] = $relcriteriarow["column_condition"];
                $advft_criteria[$i]['columns'][$j] = $criteria;
                $advft_criteria[$i]['condition'] = $groupCondition;
                $j++;
            }
            if (!empty($advft_criteria[$i]['columns'][$j - 1]['column_condition'])) {
                $advft_criteria[$i]['columns'][$j - 1]['column_condition'] = '';
            }
            $i++;
        }
        // Clear the condition (and/or) for last group, if any.
        if (!empty($advft_criteria[$i - 1]['condition'])) {
            $advft_criteria[$i - 1]['condition'] = '';
        }
        return $advft_criteria;
    }
コード例 #10
0
/**
 * this function processes the given result and returns the value :: for now we are getting the values for the
 * reference, owner fields, booleans and currency fields; other processing might be added later if required
 * @param array $result - the webservices result object
 * @param array $descObj - the webservices describe object
 * @return array $result - the processes webservices result object
 */
function vttooltip_processResult($result, $descObj)
{
    global $current_user;
    foreach ($descObj['fields'] as $field) {
        $name = $field['name'];
        $value = $result[0][$name];
        if ($field['type']['name'] == 'reference') {
            $name = $field['name'];
            if (!empty($value)) {
                $result[0][$name] = vtws_getName($value, $current_user);
            } else {
                $result[0][$name] = '';
            }
        } elseif ($field['type']['name'] == 'owner') {
            list($info, $id) = explode("x", $value);
            $result[0][$name] = getOwnerName($id);
        } elseif ($field['type']['name'] == 'boolean') {
            if ($result[0][$name] == 1) {
                $result[0][$name] = "on";
            } else {
                $result[0][$name] = "off";
            }
        } elseif ($field['type']['name'] == 'picklist') {
            $temp = '';
            foreach ($field['type']['picklistValues'] as $value) {
                if (strcmp($value['value'], $result[0][$name]) == 0) {
                    $temp = $value['value'];
                }
            }
            $result[0][$name] = $temp;
        } elseif ($field['type']['name'] == 'date') {
            $result[0][$name] = DateTimeField::convertToUserFormat($value);
        } elseif ($field['type']['name'] == 'datetime') {
            $date = new DateTimeField($value);
            $result[0][$name] = $date->getDisplayDateTimeValue();
        } elseif ($field['type']['name'] == 'time') {
            $date = new DateTimeField($value);
            $result[0][$name] = $date->getDisplayTime();
        } elseif ($field['type']['name'] == 'currency') {
            $currencyField = new CurrencyField($value);
            $result[0][$name] = $currencyField->getDisplayValueWithSymbol();
        }
    }
    return $result;
}
コード例 #11
0
ファイル: Faq.php プロジェクト: jaimeaga84/corebos
 /**     Function to get the list of comments for the given FAQ id
  *      @param  int  $faqid - FAQ id
  *      @return list $list - return the list of comments and comment informations as a html output where as these comments and comments informations will be formed in div tag.
  **/
 function getFAQComments($faqid)
 {
     global $log, $default_charset;
     $log->debug("Entering getFAQComments(" . $faqid . ") method ...");
     global $mod_strings;
     $sql = "select * from vtiger_faqcomments where faqid=?";
     $result = $this->db->pquery($sql, array($faqid));
     $noofrows = $this->db->num_rows($result);
     //In ajax save we should not add this div
     if ($_REQUEST['action'] != 'FaqAjax') {
         $list .= '<div id="comments_div" style="overflow: auto;height:200px;width:100%;">';
         $enddiv = '</div>';
     }
     for ($i = 0; $i < $noofrows; $i++) {
         $comment = $this->db->query_result($result, $i, 'comments');
         $date = new DateTimeField($this->db->query_result($result, $i, 'createdtime'));
         $createdtime = $date->getDisplayDateTimeValue();
         if ($comment != '') {
             //this div is to display the comment
             if ($_REQUEST['action'] == 'FaqAjax') {
                 $comment = htmlentities($comment, ENT_QUOTES, $default_charset);
             }
             $list .= '<div valign="top" style="width:99%;padding-top:10px;" class="dataField">' . make_clickable(nl2br($comment)) . '</div>';
             //this div is to display the created time
             $list .= '<div valign="top" style="width:99%;border-bottom:1px dotted #CCCCCC;padding-bottom:5px;" class="dataLabel"><font color=darkred>' . $mod_strings['Created Time'];
             $list .= ' : ' . $createdtime . '</font></div>';
         }
     }
     $list .= $enddiv;
     $log->debug("Exiting getFAQComments method ...");
     return $list;
 }
コード例 #12
0
ファイル: ModTracker_Basic.php プロジェクト: nvh3010/quancrm
	function getModifiedOn() {
		$changedOn = new DateTimeField($this->changedon);
		return $changedOn->getDisplayDateTimeValue();
	}
コード例 #13
0
ファイル: RelatedListView.php プロジェクト: kikojover/corebos
/** Function to get related list entries in detailed array format
 * @param $parentmodule -- parentmodulename:: Type string
 * @param $query -- query:: Type string
 * @param $id -- id:: Type string
 * @returns $return_data -- return data:: Type string array
 */
function getHistory($parentmodule, $query, $id)
{
    global $log;
    $log->debug("Entering getHistory(" . $parentmodule . "," . $query . "," . $id . ") method ...");
    $parentaction = vtlib_purify($_REQUEST['action']);
    global $theme;
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    global $adb;
    global $mod_strings;
    global $app_strings;
    //Appending the security parameter
    global $current_user;
    $rel_tab_id = getTabid("Calendar");
    global $current_user;
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $tab_id = getTabid('Calendar');
    if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) {
        $sec_parameter = getListViewSecurityParameter('Calendar');
        $query .= ' ' . $sec_parameter;
    }
    $query .= ' ' . "ORDER BY vtiger_activity.date_start DESC,vtiger_activity.time_start DESC";
    $result = $adb->query($query);
    $noofrows = $adb->num_rows($result);
    if ($noofrows == 0) {
        //There is no entries for history
    } else {
        //Form the header columns
        $header[] = $app_strings['LBL_TYPE'];
        $header[] = $app_strings['LBL_SUBJECT'];
        $header[] = $app_strings['LBL_RELATED_TO'];
        $header[] = $app_strings['LBL_START_DATE'] . " & " . $app_strings['LBL_TIME'];
        $header[] = $app_strings['LBL_END_DATE'] . " & " . $app_strings['LBL_TIME'];
        //$header[] = $app_strings['LBL_DESCRIPTION'];
        $header[] = $app_strings['LBL_STATUS'];
        $header[] = $app_strings['LBL_ASSIGNED_TO'];
        $i = 1;
        while ($row = $adb->fetch_array($result)) {
            $entries = array();
            if ($row['activitytype'] == 'Task') {
                $activitymode = 'Task';
                $icon = 'Tasks.gif';
                $status = $row['status'];
                $status = $app_strings[$status];
            } else {
                $activitymode = 'Events';
                $icon = 'Activities.gif';
                $status = $row['eventstatus'];
                $status = $app_strings[$status];
            }
            $typeofactivity = $row['activitytype'];
            $typeofactivity = getTranslatedString($typeofactivity, 'Calendar');
            $entries[] = $typeofactivity;
            $activity = '<a href="index.php?module=Calendar4You&action=EventDetailView&return_module=' . $parentmodule . '&return_action=DetailView&record=' . $row["activityid"] . '&activity_mode=' . $activitymode . '&return_id=' . vtlib_purify($_REQUEST['record']) . '&parenttab=' . vtlib_purify($_REQUEST['parenttab']) . '">' . $row['subject'] . '</a></td>';
            $entries[] = $activity;
            $parentname = getRelatedTo('Calendar', $result, $i - 1);
            $entries[] = $parentname;
            $date = new DateTimeField($row['date_start'] . ' ' . $row['time_start']);
            $entries[] = $date->getDisplayDateTimeValue();
            $date = new DateTimeField($row['due_date'] . ' ' . $row['time_end']);
            $entries[] = $date->getDisplayDate();
            $entries[] = $status;
            if ($row['user_name'] == null && $row['groupname'] != null) {
                $entries[] = $row['groupname'];
            } else {
                $entries[] = $row['user_name'];
            }
            $i++;
            $entries_list[] = $entries;
        }
        $return_data = array('header' => $header, 'entries' => $entries_list);
        $log->debug("Exiting getHistory method ...");
        return $return_data;
    }
}
コード例 #14
0
ファイル: Record.php プロジェクト: JeRRimix/YetiForceCRM
    /**
     * Function to get the list of advanced filter conditions for the current custom view
     * @return <Array> - All the advanced filter conditions for the custom view, grouped by the condition grouping
     */
    public function getAdvancedCriteria()
    {
        $db = PearDatabase::getInstance();
        $default_charset = vglobal('default_charset');
        $cvId = $this->getId();
        $advft_criteria = array();
        if (empty($cvId)) {
            return $advft_criteria;
        }
        $sql = 'SELECT * FROM vtiger_cvadvfilter_grouping WHERE cvid = ? ORDER BY groupid';
        $groupsresult = $db->pquery($sql, array($this->getId()));
        $i = 1;
        $j = 0;
        while ($relcriteriagroup = $db->fetch_array($groupsresult)) {
            $groupId = $relcriteriagroup["groupid"];
            $groupCondition = $relcriteriagroup["group_condition"];
            $ssql = 'select vtiger_cvadvfilter.* from vtiger_customview
						inner join vtiger_cvadvfilter on vtiger_cvadvfilter.cvid = vtiger_customview.cvid
						left join vtiger_cvadvfilter_grouping on vtiger_cvadvfilter.cvid = vtiger_cvadvfilter_grouping.cvid
								and vtiger_cvadvfilter.groupid = vtiger_cvadvfilter_grouping.groupid';
            $ssql .= " where vtiger_customview.cvid = ? AND vtiger_cvadvfilter.groupid = ? order by vtiger_cvadvfilter.columnindex";
            $result = $db->pquery($ssql, array($this->getId(), $groupId));
            $noOfColumns = $db->num_rows($result);
            if ($noOfColumns <= 0) {
                continue;
            }
            while ($relcriteriarow = $db->fetch_array($result)) {
                $criteria = array();
                $criteria['columnname'] = html_entity_decode($relcriteriarow["columnname"], ENT_QUOTES, $default_charset);
                $criteria['comparator'] = $relcriteriarow["comparator"];
                $advfilterval = html_entity_decode($relcriteriarow["value"], ENT_QUOTES, $default_charset);
                $col = explode(":", $relcriteriarow["columnname"]);
                $temp_val = explode(",", $relcriteriarow["value"]);
                if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') {
                    $val = array();
                    for ($x = 0; $x < count($temp_val); $x++) {
                        if ($col[4] == 'D') {
                            /** while inserting in db for due_date it was taking date and time values also as it is 
                             * date time field. We only need to take date from that value
                             */
                            if ($col[0] == 'vtiger_activity' && $col[1] == 'due_date') {
                                $originalValue = $temp_val[$x];
                                $dateTime = explode(' ', $originalValue);
                                $temp_val[$x] = $dateTime[0];
                            }
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayDate();
                        } elseif ($col[4] == 'DT') {
                            $comparator = array('e', 'n', 'b', 'a');
                            if (in_array($criteria['comparator'], $comparator)) {
                                $originalValue = $temp_val[$x];
                                $dateTime = explode(' ', $originalValue);
                                $temp_val[$x] = $dateTime[0];
                            }
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayDateTimeValue();
                        } else {
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayTime();
                        }
                    }
                    $advfilterval = implode(",", $val);
                }
                $criteria['value'] = Vtiger_Util_Helper::toSafeHTML(decode_html($advfilterval));
                $criteria['column_condition'] = $relcriteriarow["column_condition"];
                $groupId = $relcriteriarow['groupid'];
                $advft_criteria[$groupId]['columns'][$j] = $criteria;
                $advft_criteria[$groupId]['condition'] = $groupCondition;
                $j++;
            }
            if (!empty($advft_criteria[$groupId]['columns'][$j - 1]['column_condition'])) {
                $advft_criteria[$groupId]['columns'][$j - 1]['column_condition'] = '';
            }
            $i++;
        }
        // Clear the condition (and/or) for last group, if any.
        if (!empty($advft_criteria[$i - 1]['condition'])) {
            $advft_criteria[$i - 1]['condition'] = '';
        }
        return $advft_criteria;
    }
コード例 #15
0
ファイル: CustomView.php プロジェクト: rcrrich/YetiForceCRM
 function getAdvftCriteria($relcriteriarow)
 {
     $columnIndex = $relcriteriarow['columnindex'];
     $criteria = array();
     $criteria['columnname'] = html_entity_decode($relcriteriarow["columnname"], ENT_QUOTES, $default_charset);
     $criteria['comparator'] = $relcriteriarow["comparator"];
     $advfilterval = html_entity_decode($relcriteriarow["value"], ENT_QUOTES, $default_charset);
     $col = explode(":", $relcriteriarow["columnname"]);
     $temp_val = explode(",", $relcriteriarow["value"]);
     if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') {
         $val = array();
         for ($x = 0; $x < count($temp_val); $x++) {
             if ($col[4] == 'D') {
                 /** while inserting in db for due_date it was taking date and time values also as it is
                  * date time field. We only need to take date from that value
                  */
                 if ($col[0] == "vtiger_activity" && $col[1] == "due_date") {
                     $values = explode(' ', $temp_val[$x]);
                     $temp_val[$x] = $values[0];
                 }
                 $date = new DateTimeField(trim($temp_val[$x]));
                 $val[$x] = $date->getDisplayDate();
             } elseif ($col[4] == 'DT') {
                 $comparator = array('e', 'n', 'b', 'a');
                 if (in_array($criteria['comparator'], $comparator)) {
                     $originalValue = $temp_val[$x];
                     $dateTime = explode(' ', $originalValue);
                     $temp_val[$x] = $dateTime[0];
                 }
                 $date = new DateTimeField(trim($temp_val[$x]));
                 $val[$x] = $date->getDisplayDateTimeValue();
             } else {
                 $date = new DateTimeField(trim($temp_val[$x]));
                 $val[$x] = $date->getDisplayTime();
             }
         }
         $advfilterval = implode(",", $val);
     }
     $criteria['value'] = $advfilterval;
     $criteria['column_condition'] = $relcriteriarow["column_condition"];
     return $criteria;
 }
コード例 #16
0
ファイル: ListViewUtils.php プロジェクト: jaimeaga84/corebos
function getValue($field_result, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, $mode, $popuptype, $returnset = '', $viewid = '')
{
    global $log, $listview_max_textlength, $app_strings, $current_language, $currentModule;
    $log->debug("Entering getValue(" . $field_result . "," . $list_result . "," . $fieldname . "," . get_class($focus) . "," . $module . "," . $entity_id . "," . $list_result_count . "," . $mode . "," . $popuptype . "," . $returnset . "," . $viewid . ") method ...");
    global $adb, $current_user, $default_charset;
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    $tabname = getParentTab();
    $tabid = getTabid($module);
    $current_module_strings = return_module_language($current_language, $module);
    $uicolarr = $field_result[$fieldname];
    foreach ($uicolarr as $key => $value) {
        $uitype = $key;
        $colname = $value;
    }
    //added for getting event status in Custom view - Jaguar
    if ($module == 'Calendar' && ($colname == "status" || $colname == "eventstatus")) {
        $colname = "activitystatus";
    }
    //Ends
    $field_val = $adb->query_result($list_result, $list_result_count, $colname);
    if ($uitype != 8) {
        $temp_val = html_entity_decode($field_val, ENT_QUOTES, $default_charset);
    } else {
        $temp_val = $field_val;
    }
    // vtlib customization: New uitype to handle relation between modules
    if ($uitype == '10') {
        $parent_id = $field_val;
        if (!empty($parent_id)) {
            $parent_module = getSalesEntityType($parent_id);
            $valueTitle = $parent_module;
            if ($app_strings[$valueTitle]) {
                $valueTitle = $app_strings[$valueTitle];
            }
            $displayValueArray = getEntityName($parent_module, $parent_id);
            if (!empty($displayValueArray)) {
                foreach ($displayValueArray as $key => $value) {
                    $value = $value;
                }
            }
            $value = "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>" . textlength_check($value) . "</a>";
        } else {
            $value = '';
        }
    } else {
        if ($uitype == 53) {
            $value = $adb->query_result($list_result, $list_result_count, 'user_name');
            // When Assigned To field is used in Popup window
            if ($value == '') {
                $user_id = $adb->query_result($list_result, $list_result_count, 'smownerid');
                if ($user_id != null && $user_id != '') {
                    $value = getOwnerName($user_id);
                    $value = textlength_check($value);
                }
            }
        } elseif ($uitype == 52) {
            $value = getOwnerName($adb->query_result($list_result, $list_result_count, $colname));
            $value = textlength_check($value);
        } elseif ($uitype == 51) {
            //Accounts - Member Of
            $parentid = $adb->query_result($list_result, $list_result_count, "parentid");
            if ($module == 'Accounts') {
                $entity_name = textlength_check(getAccountName($parentid));
            } elseif ($module == 'Products') {
                $entity_name = textlength_check(getProductName($parentid));
            }
            $value = '<a href="index.php?module=' . $module . '&action=DetailView&record=' . $parentid . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $entity_name . '</a>';
        } elseif ($uitype == 77) {
            $value = getOwnerName($adb->query_result($list_result, $list_result_count, 'inventorymanager'));
            $value = textlength_check($value);
        } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) {
            $temp_val = trim($temp_val);
            $timeField = 'time_start';
            if ($fieldname == 'due_date') {
                $timeField = 'time_end';
            }
            if ($temp_val != '' && $module == 'Calendar' && ($uitype == 23 || $uitype == 6) && $timeField != '' && ($fieldname == 'date_start' || $fieldname == 'due_date')) {
                $time = $adb->query_result($list_result, $list_result_count, $timeField);
                if (empty($time)) {
                    $time = getSingleFieldValue('vtiger_activity', $timeField, 'activityid', $entity_id);
                }
            }
            if ($temp_val == '0000-00-00' || empty($temp_val)) {
                $value = '';
            } else {
                if (empty($time) && strpos($temp_val, ' ') == false) {
                    $value = DateTimeField::convertToUserFormat($temp_val);
                } else {
                    if (!empty($time)) {
                        $date = new DateTimeField($temp_val . ' ' . $time);
                        $value = $date->getDisplayDate();
                    } else {
                        $date = new DateTimeField($temp_val);
                        $value = $date->getDisplayDateTimeValue();
                    }
                }
            }
        } elseif ($uitype == 15 || $uitype == 55 && $fieldname == "salutationtype") {
            $temp_val = decode_html($adb->query_result($list_result, $list_result_count, $colname));
            if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $temp_val != '') {
                $temp_acttype = $adb->query_result($list_result, $list_result_count, 'activitytype');
                if ($temp_acttype != 'Task' && $fieldname == "taskstatus") {
                    $temptable = "eventstatus";
                } else {
                    $temptable = $fieldname;
                }
                $roleid = $current_user->roleid;
                $roleids = array();
                $subrole = getRoleSubordinates($roleid);
                if (count($subrole) > 0) {
                    $roleids = $subrole;
                }
                array_push($roleids, $roleid);
                //here we are checking wheather the table contains the sortorder column .If  sortorder is present in the main picklist table, then the role2picklist will be applicable for this table...
                $sql = "select * from vtiger_{$temptable} where {$temptable}=?";
                $res = $adb->pquery($sql, array(decode_html($temp_val)));
                $picklistvalueid = $adb->query_result($res, 0, 'picklist_valueid');
                if ($picklistvalueid != null) {
                    $pick_query = "select * from vtiger_role2picklist where picklistvalueid={$picklistvalueid} and roleid in (" . generateQuestionMarks($roleids) . ")";
                    $res_val = $adb->pquery($pick_query, array($roleids));
                    $num_val = $adb->num_rows($res_val);
                }
                if ($num_val > 0 || $temp_acttype == 'Task' && $fieldname == 'activitytype') {
                    $temp_val = $temp_val;
                } else {
                    $temp_val = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                }
            }
            $value = $current_module_strings[$temp_val] != '' ? $current_module_strings[$temp_val] : ($app_strings[$temp_val] != '' ? $app_strings[$temp_val] : $temp_val);
            if ($value != "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>") {
                $value = textlength_check($value);
            }
        } elseif ($uitype == 16) {
            $value = getTranslatedString($temp_val, $currentModule);
            $value = textlength_check($value);
        } elseif ($uitype == 71 || $uitype == 72) {
            if ($temp_val != '') {
                // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
                if ($uitype == 72) {
                    if ($fieldname == 'unit_price') {
                        $currency_id = getProductBaseCurrency($entity_id, $module);
                        $cursym_convrate = getCurrencySymbolandCRate($currency_id);
                        $currency_symbol = $cursym_convrate['symbol'];
                    } else {
                        $currency_info = getInventoryCurrencyInfo($module, $entity_id);
                        $currency_symbol = $currency_info['currency_symbol'];
                    }
                    $currencyValue = CurrencyField::convertToUserFormat($temp_val, null, true);
                    $value = CurrencyField::appendCurrencySymbol($currencyValue, $currency_symbol);
                } else {
                    //changes made to remove vtiger_currency symbol infront of each vtiger_potential amount
                    if ($temp_val != 0) {
                        $value = CurrencyField::convertToUserFormat($temp_val);
                    } else {
                        $value = $temp_val;
                    }
                }
            } else {
                $value = '';
            }
        } elseif ($uitype == 17) {
            $matchPattern = "^[\\w]+:\\/\\/^";
            preg_match($matchPattern, $field_val, $matches);
            if (!empty($matches[0])) {
                $value = '<a href="' . $field_val . '" target="_blank">' . textlength_check($temp_val) . '</a>';
            } else {
                $value = '<a href="http://' . $field_val . '" target="_blank">' . textlength_check($temp_val) . '</a>';
            }
        } elseif ($uitype == 13 || $uitype == 104 && ($_REQUEST['action'] != 'Popup' && $_REQUEST['file'] != 'Popup')) {
            if ($_SESSION['internal_mailer'] == 1) {
                //check added for email link in user detailview
                if ($module == 'Calendar') {
                    if (getActivityType($entity_id) == 'Task') {
                        $tabid = 9;
                    } else {
                        $tabid = 16;
                    }
                } else {
                    $tabid = getTabid($module);
                }
                $fieldid = getFieldid($tabid, $fieldname);
                if (empty($popuptype)) {
                    $value = '<a href="javascript:InternalMailer(' . $entity_id . ',' . $fieldid . ',\'' . $fieldname . '\',\'' . $module . '\',\'record_id\');">' . textlength_check($temp_val) . '</a>';
                } else {
                    $value = $temp_val;
                    $value = textlength_check($value);
                }
            } else {
                $value = '<a href="mailto:' . $field_val . '">' . textlength_check($temp_val) . '</a>';
            }
        } elseif ($uitype == 56) {
            if ($temp_val == 1) {
                $value = $app_strings['yes'];
            } elseif ($temp_val == 0) {
                $value = $app_strings['no'];
            } else {
                $value = '';
            }
        } elseif ($uitype == 57) {
            if ($temp_val != '') {
                $sql = "SELECT * FROM vtiger_contactdetails WHERE contactid=?";
                $result = $adb->pquery($sql, array($temp_val));
                $value = '';
                if ($adb->num_rows($result)) {
                    $name = getFullNameFromQResult($result, 0, "Contacts");
                    $value = '<a href=index.php?module=Contacts&action=DetailView&record=' . $temp_val . '>' . textlength_check($name) . '</a>';
                }
            } else {
                $value = '';
            }
        } elseif ($uitype == 58) {
            if ($temp_val != '') {
                $sql = "SELECT * FROM vtiger_campaign WHERE campaignid=?";
                $result = $adb->pquery($sql, array($temp_val));
                $campaignname = $adb->query_result($result, 0, "campaignname");
                $value = '<a href=index.php?module=Campaigns&action=DetailView&record=' . $temp_val . '>' . textlength_check($campaignname) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 59) {
            if ($temp_val != '') {
                $value = getProductName($temp_val);
            } else {
                $value = '';
            }
        } elseif ($uitype == 61) {
            $attachmentid = $adb->query_result($adb->pquery("SELECT * FROM vtiger_seattachmentsrel WHERE crmid = ?", array($entity_id)), 0, 'attachmentsid');
            $value = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $module . '&fileid=' . $attachmentid . '&filename=' . $temp_val . '">' . textlength_check($temp_val) . '</a>';
        } elseif ($uitype == 62) {
            $parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
            $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
            if ($parenttype == "Leads") {
                $tablename = "vtiger_leaddetails";
                $fieldname = "lastname";
                $idname = "leadid";
            }
            if ($parenttype == "Accounts") {
                $tablename = "vtiger_account";
                $fieldname = "accountname";
                $idname = "accountid";
            }
            if ($parenttype == "Products") {
                $tablename = "vtiger_products";
                $fieldname = "productname";
                $idname = "productid";
            }
            if ($parenttype == "HelpDesk") {
                $tablename = "vtiger_troubletickets";
                $fieldname = "title";
                $idname = "ticketid";
            }
            if ($parenttype == "Invoice") {
                $tablename = "vtiger_invoice";
                $fieldname = "subject";
                $idname = "invoiceid";
            }
            if ($parentid != '') {
                $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?";
                $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
                $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($fieldvalue) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 66) {
            $parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
            $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
            if ($parenttype == "Leads") {
                $tablename = "vtiger_leaddetails";
                $fieldname = "lastname";
                $idname = "leadid";
            }
            if ($parenttype == "Accounts") {
                $tablename = "vtiger_account";
                $fieldname = "accountname";
                $idname = "accountid";
            }
            if ($parenttype == "HelpDesk") {
                $tablename = "vtiger_troubletickets";
                $fieldname = "title";
                $idname = "ticketid";
            }
            if ($parentid != '') {
                $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?";
                $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
                $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($fieldvalue) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 67) {
            $parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
            $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
            if ($parenttype == "Leads") {
                $tablename = "vtiger_leaddetails";
                $fieldname = "lastname";
                $idname = "leadid";
            }
            if ($parenttype == "Contacts") {
                $tablename = "vtiger_contactdetails";
                $fieldname = "contactname";
                $idname = "contactid";
            }
            if ($parentid != '') {
                $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?";
                $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
                $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($fieldvalue) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 68) {
            $parentid = $adb->query_result($list_result, $list_result_count, "parent_id");
            $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type");
            if ($parenttype == '' && $parentid != '') {
                $parenttype = getSalesEntityType($parentid);
            }
            if ($parenttype == "Contacts") {
                $tablename = "vtiger_contactdetails";
                $fieldname = "contactname";
                $idname = "contactid";
            }
            if ($parenttype == "Accounts") {
                $tablename = "vtiger_account";
                $fieldname = "accountname";
                $idname = "accountid";
            }
            if ($parentid != '') {
                $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?";
                $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname);
                $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($fieldvalue) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 78) {
            if ($temp_val != '') {
                $quote_name = getQuoteName($temp_val);
                $value = '<a href=index.php?module=Quotes&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($quote_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 79) {
            if ($temp_val != '') {
                $purchaseorder_name = getPoName($temp_val);
                $value = '<a href=index.php?module=PurchaseOrder&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($purchaseorder_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 80) {
            if ($temp_val != '') {
                $salesorder_name = getSoName($temp_val);
                $value = "<a href=index.php?module=SalesOrder&action=DetailView&record={$temp_val}&parenttab=" . urlencode($tabname) . ">" . textlength_check($salesorder_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 75 || $uitype == 81) {
            if ($temp_val != '') {
                $vendor_name = getVendorName($temp_val);
                $value = '<a href=index.php?module=Vendors&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($vendor_name) . '</a>';
            } else {
                $value = '';
            }
        } elseif ($uitype == 98) {
            $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=Settings&roleid=' . $temp_val . '">' . textlength_check(getRoleName($temp_val)) . '</a>';
        } elseif ($uitype == 33) {
            $value = $temp_val != "" ? str_ireplace(' |##| ', ', ', $temp_val) : "";
            if (!$is_admin && $value != '') {
                $value = $field_val != "" ? str_ireplace(' |##| ', ', ', $field_val) : "";
                if ($value != '') {
                    $value_arr = explode(',', trim($value));
                    $roleid = $current_user->roleid;
                    $subrole = getRoleSubordinates($roleid);
                    if (count($subrole) > 0) {
                        $roleids = $subrole;
                        array_push($roleids, $roleid);
                    } else {
                        $roleids = $roleid;
                    }
                    if (count($roleids) > 0) {
                        $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where roleid in (" . generateQuestionMarks($roleids) . ") and picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc";
                        $params = array($roleids);
                    } else {
                        $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc";
                        $params = array();
                    }
                    $pickListResult = $adb->pquery($pick_query, $params);
                    $picklistval = array();
                    for ($i = 0; $i < $adb->num_rows($pickListResult); $i++) {
                        $picklistarr[] = $adb->query_result($pickListResult, $i, $fieldname);
                    }
                    $value_temp = array();
                    $string_temp = '';
                    $str_c = 0;
                    foreach ($value_arr as $ind => $val) {
                        $notaccess = '<font color="red">' . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                        if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $string_temp)) > $listview_max_textlength)) {
                            $value_temp1 = in_array(trim($val), $picklistarr) ? $val : $notaccess;
                            if ($str_c != 0) {
                                $string_temp .= ' , ';
                            }
                            $string_temp .= $value_temp1;
                            $str_c++;
                        } else {
                            $string_temp .= '...';
                        }
                    }
                    $value = $string_temp;
                }
            }
        } elseif ($uitype == 85) {
            $value = $temp_val != "" ? "<a href='skype:{$temp_val}?call'>{$temp_val}</a>" : "";
        } elseif ($uitype == 116) {
            $value = $temp_val != "" ? getCurrencyName($temp_val) : "";
        } elseif ($uitype == 117) {
            // NOTE: Without symbol the value could be used for filtering/lookup hence avoiding the translation
            $value = $temp_val != "" ? getCurrencyName($temp_val, false) : "";
        } elseif ($uitype == 26) {
            $sql = "select foldername from vtiger_attachmentsfolder where folderid = ?";
            $res = $adb->pquery($sql, array($temp_val));
            $foldername = $adb->query_result($res, 0, 'foldername');
            $value = $foldername;
        } elseif ($uitype == 11) {
            // Fix added for Trac Id: 6139
            if (get_use_asterisk($current_user->id)) {
                $value = "<a href='javascript:;' onclick='startCall(&quot;{$temp_val}&quot;, &quot;{$entity_id}&quot;)'>" . textlength_check($temp_val) . "</a>";
            } else {
                $value = $temp_val;
            }
        } elseif ($uitype == 25) {
            $contactid = $_REQUEST['record'];
            $emailid = $adb->query_result($list_result, $list_result_count, "activityid");
            $result = $adb->pquery("SELECT access_count FROM vtiger_email_track WHERE crmid=? AND mailid=?", array($contactid, $emailid));
            $value = $adb->query_result($result, 0, "access_count");
            if (!$value) {
                $value = 0;
            }
        } elseif ($uitype == 8) {
            if (!empty($temp_val)) {
                $temp_val = html_entity_decode($temp_val, ENT_QUOTES, $default_charset);
                $json = new Zend_Json();
                $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val)));
            }
        } else {
            if ($fieldname == $focus->list_link_field) {
                if ($mode == "search") {
                    if ($popuptype == "specific" || $popuptype == "toDospecific") {
                        // Added for get the first name of contact in Popup window
                        if ($colname == "lastname" && $module == 'Contacts') {
                            $temp_val = getFullNameFromQResult($list_result, $list_result_count, "Contacts");
                        }
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        //Added to avoid the error when select SO from Invoice through AjaxEdit
                        if ($module == 'SalesOrder') {
                            $count = counterValue();
                            $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '","' . $_REQUEST['form'] . '");\' id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                        } elseif ($module == 'Contacts') {
                            require_once 'modules/Contacts/Contacts.php';
                            $cntct_focus = new Contacts();
                            $cntct_focus->retrieve_entity_info($entity_id, "Contacts");
                            $slashes_temp_val = popup_from_html($temp_val);
                            $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                            //ADDED TO CHECK THE FIELD PERMISSIONS FOR
                            $xyz = array('mailingstreet', 'mailingcity', 'mailingzip', 'mailingpobox', 'mailingcountry', 'mailingstate', 'otherstreet', 'othercity', 'otherzip', 'otherpobox', 'othercountry', 'otherstate');
                            for ($i = 0; $i < 12; $i++) {
                                if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') {
                                    $cntct_focus->column_fields[$xyz[$i]] = $cntct_focus->column_fields[$xyz[$i]];
                                } else {
                                    $cntct_focus->column_fields[$xyz[$i]] = '';
                                }
                            }
                            // For ToDo creation the underlying form is not named as EditView
                            $form = !empty($_REQUEST['form']) ? $_REQUEST['form'] : '';
                            if (!empty($form)) {
                                $form = htmlspecialchars($form, ENT_QUOTES, $default_charset);
                            }
                            $count = counterValue();
                            $value = '<a href="javascript:void(0);" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcity']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercity']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcountry']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercountry']) . '","' . popup_decode_html($cntct_focus->column_fields['mailingpobox']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherpobox']) . '","' . $form . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                        } else {
                            if ($popuptype == 'toDospecific') {
                                $count = counterValue();
                                $value = '<a href="javascript:window.close();" onclick=\'set_return_toDospecific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                            } else {
                                $count = counterValue();
                                $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                            }
                        }
                    } elseif ($popuptype == "detailview") {
                        if ($colname == "lastname" && ($module == 'Contacts' || $module == 'Leads')) {
                            $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module);
                        }
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $focus->record_id = $_REQUEST['recordid'];
                        $popupMode = $_REQUEST['popupmode'];
                        $callBack = $_REQUEST['callback'];
                        if ($_REQUEST['return_module'] == "Calendar") {
                            $count = counterValue();
                            $value = '<a href="javascript:window.close();" id="calendarCont' . $entity_id . '" LANGUAGE=javascript onclick=\'add_data_to_relatedlist_incal("' . $entity_id . '","' . decode_html($slashes_temp_val) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                        } else {
                            $count = counterValue();
                            if (empty($callBack)) {
                                $value = '<a style="cursor:pointer;" onclick=\'add_data_to_relatedlist("' . $entity_id . '","' . $focus->record_id . '","' . $module . '","' . $popupMode . '");\'>' . textlength_check($temp_val) . '</a>';
                            } else {
                                $value = '<a style="cursor:pointer;" onclick=\'add_data_to_relatedlist("' . $entity_id . '","' . $focus->record_id . '","' . $module . '","' . $popupMode . '",' . $callBack . ');\'>' . textlength_check($temp_val) . '</a>';
                            }
                            if ($module === 'Documents' && $_REQUEST['return_module'] === 'Emails') {
                                $attachment = $adb->query_result($list_result, $list_result_count, 'filename');
                                $value .= "<input type='hidden' id='document_attachment_{$entity_id}' value='{$attachment}'>";
                            }
                        }
                    } elseif ($popuptype == "formname_specific") {
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $count = counterValue();
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_formname_specific("' . $_REQUEST['form'] . '", "' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                    } elseif ($popuptype == "inventory_prod") {
                        $row_id = $_REQUEST['curr_row'];
                        //To get all the tax types and values and pass it to product details
                        $tax_str = '';
                        $tax_details = getAllTaxes();
                        for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
                            $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ',';
                        }
                        $tax_str = trim($tax_str, ',');
                        $rate = $user_info['conv_rate'];
                        if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') {
                            $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price');
                            if ($_REQUEST['currencyid'] != null) {
                                $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id));
                                $unitprice = $prod_prices[$entity_id];
                            }
                        } else {
                            $unitprice = '';
                        }
                        $sub_products = '';
                        $sub_prod = '';
                        $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id));
                        for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) {
                            //$sub_prod=array();
                            $id = $adb->query_result($sub_prod_query, $i, "productid");
                            $str_sep = '';
                            if ($i > 0) {
                                $str_sep = ":";
                            }
                            $sub_products .= $str_sep . $id;
                            $sub_prod .= $str_sep . " - " . htmlspecialchars($adb->query_result($sub_prod_query, $i, "productname"), ENT_QUOTES, $default_charset);
                        }
                        $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod);
                        $qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock');
                        //fix for T6943
                        $slashes_temp_val = popup_from_html($field_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description'));
                        $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset));
                        $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc);
                        $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}");
                        require_once 'include/Zend/Json.php';
                        $prod_arr = Zend_Json::encode($tmp_arr);
                        $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $qty_stock . '","' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '");\' vt_prod_arr=\'' . $prod_arr . '\' >' . textlength_check($temp_val) . '</a>';
                    } elseif ($popuptype == "inventory_prod_po") {
                        $row_id = $_REQUEST['curr_row'];
                        //To get all the tax types and values and pass it to product details
                        $tax_str = '';
                        $tax_details = getAllTaxes();
                        for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
                            $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ',';
                        }
                        $tax_str = trim($tax_str, ',');
                        $rate = $user_info['conv_rate'];
                        if (getFieldVisibilityPermission($module, $current_user->id, 'unit_price') == '0') {
                            $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price');
                            if ($_REQUEST['currencyid'] != null) {
                                $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module);
                                $unitprice = $prod_prices[$entity_id];
                            }
                        } else {
                            $unitprice = '';
                        }
                        $sub_products = '';
                        $sub_prod = '';
                        $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id));
                        for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) {
                            //$sub_prod=array();
                            $id = $adb->query_result($sub_prod_query, $i, "productid");
                            $str_sep = '';
                            if ($i > 0) {
                                $str_sep = ":";
                            }
                            $sub_products .= $str_sep . $id;
                            $sub_prod .= $str_sep . " - {$id}." . $adb->query_result($sub_prod_query, $i, "productname");
                        }
                        $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod);
                        $slashes_temp_val = popup_from_html($field_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description'));
                        $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset));
                        $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc);
                        $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}");
                        require_once 'include/Zend/Json.php';
                        $prod_arr = Zend_Json::encode($tmp_arr);
                        $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory_po("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '"); \'  vt_prod_arr=\'' . $prod_arr . '\' >' . textlength_check($temp_val) . '</a>';
                    } elseif ($popuptype == "inventory_service") {
                        $row_id = $_REQUEST['curr_row'];
                        //To get all the tax types and values and pass it to product details
                        $tax_str = '';
                        $tax_details = getAllTaxes();
                        for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
                            $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ',';
                        }
                        $tax_str = trim($tax_str, ',');
                        $rate = $user_info['conv_rate'];
                        if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') {
                            $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price');
                            if ($_REQUEST['currencyid'] != null) {
                                $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module);
                                $unitprice = $prod_prices[$entity_id];
                            }
                        } else {
                            $unitprice = '';
                        }
                        $slashes_temp_val = popup_from_html($field_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description'));
                        $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset));
                        $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc);
                        $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}");
                        require_once 'include/Zend/Json.php';
                        $prod_arr = Zend_Json::encode($tmp_arr);
                        $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '");\'  vt_prod_arr=\'' . $prod_arr . '\' >' . textlength_check($temp_val) . '</a>';
                    } elseif ($popuptype == "inventory_pb") {
                        $prod_id = $_REQUEST['productid'];
                        $flname = $_REQUEST['fldname'];
                        $listprice = getListPrice($prod_id, $entity_id);
                        $temp_val = popup_from_html($temp_val);
                        $count = counterValue();
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_pb("' . $listprice . '", "' . $flname . '"); \'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                    } elseif ($popuptype == "specific_account_address") {
                        require_once 'modules/Accounts/Accounts.php';
                        $acct_focus = new Accounts();
                        $acct_focus->retrieve_entity_info($entity_id, "Accounts");
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state');
                        for ($i = 0; $i < 12; $i++) {
                            if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') {
                                $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]];
                            } else {
                                $acct_focus->column_fields[$xyz[$i]] = '';
                            }
                        }
                        $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street']));
                        $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street']));
                        $count = counterValue();
                        $value = '<a href="javascript:void(0);" onclick=\'set_return_shipbilladdress("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                    } elseif ($popuptype == "specific_contact_account_address") {
                        require_once 'modules/Accounts/Accounts.php';
                        $acct_focus = new Accounts();
                        $acct_focus->retrieve_entity_info($entity_id, "Accounts");
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street']));
                        $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street']));
                        $count = counterValue();
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                    } elseif ($popuptype == "specific_potential_account_address") {
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        // For B2C support, Potential was enabled to be linked to Contacts also.
                        // Hence we need case handling for it.
                        $relatedid = $adb->query_result($list_result, $list_result_count, "related_to");
                        $relatedentity = getSalesEntityType($relatedid);
                        if ($relatedentity == 'Accounts') {
                            require_once 'modules/Accounts/Accounts.php';
                            $acct_focus = new Accounts();
                            $acct_focus->retrieve_entity_info($relatedid, "Accounts");
                            $account_name = getAccountName($relatedid);
                            $slashes_account_name = popup_from_html($account_name);
                            $slashes_account_name = htmlspecialchars($slashes_account_name, ENT_QUOTES, $default_charset);
                            $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state');
                            for ($i = 0; $i < 12; $i++) {
                                if (getFieldVisibilityPermission('Accounts', $current_user->id, $xyz[$i]) == '0') {
                                    $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]];
                                } else {
                                    $acct_focus->column_fields[$xyz[$i]] = '';
                                }
                            }
                            $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street']));
                            $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street']));
                            $count = counterValue();
                            $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_account_name)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                        } else {
                            if ($relatedentity == 'Contacts') {
                                require_once 'modules/Contacts/Contacts.php';
                                $displayValueArray = getEntityName('Contacts', $relatedid);
                                if (!empty($displayValueArray)) {
                                    foreach ($displayValueArray as $key => $field_value) {
                                        $contact_name = $field_value;
                                    }
                                } else {
                                    $contact_name = '';
                                }
                                $slashes_contact_name = popup_from_html($contact_name);
                                $slashes_contact_name = htmlspecialchars($slashes_contact_name, ENT_QUOTES, $default_charset);
                                $count = counterValue();
                                $value = '<a href="javascript:window.close();" onclick=\'set_return_contact("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_contact_name)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                            } else {
                                $value = $temp_val;
                            }
                        }
                    } elseif ($popuptype == "set_return_emails") {
                        if (empty($_REQUEST['email_field'])) {
                            $sre_param = ', "default"';
                        } else {
                            $sre_param = ', "' . $_REQUEST['email_field'] . '"';
                        }
                        if ($module == 'Accounts') {
                            $name = $adb->query_result($list_result, $list_result_count, 'accountname');
                            $accid = $adb->query_result($list_result, $list_result_count, 'accountid');
                            if (CheckFieldPermission('email1', $module) == "true") {
                                $emailaddress = $adb->query_result($list_result, $list_result_count, "email1");
                                $email_check = 1;
                            } else {
                                $email_check = 0;
                            }
                            if ($emailaddress == '') {
                                if (CheckFieldPermission('email2', $module) == 'true') {
                                    $emailaddress2 = $adb->query_result($list_result, $list_result_count, "email2");
                                    $email_check = 2;
                                } else {
                                    if ($email_check == 1) {
                                        $email_check = 4;
                                    } else {
                                        $email_check = 3;
                                    }
                                }
                            }
                            $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
                            $queryres = $adb->pquery($querystr, array(getTabid($module)));
                            //Change this index 0 - to get the vtiger_fieldid based on email1 or email2
                            $fieldid = $adb->query_result($queryres, 0, 'fieldid');
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $count = counterValue();
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'id = ' . $count . '>' . textlength_check($name) . '</a>';
                        } elseif ($module == 'Vendors') {
                            $name = $adb->query_result($list_result, $list_result_count, 'vendorname');
                            $venid = $adb->query_result($list_result, $list_result_count, 'vendorid');
                            if (CheckFieldPermission('email', $module) == "true") {
                                $emailaddress = $adb->query_result($list_result, $list_result_count, "email");
                                $email_check = 1;
                            } else {
                                $email_check = 0;
                            }
                            $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
                            $queryres = $adb->pquery($querystr, array(getTabid($module)));
                            //Change this index 0 - to get the vtiger_fieldid based on email1 or email2
                            $fieldid = $adb->query_result($queryres, 0, 'fieldid');
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $count = counterValue();
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'id = ' . $count . '>' . textlength_check($name) . '</a>';
                        } elseif ($module == 'Contacts' || $module == 'Leads') {
                            $name = getFullNameFromQResult($list_result, $list_result_count, $module);
                            if (CheckFieldPermission('email', $module) == "true") {
                                $emailaddress = $adb->query_result($list_result, $list_result_count, "email");
                                $email_check = 1;
                            } else {
                                $email_check = 0;
                            }
                            if ($emailaddress == '') {
                                if (CheckFieldPermission('secondaryemail', $module) == 'true') {
                                    $emailaddress2 = $adb->query_result($list_result, $list_result_count, "secondaryemail");
                                    $email_check = 2;
                                } else {
                                    if ($email_check == 1) {
                                        $email_check = 4;
                                    } else {
                                        $email_check = 3;
                                    }
                                }
                            }
                            $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
                            $queryres = $adb->pquery($querystr, array(getTabid($module)));
                            //Change this index 0 - to get the vtiger_fieldid based on email or secondaryemail
                            $fieldid = $adb->query_result($queryres, 0, 'fieldid');
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $count = counterValue();
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'id = ' . $count . '>' . $name . '</a>';
                        } elseif ($module == 'Project') {
                            $name = $adb->query_result($list_result, $list_result_count, 'projectname');
                            $projid = $adb->query_result($list_result, $list_result_count, 'projectid');
                            if (CheckFieldPermission('email', $module) == "true") {
                                $emailaddress = $adb->query_result($list_result, $list_result_count, "email");
                                $email_check = 1;
                            } else {
                                $email_check = 0;
                            }
                            $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
                            $queryres = $adb->pquery($querystr, array(getTabid($module)));
                            //Change this index 0 - to get the vtiger_fieldid based on email1 or email2
                            $fieldid = $adb->query_result($queryres, 0, 'fieldid');
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'>' . textlength_check($name) . '</a>';
                        } elseif ($module == 'ProjectTask') {
                            $name = $adb->query_result($list_result, $list_result_count, 'projecttaskname');
                            $projid = $adb->query_result($list_result, $list_result_count, 'projecttaskid');
                            if (CheckFieldPermission('email', $module) == "true") {
                                $emailaddress = $adb->query_result($list_result, $list_result_count, "email");
                                $email_check = 1;
                            } else {
                                $email_check = 0;
                            }
                            $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
                            $queryres = $adb->pquery($querystr, array(getTabid($module)));
                            //Change this index 0 - to get the vtiger_fieldid based on email1 or email2
                            $fieldid = $adb->query_result($queryres, 0, 'fieldid');
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'>' . textlength_check($name) . '</a>';
                        } elseif ($module == 'Potentials') {
                            $name = $adb->query_result($list_result, $list_result_count, 'potentialname');
                            $potid = $adb->query_result($list_result, $list_result_count, 'potentialid');
                            if (CheckFieldPermission('email', $module) == "true") {
                                $emailaddress = $adb->query_result($list_result, $list_result_count, "email");
                                $email_check = 1;
                            } else {
                                $email_check = 0;
                            }
                            $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
                            $queryres = $adb->pquery($querystr, array(getTabid($module)));
                            //Change this index 0 - to get the vtiger_fieldid based on email1 or email2
                            $fieldid = $adb->query_result($queryres, 0, 'fieldid');
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'>' . textlength_check($name) . '</a>';
                        } elseif ($module == 'HelpDesk') {
                            $name = $adb->query_result($list_result, $list_result_count, 'title');
                            $potid = $adb->query_result($list_result, $list_result_count, 'ticketid');
                            if (CheckFieldPermission('email', $module) == "true") {
                                $emailaddress = $adb->query_result($list_result, $list_result_count, "email");
                                $email_check = 1;
                            } else {
                                $email_check = 0;
                            }
                            $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)";
                            $queryres = $adb->pquery($querystr, array(getTabid($module)));
                            //Change this index 0 - to get the vtiger_fieldid based on email1 or email2
                            $fieldid = $adb->query_result($queryres, 0, 'fieldid');
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'>' . textlength_check($name) . '</a>';
                        } else {
                            $name = getFullNameFromQResult($list_result, $list_result_count, $module);
                            $emailaddress = $adb->query_result($list_result, $list_result_count, "email1");
                            $slashes_name = popup_from_html($name);
                            $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset);
                            $email_check = 1;
                            $count = counterValue();
                            $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',-1,"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'id = ' . $count . '>' . textlength_check($name) . '</a>';
                        }
                    } elseif ($popuptype == "specific_vendor_address") {
                        require_once 'modules/Vendors/Vendors.php';
                        $acct_focus = new Vendors();
                        $acct_focus->retrieve_entity_info($entity_id, "Vendors");
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $xyz = array('street', 'city', 'postalcode', 'pobox', 'country', 'state');
                        for ($i = 0; $i < 6; $i++) {
                            if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') {
                                $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]];
                            } else {
                                $acct_focus->column_fields[$xyz[$i]] = '';
                            }
                        }
                        $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['street']));
                        $count = counterValue();
                        $value = '<a href="javascript:void(0);" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . popup_decode_html($acct_focus->column_fields['city']) . '", "' . popup_decode_html($acct_focus->column_fields['state']) . '", "' . popup_decode_html($acct_focus->column_fields['postalcode']) . '", "' . popup_decode_html($acct_focus->column_fields['country']) . '","' . popup_decode_html($acct_focus->column_fields['pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                    } elseif ($popuptype == "specific_campaign") {
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $count = counterValue();
                        $value = '<a href="javascript:window.close();" onclick=\'set_return_specific_campaign("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                    } else {
                        if ($colname == "lastname") {
                            $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module);
                        } elseif ($module == 'Users' && $fieldname == 'last_name') {
                            $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module);
                        }
                        $slashes_temp_val = popup_from_html($temp_val);
                        $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset);
                        $log->debug("Exiting getValue method ...");
                        if ($_REQUEST['maintab'] == 'Calendar') {
                            $count = counterValue();
                            $value = '<a href="javascript:window.close();" onclick=\'set_return_todo("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                        } else {
                            $value = '<a href="javascript:window.close();" onclick=\'set_return("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'';
                            if (empty($_REQUEST['forfield']) && $focus->popup_type != 'detailview') {
                                $count = counterValue();
                                $value .= " id='{$count}' ";
                            }
                            $value .= '>' . textlength_check($temp_val) . '</a>';
                        }
                    }
                } else {
                    if ($module == "Leads" && $colname == "lastname" || $module == "Contacts" && $colname == "lastname") {
                        $count = counterValue();
                        $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                    } elseif ($module == "Calendar") {
                        $actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype');
                        $actvity_type = $actvity_type != '' ? $actvity_type : $adb->query_result($list_result, $list_result_count, 'type');
                        if ($actvity_type == "Task") {
                            $count = counterValue();
                            $value = '<a href="index.php?action=EventDetailView&module=Calendar4You&record=' . $entity_id . '&activity_mode=Task&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                        } else {
                            $count = counterValue();
                            $value = '<a href="index.php?action=EventDetailView&module=Calendar4You&record=' . $entity_id . '&activity_mode=Events&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                        }
                    } elseif ($module == "Vendors") {
                        $count = counterValue();
                        $value = '<a href="index.php?action=DetailView&module=Vendors&record=' . $entity_id . '&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                    } elseif ($module == "PriceBooks") {
                        $count = counterValue();
                        $value = '<a href="index.php?action=DetailView&module=PriceBooks&record=' . $entity_id . '&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                    } elseif ($module == "SalesOrder") {
                        $count = counterValue();
                        $value = '<a href="index.php?action=DetailView&module=SalesOrder&record=' . $entity_id . '&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                    } elseif ($module == 'Emails') {
                        $value = $temp_val;
                    } elseif ($module == "Users" && $colname == "last_name") {
                        $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module);
                        $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . textlength_check($temp_val) . '</a>';
                    } else {
                        $count = counterValue();
                        $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>';
                    }
                }
            } elseif ($module == 'Calendar' && ($fieldname == 'time_start' || $fieldname == 'time_end')) {
                $dateField = 'date_start';
                if ($fieldname == 'time_end') {
                    $dateField = 'due_date';
                }
                $type = $adb->query_result($list_result, $list_result_count, 'activitytype');
                if (empty($type)) {
                    $type = $adb->query_result($list_result, $list_result_count, 'type');
                }
                if ($type == 'Task' && $fieldname == 'time_end') {
                    $value = '--';
                } else {
                    $date_val = $adb->query_result($list_result, $list_result_count, $dateField);
                    $date = new DateTimeField($date_val . ' ' . $temp_val);
                    $value = $date->getDisplayTime();
                    $value = textlength_check($value);
                }
            } else {
                $value = $temp_val;
                $value = textlength_check($value);
            }
        }
    }
    // Mike Crowe Mod --------------------------------------------------------Make right justified and vtiger_currency value
    if (in_array($uitype, array(71, 72, 7, 9, 90))) {
        $value = '<span align="right">' . $value . '</div>';
    }
    $log->debug("Exiting getValue method ...");
    return $value;
}
コード例 #17
0
ファイル: Calendar.php プロジェクト: noclav/UpdatePackages
 public function getEntityCount()
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $db = PearDatabase::getInstance();
     $startDate = DateTimeField::convertToDBTimeZone($this->get('start'));
     $startDate = strtotime($startDate->format('Y-m-d H:i:s'));
     $endDate = DateTimeField::convertToDBTimeZone($this->get('end'));
     $endDate = strtotime($endDate->format('Y-m-d H:i:s'));
     $data = $this->getQuery();
     $result = $db->pquery($data['query'], $data['params']);
     $return = [];
     while ($record = $db->fetch_array($result)) {
         $crmid = $record['activityid'];
         $activitytype = $record['activitytype'];
         $dateTimeFieldInstance = new DateTimeField($record['date_start'] . ' ' . $record['time_start']);
         $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser);
         $dateTimeComponents = explode(' ', $userDateTimeString);
         $dateComponent = $dateTimeComponents[0];
         $startDateFormated = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format'));
         $dateTimeFieldInstance = new DateTimeField($record['due_date'] . ' ' . $record['time_end']);
         $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser);
         $dateTimeComponents = explode(' ', $userDateTimeString);
         $dateComponent = $dateTimeComponents[0];
         $endDateFormated = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format'));
         $begin = new DateTime($startDateFormated);
         $end = new DateTime($endDateFormated);
         $end->modify('+1 day');
         $interval = DateInterval::createFromDateString('1 day');
         foreach (new DatePeriod($begin, $interval, $end) as $dt) {
             $date = strtotime($dt->format('Y-m-d'));
             if ($date >= $startDate && $date <= $endDate) {
                 $date = date('Y-m-d', $date);
                 $return[$date]['start'] = $date;
                 $return[$date]['date'] = $date;
                 $return[$date]['event'][$activitytype]['count'] += 1;
                 $return[$date]['event'][$activitytype]['className'] = '  fc-draggable calCol_' . $activitytype;
                 $return[$date]['event'][$activitytype]['label'] = vtranslate($activitytype, $this->getModuleName());
                 $return[$date]['type'] = 'widget';
             }
         }
     }
     return array_values($return);
 }
コード例 #18
0
    /** to get the Advanced filter for the given customview Id
     * @param $cvid :: Type Integer
     * @returns  $advfilterlist Array
     */
    function getAdvFilterByCvid($cvid)
    {
        global $adb, $log, $default_charset;
        $advft_criteria = array();
        $sql = 'SELECT * FROM vtiger_cvadvfilter_grouping WHERE cvid = ? ORDER BY groupid';
        $groupsresult = $adb->pquery($sql, array($cvid));
        $i = 1;
        $j = 0;
        while ($relcriteriagroup = $adb->fetch_array($groupsresult)) {
            $groupId = $relcriteriagroup["groupid"];
            $groupCondition = $relcriteriagroup["group_condition"];
            $ssql = 'select vtiger_cvadvfilter.* from vtiger_customview
						inner join vtiger_cvadvfilter on vtiger_cvadvfilter.cvid = vtiger_customview.cvid
						left join vtiger_cvadvfilter_grouping on vtiger_cvadvfilter.cvid = vtiger_cvadvfilter_grouping.cvid
								and vtiger_cvadvfilter.groupid = vtiger_cvadvfilter_grouping.groupid';
            $ssql .= " where vtiger_customview.cvid = ? AND vtiger_cvadvfilter.groupid = ? order by vtiger_cvadvfilter.columnindex";
            $result = $adb->pquery($ssql, array($cvid, $groupId));
            $noOfColumns = $adb->num_rows($result);
            if ($noOfColumns <= 0) {
                continue;
            }
            while ($relcriteriarow = $adb->fetch_array($result)) {
                $columnIndex = $relcriteriarow["columnindex"];
                $criteria = array();
                $criteria['columnname'] = html_entity_decode($relcriteriarow["columnname"], ENT_QUOTES, $default_charset);
                $criteria['comparator'] = $relcriteriarow["comparator"];
                $advfilterval = html_entity_decode($relcriteriarow["value"], ENT_QUOTES, $default_charset);
                $col = explode(":", $relcriteriarow["columnname"]);
                $temp_val = explode(",", $relcriteriarow["value"]);
                if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') {
                    $val = array();
                    for ($x = 0; $x < count($temp_val); $x++) {
                        if ($col[4] == 'D') {
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayDate();
                        } elseif ($col[4] == 'DT') {
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayDateTimeValue();
                        } else {
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayTime();
                        }
                    }
                    $advfilterval = implode(",", $val);
                }
                $criteria['value'] = $advfilterval;
                $criteria['column_condition'] = $relcriteriarow["column_condition"];
                $advft_criteria[$i]['columns'][$j] = $criteria;
                $advft_criteria[$i]['condition'] = $groupCondition;
                $j++;
            }
            if (!empty($advft_criteria[$i]['columns'][$j - 1]['column_condition'])) {
                $advft_criteria[$i]['columns'][$j - 1]['column_condition'] = '';
            }
            $i++;
        }
        // Clear the condition (and/or) for last group, if any.
        if (!empty($advft_criteria[$i - 1]['condition'])) {
            $advft_criteria[$i - 1]['condition'] = '';
        }
        return $advft_criteria;
    }
コード例 #19
0
ファイル: ReportUtils.php プロジェクト: nikdejan/YetiForceCRM
/**
 *
 * @global Users $current_user
 * @param ReportRun $report
 * @param Array $picklistArray
 * @param ADOFieldObject $dbField
 * @param Array $valueArray
 * @param String $fieldName
 * @return String
 */
function getReportFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName)
{
    global $current_user, $default_charset;
    $db = PearDatabase::getInstance();
    $value = $valueArray[$fieldName];
    $fld_type = $dbField->type;
    list($module, $fieldLabel) = explode('__', $dbField->name, 2);
    $fieldInfo = getFieldByReportLabel($module, $fieldLabel);
    $fieldType = null;
    $fieldvalue = $value;
    if (!empty($fieldInfo)) {
        $field = WebserviceField::fromArray($db, $fieldInfo);
        $fieldType = $field->getFieldDataType();
    }
    if ($fieldType == 'currency' && $value != '') {
        // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
        if ($field->getUIType() == '72') {
            $curid_value = explode("::", $value);
            $currency_id = $curid_value[0];
            $currency_value = $curid_value[1];
            $cur_sym_rate = getCurrencySymbolandCRate($currency_id);
            if ($value != '') {
                if ($dbField->name == 'Products_Unit_Price') {
                    // need to do this only for Products Unit Price
                    if ($currency_id != 1) {
                        $currency_value = (double) $cur_sym_rate['rate'] * (double) $currency_value;
                    }
                }
                $formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true);
                $fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']);
            }
        } else {
            $currencyField = new CurrencyField($value);
            $fieldvalue = $currencyField->getDisplayValue();
        }
    } elseif ($dbField->name == "PriceBooks_Currency") {
        if ($value != '') {
            $fieldvalue = getTranslatedCurrencyString($value);
        }
    } elseif (in_array($dbField->name, $report->ui101_fields) && !empty($value)) {
        $entityNames = getEntityName('Users', $value);
        $fieldvalue = $entityNames[$value];
    } elseif ($fieldType == 'date' && !empty($value)) {
        if ($module == 'Calendar' && $field->getFieldName() == 'due_date') {
            $endTime = $valueArray['calendar_end_time'];
            if (empty($endTime)) {
                $recordId = $valueArray['calendar_id'];
                $endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId);
            }
            $date = new DateTimeField($value . ' ' . $endTime);
            $fieldvalue = $date->getDisplayDate();
        } else {
            if (!($field->getUIType() == '5')) {
                $date = new DateTimeField($fieldvalue);
                $fieldvalue = $date->getDisplayDateTimeValue();
            }
        }
    } elseif ($fieldType == "datetime" && !empty($value)) {
        $date = new DateTimeField($value);
        $fieldvalue = $date->getDisplayDateTimeValue();
    } elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours') {
        if ($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") {
            $date = new DateTimeField($value);
            $fieldvalue = $date->getDisplayTime();
        } else {
            $userModel = Users_Privileges_Model::getCurrentUserModel();
            if ($userModel->get('hour_format') == '12') {
                $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value);
            }
            $fieldvalue = $value;
        }
    } elseif ($fieldType == "picklist" && !empty($value)) {
        if (is_array($picklistArray)) {
            if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) {
                $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE'];
            } else {
                $fieldvalue = getTranslatedString($value, $module);
            }
        } else {
            $fieldvalue = getTranslatedString($value, $module);
        }
    } elseif ($fieldType == "multipicklist" && !empty($value)) {
        if (is_array($picklistArray[1])) {
            $valueList = explode(' |##| ', $value);
            $translatedValueList = array();
            foreach ($valueList as $value) {
                if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) {
                    $translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE'];
                } else {
                    $translatedValueList[] = getTranslatedString($value, $module);
                }
            }
        }
        if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) {
            $fieldvalue = str_replace(' |##| ', ', ', $value);
        } else {
            implode(', ', $translatedValueList);
        }
    } elseif ($fieldType == 'double') {
        if ($current_user->truncate_trailing_zeros == true) {
            $fieldvalue = decimalFormat($fieldvalue);
        }
    } elseif ($fieldType == 'boolean') {
        if (strtolower($value) === 'yes' || strtolower($value) === 'on' || $value == 1) {
            $fieldvalue = vtranslate('LBL_YES');
        } else {
            $fieldvalue = vtranslate('LBL_NO');
        }
    } elseif ($field && $field->getUIType() == 117 && $value != '') {
        if ($value != '0') {
            $currencyList = Settings_Currency_Record_Model::getAll();
            $fieldvalue = $currencyList[$value]->getName() . ' (' . $currencyList[$value]->get('currency_symbol') . ')';
        } else {
            $fieldvalue = '-';
        }
    }
    if ('vtiger_crmentity' == $dbField->table && false != strpos($dbField->name, 'Share__with__users')) {
        if ($value) {
            $listId = explode(',', $value);
            $usersSqlFullName = getSqlForNameInDisplayFormat(['first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'], 'Users');
            $getListUserSql = "select {$usersSqlFullName} as uname from vtiger_users WHERE id IN (" . generateQuestionMarks($listId) . ') ';
            $getListUserResult = $db->pquery($getListUserSql, array($listId), TRUE);
            $fieldvalue = '';
            $finalList = array();
            $listUsers = $getListUserResult->GetAll();
            for ($i = 0; $i < count($listUsers); $i++) {
                $finalList[] = $listUsers[$i][0];
            }
            $fieldvalue = implode(', ', $finalList);
        }
    }
    if ($fieldvalue == "") {
        return "-";
    }
    $fieldvalue = str_replace("<", "&lt;", $fieldvalue);
    $fieldvalue = str_replace(">", "&gt;", $fieldvalue);
    $fieldvalue = decode_html($fieldvalue);
    if (stristr($fieldvalue, "|##|") && empty($fieldType)) {
        $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue);
    } elseif ($fld_type == "date" && empty($fieldType)) {
        $fieldvalue = DateTimeField::convertToUserFormat($fieldvalue);
    } elseif ($fld_type == "datetime" && empty($fieldType)) {
        $date = new DateTimeField($fieldvalue);
        $fieldvalue = $date->getDisplayDateTimeValue();
    }
    // Added to render html tag for description fields
    if ($fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) {
        return $fieldvalue;
    }
    return htmlentities($fieldvalue, ENT_QUOTES, $default_charset);
}
コード例 #20
0
ファイル: HelpDesk.php プロジェクト: kikojover/corebos
 /** Function to get the list of comments for the given ticket id
  * @param  int  $ticketid - Ticket id
  * @return list $list - return the list of comments and comment informations as a html output where as these comments and comments informations will be formed in div tag.
  **/
 function getCommentInformation($ticketid)
 {
     global $log;
     $log->debug("Entering getCommentInformation(" . $ticketid . ") method ...");
     global $adb;
     global $mod_strings, $default_charset;
     $sql = "select * from vtiger_ticketcomments where ticketid=?";
     $result = $adb->pquery($sql, array($ticketid));
     $noofrows = $adb->num_rows($result);
     //In ajax save we should not add this div
     if ($_REQUEST['action'] != 'HelpDeskAjax') {
         $list .= '<div id="comments_div" style="overflow: auto;height:200px;width:100%;">';
         $enddiv = '</div>';
     }
     for ($i = 0; $i < $noofrows; $i++) {
         if ($adb->query_result($result, $i, 'comments') != '') {
             //this div is to display the comment
             $comment = $adb->query_result($result, $i, 'comments');
             // Asha: Fix for ticket #4478 . Need to escape html tags during ajax save.
             if ($_REQUEST['action'] == 'HelpDeskAjax') {
                 $comment = htmlentities($comment, ENT_QUOTES, $default_charset);
             }
             $list .= '<div valign="top" style="width:99%;padding-top:10px;" class="dataField">';
             $list .= make_clickable(nl2br($comment));
             $list .= '</div>';
             //this div is to display the author and time
             $list .= '<div valign="top" style="width:99%;border-bottom:1px dotted #CCCCCC;padding-bottom:5px;" class="dataLabel"><font color=darkred>';
             $list .= $mod_strings['LBL_AUTHOR'] . ' : ';
             if ($adb->query_result($result, $i, 'ownertype') == 'user') {
                 $list .= getUserFullName($adb->query_result($result, $i, 'ownerid'));
             } elseif ($adb->query_result($result, $i, 'ownertype') == 'customer') {
                 $contactid = $adb->query_result($result, $i, 'ownerid');
                 $displayValueArray = getEntityName('Contacts', $contactid);
                 if (!empty($displayValueArray)) {
                     foreach ($displayValueArray as $key => $field_value) {
                         $contact_name = $field_value;
                     }
                 } else {
                     $contact_name = '';
                 }
                 $list .= $contact_name;
             }
             $date = new DateTimeField($adb->query_result($result, $i, 'createdtime'));
             $list .= ' on ' . $date->getDisplayDateTimeValue() . ' &nbsp;';
             $list .= '</font></div>';
         }
     }
     $list .= $enddiv;
     $log->debug("Exiting getCommentInformation method ...");
     return $list;
 }
コード例 #21
0
 if ($parent_type != '') {
     $parent_content = getParentInfo($parent_type) . "\n";
 } else {
     $parent_content = "";
 }
 //code included for recurring events by jaguar starts
 $recur_id = $result_set['recurringid'];
 $current_date = date('Y-m-d');
 if ($recur_id == 0) {
     $date_start = $result_set['date_start'];
 } else {
     $date_start = $result_set['recurringdate'];
 }
 //code included for recurring events by jaguar ends
 $date = new DateTimeField("{$date_start} {$time_start}");
 $activity_time = strtotime($date->getDisplayDateTimeValue()) / 60;
 if ($activity_time - $curr_time > 0 && $activity_time - $curr_time <= $reminder_time) {
     $log->debug(" InSide  REMINDER");
     $query_user = "******";
     $user_result = $adb->pquery($query_user, array($activity_id));
     if ($adb->num_rows($user_result) >= 1) {
         while ($user_result_row = $adb->fetch_array($user_result)) {
             if ($user_result_row['email1'] != '' || $user_result_row['email1'] != NULL) {
                 $to_addr[] = $user_result_row['email1'];
             }
         }
     }
     // Retriving the Subject and message from reminder table
     $sql = "select active,notificationsubject,notificationbody from vtiger_notificationscheduler where schedulednotificationid=8";
     $result_main = $adb->pquery($sql, array());
     $subject = $app_strings['Reminder'] . $result_set['activitytype'] . " @ " . $result_set['date_start'] . " " . $result_set['time_start'] . "] (" . DateTimeField::getDBTimeZone() . ")" . $adb->query_result($result_main, 0, 'notificationsubject');
コード例 #22
0
 private function convertRecordToNativeFormat($module, $record)
 {
     if ($module == 'Events') {
         $record['start_time'] = $record['date_start'] . " " . $record['time_start'];
         $record['end_time'] = $record['due_date'] . " " . $record['time_end'];
     } else {
         if ($module == 'Calendar') {
             $dformat = "Y-m-d H:i:s";
             $record['start_time'] = date($dformat, strtotime($record['date_start']));
             $record['end_time'] = date($dformat, strtotime($record['due_date']));
             // convert the start time and end time to user time zone as outlook does not take the datetime in utc
             $oldDateFormat = $this->user->date_format;
             $this->user->date_format = 'yyyy-mm-dd';
             $dateTimeField = new DateTimeField($record['start_time']);
             $record['start_time'] = $dateTimeField->getDisplayDateTimeValue($this->user);
             $dateTimeField = new DateTimeField($record['end_time']);
             $record['end_time'] = $dateTimeField->getDisplayDateTimeValue($this->user);
             $this->user->date_format = $oldDateFormat;
         }
     }
     return $record;
 }
コード例 #23
0
ファイル: Cron.php プロジェクト: Bergdahls/YetiForceCRM
 /**
  *
  * get the last start datetime field
  */
 function getLastStartDateTime()
 {
     if ($this->data['laststart'] != NULL) {
         $lastStartDateTime = new DateTimeField(date('Y-m-d H:i:s', $this->data['laststart']));
         return $lastStartDateTime->getDisplayDateTimeValue();
     } else {
         return '';
     }
 }
コード例 #24
0
ファイル: Datetime.php プロジェクト: rcrrich/UpdatePackages
 /**
  * Function to get Date and Time value for Display
  * @param <type> $date
  * @return <String>
  */
 public static function getDisplayDateTimeValue($date)
 {
     $date = new DateTimeField($date);
     return $date->getDisplayDateTimeValue();
 }
コード例 #25
0
ファイル: CalendarCommon.php プロジェクト: kduqi/corebos
/**
 * Function to get the vtiger_activity details for mail body
 * @param   string   $description       - activity description
 * @param   string   $from              - to differenciate from notification to invitation.
 * return   string   $list              - HTML in string format
 */
function getActivityDetails($description, $user_id, $from = '')
{
    global $log, $current_user, $current_language, $adb;
    require_once 'include/utils/utils.php';
    $mod_strings = return_module_language($current_language, 'Calendar');
    $log->debug("Entering getActivityDetails(" . $description . ") method ...");
    $updated = $mod_strings['LBL_UPDATED'];
    $created = $mod_strings['LBL_CREATED'];
    $reply = $description['mode'] == 'edit' ? "{$updated}" : "{$created}";
    if ($description['activity_mode'] == "Events") {
        $end_date_lable = $mod_strings['End date and time'];
    } else {
        $end_date_lable = $mod_strings['Due Date'];
    }
    $name = getUserFullName($user_id);
    $inviteuser = new Users();
    $inviteuser->retrieveCurrentUserInfoFromFile($user_id);
    $stdatetime = new DateTimeField($description['st_date_time']);
    $etdatetime = new DateTimeField($description['end_date_time']);
    if ($from == "invite") {
        $msg = getTranslatedString($mod_strings['LBL_ACTIVITY_INVITATION']);
    } else {
        $msg = getTranslatedString($mod_strings['LBL_ACTIVITY_NOTIFICATION']);
    }
    $current_username = getUserFullName($current_user->id);
    $status = getTranslatedString($description['status'], 'Calendar');
    $list = $name . ',';
    $list .= '<br><br>' . $msg . ' ' . $reply . '.<br> ' . $mod_strings['LBL_DETAILS_STRING'] . ':<br>';
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["LBL_SUBJECT"] . ' : ' . $description['subject'];
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["Start date and time"] . ' : ' . $stdatetime->getDisplayDateTimeValue($inviteuser) . ' ' . $inviteuser->column_fields['time_zone'];
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $end_date_lable . ' : ' . $etdatetime->getDisplayDateTimeValue($inviteuser) . ' ' . $inviteuser->column_fields['time_zone'];
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["LBL_STATUS"] . ': ' . $status;
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["Priority"] . ': ' . getTranslatedString($description['taskpriority']);
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["Related To"] . ': ' . getTranslatedString($description['relatedto']);
    if (!empty($description['contact_name'])) {
        $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["LBL_CONTACT_LIST"] . ' ' . $description['contact_name'];
    } else {
        $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["Location"] . ' : ' . $description['location'];
    }
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["LBL_APP_DESCRIPTION"] . ': ' . $description['description'];
    $list .= '<br><br>' . $mod_strings["LBL_REGARDS_STRING"] . ' ,';
    $list .= '<br>' . $current_username . '.';
    $log->debug("Exiting getActivityDetails method ...");
    return $list;
}
コード例 #26
0
ファイル: PDFContent.php プロジェクト: jmangarret/vtigercrm
 private function x0b()
 {
     global $x15d, $x15e, $x15f, $x160, $x161, $x162, $x163, $x164, $x165, $x166, $x167, $x168, $x169, $x16a, $x16b, $x16c, $x16d, $x16e, $x16f, $x170, $x171, $x172, $x173, $x174, $x175, $x176, $x177, $x178;
     $x2b = "vtiger_current_version";
     $x2c = vglobal($x2b);
     $x40 = "_fieldinfo_cache";
     $x3d = "SELECT fieldid, relmodule FROM vtiger_fieldmodulerel";
     $x3e = self::$x0f->query($x3d);
     $x41 = array();
     while ($x42 = self::$x0f->fetchByAssoc($x3e)) {
         $x41[$x42["fieldid"]][] = $x42["relmodule"];
     }
     $x3d = "SELECT fieldid, fieldname, uitype, columnname\n\n              FROM vtiger_field\r\n              WHERE tabid=" . getTabId(self::$x0c) . " AND (displaytype != 3 OR fieldid = 64)";
     $x3e = self::$x0f->query($x3d);
     $x43 = self::$x0f->num_rows($x3e);
     if ($x43 > 0) {
         $x44 = array();
         $x45 = $x16a(getTabId("Tac4you"));
         if ($x45 == true) {
             $x46 = "SELECT tac4you_module FROM vtiger_tac4you_module WHERE presence = 1";
             $x47 = self::$x0f->query($x46);
             while ($x48 = self::$x0f->fetchByAssoc($x47)) {
                 $x44[$x48["tac4you_module"]] = $x48["tac4you_module"];
             }
         }
         $x49 = array();
         $x4a = $x16a(getTabId("Descriptions4you"));
         if ($x4a == true) {
             $x4b = "SELECT b.name FROM vtiger_links AS a\r\n                         INNER JOIN vtiger_tab AS b USING (tabid)\n\n                         WHERE linktype = 'DETAILVIEWWIDGET'\r\n                            AND linkurl = 'block://ModDescriptions4you:modules/Descriptions4you/ModDescriptions4you.php'";
             $x4c = self::$x0f->query($x4b);
             while ($x4d = self::$x0f->fetchByAssoc($x4c)) {
                 $x49[$x4d["name"]] = $x4d["name"];
             }
         }
         while ($x42 = self::$x0f->fetch_array($x3e)) {
             $x4e = "";
             $x4f = $x42["columnname"];
             $x50 = self::$x0e->column_fields[$x42["fieldname"]];
             switch ($x42["uitype"]) {
                 case "51":
                     $x4e = "Accounts";
                     break;
                 case "57":
                     $x4e = "Contacts";
                     break;
                 case "58":
                     $x4e = "Campaigns";
                     break;
                 case "59":
                     $x4e = "Products";
                     break;
                 case "73":
                     $x4e = "Accounts";
                     break;
                 case "75":
                     $x4e = "Vendors";
                     break;
                 case "81":
                     $x4e = "Vendors";
                     break;
                 case "76":
                     $x4e = "Potentials";
                     break;
                 case "78":
                     $x4e = "Quotes";
                     break;
                 case "80":
                     $x4e = "SalesOrder";
                     break;
                 case "68":
                 case "10":
                     $x4e = getSalesEntityType($x50);
                     break;
             }
             if ($x4e != "") {
                 $x51 = getTabId($x4e);
                 $x52 =& VTCacheUtils::${$x40};
                 unset($x52[$x51]);
                 $x53 = CRMEntity::getInstance($x4e);
                 if ($x50 != "" && $x50 != "0") {
                     $x54 = self::$x0f->query("SELECT deleted FROM vtiger_crmentity WHERE crmid='" . $x50 . "' AND deleted=0");
                     if (self::$x0f->num_rows($x54) > 0) {
                         $x53->retrieve_entity_info($x50, $x4e);
                         $x53->id = $x50;
                     }
                 }
                 self::$x21["\$" . "R_" . $x175($x4e) . "_CRMID\$"] = $x53->id;
                 self::$x21["\$" . "R_" . $x175($x4f) . "_CRMID\$"] = $x53->id;
                 if ($x2c == '5.2.1') {
                     $x36 = getDisplayDate($x53->column_fields['createdtime']);
                     $x37 = getDisplayDate($x53->column_fields['modifiedtime']);
                 } else {
                     $x38 = new DateTimeField($x53->column_fields['createdtime']);
                     $x36 = $x38->getDisplayDateTimeValue();
                     $x39 = new DateTimeField($x53->column_fields['modifiedtime']);
                     $x37 = $x39->getDisplayDateTimeValue();
                 }
                 self::$x21["\$" . "R_" . $x175($x4e) . "_CREATEDTIME_DATETIME\$"] = $x36;
                 self::$x21["\$" . "R_" . $x175($x4f) . "_CREATEDTIME_DATETIME\$"] = $x36;
                 self::$x21["\$" . "R_" . $x175($x4e) . "_MODIFIEDTIME_DATETIME\$"] = $x37;
                 self::$x21["\$" . "R_" . $x175($x4f) . "_MODIFIEDTIME_DATETIME\$"] = $x37;
                 if (isset($x4e)) {
                     $x55 = "";
                     switch ($x4e) {
                         case "Contacts":
                             $x55 = $this->x1b($x53->id);
                             break;
                         case "Products":
                             $x55 = $this->x1d($x53->id);
                             break;
                     }
                     self::$x21['$x56' . $x175($x4e) . '_IMAGENAME$'] = $x55;
                     self::$x21['$x56' . $x175($x4f) . '_IMAGENAME$'] = $x55;
                 }
                 if (isset($x44[$x4e])) {
                     $x46 = "SELECT text FROM vtiger_tac4you_texts WHERE id=?";
                     $x47 = self::$x0f->pquery($x46, array($x53->id));
                     $x57 = self::$x0f->query_result($x47, 0, "text");
                     $x57 = $x165($x57, ENT_QUOTES, self::$x11);
                     self::$x21["\$" . "R_" . $x175($x4e) . "_TAC4YOU\$"] = $x57;
                     self::$x21["\$" . "R_" . $x175($x4f) . "_TAC4YOU\$"] = $x57;
                 }
                 if (isset($x49[$x4e])) {
                     $x4b = "SELECT text FROM vtiger_descriptions4you_texts WHERE id=?";
                     $x4c = self::$x0f->pquery($x4b, array($x53->id));
                     $x58 = self::$x0f->query_result($x4c, 0, "text");
                     $x58 = $x165($x58, ENT_QUOTES, self::$x11);
                     self::$x21["\$" . "R_" . $x175($x4e) . "_DESC4YOU\$"] = $x58;
                     self::$x21["\$" . "R_" . $x175($x4f) . "_DESC4YOU\$"] = $x58;
                 }
                 if (isset($x59[$x4e])) {
                     $x5a = $this->x2d($x53->id);
                     $x5a = $x165($x5a, ENT_QUOTES, self::$x11);
                     self::$x21["\$" . "R_" . $x175($x4f) . "_MODCOMMENTS\$"] = $x5a;
                 }
                 $this->x15();
                 $this->x10($x4e, $x53, true);
                 $this->x10($x4e, $x53, $x4f);
                 $this->x2f($x4e, $x53, $x4f);
                 unset($x53);
             }
             if ($x42["uitype"] == "68") {
                 $x41[$x42["fieldid"]][] = "Contacts";
                 $x41[$x42["fieldid"]][] = "Accounts";
             }
             if (isset($x41[$x42["fieldid"]])) {
                 foreach ($x41[$x42["fieldid"]] as $x5b => $x5c) {
                     if ($x5c == $x4e) {
                         continue;
                     }
                     $x5d = getTabId($x5c);
                     $x52 =& VTCacheUtils::${$x40};
                     unset($x52[$x5d]);
                     if ($x164("modules/" . $x5c . "/" . $x5c . ".php")) {
                         $x5e = CRMEntity::getInstance($x5c);
                         self::$x21["\$" . "R_" . $x175($x5c) . "_CRMID\$"] = $x5e->id;
                         self::$x21["\$" . "R_" . $x175($x4f) . "_CRMID\$"] = $x5e->id;
                         if ($x2c == '5.2.1') {
                             $x36 = getDisplayDate($x5e->column_fields['createdtime']);
                             $x37 = getDisplayDate($x5e->column_fields['modifiedtime']);
                         } else {
                             $x38 = new DateTimeField($x5e->column_fields['createdtime']);
                             $x36 = $x38->getDisplayDateTimeValue();
                             $x39 = new DateTimeField($x5e->column_fields['modifiedtime']);
                             $x37 = $x39->getDisplayDateTimeValue();
                         }
                         self::$x21["\$" . "R_" . $x175($x5c) . "_CREATEDTIME_DATETIME\$"] = $x36;
                         self::$x21["\$" . "R_" . $x175($x4f) . "_CREATEDTIME_DATETIME\$"] = $x36;
                         self::$x21["\$" . "R_" . $x175($x5c) . "_MODIFIEDTIME_DATETIME\$"] = $x37;
                         self::$x21["\$" . "R_" . $x175($x4f) . "_MODIFIEDTIME_DATETIME\$"] = $x37;
                         $this->x10($x5c, $x5e, true);
                         $this->x10($x5c, $x5e, $x4f);
                         $this->x2f($x5c, $x5e, $x4f);
                         unset($x5e);
                     }
                 }
             }
         }
     }
 }
コード例 #27
0
ファイル: Message.php プロジェクト: casati-dolibarr/corebos
 /**
  * Gets the Mail Date
  * @param Boolean $format
  * @return Date
  */
 function date($format = false)
 {
     $date = $this->_date;
     if ($format) {
         if (preg_match(sprintf("/%s ([^ ]+)/", date('D, d M Y')), $date, $m)) {
             $date = $m[1];
             // Pick only time part for today
         } else {
             if (preg_match("/[a-zA-Z]{3}, ([0-9]{1,2} [a-zA-Z]{3} [0-9]{4})/", $date, $m)) {
                 $date = $m[1];
                 // Pick only date part
             }
         }
         $userDate = str_replace('--', '', getValidDisplayDate($date));
         return $userDate;
     } else {
         $dateWithTime = new DateTimeField(date('Y-m-d H:i:s', $date));
         $userDateTime = $dateWithTime->getDisplayDateTimeValue();
         return $userDateTime;
     }
 }
コード例 #28
0
ファイル: Quotes.php プロジェクト: nouphet/vtigercrm-6.0.0-ja
 /**	Function used to get the Quote Stage history of the Quotes
  *	@param $id - quote id
  *	@return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are arrays which contains header values and all column values of all entries
  */
 function get_quotestagehistory($id)
 {
     global $log;
     $log->debug("Entering get_quotestagehistory(" . $id . ") method ...");
     global $adb;
     global $mod_strings;
     global $app_strings;
     $query = 'select vtiger_quotestagehistory.*, vtiger_quotes.quote_no from vtiger_quotestagehistory inner join vtiger_quotes on vtiger_quotes.quoteid = vtiger_quotestagehistory.quoteid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_quotes.quoteid where vtiger_crmentity.deleted = 0 and vtiger_quotes.quoteid = ?';
     $result = $adb->pquery($query, array($id));
     $noofrows = $adb->num_rows($result);
     $header[] = $app_strings['Quote No'];
     $header[] = $app_strings['LBL_ACCOUNT_NAME'];
     $header[] = $app_strings['LBL_AMOUNT'];
     $header[] = $app_strings['Quote Stage'];
     $header[] = $app_strings['LBL_LAST_MODIFIED'];
     //Getting the field permission for the current user. 1 - Not Accessible, 0 - Accessible
     //Account Name , Total are mandatory fields. So no need to do security check to these fields.
     global $current_user;
     //If field is accessible then getFieldVisibilityPermission function will return 0 else return 1
     $quotestage_access = getFieldVisibilityPermission('Quotes', $current_user->id, 'quotestage') != '0' ? 1 : 0;
     $picklistarray = getAccessPickListValues('Quotes');
     $quotestage_array = $quotestage_access != 1 ? $picklistarray['quotestage'] : array();
     //- ==> picklist field is not permitted in profile
     //Not Accessible - picklist is permitted in profile but picklist value is not permitted
     $error_msg = $quotestage_access != 1 ? 'Not Accessible' : '-';
     while ($row = $adb->fetch_array($result)) {
         $entries = array();
         // Module Sequence Numbering
         //$entries[] = $row['quoteid'];
         $entries[] = $row['quote_no'];
         // END
         $entries[] = $row['accountname'];
         $entries[] = $row['total'];
         $entries[] = in_array($row['quotestage'], $quotestage_array) ? $row['quotestage'] : $error_msg;
         $date = new DateTimeField($row['lastmodified']);
         $entries[] = $date->getDisplayDateTimeValue();
         $entries_list[] = $entries;
     }
     $return_data = array('header' => $header, 'entries' => $entries_list);
     $log->debug("Exiting get_quotestagehistory method ...");
     return $return_data;
 }
コード例 #29
0
ファイル: Reports.php プロジェクト: rcrrich/UpdatePackages
    function getAdvancedFilterList($reportid)
    {
        global $adb;
        global $modules;
        global $log;
        global $current_user;
        $advft_criteria = array();
        $sql = 'SELECT * FROM vtiger_relcriteria_grouping WHERE queryid = ? ORDER BY groupid';
        $groupsresult = $adb->pquery($sql, array($reportid));
        $i = 1;
        $j = 0;
        while ($relcriteriagroup = $adb->fetch_array($groupsresult)) {
            $groupId = $relcriteriagroup["groupid"];
            $groupCondition = $relcriteriagroup["group_condition"];
            $ssql = 'select vtiger_relcriteria.* from vtiger_report
						inner join vtiger_relcriteria on vtiger_relcriteria.queryid = vtiger_report.queryid
						left join vtiger_relcriteria_grouping on vtiger_relcriteria.queryid = vtiger_relcriteria_grouping.queryid
								and vtiger_relcriteria.groupid = vtiger_relcriteria_grouping.groupid';
            $ssql .= " where vtiger_report.reportid = ? AND vtiger_relcriteria.groupid = ? order by vtiger_relcriteria.columnindex";
            $result = $adb->pquery($ssql, array($reportid, $groupId));
            $noOfColumns = $adb->num_rows($result);
            if ($noOfColumns <= 0) {
                continue;
            }
            while ($relcriteriarow = $adb->fetch_array($result)) {
                $columnIndex = $relcriteriarow["columnindex"];
                $criteria = array();
                $criteria['columnname'] = $relcriteriarow["columnname"];
                $criteria['comparator'] = $relcriteriarow["comparator"];
                $advfilterval = $relcriteriarow["value"];
                $col = explode(":", $relcriteriarow["columnname"]);
                $moduleFieldLabel = $col[2];
                $fieldName = $col[3];
                list($module, $fieldLabel) = explode('__', $moduleFieldLabel, 2);
                $fieldInfo = getFieldByReportLabel($module, $fieldLabel);
                $fieldType = null;
                if (!empty($fieldInfo)) {
                    $field = WebserviceField::fromArray($adb, $fieldInfo);
                    $fieldType = $field->getFieldDataType();
                }
                if ($fieldType == 'currency') {
                    if ($field->getUIType() == '71') {
                        $advfilterval = CurrencyField::convertToUserFormat($advfilterval, $current_user);
                    } else {
                        if ($field->getUIType() == '72') {
                            $advfilterval = CurrencyField::convertToUserFormat($advfilterval, $current_user, true);
                        }
                    }
                }
                $temp_val = explode(",", $relcriteriarow["value"]);
                if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') {
                    $val = array();
                    for ($x = 0; $x < count($temp_val); $x++) {
                        if ($col[4] == 'D') {
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayDate();
                        } elseif ($col[4] == 'DT') {
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayDateTimeValue();
                        } else {
                            $date = new DateTimeField(trim($temp_val[$x]));
                            $val[$x] = $date->getDisplayTime();
                        }
                    }
                    $advfilterval = implode(",", $val);
                }
                //In vtiger6 report filter conditions, if the value has "(double quotes) then it is failed.
                $criteria['value'] = Vtiger_Util_Helper::toSafeHTML(decode_html($advfilterval));
                $criteria['column_condition'] = $relcriteriarow["column_condition"];
                $advft_criteria[$relcriteriarow['groupid']]['columns'][$j] = $criteria;
                $advft_criteria[$relcriteriarow['groupid']]['condition'] = $groupCondition;
                $j++;
            }
            $i++;
        }
        // Clear the condition (and/or) for last group, if any.
        if (!empty($advft_criteria[$i - 1]['condition'])) {
            $advft_criteria[$i - 1]['condition'] = '';
        }
        $this->advft_criteria = $advft_criteria;
        $log->info("Reports :: Successfully returned getAdvancedFilterList");
        return true;
    }
コード例 #30
-1
/** This function returns the detail view form vtiger_field and and its properties in array format.
 * Param $uitype - UI type of the vtiger_field
 * Param $fieldname - Form vtiger_field name
 * Param $fieldlabel - Form vtiger_field label name
 * Param $col_fields - array contains the vtiger_fieldname and values
 * Param $generatedtype - Field generated type (default is 1)
 * Param $tabid - vtiger_tab id to which the Field belongs to (default is "")
 * Return type is an array
 */
function getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid = '', $module = '')
{
    global $log;
    $log->debug("Entering getDetailViewOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $col_fields . "," . $generatedtype . "," . $tabid . ") method ...");
    global $adb;
    global $mod_strings;
    global $app_strings;
    global $current_user;
    global $theme;
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $fieldlabel = from_html($fieldlabel);
    $custfld = '';
    $value = '';
    $arr_data = array();
    $label_fld = array();
    $data_fld = array();
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    // vtlib customization: New uitype to handle relation between modules
    if ($uitype == '10') {
        $fieldlabel = getTranslatedString($fieldlabel, $module);
        $parent_id = $col_fields[$fieldname];
        if (!empty($parent_id)) {
            $parent_module = getSalesEntityType($parent_id);
            $valueTitle = getTranslatedString($parent_module, $parent_module);
            $displayValueArray = getEntityName($parent_module, $parent_id);
            if (!empty($displayValueArray)) {
                foreach ($displayValueArray as $key => $value) {
                    $displayValue = $value;
                }
            }
            // vtlib customization: For listview javascript triggers
            $modMetaInfo = getEntityFieldNames($parent_module);
            $modEName = is_array($modMetaInfo['fieldname']) ? $modMetaInfo['fieldname'][0] : $modMetaInfo['fieldname'];
            $vtlib_metainfo = "<span type='vtlib_metainfo' vtrecordid='{$parent_id}' vtfieldname=" . "'{$modEName}' vtmodule='{$parent_module}' style='display:none;'></span>";
            // END
            $label_fld = array($fieldlabel, "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>{$vtlib_metainfo}");
        } else {
            $moduleSpecificMessage = 'MODULE_NOT_SELECTED';
            if ($mod_strings[$moduleSpecificMessage] != "") {
                $moduleSpecificMessage = $mod_strings[$moduleSpecificMessage];
            }
            $label_fld = array($fieldlabel, '');
        }
    } else {
        if ($uitype == 99) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
            if ($fieldname == 'confirm_password') {
                return null;
            }
        } elseif ($uitype == 116 || $uitype == 117) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = getCurrencyName($col_fields[$fieldname]);
            $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name');
                $currency_id = $adb->query_result($pickListResult, $j, 'id');
                if ($col_fields[$fieldname] == $currency_id) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[$currency_id] = array($pickListValue => $chk_val);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 13 || $uitype == 104) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 16) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = getTranslatedString($col_fields[$fieldname], $module);
            $fieldname = $adb->sql_escape_string($fieldname);
            $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid";
            $params = array();
            $pickListResult = $adb->pquery($pick_query, $params);
            $noofpickrows = $adb->num_rows($pickListResult);
            $options = array();
            $count = 0;
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname)));
                $col_fields[$fieldname] = decode_html($col_fields[$fieldname]);
                if ($col_fields[$fieldname] == $pickListValue) {
                    $chk_val = "selected";
                    $count++;
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $pickListValue = to_html($pickListValue);
                $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 15) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
            $roleid = $current_user->roleid;
            $valueArr = explode("|##|", $col_fields[$fieldname]);
            $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $count = 0;
            $found = false;
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    if (in_array(trim($pickListValue), array_map("trim", $valueArr))) {
                        $chk_val = "selected";
                        $pickcount++;
                    } else {
                        $chk_val = '';
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected');
                }
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 115) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = getTranslatedString($col_fields[$fieldname]);
            $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname);
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname));
                if ($col_fields[$fieldname] == $pickListValue) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[] = array($pickListValue => $chk_val);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 33) {
            //uitype 33 added for multiselector picklist - Jeri
            $roleid = $current_user->roleid;
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = str_ireplace(' |##| ', ', ', $col_fields[$fieldname]);
            $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
            $options = array();
            $selected_entries = array();
            $selected_entries = explode(' |##| ', $col_fields[$fieldname]);
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    foreach ($selected_entries as $selected_entries_value) {
                        if (trim($selected_entries_value) == trim(htmlentities($pickListValue, ENT_QUOTES, $default_charset))) {
                            $chk_val = 'selected';
                            $pickcount++;
                            break;
                        } else {
                            $chk_val = '';
                        }
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $not_access_lbl = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                    $options[] = array($not_access_lbl, trim($selected_entries_value), 'selected');
                }
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 17) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $matchPattern = "^[\\w]+:\\/\\/^";
            $value = $col_fields[$fieldname];
            preg_match($matchPattern, $value, $matches);
            if (!empty($matches[0])) {
                $fieldValue = str_replace($matches, "", $value);
                $label_fld[] = $value;
            } else {
                if ($value != null) {
                    $label_fld[] = 'http://' . $value;
                } else {
                    $label_fld[] = '';
                }
            }
        } elseif ($uitype == 19) {
            if ($fieldname == 'notecontent' or $module == 'Timecontrol') {
                $col_fields[$fieldname] = decode_html($col_fields[$fieldname]);
            } else {
                $col_fields[$fieldname] = str_replace("&lt;br /&gt;", "<br>", $col_fields[$fieldname]);
            }
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 20 || $uitype == 21 || $uitype == 22 || $uitype == 24) {
            // Armando LC<scher 11.08.2005 -> B'descriptionSpan -> Desc: removed $uitype == 19 and made an aditional elseif above
            if ($uitype == 20) {
                //Fix the issue #4680
                $col_fields[$fieldname] = $col_fields[$fieldname];
            } else {
                $col_fields[$fieldname] = nl2br($col_fields[$fieldname]);
            }
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) {
            $account_id = $col_fields[$fieldname];
            if ($account_id != '') {
                $account_name = getAccountName($account_id);
            }
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $account_name;
            $label_fld["secid"] = $account_id;
            $label_fld["link"] = "index.php?module=Accounts&action=DetailView&record=" . $account_id;
            //Account Name View
        } elseif ($uitype == 52 || $uitype == 77 || $uitype == 101) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $user_id = $col_fields[$fieldname];
            $user_name = getOwnerName($user_id);
            if ($user_id != '') {
                $assigned_user_id = $user_id;
            } else {
                $assigned_user_id = $current_user->id;
            }
            if (is_admin($current_user)) {
                $label_fld[] = '<a href="index.php?module=Users&action=DetailView&record=' . $user_id . '">' . $user_name . '</a>';
            } else {
                $label_fld[] = $user_name;
            }
            if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $user_id), $assigned_user_id);
            }
            $label_fld["options"] = $users_combo;
        } elseif ($uitype == 11) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 53) {
            global $noof_group_rows, $adb;
            $owner_id = $col_fields[$fieldname];
            $user = '******';
            $result = $adb->pquery("SELECT count(*) as count from vtiger_users where id = ?", array($owner_id));
            if ($adb->query_result($result, 0, 'count') > 0) {
                $user = '******';
            }
            $owner_name = getOwnerName($owner_id);
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $owner_name;
            if (is_admin($current_user)) {
                $label_fld["secid"][] = $owner_id;
                if ($user == 'no') {
                    $label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=" . $owner_id;
                } else {
                    $label_fld["link"][] = "index.php?module=Users&action=DetailView&record=" . $owner_id;
                }
                //$label_fld["secid"][] = $groupid;
                //$label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=".$groupid;
            }
            //Security Checks
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $result = get_current_user_access_groups($module_name);
            } else {
                $result = get_group_options();
            }
            if ($result) {
                $nameArray = $adb->fetch_array($result);
            }
            global $current_user;
            //$value = $user_id;
            if ($owner_id != '') {
                if ($user == 'yes') {
                    $label_fld["options"][] = 'User';
                    $assigned_user_id = $owner_id;
                    $user_checked = "checked";
                    $team_checked = '';
                    $user_style = 'display:block';
                    $team_style = 'display:none';
                } else {
                    //$record = $col_fields["record_id"];
                    //$module = $col_fields["record_module"];
                    $label_fld["options"][] = 'Group';
                    $assigned_group_id = $owner_id;
                    $user_checked = '';
                    $team_checked = 'checked';
                    $user_style = 'display:none';
                    $team_style = 'display:block';
                }
            } else {
                $label_fld["options"][] = 'User';
                $assigned_user_id = $current_user->id;
                $user_checked = "checked";
                $team_checked = '';
                $user_style = 'display:block';
                $team_style = 'display:none';
            }
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id), $assigned_user_id);
            }
            if ($noof_group_rows != 0) {
                if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id, 'private'), $current_user->id);
                } else {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id), $current_user->id);
                }
            }
            $label_fld["options"][] = $users_combo;
            $label_fld["options"][] = $groups_combo;
        } elseif ($uitype == 55 || $uitype == 255) {
            if ($tabid == 4) {
                $query = "select vtiger_contactdetails.imagename from vtiger_contactdetails where contactid=?";
                $result = $adb->pquery($query, array($col_fields['record_id']));
                $imagename = $adb->query_result($result, 0, 'imagename');
                if ($imagename != '') {
                    $imgpath = "test/contact/" . $imagename;
                    $label_fld[] = getTranslatedString($fieldlabel, $module);
                } else {
                    $label_fld[] = getTranslatedString($fieldlabel, $module);
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
            }
            $value = $col_fields[$fieldname];
            if ($uitype == 255) {
                global $currentModule;
                $fieldpermission = getFieldVisibilityPermission($currentModule, $current_user->id, 'firstname');
            }
            if ($uitype == 255 && $fieldpermission == 0 && $fieldpermission != '') {
                $fieldvalue[] = '';
            } else {
                $roleid = $current_user->roleid;
                $subrole = getRoleSubordinates($roleid);
                if (count($subrole) > 0) {
                    $roleids = implode("','", $subrole);
                    $roleids = $roleids . "','" . $roleid;
                } else {
                    $roleids = $roleid;
                }
                if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
                    $pick_query = "select salutationtype from vtiger_salutationtype order by salutationtype";
                    $params = array();
                } else {
                    $pick_query = "select * from vtiger_salutationtype left join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid=vtiger_salutationtype.picklist_valueid where picklistid in (select picklistid from vtiger_picklist where name='salutationtype') and roleid=? order by salutationtype";
                    $params = array($current_user->roleid);
                }
                $pickListResult = $adb->pquery($pick_query, $params);
                $noofpickrows = $adb->num_rows($pickListResult);
                $sal_value = $col_fields["salutationtype"];
                $salcount = 0;
                for ($j = 0; $j < $noofpickrows; $j++) {
                    $pickListValue = $adb->query_result($pickListResult, $j, "salutationtype");
                    if ($sal_value == $pickListValue) {
                        $chk_val = "selected";
                        $salcount++;
                    } else {
                        $chk_val = '';
                    }
                }
                if ($salcount == 0 && $sal_value != '') {
                    $notacc = $app_strings['LBL_NOT_ACCESSIBLE'];
                }
                $sal_value = $col_fields["salutationtype"];
                if ($sal_value == '--None--') {
                    $sal_value = '';
                }
                $label_fld["salut"] = getTranslatedString($sal_value);
                $label_fld["notaccess"] = $notacc;
            }
            $label_fld[] = $value;
        } elseif ($uitype == 56) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $value = $col_fields[$fieldname];
            if ($value == 1) {
                //Since "yes" is not been translated it is given as app strings here..
                $displayValue = $app_strings['yes'];
            } else {
                $displayValue = $app_strings['no'];
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 156) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $value = $col_fields[$fieldname];
            if ($value == 'on') {
                //Since "yes" is not been translated it is given as app strings here..
                $displayValue = $app_strings['yes'];
            } else {
                $displayValue = $app_strings['no'];
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 57) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $contact_id = $col_fields[$fieldname];
            if ($contact_id != '') {
                $displayValueArray = getEntityName('Contacts', $contact_id);
                if (!empty($displayValueArray)) {
                    foreach ($displayValueArray as $key => $field_value) {
                        $contact_name = $field_value;
                    }
                } else {
                    $contact_name = '';
                }
            }
            $label_fld[] = $contact_name;
            $label_fld["secid"] = $contact_id;
            $label_fld["link"] = "index.php?module=Contacts&action=DetailView&record=" . $contact_id;
        } elseif ($uitype == 58) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $campaign_id = $col_fields[$fieldname];
            if ($campaign_id != '') {
                $campaign_name = getCampaignName($campaign_id);
            }
            $label_fld[] = $campaign_name;
            $label_fld["secid"] = $campaign_id;
            $label_fld["link"] = "index.php?module=Campaigns&action=DetailView&record=" . $campaign_id;
        } elseif ($uitype == 59) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $product_id = $col_fields[$fieldname];
            if ($product_id != '') {
                $product_name = getProductName($product_id);
            }
            //Account Name View
            $label_fld[] = $product_name;
            $label_fld["secid"] = $product_id;
            $label_fld["link"] = "index.php?module=Products&action=DetailView&record=" . $product_id;
        } elseif ($uitype == 61) {
            global $adb;
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($tabid == 10) {
                $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id']));
                for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) {
                    $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid');
                    if ($attachmentid != '') {
                        $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                        $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                        if ($attachmentsname != '') {
                            $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '">' . $attachmentsname . '</a>';
                        } else {
                            $custfldval = '';
                        }
                    }
                    $label_fld['options'][] = $custfldval;
                }
            } else {
                $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
                if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                    $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                    $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                }
                //This is added to strip the crmid and _ from the file name and show the original filename
                //$org_filename = ltrim($col_fields[$fieldname],$col_fields['record_id'].'_');
                /* Above line is not required as the filename in the database is stored as it is and doesn't have crmid attached to it.
                	  This was the cause for the issue reported in ticket #4645 */
                $org_filename = $col_fields[$fieldname];
                // For Backward Compatibility version < 5.0.4
                $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_');
                if ($filename_pos === 0) {
                    $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_');
                    $org_filename = substr($org_filename, $start_idx);
                }
                if ($org_filename != '') {
                    if ($col_fields['filelocationtype'] == 'E') {
                        if ($col_fields['filestatus'] == 1) {
                            //&& strlen($col_fields['filename']) > 7  ){
                            $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                        } else {
                            $custfldval = $col_fields[$fieldname];
                        }
                    } elseif ($col_fields['filelocationtype'] == 'I') {
                        if ($col_fields['filestatus'] == 1) {
                            $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                        } else {
                            $custfldval = $col_fields[$fieldname];
                        }
                    } else {
                        $custfldval = '';
                    }
                }
                $label_fld[] = $custfldval;
            }
        } elseif ($uitype == 28) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
            if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
            }
            $org_filename = $col_fields[$fieldname];
            // For Backward Compatibility version < 5.0.4
            $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_');
            if ($filename_pos === 0) {
                $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_');
                $org_filename = substr($org_filename, $start_idx);
            }
            if ($org_filename != '') {
                if ($col_fields['filelocationtype'] == 'E') {
                    if ($col_fields['filestatus'] == 1) {
                        //&& strlen($col_fields['filename']) > 7  ){
                        $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                    } else {
                        $custfldval = $col_fields[$fieldname];
                    }
                } elseif ($col_fields['filelocationtype'] == 'I') {
                    if ($col_fields['filestatus'] == 1) {
                        $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                    } else {
                        $custfldval = $col_fields[$fieldname];
                    }
                } else {
                    $custfldval = '';
                }
            }
            $label_fld[] = $custfldval;
        } elseif ($uitype == 69) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($tabid == 14) {
                $images = array();
                $query = 'select productname, vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?';
                $result_image = $adb->pquery($query, array($col_fields['record_id']));
                for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) {
                    $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid');
                    //decode_html  - added to handle UTF-8   characters in file names
                    //urlencode    - added to handle special characters like #, %, etc.,
                    $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name')));
                    $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name'));
                    $imagepath_array[] = $adb->query_result($result_image, $image_iter, 'path');
                }
                if (count($image_array) > 1) {
                    if (count($image_array) < 4) {
                        $sides = count($image_array) * 2;
                    } else {
                        $sides = 8;
                    }
                    $image_lists = '<div id="Carousel" style="position:relative;vertical-align: middle;">
					<img src="modules/Products/placeholder.gif" width="571" height="117" style="position:relative;">
					</div><script>var Car_NoOfSides=' . $sides . '; Car_Image_Sources=new Array(';
                    for ($image_iter = 0; $image_iter < count($image_array); $image_iter++) {
                        $images[] = '"' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '","' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '"';
                    }
                    $image_lists .= implode(',', $images) . ');</script><script language="JavaScript" type="text/javascript" src="modules/Products/Productsslide.js"></script><script language="JavaScript" type="text/javascript">Carousel();</script>';
                    $label_fld[] = $image_lists;
                } elseif (count($image_array) == 1) {
                    list($pro_image_width, $pro_image_height) = getimagesize($imagepath_array[0] . $image_id_array[0] . "_" . $image_orgname_array[0]);
                    if ($pro_image_width > 450 || $pro_image_height > 300) {
                        $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="450" height="300">';
                    } else {
                        $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="' . $pro_image_width . '" height="' . $pro_image_height . '">';
                    }
                } else {
                    $label_fld[] = '';
                }
            } else {
                if ($module == 'Contacts') {
                    $imageattachment = 'Image';
                } else {
                    $imageattachment = 'Attachment';
                }
                //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname];
                $sql = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t from vtiger_attachments\n\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t  and vtiger_attachments.name = ?\n\t\t\t  and vtiger_seattachmentsrel.crmid=?";
                $image_res = $adb->pquery($sql, array($col_fields[$fieldname], $col_fields['record_id']));
                $image_id = $adb->query_result($image_res, 0, 'attachmentsid');
                $image_path = $adb->query_result($image_res, 0, 'path');
                //decode_html  - added to handle UTF-8   characters in file names
                //urlencode    - added to handle special characters like #, %, etc.,
                $image_name = urlencode(decode_html($adb->query_result($image_res, 0, 'name')));
                $imgpath = $image_path . $image_id . "_" . $image_name;
                if ($image_name != '') {
                    $ftype = $adb->query_result($image_res, 0, 'type');
                    $isimage = stripos($ftype, 'image') !== false;
                    if ($isimage) {
                        $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image');
                        $label_fld[] = '<img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 500px;">';
                    } else {
                        $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents');
                        $label_fld[] = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>';
                    }
                } else {
                    $label_fld[] = '';
                }
            }
        } elseif ($uitype == 62) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Leads") {
                    $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $lead_name = $field_value;
                        }
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                } elseif ($parent_module == "Accounts") {
                    $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                    $sql = "select * from  vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $account_name = $adb->query_result($result, 0, "accountname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>';
                } elseif ($parent_module == "Potentials") {
                    $label_fld[] = $app_strings['LBL_POTENTIAL_NAME'];
                    $sql = "select * from  vtiger_potential where potentialid=?";
                    $result = $adb->pquery($sql, array($value));
                    $potentialname = $adb->query_result($result, 0, "potentialname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>';
                } elseif ($parent_module == "Products") {
                    $label_fld[] = $app_strings['LBL_PRODUCT_NAME'];
                    $sql = "select * from  vtiger_products where productid=?";
                    $result = $adb->pquery($sql, array($value));
                    $productname = $adb->query_result($result, 0, "productname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $productname . '</a>';
                } elseif ($parent_module == "PurchaseOrder") {
                    $label_fld[] = $app_strings['LBL_PORDER_NAME'];
                    $sql = "select * from  vtiger_purchaseorder where purchaseorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $pordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>';
                } elseif ($parent_module == "SalesOrder") {
                    $label_fld[] = $app_strings['LBL_SORDER_NAME'];
                    $sql = "select * from  vtiger_salesorder where salesorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $sordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>';
                } elseif ($parent_module == "Invoice") {
                    $label_fld[] = $app_strings['LBL_INVOICE_NAME'];
                    $sql = "select * from  vtiger_invoice where invoiceid=?";
                    $result = $adb->pquery($sql, array($value));
                    $invoicename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>';
                } elseif ($parent_module == "Quotes") {
                    $label_fld[] = $app_strings['LBL_QUOTES_NAME'];
                    $sql = "select * from  vtiger_quotes where quoteid=?";
                    $result = $adb->pquery($sql, array($value));
                    $quotename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>';
                } elseif ($parent_module == "HelpDesk") {
                    $label_fld[] = $app_strings['LBL_HELPDESK_NAME'];
                    $sql = "select * from  vtiger_troubletickets where ticketid=?";
                    $result = $adb->pquery($sql, array($value));
                    $title = $adb->query_result($result, 0, "title");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $title . '</a>';
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 105) {
            //Added for user image
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname];
            $sql = "select vtiger_attachments.* from vtiger_attachments left join vtiger_salesmanattachmentsrel on vtiger_salesmanattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid where vtiger_salesmanattachmentsrel.smid=?";
            $image_res = $adb->pquery($sql, array($col_fields['record_id']));
            $image_id = $adb->query_result($image_res, 0, 'attachmentsid');
            $image_path = $adb->query_result($image_res, 0, 'path');
            $image_name = $adb->query_result($image_res, 0, 'name');
            $imgpath = $image_path . $image_id . "_" . $image_name;
            if ($image_name != '') {
                //Added the following check for the image to retain its in original size.
                list($pro_image_width, $pro_image_height) = getimagesize(decode_html($imgpath));
                $label_fld[] = '<a href="' . $imgpath . '" target="_blank"><img src="' . $imgpath . '" width="' . $pro_image_width . '" height="' . $pro_image_height . '" alt="' . $col_fields['user_name'] . '" title="' . $col_fields['user_name'] . '" border="0"></a>';
            } else {
                $label_fld[] = '';
            }
        } elseif ($uitype == 66) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Leads") {
                    $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $lead_name = $field_value;
                        }
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                } elseif ($parent_module == "Accounts") {
                    $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                    $sql = "select * from  vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $account_name = $adb->query_result($result, 0, "accountname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>';
                } elseif ($parent_module == "Potentials") {
                    $label_fld[] = $app_strings['LBL_POTENTIAL_NAME'];
                    $sql = "select * from  vtiger_potential where potentialid=?";
                    $result = $adb->pquery($sql, array($value));
                    $potentialname = $adb->query_result($result, 0, "potentialname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>';
                } elseif ($parent_module == "Quotes") {
                    $label_fld[] = $app_strings['LBL_QUOTE_NAME'];
                    $sql = "select * from  vtiger_quotes where quoteid=?";
                    $result = $adb->pquery($sql, array($value));
                    $quotename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>';
                } elseif ($parent_module == "PurchaseOrder") {
                    $label_fld[] = $app_strings['LBL_PORDER_NAME'];
                    $sql = "select * from  vtiger_purchaseorder where purchaseorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $pordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>';
                } elseif ($parent_module == "SalesOrder") {
                    $label_fld[] = $app_strings['LBL_SORDER_NAME'];
                    $sql = "select * from  vtiger_salesorder where salesorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $sordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>';
                } elseif ($parent_module == "Invoice") {
                    $label_fld[] = $app_strings['LBL_INVOICE_NAME'];
                    $sql = "select * from  vtiger_invoice where invoiceid=?";
                    $result = $adb->pquery($sql, array($value));
                    $invoicename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>';
                } elseif ($parent_module == "Campaigns") {
                    $label_fld[] = $app_strings['LBL_CAMPAIGN_NAME'];
                    $sql = "select * from  vtiger_campaign where campaignid=?";
                    $result = $adb->pquery($sql, array($value));
                    $campaignname = $adb->query_result($result, 0, "campaignname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $campaignname . '</a>';
                } elseif ($parent_module == "HelpDesk") {
                    $label_fld[] = $app_strings['LBL_HELPDESK_NAME'];
                    $sql = "select * from  vtiger_troubletickets where ticketid=?";
                    $result = $adb->pquery($sql, array($value));
                    $tickettitle = $adb->query_result($result, 0, "title");
                    if (strlen($tickettitle) > 25) {
                        $tickettitle = substr($tickettitle, 0, 25) . '...';
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $tickettitle . '</a>';
                } elseif ($parent_module == "Vendors") {
                    //MSL
                    $label_fld[] = $app_strings['LBL_VENDOR_NAME'];
                    $sql = "select vendorname from  vtiger_vendor where vendorid=?";
                    $result = $adb->pquery($sql, array($value));
                    $vendor_name = $adb->query_result($result, 0, "vendorname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $vendor_name . '</a>';
                }
                //MSL -------------------------------------------
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 67) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Leads") {
                    $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $lead_name = $field_value;
                        }
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                } elseif ($parent_module == "Contacts") {
                    $label_fld[] = $app_strings['LBL_CONTACT_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $contact_name = $field_value;
                        }
                    } else {
                        $contact_name = '';
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>';
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 357) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_name = '';
                $parent_id = '';
                $myemailid = $_REQUEST['record'];
                $mysql = "select crmid from vtiger_seactivityrel where activityid=?";
                $myresult = $adb->pquery($mysql, array($myemailid));
                $mycount = $adb->num_rows($myresult);
                if ($mycount > 1) {
                    $label_fld[] = $app_strings['LBL_RELATED_TO'];
                    $label_fld[] = $app_strings['LBL_MULTIPLE'];
                } else {
                    $parent_module = getSalesEntityType($value);
                    if ($parent_module == "Leads") {
                        $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                        $displayValueArray = getEntityName($parent_module, $value);
                        if (!empty($displayValueArray)) {
                            foreach ($displayValueArray as $key => $field_value) {
                                $lead_name = $field_value;
                            }
                        }
                        $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                    } elseif ($parent_module == "Contacts") {
                        $label_fld[] = $app_strings['LBL_CONTACT_NAME'];
                        $displayValueArray = getEntityName($parent_module, $value);
                        if (!empty($displayValueArray)) {
                            foreach ($displayValueArray as $key => $field_value) {
                                $contact_name = $field_value;
                            }
                        } else {
                            $contact_name = '';
                        }
                        $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>';
                    } elseif ($parent_module == "Accounts") {
                        $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                        $sql = "select * from  vtiger_account where accountid=?";
                        $result = $adb->pquery($sql, array($value));
                        $accountname = $adb->query_result($result, 0, "accountname");
                        $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $accountname . '</a>';
                    }
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 68) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Contacts") {
                    $label_fld[] = $app_strings['LBL_CONTACT_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $contact_name = $field_value;
                        }
                    } else {
                        $contact_name = '';
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>';
                } elseif ($parent_module == "Accounts") {
                    $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                    $sql = "select * from vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $account_name = $adb->query_result($result, 0, "accountname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>';
                } else {
                    $value = '';
                    $label_fld[] = getTranslatedString($fieldlabel, $module);
                    $label_fld[] = $value;
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 63) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname] . 'h&nbsp; ' . $col_fields['duration_minutes'] . 'm';
        } elseif ($uitype == 6) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($col_fields[$fieldname] == '0') {
                $col_fields[$fieldname] = '';
            }
            if ($col_fields['time_start'] != '') {
                $start_time = $col_fields['time_start'];
            }
            $dateValue = $col_fields[$fieldname];
            if ($col_fields[$fieldname] == '0000-00-00' || empty($dateValue)) {
                $displayValue = '';
            } else {
                if (empty($start_time) && strpos($col_fields[$fieldname], ' ') == false) {
                    $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]);
                } else {
                    if (!empty($start_time)) {
                        $date = new DateTimeField($col_fields[$fieldname] . ' ' . $start_time);
                    } else {
                        $date = new DateTimeField($col_fields[$fieldname]);
                    }
                    $displayValue = $date->getDisplayDateTimeValue();
                }
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 5 || $uitype == 23 || $uitype == 70) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $dateValue = $col_fields[$fieldname];
            if ($col_fields['time_end'] != '' && ($tabid == 9 || $tabid == 16) && $uitype == 23) {
                $end_time = $col_fields['time_end'];
            }
            if ($dateValue == '0000-00-00' || empty($dateValue)) {
                $displayValue = '';
            } else {
                if (empty($end_time) && strpos($dateValue, ' ') == false) {
                    $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]);
                } else {
                    if (!empty($end_time)) {
                        $date = new DateTimeField($col_fields[$fieldname] . ' ' . $end_time);
                    } else {
                        $date = new DateTimeField($col_fields[$fieldname]);
                    }
                    $displayValue = $date->getDisplayDateTimeValue();
                }
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 71 || $uitype == 72) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $currencyField = new CurrencyField($col_fields[$fieldname]);
            if ($uitype == 72) {
                // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
                if ($fieldname == 'unit_price') {
                    $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module));
                    $label_fld[] = $currencyField->getDisplayValue(null, true);
                    $label_fld["cursymb"] = $rate_symbol['symbol'];
                } else {
                    $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']);
                    $label_fld[] = $currencyField->getDisplayValue(null, true);
                    $label_fld["cursymb"] = $currency_info['currency_symbol'];
                }
            } else {
                $label_fld[] = $currencyField->getDisplayValue();
                $label_fld["cursymb"] = $currencyField->getCurrencySymbol();
            }
        } elseif ($uitype == 75 || $uitype == 81) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $vendor_id = $col_fields[$fieldname];
            if ($vendor_id != '') {
                $vendor_name = getVendorName($vendor_id);
            }
            $label_fld[] = $vendor_name;
            $label_fld["secid"] = $vendor_id;
            $label_fld["link"] = "index.php?module=Vendors&action=DetailView&record=" . $vendor_id;
        } elseif ($uitype == 76) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $potential_id = $col_fields[$fieldname];
            if ($potential_id != '') {
                $potential_name = getPotentialName($potential_id);
            }
            $label_fld[] = $potential_name;
            $label_fld["secid"] = $potential_id;
            $label_fld["link"] = "index.php?module=Potentials&action=DetailView&record=" . $potential_id;
        } elseif ($uitype == 78) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $quote_id = $col_fields[$fieldname];
            if ($quote_id != '') {
                $quote_name = getQuoteName($quote_id);
            }
            $label_fld[] = $quote_name;
            $label_fld["secid"] = $quote_id;
            $label_fld["link"] = "index.php?module=Quotes&action=DetailView&record=" . $quote_id;
        } elseif ($uitype == 79) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $purchaseorder_id = $col_fields[$fieldname];
            if ($purchaseorder_id != '') {
                $purchaseorder_name = getPoName($purchaseorder_id);
            }
            $label_fld[] = $purchaseorder_name;
            $label_fld["secid"] = $purchaseorder_id;
            $label_fld["link"] = "index.php?module=PurchaseOrder&action=DetailView&record=" . $purchaseorder_id;
        } elseif ($uitype == 80) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $salesorder_id = $col_fields[$fieldname];
            if ($salesorder_id != '') {
                $salesorder_name = getSoName($salesorder_id);
            }
            $label_fld[] = $salesorder_name;
            $label_fld["secid"] = $salesorder_id;
            $label_fld["link"] = "index.php?module=SalesOrder&action=DetailView&record=" . $salesorder_id;
        } elseif ($uitype == 30) {
            $rem_days = 0;
            $rem_hrs = 0;
            $rem_min = 0;
            $reminder_str = "";
            $rem_days = floor($col_fields[$fieldname] / (24 * 60));
            $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60);
            $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60;
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($col_fields[$fieldname]) {
                $reminder_str = $rem_days . '&nbsp;' . $mod_strings['LBL_DAYS'] . '&nbsp;' . $rem_hrs . '&nbsp;' . $mod_strings['LBL_HOURS'] . '&nbsp;' . $rem_min . '&nbsp;' . $mod_strings['LBL_MINUTES'] . '&nbsp;&nbsp;' . $mod_strings['LBL_BEFORE_EVENT'];
            }
            $label_fld[] = '&nbsp;' . $reminder_str;
        } elseif ($uitype == 98) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if (is_admin($current_user)) {
                $label_fld[] = '<a href="index.php?module=Settings&action=RoleDetailView&roleid=' . $col_fields[$fieldname] . '">' . getRoleName($col_fields[$fieldname]) . '</a>';
            } else {
                $label_fld[] = getRoleName($col_fields[$fieldname]);
            }
        } elseif ($uitype == 85) {
            //Added for Skype by Minnie
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 26) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $query = "select foldername from vtiger_attachmentsfolder where folderid = ?";
            $result = $adb->pquery($query, array($col_fields[$fieldname]));
            $folder_name = $adb->query_result($result, 0, "foldername");
            $label_fld[] = $folder_name;
        } elseif ($uitype == 27) {
            if ($col_fields[$fieldname] == 'I') {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $mod_strings['LBL_INTERNAL'];
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $mod_strings['LBL_EXTERNAL'];
            }
        } elseif ($uitype == 31) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
            $options = array();
            $themeList = get_themes();
            foreach ($themeList as $theme) {
                if ($current_user->theme == $theme) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($theme), $theme, $selected);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 32) {
            $options = array();
            $languageList = Vtiger_Language::getAll();
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = isset($languageList[$col_fields[$fieldname]]) ? $languageList[$col_fields[$fieldname]] : $col_fields[$fieldname];
            foreach ($languageList as $prefix => $label) {
                if ($current_user->language == $prefix) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($label), $prefix, $selected);
            }
            $label_fld["options"] = $options;
        } else {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($col_fields[$fieldname] == '0' && $fieldname != 'filedownloadcount' && $fieldname != 'filestatus' && $fieldname != 'filesize') {
                $col_fields[$fieldname] = '';
            }
            //code for Documents module :start
            if ($tabid == 8) {
                $downloadtype = $col_fields['filelocationtype'];
                if ($fieldname == 'filename') {
                    if ($downloadtype == 'I') {
                        //$file_value = $mod_strings['LBL_INTERNAL'];
                        $fld_value = $col_fields['filename'];
                        $ext_pos = strrpos($fld_value, ".");
                        $ext = substr($fld_value, $ext_pos + 1);
                        $ext = strtolower($ext);
                        if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') {
                            $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') {
                            $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') {
                            $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') {
                            $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>";
                        } else {
                            $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        }
                    } else {
                        $fld_value = $col_fields['filename'];
                        $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' title='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' hspace='3' align='absmiddle' border='0'>";
                    }
                    $label_fld[] = $fileicon . $fld_value;
                }
                if ($fieldname == 'filesize') {
                    if ($col_fields['filelocationtype'] == 'I') {
                        $filesize = $col_fields[$fieldname];
                        if ($filesize < 1024) {
                            $label_fld[] = $filesize . ' B';
                        } elseif ($filesize > 1024 && $filesize < 1048576) {
                            $label_fld[] = round($filesize / 1024, 2) . ' KB';
                        } else {
                            if ($filesize > 1048576) {
                                $label_fld[] = round($filesize / (1024 * 1024), 2) . ' MB';
                            }
                        }
                    } else {
                        $label_fld[] = ' --';
                    }
                }
                if ($fieldname == 'filetype' && $col_fields['filelocationtype'] == 'E') {
                    $label_fld[] = ' --';
                }
                /* if($fieldname == 'filestatus')
                	  {
                	  $filestatus = $col_fields[$fieldname];
                	  if($filestatus == 0)
                	  $label_fld[]=$mod_strings['LBL_ACTIVE'];
                	  else
                	  $label_fld[]=$mod_strings['LBL_INACTIVE'];
                	  } */
            }
            //code for Documents module :end
            $label_fld[] = $col_fields[$fieldname];
        }
    }
    $label_fld[] = $uitype;
    //sets whether the currenct user is admin or not
    if (is_admin($current_user)) {
        $label_fld["isadmin"] = 1;
    } else {
        $label_fld["isadmin"] = 0;
    }
    $log->debug("Exiting getDetailViewOutputHtml method ...");
    return $label_fld;
}