function getContact($idContact) { //Realiza el query en la base de datos $mysqli = makeSqlConnection(); $sql = "SELECT * FROM contacts a LEFT JOIN contacts_cstm ac ON a.id = ac.id_c WHERE id = '{$idContact}'"; $res = $mysqli->query($sql); $rows = array(); while ($r = mysqli_fetch_assoc($res)) { $obj = (object) $r; $obj->email_address = getEmail($idContact); $obj->idAccount = getAccountId($idContact); $obj->nameAccount = getAccountName($obj->idAccount); $obj->reports_to_name = getContactName($obj->reports_to_id); $obj->created_by_name = getUserName($obj->created_by); $obj->modified_user_name = getUserName($obj->modified_user_id); $obj->assigned_user_name = getUserName($obj->user_id_c); $obj->nameCampaign = getCampaignName($obj->campaign_id); $a = (array) $obj; $rows[] = $a; } if (empty($rows)) { return '{"results" :[]}'; } else { //Convierte el arreglo en json y lo retorna $temp = json_encode(utf8ize($rows)); return '{"results" :' . $temp . '}'; } }
/** This function returns the vtiger_field details for a given vtiger_fieldname. * Param $uitype - UI type of the vtiger_field * Param $fieldname - Form vtiger_field name * Param $fieldlabel - Form vtiger_field label name * Param $maxlength - maximum length of the vtiger_field * Param $col_fields - array contains the vtiger_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $module_name - module name * Return type is an array */ function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module_name, $mode = '', $typeofdata = null) { global $log, $app_strings, $adb, $default_charset, $theme, $mod_strings, $current_user; $log->debug("Entering getOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $maxlength . "," . print_r($col_fields, true) . "," . $generatedtype . "," . $module_name . ") method ..."); require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $fieldlabel = from_html($fieldlabel); $fieldvalue = array(); $final_arr = array(); $value = $col_fields[$fieldname]; $custfld = ''; $ui_type[] = $uitype; $editview_fldname[] = $fieldname; // vtlib customization: Related type field if ($uitype == '10') { global $adb; $fldmod_result = $adb->pquery('SELECT relmodule, status FROM vtiger_fieldmodulerel WHERE fieldid= (SELECT fieldid FROM vtiger_field, vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid AND fieldname=? AND name=? and vtiger_field.presence in (0,2)) order by sequence', array($fieldname, $module_name)); $entityTypes = array(); $parent_id = $value; for ($index = 0; $index < $adb->num_rows($fldmod_result); ++$index) { $entityTypes[] = $adb->query_result($fldmod_result, $index, 'relmodule'); } if (!empty($value)) { if ($adb->num_rows($fldmod_result) == 1) { $valueType = $adb->query_result($fldmod_result, 0, 0); } else { $valueType = getSalesEntityType($value); } $displayValueArray = getEntityName($valueType, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $value) { $displayValue = $value; } } } else { $displayValue = ''; $valueType = ''; $value = ''; } $editview_label[] = array('options' => $entityTypes, 'selected' => $valueType, 'displaylabel' => getTranslatedString($fieldlabel, $module_name)); $fieldvalue[] = array('displayvalue' => $displayValue, 'entityid' => $parent_id); } else { if ($uitype == 5 || $uitype == 6 || $uitype == 23) { $log->info("uitype is " . $uitype); if ($value == '') { //modified to fix the issue in trac(http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/1469) if ($fieldname != 'birthday' && $generatedtype != 2 && getTabid($module_name) != 14) { $disp_value = getNewDisplayDate(); } if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 6) { $curr_time = date('H:i', strtotime('+5 minutes')); } if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) { $curr_time = date('H:i', strtotime('+10 minutes')); } //Added to display the Contact - Support End Date as one year future instead of //today's date -- 30-11-2005 if ($fieldname == 'support_end_date' && $_REQUEST['module'] == 'Contacts') { $addyear = strtotime("+1 year"); $disp_value = DateTimeField::convertToUserFormat(date('Y-m-d', $addyear)); } elseif ($fieldname == 'validtill' && $_REQUEST['module'] == 'Quotes') { $disp_value = ''; } } else { if ($uitype == 6) { if ($col_fields['time_start'] != '' && ($module_name == 'Events' || $module_name == 'Calendar')) { $curr_time = $col_fields['time_start']; $value = $value . ' ' . $curr_time; } else { $curr_time = date('H:i', strtotime('+5 minutes')); } } if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) { if ($col_fields['time_end'] != '') { $curr_time = $col_fields['time_end']; $value = $value . ' ' . $curr_time; } else { $curr_time = date('H:i', strtotime('+10 minutes')); } } $disp_value = getValidDisplayDate($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); if (!empty($curr_time)) { if (($module_name == 'Events' || $module_name == 'Calendar') && ($uitype == 23 || $uitype == 6)) { $curr_time = DateTimeField::convertToUserTimeZone($curr_time); $curr_time = $curr_time->format('H:i'); } } else { $curr_time = ''; } if (empty($disp_value)) { $disp_value = ''; } $fieldvalue[] = array($disp_value => $curr_time); if ($uitype == 5 || $uitype == 23) { if ($module_name == 'Events' && $uitype == 23) { $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']); } else { $fieldvalue[] = array($date_format => $current_user->date_format); } } else { $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']); } } elseif ($uitype == 16) { require_once 'modules/PickList/PickListUtils.php'; $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldname = $adb->sql_escape_string($fieldname); $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid"; $params = array(); $pickListResult = $adb->pquery($pick_query, $params); $noofpickrows = $adb->num_rows($pickListResult); $options = array(); $pickcount = 0; $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $value = decode_html($value); $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname))); if ($value == trim($pickListValue)) { $chk_val = "selected"; $pickcount++; $found = true; } else { $chk_val = ''; } $pickListValue = to_html($pickListValue); if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } $fieldvalue[] = $options; } elseif ($uitype == 1613) { require_once 'modules/PickList/PickListUtils.php'; $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldname = $adb->sql_escape_string($fieldname); $pickListResult = getAllowedPicklistModules(); $options = array(); $options[] = ""; $pickcount = 0; $found = false; foreach ($pickListResult as $pKey => $pValue) { $value = decode_html($value); $pickListValue = decode_html($pValue); if ($value == trim($pickListValue)) { $chk_val = "selected"; $pickcount++; $found = true; } else { $chk_val = ''; } $pickListValue = to_html($pickListValue); if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val); } } uasort($options, function ($a, $b) { return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1; }); $fieldvalue[] = $options; } elseif ($uitype == 15 || $uitype == 33) { require_once 'modules/PickList/PickListUtils.php'; $roleid = $current_user->roleid; $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); $valueArr = explode("|##|", $value); foreach ($valueArr as $key => $value) { $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset)); } $pickcount = 0; if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { if (in_array(trim($pickListValue), $valueArr)) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected'); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $options; } elseif ($uitype == 3313) { require_once 'modules/PickList/PickListUtils.php'; $picklistValues = getAllowedPicklistModules(); $valueArr = explode("|##|", $value); foreach ($valueArr as $key => $value) { $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset)); } $pickcount = 0; if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { if (in_array(trim($pickListValue), $valueArr)) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected'); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); uasort($options, function ($a, $b) { return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1; }); $fieldvalue[] = $options; } elseif ($uitype == 1024) { $options = array(); $arr_evo = explode(' |##| ', $value); $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); $uservalues = array_merge($subrole, array($roleid)); for ($i = 0; $i < sizeof($uservalues); $i++) { $currentValId = $uservalues[$i]; $currentValName = getRoleName($currentValId); if (in_array(trim($currentValId), $arr_evo)) { $chk_val = 'selected'; } else { $chk_val = ''; } $options[] = array($currentValName, $currentValId, $chk_val); } $fieldvalue[] = $options; $editview_label[] = getTranslatedString($fieldlabel, $module_name); } elseif ($uitype == 17) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 85) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 14) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 19 || $uitype == 20) { if (isset($_REQUEST['body'])) { $value = $_REQUEST['body']; } if ($fieldname == 'terms_conditions') { //Assign the value from focus->column_fields (if we create Invoice from SO the SO's terms and conditions will be loaded to Invoice's terms and conditions, etc.,) $value = $col_fields['terms_conditions']; //if the value is empty then only we should get the default Terms and Conditions if ($value == '' && $mode != 'edit') { $value = getTermsandConditions(); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 21 || $uitype == 24) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 22) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 52 || $uitype == 77) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); global $current_user; if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } if ($uitype == 52) { $combo_lbl_name = 'assigned_user_id'; } elseif ($uitype == 77) { $combo_lbl_name = 'assigned_user_id1'; } //Control will come here only for Products - Handler and Quotes - Inventory Manager if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); } $fieldvalue[] = $users_combo; } elseif ($uitype == 53) { global $noof_group_rows; $editview_label[] = getTranslatedString($fieldlabel, $module_name); //Security Checks if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $result = get_current_user_access_groups($module_name); } else { $result = get_group_options(); } if ($result) { $nameArray = $adb->fetch_array($result); } $assigned_user_id = empty($value) ? $current_user->id : $value; if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); } if ($noof_group_rows != 0) { if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); } } $fieldvalue[] = $users_combo; $fieldvalue[] = $groups_combo; } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { if (!isset($_REQUEST['convertmode']) || $_REQUEST['convertmode'] != 'update_quote_val' && $_REQUEST['convertmode'] != 'update_so_val') { if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $value = vtlib_purify($_REQUEST['account_id']); } } if ($value != '') { $account_name = getAccountName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $account_name; $fieldvalue[] = $value; } elseif ($uitype == 54) { $options = array(); $editview_label[] = getTranslatedString($fieldlabel, $module_name); $pick_query = "select * from vtiger_groups"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, "name"); if ($value == $pickListValue) { $chk_val = "selected"; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == 55 || $uitype == 255) { require_once 'modules/PickList/PickListUtils.php'; if ($uitype == 255) { $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'firstname', 'readwrite'); } if ($uitype == 255 && $fieldpermission == '0') { $fieldvalue[] = ''; } else { $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'salutationtype', 'readwrite'); if ($fieldpermission == '0') { $roleid = $current_user->roleid; $picklistValues = getAssignedPicklistValues('salutationtype', $roleid, $adb); $pickcount = 0; $salt_value = $col_fields["salutationtype"]; foreach ($picklistValues as $order => $pickListValue) { if ($salt_value == trim($pickListValue)) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && $salt_value != '') { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $salt_value, 'selected'); } $fieldvalue[] = $options; } else { $fieldvalue[] = ''; } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 59) { if ($_REQUEST['module'] == 'HelpDesk') { if (isset($_REQUEST['product_id']) & $_REQUEST['product_id'] != '') { $value = $_REQUEST['product_id']; } } elseif (isset($_REQUEST['parent_id']) & $_REQUEST['parent_id'] != '') { $value = vtlib_purify($_REQUEST['parent_id']); } if ($value != '') { $product_name = getProductName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $product_name; $fieldvalue[] = $value; } elseif ($uitype == 63) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); if ($value == '') { $value = 1; } $options = array(); $pick_query = "select * from vtiger_duration_minutes order by sortorderid"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); $salt_value = $col_fields["duration_minutes"]; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, "duration_minutes"); if ($salt_value == $pickListValue) { $chk_val = "selected"; } else { $chk_val = ''; } $options[$pickListValue] = $chk_val; } $fieldvalue[] = $value; $fieldvalue[] = $options; } elseif ($uitype == 64) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); $fieldvalue[] = $value; } elseif ($uitype == 156) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; $fieldvalue[] = $is_admin; } elseif ($uitype == 56) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 57) { if ($value != '') { $displayValueArray = getEntityName('Contacts', $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } } elseif (isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') { if ($_REQUEST['module'] == 'Contacts' && ($fieldname = 'contact_id')) { $contact_name = ''; } else { $value = $_REQUEST['contact_id']; $displayValueArray = getEntityName('Contacts', $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } } } //Checking for contacts duplicate $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $contact_name; $fieldvalue[] = $value; } elseif ($uitype == 58) { if ($value != '') { $campaign_name = getCampaignName($value); } elseif (isset($_REQUEST['campaignid']) && $_REQUEST['campaignid'] != '') { if ($_REQUEST['module'] == 'Campaigns' && ($fieldname = 'campaignid')) { $campaign_name = ''; } else { $value = $_REQUEST['campaignid']; $campaign_name = getCampaignName($value); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $campaign_name; $fieldvalue[] = $value; } elseif ($uitype == 61) { if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } if ($module_name == 'Emails' && $col_fields['record_id'] != '') { $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])); //to fix the issue in mail attachment on forwarding mails if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') { global $att_id_list; } for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) { $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid'); if ($attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); if ($attachmentsname != '') { $fieldvalue[$attachmentid] = '[ ' . $attachmentsname . ' ]'; } if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') { $att_id_list .= $attachmentid . ';'; } } } } else { if ($col_fields['record_id'] != '') { $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } } if ($value != '') { $filename = ' [ ' . $value . ' ]'; } if ($filename != '') { $fieldvalue[] = $filename; } if ($value != '') { $fieldvalue[] = $value; } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); } elseif ($uitype == 28) { if ($col_fields['record_id'] != '') { $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } } if ($value != '' && $module_name != 'Documents') { $filename = ' [ ' . $value . ' ]'; } elseif ($value != '' && $module_name == 'Documents') { $filename = $value; } if ($filename != '') { $fieldvalue[] = $filename; } if ($value != '') { $fieldvalue[] = $value; } $editview_label[] = getTranslatedString($fieldlabel, $module_name); } elseif ($uitype == 69) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); if ($col_fields['record_id'] != "") { if ($module_name == 'Products') { $query = 'select vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name ,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?'; $params = array($col_fields['record_id']); } else { if ($module_name == 'Contacts') { $imageattachment = 'Image'; } else { $imageattachment = 'Attachment'; } $query = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t\t from vtiger_attachments\n\t\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid\n\t\t\t\t where vtiger_crmentity.setype='{$module_name} {$imageattachment}'\n\t\t\t\t and vtiger_attachments.name = ?\n\t\t\t\t and vtiger_seattachmentsrel.crmid=?"; $params = array($col_fields[$fieldname], $col_fields['record_id']); } $result_image = $adb->pquery($query, $params); for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) { $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid'); //decode_html - added to handle UTF-8 characters in file names //urlencode - added to handle special characters like #, %, etc., $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name'))); $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name')); $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path'); } if (is_array($image_array)) { for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) { $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr] . $image_id_array[$img_itr] . "_", "orgname" => $image_orgname_array[$img_itr]); } } else { $fieldvalue[] = ''; } } else { $fieldvalue[] = ''; } } elseif ($uitype == 62) { if (isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') { $value = vtlib_purify($_REQUEST['parent_id']); } if ($value != '') { $parent_module = getSalesEntityType($value); } if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $parent_module = "Accounts"; $value = $_REQUEST['account_id']; } if ($parent_module != 'Contacts') { if ($parent_module == "Leads") { $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $parent_name = $field_value; } } $lead_selected = "selected"; } elseif ($parent_module == "Accounts") { $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "accountname"); $account_selected = "selected"; } elseif ($parent_module == "Potentials") { $sql = "select * from vtiger_potential where potentialid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "potentialname"); $potential_selected = "selected"; } elseif ($parent_module == "Products") { $sql = "select * from vtiger_products where productid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "productname"); $product_selected = "selected"; } elseif ($parent_module == "PurchaseOrder") { $sql = "select * from vtiger_purchaseorder where purchaseorderid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $porder_selected = "selected"; } elseif ($parent_module == "SalesOrder") { $sql = "select * from vtiger_salesorder where salesorderid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $sorder_selected = "selected"; } elseif ($parent_module == "Invoice") { $sql = "select * from vtiger_invoice where invoiceid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $invoice_selected = "selected"; } elseif ($parent_module == "Quotes") { $sql = "select * from vtiger_quotes where quoteid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $quote_selected = "selected"; } elseif ($parent_module == "HelpDesk") { $sql = "select * from vtiger_troubletickets where ticketid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "title"); $ticket_selected = "selected"; } } $editview_label[] = array($app_strings['COMBO_LEADS'], $app_strings['COMBO_ACCOUNTS'], $app_strings['COMBO_POTENTIALS'], $app_strings['COMBO_PRODUCTS'], $app_strings['COMBO_INVOICES'], $app_strings['COMBO_PORDER'], $app_strings['COMBO_SORDER'], $app_strings['COMBO_QUOTES'], $app_strings['COMBO_HELPDESK']); $editview_label[] = array($lead_selected, $account_selected, $potential_selected, $product_selected, $invoice_selected, $porder_selected, $sorder_selected, $quote_selected, $ticket_selected); $editview_label[] = array("Leads&action=Popup", "Accounts&action=Popup", "Potentials&action=Popup", "Products&action=Popup", "Invoice&action=Popup", "PurchaseOrder&action=Popup", "SalesOrder&action=Popup", "Quotes&action=Popup", "HelpDesk&action=Popup"); $fieldvalue[] = $parent_name; $fieldvalue[] = $value; } elseif ($uitype == 66) { if (!empty($_REQUEST['parent_id'])) { $value = vtlib_purify($_REQUEST['parent_id']); } if (!empty($value)) { $parent_module = getSalesEntityType($value); if ($parent_module != "Contacts") { $entity_names = getEntityName($parent_module, $value); $parent_name = $entity_names[$value]; $fieldvalue[] = $parent_name; $fieldvalue[] = $value; } } // Check for vtiger_activity type if task orders to be added in select option $act_mode = $_REQUEST['activity_mode']; $parentModulesList = array('Leads' => $app_strings['COMBO_LEADS'], 'Accounts' => $app_strings['COMBO_ACCOUNTS'], 'Potentials' => $app_strings['COMBO_POTENTIALS'], 'HelpDesk' => $app_strings['COMBO_HELPDESK'], 'Campaigns' => $app_strings['COMBO_CAMPAIGNS'], 'Vendors' => $app_strings['COMBO_VENDORS']); if ($act_mode == "Task") { $parentModulesList['Quotes'] = $app_strings['COMBO_QUOTES']; $parentModulesList['PurchaseOrder'] = $app_strings['COMBO_PORDER']; $parentModulesList['SalesOrder'] = $app_strings['COMBO_SORDER']; $parentModulesList['Invoice'] = $app_strings['COMBO_INVOICES']; } $parentModuleNames = array_keys($parentModulesList); $parentModuleLabels = array_values($parentModulesList); $editview_label[0] = $parentModuleLabels; $editview_label[1] = array_fill(0, count($parentModulesList), ''); $selectedModuleIndex = array_search($parent_module, $parentModuleNames); if ($selectedModuleIndex > -1) { $editview_label[1][$selectedModuleIndex] = 'selected'; } $parentModulePopupUrl = array(); foreach ($parentModuleNames as $parentModule) { $parentModulePopupUrl[] = $parentModule . '&action=Popup'; } $editview_label[2] = $parentModulePopupUrl; } elseif ($uitype == 357) { $pmodule = $_REQUEST['pmodule']; if (empty($pmodule)) { $pmodule = $_REQUEST['par_module']; } if ($pmodule == 'Contacts') { $contact_selected = 'selected'; } elseif ($pmodule == 'Accounts') { $account_selected = 'selected'; } elseif ($pmodule == 'Leads') { $lead_selected = 'selected'; } elseif ($pmodule == 'Vendors') { $vendor_selected = 'selected'; } elseif ($pmodule == 'Users') { $user_selected = 'selected'; } elseif ($pmodule == 'Project') { $project_selected = 'selected'; } elseif ($pmodule == 'ProjectTask') { $projecttask_selected = 'selected'; } elseif ($pmodule == 'Potentials') { $potentials_selected = 'selected'; } elseif ($pmodule == 'HelpDesk') { $helpdesk_selected = 'selected'; } if (isset($_REQUEST['emailids']) && $_REQUEST['emailids'] != '') { $parent_id = $_REQUEST['emailids']; $parent_name = ''; $myids = explode("|", $parent_id); for ($i = 0; $i < count($myids) - 1; $i++) { $realid = explode("@", $myids[$i]); $entityid = $realid[0]; $nemail = count($realid); if ($pmodule == 'Accounts') { require_once 'modules/Accounts/Accounts.php'; $myfocus = new Accounts(); $myfocus->retrieve_entity_info($entityid, "Accounts"); $fullname = br2nl($myfocus->column_fields['accountname']); $account_selected = 'selected'; } elseif ($pmodule == 'Contacts') { require_once 'modules/Contacts/Contacts.php'; $myfocus = new Contacts(); $myfocus->retrieve_entity_info($entityid, "Contacts"); $fname = br2nl($myfocus->column_fields['firstname']); $lname = br2nl($myfocus->column_fields['lastname']); $fullname = $lname . ' ' . $fname; $contact_selected = 'selected'; } elseif ($pmodule == 'Leads') { require_once 'modules/Leads/Leads.php'; $myfocus = new Leads(); $myfocus->retrieve_entity_info($entityid, "Leads"); $fname = br2nl($myfocus->column_fields['firstname']); $lname = br2nl($myfocus->column_fields['lastname']); $fullname = $lname . ' ' . $fname; $lead_selected = 'selected'; } elseif ($pmodule == 'Project') { require_once 'modules/Project/Project.php'; $myfocus = new Project(); $myfocus->retrieve_entity_info($entityid, "Project"); $fname = br2nl($myfocus->column_fields['projectname']); $lname = br2nl($myfocus->column_fields['projectid']); $fullname = $fname; $project_selected = 'selected'; } elseif ($pmodule == 'ProjectTask') { require_once 'modules/ProjectTask/ProjectTask.php'; $myfocus = new ProjectTask(); $myfocus->retrieve_entity_info($entityid, "ProjectTask"); $fname = br2nl($myfocus->column_fields['projecttaskname']); $lname = br2nl($myfocus->column_fields['projecttaskid']); $fullname = $fname; $projecttask_selected = 'selected'; } elseif ($pmodule == 'Potentials') { require_once 'modules/Potentials/Potentials.php'; $myfocus = new Potentials(); $myfocus->retrieve_entity_info($entityid, "Potentials"); $fname = br2nl($myfocus->column_fields['potentialname']); $lname = br2nl($myfocus->column_fields['potentialid']); $fullname = $fname; $potentials_selected = 'selected'; } elseif ($pmodule == 'HelpDesk') { require_once 'modules/HelpDesk/HelpDesk.php'; $myfocus = new HelpDesk(); $myfocus->retrieve_entity_info($entityid, "HelpDesk"); $fname = br2nl($myfocus->column_fields['title']); $lname = br2nl($myfocus->column_fields['ticketid']); $fullname = $fname; $helpdesk_selected = 'selected'; } for ($j = 1; $j < $nemail; $j++) { $querystr = 'select columnname from vtiger_field where fieldid=? and vtiger_field.presence in (0,2)'; $result = $adb->pquery($querystr, array($realid[$j])); $temp = $adb->query_result($result, 0, 'columnname'); $temp1 = br2nl($myfocus->column_fields[$temp]); //Modified to display the entities in red which don't have email id if (!empty($temp_parent_name) && strlen($temp_parent_name) > 150) { $parent_name .= '<br>'; $temp_parent_name = ''; } if ($temp1 != '') { $parent_name .= $fullname . '<' . $temp1 . '>; '; $temp_parent_name .= $fullname . '<' . $temp1 . '>; '; } else { $parent_name .= "<b style='color:red'>" . $fullname . '<' . $temp1 . '>; ' . "</b>"; $temp_parent_name .= "<b style='color:red'>" . $fullname . '<' . $temp1 . '>; ' . "</b>"; } } } } else { if ($_REQUEST['record'] != '' && $_REQUEST['record'] != NULL) { $parent_name = ''; $parent_id = ''; $myemailid = $_REQUEST['record']; $mysql = "select crmid from vtiger_seactivityrel where activityid=?"; $myresult = $adb->pquery($mysql, array($myemailid)); $mycount = $adb->num_rows($myresult); if ($mycount > 0) { for ($i = 0; $i < $mycount; $i++) { $mycrmid = $adb->query_result($myresult, $i, 'crmid'); $parent_module = getSalesEntityType($mycrmid); if ($parent_module == "Leads") { $sql = "select firstname,lastname,email from vtiger_leaddetails where leadid=?"; $result = $adb->pquery($sql, array($mycrmid)); $full_name = getFullNameFromQResult($result, 0, "Leads"); $myemail = $adb->query_result($result, 0, "email"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $full_name . '<' . $myemail . '>; '; $lead_selected = 'selected'; } elseif ($parent_module == "Contacts") { $sql = "select * from vtiger_contactdetails where contactid=?"; $result = $adb->pquery($sql, array($mycrmid)); $full_name = getFullNameFromQResult($result, 0, "Contacts"); $myemail = $adb->query_result($result, 0, "email"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $full_name . '<' . $myemail . '>; '; $contact_selected = 'selected'; } elseif ($parent_module == "Accounts") { $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($mycrmid)); $account_name = $adb->query_result($result, 0, "accountname"); $myemail = $adb->query_result($result, 0, "email1"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $account_name . '<' . $myemail . '>; '; $account_selected = 'selected'; } elseif ($parent_module == "Users") { $sql = "select user_name,email1 from vtiger_users where id=?"; $result = $adb->pquery($sql, array($mycrmid)); $account_name = $adb->query_result($result, 0, "user_name"); $myemail = $adb->query_result($result, 0, "email1"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $account_name . '<' . $myemail . '>; '; $user_selected = 'selected'; } elseif ($parent_module == "Vendors") { $sql = "select * from vtiger_vendor where vendorid=?"; $result = $adb->pquery($sql, array($mycrmid)); $vendor_name = $adb->query_result($result, 0, "vendorname"); $myemail = $adb->query_result($result, 0, "email"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $vendor_name . '<' . $myemail . '>; '; $vendor_selected = 'selected'; } } } } $custfld .= '<td width="20%" class="dataLabel">' . $app_strings['To'] . ' </td>'; $custfld .= '<td width="90%" colspan="3"><input name="parent_id" type="hidden" value="' . $parent_id . '"><textarea readonly name="parent_name" cols="70" rows="2">' . $parent_name . '</textarea> <select name="parent_type" >'; $custfld .= '<OPTION value="Contacts" selected>' . $app_strings['COMBO_CONTACTS'] . '</OPTION>'; $custfld .= '<OPTION value="Accounts" >' . $app_strings['COMBO_ACCOUNTS'] . '</OPTION>'; $custfld .= '<OPTION value="Leads" >' . $app_strings['COMBO_LEADS'] . '</OPTION>'; $custfld .= '<OPTION value="Vendors" >' . $app_strings['COMBO_VENDORS'] . '</OPTION></select><img src="' . vtiger_imageurl('select.gif', $theme) . '" alt="Select" title="Select" LANGUAGE=javascript onclick=\'$log->debug("Exiting getOutputHtml method ..."); return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&popuptype=set_$log->debug("Exiting getOutputHtml method ..."); return_emails&form=EmailEditView&form_submit=false","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");\' align="absmiddle" style=\'cursor:hand;cursor:pointer\'> <input type="image" src="' . vtiger_imageurl('clear_field.gif', $theme) . '" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=\'\';this.form.parent_name.value=\'\';$log->debug("Exiting getOutputHtml method ..."); return false;" align="absmiddle" style=\'cursor:hand;cursor:pointer\'></td>'; $editview_label[] = array('Contacts' => $contact_selected, 'Accounts' => $account_selected, 'Vendors' => $vendor_selected, 'Leads' => $lead_selected, 'Users' => $user_selected); $fieldvalue[] = $parent_name; $fieldvalue[] = $parent_id; } } elseif ($uitype == 68) { if (empty($value) && isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') { $value = vtlib_purify($_REQUEST['parent_id']); } if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Contacts") { $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $parent_name = $field_value; } } $contact_selected = "selected"; } elseif ($parent_module == "Accounts") { $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "accountname"); $account_selected = "selected"; } else { $parent_name = ""; $value = ""; } } $editview_label[0] = array(); $editview_label[1] = array(); $editview_label[2] = array(); if (vtlib_isModuleActive('Accounts')) { array_push($editview_label[0], $app_strings['COMBO_ACCOUNTS']); array_push($editview_label[1], $account_selected); array_push($editview_label[2], "Accounts"); } if (vtlib_isModuleActive('Contacts')) { array_push($editview_label[0], $app_strings['COMBO_CONTACTS']); array_push($editview_label[1], $contact_selected); array_push($editview_label[2], "Contacts"); } $fieldvalue[] = $parent_name; $fieldvalue[] = $value; } elseif ($uitype == 9 || $uitype == 7) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fldrs = $adb->pquery('select typeofdata from vtiger_field where vtiger_field.fieldname=? and vtiger_field.tabid=?', array($fieldname, getTabid($module_name))); $typeofdata = $adb->query_result($fldrs, 0, 0); $typeinfo = explode('~', $typeofdata); if ($typeinfo[0] == 'I') { $fieldvalue[] = $value; } else { $currencyField = new CurrencyField($value); $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata); $currencyField->initialize($current_user); $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces())); $fieldvalue[] = $currencyField->getDisplayValue(null, false, true); } } elseif ($uitype == 71 || $uitype == 72) { $currencyField = new CurrencyField($value); // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($col_fields['record_id'] != '' && $uitype == 72) { if ($fieldname == 'unit_price') { $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module_name)); $currencySymbol = $rate_symbol['symbol']; } else { $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']); $currencySymbol = $currency_info['currency_symbol']; } $fieldvalue[] = $currencyField->getDisplayValue(null, true); } else { $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata); $currencyField->initialize($current_user); $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces())); $fieldvalue[] = $currencyField->getDisplayValue(null, false, true); $currencySymbol = $currencyField->getCurrencySymbol(); } $editview_label[] = getTranslatedString($fieldlabel, $module_name) . ': (' . $currencySymbol . ')'; } elseif ($uitype == 75 || $uitype == 81) { if ($value != '') { $vendor_name = getVendorName($value); } elseif (isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id'] != '') { $value = $_REQUEST['vendor_id']; $vendor_name = getVendorName($value); } $pop_type = 'specific'; if ($uitype == 81) { $pop_type = 'specific_vendor_address'; } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $vendor_name; $fieldvalue[] = $value; } elseif ($uitype == 76) { if ($value != '') { $potential_name = getPotentialName($value); } elseif (isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') { $value = $_REQUEST['potental_id']; $potential_name = getPotentialName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $potential_name; $fieldvalue[] = $value; } elseif ($uitype == 78) { if ($value != '') { $quote_name = getQuoteName($value); } elseif (isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '') { $value = $_REQUEST['quote_id']; $potential_name = getQuoteName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $quote_name; $fieldvalue[] = $value; } elseif ($uitype == 79) { if ($value != '') { $purchaseorder_name = getPoName($value); } elseif (isset($_REQUEST['purchaseorder_id']) && $_REQUEST['purchaseorder_id'] != '') { $value = $_REQUEST['purchaseorder_id']; $purchaseorder_name = getPoName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $purchaseorder_name; $fieldvalue[] = $value; } elseif ($uitype == 80) { if ($value != '') { $salesorder_name = getSoName($value); } elseif (isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') { $value = $_REQUEST['salesorder_id']; $salesorder_name = getSoName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $salesorder_name; $fieldvalue[] = $value; } elseif ($uitype == 30) { $rem_days = 0; $rem_hrs = 0; $rem_min = 0; if ($value != '') { $SET_REM = 'CHECKED'; } else { $SET_REM = ''; } $rem_days = floor($col_fields[$fieldname] / (24 * 60)); $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60); $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60; $editview_label[] = getTranslatedString($fieldlabel, $module_name); $day_options = getReminderSelectOption(0, 31, 'remdays', $rem_days); $hr_options = getReminderSelectOption(0, 23, 'remhrs', $rem_hrs); $min_options = getReminderSelectOption(10, 59, 'remmin', $rem_min); $fieldvalue[] = array(array(0, 32, 'remdays', getTranslatedString('LBL_DAYS', 'Calendar'), $rem_days), array(0, 24, 'remhrs', getTranslatedString('LBL_HOURS', 'Calendar'), $rem_hrs), array(10, 60, 'remmin', getTranslatedString('LBL_MINUTES', 'Calendar') . ' ' . getTranslatedString('LBL_BEFORE_EVENT', 'Calendar'), $rem_min)); $fieldvalue[] = array($SET_REM, getTranslatedString('LBL_YES'), getTranslatedString('LBL_NO')); $SET_REM = ''; } elseif ($uitype == 115) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname); $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname)); if ($value == $pickListValue) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } $fieldvalue[] = $options; $fieldvalue[] = $is_admin; } elseif ($uitype == 116 || $uitype == 117) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name'); $currency_id = $adb->query_result($pickListResult, $j, 'id'); if ($value == $currency_id) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[$currency_id] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; $fieldvalue[] = $is_admin; } elseif ($uitype == 98) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; $fieldvalue[] = getRoleName($value); $fieldvalue[] = $is_admin; } elseif ($uitype == 105) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); if (isset($col_fields['record_id']) && $col_fields['record_id'] != '') { $query = "select vtiger_attachments.path, vtiger_attachments.name from vtiger_contactdetails left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_contactdetails.contactid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where vtiger_contactdetails.imagename=vtiger_attachments.name and contactid=?"; $result_image = $adb->pquery($query, array($col_fields['record_id'])); for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) { $image_array[] = $adb->query_result($result_image, $image_iter, 'name'); $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path'); } } if (is_array($image_array)) { for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) { $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr]); } } else { $fieldvalue[] = ''; } } elseif ($uitype == 101) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = getOwnerName($value); $fieldvalue[] = $value; } elseif ($uitype == 26) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $folderid = $col_fields['folderid']; $foldername_query = 'select foldername from vtiger_attachmentsfolder where folderid = ?'; $res = $adb->pquery($foldername_query, array($folderid)); $foldername = $adb->query_result($res, 0, 'foldername'); if ($foldername != '' && $folderid != '') { $fldr_name[$folderid] = $foldername; } $sql = "select foldername,folderid from vtiger_attachmentsfolder order by foldername"; $res = $adb->pquery($sql, array()); for ($i = 0; $i < $adb->num_rows($res); $i++) { $fid = $adb->query_result($res, $i, "folderid"); $fldr_name[$fid] = $adb->query_result($res, $i, "foldername"); } $fieldvalue[] = $fldr_name; } elseif ($uitype == 27) { if ($value == 'E') { $external_selected = "selected"; $filename = $col_fields['filename']; } else { $internal_selected = "selected"; $filename = $col_fields['filename']; } $editview_label[] = array(getTranslatedString('Internal'), getTranslatedString('External')); $editview_label[] = array($internal_selected, $external_selected); $editview_label[] = array("I", "E"); $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; $fieldvalue[] = $filename; } elseif ($uitype == '31') { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $options = array(); $themeList = get_themes(); foreach ($themeList as $theme) { if ($value == $theme) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($theme), $theme, $selected); } $fieldvalue[] = $options; } elseif ($uitype == '32') { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $options = array(); $languageList = Vtiger_Language::getAll(); foreach ($languageList as $prefix => $label) { if ($value == $prefix) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($label), $prefix, $selected); } $fieldvalue[] = $options; } else { //Added condition to set the subject if click Reply All from web mail if ($_REQUEST['module'] == 'Emails' && $_REQUEST['mg_subject'] != '') { $value = $_REQUEST['mg_subject']; } $editview_label[] = getTranslatedString($fieldlabel, $module_name); if ($fieldname == 'fileversion') { if (empty($value)) { $value = ''; } else { $fieldvalue[] = $value; } } else { $fieldvalue[] = $value; } } } // Mike Crowe Mod --------------------------------------------------------force numerics right justified. if (!preg_match("/id=/i", $custfld)) { $custfld = preg_replace("/<input/iS", "<input id='{$fieldname}' ", $custfld); } if (in_array($uitype, array(71, 72, 7, 9, 90))) { $custfld = preg_replace("/<input/iS", "<input align=right ", $custfld); } $final_arr[] = $ui_type; $final_arr[] = $editview_label; $final_arr[] = $editview_fldname; $final_arr[] = $fieldvalue; $type_of_data = explode('~', $typeofdata); $final_arr[] = $type_of_data[1]; $log->debug('Exiting getOutputHtml method ...'); return $final_arr; }
} if ($npcid != '' && $npcid != 'ID' && $editor != 'altcur' && $editor != 'qglobal') { $breadcrumbs .= " >> " . getNPCName($npcid) . " ({$npcid})"; } if ($fid != '') { $breadcrumbs .= " >> " . getFactionName($fid); } if ($tskid != '') { $breadcrumbs .= " >> " . getTaskTitle($tskid); } if ($ts != '') { $breadcrumbs .= " >> " . "<a href='index.php?editor=" . $editor . "&ts=" . $ts . "'>" . $tradeskills[$ts] . "</a>"; } if ($rec != '0') { $breadcrumbs .= " >> " . getRecipeName($rec); } if ($spellset != '') { $breadcrumbs .= " >> " . getSpellsetName($spellset); } if ($playerid != '' && $playerid != 'Player ID') { $breadcrumbs .= " >> <a href='index.php?editor=" . $editor . "&playerid=" . $playerid . "'>" . getPlayerName($playerid) . " ({$playerid})</a>"; } if ($acctid != '') { $breadcrumbs .= " >> " . getAccountName($acctid) . " ({$acctid})"; } if ($guildid != '') { $breadcrumbs .= " >> " . getGuildName($guildid) . " ({$guildid})"; } if ($aaid != '') { $breadcrumbs .= " >> " . getAAName($aaid) . " ({$aaid})"; }
function getValue($field_result, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, $mode, $popuptype, $returnset = '', $viewid = '') { global $log, $listview_max_textlength, $app_strings, $current_language, $currentModule; $log->debug("Entering getValue(" . $field_result . "," . $list_result . "," . $fieldname . "," . get_class($focus) . "," . $module . "," . $entity_id . "," . $list_result_count . "," . $mode . "," . $popuptype . "," . $returnset . "," . $viewid . ") method ..."); global $adb, $current_user, $default_charset; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $tabname = getParentTab(); $tabid = getTabid($module); $current_module_strings = return_module_language($current_language, $module); $uicolarr = $field_result[$fieldname]; foreach ($uicolarr as $key => $value) { $uitype = $key; $colname = $value; } //added for getting event status in Custom view - Jaguar if ($module == 'Calendar' && ($colname == "status" || $colname == "eventstatus")) { $colname = "activitystatus"; } //Ends $field_val = $adb->query_result($list_result, $list_result_count, $colname); if (stristr(html_entity_decode($field_val), "<a href") === false && $uitype != 8) { $temp_val = textlength_check($field_val); } elseif ($uitype != 8) { $temp_val = html_entity_decode($field_val, ENT_QUOTES); } else { $temp_val = $field_val; } // vtlib customization: New uitype to handle relation between modules if ($uitype == '10') { $parent_id = $field_val; if (!empty($parent_id)) { $parent_module = getSalesEntityType($parent_id); $valueTitle = $parent_module; if ($app_strings[$valueTitle]) { $valueTitle = $app_strings[$valueTitle]; } $displayValueArray = getEntityName($parent_module, $parent_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $value) { $displayValue = $value; } } $value = "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>"; } else { $value = ''; } } else { if ($uitype == 53) { $value = textlength_check($adb->query_result($list_result, $list_result_count, 'user_name')); // When Assigned To field is used in Popup window if ($value == '') { $user_id = $adb->query_result($list_result, $list_result_count, 'smownerid'); if ($user_id != null && $user_id != '') { $value = getOwnerName($user_id); } } } elseif ($uitype == 52) { $value = getUserName($adb->query_result($list_result, $list_result_count, $colname)); } elseif ($uitype == 51) { $parentid = $adb->query_result($list_result, $list_result_count, "parentid"); if ($module == 'Accounts') { $entity_name = textlength_check(getAccountName($parentid)); } elseif ($module == 'Products') { $entity_name = textlength_check(getProductName($parentid)); } $value = '<a href="index.php?module=' . $module . '&action=DetailView&record=' . $parentid . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $entity_name . '</a>'; } elseif ($uitype == 77) { $value = getUserName($adb->query_result($list_result, $list_result_count, 'inventorymanager')); } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) { if ($temp_val != '' && $temp_val != '0000-00-00') { $value = getDisplayDate($temp_val); } elseif ($temp_val == '0000-00-00') { $value = ''; } else { $value = $temp_val; } } elseif ($uitype == 15 || $uitype == 55 && $fieldname == "salutationtype") { $temp_val = decode_html($adb->query_result($list_result, $list_result_count, $colname)); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $temp_val != '') { $temp_acttype = $adb->query_result($list_result, $list_result_count, 'activitytype'); if ($temp_acttype != 'Task' && $fieldname == "taskstatus") { $temptable = "eventstatus"; } else { $temptable = $fieldname; } $roleid = $current_user->roleid; $roleids = array(); $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; } array_push($roleids, $roleid); //here we are checking wheather the table contains the sortorder column .If sortorder is present in the main picklist table, then the role2picklist will be applicable for this table... $sql = "select * from vtiger_{$temptable} where {$temptable}=?"; $res = $adb->pquery($sql, array(decode_html($temp_val))); $picklistvalueid = $adb->query_result($res, 0, 'picklist_valueid'); if ($picklistvalueid != null) { $pick_query = "select * from vtiger_role2picklist where picklistvalueid={$picklistvalueid} and roleid in (" . generateQuestionMarks($roleids) . ")"; $res_val = $adb->pquery($pick_query, array($roleids)); $num_val = $adb->num_rows($res_val); } if ($num_val > 0 || $temp_acttype == 'Task' && $fieldname == 'activitytype') { $temp_val = $temp_val; } else { $temp_val = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; } } $value = $current_module_strings[$temp_val] != '' ? $current_module_strings[$temp_val] : ($app_strings[$temp_val] != '' ? $app_strings[$temp_val] : $temp_val); if ($value != "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>") { $value = textlength_check($value); } } elseif ($uitype == 16) { $value = getTranslatedString($temp_val, $currentModule); } elseif ($uitype == 71 || $uitype == 72) { if ($temp_val != '') { if ($fieldname == 'unit_price') { $currency_id = getProductBaseCurrency($entity_id, $module); $cursym_convrate = getCurrencySymbolandCRate($currency_id); $value = "<font style='color:grey;'>" . $cursym_convrate['symbol'] . "</font> " . $temp_val; } else { $rate = $user_info['conv_rate']; //changes made to remove vtiger_currency symbol infront of each vtiger_potential amount if ($temp_val != 0) { $value = convertFromDollar($temp_val, $rate); } else { $value = $temp_val; } } } else { $value = ''; } } elseif ($uitype == 17) { $value = '<a href="http://' . $field_val . '" target="_blank">' . $temp_val . '</a>'; } elseif ($uitype == 13 || $uitype == 104 && ($_REQUEST['action'] != 'Popup' && $_REQUEST['file'] != 'Popup')) { if ($_SESSION['internal_mailer'] == 1) { //check added for email link in user detailview if ($module == 'Calendar') { if (getActivityType($entity_id) == 'Task') { $tabid = 9; } else { $tabid = 16; } } else { $tabid = getTabid($module); } $fieldid = getFieldid($tabid, $fieldname); if (empty($popuptype)) { $value = '<a href="javascript:InternalMailer(' . $entity_id . ',' . $fieldid . ',\'' . $fieldname . '\',\'' . $module . '\',\'record_id\');">' . $temp_val . '</a>'; } else { $value = $temp_val; } } else { $value = '<a href="mailto:' . $field_val . '">' . $temp_val . '</a>'; } } elseif ($uitype == 56) { if ($temp_val == 1) { $value = $app_strings['yes']; } elseif ($temp_val == 0) { $value = $app_strings['no']; } else { $value = ''; } } elseif ($uitype == 57) { if ($temp_val != '') { $sql = "SELECT * FROM vtiger_contactdetails WHERE contactid=?"; $result = $adb->pquery($sql, array($temp_val)); $value = ''; if ($adb->num_rows($result)) { $name = getFullNameFromQResult($result, 0, "Contacts"); $value = '<a href=index.php?module=Contacts&action=DetailView&record=' . $temp_val . '>' . $name . '</a>'; } } else { $value = ''; } } elseif ($uitype == 58) { if ($temp_val != '') { $sql = "SELECT * FROM vtiger_campaign WHERE campaignid=?"; $result = $adb->pquery($sql, array($temp_val)); $campaignname = $adb->query_result($result, 0, "campaignname"); $value = '<a href=index.php?module=Campaigns&action=DetailView&record=' . $temp_val . '>' . $campaignname . '</a>'; } else { $value = ''; } } elseif ($uitype == 59) { if ($temp_val != '') { $value = getProductName($temp_val); } else { $value = ''; } } elseif ($uitype == 61) { $attachmentid = $adb->query_result($adb->pquery("SELECT * FROM vtiger_seattachmentsrel WHERE crmid = ?", array($entity_id)), 0, 'attachmentsid'); $value = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $module . '&fileid=' . $attachmentid . '&filename=' . $temp_val . '">' . $temp_val . '</a>'; } elseif ($uitype == 62) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parenttype == "Products") { $tablename = "vtiger_products"; $fieldname = "productname"; $idname = "productid"; } if ($parenttype == "HelpDesk") { $tablename = "vtiger_troubletickets"; $fieldname = "title"; $idname = "ticketid"; } if ($parenttype == "Invoice") { $tablename = "vtiger_invoice"; $fieldname = "subject"; $idname = "invoiceid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 66) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parenttype == "HelpDesk") { $tablename = "vtiger_troubletickets"; $fieldname = "title"; $idname = "ticketid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 67) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Contacts") { $tablename = "vtiger_contactdetails"; $fieldname = "contactname"; $idname = "contactid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 68) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == '' && $parentid != '') { $parenttype = getSalesEntityType($parentid); } if ($parenttype == "Contacts") { $tablename = "vtiger_contactdetails"; $fieldname = "contactname"; $idname = "contactid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 78) { if ($temp_val != '') { $quote_name = getQuoteName($temp_val); $value = '<a href=index.php?module=Quotes&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($quote_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 79) { if ($temp_val != '') { $purchaseorder_name = getPoName($temp_val); $value = '<a href=index.php?module=PurchaseOrder&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($purchaseorder_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 80) { if ($temp_val != '') { $salesorder_name = getSoName($temp_val); $value = "<a href=index.php?module=SalesOrder&action=DetailView&record={$temp_val}&parenttab=" . urlencode($tabname) . ">" . textlength_check($salesorder_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 75 || $uitype == 81) { if ($temp_val != '') { $vendor_name = getVendorName($temp_val); $value = '<a href=index.php?module=Vendors&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($vendor_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 98) { $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=Settings&roleid=' . $temp_val . '">' . textlength_check(getRoleName($temp_val)) . '</a>'; } elseif ($uitype == 33) { $value = $temp_val != "" ? str_ireplace(' |##| ', ', ', $temp_val) : ""; if (!$is_admin && $value != '') { $value = $field_val != "" ? str_ireplace(' |##| ', ', ', $field_val) : ""; if ($value != '') { $value_arr = explode(',', trim($value)); $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; array_push($roleids, $roleid); } else { $roleids = $roleid; } if (count($roleids) > 0) { $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where roleid in (" . generateQuestionMarks($roleids) . ") and picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc"; $params = array($roleids); } else { $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc"; $params = array(); } $pickListResult = $adb->pquery($pick_query, $params); $picklistval = array(); for ($i = 0; $i < $adb->num_rows($pickListResult); $i++) { $picklistarr[] = $adb->query_result($pickListResult, $i, $fieldname); } $value_temp = array(); $string_temp = ''; $str_c = 0; foreach ($value_arr as $ind => $val) { $notaccess = '<font color="red">' . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $string_temp)) > $listview_max_textlength)) { $value_temp1 = in_array(trim($val), $picklistarr) ? $val : $notaccess; if ($str_c != 0) { $string_temp .= ' , '; } $string_temp .= $value_temp1; $str_c++; } else { $string_temp .= '...'; } } $value = $string_temp; } } } elseif ($uitype == 85) { $value = $temp_val != "" ? "<a href='skype:{$temp_val}?call'>{$temp_val}</a>" : ""; } elseif ($uitype == 116) { $value = $temp_val != "" ? getCurrencyName($temp_val) : ""; } elseif ($uitype == 117) { // NOTE: Without symbol the value could be used for filtering/lookup hence avoiding the translation $value = $temp_val != "" ? getCurrencyName($temp_val, false) : ""; } elseif ($uitype == 26) { $sql = "select foldername from vtiger_attachmentsfolder where folderid = ?"; $res = $adb->pquery($sql, array($temp_val)); $foldername = $adb->query_result($res, 0, 'foldername'); $value = $foldername; } elseif ($uitype == 11) { // Fix added for Trac Id: 6139 if (vtlib_isModuleActive('PBXManager')) { $value = "<a href='javascript:;' onclick='startCall("{$temp_val}", "{$entity_id}")'>" . $temp_val . "</a>"; } else { $value = $temp_val; } } elseif ($uitype == 25) { $contactid = $_REQUEST['record']; $emailid = $adb->query_result($list_result, $list_result_count, "activityid"); $result = $adb->pquery("SELECT access_count FROM vtiger_email_track WHERE crmid=? AND mailid=?", array($contactid, $emailid)); $value = $adb->query_result($result, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($uitype == 8) { if (!empty($temp_val)) { $temp_val = html_entity_decode($temp_val, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } else { if ($fieldname == $focus->list_link_field) { if ($mode == "search") { if ($popuptype == "specific" || $popuptype == "toDospecific") { // Added for get the first name of contact in Popup window if ($colname == "lastname" && $module == 'Contacts') { $temp_val = getFullNameFromQResult($list_result, $list_result_count, "Contacts"); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); //Added to avoid the error when select SO from Invoice through AjaxEdit if ($module == 'SalesOrder') { $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '","' . $_REQUEST['form'] . '");\'>' . $temp_val . '</a>'; } elseif ($module == 'Contacts') { require_once 'modules/Contacts/Contacts.php'; $cntct_focus = new Contacts(); $cntct_focus->retrieve_entity_info($entity_id, "Contacts"); $slashes_temp_val = popup_from_html($temp_val); //ADDED TO CHECK THE FIELD PERMISSIONS FOR $xyz = array('mailingstreet', 'mailingcity', 'mailingzip', 'mailingpobox', 'mailingcountry', 'mailingstate', 'otherstreet', 'othercity', 'otherzip', 'otherpobox', 'othercountry', 'otherstate'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $cntct_focus->column_fields[$xyz[$i]] = $cntct_focus->column_fields[$xyz[$i]]; } else { $cntct_focus->column_fields[$xyz[$i]] = ''; } } // For ToDo creation the underlying form is not named as EditView $form = !empty($_REQUEST['form']) ? $_REQUEST['form'] : ''; if (!empty($form)) { $form = htmlspecialchars($form, ENT_QUOTES, $default_charset); } $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcity']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercity']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcountry']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercountry']) . '","' . popup_decode_html($cntct_focus->column_fields['mailingpobox']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherpobox']) . '","' . $form . '");\'>' . $temp_val . '</a>'; } else { if ($popuptype == 'toDospecific') { $value = '<a href="javascript:window.close();" onclick=\'set_return_toDospecific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } } } elseif ($popuptype == "detailview") { if ($colname == "lastname" && ($module == 'Contacts' || $module == 'Leads')) { $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $focus->record_id = $_REQUEST['recordid']; if ($_REQUEST['return_module'] == "Calendar") { $value = '<a href="javascript:window.close();" id="calendarCont' . $entity_id . '" LANGUAGE=javascript onclick=\'add_data_to_relatedlist_incal("' . $entity_id . '","' . decode_html($slashes_temp_val) . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'add_data_to_relatedlist("' . $entity_id . '","' . $focus->record_id . '","' . $module . '");\'>' . $temp_val . '</a>'; } } elseif ($popuptype == "formname_specific") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'set_return_formname_specific("' . $_REQUEST['form'] . '", "' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id)); $unitprice = $prod_prices[$entity_id]; } } else { $unit_price = ''; } $sub_products = ''; $sub_prod = ''; $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id)); for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) { //$sub_prod=array(); $id = $adb->query_result($sub_prod_query, $i, "productid"); $str_sep = ''; if ($i > 0) { $str_sep = ":"; } $sub_products .= $str_sep . $id; $sub_prod .= $str_sep . " - " . $adb->query_result($sub_prod_query, $i, "productname"); } $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod); $qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); //fix for T6943 $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $qty_stock . '","' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '");\' vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod_po") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission($module, $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module); $unitprice = $prod_prices[$entity_id]; } } else { $unit_price = ''; } $sub_products = ''; $sub_prod = ''; $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id)); for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) { //$sub_prod=array(); $id = $adb->query_result($sub_prod_query, $i, "productid"); $str_sep = ''; if ($i > 0) { $str_sep = ":"; } $sub_products .= $str_sep . $id; $sub_prod .= $str_sep . " - {$id}." . $adb->query_result($sub_prod_query, $i, "productname"); } $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod); $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory_po("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '"); \' vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_service") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module); $unitprice = $prod_prices[$entity_id]; } } else { $unit_price = ''; } $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '");\' vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_pb") { $prod_id = $_REQUEST['productid']; $flname = $_REQUEST['fldname']; $listprice = getListPrice($prod_id, $entity_id); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_pb("' . $listprice . '", "' . $flname . '"); \'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_account_address") { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($entity_id, "Accounts"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_contact_account_address") { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($entity_id, "Accounts"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_potential_account_address") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); // For B2C support, Potential was enabled to be linked to Contacts also. // Hence we need case handling for it. $relatedid = $adb->query_result($list_result, $list_result_count, "related_to"); $relatedentity = getSalesEntityType($relatedid); if ($relatedentity == 'Accounts') { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($relatedid, "Accounts"); $account_name = getAccountName($relatedid); $slashes_account_name = popup_from_html($account_name); $slashes_account_name = htmlspecialchars($slashes_account_name, ENT_QUOTES, $default_charset); $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission('Accounts', $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_account_name)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } else { if ($relatedentity == 'Contacts') { require_once 'modules/Contacts/Contacts.php'; $contact_name = getContactName($relatedid); $slashes_contact_name = popup_from_html($contact_name); $slashes_contact_name = htmlspecialchars($slashes_contact_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'set_return_contact("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_contact_name)) . '");\'>' . $temp_val . '</a>'; } else { $value = $temp_val; } } } elseif ($popuptype == "set_return_emails") { if ($module == 'Accounts') { $name = $adb->query_result($list_result, $list_result_count, 'accountname'); $accid = $adb->query_result($list_result, $list_result_count, 'accountid'); if (CheckFieldPermission('email1', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email1"); $email_check = 1; } else { $email_check = 0; } if ($emailaddress == '') { if (CheckFieldPermission('email2', $module) == 'true') { $emailaddress2 = $adb->query_result($list_result, $list_result_count, "email2"); $email_check = 2; } else { if ($email_check == 1) { $email_check = 4; } else { $email_check = 3; } } } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>'; } elseif ($module == 'Vendors') { $name = $adb->query_result($list_result, $list_result_count, 'vendorname'); $venid = $adb->query_result($list_result, $list_result_count, 'vendorid'); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>'; } elseif ($module == 'Contacts' || $module == 'Leads') { $name = getFullNameFromQResult($list_result, $list_result_count, $module); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } if ($emailaddress == '') { if (CheckFieldPermission('yahooid', $module) == 'true') { $emailaddress2 = $adb->query_result($list_result, $list_result_count, "yahooid"); $email_check = 2; } else { if ($email_check == 1) { $email_check = 4; } else { $email_check = 3; } } } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email or yahooid $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . $name . '</a>'; } else { $firstname = $adb->query_result($list_result, $list_result_count, "first_name"); $lastname = $adb->query_result($list_result, $list_result_count, "last_name"); $name = $lastname . ' ' . $firstname; $emailaddress = $adb->query_result($list_result, $list_result_count, "email1"); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $email_check = 1; $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',-1,"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>'; } } elseif ($popuptype == "specific_vendor_address") { require_once 'modules/Vendors/Vendors.php'; $acct_focus = new Vendors(); $acct_focus->retrieve_entity_info($entity_id, "Vendors"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $xyz = array('street', 'city', 'postalcode', 'pobox', 'country', 'state'); for ($i = 0; $i < 6; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . popup_decode_html($acct_focus->column_fields['city']) . '", "' . popup_decode_html($acct_focus->column_fields['state']) . '", "' . popup_decode_html($acct_focus->column_fields['postalcode']) . '", "' . popup_decode_html($acct_focus->column_fields['country']) . '","' . popup_decode_html($acct_focus->column_fields['pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_campaign") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'set_return_specific_campaign("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } else { if ($colname == "lastname") { $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $log->debug("Exiting getValue method ..."); if ($_REQUEST['maintab'] == 'Calendar') { $value = '<a href="javascript:window.close();" onclick=\'set_return_todo("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'set_return("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } } } else { if ($module == "Leads" && $colname == "lastname" || $module == "Contacts" && $colname == "lastname") { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == "Calendar") { $actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype'); $actvity_type = $actvity_type != '' ? $actvity_type : $adb->query_result($list_result, $list_result_count, 'type'); if ($actvity_type == "Task") { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&activity_mode=Task&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } else { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&activity_mode=Events&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } } elseif ($module == "Vendors") { $value = '<a href="index.php?action=DetailView&module=Vendors&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == "PriceBooks") { $value = '<a href="index.php?action=DetailView&module=PriceBooks&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == "SalesOrder") { $value = '<a href="index.php?action=DetailView&module=SalesOrder&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == 'Emails') { $value = $temp_val; } else { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } } } elseif ($fieldname == 'expectedroi' || $fieldname == 'actualroi' || $fieldname == 'actualcost' || $fieldname == 'budgetcost' || $fieldname == 'expectedrevenue') { $rate = $user_info['conv_rate']; $value = convertFromDollar($temp_val, $rate); } elseif (($module == 'Invoice' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder') && ($fieldname == 'hdnGrandTotal' || $fieldname == 'hdnSubTotal' || $fieldname == 'txtAdjustment' || $fieldname == 'hdnDiscountAmount' || $fieldname == 'hdnS_H_Amount')) { $currency_info = getInventoryCurrencyInfo($module, $entity_id); $currency_id = $currency_info['currency_id']; $currency_symbol = $currency_info['currency_symbol']; $value = $currency_symbol . $temp_val; } else { $value = $temp_val; } } } // Mike Crowe Mod --------------------------------------------------------Make right justified and vtiger_currency value if (in_array($uitype, array(71, 72, 7, 9, 90))) { $value = '<span align="right">' . $value . '</div>'; } $log->debug("Exiting getValue method ..."); return $value; }
/** Function to return the duplicate records data as a formatted array */ function getDuplicateRecordsArr($module) { global $adb, $app_strings, $list_max_entries_per_page, $theme; $field_values_array = getFieldValues($module); $field_values = $field_values_array['fieldnames_list']; $fld_arr = $field_values_array['fieldnames_array']; $col_arr = $field_values_array['columnnames_array']; $fld_labl_arr = $field_values_array['fieldlabels_array']; $ui_type = $field_values_array['fieldname_uitype']; $dup_query = getDuplicateQuery($module, $field_values, $ui_type); // added for page navigation $dup_count_query = substr($dup_query, stripos($dup_query, 'FROM'), strlen($dup_query)); $dup_count_query = "SELECT count(*) as count " . $dup_count_query; $count_res = $adb->query($dup_count_query); $no_of_rows = $adb->query_result($count_res, 0, "count"); if ($no_of_rows <= $list_max_entries_per_page) { $_SESSION['dup_nav_start' . $module] = 1; } else { if (isset($_REQUEST["start"]) && $_REQUEST["start"] != "" && $_SESSION['dup_nav_start' . $module] != $_REQUEST["start"]) { $_SESSION['dup_nav_start' . $module] = ListViewSession::getRequestStartPage(); } } $start = $_SESSION['dup_nav_start' . $module] != "" ? $_SESSION['dup_nav_start' . $module] : 1; $navigation_array = getNavigationValues($start, $no_of_rows, $list_max_entries_per_page); $start_rec = $navigation_array['start']; $end_rec = $navigation_array['end_val']; $navigationOutput = getTableHeaderNavigation($navigation_array, "", $module, "FindDuplicate", ""); if ($start_rec == 0) { $limit_start_rec = 0; } else { $limit_start_rec = $start_rec - 1; } $dup_query .= " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}"; //ends $nresult = $adb->query($dup_query); $no_rows = $adb->num_rows($nresult); require_once 'modules/Vtiger/layout_utils.php'; if ($no_rows == 0) { if ($_REQUEST['action'] == 'FindDuplicateRecords') { //echo "<br><br><center>".$app_strings['LBL_NO_DUPLICATE']." <a href='javascript:window.history.back()'>".$app_strings['LBL_GO_BACK'].".</a></center>"; //die; echo "<link rel='stylesheet' type='text/css' href='themes/{$theme}/style.css'>"; echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>"; echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>\n\n\t\t\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t\t\t<tbody><tr>\n\t\t\t\t<td rowspan='2' width='11%'><img src='" . vtiger_imageurl('empty.jpg', $theme) . "' ></td>\n\t\t\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'><span class='genHeaderSmall'>{$app_strings['LBL_NO_DUPLICATE']}</span></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t<td class='small' align='right' nowrap='nowrap'>\n\t\t\t\t<a href='javascript:window.history.back();'>{$app_strings['LBL_GO_BACK']}</a><br> </td>\n\t\t\t\t</tr>\n\t\t\t\t</tbody></table>\n\t\t\t\t</div>"; echo "</td></tr></table>"; exit; } else { echo "<br><br><table align='center' class='reportCreateBottom big' width='95%'><tr><td align='center'>" . $app_strings['LBL_NO_DUPLICATE'] . "</td></tr></table>"; die; } } $rec_cnt = 0; $temp = array(); $sl_arr = array(); $grp = "group0"; $gcnt = 0; $ii = 0; //ii'th record in group while ($rec_cnt < $no_rows) { $result = $adb->fetchByAssoc($nresult); //echo '<pre>';print_r($result);echo '</pre>'; if ($rec_cnt != 0) { $sl_arr = array_slice($result, 2); array_walk($temp, 'lower_array'); array_walk($sl_arr, 'lower_array'); $arr_diff = array_diff($temp, $sl_arr); if (count($arr_diff) > 0) { $gcnt++; $temp = $sl_arr; $ii = 0; } $grp = "group" . $gcnt; } $fld_values[$grp][$ii]['recordid'] = $result['recordid']; for ($k = 0; $k < count($col_arr); $k++) { if ($rec_cnt == 0) { $temp[$fld_labl_arr[$k]] = $result[$col_arr[$k]]; } if ($ui_type[$fld_arr[$k]] == 56) { if ($result[$col_arr[$k]] == 0) { $result[$col_arr[$k]] = $app_strings['no']; } else { $result[$col_arr[$k]] = $app_strings['yes']; } } if ($ui_type[$fld_arr[$k]] == 75 || $ui_type[$fld_arr[$k]] == 81) { $vendor_id = $result[$col_arr[$k]]; if ($vendor_id != '') { $vendor_name = getVendorName($vendor_id); } $result[$col_arr[$k]] = $vendor_name; } if ($ui_type[$fld_arr[$k]] == 57) { $contact_id = $result[$col_arr[$k]]; if ($contact_id != '') { $parent_module = 'Contacts'; $displayValueArray = getEntityName($parent_module, $contact_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contactname = $field_value; } } } $result[$col_arr[$k]] = $contactname; } if ($ui_type[$fld_arr[$k]] == 15 || $ui_type[$fld_arr[$k]] == 16) { $result[$col_arr[$k]] = getTranslatedString($result[$col_arr[$k]], $module); } if ($ui_type[$fld_arr[$k]] == 33) { $fieldvalue = explode(' |##| ', $result[$col_arr[$k]]); $result[$col_arr[$k]] = array(); foreach ($fieldvalue as $picklistValue) { $result[$col_arr[$k]][] = getTranslatedString($picklistValue, $module); } $result[$col_arr[$k]] = implode(', ', $result[$col_arr[$k]]); } if ($ui_type[$fld_arr[$k]] == 68) { $parent_id = $result[$col_arr[$k]]; if ($parent_id != '') { $parentname = getParentName($parent_id); } $result[$col_arr[$k]] = $parentname; } if ($ui_type[$fld_arr[$k]] == 53 || $ui_type[$fld_arr[$k]] == 52) { if ($result[$col_arr[$k]] != '') { $owner = getOwnerName($result[$col_arr[$k]]); } $result[$col_arr[$k]] = $owner; } if ($ui_type[$fld_arr[$k]] == 50 or $ui_type[$fld_arr[$k]] == 51) { if ($module != 'Products') { $entity_name = getAccountName($result[$col_arr[$k]]); } else { $entity_name = getProductName($result[$col_arr[$k]]); } if ($entity_name != '') { $result[$col_arr[$k]] = $entity_name; } else { $result[$col_arr[$k]] = ''; } } if ($ui_type[$fld_arr[$k]] == 58) { $campaign_name = getCampaignName($result[$col_arr[$k]]); if ($campaign_name != '') { $result[$col_arr[$k]] = $campaign_name; } else { $result[$col_arr[$k]] = ''; } } if ($ui_type[$fld_arr[$k]] == 59) { $product_name = getProductName($result[$col_arr[$k]]); if ($product_name != '') { $result[$col_arr[$k]] = $product_name; } else { $result[$col_arr[$k]] = ''; } } /*uitype 10 handling*/ if ($ui_type[$fld_arr[$k]] == 10) { $result[$col_arr[$k]] = getRecordInfoFromID($result[$col_arr[$k]]); } if ($ui_type[$fld_arr[$k]] == 5 || $ui_type[$fld_arr[$k]] == 6 || $ui_type[$fld_arr[$k]] == 23) { if (${$result}[$col_arr[$k]] != '' && ${$result}[$col_arr[$k]] != '0000-00-00') { $date = new DateTimeField(${$result}[$col_arr[$k]]); $value = $date->getDisplayDate(); if (strpos(${$result}[$col_arr[$k]], ' ') > -1) { $value .= ' ' . $date->getDisplayTime(); } } elseif (${$result}[$col_arr[$k]] == '0000-00-00') { $value = ''; } else { $value = ${$result}[$col_arr[$k]]; } $result[$col_arr[$k]] = $value; } if ($ui_type[$fld_arr[$k]] == 71) { $result[$col_arr[$k]] = CurrencyField::convertToUserFormat($result[$col_arr[$k]]); } if ($ui_type[$fld_arr[$k]] == 72) { $result[$col_arr[$k]] = CurrencyField::convertToUserFormat($result[$col_arr[$k]], null, true); } $fld_values[$grp][$ii][$fld_labl_arr[$k]] = $result[$col_arr[$k]]; } $fld_values[$grp][$ii]['Entity Type'] = $result['deleted']; $ii++; $rec_cnt++; } $gro = "group"; for ($i = 0; $i < $no_rows; $i++) { $ii = 0; $dis_group[] = $fld_values[$gro . $i][$ii]; $count_group[$i] = count($fld_values[$gro . $i]); $ii++; $new_group[] = $dis_group[$i]; } $fld_nam = $new_group[0]; $ret_arr[0] = $fld_values; $ret_arr[1] = $fld_nam; $ret_arr[2] = $ui_type; $ret_arr["navigation"] = $navigationOutput; return $ret_arr; }
} else { $value['repeatMonth_daytype'] = $recurringInfo['repeatmonth_daytype']; $value['repeatMonth_day'] = $recurringInfo['dayofweek_to_repeat'][0]; } } } else { $value['recurringcheck'] = 'No'; } } else { if (isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') { $contactId = vtlib_purify($_REQUEST['contact_id']); $smarty->assign("CONTACTSID", $contactId); $contact_name = "<option value=" . $contactId . ">" . getContactName($contactId) . "</option>"; $smarty->assign("CONTACTSNAME", $contact_name); $account_id = vtlib_purify($_REQUEST['account_id']); $account_name = getAccountName($account_id); } } if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') { $focus->id = ""; $focus->mode = ''; } if (empty($_REQUEST['record']) && $focus->mode != 'edit') { setObjectValuesFromRequest($focus); } $userDetails = getOtherUserName($current_user->id); $to_email = getUserEmailId('id', $current_user->id); $smarty->assign("CURRENTUSERID", $current_user->id); $disp_view = getView($focus->mode); if ($disp_view == 'edit_view') { $act_data = getBlocks($tab_type, $disp_view, $mode, $focus->column_fields);
function getListViewEntries2($focus, $module, $list_result, $navigation_array, $relatedlist = '', $returnset = '', $edit_action = 'EditView', $del_action = 'Delete', $oCv = '', $page = '', $selectedfields = '', $contRelatedfields = '', $skipActions = false) { global $log; global $mod_strings; $log->debug("Entering getListViewEntries(" . get_class($focus) . "," . $module . "," . $list_result . "," . $navigation_array . "," . $relatedlist . "," . $returnset . "," . $edit_action . "," . $del_action . "," . (is_object($oCv) ? get_class($oCv) : $oCv) . ") method ..."); $tabname = getParentTab(); global $adb, $current_user; global $app_strings; $noofrows = $adb->num_rows($list_result); $list_block = array(); global $theme; $evt_status = ''; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; //getting the vtiger_fieldtable entries from database $tabid = getTabid($module); //added for vtiger_customview 27/5 if ($oCv) { if (isset($oCv->list_fields)) { $focus->list_fields = $oCv->list_fields; } } if (is_array($selectedfields) && $selectedfields != '') { $focus->list_fields = $selectedfields; } // Remove fields which are made inactive $focus->filterInactiveFields($module); //Added to reduce the no. of queries logging for non-admin user -- by minnie-start $field_list = array(); $j = 0; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; foreach ($focus->list_fields as $name => $tableinfo) { $fieldname = $focus->list_fields_name[$name]; if ($oCv) { if (isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; } } if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } array_push($field_list, $fieldname); $j++; } $field = array(); if ($is_admin == false) { if ($module == 'Emails') { $query = "SELECT fieldname FROM vtiger_field WHERE tabid = ? and vtiger_field.presence in (0,2)"; $params = array($tabid); } else { $profileList = getCurrentUserProfileList(); $params = array(); $query = "SELECT DISTINCT vtiger_field.fieldname\r\n\t\t\t\tFROM vtiger_field\r\n\t\t\t\tINNER JOIN vtiger_profile2field\r\n\t\t\t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\r\n\t\t\t\tINNER JOIN vtiger_def_org_field\r\n\t\t\t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid"; if ($module == "Calendar") { $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)"; } else { $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)"; array_push($params, $tabid); } $query .= " AND vtiger_profile2field.visible = 0\r\n\t\t\t\t\tAND vtiger_profile2field.visible = 0\r\n\t\t\t\t\tAND vtiger_def_org_field.visible = 0\r\n\t\t\t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\r\n\t\t\t\t\tAND vtiger_field.fieldname IN (" . generateQuestionMarks($field_list) . ")"; array_push($params, $profileList, $field_list); } $result = $adb->pquery($query, $params); for ($k = 0; $k < $adb->num_rows($result); $k++) { $field[] = $adb->query_result($result, $k, "fieldname"); } } //constructing the uitype and columnname array $ui_col_array = array(); $params = array(); $query = "SELECT uitype, columnname, fieldname FROM vtiger_field "; if ($module == "Calendar") { $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)"; } else { $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)"; array_push($params, $tabid); } $query .= " AND fieldname IN (" . generateQuestionMarks($field_list) . ") "; array_push($params, $field_list); $result = $adb->pquery($query, $params); $num_rows = $adb->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $tempArr = array(); $uitype = $adb->query_result($result, $i, 'uitype'); $columnname = $adb->query_result($result, $i, 'columnname'); $field_name = $adb->query_result($result, $i, 'fieldname'); $tempArr[$uitype] = $columnname; $ui_col_array[$field_name] = $tempArr; } //end if ($navigation_array['start'] != 0) { for ($i = 1; $i <= $noofrows; $i++) { $list_header = array(); //Getting the entityid if ($module != 'Users') { $entity_id = $adb->query_result($list_result, $i - 1, "crmid"); $owner_id = $adb->query_result($list_result, $i - 1, "smownerid"); } else { $entity_id = $adb->query_result($list_result, $i - 1, "id"); } // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2 // begin: Armando Lüscher 05.07.2005 -> §priority // Code contri buted by fredy Desc: Set Priority color $priority = $adb->query_result($list_result, $i - 1, "priority"); $font_color_high = "color:#00DD00;"; $font_color_medium = "color:#DD00DD;"; $P_FONT_COLOR = ""; switch ($priority) { case 'High': $P_FONT_COLOR = $font_color_high; break; case 'Medium': $P_FONT_COLOR = $font_color_medium; break; default: $P_FONT_COLOR = ""; } //end: Armando Lüscher 05.07.2005 -> §priority foreach ($focus->list_fields as $name => $tableinfo) { $fieldname = $focus->list_fields_name[$name]; //added for vtiger_customview 27/5 if ($oCv) { if (isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } } else { $fieldname = $focus->list_fields_name[$name]; } } else { $fieldname = $focus->list_fields_name[$name]; if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } } if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || in_array($fieldname, $field) || $fieldname == '' || $name == 'Close' && $module == 'Calendar') { if ($fieldname == '') { $table_name = ''; $column_name = ''; foreach ($tableinfo as $tablename => $colname) { $table_name = $tablename; $column_name = $colname; } $value = $adb->query_result($list_result, $i - 1, $colname); } else { if ($module == 'Calendar') { $act_id = $adb->query_result($list_result, $i - 1, "activityid"); $cal_sql = "select activitytype from vtiger_activity where activityid=?"; $cal_res = $adb->pquery($cal_sql, array($act_id)); if ($adb->num_rows($cal_res) >= 0) { $activitytype = $adb->query_result($cal_res, 0, "activitytype"); } } if (($module == 'Calendar' || $module == 'Emails' || $module == 'HelpDesk' || $module == 'Invoice' || $module == 'Leads' || $module == 'Contacts') && ($fieldname == 'parent_id' || $name == 'Contact Name' || $name == 'Close' || $fieldname == 'firstname')) { if ($module == 'Calendar') { if ($fieldname == 'status') { if ($activitytype == 'Task') { $fieldname = 'taskstatus'; } else { $fieldname = 'eventstatus'; } } if ($activitytype == 'Task') { if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') { $has_permission = 'yes'; } else { $has_permission = 'no'; } } else { if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') { $has_permission = 'yes'; } else { $has_permission = 'no'; } } } if ($module != 'Calendar' || $module == 'Calendar' && $has_permission == 'yes') { if ($fieldname == 'parent_id') { $value = getRelatedTo($module, $list_result, $i - 1); } if ($name == 'Contact Name') { $contact_id = $adb->query_result($list_result, $i - 1, "contactid"); $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts"); $value = ""; //Added to get the contactname for activities custom view - t=2190 if ($contact_id != '' && !empty($contact_name)) { $contact_name = getContactName($contact_id); } if ($contact_name != "" && $contact_id != 'NULL') { // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2 $value = "<a href='index.php?module=Contacts&action=DetailView&parenttab=" . $tabname . "&record=" . $contact_id . "' style='" . $P_FONT_COLOR . "'>" . $contact_name . "</a>"; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR" } } if ($fieldname == "firstname") { $first_name = textlength_check($adb->query_result($list_result, $i - 1, "firstname")); $value = '<a href="index.php?action=DetailView&module=' . $module . '&parenttab=' . $tabname . '&record=' . $entity_id . '">' . $first_name . '</a>'; } if ($name == 'Close') { $status = $adb->query_result($list_result, $i - 1, "status"); $activityid = $adb->query_result($list_result, $i - 1, "activityid"); if (empty($activityid)) { $activityid = $adb->query_result($list_result, $i - 1, "tmp_activity_id"); } $activitytype = $adb->query_result($list_result, $i - 1, "activitytype"); // TODO - Picking activitytype when it is not present in the Custom View. // Going forward, this column should be added to the select list if not already present as a performance improvement. if (empty($activitytype)) { $activitytypeRes = $adb->pquery('SELECT activitytype FROM vtiger_activity WHERE activityid=?', array($activityid)); if ($adb->num_rows($activitytypeRes) > 0) { $activitytype = $adb->query_result($activitytypeRes, 0, 'activitytype'); } } if ($activitytype != 'Task' && $activitytype != 'Emails') { $eventstatus = $adb->query_result($list_result, $i - 1, "eventstatus"); if (isset($eventstatus)) { $status = $eventstatus; } } if ($status == 'Deferred' || $status == 'Completed' || $status == 'Held' || $status == '') { $value = ""; } else { if ($activitytype == 'Task') { $evt_status = '&status=Completed'; } else { $evt_status = '&eventstatus=Held'; } if (isPermitted("Calendar", 'EditView', $activityid) == 'yes') { if ($returnset == '') { $returnset = '&return_module=Calendar&return_action=ListView&return_id=' . $activityid . '&return_viewname=' . $oCv->setdefaultviewid; } // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2 $value = "<a href='index.php?action=Save&module=Calendar&record=" . $activityid . "&parenttab=" . $tabname . "&change_status=true" . $returnset . $evt_status . "&start=" . $navigation_array['current'] . "' style='" . $P_FONT_COLOR . "'>X</a>"; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR" } else { $value = ""; } } } } else { $value = ""; } } elseif ($module == "Documents" && ($fieldname == 'filelocationtype' || $fieldname == 'filename' || $fieldname == 'filesize' || $fieldname == 'filestatus' || $fieldname == 'filetype')) { $value = $adb->query_result($list_result, $i - 1, $fieldname); if ($fieldname == 'filelocationtype') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } if ($fieldname == 'filename') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); if ($downloadtype == 'I') { $fld_value = $value; $ext_pos = strrpos($fld_value, "."); $ext = substr($fld_value, $ext_pos + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fld_value = $value; $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $fld_value = '--'; $fileicon = ''; } } else { $fld_value = ' --'; $fileicon = ''; } $file_name = $adb->query_result($list_result, $i - 1, 'filename'); $notes_id = $adb->query_result($list_result, $i - 1, 'crmid'); $folder_id = $adb->query_result($list_result, $i - 1, 'folderid'); $download_type = $adb->query_result($list_result, $i - 1, 'filelocationtype'); $file_status = $adb->query_result($list_result, $i - 1, 'filestatus'); $fileidQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileidres = $adb->pquery($fileidQuery, array($notes_id)); $fileid = $adb->query_result($fileidres, 0, 'attachmentsid'); if ($file_name != '' && $file_status == 1) { if ($download_type == 'I') { $fld_value = "<a href='index.php?module=uploads&action=downloadfile&entityid={$notes_id}&fileid={$fileid}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$notes_id});'>" . $fld_value . "</a>"; } elseif ($download_type == 'E') { $fld_value = "<a target='_blank' href='{$file_name}' onclick='javascript:dldCntIncrease({$notes_id});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . $fld_value . "</a>"; } else { $fld_value = ' --'; } } $value = $fileicon . $fld_value; } if ($fieldname == 'filesize') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); if ($downloadtype == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } if ($fieldname == 'filestatus') { $filestatus = $value; if ($filestatus == 1) { $value = getTranslatedString('yes', $module); } elseif ($filestatus == 0) { $value = getTranslatedString('no', $module); } else { $value = ' --'; } } if ($fieldname == 'filetype') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); $filetype = $adb->query_result($list_result, $i - 1, 'filetype'); if ($downloadtype == 'E' || $downloadtype != 'I') { $value = ' --'; } else { $value = $filetype; } } if ($fieldname == 'notecontent') { $value = decode_html($value); $value = textlength_check($value); } } elseif ($module == "Products" && $name == "Related to") { $value = getRelatedTo($module, $list_result, $i - 1); } elseif ($name == 'Contact Name' && ($module == 'SalesOrder' || $module == 'Quotes' || $module == 'PurchaseOrder')) { if ($name == 'Contact Name') { $contact_id = $adb->query_result($list_result, $i - 1, "contactid"); $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts"); $value = ""; if ($contact_name != "" && $contact_id != 'NULL') { $value = "<a href='index.php?module=Contacts&action=DetailView&parenttab=" . $tabname . "&record=" . $contact_id . "' style='" . $P_FONT_COLOR . "'>" . $contact_name . "</a>"; } } } elseif ($name == 'Product') { $product_id = textlength_check($adb->query_result($list_result, $i - 1, "productname")); $value = $product_id; } elseif ($name == 'Account Name') { //modified for vtiger_customview 27/5 if ($module == 'Accounts') { $account_id = $adb->query_result($list_result, $i - 1, "crmid"); //$account_name = getAccountName($account_id); $account_name = textlength_check($adb->query_result($list_result, $i - 1, "accountname")); // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2 $value = '<a href="index.php?module=Accounts&action=DetailView&record=' . $account_id . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $account_name . '</a>'; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR" } elseif ($module == 'Potentials' || $module == 'Contacts' || $module == 'Invoice' || $module == 'SalesOrder' || $module == 'Quotes') { //Potential,Contacts,Invoice,SalesOrder & Quotes records sort by Account Name $accountname = textlength_check($adb->query_result($list_result, $i - 1, "accountname")); $accountid = $adb->query_result($list_result, $i - 1, "accountid"); $value = '<a href="index.php?module=Accounts&action=DetailView&record=' . $accountid . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $accountname . '</a>'; } else { $account_id = $adb->query_result($list_result, $i - 1, "accountid"); $account_name = getAccountName($account_id); $acc_name = textlength_check($account_name); // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2 $value = '<a href="index.php?module=Accounts&action=DetailView&record=' . $account_id . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $acc_name . '</a>'; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR" } } elseif (($module == 'HelpDesk' || $module == 'PriceBook' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'Faq') && $name == 'Product Name') { if ($module == 'HelpDesk' || $module == 'Faq') { $product_id = $adb->query_result($list_result, $i - 1, "product_id"); } else { $product_id = $adb->query_result($list_result, $i - 1, "productid"); } if ($product_id != '') { $product_name = getProductName($product_id); } else { $product_name = ''; } $value = '<a href="index.php?module=Products&action=DetailView&parenttab=' . $tabname . '&record=' . $product_id . '">' . textlength_check($product_name) . '</a>'; } elseif ($module == 'Quotes' && $name == 'Potential Name' || $module == 'SalesOrder' && $name == 'Potential Name') { $potential_id = $adb->query_result($list_result, $i - 1, "potentialid"); $potential_name = getPotentialName($potential_id); $value = '<a href="index.php?module=Potentials&action=DetailView&parenttab=' . $tabname . '&record=' . $potential_id . '">' . textlength_check($potential_name) . '</a>'; } elseif ($module == 'Emails' && $relatedlist != '' && ($name == 'Subject' || $name == 'Date Sent' || $name == 'To')) { $list_result_count = $i - 1; $tmp_value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); $value = '<a href="javascript:;" onClick="ShowEmail(\'' . $entity_id . '\');">' . textlength_check($tmp_value) . '</a>'; if ($name == 'Date Sent') { $sql = "select email_flag from vtiger_emaildetails where emailid=?"; $result = $adb->pquery($sql, array($entity_id)); $email_flag = $adb->query_result($result, 0, "email_flag"); if ($email_flag != 'SAVED') { $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } else { $value = ''; } } } elseif ($module == 'Calendar' && ($fieldname != 'taskstatus' && $fieldname != 'eventstatus')) { if ($activitytype == 'Task') { if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } else { $value = ''; } } else { if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } else { $value = ''; } } } elseif ($module == "Accounting" && $fieldname == "accounting_id") { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); $value = '<a href="index.php?action=DetailView&module=' . $module . '&parenttab=' . $tabname . '&record=' . $entity_id . '">' . $value . '</a>'; } else { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } } // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$entity_id}' vtfieldname='{$fieldname}' vtmodule='{$module}' style='display:none;'></span>"; // END if ($module == "Calendar" && $name == $app_strings['Close']) { if (isPermitted("Calendar", "EditView") == 'yes') { if (getFieldVisibilityPermission('Events', $current_user->id, 'eventstatus') == '0' || getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') { array_push($list_header, $value); } } } else { $list_header[] = $value; } } } $varreturnset = ''; if ($returnset == '') { $varreturnset = '&return_module=' . $module . '&return_action=index'; } else { $varreturnset = $returnset; } if ($module == 'Calendar') { $actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype'); if ($actvity_type == 'Task') { $varreturnset .= '&activity_mode=Task'; } else { $varreturnset .= '&activity_mode=Events'; } } //Added for Actions ie., edit and delete links in listview $links_info = ""; if (!(is_array($selectedfields) && $selectedfields != '')) { if (isPermitted($module, "EditView", "") == 'yes') { $edit_link = getListViewEditLink($module, $entity_id, $relatedlist, $varreturnset, $list_result, $list_result_count); if (isset($_REQUEST['start']) && $_REQUEST['start'] > 1 && $module != 'Emails') { $links_info .= "<a href=\"{$edit_link}&start=" . vtlib_purify($_REQUEST['start']) . "\">" . $app_strings["LNK_EDIT"] . "</a> "; } else { $links_info .= "<a href=\"{$edit_link}\">" . $app_strings["LNK_EDIT"] . "</a> "; } } if (isPermitted($module, "Delete", "") == 'yes') { $del_link = getListViewDeleteLink($module, $entity_id, $relatedlist, $varreturnset); if ($links_info != "" && $del_link != "") { $links_info .= " | "; } if ($del_link != "") { $links_info .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . $app_strings["LNK_DELETE"] . "</a>"; } } } // Record Change Notification if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) { if (!$focus->isViewed($entity_id)) { $links_info .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>"; } } // END if ($links_info != "" && !$skipActions) { $list_header[] = $links_info; } // $list_block[$entity_id] = $list_header; if (isset($_SESSION['partialpaymentview']) && $_SESSION['partialpaymentview'] == "true") { $list_block[$entity_id . "_" . $i] = $list_header; } else { $list_block[$entity_id] = $list_header; } } } $log->debug("Exiting getListViewEntries method ..."); return $list_block; }
function createXls($accountinfs) { $headArr = array('合同订单编号', '状态', '客户名称', '联系人姓名', '签约日期', '合同金额', '产品名称', '产品编码', '数量', '价格', '备注'); $filepath = $this->accountfile; if (is_array($accountinfs) && count($accountinfs) > 0) { $objPHPExcel = new PHPExcel(); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel5"); $objWorksheet = $objPHPExcel->getActiveSheet(); $rowIndex = 1; $cellIndex = 0; $headrows = $headArr; foreach ($headrows as $headcell) { $objWorksheet->getCellByColumnAndRow($cellIndex, $rowIndex)->setValue($headcell); $cellIndex += 1; } $rowIndex += 1; $cellIndex = 0; $accountrelation = array('subject', 'sostatus', 'account_id', 'contact_id', 'duedate', 'salestotal', 'productname', 'productcode', 'quantity', 'listprice', 'commet'); foreach ($accountinfs as $accountinf) { foreach ($accountrelation as $pos => $propname) { $accountval = $accountinf[$propname]; if ($propname == 'account_id') { $accountval = getAccountName($accountval); } if ($propname == 'contact_id') { $accountval = getContactName($accountval); } $objWorksheet->getCellByColumnAndRow($pos, $rowIndex)->setValueExplicit($accountval, PHPExcel_Cell_DataType::TYPE_STRING); } $rowIndex += 1; } $objWriter->save($filepath); } }
$result = $adb->getList($query); foreach ($result as $row) { $accountid = $row['accountid']; $NextContactAccount[$accountid] = "<img src=\"themes/softed/images/s1.png\" border=0/> <a href=\"index.php?module=Accounts&action=DetailView&record=" . $row['accountid'] . "\" >" . $row['accountname'] . "</a> " . $row['contact_date'] . " <a href=\"index.php?module=Notes&action=EditView&&return_module=Accounts&return_action=ListView&return_id=" . $row['accountid'] . "\" >新增联系记录</a>"; } $dashboard_arr['contact']['title'] = "7天内待联系客户(下次联系日期)"; $dashboard_arr['contact']['type'] = "text"; $dashboard_arr['contact']['divid'] = "7_day_contact"; $dashboard_arr['contact']['content'] = $NextContactAccount; //=========================一月内到期纪念日==================================// $onemonthlater = date("m-d", strtotime("1 month")); $query = "select * from ec_memdays where deleted=0 and smownerid='" . $current_user->id . "' and substr(memday946,-5) between '" . date("m-d") . "' and '" . $onemonthlater . "' order by memday946 asc"; $result = $adb->getList($query); foreach ($result as $row) { $memdaysid = $row['memdaysid']; $accountname = getAccountName($row['accountid']); $OneMonthMemday[$memdaysid] = "<img src=\"themes/softed/images/s1.png\" border=0/> <a href=\"index.php?module=Accounts&action=DetailView&record=" . $row['accountid'] . "\" >" . $accountname . "</a> " . $row['memday938'] . " " . $row['memday946'] . " "; } $dashboard_arr['memday']['title'] = "一月内到期纪念日"; $dashboard_arr['memday']['type'] = "text"; $dashboard_arr['memday']['divid'] = "1_month_memday"; $dashboard_arr['memday']['content'] = $OneMonthMemday; //=========================最近6个月销售情况=====================================// $date_start = date('Y-m-d', mktime(0, 0, 0, date("m") - 5, date("d"), date("Y"))); $date_end = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d"), date("Y"))); if ($current_user->is_admin === true) { $soadmin = ""; } else { $soadmin = " and ec_salesorder.smownerid='" . $current_user->id . "'"; } $where .= " ec_salesorder.orderdate >= " . db_convert("'" . $date_start . "'", 'date') . " AND ec_salesorder.orderdate <= " . db_convert("'" . $date_end . "'", 'date') . " ";
/** This function returns the detail view form ec_field and and its properties in array format. * Param $uitype - UI type of the ec_field * Param $fieldname - Form ec_field name * Param $fieldlabel - Form ec_field label name * Param $col_fields - array contains the ec_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $tabid - ec_tab id to which the Field belongs to (default is "") * Return type is an array */ function getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid = '') { global $log; $log->debug("Entering getDetailViewOutputHtml() method ..."); global $adb; global $mod_strings; global $app_strings; global $current_user; //$fieldlabel = from_html($fieldlabel); $custfld = ''; $value = ''; $arr_data = array(); $label_fld = array(); $data_fld = array(); if ($generatedtype == 2) { $mod_strings[$fieldlabel] = $fieldlabel; } if (!isset($mod_strings[$fieldlabel])) { $mod_strings[$fieldlabel] = $fieldlabel; } if ($col_fields[$fieldname] == '--None--') { $col_fields[$fieldname] = ''; } if ($uitype == 116) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 13) { $label_fld[] = $mod_strings[$fieldlabel]; $temp_val = $col_fields[$fieldname]; $label_fld[] = $temp_val; $linkvalue = getComposeMailUrl($temp_val); $label_fld["link"] = $linkvalue; } elseif ($uitype == 5 || $uitype == 23 || $uitype == 70) { $label_fld[] = $mod_strings[$fieldlabel]; $cur_date_val = $col_fields[$fieldname]; if (!isValidDate($cur_date_val)) { $display_val = ''; } else { $display_val = getDisplayDate($cur_date_val); } $label_fld[] = $display_val; } elseif ($uitype == 15 || $uitype == 16 || $uitype == 115 || $uitype == 111) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 10) { if (isset($app_strings[$fieldlabel])) { $label_fld[] = $app_strings[$fieldlabel]; } elseif (isset($mod_strings[$fieldlabel])) { $label_fld[] = $mod_strings[$fieldlabel]; } else { $label_fld[] = $fieldlabel; } $value = $col_fields[$fieldname]; $module_entityname = ""; if ($value != '') { $query = "SELECT ec_entityname.* FROM ec_crmentityrel inner join ec_entityname on ec_entityname.modulename=ec_crmentityrel.relmodule inner join ec_tab on ec_tab.name=ec_crmentityrel.module WHERE ec_tab.tabid='" . $tabid . "' and ec_entityname.entityidfield='" . $fieldname . "'"; $fldmod_result = $adb->query($query); $rownum = $adb->num_rows($fldmod_result); if ($rownum > 0) { $rel_modulename = $adb->query_result($fldmod_result, 0, 'modulename'); $rel_tablename = $adb->query_result($fldmod_result, 0, 'tablename'); $rel_entityname = $adb->query_result($fldmod_result, 0, 'fieldname'); $rel_entityid = $adb->query_result($fldmod_result, 0, 'entityidfield'); $module_entityname = getEntityNameForTen($rel_tablename, $rel_entityname, $fieldname, $value); } } $label_fld[] = $module_entityname; $label_fld["secid"] = $value; $label_fld["link"] = "index.php?module=" . $rel_modulename . "&action=DetailView&record=" . $value; } elseif ($uitype == 33) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = str_ireplace(' |##| ', ', ', $col_fields[$fieldname]); } elseif ($uitype == 17) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; //$label_fld[] = '<a href="http://'.$col_fields[$fieldname].'" target="_blank">'.$col_fields[$fieldname].'</a>'; } elseif ($uitype == 19) { //$tmp_value = str_replace("<","<",nl2br($col_fields[$fieldname])); //$tmp_value = str_replace(">",">",$tmp_value); //$col_fields[$fieldname]= make_clickable($tmp_value); $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 20 || $uitype == 21 || $uitype == 22 || $uitype == 24) { //$col_fields[$fieldname]=nl2br($col_fields[$fieldname]); $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { $account_id = $col_fields[$fieldname]; $account_name = ""; if ($account_id != '') { $account_name = getAccountName($account_id); } //Account Name View $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $account_name; $label_fld["secid"] = $account_id; $label_fld["link"] = "index.php?module=Accounts&action=DetailView&record=" . $account_id; } elseif ($uitype == 52 || $uitype == 77 || $uitype == 101) { $label_fld[] = $mod_strings[$fieldlabel]; $user_id = $col_fields[$fieldname]; $user_name = getUserName($user_id); $label_fld[] = $user_name; } elseif ($uitype == 53) { $user_id = $col_fields[$fieldname]; $user_name = getUserName($user_id); $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $user_name; } elseif ($uitype == 1004) { if (isset($mod_strings[$fieldlabel])) { $label_fld[] = $mod_strings[$fieldlabel]; } else { $label_fld[] = $fieldlabel; } $value = $col_fields[$fieldname]; $label_fld[] = getUserName($value); } elseif ($uitype == 56) { $label_fld[] = $mod_strings[$fieldlabel]; $value = $col_fields[$fieldname]; if ($value == 1) { //Since "yes" is not been translated it is given as app strings here.. $display_val = $app_strings['yes']; } else { $display_val = ''; } $label_fld[] = $display_val; } elseif ($uitype == 57) { $label_fld[] = $mod_strings[$fieldlabel]; $contact_id = $col_fields[$fieldname]; $contact_name = ""; if (trim($contact_id) != '') { $contact_name = getContactName($contact_id); } $label_fld[] = $contact_name; $label_fld["secid"] = $contact_id; $label_fld["link"] = "index.php?module=Contacts&action=DetailView&record=" . $contact_id; } elseif ($uitype == 59) { $label_fld[] = $mod_strings[$fieldlabel]; $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 == 71 || $uitype == 72) { $label_fld[] = $mod_strings[$fieldlabel]; $display_val = $col_fields[$fieldname]; $label_fld[] = $display_val; } elseif ($uitype == 76) { $label_fld[] = $mod_strings[$fieldlabel]; $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 == 80) { $label_fld[] = $mod_strings[$fieldlabel]; $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 == 85) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 86) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 87) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 88) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 89) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } else { $label_fld[] = $mod_strings[$fieldlabel]; if ($col_fields[$fieldname] == '0') { $col_fields[$fieldname] = ''; } $label_fld[] = $col_fields[$fieldname]; } $label_fld[] = $uitype; $log->debug("Exiting getDetailViewOutputHtml method ..."); return $label_fld; }
<td align="right" width="5%"><input type="checkbox" id="all" onChange="toggle_all();" /></td> </tr> <?php $x = 0; foreach ($accounts as $account => $v) { ?> <tr bgcolor="#<?php echo $x % 2 == 0 ? "BBBBBB" : "AAAAAA"; ?> "> <td align="center" width="5%"><?php echo $v['id']; ?> </td> <td align="center" width="15%"><?php echo getAccountName($v['id']); ?> </td> <td align="right"><input type="checkbox" name="id[]" value="<?php echo $v['id']; ?> " /></td> </tr> <?php $x++; } } if (!isset($accounts)) { ?> <tr> <td align="left" width="100" style="padding: 10px;">No empty accounts</td>
/** * Function to generate Quote pdf */ function get_quote_pdf() { require_once 'include/tcpdf/pdf.php'; require_once 'include/tcpdf/pdfconfig.php'; require_once 'include/database/PearDatabase.php'; require_once 'modules/Quotes/Quotes.php'; global $adb, $app_strings, $current_user; // would you like and end page? 1 for yes 0 for no $endpage = "1"; $focus = new Quotes(); $focus->retrieve_entity_info($_REQUEST['record'], "Quotes"); $focus->apply_field_security(); $account_name = getAccountName($focus->column_fields[account_id]); $quote_no = $focus->column_fields[quote_no]; if ($focus->column_fields["hdnTaxType"] == "individual") { $product_taxes = 'true'; } else { $product_taxes = 'false'; } $sql = "select currency_symbol from vtiger_currency_info where id=?"; $result = $adb->pquery($sql, array($focus->column_fields['currency_id'])); $currency_symbol = $adb->query_result($result, 0, 'currency_symbol'); // **************** BEGIN POPULATE DATA ******************** $account_id = $focus->column_fields[account_id]; $quote_id = $_REQUEST['record']; // Quote Information $valid_till = $focus->column_fields["validtill"]; $valid_till = getDisplayDate($valid_till); $bill_street = $focus->column_fields["bill_street"]; $bill_city = $focus->column_fields["bill_city"]; $bill_state = $focus->column_fields["bill_state"]; $bill_code = $focus->column_fields["bill_code"]; $bill_country = $focus->column_fields["bill_country"]; $contact_name = getContactName($focus->column_fields["contact_id"]); $ship_street = $focus->column_fields["ship_street"]; $ship_city = $focus->column_fields["ship_city"]; $ship_state = $focus->column_fields["ship_state"]; $ship_code = $focus->column_fields["ship_code"]; $ship_country = $focus->column_fields["ship_country"]; $conditions = from_html($focus->column_fields["terms_conditions"]); $description = from_html($focus->column_fields["description"]); $status = $focus->column_fields["quotestage"]; // Company information $add_query = "select * from vtiger_organizationdetails"; $result = $adb->pquery($add_query, array()); $num_rows = $adb->num_rows($result); if ($num_rows > 0) { $org_name = $adb->query_result($result, 0, "organizationname"); $org_address = $adb->query_result($result, 0, "address"); $org_city = $adb->query_result($result, 0, "city"); $org_state = $adb->query_result($result, 0, "state"); $org_country = $adb->query_result($result, 0, "country"); $org_code = $adb->query_result($result, 0, "code"); $org_phone = $adb->query_result($result, 0, "phone"); $org_fax = $adb->query_result($result, 0, "fax"); $org_website = $adb->query_result($result, 0, "website"); $logo_name = $adb->query_result($result, 0, "logoname"); } //Population of Product Details - Starts //we can cut and paste the following lines in a file and include that file here is enough. For that we have to put a new common file. we will do this later //NOTE : Removed currency symbols and added with Grand Total text. it is enough to show the currency symbol in one place //we can also get the NetTotal, Final Discount Amount/Percent, Adjustment and GrandTotal from the array $associated_products[1]['final_details'] //get the Associated Products for this Invoice $focus->id = $focus->column_fields["record_id"]; $associated_products = getAssociatedProducts("Quotes", $focus); $num_products = count($associated_products); //This $final_details array will contain the final total, discount, Group Tax, S&H charge, S&H taxes and adjustment $final_details = $associated_products[1]['final_details']; //getting the Net Total $price_subtotal = number_format($final_details["hdnSubTotal"], 2, '.', ','); //Final discount amount/percentage $discount_amount = $final_details["discount_amount_final"]; $discount_percent = $final_details["discount_percentage_final"]; if ($discount_amount != "") { $price_discount = number_format($discount_amount, 2, '.', ','); } else { if ($discount_percent != "") { //This will be displayed near Discount label - used in include/fpdf/templates/body.php $final_price_discount_percent = "(" . number_format($discount_percent, 2, '.', ',') . " %)"; $price_discount = number_format($discount_percent * $final_details["hdnSubTotal"] / 100, 2, '.', ','); } else { $price_discount = "0.00"; } } //Adjustment $price_adjustment = number_format($final_details["adjustment"], 2, '.', ','); //Grand Total $price_total = number_format($final_details["grandTotal"], 2, '.', ','); //To calculate the group tax amount if ($final_details['taxtype'] == 'group') { $group_tax_total = $final_details['tax_totalamount']; $price_salestax = number_format($group_tax_total, 2, '.', ','); $group_total_tax_percent = '0.00'; $group_tax_details = $final_details['taxes']; for ($i = 0; $i < count($group_tax_details); $i++) { $group_total_tax_percent = $group_total_tax_percent + $group_tax_details[$i]['percentage']; } } //S&H amount $sh_amount = $final_details['shipping_handling_charge']; $price_shipping = number_format($sh_amount, 2, '.', ','); //S&H taxes $sh_tax_details = $final_details['sh_taxes']; $sh_tax_percent = '0.00'; for ($i = 0; $i < count($sh_tax_details); $i++) { $sh_tax_percent = $sh_tax_percent + $sh_tax_details[$i]['percentage']; } $sh_tax_amount = $final_details['shtax_totalamount']; $price_shipping_tax = number_format($sh_tax_amount, 2, '.', ','); $prod_line = array(); $lines = 0; //This is to get all prodcut details as row basis for ($i = 1, $j = $i - 1; $i <= $num_products; $i++, $j++) { $product_name[$i] = $associated_products[$i]['productName' . $i]; $subproduct_name[$i] = split("<br>", $associated_products[$i]['subprod_names' . $i]); //$prod_description[$i] = $associated_products[$i]['productDescription'.$i]; $comment[$i] = $associated_products[$i]['comment' . $i]; $product_id[$i] = $associated_products[$i]['hdnProductId' . $i]; $qty[$i] = $associated_products[$i]['qty' . $i]; $unit_price[$i] = number_format($associated_products[$i]['unitPrice' . $i], 2, '.', ','); $list_price[$i] = number_format($associated_products[$i]['listPrice' . $i], 2, '.', ','); $list_pricet[$i] = $associated_products[$i]['listPrice' . $i]; $discount_total[$i] = $associated_products[$i]['discountTotal' . $i]; //aded for 5.0.3 pdf changes $product_code[$i] = $associated_products[$i]['hdnProductcode' . $i]; $taxable_total = $qty[$i] * $list_pricet[$i] - $discount_total[$i]; $producttotal = $taxable_total; $total_taxes = '0.00'; if ($focus->column_fields["hdnTaxType"] == "individual") { $total_tax_percent = '0.00'; //This loop is to get all tax percentage and then calculate the total of all taxes for ($tax_count = 0; $tax_count < count($associated_products[$i]['taxes']); $tax_count++) { $tax_percent = $associated_products[$i]['taxes'][$tax_count]['percentage']; $total_tax_percent = $total_tax_percent + $tax_percent; $tax_amount = $taxable_total * $tax_percent / 100; $total_taxes = $total_taxes + $tax_amount; } $producttotal = $taxable_total + $total_taxes; $product_line[$j]["Tax"] = number_format($total_taxes, 2, '.', ',') . "\n ({$total_tax_percent} %) "; $price_salestax += $total_taxes; } $prod_total[$i] = number_format($producttotal, 2, '.', ','); $product_line[$j]["Product Code"] = $product_code[$i]; $product_line[$j]["Qty"] = $qty[$i]; $product_line[$j]["Price"] = $list_price[$i]; $product_line[$j]["Discount"] = $discount_total[$i]; $product_line[$j]["Total"] = $prod_total[$i]; $lines++; $product_line[$j]["Product Name"] = decode_html($product_name[$i]); $prod_line[$j] = 1; for ($count = 0; $count < count($subproduct_name[$i]); $count++) { if ($lines % 12 != 0) { $product_line[$j]["Product Name"] .= "\n" . decode_html($subproduct_name[$i][$count]); $prod_line[$j]++; } else { $j++; $product_line[$j]["Product Name"] = decode_html($product_name[$i]); $product_line[$j]["Product Name"] .= "\n" . decode_html($subproduct_name[$i][$count]); $prod_line[$j] = 2; $lines++; } $lines++; } if ($comment[$i] != '') { $product_line[$j]["Product Name"] .= "\n" . decode_html($comment[$i]); $prod_line[$j]++; $lines++; } } $price_salestax = number_format($price_salestax, 2, '.', ','); //echo '<pre>Product Details ==>';print_r($product_line);echo '</pre>'; //echo '<pre>';print_r($associated_products);echo '</pre>'; //Population of Product Details - Ends // ************************ END POPULATE DATA ***************************8 $page_num = '1'; $pdf = new PDF('P', 'mm', 'A4'); $pdf->Open(); // $num_pages=ceil(($num_products/$products_per_page)); //STARTS - Placement of products in pages as per the lines count $lines_per_page = "12"; $prod_cnt = 0; $num_pages = ceil($lines / $lines_per_page); $tmp = 0; for ($count = 0; $count < $num_pages; $count++) { for ($k = $tmp; $k < $j; $k++) { if ($prod_cnt != 12) { $products[$count][] = $k; $prod_cnt += $prod_line[$k]; } else { $tmp = $k; $prod_cnt = 0; break; } } } //ENDS - Placement of products in pages as per the lines count $current_product = 0; for ($l = 0; $l < $num_pages; $l++) { $line = array(); if ($num_pages == $page_num) { $lastpage = 1; } /*while($current_product != $page_num*$products_per_page) { $line[]=$product_line[$current_product]; $current_product++; }/*/ foreach ($products[$l] as $index => $key) { $line[] = $product_line[$key]; } $pdf->AddPage(); include "modules/Quotes/pdf_templates/header.php"; include "include/tcpdf/templates/body.php"; //if bottom > 145 then we skip the Description and T&C in every page and display only in lastpage //if you want to display the description and T&C in each page then set the display_desc_tc='true' and bottom <= 145 in pdfconfig.php if ($display_desc_tc == 'true') { if ($bottom <= 145) { include "modules/Quotes/pdf_templates/footer.php"; } } $page_num++; if ($endpage && $lastpage) { $pdf->AddPage(); include "modules/Quotes/pdf_templates/header.php"; include "modules/Quotes/pdf_templates/lastpage/body.php"; include "modules/Quotes/pdf_templates/lastpage/footer.php"; } } return $pdf; }
/** To get the converted record values which have to be display in duplicates merging tpl*/ function getRecordValues($id_array, $module) { global $adb, $current_user; global $app_strings; global $mod_strings; $tabid = getTabid($module); $query = "select fieldname,fieldlabel from ec_field where tabid=" . $tabid . " and fieldname not in ('createdtime','modifiedtime')"; $result = $adb->query($query); $no_rows = $adb->num_rows($result); for ($i = 0; $i < $no_rows; $i++) { $fld_name = $adb->query_result($result, $i, "fieldname"); if (getFieldVisibilityPermission($module, $current_user->id, $fld_name) == '0') { $fld_array[] = $fld_name; } } $js_arr = $fld_array; $focus = new $module(); if (isset($id_array) && $id_array != '') { foreach ($id_array as $value) { $focus->id = $value; $focus->retrieve_entity_info($value, $module); $field_values[] = $focus->column_fields; } } $tabid = getTabid($module); $query = "select fieldname,uitype,fieldlabel from ec_field where tabid=" . $tabid . " and fieldname not in ('createdtime','modifiedtime','lastcontacttime')"; $result = $adb->query($query); $no_rows = $adb->num_rows($result); $labl_array = array(); $value_pair = array(); $c = 0; for ($i = 0; $i < $no_rows; $i++) { $fld_name = $adb->query_result($result, $i, "fieldname"); $fld_label = $adb->query_result($result, $i, "fieldlabel"); if (isset($mod_strings[$fld_label])) { $fld_label = $mod_strings[$fld_label]; } $ui_type = $adb->query_result($result, $i, "uitype"); if (getFieldVisibilityPermission($module, $current_user->id, $fld_name) == '0') { $record_values[$c][$fld_label] = array(); $ui_value[] = $ui_type; for ($j = 0; $j < count($field_values); $j++) { if ($ui_type == 56) { if ($field_values[$j][$fld_name] == 0) { $value_pair['disp_value'] = $app_strings['no']; } else { $value_pair['disp_value'] = $app_strings['yes']; } } elseif ($ui_type == 51 || $ui_type == 50) { $account_id = $field_values[$j][$fld_name]; $account_name = getAccountName($account_id); $value_pair['disp_value'] = $account_name; } elseif ($ui_type == 53) { $user_id = $field_values[$j][$fld_name]; $username = getUserName($user_id); $group_info = getGroupName($field_values[$j]['record_id'], $module); $groupname = $group_info[0]; $groupid = $group_info[1]; if ($user_id != 0) { $value_pair['disp_value'] = $username; } else { $value_pair['disp_value'] = $groupname; } } elseif ($ui_type == 57) { $contact_id = $field_values[$j][$fld_name]; if ($contact_id != '') { $contactname = getContactName($contact_id); } $value_pair['disp_value'] = $contactname; } elseif ($ui_type == 75 || $ui_type == 81) { $vendor_id = $field_values[$j][$fld_name]; if ($vendor_id != '') { $vendor_name = getVendorName($vendor_id); } $value_pair['disp_value'] = $vendor_name; } elseif ($ui_type == 52) { $user_id = $field_values[$j][$fld_name]; $user_name = getUserName($user_id); $value_pair['disp_value'] = $user_name; } elseif ($ui_type == 68) { $parent_id = $field_values[$j][$fld_name]; $value_pair['disp_value'] = getAccountName($parent_id); if ($value_pair['disp_value'] == '' || $value_pair['disp_value'] == NULL) { $value_pair['disp_value'] = getContactName($parent_id); } } elseif ($ui_type == 59) { $product_name = getProductName($field_values[$j][$fld_name]); if ($product_name != '') { $value_pair['disp_value'] = $product_name; } else { $value_pair['disp_value'] = ''; } } elseif ($ui_type == 58) { $campaign_name = getCampaignName($field_values[$j][$fld_name]); if ($campaign_name != '') { $value_pair['disp_value'] = $campaign_name; } else { $value_pair['disp_value'] = ''; } } else { $value_pair['disp_value'] = $field_values[$j][$fld_name]; } $value_pair['org_value'] = $field_values[$j][$fld_name]; array_push($record_values[$c][$fld_label], $value_pair); } $c++; } } $parent_array[0] = $record_values; $parent_array[1] = $js_arr; $parent_array[2] = $fld_array; return $parent_array; }
<td align="center"><?php echo $player['id']; ?> </td> <td align="center"><a href="index.php?editor=player&playerid=<?php echo getPlayerID($player['name']); ?> "><?php echo $player['name']; ?> </a></td> <td align="center"><a href="index.php?editor=account&acctid=<?php echo $player['account_id']; ?> "><?php echo getAccountName($player['account_id']); ?> </a></td> <td align="center"><?php echo $classes[$player['class']]; ?> </td> <td align="center"><?php echo $player['level']; ?> </td> <td align="right"><a href="index.php?editor=player&playerid=<?php echo $player['id']; ?> "><img src="images/view_all.gif" width="13" height="13" border="0" title="View Player"></a></td> </tr>
//step2: compare timestart and reminder time //step3: send reminder to smownerid or groupname or inviter $dateTimeNow = date('Y-m-d H:i:s'); //New Reminder $query = "select * from ec_reminders where userid ='{$current_user->id}' and isused=0 and remindertime >= '" . $dateTimeNow . "'"; $result = $adb->query($query); if ($adb->num_rows($result) >= 1) { while ($result_set = $adb->fetch_array($result)) { $reminderid = $result_set['reminderid']; $remindertime = $result_set['remindertime']; $comments = $result_set['comments']; $crmid = $result_set['crmid']; $userid = $result_set['userid']; $subject = $app_strings["LBL_REMINDER"] . ":<a href=\"index.php?module=CustomReminder&action=PopupReminders\" target=\"_blank\">" . $comments . "</a>," . $remindertime; if ($crmid != "0" && $crmid != "" && $crmid != NULL) { $accountname = getAccountName($crmid); $subject = $subject . "," . $app_strings["Accounts"] . ":<a href=\"index.php?module=Accounts&action=DetaiView&record=" . $crmid . "\" target=\"_blank\">" . $accountname . "</a>"; } $curr_time = strtotime(date("Y-m-d H:i")) / 60; $current_date = date('Y-m-d'); $activity_time = strtotime(date("{$remindertime}")) / 60; $needed_remindertime = $activity_time - $curr_time; $reminder_time = 60; //$log->debug("****new remindertime:".$remindertime); //$log->debug("****new reminder_time:".$reminder_time); //$log->debug("****new activity_time:".$activity_time); //$log->debug("****new curr_time:".$curr_time); //$log->debug("****new needed_remindertime:".$needed_remindertime); if ($needed_remindertime > 0 && $needed_remindertime <= $reminder_time) { $upd_query = "UPDATE ec_reminders SET isused=1 where reminderid=" . $reminderid; $adb->query($upd_query);
function viewSurat($id, $token) { global $app; $app->response->headers->set("Content-Type", "application/pdf"); //include header include 'headerpdf.php'; $req = json_decode($app->request->getBody(), true); // $token = $req['token']; Jika menggunakan method POST // $id = $req['id']; $decode = JWT::decode($token, TK); $account = $decode->account; $id_jabatan = $decode->id_jabatan; $dbh = getDB(); // setReads($dbh, $id); $query = "SELECT surat.*, surat_terdistribusi.penerima, surat_kode_hal.deskripsi, users.nama, jabatan.jabatan from surat, surat_terdistribusi, surat_kode_hal, users, jabatan WHERE surat_terdistribusi.id=:id_surat AND surat_terdistribusi.id_surat = surat.id_surat AND (surat_terdistribusi.penerima = :id_jabatan OR surat_terdistribusi.penerima = :account) AND surat.kode_hal = surat_kode_hal.kode_hal AND ((surat_terdistribusi.penerima = users.account) OR (surat_terdistribusi.penerima = users.id_jabatan AND users.id_jabatan = jabatan.id_jabatan))"; $stmt = $dbh->prepare($query); $stmt->bindValue(':id_surat', (int) $id, PDO::PARAM_INT); $stmt->bindValue(':id_jabatan', $id_jabatan); $stmt->bindValue(':account', $account); try { $stmt->execute(); $row = $stmt->fetch(); $hal = $row['deskripsi']; // Mendapatkan deskripsi dari HAL $input = $row['isi']; // Mendapatkan isi dari surat // $tjb = $row['jabatan']; // $nama_pejabat = $row['nama']; $nosurat = $row['no_surat']; $lam = $row['lampiran']; $tanggal = convertDate($row['tanggal_surat']); $tjb = getJabatan($dbh, $row['penandatangan']); $nama_pejabat = getAccountName($dbh, $row['penandatangan']); $tembusan = explode("@+id/", $row['tembusan']); // Cari nama user berdasarkan jabatan parameter 'tujuan' // $query2 = "SELECT users.nama FROM users WHERE users.id_jabatan = :tujuan OR users.account = :tujuan"; $stmt2 = $dbh->prepare($query2); $stmt2->bindValue(":tujuan", $row['penerima']); try { $stmt2->execute(); if ($stmt2->rowCount() > 0) { // Jika ditemukan $row2 = $stmt2->fetch(); $tujuan2 = $row2['nama']; } else { // Jika tidak ditemukan, berarti suratnya ditujukan kepada pejabat. Cari di tabel pejabat $tujuan2 = getJabatan($dbh, $row['penerima']); } } catch (PDOException $ex) { echo $ex->getMessage(); } } catch (PDOException $e) { echo $e->getMessage(); } // add a page $pdf->AddPage(); //content PDF setlocale(LC_ALL, 'IND'); //$nosurat = '999/UN.39.18/TU/15'; //$tanggal = strftime("%d %B %Y"); $lam = '2'; //$hal = 'Pengajuan Peminjaman Scanner'; $tujuan = 'KEPALA BIRO ADM. UMUM dan KEUANGAN (BAUK)'; //$tujuan2 = 'KEPALA BIRO PERENCANAAN & SISTEM INFORMASI (BAPSI)'; $tujuan3 = 'KA. UPT PERPUSTAKAAN'; //$tjb = 'Ka. Pustikom'; $nip = '197408242005011001'; //$nama_pejabat = 'Hamidillah Adjie, ST'; //a. first //$pdf->Cell(0, 0, 'Nomor : '.$tes.' '.$tanggal.'', 0, false, 'L', 0, '', 0, false, 'M', 'M'); //$pdf->Ln(6); //$pdf->Cell(0, 0, 'Lamp :', 0, false, 'L', 0, '', 0, false, 'M', 'M'); //$pdf->Ln(6); //$pdf->Cell(0, 0, 'Hal :', 0, false, 'L', 0, '', 0, false, 'M', 'M'); //$pdf->Ln(6); $pdf->Ln(55); $pdf->SetFont('times', '', 12); //first $pdf->MultiCell(0, 0, '' . $tanggal . '', 0, 'L', 0, 0, 160, 53, true, 0, false, true, 0, 'M', true); //selisih turun cell 9 $pdf->MultiCell(0, 0, 'No', 0, 'L', 0, 0, 25, 53, true, 0, false, true, 0, 'M', true); //25 : margin dari kiri 53: margin dari atas $pdf->MultiCell(0, 0, ':', 0, 'L', 0, 0, 50, 53, true, 0, false, true, 0, 'M', true); $pdf->MultiCell(0, 0, 'Lampiran', 0, 'L', 0, 0, 25, 61, true, 0, false, true, 0, 'M', true); $pdf->MultiCell(0, 0, ':', 0, 'L', 0, 0, 50, 61, true, 0, false, true, 0, 'M', true); $pdf->MultiCell(0, 0, 'Hal', 0, 'L', 0, 0, 25, 69, true, 0, false, true, 0, 'M', true); $pdf->MultiCell(0, 0, ':', 0, 'L', 0, 0, 50, 69, true, 0, false, true, 0, 'M', true); $pdf->MultiCell(0, 0, '' . $nosurat . '', 0, 'L', 0, 0, 53, 53, true, 0, false, true, 0, 'M', true); $pdf->MultiCell(0, 0, '' . $lam . '', 0, 'L', 0, 0, 53, 61, true, 0, false, true, 0, 'M', true); $pdf->MultiCell(90, 17, '' . $hal . '', 0, 'L', 0, 0, 53, 69, true, 0, false, true, 0, 'T', true); //second $pdf->MultiCell(0, 0, 'Yth.', 0, 'L', 0, 0, 25, 88, true, 0, false, true, 0, 'M', true); $pdf->MultiCell(90, 6, '' . $tujuan2 . '', 0, 'L', 0, 0, 33, 88, true, 0, false, true, 0, 'M', true); $pdf->MultiCell(90, 6, 'Universitas Negeri Jakarta', 0, 'L', 0, 0, 33, 93, true, 0, false, true, 0, 'M', true); //third //$input = str_replace('<br />', '\n', $_POST['isi']); $html = $input; $pdf->MultiCell(170, 0, '' . $input . '' . "\n", 0, 'J', 0, 1, 25, 105, true, 0, true, true, 0, 'T', true); //nilai 1 setelah J adalah posisi cell default berada dibawah //$pdf->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml, $autopadding, $maxh); ////$pdf->writeHTML($html); // $pdf->setCellMargins(0, 7, 0, 0); $pdf->MultiCell(170, 0, '' . $tjb . '', 0, 'L', 0, 1, 140, '', true, 0, false, true, 0, 'T', true); $pdf->setCellMargins(0, 23, 0, 0); $pdf->MultiCell(170, 0, '' . $nama_pejabat . '', 0, 'L', 0, 1, 140, '', true, 0, false, true, 0, 'T', true); $pdf->setCellMargins(0, 0, 0, 0); $pdf->MultiCell(170, 0, 'NIP' . ".{$nip}.", 0, 'L', 0, 1, 140, '', true, 0, false, true, 0, 'T', true); //Tembusan $pdf->setCellMargins(0, 10, 0, 0); $pdf->MultiCell(170, 0, 'Tembusan :', 0, 'L', 0, 1, 25, '', true, 0, false, true, 0, 'T', true); $pdf->setCellMargins(0, 0, 0, 0); for ($i = 0; $i < count($tembusan); $i++) { if ($tembusan[$i] != '') { $pdf->MultiCell(170, 0, $i + 1 . '. ' . getJabatan($dbh, $tembusan[$i]), 0, 'L', 0, 1, 25, '', true, 0, false, true, 0, 'T', true); } } // create some HTMNomor : L content //$html = '<span style="text-align:justify;">a <u>abc</u> abcdefghijkl (abcdef) abcdefg <b>abcdefghi</b> a ((abc)) abcd <img src="images/logo_example.png" border="0" height="41" width="41" /> <img src="images/tcpdf_box.svg" alt="test alt attribute" width="80" height="60" border="0" /> abcdef abcdefg <b>abcdefghi</b> a abc abcd abcdef abcdefg <b>abcdefghi</b> a abc abcd abcdef abcdefg <b>abcdefghi</b> a <u>abc</u> abcd abcdef abcdefg <b>abcdefghi</b> a abc \(abcd\) abcdef abcdefg <b>abcdefghi</b> a abc \\\(abcd\\\) abcdef abcdefg <b>abcdefghi</b> a abc abcd abcdef abcdefg <b>abcdefghi</b> a abc abcd abcdef abcdefg <b>abcdefghi</b> a abc abcd abcdef abcdefg abcdefghi a abc abcd <a href="http://tcpdf.org">abcdef abcdefg</a> start a abc before <span style="background-color:yellow">yellow color</span> after a abc abcd abcdef abcdefg abcdefghi a abc abcd end abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi<br />abcd abcdef abcdefg abcdefghi<br />abcd abcde abcdef</span>'; //$html = "<span>Much playing will only make you happy temporarily</span>"; //$input = $_POST['isi']; // set core font $pdf->SetFont('helvetica', '', 10); // output the HTML content //$pdf->writeHTML($html, true, 0, true, true); $pdf->Ln(); // set UTF-8 Unicode font $pdf->SetFont('dejavusans', '', 10); // output the HTML content //$pdf->writeHTML($html, true, 0, true, true,'J'); //$pdf->Write(0, $input); // reset pointer to the last page $pdf->lastPage(); // --------------------------------------------------------- //Close and output PDF document $nama_pengirim = $_POST['sender']; $nama_file = $nosurat . '.pdf'; $output = $pdf->Output('', 'S'); $savePdf = addslashes($output); $pdf->Output($nama_file, 'I'); }
update_account(); header("Location: index.php?editor=account&acctid={$acctid}"); exit; case 4: // Delete Account check_admin_authorization(); delete_account($acctid); header("Location: index.php?editor=account"); exit; case 5: // Character Transfer Selection check_admin_authorization(); $body = new Template("templates/account/account.chartransfer.tmpl.php"); $javascript = new Template("templates/account/js.tmpl.php"); $body->set('acctid', $acctid); $body->set('acctname', getAccountName($acctid)); $body->set('target_accounts', $target_accounts); break; case 6: // Transfer Character check_admin_authorization(); char_transfer(); header("Location: index.php?editor=account&acctid={$acctid}"); exit; case 7: // Edit Account Status check_admin_authorization(); $cur_acct_status = get_account_status(); $body = new Template("templates/account/account.status.tmpl.php"); $body->set('acctid', $acctid); $body->set('cur_acct_status', $cur_acct_status);
/** * Function to Recursively get all the child contacts of a given Contact * @param integer $id - contactid * @param array $child_contacts - Array of all the child contacts * @param integer $depth - Depth at which the particular contact has to be placed in the hierarchy * returns All the child contacts of the given contactid in array format */ function __getChildContacts($id, &$child_contacts, $depth) { global $log, $adb; $log->debug("Entering __getChildContacts({$id}," . print_r($child_contacts, true) . ",{$depth}) method ..."); $query = "SELECT vtiger_contactdetails.*, " . " CASE when (vtiger_users.user_name not like '') THEN vtiger_users.user_name ELSE vtiger_groups.groupname END as user_name " . " FROM vtiger_contactdetails" . " INNER JOIN vtiger_crmentity " . " ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid" . " LEFT JOIN vtiger_groups" . " ON vtiger_groups.groupid = vtiger_crmentity.smownerid" . " LEFT JOIN vtiger_users" . " ON vtiger_users.id = vtiger_crmentity.smownerid" . " WHERE vtiger_crmentity.deleted = 0 and reportsto = ?"; $params = array($id); $res = $adb->pquery($query, $params); $num_rows = $adb->num_rows($res); if ($num_rows > 0) { $depth = $depth + 1; for ($i = 0; $i < $num_rows; $i++) { $child_acc_id = $adb->query_result($res, $i, 'contactid'); if (array_key_exists($child_acc_id, $child_contacts)) { continue; } $child_contact_info = array(); $child_contact_info['depth'] = $depth; foreach ($this->list_fields_name as $fieldname => $columnname) { if ($columnname == 'account_id') { $accountid = $adb->query_result($res, $i, 'accountid'); $accountname = getAccountName($accountid); $child_contact_info[$columnname] = '<a href="index.php?module=Accounts&action=DetailView&record=' . $accountid . '">' . $accountname . '</a>'; } else { if ($columnname == 'assigned_user_id') { $child_contact_info[$columnname] = $adb->query_result($res, $i, 'user_name'); } else { $child_contact_info[$columnname] = $adb->query_result($res, $i, $columnname); } } } $child_contacts[$child_acc_id] = $child_contact_info; $this->__getChildContacts($child_acc_id, $child_contacts, $depth); } } $log->debug('Exiting __getChildContacts method ...'); return $child_contacts; }
private function x0e($emodule, $efocus, $is_related = false, $is_inventory = false) { global $x0b, $x0c, $x0d, $x0e, $x0f, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x1a, $x1b, $x1c, $x1d, $x1e, $x1f, $x20, $x21, $x22, $x23, $x24, $x25, $x26; $related_fieldnames = array("related_to", "relatedto", "parent_id", "parentid", "product_id", "productid", "service_id", "serviceid", "vendor_id", "product", "account", "invoiceid", "linktoaccountscontacts", "projectid", "sc_related_to"); if ($is_inventory) { $inventory_content = array(); } $tabid = getTabid($emodule); if ($is_related) { $related = "R_"; } else { $related = ""; } $Checkboxes = array(); $Picklists = array(); $Textareas = array(); $Datefields = array(); $Multipicklists = array(); $NumbersField = array(); $sql = "SELECT fieldname, uitype FROM vtiger_field WHERE tabid = '" . $tabid . "'"; $result = $this->db->query($sql); while ($row = $this->db->fetchByAssoc($result)) { if ($row["uitype"] == "19" || $row["uitype"] == "20" || $row["uitype"] == "21" || $row["uitype"] == "24") { $Textareas[] = $row["fieldname"]; } elseif ($row["uitype"] == "5" || $row["uitype"] == "23" || $row["uitype"] == "70") { $Datefields[] = $row["fieldname"]; } elseif ($row["uitype"] == "15" || $row["fieldname"] == "salutationtype") { $Picklists[] = $row["fieldname"]; } elseif ($row["uitype"] == "56") { $Checkboxes[] = $row["fieldname"]; } elseif ($row["uitype"] == "33") { $Multipicklists[] = $row["fieldname"]; } elseif ($row["uitype"] == "71") { $NumbersField[] = $row["fieldname"]; } } foreach ($efocus->column_fields as $fieldname => $value) { if ($fieldname == "assigned_user_id") { $value = $this->x19($value); } elseif ($fieldname == "account_id") { $value = getAccountName($value); } elseif ($fieldname == "potential_id") { $value = getPotentialName($value); } elseif ($fieldname == "contact_id") { $value = getContactName($value); } elseif ($fieldname == "quote_id") { $value = getQuoteName($value); } elseif ($fieldname == "salesorder_id") { $value = getSoName($value); } elseif ($fieldname == "campaignid") { $value = getCampaignName($value); } elseif ($fieldname == "terms_conditions") { $value = $this->x20($value); } elseif ($fieldname == "comments") { $value = $this->x21($efocus); } elseif ($fieldname == "folderid") { $value = $this->x22($value); } elseif ($x16($fieldname, $related_fieldnames)) { if ($value != "") { $parent_module = getSalesEntityType($value); $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $p_value) { $value = $p_value; } } if ($fieldname == "invoiceid" && $value == "0") { $value = ""; } } } if ($x16($fieldname, $Datefields)) { $value = getValidDisplayDate($value); } elseif ($x16($fieldname, $Picklists)) { if (!$x16($x26($value), $this->ignored_picklist_values)) { $value = $this->x1b($value, $emodule); } else { $value = ""; } } elseif ($x16($fieldname, $Checkboxes)) { $pdf_app_strings = return_application_language($this->language); if ($value == 1) { $value = $pdf_app_strings["yes"]; } else { $value = $pdf_app_strings["no"]; } } elseif ($x16($fieldname, $Textareas)) { $value = $x1a($value); } elseif ($x16($fieldname, $Multipicklists)) { $value = $x1f(' |##| ', ', ', $value); } elseif ($x16($fieldname, $NumbersField)) { $value = $this->x1e($value); } if ($is_inventory) { $inventory_content[$x22($emodule . "_" . $fieldname)] = $value; } else { $this->replacements["\$" . $related . $x22($emodule . "_" . $fieldname) . "\$"] = $value; } } if ($is_inventory) { return $inventory_content; } else { $this->x12(); } }
function getSearchingListViewEntries($focus, $module, $list_result, $navigation_array, $relatedlist = '', $returnset = '', $edit_action = 'EditView', $del_action = 'Delete', $oCv = '', $page = '', $selectedfields = '', $contRelatedfields = '', $skipActions = false, $linksallowed = false) { global $log; global $mod_strings; $log->debug("Entering getSearchingListViewEntries(" . get_class($focus) . "," . $module . "," . $list_result . "," . $navigation_array . "," . $relatedlist . "," . $returnset . "," . $edit_action . "," . $del_action . "," . (is_object($oCv) ? get_class($oCv) : $oCv) . ") method ..."); $tabname = getParentTab(); global $adb, $current_user; global $app_strings; $noofrows = $adb->num_rows($list_result); $list_block = array(); global $theme; $evt_status = ''; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; //getting the vtiger_fieldtable entries from database $tabid = getTabid($module); //added for vtiger_customview 27/5 if ($oCv) { if (isset($oCv->list_fields)) { $focus->list_fields = $oCv->list_fields; } } if (is_array($selectedfields) && $selectedfields != '') { $focus->list_fields = $selectedfields; } // Remove fields which are made inactive $focus->filterInactiveFields($module); //Added to reduce the no. of queries logging for non-admin user -- by minnie-start $field_list = array(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; foreach ($focus->list_fields as $name => $tableinfo) { $fieldname = $focus->list_fields_name[$name]; if ($oCv) { if (isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; } } if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } array_push($field_list, $fieldname); } $field = array(); if ($is_admin == false) { if ($module == 'Emails') { $query = "SELECT fieldname FROM vtiger_field WHERE tabid = ? and vtiger_field.presence in (0,2)"; $params = array($tabid); } else { $profileList = getCurrentUserProfileList(); $params = array(); $query = "SELECT DISTINCT vtiger_field.fieldname\n\t\t\tFROM vtiger_field\n\t\t\tINNER JOIN vtiger_profile2field\n\t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\tINNER JOIN vtiger_def_org_field\n\t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid"; if ($module == "Calendar") { $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)"; } else { $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)"; array_push($params, $tabid); } $query .= " AND vtiger_profile2field.visible = 0\n\t\t\tAND vtiger_profile2field.visible = 0\n\t\t\tAND vtiger_def_org_field.visible = 0\n\t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\n\t\t\tAND vtiger_field.fieldname IN (" . generateQuestionMarks($field_list) . ")"; array_push($params, $profileList, $field_list); } $result = $adb->pquery($query, $params); for ($k = 0; $k < $adb->num_rows($result); $k++) { $field[] = $adb->query_result($result, $k, "fieldname"); } } //constructing the uitype and columnname array $ui_col_array = array(); $params = array(); $query = "SELECT uitype, columnname, fieldname FROM vtiger_field "; if ($module == "Calendar") { $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)"; } else { $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)"; array_push($params, $tabid); } $query .= " AND fieldname IN (" . generateQuestionMarks($field_list) . ") "; array_push($params, $field_list); $result = $adb->pquery($query, $params); $num_rows = $adb->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $tempArr = array(); $uitype = $adb->query_result($result, $i, 'uitype'); $columnname = $adb->query_result($result, $i, 'columnname'); $field_name = $adb->query_result($result, $i, 'fieldname'); $tempArr[$uitype] = $columnname; $ui_col_array[$field_name] = $tempArr; } //end if ($navigation_array['start'] != 0) { for ($i = 1; $i <= $noofrows; $i++) { $list_header = array(); //Getting the entityid if ($module != 'Users') { $entity_id = $adb->query_result($list_result, $i - 1, "crmid"); $owner_id = $adb->query_result($list_result, $i - 1, "smownerid"); } else { $entity_id = $adb->query_result($list_result, $i - 1, "id"); } foreach ($focus->list_fields as $name => $tableinfo) { $fieldname = $focus->list_fields_name[$name]; //added for vtiger_customview 27/5 if ($oCv) { if (isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } } else { $fieldname = $focus->list_fields_name[$name]; } } else { $fieldname = $focus->list_fields_name[$name]; if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } } if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || in_array($fieldname, $field) || $fieldname == '' || $name == 'Close' && $module == 'Calendar') { if ($fieldname == '') { $table_name = ''; $column_name = ''; foreach ($tableinfo as $tablename => $colname) { $table_name = $tablename; $column_name = $colname; } $value = $adb->query_result($list_result, $i - 1, $colname); } else { if ($module == 'Calendar') { $act_id = $adb->query_result($list_result, $i - 1, "activityid"); $cal_sql = "select activitytype from vtiger_activity where activityid=?"; $cal_res = $adb->pquery($cal_sql, array($act_id)); if ($adb->num_rows($cal_res) >= 0) { $activitytype = $adb->query_result($cal_res, 0, "activitytype"); } } if (($module == 'Calendar' || $module == 'Emails' || $module == 'HelpDesk' || $module == 'Invoice' || $module == 'Leads' || $module == 'Contacts') && ($fieldname == 'parent_id' || $name == 'Contact Name' || $name == 'Close' || $fieldname == 'firstname')) { if ($module == 'Calendar') { if ($fieldname == 'status') { if ($activitytype == 'Task') { $fieldname = 'taskstatus'; } else { $fieldname = 'eventstatus'; } } if ($activitytype == 'Task') { if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') { $has_permission = 'yes'; } else { $has_permission = 'no'; } } else { if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') { $has_permission = 'yes'; } else { $has_permission = 'no'; } } } if ($module != 'Calendar' || $module == 'Calendar' && $has_permission == 'yes') { if ($fieldname == 'parent_id') { $value = getRelatedTo($module, $list_result, $i - 1); } if ($name == 'Contact Name') { $contact_id = $adb->query_result($list_result, $i - 1, "contactid"); $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts"); $value = ""; //Added to get the contactname for activities custom view - t=2190 if ($contact_id != '' && !empty($contact_name)) { $contact_name = getContactName($contact_id); } if ($contact_name != "" && $contact_id != 'NULL') { $value = $contact_name; } } if ($fieldname == "firstname") { $first_name = textlength_check($adb->query_result($list_result, $i - 1, "firstname")); $value = $first_name; } if ($name == 'Close') { $status = $adb->query_result($list_result, $i - 1, "status"); $activityid = $adb->query_result($list_result, $i - 1, "activityid"); if (empty($activityid)) { $activityid = $adb->query_result($list_result, $i - 1, "tmp_activity_id"); } $activitytype = $adb->query_result($list_result, $i - 1, "activitytype"); // TODO - Picking activitytype when it is not present in the Custom View. // Going forward, this column should be added to the select list if not already present as a performance improvement. if (empty($activitytype)) { $activitytypeRes = $adb->pquery('SELECT activitytype FROM vtiger_activity WHERE activityid=?', array($activityid)); if ($adb->num_rows($activitytypeRes) > 0) { $activitytype = $adb->query_result($activitytypeRes, 0, 'activitytype'); } } if ($activitytype != 'Task' && $activitytype != 'Emails') { $eventstatus = $adb->query_result($list_result, $i - 1, "eventstatus"); if (isset($eventstatus)) { $status = $eventstatus; } } if ($status == 'Deferred' || $status == 'Completed' || $status == 'Held' || $status == '') { $value = ""; } else { if ($activitytype == 'Task') { $evt_status = '&status=Completed'; } else { $evt_status = '&eventstatus=Held'; } } } } else { $value = ""; } } elseif ($module == "Documents" && ($fieldname == 'filelocationtype' || $fieldname == 'filename' || $fieldname == 'filesize' || $fieldname == 'filestatus' || $fieldname == 'filetype')) { $value = $adb->query_result($list_result, $i - 1, $fieldname); if ($fieldname == 'filelocationtype') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } if ($fieldname == 'filename') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); if ($downloadtype == 'I') { $fld_value = $value; $ext_pos = strrpos($fld_value, "."); $ext = substr($fld_value, $ext_pos + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fld_value = $value; $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $fld_value = '--'; $fileicon = ''; } } else { $fld_value = ' --'; $fileicon = ''; } $file_name = $adb->query_result($list_result, $i - 1, 'filename'); $notes_id = $adb->query_result($list_result, $i - 1, 'crmid'); $folder_id = $adb->query_result($list_result, $i - 1, 'folderid'); $download_type = $adb->query_result($list_result, $i - 1, 'filelocationtype'); $file_status = $adb->query_result($list_result, $i - 1, 'filestatus'); $fileidQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileidres = $adb->pquery($fileidQuery, array($notes_id)); $fileid = $adb->query_result($fileidres, 0, 'attachmentsid'); if ($file_name != '' && $file_status == 1) { if ($download_type == 'I') { $fld_value = "<a href='index.php?module=uploads&action=downloadfile&entityid={$notes_id}&fileid={$fileid}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$notes_id});'>" . $fld_value . "</a>"; } elseif ($download_type == 'E') { $fld_value = "<a target='_blank' href='{$file_name}' onclick='javascript:dldCntIncrease({$notes_id});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . $fld_value . "</a>"; } else { $fld_value = ' --'; } } $value = $fileicon . $fld_value; } if ($fieldname == 'filesize') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); if ($downloadtype == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } if ($fieldname == 'filestatus') { $filestatus = $value; if ($filestatus == 1) { $value = getTranslatedString('yes', $module); } elseif ($filestatus == 0) { $value = getTranslatedString('no', $module); } else { $value = ' --'; } } if ($fieldname == 'filetype') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); $filetype = $adb->query_result($list_result, $i - 1, 'filetype'); if ($downloadtype == 'E' || $downloadtype != 'I') { $value = ' --'; } else { $value = $filetype; } } if ($fieldname == 'notecontent') { $value = decode_html($value); $value = textlength_check($value); } } elseif ($module == "Products" && $name == "Related to") { $value = getRelatedTo($module, $list_result, $i - 1); } elseif ($name == 'Contact Name' && ($module == 'SalesOrder' || $module == 'Quotes' || $module == 'PurchaseOrder')) { if ($name == 'Contact Name') { $contact_id = $adb->query_result($list_result, $i - 1, "contactid"); $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts"); $value = ""; if ($contact_name != "" && $contact_id != 'NULL') { $value = $contact_name; } } } elseif ($name == 'Product') { $product_id = textlength_check($adb->query_result($list_result, $i - 1, "productname")); $value = $product_id; } elseif ($name == 'Account Name') { //modified for vtiger_customview 27/5 if ($module == 'Accounts') { $account_id = $adb->query_result($list_result, $i - 1, "crmid"); //$account_name = getAccountName($account_id); $account_name = textlength_check($adb->query_result($list_result, $i - 1, "accountname")); $value = $account_name; } elseif ($module == 'Potentials' || $module == 'Contacts' || $module == 'Invoice' || $module == 'SalesOrder' || $module == 'Quotes') { //Potential,Contacts,Invoice,SalesOrder & Quotes records sort by Account Name //$accountname = textlength_check($adb->query_result($list_result,$i-1,"accountname")); $accountid = $adb->query_result($list_result, $i - 1, "accountid"); $accountname = textlength_check(getAccountName($accountid)); $value = $accountname; } else { $account_id = $adb->query_result($list_result, $i - 1, "accountid"); $account_name = getAccountName($account_id); $acc_name = textlength_check($account_name); $value = $acc_name; } } elseif (($module == 'HelpDesk' || $module == 'PriceBook' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'Faq') && $name == 'Product Name') { if ($module == 'HelpDesk' || $module == 'Faq') { $product_id = $adb->query_result($list_result, $i - 1, "product_id"); } else { $product_id = $adb->query_result($list_result, $i - 1, "productid"); } if ($product_id != '') { $product_name = getProductName($product_id); } else { $product_name = ''; } $value = textlength_check($product_name); } elseif ($module == 'Quotes' && $name == 'Potential Name' || $module == 'SalesOrder' && $name == 'Potential Name') { $potential_id = $adb->query_result($list_result, $i - 1, "potentialid"); $potential_name = getPotentialName($potential_id); $value = textlength_check($potential_name); } elseif ($module == 'Emails' && $relatedlist != '' && ($name == 'Subject' || $name == 'Date Sent' || $name == 'To')) { $list_result_count = $i - 1; $tmp_value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid, false); $tmp_value = evvt_strip_html_links($tmp_value); $value = textlength_check($tmp_value); if ($name == 'Date Sent') { $sql = "select email_flag from vtiger_emaildetails where emailid=?"; $result = $adb->pquery($sql, array($entity_id)); $email_flag = $adb->query_result($result, 0, "email_flag"); if ($email_flag != 'SAVED') { $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid, false); $value = evvt_strip_html_links($value); } else { $value = ''; } } } elseif ($module == 'Calendar' && ($fieldname != 'taskstatus' && $fieldname != 'eventstatus')) { if ($activitytype == 'Task') { if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid, false); $value = evvt_strip_html_links($value); } else { $value = ''; } } else { if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid, false); $value = evvt_strip_html_links($value); } else { $value = ''; } } } else { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid, false); $value = evvt_strip_html_links($value); } } // vtlib customization: For listview javascript triggers //$value = "$value <span type='vtlib_metainfo' vtrecordid='{$entity_id}' vtfieldname='{$fieldname}' vtmodule='$module' style='display:none;'></span>"; // END if ($module == "Calendar" && $name == $app_strings['Close']) { if (isPermitted("Calendar", "EditView") == 'yes') { if (getFieldVisibilityPermission('Events', $current_user->id, 'eventstatus') == '0' || getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') { array_push($list_header, $value); } } } else { $list_header[] = $value; } } } $varreturnset = ''; $varreturnset = $returnset; $webserviceEntityId = vtyiicpng_getWSEntityId($module); $list_header[] = $webserviceEntityId . $entity_id; $list_header[] = $module; $list_block[$entity_id] = $list_header; } } $log->debug("Exiting getSearchingListViewEntries method ..."); return $list_block; }
<?php $from_acct = getAccountName($acctid); ?> <div id="searchblock" style="display:none;"> <center> <iframe src="templates/iframes/accountsearch.php" style="display:block;"></iframe> <input type="button" value="Hide Search" onclick="hideSearch();"> </center><br/> </div> <div class="table_container" style="width:250px;"> <div class="table_header"> Character Transfer </div> <div class="table_content"> <form id="transfer" method="post" action="index.php?editor=account&acctid=<?php echo $acctid; ?> &playerid=<?php echo $_GET['playerid']; ?> &action=6"> <center> Transfer <strong><font color="green"><?php echo getPlayerName($_GET['playerid']); ?> </font></strong> from<br/><br/> <strong><?php echo $from_acct; ?> </strong><br/><br/>
function getValue($uitype, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, $mode, $popuptype, $returnset = '', $viewid = '') { global $log; global $app_strings; //changed by dingjianting on 2007-11-05 for php5.2.x $log->debug("Entering getValue() method ..."); global $adb, $current_user; if ($uitype == 10) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val != "") { $value = ""; $module_entityname = ""; $modulename_lower = substr($fieldname, 0, -2); $modulename = ucfirst($modulename_lower); $modulesid = $modulename_lower . "id"; $tablename = "ec_" . $modulename_lower; $entityname = substr($fieldname, 0, -3) . "name"; $query = "SELECT {$entityname} FROM {$tablename} WHERE {$modulesid}='" . $temp_val . "' and deleted=0"; $fldmod_result = $adb->query($query); $rownum = $adb->num_rows($fldmod_result); if ($rownum > 0) { $value = $adb->query_result($fldmod_result, 0, $entityname); } } else { $value = ''; } } elseif ($uitype == 52 || $uitype == 53 || $uitype == 77) { $value = $adb->query_result($list_result, $list_result_count, 'user_name'); } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if (isValidDate($temp_val)) { $value = getDisplayDate($temp_val); } else { $value = ''; } } elseif ($uitype == 33) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = str_ireplace(' |##| ', ', ', $temp_val); } elseif ($uitype == 17) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = '<a href="http://' . $temp_val . '" target="_blank">' . $temp_val . '</a>'; } elseif ($uitype == 13 || $uitype == 104) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = '<a href="' . getComposeMailUrl($temp_val) . '" target="_blank">' . $temp_val . '</a>'; } elseif ($uitype == 56) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val == 1) { $value = 'yes'; } else { $value = 'no'; } //changed by dingjianting on 2006-10-15 for simplized chinese if (isset($app_strings[$value])) { $value = $app_strings[$value]; } } elseif ($uitype == 51 || $uitype == 73 || $uitype == 50) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val != '') { $value = getAccountName($temp_val); } else { $value = ''; } } elseif ($uitype == 59) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val != '') { $value = getProductName($temp_val); } else { $value = ''; } } elseif ($uitype == 76) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val != '') { $value = getPotentialName($temp_val); } else { $value = ''; } } elseif ($uitype == 80) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val != '') { $value = getSoName($temp_val); } else { $value = ''; } } elseif ($uitype == 1004) { $value = $adb->query_result($list_result, $list_result_count, 'smcreatorid'); $value = getUserName($value); } elseif ($uitype == 1007) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = getApproveStatusById($temp_val); } elseif ($uitype == 1008) { $value = $adb->query_result($list_result, $list_result_count, 'approvedby'); $value = getUserName($value); } elseif ($uitype == 1004) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = getUserName($temp_val); } elseif ($uitype == 1007) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val == '1') { $value = $app_strings["already_approved"]; } elseif ($temp_val == '-1') { $value = $app_strings["unapproved"]; } elseif ($temp_val == '-2') { $value = $app_strings["Rejected"]; } else { $value = $app_strings["approving"]; } } elseif ($uitype == 1008) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = getUserName($temp_val); } else { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($fieldname != $focus->list_link_field) { $value = $temp_val; } else { if ($mode == "list") { $tabname = getParentTab(); $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($mode == "search") { if ($popuptype == "specific") { $temp_val = str_replace("'", '\\"', $temp_val); $temp_val = popup_from_html($temp_val); //Added to avoid the error when select SO from Invoice through AjaxEdit if ($module == 'Salesorders') { $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . br2nl($temp_val) . '","' . $_REQUEST['form'] . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . br2nl($temp_val) . '");\'>' . $temp_val . '</a>'; } } elseif ($popuptype == "detailview") { $temp_val = popup_from_html($temp_val); $focus->record_id = $_REQUEST['recordid']; if ($_REQUEST['return_module'] == "Calendar") { $value = '<a href="javascript:window.close();" id="calendarCont' . $entity_id . '" LANGUAGE=javascript onclick=\'add_data_to_relatedlist_incal("' . $entity_id . '","' . $temp_val . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'add_data_to_relatedlist("' . $entity_id . '","' . $focus->record_id . '","' . $module . '");\'>' . $temp_val . '</a>'; } } elseif ($popuptype == "formname_specific") { $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_formname_specific("' . $_REQUEST['form'] . '", "' . $entity_id . '", "' . br2nl($temp_val) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); $qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); $productcode = $adb->query_result($list_result, $list_result_count, 'productcode'); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . $unitprice . '", "' . $qty_stock . '","' . $tax_str . '","' . $row_id . '","' . $productcode . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prods") { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); $qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); $productcode = $adb->query_result($list_result, $list_result_count, 'productcode'); $serialno = $adb->query_result($list_result, $list_result_count, 'serialno'); $temp_val = popup_from_html($temp_val); $value = $temp_val . '<input type="hidden" name="productname_' . $entity_id . '" id="productname_' . $entity_id . '" value="' . $temp_val . '"><input type="hidden" name="listprice_' . $entity_id . '" id="listprice_' . $entity_id . '" value="' . $unitprice . '"><input type="hidden" name="qtyinstock_' . $entity_id . '" id="qtyinstock_' . $entity_id . '" value="' . $qty_stock . '"><input type="hidden" id="productcode_' . $entity_id . '" name="productcode_' . $entity_id . '" value="' . $productcode . '"><input type="hidden" id="serialno_' . $entity_id . '" name="serialno_' . $entity_id . '" value="' . $serialno . '">'; } elseif ($popuptype == "salesorder_prod") { $row_id = $_REQUEST['curr_row']; $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); $temp_val = popup_from_html($temp_val); $producttype = $_REQUEST['producttype']; $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_so("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . $unitprice . '", "' . $row_id . '","' . $producttype . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod_po") { $row_id = $_REQUEST['curr_row']; $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); $productcode = $adb->query_result($list_result, $list_result_count, 'productcode'); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_po("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . $unitprice . '", "' . $productcode . '","' . $row_id . '"); \'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod_noprice") { $row_id = $_REQUEST['curr_row']; $temp_val = popup_from_html($temp_val); $qtyinstock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); $productcode = $adb->query_result($list_result, $list_result_count, 'productcode'); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_noprice("' . $entity_id . '", "' . br2nl($temp_val) . '","' . $row_id . '","' . $qtyinstock . '","' . $productcode . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod_check") { $row_id = $_REQUEST['curr_row']; $temp_val = popup_from_html($temp_val); $productcode = $adb->query_result($list_result, $list_result_count, 'productcode'); $usageunit = $adb->query_result($list_result, $list_result_count, 'usageunit'); $qtyinstock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_check("' . $entity_id . '", "' . br2nl($temp_val) . '","' . $row_id . '","' . $productcode . '","' . $usageunit . '","' . $qtyinstock . '"); \'>' . $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"); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . br2nl($acct_focus->column_fields['bill_street']) . '", "' . br2nl($acct_focus->column_fields['ship_street']) . '", "' . br2nl($acct_focus->column_fields['bill_city']) . '", "' . br2nl($acct_focus->column_fields['ship_city']) . '", "' . br2nl($acct_focus->column_fields['bill_state']) . '", "' . br2nl($acct_focus->column_fields['ship_state']) . '", "' . br2nl($acct_focus->column_fields['bill_code']) . '", "' . br2nl($acct_focus->column_fields['ship_code']) . '", "' . br2nl($acct_focus->column_fields['bill_country']) . '", "' . br2nl($acct_focus->column_fields['ship_country']) . '","' . br2nl($acct_focus->column_fields['bill_pobox']) . '", "' . br2nl($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_contact_account_address") { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($entity_id, "Accounts"); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . br2nl($acct_focus->column_fields['bill_street']) . '", "' . br2nl($acct_focus->column_fields['ship_street']) . '", "' . br2nl($acct_focus->column_fields['bill_city']) . '", "' . br2nl($acct_focus->column_fields['ship_city']) . '", "' . br2nl($acct_focus->column_fields['bill_state']) . '", "' . br2nl($acct_focus->column_fields['ship_state']) . '", "' . br2nl($acct_focus->column_fields['bill_code']) . '", "' . br2nl($acct_focus->column_fields['ship_code']) . '", "' . br2nl($acct_focus->column_fields['bill_country']) . '", "' . br2nl($acct_focus->column_fields['ship_country']) . '","' . br2nl($acct_focus->column_fields['bill_pobox']) . '", "' . br2nl($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_potential_account_address") { $acntid = $adb->query_result($list_result, $list_result_count, "accountid"); if ($acntid != "") { //require_once('modules/Accounts/Accounts.php'); //$acct_focus = new Accounts(); //$acct_focus->retrieve_entity_info($acntid,"Accounts"); $account_name = getAccountName($acntid); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . $acntid . '", "' . br2nl($account_name) . '");\'>' . $temp_val . '</a>'; } else { $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" >' . $temp_val . '</a>'; } } elseif ($popuptype == "set_return_emails") { $name = $adb->query_result($list_result, $list_result_count, "lastname"); $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); if ($emailaddress == '') { $emailaddress = $adb->query_result($list_result, $list_result_count, "msn"); } $where = isset($_REQUEST['where']) ? $_REQUEST['where'] : ""; $value = '<a href="javascript:;" onclick=\'return set_return_emails("' . $where . '","' . $name . '","' . $emailaddress . '"); \'>' . $name . '</a>'; } elseif ($popuptype == "set_return_mobiles") { //$firstname=$adb->query_result($list_result,$list_result_count,"first_name"); $contactname = $adb->query_result($list_result, $list_result_count, "lastname"); $mobile = $adb->query_result($list_result, $list_result_count, "mobile"); //changed by dingjianting on 2006-11-9 for simplized chinese $value = '<a href="#" onclick=\'return set_return_mobiles(' . $entity_id . ',"' . $contactname . '","' . $mobile . '"); \'>' . $contactname . '</a>'; } elseif ($popuptype == "set_return_usermobiles") { //$firstname=$adb->query_result($list_result,$list_result_count,"first_name"); $lastname = $adb->query_result($list_result, $list_result_count, "last_name"); $mobile = $adb->query_result($list_result, $list_result_count, "phone_mobile"); //changed by dingjianting on 2006-11-9 for simplized chinese $value = '<a href="#" onclick=\'return set_return_mobiles(' . $entity_id . ',"' . $lastname . '","' . $mobile . '"); \'>' . $lastname . '</a>'; } else { $temp_val = str_replace("'", '\\"', $temp_val); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return("' . $entity_id . '", "' . br2nl($temp_val) . '");\'>' . $temp_val . '</a>'; } } } } $log->debug("Exiting getValue method ..."); return $value; }
function getAllFavorites($token, $offset, $limit) { $db = getDB(); $decode = JWT::decode($token, TK); $account = $decode->account; $id_jabatan = $decode->id_jabatan; // if ($jabatan->status) { $query = "SELECT surat.*, surat_terdistribusi.*, institusi.nama_institusi, surat_kode_hal.deskripsi FROM `surat_terdistribusi`, `surat`, `institusi`, `surat_kode_hal` WHERE (surat_terdistribusi.penerima=:account or surat_terdistribusi.penerima=:idJabatan) AND surat_terdistribusi.id_surat = surat.id_surat AND surat.kode_lembaga_pengirim = institusi.id_institusi AND surat.ditandatangani = '1' AND surat_kode_hal.kode_hal = surat.kode_hal AND surat_terdistribusi.isFavorite = :isFavorite ORDER BY surat.created DESC LIMIT :limit OFFSET :offset"; // } else { // $query = "SELECT surat.*, surat_terdistribusi.*, operator.*, institusi.* FROM `surat_terdistribusi`, `surat`, `operator`, `institusi` WHERE surat_terdistribusi.penerima=:account AND surat_terdistribusi.id_surat = surat.id_surat AND surat.id_operator = operator.id_operator AND operator.id_institusi = institusi.id_institusi AND surat_terdistribusi.is_favorite='1' ORDER BY surat.created DESC"; // } $stmt = $db->prepare($query); $stmt->bindValue(":account", $account); $stmt->bindValue(":idJabatan", $id_jabatan); $stmt->bindValue(":limit", (int) $limit, PDO::PARAM_INT); $stmt->bindValue(":offset", (int) $offset, PDO::PARAM_INT); $stmt->bindValue(":isFavorite", 1, PDO::PARAM_INT); $stmt->execute(); if ($stmt->rowCount() > 0) { $i = 0; while ($row = $stmt->fetch()) { if ($row['penerima'] == $id_jabatan) { $role = $id_jabatan; } else { $role = $account; } // $output[$i] = array("pengirim" => $row['nama_institusi'], "id" => $row['id'], "hal" => $row['deskripsi'], "subject" => $row['subject_surat'], "role" => $role, "notif_web" => filter_var($row['notif_web'], FILTER_VALIDATE_BOOLEAN), "notif_app" => filter_var($row['notif_app'], FILTER_VALIDATE_BOOLEAN), "isFavorite" => filter_var($row['isFavorite'], FILTER_VALIDATE_BOOLEAN), "isUnread" => filter_var($row['isUnread'], FILTER_VALIDATE_BOOLEAN), "tanggal" => convertDate($row['tanggal_surat'])); $output[$i] = array("pengirim" => $row['nama_institusi'], "id" => $row['id'], "hal" => $row['deskripsi'], "subject" => $row['subject_surat'], "role" => $role, "notif_web" => filter_var($row['notif_web'], FILTER_VALIDATE_BOOLEAN), "notif_app" => filter_var($row['notif_app'], FILTER_VALIDATE_BOOLEAN), "isFavorite" => filter_var($row['isFavorite'], FILTER_VALIDATE_BOOLEAN), "isUnread" => filter_var($row['isUnread'], FILTER_VALIDATE_BOOLEAN), "no_surat" => $row['no_surat'], "lampiran" => $row['lampiran'], "namaPenandatangan" => getAccountName($db, $row['penandatangan']), "jabatanPenandatangan" => getJabatan($db, $row['penandatangan']), "tanggal" => convertDate($row['tanggal_surat']), "isi" => $row['isi'], "tembusan" => $row['tembusan']); $i++; } } else { $output = []; } echo '{"count": ' . $stmt->rowCount() . ', "isUnreads": ' . countUnreads($token) . ', "isFavorites": ' . countFavorites($token) . ', "isUnsigned": ' . countUnsigned($token) . ', "result": ' . json_encode($output) . '}'; }
<td align="center" width="5%"><?php echo $v['id']; ?> </td> <td align="center" width="15%"><a href="index.php?editor=player&playerid=<?php echo $v['id']; ?> "><?php echo getPlayerName($v['id']); ?> </a></td> <td align="center" width="15%"><a href="index.php?editor=account&acctid=<?php echo $v['account_id']; ?> "><?php echo getAccountName($v['account_id']); ?> </a></td> <td align="center" width="15%"><?php echo $v['timelaston'] > 0 ? get_real_time($v['timelaston']) : "Never"; ?> </td> <td align="right"><input type="checkbox" name="id[]" value="<?php echo $v['id']; ?> " /></td> </tr> <?php $x++; } }
/** Function to insert values in the specifed table for the specified module * @param $table_name -- table name:: Type varchar * @param $module -- module:: Type varchar */ function insertIntoEntityTable($table_name, $module, $fileid = '') { global $log; global $current_user, $app_strings; $log->info("function insertIntoEntityTable " . $module . ' vtiger_table name ' . $table_name); global $adb; $insertion_mode = $this->mode; //Checkin whether an entry is already is present in the vtiger_table to update if ($insertion_mode == 'edit') { $tablekey = $this->tab_name_index[$table_name]; // Make selection on the primary key of the module table to check. $check_query = "select {$tablekey} from {$table_name} where {$tablekey}=?"; $check_result = $adb->pquery($check_query, array($this->id)); $num_rows = $adb->num_rows($check_result); if ($num_rows <= 0) { $insertion_mode = ''; } } $tabid = getTabid($module); if ($module == 'Calendar' && $this->column_fields["activitytype"] != null && $this->column_fields["activitytype"] != 'Task') { $tabid = getTabid('Events'); } if ($insertion_mode == 'edit') { $update = array(); $update_params = array(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $sql = "select * from vtiger_field where tabid in (" . generateQuestionMarks($tabid) . ") and tablename=? and displaytype in (1,3) and presence in (0,2) group by columnname"; $params = array($tabid, $table_name); } else { $profileList = getCurrentUserProfileList(); if (count($profileList) > 0) { $sql = "SELECT *\n\t\t\t \t\t\tFROM vtiger_field\n\t\t\t \t\t\tINNER JOIN vtiger_profile2field\n\t\t\t \t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t \t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t \t\t\tAND vtiger_profile2field.visible = 0 \n\t\t\t \t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\n\t\t\t \t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname"; $params = array($tabid, $profileList, $table_name); } else { $sql = "SELECT *\n\t\t\t \t\t\tFROM vtiger_field\n\t\t\t \t\t\tINNER JOIN vtiger_profile2field\n\t\t\t \t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t \t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t \t\t\tAND vtiger_profile2field.visible = 0 \n\t\t\t \t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname"; $params = array($tabid, $table_name); } } } else { $table_index_column = $this->tab_name_index[$table_name]; if ($table_index_column == 'id' && $table_name == 'vtiger_users') { $currentuser_id = $adb->getUniqueID("vtiger_users"); $this->id = $currentuser_id; } $column = array($table_index_column); $value = array($this->id); $sql = "select * from vtiger_field where tabid=? and tablename=? and displaytype in (1,3,4) and vtiger_field.presence in (0,2)"; $params = array($tabid, $table_name); } $result = $adb->pquery($sql, $params); $noofrows = $adb->num_rows($result); for ($i = 0; $i < $noofrows; $i++) { $fieldname = $adb->query_result($result, $i, "fieldname"); $columname = $adb->query_result($result, $i, "columnname"); $uitype = $adb->query_result($result, $i, "uitype"); $generatedtype = $adb->query_result($result, $i, "generatedtype"); $typeofdata = $adb->query_result($result, $i, "typeofdata"); $typeofdata_array = explode("~", $typeofdata); $datatype = $typeofdata_array[0]; if ($uitype == 4 && $insertion_mode != 'edit') { $this->column_fields[$fieldname] = $this->setModuleSeqNumber("increment", $module); $fldvalue = $this->column_fields[$fieldname]; } if (isset($this->column_fields[$fieldname])) { if ($uitype == 56) { if ($this->column_fields[$fieldname] == 'on' || $this->column_fields[$fieldname] == 1) { $fldvalue = '1'; } else { $fldvalue = '0'; } } elseif ($uitype == 15 || $uitype == 16) { if ($this->column_fields[$fieldname] == $app_strings['LBL_NOT_ACCESSIBLE']) { //If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value. $sql = "select {$columname} from {$table_name} where " . $this->tab_name_index[$table_name] . "=?"; $res = $adb->pquery($sql, array($this->id)); $pick_val = $adb->query_result($res, 0, $columname); $fldvalue = $pick_val; } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 33) { if (is_array($this->column_fields[$fieldname])) { $field_list = implode(' |##| ', $this->column_fields[$fieldname]); } else { $field_list = $this->column_fields[$fieldname]; } $fldvalue = $field_list; } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23) { if ($_REQUEST['action'] == 'Import') { $fldvalue = $this->column_fields[$fieldname]; } else { //Added to avoid function call getDBInsertDateValue in ajax save if (isset($current_user->date_format)) { $fldvalue = getValidDBInsertDateValue($this->column_fields[$fieldname]); } else { $fldvalue = $this->column_fields[$fieldname]; } } } elseif ($uitype == 7) { //strip out the spaces and commas in numbers if given ie., in amounts there may be , $fldvalue = str_replace(",", "", $this->column_fields[$fieldname]); //trim($this->column_fields[$fieldname],","); } elseif ($uitype == 26) { if (empty($this->column_fields[$fieldname])) { $fldvalue = 1; //the documents will stored in default folder } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 28) { if ($this->column_fields[$fieldname] == null) { $fileQuery = $adb->pquery("SELECT filename from vtiger_notes WHERE notesid = ?", array($this->id)); $fldvalue = null; if (isset($fileQuery)) { $rowCount = $adb->num_rows($fileQuery); if ($rowCount > 0) { $fldvalue = $adb->query_result($fileQuery, 0, 'filename'); } } } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 8) { $this->column_fields[$fieldname] = rtrim($this->column_fields[$fieldname], ','); $ids = explode(',', $this->column_fields[$fieldname]); $json = new Zend_Json(); $fldvalue = $json->encode($ids); } elseif ($uitype == 12) { $query = "SELECT email1 FROM vtiger_users WHERE id = ?"; $res = $adb->pquery($query, array($current_user->id)); $rows = $adb->num_rows($res); if ($rows > 0) { $fldvalue = $adb->query_result($res, 0, 'email1'); } } elseif ($uitype == 71 && $generatedtype == 2) { // Convert currency to base currency value before saving for custom fields of type currency $currency_id = $current_user->currency_id; $curSymCrate = getCurrencySymbolandCRate($currency_id); $fldvalue = convertToDollar($this->column_fields[$fieldname], $curSymCrate['rate']); } else { $fldvalue = $this->column_fields[$fieldname]; } if ($uitype != 33 && $uitype != 8) { $fldvalue = from_html($fldvalue, $insertion_mode == 'edit' ? true : false); } } else { $fldvalue = ''; } if ($fldvalue == '') { $fldvalue = $this->get_column_value($columname, $fldvalue, $fieldname, $uitype, $datatype); } if ($insertion_mode == 'edit') { if ($table_name != 'vtiger_ticketcomments' && $uitype != 4) { array_push($update, $columname . "=?"); array_push($update_params, $fldvalue); } } else { array_push($column, $columname); array_push($value, $fldvalue); } } if ($insertion_mode == 'edit') { if ($_REQUEST['module'] == 'Potentials') { $dbquery = 'select sales_stage from vtiger_potential where potentialid = ?'; $sales_stage = $adb->query_result($adb->pquery($dbquery, array($this->id)), 0, 'sales_stage'); if ($sales_stage != $_REQUEST['sales_stage'] && $_REQUEST['sales_stage'] != '') { $date_var = date('YmdHis'); $closingdate = $_REQUEST['ajxaction'] == 'DETAILVIEW' ? $this->column_fields['closingdate'] : getDBInsertDateValue($this->column_fields['closingdate']); $sql = "insert into vtiger_potstagehistory values(?,?,?,?,?,?,?,?)"; $params = array('', $this->id, $this->column_fields['amount'], decode_html($sales_stage), $this->column_fields['probability'], 0, $adb->formatDate($closingdate, true), $adb->formatDate($date_var, true)); $adb->pquery($sql, $params); } } elseif ($_REQUEST['module'] == 'PurchaseOrder' || $_REQUEST['module'] == 'SalesOrder' || $_REQUEST['module'] == 'Quotes' || $_REQUEST['module'] == 'Invoice') { //added to update the history for PO, SO, Quotes and Invoice $history_field_array = array("PurchaseOrder" => "postatus", "SalesOrder" => "sostatus", "Quotes" => "quotestage", "Invoice" => "invoicestatus"); $inventory_module = $_REQUEST['module']; if ($_REQUEST['ajxaction'] == 'DETAILVIEW') { if ($inventory_module == "PurchaseOrder") { $relatedname = getVendorName($this->column_fields['vendor_id']); } else { $relatedname = getAccountName($this->column_fields['account_id']); } $total = $this->column_fields['hdnGrandTotal']; } else { if ($inventory_module == "PurchaseOrder") { $relatedname = $_REQUEST["vendor_name"]; } else { $relatedname = $_REQUEST["account_name"]; } $total = $_REQUEST['total']; } if ($this->column_fields["{$history_field_array[$inventory_module]}"] == $app_strings['LBL_NOT_ACCESSIBLE']) { //If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value. $his_col = $history_field_array[$inventory_module]; $his_sql = "select {$his_col} from {$this->table_name} where " . $this->table_index . "=?"; $his_res = $adb->pquery($his_sql, array($this->id)); $status_value = $adb->query_result($his_res, 0, $his_col); $stat_value = $status_value; } else { $stat_value = $this->column_fields["{$history_field_array[$inventory_module]}"]; } $oldvalue = getSingleFieldValue($this->table_name, $history_field_array[$inventory_module], $this->table_index, $this->id); if ($this->column_fields["{$history_field_array[$inventory_module]}"] != '' && $oldvalue != $stat_value) { addInventoryHistory($inventory_module, $this->id, $relatedname, $total, $stat_value); } } //Check done by Don. If update is empty the the query fails if (count($update) > 0) { $sql1 = "update {$table_name} set " . implode(",", $update) . " where " . $this->tab_name_index[$table_name] . "=?"; array_push($update_params, $this->id); $adb->pquery($sql1, $update_params); } } else { $sql1 = "insert into {$table_name}(" . implode(",", $column) . ") values(" . generateQuestionMarks($value) . ")"; $adb->pquery($sql1, $value); } }
private function x10($x92, $x93, $x94 = false, $x95 = false) { 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; $x96 = Users_Record_Model::getCurrentUserModel(); $x97 = array("related_to", "relatedto", "parent_id", "parentid", "product_id", "productid", "service_id", "serviceid", "vendor_id", "product", "account", "invoiceid", "linktoaccountscontacts", "projectid", "sc_related_to"); if ($x95 !== false) { $x98 = array(); } $x51 = getTabid($x92); $x99 = $x92; if ($x94 === false) { $x9a = ""; } else { $x9a = "R_"; if ($x94 !== true) { $x99 = $x94; } } $x9b = array(); $x9c = array(); $x9d = array(); $x9e = array(); $x9f = array(); $xa0 = array(); $xa1 = array(); if ($x51 == '9') { $x3d = "SELECT fieldname, uitype FROM vtiger_field WHERE tabid IN (9,16)"; } else { $x3d = "SELECT fieldname, uitype FROM vtiger_field WHERE tabid = '" . $x51 . "'"; } $x3e = self::$x0f->query($x3d); while ($x42 = self::$x0f->fetchByAssoc($x3e)) { switch ($x42['uitype']) { case '19': case '20': case '21': case '24': $x9d[] = $x42['fieldname']; break; case '5': case '6': case '23': case '70': $x9e[] = $x42['fieldname']; break; case '15': $x9c[] = $x42['fieldname']; break; case '56': $x9b[] = $x42['fieldname']; break; case '33': $x9f[] = $x42['fieldname']; break; case '71': $xa0[] = $x42['fieldname']; break; case '9': $xa1[] = $x42['fieldname']; break; } if ($x42["fieldname"] == "salutationtype") { $x9c[] = $x42["fieldname"]; } } foreach ($x93->column_fields as $xa2 => $x83) { if ($xa2 == "assigned_user_id") { $x83 = $this->x1e($x83); } elseif ($xa2 == "account_id") { $x83 = getAccountName($x83); } elseif ($xa2 == "potential_id") { $x83 = getPotentialName($x83); } elseif ($xa2 == "contact_id") { $x83 = getContactName($x83); } elseif ($xa2 == "quote_id") { $x83 = getQuoteName($x83); } elseif ($xa2 == "salesorder_id") { $x83 = getSoName($x83); } elseif ($xa2 == "campaignid") { $x83 = getCampaignName($x83); } elseif ($xa2 == "terms_conditions") { $x83 = $this->x25($x83); } elseif ($xa2 == "comments") { $x83 = $this->x26($x93); } elseif ($xa2 == "folderid") { $x83 = $this->x27($x83); } elseif ($xa2 == "time_start" || $xa2 == "time_end") { $xa3 = DateTimeField::convertToUserTimeZone($x83); $x83 = $xa3->format('H:i'); } elseif ($x168($xa2, $x97)) { if ($x83 != "") { $xa4 = getSalesEntityType($x83); $xa5 = getEntityName($xa4, $x83); if (!empty($xa5)) { foreach ($xa5 as $xa6) { $x83 = $xa6; } } if ($xa2 == "invoiceid" && $x83 == "0") { $x83 = ""; } } } if ($x168($xa2, $x9e)) { if ($x92 == "Events" || $x92 == "Calendar") { if ($xa2 == "date_start" && $x93->column_fields["time_start"] != "") { $xa3 = $x93->column_fields['time_start']; $x83 = $x83 . ' ' . $xa3; } elseif ($xa2 == "due_date" && $x93->column_fields["time_end"] != "") { $xa3 = $x93->column_fields['time_end']; $x83 = $x83 . ' ' . $xa3; } } if ($x83 != "") { $x83 = getValidDisplayDate($x83); } } elseif ($x168($xa2, $x9c)) { if (!$x168($x178($x83), self::$x18)) { $x83 = $this->x20($x83, $x92); } else { $x83 = ""; } } elseif ($x168($xa2, $x9b)) { if ($x83 == 1) { $x83 = vtranslate('LBL_YES'); } else { $x83 = vtranslate('LBL_NO'); } } elseif ($x168($xa2, $x9d)) { $x83 = $x16d($x83); $x83 = $x165($x83, ENT_QUOTES, self::$x11); } elseif ($x168($xa2, $x9f)) { $x83 = $x173(' |##| ', ', ', $x83); } elseif ($x168($xa2, $xa0)) { if ($x16a($x83)) { if ($x95 === false) { $xa7 = getCurrencySymbolandCRate($x96->currency_id); $xa8 = $xa7["rate"]; } else { $xa8 = $x95["conversion_rate"]; } $x83 = $x83 * $xa8; } $x83 = $this->x23($x83); } elseif ($x168($xa2, $xa1)) { $x83 = $this->x23($x83); } if ($x95 !== false) { $x98[$x175($x92 . "_" . $xa2)] = $x83; } else { self::$x21["\$" . $x9a . $x175($x99 . "_" . $xa2) . "\$"] = $x83; } } if ($x95 !== false) { return $x98; } else { $this->x15(); } }
/** This function returns the ec_field details for a given ec_fieldname. * Param $uitype - UI type of the ec_field * Param $fieldname - Form ec_field name * Param $fieldlabel - Form ec_field label name * Param $maxlength - maximum length of the ec_field * Param $col_fields - array contains the ec_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $module_name - module name * Return type is an array */ function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module_name, $mode = '', $mandatory = 0, $typeofdata = "") { global $log; $log->debug("Entering getOutputHtml() method ..."); global $adb, $log; global $theme; global $mod_strings; global $app_strings; global $current_user; global $noof_group_rows; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; //$fieldlabel = from_html($fieldlabel); $fieldvalue = array(); $final_arr = array(); $value = $col_fields[$fieldname]; $custfld = ''; $ui_type[] = $uitype; $editview_fldname[] = $fieldname; if ($generatedtype == 2) { $mod_strings[$fieldlabel] = $fieldlabel; } if (!isset($mod_strings[$fieldlabel])) { $mod_strings[$fieldlabel] = $fieldlabel; } if ($uitype == 5) { if ($value == '') { if ($mandatory == 1) { $disp_value = getNewDisplayDate(); } } else { $disp_value = getDisplayDate($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $disp_value; } elseif ($uitype == 15 || $uitype == 16 || $uitype == 111) { $editview_label[] = $mod_strings[$fieldlabel]; //changed by dingjianting on 2007-10-3 for cache pickListResult $key = "picklist_array_" . $fieldname; $picklist_array = getSqlCacheData($key); if (!$picklist_array) { $pick_query = "select colvalue from ec_picklist where colname='" . $fieldname . "' order by sequence asc"; $pickListResult = $adb->getList($pick_query); $picklist_array = array(); foreach ($pickListResult as $row) { $picklist_array[] = $row['colvalue']; } setSqlCacheData($key, $picklist_array); } //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; foreach ($picklist_array as $pickListValue) { if ($value == $pickListValue) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == '1021' || $uitype == '1022' || $uitype == '1023') { $typearr = explode("::", $typeofdata); $multifieldid = $typearr[1]; $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = getMultiFieldEditViewValue($multifieldid, $uitype, $col_fields); $fieldvalue[] = $multifieldid; //print_r($fieldvalue); } elseif ($uitype == 10) { $query = "SELECT ec_entityname.* FROM ec_crmentityrel inner join ec_entityname on ec_entityname.modulename=ec_crmentityrel.relmodule WHERE ec_crmentityrel.module='" . $module_name . "' and ec_entityname.entityidfield='" . $fieldname . "'"; $fldmod_result = $adb->query($query); $rownum = $adb->num_rows($fldmod_result); if ($rownum > 0) { $rel_modulename = $adb->query_result($fldmod_result, 0, 'modulename'); $rel_tablename = $adb->query_result($fldmod_result, 0, 'tablename'); $rel_entityname = $adb->query_result($fldmod_result, 0, 'fieldname'); $rel_entityid = $adb->query_result($fldmod_result, 0, 'entityidfield'); } if ($value != '') { $module_entityname = getEntityNameForTen($rel_tablename, $rel_entityname, $fieldname, $value); } elseif (isset($_REQUEST[$fieldname]) && $_REQUEST[$fieldname] != '') { if ($_REQUEST['module'] == $rel_modulename) { $module_entityname = ''; } else { $value = $_REQUEST[$fieldname]; $module_entityname = getEntityNameForTen($rel_tablename, $rel_entityname, $fieldname, $value); } } if (isset($app_strings[$fieldlabel])) { $editview_label[] = $app_strings[$fieldlabel]; } elseif (isset($mod_strings[$fieldlabel])) { $editview_label[] = $mod_strings[$fieldlabel]; } else { $editview_label[] = $fieldlabel; } $fieldvalue[] = $module_entityname; $fieldvalue[] = $value; $fieldvalue[] = $rel_entityname; $fieldvalue[] = $rel_modulename; } elseif ($uitype == 17) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 85) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 86) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 87) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 88) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 89) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 33) { $pick_query = "select colvalue from ec_picklist where colname='" . $fieldname . "' order by sequence asc"; $pickListResult = $adb->getList($pick_query); $picklist_array = array(); foreach ($pickListResult as $row) { $picklist_array[] = $row['colvalue']; } $editview_label[] = $mod_strings[$fieldlabel]; $mulsel = "select colvalue from ec_picklist where colname='" . $fieldname . "' order by sequence asc"; $multiselect_result = $adb->query($mulsel); $noofoptions = $adb->num_rows($multiselect_result); $options = array(); $found = false; $valur_arr = explode(' |##| ', $value); for ($j = 0; $j < $noofoptions; $j++) { $multiselect_combo = $adb->query_result($multiselect_result, $j, "colvalue"); if (in_array($multiselect_combo, $valur_arr)) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array($multiselect_combo => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == 19 || $uitype == 20) { if (isset($_REQUEST['body'])) { $value = $_REQUEST['body']; } $editview_label[] = $mod_strings[$fieldlabel]; //$value = to_html($value); //$value = htmlspecialchars($value, ENT_QUOTES, "UTF-8"); $fieldvalue[] = $value; } elseif ($uitype == 21 || $uitype == 24) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 22) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 52) { $editview_label[] = $mod_strings[$fieldlabel]; global $current_user; if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } $combo_lbl_name = 'assigned_user_id'; if ($fieldlabel == 'Assigned To') { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } else { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } $fieldvalue[] = $users_combo; } elseif ($uitype == 77) { $editview_label[] = $mod_strings[$fieldlabel]; global $current_user; if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } $combo_lbl_name = 'assigned_user_id'; $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); $fieldvalue[] = $users_combo; } elseif ($uitype == 53) { $editview_label[] = $mod_strings[$fieldlabel]; global $current_user; if ($value != '' && $value != 0) { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } if ($fieldlabel == 'Assigned To') { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } else { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } $fieldvalue[] = $users_combo; } elseif ($uitype == 1004) { if (isset($mod_strings[$fieldlabel])) { $editview_label[] = $mod_strings[$fieldlabel]; } else { $editview_label[] = $fieldlabel; } if (empty($value)) { global $current_user; $value = $current_user->id; } $fieldvalue[] = getUserName($value); } elseif ($uitype == 1008) { if (isset($mod_strings[$fieldlabel])) { $editview_label[] = $mod_strings[$fieldlabel]; } else { $editview_label[] = $fieldlabel; } if (empty($value)) { global $current_user; $value = $current_user->id; } $fieldvalue[] = getUserName($value); } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { $account_name = ""; /*$convertmode = ""; if(isset($_REQUEST['convertmode'])) { $convertmode = $_REQUEST['convertmode']; } if($convertmode != 'update_quote_val' && $convertmode != 'update_so_val') { if(isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') $value = $_REQUEST['account_id']; }*/ if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $value = $_REQUEST['account_id']; } if ($value != '') { $account_name = getAccountName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $account_name; $fieldvalue[] = $value; } elseif ($uitype == 54) { $options = array(); if ($value == "") { $key = "currentuser_group_" . $current_user->id; $currentuser_group = getSqlCacheData($key); if (!$currentuser_group) { $query = "select ec_groups.groupname from ec_groups left join ec_users2group on ec_users2group.groupid=ec_groups.groupid where ec_users2group.userid='" . $current_user->id . "' and ec_users2group.groupid!=0"; $result = $adb->query($query); $noofrows = $adb->num_rows($result); if ($noofrows > 0) { $currentuser_group = $adb->query_result($result, 0, "groupname"); } setSqlCacheData($key, $currentuser_group); } $value = $currentuser_group; } $key = "picklist_array_group"; $picklist_array = getSqlCacheData($key); if (!$picklist_array) { $pick_query = "select * from ec_groups order by groupid"; $pickListResult = $adb->getList($pick_query); $picklist_array = array(); foreach ($pickListResult as $row) { $picklist_array[] = $row["groupname"]; } setSqlCacheData($key, $picklist_array); } $editview_label[] = $mod_strings[$fieldlabel]; foreach ($picklist_array as $pickListValue) { if ($value == $pickListValue) { $chk_val = "selected"; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == 59) { if ($value != '') { $product_name = getProductName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $product_name; $fieldvalue[] = $value; } elseif ($uitype == 64) { $editview_label[] = $mod_strings[$fieldlabel]; $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); $fieldvalue[] = $value; } elseif ($uitype == 56) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 57) { $accountid = $col_fields['account_id']; if (empty($accountid)) { $convertmode = ""; if (isset($_REQUEST['convertmode'])) { $convertmode = $_REQUEST['convertmode']; } if ($convertmode != 'update_quote_val' && $convertmode != 'update_so_val') { if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $accountid = $_REQUEST['account_id']; } } } $contact_name = ''; // if(trim($value) != '') // { // $contact_name = getContactName($value); // } // elseif(isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') // { // if(isset($_REQUEST['module']) && $_REQUEST['module'] == 'Contacts' && $fieldname = 'contact_id') // { // $contact_name = ''; // } // else // { // $value = $_REQUEST['contact_id']; // $contact_name = getContactName($value); // } // // } if (trim($value) == '') { if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'Contacts' && ($fieldname = 'contact_id')) { } else { $value = $_REQUEST['contact_id']; } } $contactopts = getContactOptions($accountid, $value); //Checking for contacts duplicate $editview_label[] = $mod_strings[$fieldlabel]; // $fieldvalue[] = $contact_name; $fieldvalue[] = $contactopts; $fieldvalue[] = $value; } elseif ($uitype == 76) { if ($value != '') { $potential_name = getPotentialName($value); } elseif (isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') { $value = $_REQUEST['potental_id']; $potential_name = getPotentialName($value); } elseif (isset($_REQUEST['potentialid']) && $_REQUEST['potentialid'] != '') { $value = $_REQUEST['potentalid']; $potential_name = getPotentialName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $potential_name; $fieldvalue[] = $value; } elseif ($uitype == 80) { if ($value != '') { $salesorder_name = getSoName($value); } elseif (isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') { $value = $_REQUEST['salesorder_id']; $salesorder_name = getSoName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $salesorder_name; $fieldvalue[] = $value; } elseif ($uitype == 101) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = getUserName($value); $fieldvalue[] = $value; } else { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } $final_arr[] = $ui_type; $final_arr[] = $editview_label; $final_arr[] = $editview_fldname; $final_arr[] = $fieldvalue; $log->debug("Exiting getOutputHtml method ..."); return $final_arr; }
/** Function to insert values in the specifed table for the specified module * @param $table_name -- table name:: Type varchar * @param $module -- module:: Type varchar */ function insertIntoEntityTable($table_name, $module, $fileid = '') { global $log; global $current_user, $app_strings; $log->info("function insertIntoEntityTable " . $module . ' vtiger_table name ' . $table_name); global $adb; $insertion_mode = $this->mode; //Checkin whether an entry is already is present in the vtiger_table to update if ($insertion_mode == 'edit') { $tablekey = $this->tab_name_index[$table_name]; // Make selection on the primary key of the module table to check. $check_query = "select {$tablekey} from {$table_name} where {$tablekey}=?"; $check_result = $adb->pquery($check_query, array($this->id)); $num_rows = $adb->num_rows($check_result); if ($num_rows <= 0) { $insertion_mode = ''; } } $tabid = getTabid($module); if ($module == 'Calendar' && $this->column_fields["activitytype"] != null && $this->column_fields["activitytype"] != 'Task') { $tabid = getTabid('Events'); } if ($insertion_mode == 'edit') { $update = array(); $update_params = array(); checkFileAccessForInclusion('user_privileges/user_privileges_' . $current_user->id . '.php'); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $sql = "select * from vtiger_field where tabid in (" . generateQuestionMarks($tabid) . ") and tablename=? and displaytype in (1,3) and presence in (0,2) group by columnname"; $params = array($tabid, $table_name); } else { $profileList = getCurrentUserProfileList(); if (count($profileList) > 0) { $sql = "SELECT *\n\t\t\t \t\t\tFROM vtiger_field\n\t\t\t \t\t\tINNER JOIN vtiger_profile2field\n\t\t\t \t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t \t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t \t\t\tAND vtiger_profile2field.visible = 0 AND vtiger_profile2field.readonly = 0\n\t\t\t \t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\n\t\t\t \t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname"; $params = array($tabid, $profileList, $table_name); } else { $sql = "SELECT *\n\t\t\t \t\t\tFROM vtiger_field\n\t\t\t \t\t\tINNER JOIN vtiger_profile2field\n\t\t\t \t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t \t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t \t\t\tAND vtiger_profile2field.visible = 0 AND vtiger_profile2field.readonly = 0\n\t\t\t \t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname"; $params = array($tabid, $table_name); } } } else { $table_index_column = $this->tab_name_index[$table_name]; if ($table_index_column == 'id' && $table_name == 'vtiger_users') { $currentuser_id = $adb->getUniqueID("vtiger_users"); $this->id = $currentuser_id; } $column = array($table_index_column); $value = array($this->id); $sql = "select * from vtiger_field where tabid=? and tablename=? and displaytype in (1,3,4) and vtiger_field.presence in (0,2)"; $params = array($tabid, $table_name); } // Attempt to re-use the quer-result to avoid reading for every save operation // TODO Need careful analysis on impact ... MEMORY requirement might be more static $_privatecache = array(); $cachekey = "{$insertion_mode}-" . implode(',', $params); if (!isset($_privatecache[$cachekey])) { $result = $adb->pquery($sql, $params); $noofrows = $adb->num_rows($result); if (CRMEntity::isBulkSaveMode()) { $cacheresult = array(); for ($i = 0; $i < $noofrows; ++$i) { $cacheresult[] = $adb->fetch_array($result); } $_privatecache[$cachekey] = $cacheresult; } } else { // Useful when doing bulk save $result = $_privatecache[$cachekey]; $noofrows = count($result); } for ($i = 0; $i < $noofrows; $i++) { $fieldname = $this->resolve_query_result_value($result, $i, "fieldname"); $columname = $this->resolve_query_result_value($result, $i, "columnname"); $uitype = $this->resolve_query_result_value($result, $i, "uitype"); $generatedtype = $this->resolve_query_result_value($result, $i, "generatedtype"); $typeofdata = $this->resolve_query_result_value($result, $i, "typeofdata"); $typeofdata_array = explode("~", $typeofdata); $datatype = $typeofdata_array[0]; $ajaxSave = false; if ($_REQUEST['file'] == 'DetailViewAjax' && $_REQUEST['ajxaction'] == 'DETAILVIEW' && isset($_REQUEST["fldName"]) && $_REQUEST["fldName"] != $fieldname || $_REQUEST['action'] == 'MassEditSave' && !isset($_REQUEST[$fieldname . "_mass_edit_check"])) { $ajaxSave = true; } if ($uitype == 4 && $insertion_mode != 'edit') { $fldvalue = ''; // Bulk Save Mode: Avoid generation of module sequence number, take care later. // SalesPlatform.ru begin: Added separate numbering for self organizations if (!CRMEntity::isBulkSaveMode()) { $modules = array('Invoice', 'Act', 'Consignment'); if (in_array($module, $modules) && isset($this->column_fields['spcompany'])) { $fldvalue = $this->setModuleSeqNumber("increment", $module, '', '', $this->column_fields['spcompany']); } else { $fldvalue = $this->setModuleSeqNumber("increment", $module); } //$fldvalue = $this->setModuleSeqNumber("increment", $module); } // SalesPlatform.ru end $this->column_fields[$fieldname] = $fldvalue; } if (isset($this->column_fields[$fieldname])) { if ($uitype == 56) { if ($this->column_fields[$fieldname] == 'on' || $this->column_fields[$fieldname] == 1) { $fldvalue = '1'; } else { $fldvalue = '0'; } } elseif ($uitype == 15 || $uitype == 16) { if ($this->column_fields[$fieldname] == $app_strings['LBL_NOT_ACCESSIBLE']) { //If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value. $sql = "select {$columname} from {$table_name} where " . $this->tab_name_index[$table_name] . "=?"; $res = $adb->pquery($sql, array($this->id)); $pick_val = $adb->query_result($res, 0, $columname); $fldvalue = $pick_val; } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 33) { if (is_array($this->column_fields[$fieldname])) { $field_list = implode(' |##| ', $this->column_fields[$fieldname]); } else { $field_list = $this->column_fields[$fieldname]; } if ($field_list == '') { $fldvalue = NULL; } else { $fldvalue = $field_list; } } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23) { //Added to avoid function call getDBInsertDateValue in ajax save if (isset($current_user->date_format) && !$ajaxSave) { $fldvalue = getValidDBInsertDateValue($this->column_fields[$fieldname]); } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 7) { //strip out the spaces and commas in numbers if given ie., in amounts there may be , $fldvalue = str_replace(",", "", $this->column_fields[$fieldname]); //trim($this->column_fields[$fieldname],","); } elseif ($uitype == 26) { if (empty($this->column_fields[$fieldname])) { $fldvalue = 1; //the documents will stored in default folder } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 28) { if ($this->column_fields[$fieldname] == null) { $fileQuery = $adb->pquery("SELECT filename from vtiger_notes WHERE notesid = ?", array($this->id)); $fldvalue = null; if (isset($fileQuery)) { $rowCount = $adb->num_rows($fileQuery); if ($rowCount > 0) { $fldvalue = decode_html($adb->query_result($fileQuery, 0, 'filename')); } } } else { $fldvalue = decode_html($this->column_fields[$fieldname]); } } elseif ($uitype == 8) { $this->column_fields[$fieldname] = rtrim($this->column_fields[$fieldname], ','); $ids = explode(',', $this->column_fields[$fieldname]); $json = new Zend_Json(); $fldvalue = $json->encode($ids); } elseif ($uitype == 12) { // Bulk Sae Mode: Consider the FROM email address as specified, if not lookup $fldvalue = $this->column_fields[$fieldname]; if (empty($fldvalue)) { $query = "SELECT email1 FROM vtiger_users WHERE id = ?"; $res = $adb->pquery($query, array($current_user->id)); $rows = $adb->num_rows($res); if ($rows > 0) { $fldvalue = $adb->query_result($res, 0, 'email1'); } } // END } elseif ($uitype == 72 && !$ajaxSave) { // Some of the currency fields like Unit Price, Totoal , Sub-total - doesn't need currency conversion during save $fldvalue = CurrencyField::convertToDBFormat($this->column_fields[$fieldname], null, true); } elseif ($uitype == 71 && !$ajaxSave) { $fldvalue = CurrencyField::convertToDBFormat($this->column_fields[$fieldname]); } else { $fldvalue = $this->column_fields[$fieldname]; } if ($uitype != 33 && $uitype != 8) { $fldvalue = from_html($fldvalue, $insertion_mode == 'edit' ? true : false); } } else { $fldvalue = ''; } if ($fldvalue == '') { $fldvalue = $this->get_column_value($columname, $fldvalue, $fieldname, $uitype, $datatype); } if ($insertion_mode == 'edit') { if ($table_name != 'vtiger_ticketcomments' && $uitype != 4) { array_push($update, $columname . "=?"); array_push($update_params, $fldvalue); } } else { array_push($column, $columname); array_push($value, $fldvalue); } } if ($insertion_mode == 'edit') { if ($module == 'Potentials') { $dbquery = 'select sales_stage from vtiger_potential where potentialid = ?'; $sales_stage = $adb->query_result($adb->pquery($dbquery, array($this->id)), 0, 'sales_stage'); if ($sales_stage != $_REQUEST['sales_stage'] && $_REQUEST['sales_stage'] != '') { $date_var = date("Y-m-d H:i:s"); $closingDateField = new DateTimeField($this->column_fields['closingdate']); $closingdate = $_REQUEST['ajxaction'] == 'DETAILVIEW' ? $this->column_fields['closingdate'] : $closingDateField->getDBInsertDateValue(); $sql = "insert into vtiger_potstagehistory values(?,?,?,?,?,?,?,?)"; $params = array('', $this->id, $this->column_fields['amount'], decode_html($sales_stage), $this->column_fields['probability'], 0, $adb->formatDate($closingdate, true), $adb->formatDate($date_var, true)); $adb->pquery($sql, $params); } } elseif ($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice' || $module == 'Act' || $module == 'Consignment') { //elseif ($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice') { // SalesPlatform.ru end //added to update the history for PO, SO, Quotes and Invoice $history_field_array = array("Act" => "sp_actstatus", "Consignment" => "sp_consignmentstatus", "PurchaseOrder" => "postatus", "SalesOrder" => "sostatus", "Quotes" => "quotestage", "Invoice" => "invoicestatus"); $inventory_module = $module; if ($_REQUEST['ajxaction'] == 'DETAILVIEW') { //if we use ajax edit if ($inventory_module == "PurchaseOrder") { $relatedname = getVendorName($this->column_fields['vendor_id']); } else { $relatedname = getAccountName($this->column_fields['account_id']); } $total = $this->column_fields['hdnGrandTotal']; } else { //using edit button and save if ($inventory_module == "PurchaseOrder") { $relatedname = $_REQUEST["vendor_name"]; } else { $relatedname = $_REQUEST["account_name"]; } $total = $_REQUEST['total']; } if ($this->column_fields["{$history_field_array[$inventory_module]}"] == $app_strings['LBL_NOT_ACCESSIBLE']) { //If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value. $his_col = $history_field_array[$inventory_module]; $his_sql = "select {$his_col} from {$this->table_name} where " . $this->table_index . "=?"; $his_res = $adb->pquery($his_sql, array($this->id)); $status_value = $adb->query_result($his_res, 0, $his_col); $stat_value = $status_value; } else { $stat_value = $this->column_fields["{$history_field_array[$inventory_module]}"]; } $oldvalue = getSingleFieldValue($this->table_name, $history_field_array[$inventory_module], $this->table_index, $this->id); if ($this->column_fields["{$history_field_array[$inventory_module]}"] != '' && $oldvalue != $stat_value) { addInventoryHistory($inventory_module, $this->id, $relatedname, $total, $stat_value); } } //Check done by Don. If update is empty the the query fails if (count($update) > 0) { $sql1 = "update {$table_name} set " . implode(",", $update) . " where " . $this->tab_name_index[$table_name] . "=?"; array_push($update_params, $this->id); $adb->pquery($sql1, $update_params); } } else { $sql1 = "insert into {$table_name}(" . implode(",", $column) . ") values(" . generateQuestionMarks($value) . ")"; $adb->pquery($sql1, $value); } }
function createpdffile($idnumber, $purpose = '', $path = '', $current_id = '') { require_once 'include/tcpdf/tcpdf.php'; require_once 'include/tcpdf/config/tcpdf_config.php'; require_once 'modules/SalesOrder/SalesOrder.php'; require_once 'include/database/PearDatabase.php'; require_once 'include/utils/InventoryUtils.php'; require_once 'include/utils/PDFutils.php'; require_once 'test/contact/bank.php'; global $FOOTER_PAGE, $default_font, $font_size_footer, $NUM_FACTURE_NAME, $pdf_strings, $SalesOrder_no, $footer_margin; global $org_name, $org_address, $org_city, $org_code, $org_country, $org_irs, $org_taxid, $org_phone, $org_fax, $org_website; global $VAR40_NAME, $VAR3_NAME, $VAR4_NAME, $ORG_POSITION, $VAR_PAGE, $VAR_OF; //bank information - content global $bank_name, $bank_street, $bank_city, $bank_zip, $bank_country, $bank_account, $bank_routing, $bank_iban, $bank_swift; //bank information - labels from language files global $ACCOUNT_NUMBER, $ROUTING_NUMBER, $SWIFT_NUMBER, $IBAN_NUMBER; global $columns, $logoradio, $logo_name, $footerradio, $pageradio; global $adb, $app_strings, $focus, $current_user; $module = 'SalesOrder'; //get bank information $bank_name = $bank_array['bank_name']; $bank_street = $bank_array['bank_street']; $bank_city = $bank_array['bank_city']; $bank_zip = $bank_array['bank_zip']; $bank_country = $bank_array['bank_country']; $bank_account = $bank_array['bank_account']; $bank_routing = $bank_array['bank_routing']; $bank_iban = $bank_array['bank_iban']; $bank_swift = $bank_array['bank_swift']; //get tax information $org_taxid = $tax_array['org_taxid']; $org_irs = $tax_array['org_irs']; //get the stored configuration values $pdf_config_details = getAllPDFDetails('SalesOrder'); //set font $default_font = getTCPDFFontsname($pdf_config_details[fontid]); if ($default_font == '') { $default_font = 'freesans'; } $font_size_header = $pdf_config_details[fontsizeheader]; $font_size_address = $pdf_config_details[fontsizeaddress]; $font_size_body = $pdf_config_details[fontsizebody]; $font_size_footer = $pdf_config_details[fontsizefooter]; //select comma or dot as number format //European Format $decimal_precision = 2; $decimals_separator = ','; $thousands_separator = '.'; //US Format //$decimal_precision = 2; //$decimals_separator = '.'; //$thousands_separator = ','; //get users data //select language file if (file_exists("modules/SalesOrder/language/" . $pdf_config_details[pdflang] . ".lang.pdf.php")) { include "modules/SalesOrder/language/" . $pdf_config_details[pdflang] . ".lang.pdf.php"; $language = strtoupper(substr($pdf_config_details[pdflang], -2, 2)); } else { include "modules/SalesOrder/language/en_us.lang.pdf.php"; $language = "EN"; } //internal number $id = $idnumber; //retreiving the salesorder info $focus = new SalesOrder(); $focus->retrieve_entity_info($_REQUEST['record'], "SalesOrder"); $account_name = decode_html(getAccountName($focus->column_fields['account_id'])); $SalesOrder_no = $focus->column_fields['salesorder_no']; $sql = "select vtiger_currency_info.currency_symbol from vtiger_currency_info where vtiger_currency_info.id= " . $focus->column_fields['currency_id']; $currency_symbol = $adb->query_result($adb->query($sql), 0, 'currency_symbol'); //get the SO date set $date_to_display_array = array(str_replace("-", ".", getDisplayDate(date("Y-m-d")))); $date_created = getDisplayDate($focus->column_fields['createdtime']); $date_array = explode(" ", $date_created); $date_to_display_array[1] = str_replace("-", ".", $date_array[0]); $date_modified = getDisplayDate($focus->column_fields['modifiedtime']); $date_array = explode(" ", $date_modified); $date_to_display_array[2] = str_replace("-", ".", $date_array[0]); $date_to_display = $date_to_display_array[$pdf_config_details['dateused']]; //number of lines after headline $space_headline = $pdf_config_details['space_headline']; //display logo? $logoradio = $pdf_config_details['logoradio']; //display customer sign? $clientid = $pdf_config_details['clientid']; //display summary? $summaryradio = $pdf_config_details['summaryradio']; //display footer? $footerradio = $pdf_config_details['footerradio']; //display footer page number? $pageradio = $pdf_config_details['pageradio']; // get company information from settings $add_query = "select * from vtiger_organizationdetails"; $result = $adb->query($add_query); $num_rows = $adb->num_rows($result); if ($num_rows > 0) { $org_name = $adb->query_result($result, 0, "organizationname"); $org_address = $adb->query_result($result, 0, "address"); $org_city = $adb->query_result($result, 0, "city"); $org_state = $adb->query_result($result, 0, "state"); $org_country = $adb->query_result($result, 0, "country"); $org_code = $adb->query_result($result, 0, "code"); $org_phone = $adb->query_result($result, 0, "phone"); $org_fax = $adb->query_result($result, 0, "fax"); $org_website = $adb->query_result($result, 0, "website"); $logo_name = $adb->query_result($result, 0, "logoname"); } // get owner information $recordOwnerArr = getRecordOwnerId($_REQUEST['record']); foreach ($recordOwnerArr as $type => $id) { $ownertype = $type; $ownerid = $id; } if ($ownertype == 'Users') { // get owner information for user $sql = "SELECT * FROM vtiger_users,vtiger_crmentity WHERE vtiger_users.id = vtiger_crmentity.smownerid AND vtiger_crmentity.crmid = '" . $_REQUEST['record'] . "'"; $result = $adb->query($sql); $owner_lastname = $adb->query_result($result, 0, 'last_name'); $owner_firstname = $adb->query_result($result, 0, 'first_name'); $owner_id = $adb->query_result($result, 0, 'smownerid'); $owner_phone = $adb->query_result($result, 0, 'phone_work'); $owner_title = decode_html(trim($adb->query_result($result, 0, 'title'))); } else { // get owner information for Groups $sql = "SELECT * FROM vtiger_groups,vtiger_crmentity WHERE vtiger_groups.groupid = vtiger_crmentity.smownerid AND vtiger_crmentity.crmid = '" . $_REQUEST['record'] . "'"; $result = $adb->query($sql); $owner_lastname = ''; $owner_firstname = $adb->query_result($result, 0, 'groupname'); $owner_id = $adb->query_result($result, 0, 'smownerid'); $owner_phone = $org_phone; $owner_title = ''; } //display owner? $owner = $pdf_config_details['owner']; //display owner phone#? $ownerphone = $pdf_config_details['ownerphone']; //to display at product description based on tax type $gproddetailarray = array($pdf_config_details[gprodname], $pdf_config_details[gproddes], $pdf_config_details[gprodcom]); $gproddetails = 0; foreach ($gproddetailarray as $key => $value) { if ($value == 'true') { if ($key == 0) { $gproddetails = $gproddetails + 1; } else { $gproddetails = $gproddetails + $key * 2; } } } $iproddetails = 0; $iproddetailarray = array($pdf_config_details[iprodname], $pdf_config_details[iproddes], $pdf_config_details[iprodcom]); foreach ($iproddetailarray as $key => $value) { if ($value == 'true') { if ($key == 0) { $iproddetails = $iproddetails + 1; } else { $iproddetails = $iproddetails + $key * 2; } } } // SO Requisition Nummer $requisition_no = $focus->column_fields['vtiger_purchaseorder']; // CustomerMark $customermark = $focus->column_fields['customerno']; if ($focus->column_fields['hdnTaxType'] == 'individual') { $product_taxes = 'true'; } else { $product_taxes = 'false'; } // **************** BEGIN POPULATE DATA ******************** $account_id = $focus->column_fields[account_id]; $so_id = $_REQUEST['record']; if ($focus->column_fields["quote_id"] != '') { $quote_name = getQuoteName($focus->column_fields["quote_id"]); } else { $quote_name = ''; } $po_name = $focus->column_fields["vtiger_purchaseorder"]; $subject = $focus->column_fields["subject"]; $delivery_date = $focus->column_fields["duedate"]; $delivery_date = str_replace("-", ".", getDisplayDate($delivery_date)); $bill_street = decode_html($focus->column_fields["bill_street"]); $bill_city = decode_html($focus->column_fields["bill_city"]); $bill_state = decode_html($focus->column_fields["bill_state"]); $bill_code = decode_html($focus->column_fields["bill_code"]); $bill_country = decode_html($focus->column_fields["bill_country"]); //format contact name $contact_name = decode_html(getContactforPDF($focus->column_fields["contact_id"])); //get department of contact or account, contact wins $contact_department = ''; //get contact department if (trim($focus->column_fields["contact_id"]) != '') { $sql = "select * from vtiger_contactdetails where contactid=" . $focus->column_fields["contact_id"]; $result = $adb->query($sql); $contact_department = decode_html(trim($adb->query_result($result, 0, "department"))); $contact_firstname = decode_html(trim($adb->query_result($result, 0, "firstname"))); $contact_lastname = decode_html(trim($adb->query_result($result, 0, "lastname"))); $contact_salutation = decode_html(trim($adb->query_result($result, 0, "salutation"))); } //get account department if ($contact_department == '') { $sql = "select * from vtiger_account where accountid=" . $account_id; $result = $adb->query($sql); $contact_department = decode_html(trim($adb->query_result($result, 0, "tickersymbol"))); } $ship_street = $focus->column_fields["ship_street"]; $ship_city = $focus->column_fields["ship_city"]; $ship_state = $focus->column_fields["ship_state"]; $ship_code = $focus->column_fields["ship_code"]; $ship_country = $focus->column_fields["ship_country"]; // condition field for last page $conditions = decode_html($focus->column_fields["terms_conditions"]); // description field for first page $description = decode_html($focus->column_fields["description"]); // ************************ BEGIN POPULATE DATA *************************** //get the Associated Products for this Sales Order $focus->id = $focus->column_fields["record_id"]; $associated_products = getAssociatedProducts("SalesOrder", $focus); $num_products = count($associated_products); //This $final_details array will contain the final total, discount, Group Tax, S&H charge, S&H taxes and adjustment $final_details = $associated_products[1]['final_details']; //getting the Net Total $price_subtotal = $final_details["hdnSubTotal"]; $price_subtotal_formated = number_format($price_subtotal, $decimal_precision, $decimals_separator, $thousands_separator); //Final discount amount/percentage $discount_amount = $final_details["discount_amount_final"]; $discount_percent = $final_details["discount_percentage_final"]; if ($discount_amount != "") { $price_discount = $discount_amount; $price_discount_formated = number_format($price_discount, $decimal_precision, $decimals_separator, $thousands_separator); } else { if ($discount_percent != "") { //This will be displayed near Discount label $final_price_discount_percent = "(" . number_format($discount_percent, $decimal_precision, $decimals_separator, $thousands_separator) . " %)"; $price_discount = $discount_percent * $final_details["hdnSubTotal"] / 100; $price_discount_formated = number_format($price_discount, $decimal_precision, $decimals_separator, $thousands_separator); } else { $price_discount = "0.00"; } } //Adjustment $price_adjustment = $final_details["adjustment"]; $price_adjustment_formated = number_format($price_adjustment, $decimal_precision, $decimals_separator, $thousands_separator); //Grand Total $price_total = $final_details["grandTotal"]; $price_total_formated = number_format($price_total, $decimal_precision, $decimals_separator, $thousands_separator); //To calculate the group tax amount if ($final_details['taxtype'] == 'group') { $group_tax_total = $final_details['tax_totalamount']; $price_salestax = $group_tax_total; $price_salestax_formated = number_format($price_salestax, $decimal_precision, $decimals_separator, $thousands_separator); $group_total_tax_percent = '0.00'; $group_tax_details = $final_details['taxes']; for ($i = 0; $i < count($group_tax_details); $i++) { $group_total_tax_percent = $group_total_tax_percent + $group_tax_details[$i]['percentage']; } } //S&H amount $sh_amount = $final_details['shipping_handling_charge']; $price_shipping_formated = number_format($sh_amount, $decimal_precision, $decimals_separator, $thousands_separator); //S&H taxes $sh_tax_details = $final_details['sh_taxes']; $sh_tax_percent = '0.00'; for ($i = 0; $i < count($sh_tax_details); $i++) { $sh_tax_percent = $sh_tax_percent + $sh_tax_details[$i]['percentage']; } $sh_tax_amount = $final_details['shtax_totalamount']; $price_shipping_tax = number_format($sh_tax_amount, $decimal_precision, $decimals_separator, $thousands_separator); //to calculate the individuel tax amounts included we should get all available taxes and then retrieve the corresponding tax values $tax_details = getAllTaxes('available'); $numer_of_tax_types = count($tax_details); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $taxtype_listings[taxname . $tax_count] = $tax_details[$tax_count]['taxname']; $taxtype_listings[percentage . $tax_count] = $tax_details[$tax_count]['percentage']; $taxtype_listings[value . $tax_count] = '0'; } //This is to get all prodcut details as row basis for ($i = 1, $j = $i - 1; $i <= $num_products; $i++, $j++) { $product_code[$i] = $associated_products[$i]['hdnProductcode' . $i]; $product_name[$i] = decode_html($associated_products[$i]['productName' . $i]); $prod_description[$i] = decode_html($associated_products[$i]['productDescription' . $i]); $qty[$i] = $associated_products[$i]['qty' . $i]; $qty_formated[$i] = number_format($associated_products[$i]['qty' . $i], $decimal_precision, $decimals_separator, $thousands_separator); $comment[$i] = decode_html($associated_products[$i]['comment' . $i]); $unit_price[$i] = number_format($associated_products[$i]['unitPrice' . $i], $decimal_precision, $decimals_separator, $thousands_separator); $list_price[$i] = number_format($associated_products[$i]['listPrice' . $i], $decimal_precision, $decimals_separator, $thousands_separator); $list_pricet[$i] = $associated_products[$i]['listPrice' . $i]; $discount_total[$i] = $associated_products[$i]['discountTotal' . $i]; $discount_totalformated[$i] = number_format($associated_products[$i]['discountTotal' . $i], $decimal_precision, $decimals_separator, $thousands_separator); //added by crm-now $usageunit[$i] = $associated_products[$i]['usageunit' . $i]; //look whether the entry already exists, if the translated string is available then the translated string other wise original string will be returned $usageunit[$i] = getTranslatedString($usageunit[$i], 'Products'); $taxable_total = $qty[$i] * $list_pricet[$i] - $discount_total[$i]; $producttotal = $taxable_total; $total_taxes = '0.00'; if ($focus->column_fields["hdnTaxType"] == "individual") { $total_tax_percent = '0.00'; //This loop is to get all tax percentage and then calculate the total of all taxes for ($tax_count = 0; $tax_count < count($associated_products[$i]['taxes']); $tax_count++) { $tax_percent = $associated_products[$i]['taxes'][$tax_count]['percentage']; $total_tax_percent = $total_tax_percent + $tax_percent; $tax_amount = $taxable_total * $tax_percent / 100; //calculate the tax amount for any available tax percentage $detected_tax = substr(array_search($total_tax_percent, $taxtype_listings), -1); $taxtype_listings[value . $detected_tax] = $taxtype_listings[value . $detected_tax] + $tax_amount; $total_taxes = $total_taxes + $tax_amount; } $producttotal = $taxable_total + $total_taxes; $product_line[$j][$pdf_strings['Tax']] = " ({$total_tax_percent} %) " . number_format($total_taxes, $decimal_precision, $decimals_separator, $thousands_separator); // combine product name, description and comment to one field based on settings } // combine product name, description and comment to one field based on settings if ($focus->column_fields["hdnTaxType"] == "individual") { $product_selection = $iproddetails; } else { $product_selection = $gproddetails; } switch ($product_selection) { case 1: $product_name_long[$i] = $product_name[$i]; break; case 2: $product_name_long[$i] = $prod_description[$i]; break; case 3: $product_name_long[$i] = $product_name[$i] . "\n" . $prod_description[$i]; break; case 4: $product_name_long[$i] = $comment[$i]; break; case 5: $product_name_long[$i] = $product_name[$i] . "\n" . $comment[$i]; break; case 6: if ($prod_description[$i] != '') { $product_name_long[$i] = $prod_description[$i] . "\n" . $comment[$i]; } else { $product_name_long[$i] = $comment[$i]; } break; case 7: if ($prod_description[$i] != '') { $product_name_long[$i] = $product_name[$i] . "\n" . $prod_description[$i] . "\n" . $comment[$i]; } else { $product_name_long[$i] = $product_name[$i] . "\n" . $comment[$i]; } break; default: if ($prod_description[$i] != '') { $product_name_long[$i] = $product_name[$i] . "\n" . $prod_description[$i] . "\n" . $comment[$i]; } else { $product_name_long[$i] = $product_name[$i] . "\n" . $comment[$i]; } break; } $prod_total[$i] = number_format($producttotal, $decimal_precision, $decimals_separator, $thousands_separator); $product_line[$j][$pdf_strings['Position']] = $j + 1; $product_line[$j][$pdf_strings['OrderCode']] = $product_code[$i]; $product_line[$j][$pdf_strings['Description']] = $product_name_long[$i]; $product_line[$j][$pdf_strings['Qty']] = $qty_formated[$i]; $product_line[$j][$pdf_strings['Unit']] = $usageunit[$i]; $product_line[$j][$pdf_strings['UnitPrice']] = $list_price[$i]; $product_line[$j][$pdf_strings['Discount']] = $discount_totalformated[$i]; $product_line[$j][$pdf_strings['LineTotal']] = $prod_total[$i]; } //Population of current date $addyear = strtotime("+0 year"); $dat_fmt = $current_user->date_format == '' ? 'dd-mm-yyyy' : $current_user->date_format; $date_issued = $dat_fmt == 'dd-mm-yyyy' ? date('d-m-Y', $addyear) : ($dat_fmt == 'mm-dd-yyyy' ? date('m-d-Y', $addyear) : ($dat_fmt == 'yyyy-mm-dd' ? date('Y-m-d', $addyear) : '')); // ************************ END POPULATE DATA *************************** //************************BEGIN PDF FORMATING************************** // Extend the TCPDF class to create custom Header and Footer class MYPDF extends TCPDF { //modifiy tcpdf class footer public function Footer() { //To make the function Footer() work properly $this->AliasNbPages(); if (!isset($this->original_lMargin)) { $this->original_lMargin = $this->lMargin; } if (!isset($this->original_rMargin)) { $this->original_rMargin = $this->rMargin; } include "modules/SalesOrder/pdf_templates/footer.php"; } } $page_num = '1'; // create new PDF document //$pdf = new PDF( 'P', 'mm', 'A4' ); $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); // set font $pdf->SetFont($default_font, " ", $default_font_size); $pdf->setPrintHeader(0); //header switched off permanently // auto break on //$pdf->SetAutoPageBreak(true); // set footer fonts //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set pdf information $pdf->SetTitle($pdf_strings['FACTURE'] . ": " . $account_name); $pdf->SetAuthor($owner_firstname . " " . $owner_lastname . ", " . $org_name); $pdf->SetSubject($account_name); $pdf->SetCreator('PDF Creator from www.crm-now.com'); //list product names as keywords $productlisting = implode(", ", $product_name); $pdf->SetKeywords($productlisting); //Disable automatic page break $pdf->SetAutoPageBreak(true, PDF_MARGIN_FOOTER); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); //initialize document $pdf->AliasNbPages(); //in reference to body.php -> if a new page must be added if the space available for summary is too small $new_page_started = false; $pdf->AddPage(); $pdf->setImageScale(1.5); //$pdf->SetY(PDF_MARGIN_HEADER); include "modules/SalesOrder/pdf_templates/header.php"; $pdf->SetFont($default_font, " ", $font_size_body); include "modules/SalesOrder/pdf_templates/body.php"; // issue pdf if ($purpose == 'print') { $pdf->Output($pdf_strings['FACTURE'] . '_' . $date_issued . '.pdf', 'D'); } elseif ($purpose == 'send') { // send pdf with mail switch ($language) { case "EN": $pdf->Output('storage/SalesOrder_' . $_REQUEST['record'] . '.pdf', 'F'); //added file name to make it work in IE, also forces the download giving the user the option to save break; case "DE": $pdf->Output('storage/Bestellung_' . $_REQUEST['record'] . '.pdf', 'F'); //added file name to make it work in IE, also forces the download giving the user the option to save break; } return; } exit; }
/** This function returns the detail view form vtiger_field and and its properties in array format. * Param $uitype - UI type of the vtiger_field * Param $fieldname - Form vtiger_field name * Param $fieldlabel - Form vtiger_field label name * Param $col_fields - array contains the vtiger_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $tabid - vtiger_tab id to which the Field belongs to (default is "") * Return type is an array */ function getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid = '', $module = '') { global $log; $log->debug("Entering getDetailViewOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $col_fields . "," . $generatedtype . "," . $tabid . ") method ..."); global $adb; global $mod_strings; global $app_strings; global $current_user; global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $fieldlabel = from_html($fieldlabel); $custfld = ''; $value = ''; $arr_data = array(); $label_fld = array(); $data_fld = array(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; // vtlib customization: New uitype to handle relation between modules if ($uitype == '10') { $fieldlabel = getTranslatedString($fieldlabel, $module); $parent_id = $col_fields[$fieldname]; if (!empty($parent_id)) { $parent_module = getSalesEntityType($parent_id); $valueTitle = getTranslatedString($parent_module, $parent_module); $displayValueArray = getEntityName($parent_module, $parent_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $value) { $displayValue = $value; } } // vtlib customization: For listview javascript triggers $modMetaInfo = getEntityFieldNames($parent_module); $modEName = is_array($modMetaInfo['fieldname']) ? $modMetaInfo['fieldname'][0] : $modMetaInfo['fieldname']; $vtlib_metainfo = "<span type='vtlib_metainfo' vtrecordid='{$parent_id}' vtfieldname=" . "'{$modEName}' vtmodule='{$parent_module}' style='display:none;'></span>"; // END $label_fld = array($fieldlabel, "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>{$vtlib_metainfo}"); } else { $moduleSpecificMessage = 'MODULE_NOT_SELECTED'; if ($mod_strings[$moduleSpecificMessage] != "") { $moduleSpecificMessage = $mod_strings[$moduleSpecificMessage]; } $label_fld = array($fieldlabel, ''); } } else { if ($uitype == 99) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; if ($fieldname == 'confirm_password') { return null; } } elseif ($uitype == 116 || $uitype == 117) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getCurrencyName($col_fields[$fieldname]); $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name'); $currency_id = $adb->query_result($pickListResult, $j, 'id'); if ($col_fields[$fieldname] == $currency_id) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[$currency_id] = array($pickListValue => $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 13 || $uitype == 104) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 16) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getTranslatedString($col_fields[$fieldname], $module); $fieldname = $adb->sql_escape_string($fieldname); $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid"; $params = array(); $pickListResult = $adb->pquery($pick_query, $params); $noofpickrows = $adb->num_rows($pickListResult); $options = array(); $count = 0; $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname))); $col_fields[$fieldname] = decode_html($col_fields[$fieldname]); if ($col_fields[$fieldname] == $pickListValue) { $chk_val = "selected"; $count++; $found = true; } else { $chk_val = ''; } $pickListValue = to_html($pickListValue); $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 15) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; $roleid = $current_user->roleid; $valueArr = explode("|##|", $col_fields[$fieldname]); $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $count = 0; $found = false; if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { if (in_array(trim($pickListValue), array_map("trim", $valueArr))) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected'); } } $label_fld["options"] = $options; } elseif ($uitype == 115) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getTranslatedString($col_fields[$fieldname]); $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname); $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname)); if ($col_fields[$fieldname] == $pickListValue) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 33) { //uitype 33 added for multiselector picklist - Jeri $roleid = $current_user->roleid; $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = str_ireplace(' |##| ', ', ', $col_fields[$fieldname]); $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); $options = array(); $selected_entries = array(); $selected_entries = explode(' |##| ', $col_fields[$fieldname]); if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { foreach ($selected_entries as $selected_entries_value) { if (trim($selected_entries_value) == trim(htmlentities($pickListValue, ENT_QUOTES, $default_charset))) { $chk_val = 'selected'; $pickcount++; break; } else { $chk_val = ''; } } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $not_access_lbl = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; $options[] = array($not_access_lbl, trim($selected_entries_value), 'selected'); } } $label_fld["options"] = $options; } elseif ($uitype == 17) { $label_fld[] = getTranslatedString($fieldlabel, $module); $matchPattern = "^[\\w]+:\\/\\/^"; $value = $col_fields[$fieldname]; preg_match($matchPattern, $value, $matches); if (!empty($matches[0])) { $fieldValue = str_replace($matches, "", $value); $label_fld[] = $value; } else { if ($value != null) { $label_fld[] = 'http://' . $value; } else { $label_fld[] = ''; } } } elseif ($uitype == 19) { if ($fieldname == 'notecontent' or $module == 'Timecontrol') { $col_fields[$fieldname] = decode_html($col_fields[$fieldname]); } else { $col_fields[$fieldname] = str_replace("<br />", "<br>", $col_fields[$fieldname]); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 20 || $uitype == 21 || $uitype == 22 || $uitype == 24) { // Armando LC<scher 11.08.2005 -> B'descriptionSpan -> Desc: removed $uitype == 19 and made an aditional elseif above if ($uitype == 20) { //Fix the issue #4680 $col_fields[$fieldname] = $col_fields[$fieldname]; } else { $col_fields[$fieldname] = nl2br($col_fields[$fieldname]); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { $account_id = $col_fields[$fieldname]; if ($account_id != '') { $account_name = getAccountName($account_id); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $account_name; $label_fld["secid"] = $account_id; $label_fld["link"] = "index.php?module=Accounts&action=DetailView&record=" . $account_id; //Account Name View } elseif ($uitype == 52 || $uitype == 77 || $uitype == 101) { $label_fld[] = getTranslatedString($fieldlabel, $module); $user_id = $col_fields[$fieldname]; $user_name = getOwnerName($user_id); if ($user_id != '') { $assigned_user_id = $user_id; } else { $assigned_user_id = $current_user->id; } if (is_admin($current_user)) { $label_fld[] = '<a href="index.php?module=Users&action=DetailView&record=' . $user_id . '">' . $user_name . '</a>'; } else { $label_fld[] = $user_name; } if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $user_id), $assigned_user_id); } $label_fld["options"] = $users_combo; } elseif ($uitype == 11) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 53) { global $noof_group_rows, $adb; $owner_id = $col_fields[$fieldname]; $user = '******'; $result = $adb->pquery("SELECT count(*) as count from vtiger_users where id = ?", array($owner_id)); if ($adb->query_result($result, 0, 'count') > 0) { $user = '******'; } $owner_name = getOwnerName($owner_id); $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $owner_name; if (is_admin($current_user)) { $label_fld["secid"][] = $owner_id; if ($user == 'no') { $label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=" . $owner_id; } else { $label_fld["link"][] = "index.php?module=Users&action=DetailView&record=" . $owner_id; } //$label_fld["secid"][] = $groupid; //$label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=".$groupid; } //Security Checks if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $result = get_current_user_access_groups($module_name); } else { $result = get_group_options(); } if ($result) { $nameArray = $adb->fetch_array($result); } global $current_user; //$value = $user_id; if ($owner_id != '') { if ($user == 'yes') { $label_fld["options"][] = 'User'; $assigned_user_id = $owner_id; $user_checked = "checked"; $team_checked = ''; $user_style = 'display:block'; $team_style = 'display:none'; } else { //$record = $col_fields["record_id"]; //$module = $col_fields["record_module"]; $label_fld["options"][] = 'Group'; $assigned_group_id = $owner_id; $user_checked = ''; $team_checked = 'checked'; $user_style = 'display:none'; $team_style = 'display:block'; } } else { $label_fld["options"][] = 'User'; $assigned_user_id = $current_user->id; $user_checked = "checked"; $team_checked = ''; $user_style = 'display:block'; $team_style = 'display:none'; } if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id), $assigned_user_id); } if ($noof_group_rows != 0) { if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id, 'private'), $current_user->id); } else { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id), $current_user->id); } } $label_fld["options"][] = $users_combo; $label_fld["options"][] = $groups_combo; } elseif ($uitype == 55 || $uitype == 255) { if ($tabid == 4) { $query = "select vtiger_contactdetails.imagename from vtiger_contactdetails where contactid=?"; $result = $adb->pquery($query, array($col_fields['record_id'])); $imagename = $adb->query_result($result, 0, 'imagename'); if ($imagename != '') { $imgpath = "test/contact/" . $imagename; $label_fld[] = getTranslatedString($fieldlabel, $module); } else { $label_fld[] = getTranslatedString($fieldlabel, $module); } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); } $value = $col_fields[$fieldname]; if ($uitype == 255) { global $currentModule; $fieldpermission = getFieldVisibilityPermission($currentModule, $current_user->id, 'firstname'); } if ($uitype == 255 && $fieldpermission == 0 && $fieldpermission != '') { $fieldvalue[] = ''; } else { $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = implode("','", $subrole); $roleids = $roleids . "','" . $roleid; } else { $roleids = $roleid; } if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $pick_query = "select salutationtype from vtiger_salutationtype order by salutationtype"; $params = array(); } else { $pick_query = "select * from vtiger_salutationtype left join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid=vtiger_salutationtype.picklist_valueid where picklistid in (select picklistid from vtiger_picklist where name='salutationtype') and roleid=? order by salutationtype"; $params = array($current_user->roleid); } $pickListResult = $adb->pquery($pick_query, $params); $noofpickrows = $adb->num_rows($pickListResult); $sal_value = $col_fields["salutationtype"]; $salcount = 0; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, "salutationtype"); if ($sal_value == $pickListValue) { $chk_val = "selected"; $salcount++; } else { $chk_val = ''; } } if ($salcount == 0 && $sal_value != '') { $notacc = $app_strings['LBL_NOT_ACCESSIBLE']; } $sal_value = $col_fields["salutationtype"]; if ($sal_value == '--None--') { $sal_value = ''; } $label_fld["salut"] = getTranslatedString($sal_value); $label_fld["notaccess"] = $notacc; } $label_fld[] = $value; } elseif ($uitype == 56) { $label_fld[] = getTranslatedString($fieldlabel, $module); $value = $col_fields[$fieldname]; if ($value == 1) { //Since "yes" is not been translated it is given as app strings here.. $displayValue = $app_strings['yes']; } else { $displayValue = $app_strings['no']; } $label_fld[] = $displayValue; } elseif ($uitype == 156) { $label_fld[] = getTranslatedString($fieldlabel, $module); $value = $col_fields[$fieldname]; if ($value == 'on') { //Since "yes" is not been translated it is given as app strings here.. $displayValue = $app_strings['yes']; } else { $displayValue = $app_strings['no']; } $label_fld[] = $displayValue; } elseif ($uitype == 57) { $label_fld[] = getTranslatedString($fieldlabel, $module); $contact_id = $col_fields[$fieldname]; if ($contact_id != '') { $displayValueArray = getEntityName('Contacts', $contact_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } } $label_fld[] = $contact_name; $label_fld["secid"] = $contact_id; $label_fld["link"] = "index.php?module=Contacts&action=DetailView&record=" . $contact_id; } elseif ($uitype == 58) { $label_fld[] = getTranslatedString($fieldlabel, $module); $campaign_id = $col_fields[$fieldname]; if ($campaign_id != '') { $campaign_name = getCampaignName($campaign_id); } $label_fld[] = $campaign_name; $label_fld["secid"] = $campaign_id; $label_fld["link"] = "index.php?module=Campaigns&action=DetailView&record=" . $campaign_id; } elseif ($uitype == 59) { $label_fld[] = getTranslatedString($fieldlabel, $module); $product_id = $col_fields[$fieldname]; if ($product_id != '') { $product_name = getProductName($product_id); } //Account Name View $label_fld[] = $product_name; $label_fld["secid"] = $product_id; $label_fld["link"] = "index.php?module=Products&action=DetailView&record=" . $product_id; } elseif ($uitype == 61) { global $adb; $label_fld[] = getTranslatedString($fieldlabel, $module); if ($tabid == 10) { $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])); for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) { $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid'); if ($attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); if ($attachmentsname != '') { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '">' . $attachmentsname . '</a>'; } else { $custfldval = ''; } } $label_fld['options'][] = $custfldval; } } else { $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } //This is added to strip the crmid and _ from the file name and show the original filename //$org_filename = ltrim($col_fields[$fieldname],$col_fields['record_id'].'_'); /* Above line is not required as the filename in the database is stored as it is and doesn't have crmid attached to it. This was the cause for the issue reported in ticket #4645 */ $org_filename = $col_fields[$fieldname]; // For Backward Compatibility version < 5.0.4 $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_'); if ($filename_pos === 0) { $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_'); $org_filename = substr($org_filename, $start_idx); } if ($org_filename != '') { if ($col_fields['filelocationtype'] == 'E') { if ($col_fields['filestatus'] == 1) { //&& strlen($col_fields['filename']) > 7 ){ $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } elseif ($col_fields['filelocationtype'] == 'I') { if ($col_fields['filestatus'] == 1) { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } else { $custfldval = ''; } } $label_fld[] = $custfldval; } } elseif ($uitype == 28) { $label_fld[] = getTranslatedString($fieldlabel, $module); $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } $org_filename = $col_fields[$fieldname]; // For Backward Compatibility version < 5.0.4 $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_'); if ($filename_pos === 0) { $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_'); $org_filename = substr($org_filename, $start_idx); } if ($org_filename != '') { if ($col_fields['filelocationtype'] == 'E') { if ($col_fields['filestatus'] == 1) { //&& strlen($col_fields['filename']) > 7 ){ $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } elseif ($col_fields['filelocationtype'] == 'I') { if ($col_fields['filestatus'] == 1) { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } else { $custfldval = ''; } } $label_fld[] = $custfldval; } elseif ($uitype == 69) { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($tabid == 14) { $images = array(); $query = 'select productname, vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?'; $result_image = $adb->pquery($query, array($col_fields['record_id'])); for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) { $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid'); //decode_html - added to handle UTF-8 characters in file names //urlencode - added to handle special characters like #, %, etc., $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name'))); $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name')); $imagepath_array[] = $adb->query_result($result_image, $image_iter, 'path'); } if (count($image_array) > 1) { if (count($image_array) < 4) { $sides = count($image_array) * 2; } else { $sides = 8; } $image_lists = '<div id="Carousel" style="position:relative;vertical-align: middle;"> <img src="modules/Products/placeholder.gif" width="571" height="117" style="position:relative;"> </div><script>var Car_NoOfSides=' . $sides . '; Car_Image_Sources=new Array('; for ($image_iter = 0; $image_iter < count($image_array); $image_iter++) { $images[] = '"' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '","' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '"'; } $image_lists .= implode(',', $images) . ');</script><script language="JavaScript" type="text/javascript" src="modules/Products/Productsslide.js"></script><script language="JavaScript" type="text/javascript">Carousel();</script>'; $label_fld[] = $image_lists; } elseif (count($image_array) == 1) { list($pro_image_width, $pro_image_height) = getimagesize($imagepath_array[0] . $image_id_array[0] . "_" . $image_orgname_array[0]); if ($pro_image_width > 450 || $pro_image_height > 300) { $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="450" height="300">'; } else { $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="' . $pro_image_width . '" height="' . $pro_image_height . '">'; } } else { $label_fld[] = ''; } } else { if ($module == 'Contacts') { $imageattachment = 'Image'; } else { $imageattachment = 'Attachment'; } //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t from vtiger_attachments\n\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t and vtiger_attachments.name = ?\n\t\t\t and vtiger_seattachmentsrel.crmid=?"; $image_res = $adb->pquery($sql, array($col_fields[$fieldname], $col_fields['record_id'])); $image_id = $adb->query_result($image_res, 0, 'attachmentsid'); $image_path = $adb->query_result($image_res, 0, 'path'); //decode_html - added to handle UTF-8 characters in file names //urlencode - added to handle special characters like #, %, etc., $image_name = urlencode(decode_html($adb->query_result($image_res, 0, 'name'))); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { $ftype = $adb->query_result($image_res, 0, 'type'); $isimage = stripos($ftype, 'image') !== false; if ($isimage) { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image'); $label_fld[] = '<img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 500px;">'; } else { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents'); $label_fld[] = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>'; } } else { $label_fld[] = ''; } } } elseif ($uitype == 62) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } elseif ($parent_module == "Potentials") { $label_fld[] = $app_strings['LBL_POTENTIAL_NAME']; $sql = "select * from vtiger_potential where potentialid=?"; $result = $adb->pquery($sql, array($value)); $potentialname = $adb->query_result($result, 0, "potentialname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>'; } elseif ($parent_module == "Products") { $label_fld[] = $app_strings['LBL_PRODUCT_NAME']; $sql = "select * from vtiger_products where productid=?"; $result = $adb->pquery($sql, array($value)); $productname = $adb->query_result($result, 0, "productname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $productname . '</a>'; } elseif ($parent_module == "PurchaseOrder") { $label_fld[] = $app_strings['LBL_PORDER_NAME']; $sql = "select * from vtiger_purchaseorder where purchaseorderid=?"; $result = $adb->pquery($sql, array($value)); $pordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>'; } elseif ($parent_module == "SalesOrder") { $label_fld[] = $app_strings['LBL_SORDER_NAME']; $sql = "select * from vtiger_salesorder where salesorderid=?"; $result = $adb->pquery($sql, array($value)); $sordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>'; } elseif ($parent_module == "Invoice") { $label_fld[] = $app_strings['LBL_INVOICE_NAME']; $sql = "select * from vtiger_invoice where invoiceid=?"; $result = $adb->pquery($sql, array($value)); $invoicename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>'; } elseif ($parent_module == "Quotes") { $label_fld[] = $app_strings['LBL_QUOTES_NAME']; $sql = "select * from vtiger_quotes where quoteid=?"; $result = $adb->pquery($sql, array($value)); $quotename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>'; } elseif ($parent_module == "HelpDesk") { $label_fld[] = $app_strings['LBL_HELPDESK_NAME']; $sql = "select * from vtiger_troubletickets where ticketid=?"; $result = $adb->pquery($sql, array($value)); $title = $adb->query_result($result, 0, "title"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $title . '</a>'; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 105) { //Added for user image $label_fld[] = getTranslatedString($fieldlabel, $module); //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select vtiger_attachments.* from vtiger_attachments left join vtiger_salesmanattachmentsrel on vtiger_salesmanattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid where vtiger_salesmanattachmentsrel.smid=?"; $image_res = $adb->pquery($sql, array($col_fields['record_id'])); $image_id = $adb->query_result($image_res, 0, 'attachmentsid'); $image_path = $adb->query_result($image_res, 0, 'path'); $image_name = $adb->query_result($image_res, 0, 'name'); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { //Added the following check for the image to retain its in original size. list($pro_image_width, $pro_image_height) = getimagesize(decode_html($imgpath)); $label_fld[] = '<a href="' . $imgpath . '" target="_blank"><img src="' . $imgpath . '" width="' . $pro_image_width . '" height="' . $pro_image_height . '" alt="' . $col_fields['user_name'] . '" title="' . $col_fields['user_name'] . '" border="0"></a>'; } else { $label_fld[] = ''; } } elseif ($uitype == 66) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } elseif ($parent_module == "Potentials") { $label_fld[] = $app_strings['LBL_POTENTIAL_NAME']; $sql = "select * from vtiger_potential where potentialid=?"; $result = $adb->pquery($sql, array($value)); $potentialname = $adb->query_result($result, 0, "potentialname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>'; } elseif ($parent_module == "Quotes") { $label_fld[] = $app_strings['LBL_QUOTE_NAME']; $sql = "select * from vtiger_quotes where quoteid=?"; $result = $adb->pquery($sql, array($value)); $quotename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>'; } elseif ($parent_module == "PurchaseOrder") { $label_fld[] = $app_strings['LBL_PORDER_NAME']; $sql = "select * from vtiger_purchaseorder where purchaseorderid=?"; $result = $adb->pquery($sql, array($value)); $pordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>'; } elseif ($parent_module == "SalesOrder") { $label_fld[] = $app_strings['LBL_SORDER_NAME']; $sql = "select * from vtiger_salesorder where salesorderid=?"; $result = $adb->pquery($sql, array($value)); $sordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>'; } elseif ($parent_module == "Invoice") { $label_fld[] = $app_strings['LBL_INVOICE_NAME']; $sql = "select * from vtiger_invoice where invoiceid=?"; $result = $adb->pquery($sql, array($value)); $invoicename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>'; } elseif ($parent_module == "Campaigns") { $label_fld[] = $app_strings['LBL_CAMPAIGN_NAME']; $sql = "select * from vtiger_campaign where campaignid=?"; $result = $adb->pquery($sql, array($value)); $campaignname = $adb->query_result($result, 0, "campaignname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $campaignname . '</a>'; } elseif ($parent_module == "HelpDesk") { $label_fld[] = $app_strings['LBL_HELPDESK_NAME']; $sql = "select * from vtiger_troubletickets where ticketid=?"; $result = $adb->pquery($sql, array($value)); $tickettitle = $adb->query_result($result, 0, "title"); if (strlen($tickettitle) > 25) { $tickettitle = substr($tickettitle, 0, 25) . '...'; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $tickettitle . '</a>'; } elseif ($parent_module == "Vendors") { //MSL $label_fld[] = $app_strings['LBL_VENDOR_NAME']; $sql = "select vendorname from vtiger_vendor where vendorid=?"; $result = $adb->pquery($sql, array($value)); $vendor_name = $adb->query_result($result, 0, "vendorname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $vendor_name . '</a>'; } //MSL ------------------------------------------- } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 67) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 357) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_name = ''; $parent_id = ''; $myemailid = $_REQUEST['record']; $mysql = "select crmid from vtiger_seactivityrel where activityid=?"; $myresult = $adb->pquery($mysql, array($myemailid)); $mycount = $adb->num_rows($myresult); if ($mycount > 1) { $label_fld[] = $app_strings['LBL_RELATED_TO']; $label_fld[] = $app_strings['LBL_MULTIPLE']; } else { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $accountname = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $accountname . '</a>'; } } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 68) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } else { $value = ''; $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 63) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname] . 'h ' . $col_fields['duration_minutes'] . 'm'; } elseif ($uitype == 6) { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname] == '0') { $col_fields[$fieldname] = ''; } if ($col_fields['time_start'] != '') { $start_time = $col_fields['time_start']; } $dateValue = $col_fields[$fieldname]; if ($col_fields[$fieldname] == '0000-00-00' || empty($dateValue)) { $displayValue = ''; } else { if (empty($start_time) && strpos($col_fields[$fieldname], ' ') == false) { $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]); } else { if (!empty($start_time)) { $date = new DateTimeField($col_fields[$fieldname] . ' ' . $start_time); } else { $date = new DateTimeField($col_fields[$fieldname]); } $displayValue = $date->getDisplayDateTimeValue(); } } $label_fld[] = $displayValue; } elseif ($uitype == 5 || $uitype == 23 || $uitype == 70) { $label_fld[] = getTranslatedString($fieldlabel, $module); $dateValue = $col_fields[$fieldname]; if ($col_fields['time_end'] != '' && ($tabid == 9 || $tabid == 16) && $uitype == 23) { $end_time = $col_fields['time_end']; } if ($dateValue == '0000-00-00' || empty($dateValue)) { $displayValue = ''; } else { if (empty($end_time) && strpos($dateValue, ' ') == false) { $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]); } else { if (!empty($end_time)) { $date = new DateTimeField($col_fields[$fieldname] . ' ' . $end_time); } else { $date = new DateTimeField($col_fields[$fieldname]); } $displayValue = $date->getDisplayDateTimeValue(); } } $label_fld[] = $displayValue; } elseif ($uitype == 71 || $uitype == 72) { $label_fld[] = getTranslatedString($fieldlabel, $module); $currencyField = new CurrencyField($col_fields[$fieldname]); if ($uitype == 72) { // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($fieldname == 'unit_price') { $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module)); $label_fld[] = $currencyField->getDisplayValue(null, true); $label_fld["cursymb"] = $rate_symbol['symbol']; } else { $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']); $label_fld[] = $currencyField->getDisplayValue(null, true); $label_fld["cursymb"] = $currency_info['currency_symbol']; } } else { $label_fld[] = $currencyField->getDisplayValue(); $label_fld["cursymb"] = $currencyField->getCurrencySymbol(); } } elseif ($uitype == 75 || $uitype == 81) { $label_fld[] = getTranslatedString($fieldlabel, $module); $vendor_id = $col_fields[$fieldname]; if ($vendor_id != '') { $vendor_name = getVendorName($vendor_id); } $label_fld[] = $vendor_name; $label_fld["secid"] = $vendor_id; $label_fld["link"] = "index.php?module=Vendors&action=DetailView&record=" . $vendor_id; } elseif ($uitype == 76) { $label_fld[] = getTranslatedString($fieldlabel, $module); $potential_id = $col_fields[$fieldname]; if ($potential_id != '') { $potential_name = getPotentialName($potential_id); } $label_fld[] = $potential_name; $label_fld["secid"] = $potential_id; $label_fld["link"] = "index.php?module=Potentials&action=DetailView&record=" . $potential_id; } elseif ($uitype == 78) { $label_fld[] = getTranslatedString($fieldlabel, $module); $quote_id = $col_fields[$fieldname]; if ($quote_id != '') { $quote_name = getQuoteName($quote_id); } $label_fld[] = $quote_name; $label_fld["secid"] = $quote_id; $label_fld["link"] = "index.php?module=Quotes&action=DetailView&record=" . $quote_id; } elseif ($uitype == 79) { $label_fld[] = getTranslatedString($fieldlabel, $module); $purchaseorder_id = $col_fields[$fieldname]; if ($purchaseorder_id != '') { $purchaseorder_name = getPoName($purchaseorder_id); } $label_fld[] = $purchaseorder_name; $label_fld["secid"] = $purchaseorder_id; $label_fld["link"] = "index.php?module=PurchaseOrder&action=DetailView&record=" . $purchaseorder_id; } elseif ($uitype == 80) { $label_fld[] = getTranslatedString($fieldlabel, $module); $salesorder_id = $col_fields[$fieldname]; if ($salesorder_id != '') { $salesorder_name = getSoName($salesorder_id); } $label_fld[] = $salesorder_name; $label_fld["secid"] = $salesorder_id; $label_fld["link"] = "index.php?module=SalesOrder&action=DetailView&record=" . $salesorder_id; } elseif ($uitype == 30) { $rem_days = 0; $rem_hrs = 0; $rem_min = 0; $reminder_str = ""; $rem_days = floor($col_fields[$fieldname] / (24 * 60)); $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60); $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60; $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname]) { $reminder_str = $rem_days . ' ' . $mod_strings['LBL_DAYS'] . ' ' . $rem_hrs . ' ' . $mod_strings['LBL_HOURS'] . ' ' . $rem_min . ' ' . $mod_strings['LBL_MINUTES'] . ' ' . $mod_strings['LBL_BEFORE_EVENT']; } $label_fld[] = ' ' . $reminder_str; } elseif ($uitype == 98) { $label_fld[] = getTranslatedString($fieldlabel, $module); if (is_admin($current_user)) { $label_fld[] = '<a href="index.php?module=Settings&action=RoleDetailView&roleid=' . $col_fields[$fieldname] . '">' . getRoleName($col_fields[$fieldname]) . '</a>'; } else { $label_fld[] = getRoleName($col_fields[$fieldname]); } } elseif ($uitype == 85) { //Added for Skype by Minnie $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 26) { $label_fld[] = getTranslatedString($fieldlabel, $module); $query = "select foldername from vtiger_attachmentsfolder where folderid = ?"; $result = $adb->pquery($query, array($col_fields[$fieldname])); $folder_name = $adb->query_result($result, 0, "foldername"); $label_fld[] = $folder_name; } elseif ($uitype == 27) { if ($col_fields[$fieldname] == 'I') { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $mod_strings['LBL_INTERNAL']; } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $mod_strings['LBL_EXTERNAL']; } } elseif ($uitype == 31) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; $options = array(); $themeList = get_themes(); foreach ($themeList as $theme) { if ($current_user->theme == $theme) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($theme), $theme, $selected); } $label_fld["options"] = $options; } elseif ($uitype == 32) { $options = array(); $languageList = Vtiger_Language::getAll(); $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = isset($languageList[$col_fields[$fieldname]]) ? $languageList[$col_fields[$fieldname]] : $col_fields[$fieldname]; foreach ($languageList as $prefix => $label) { if ($current_user->language == $prefix) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($label), $prefix, $selected); } $label_fld["options"] = $options; } else { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname] == '0' && $fieldname != 'filedownloadcount' && $fieldname != 'filestatus' && $fieldname != 'filesize') { $col_fields[$fieldname] = ''; } //code for Documents module :start if ($tabid == 8) { $downloadtype = $col_fields['filelocationtype']; if ($fieldname == 'filename') { if ($downloadtype == 'I') { //$file_value = $mod_strings['LBL_INTERNAL']; $fld_value = $col_fields['filename']; $ext_pos = strrpos($fld_value, "."); $ext = substr($fld_value, $ext_pos + 1); $ext = strtolower($ext); if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } else { $fld_value = $col_fields['filename']; $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' title='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' hspace='3' align='absmiddle' border='0'>"; } $label_fld[] = $fileicon . $fld_value; } if ($fieldname == 'filesize') { if ($col_fields['filelocationtype'] == 'I') { $filesize = $col_fields[$fieldname]; if ($filesize < 1024) { $label_fld[] = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $label_fld[] = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $label_fld[] = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $label_fld[] = ' --'; } } if ($fieldname == 'filetype' && $col_fields['filelocationtype'] == 'E') { $label_fld[] = ' --'; } /* if($fieldname == 'filestatus') { $filestatus = $col_fields[$fieldname]; if($filestatus == 0) $label_fld[]=$mod_strings['LBL_ACTIVE']; else $label_fld[]=$mod_strings['LBL_INACTIVE']; } */ } //code for Documents module :end $label_fld[] = $col_fields[$fieldname]; } } $label_fld[] = $uitype; //sets whether the currenct user is admin or not if (is_admin($current_user)) { $label_fld["isadmin"] = 1; } else { $label_fld["isadmin"] = 0; } $log->debug("Exiting getDetailViewOutputHtml method ..."); return $label_fld; }