function isViewPermitted() { // Check if the logged in user has access to the field global $current_user; if ($this->parent->module == 'Products' and substr($this->name, 0, 10) == 'deltaimage') { return true; } return getFieldVisibilityPermission($this->parent->module, $current_user->id, $this->name) == '0'; }
function __construct($leadid, $current_user) { global $adb; $this->leadid = $leadid; $this->current_user = $current_user; $sql = "SELECT * FROM vtiger_leaddetails,vtiger_leadscf,vtiger_crmentity\n\t\t\tWHERE vtiger_leaddetails.leadid=vtiger_leadscf.leadid\n\t\t\tAND vtiger_leaddetails.leadid=vtiger_crmentity.crmid\n\t\t\tAND vtiger_leaddetails.leadid =?"; $result = $adb->pquery($sql, array($this->leadid)); $this->row = $adb->fetch_array($result); if (getFieldVisibilityPermission('Leads', $current_user->id, 'company') == '1') { $this->row["company"] = ''; } $this->setAssignedToInfo(); }
/** * Function to set record module field values * @param parent record model */ function setRecordFieldValues($parentRecordModel) { global $log; $log->debug("Entering RequirementCards_Record_Model::setRecordFieldValues() method ..."); $currentUser = Users_Record_Model::getCurrentUserModel(); $parentModuleName = $parentRecordModel->getModuleName(); if ($parentModuleName == 'QuotesEnquires') { $fieldsToGenerate = $this->getListFieldsToGenerate($parentModuleName, $this->getModuleName()); foreach ($fieldsToGenerate as $key => $fieldName) { if (getFieldVisibilityPermission($parentModuleName, $currentUser->getId(), $key) == 0 || $key == 'id') { $this->set($fieldName, $parentRecordModel->get($key)); } } } $log->debug("Exiting RequirementCards_Record_Model::setRecordFieldValues() method ..."); }
/** This function returns the vtiger_invoice object populated with the details from sales order object. * Param $focus - Invoice object * Param $so_focus - Sales order focus * Param $soid - sales order id * Return type is an object array */ function getConvertSoToInvoice($focus, $so_focus, $soid) { $log = vglobal('log'); $current_user = vglobal('current_user'); $log->debug("Entering getConvertSoToInvoice(" . get_class($focus) . "," . get_class($so_focus) . "," . $soid . ") method ..."); $log->info("in getConvertSoToInvoice " . $soid); $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 < count($xyz); $i++) { if (getFieldVisibilityPermission('SalesOrder', $current_user->id, $xyz[$i]) == '0') { $so_focus->column_fields[$xyz[$i]] = $so_focus->column_fields[$xyz[$i]]; } else { $so_focus->column_fields[$xyz[$i]] = ''; } } $focus->column_fields['salesorder_id'] = $soid; $focus->column_fields['subject'] = $so_focus->column_fields['subject']; $focus->column_fields['customerno'] = $so_focus->column_fields['customerno']; $focus->column_fields['duedate'] = $so_focus->column_fields['duedate']; $focus->column_fields['contact_id'] = $so_focus->column_fields['contact_id']; //to include contact name in Invoice $focus->column_fields['account_id'] = $so_focus->column_fields['account_id']; $focus->column_fields['exciseduty'] = $so_focus->column_fields['exciseduty']; $focus->column_fields['salescommission'] = $so_focus->column_fields['salescommission']; $focus->column_fields['purchaseorder'] = $so_focus->column_fields['purchaseorder']; $focus->column_fields['bill_street'] = $so_focus->column_fields['bill_street']; $focus->column_fields['ship_street'] = $so_focus->column_fields['ship_street']; $focus->column_fields['bill_city'] = $so_focus->column_fields['bill_city']; $focus->column_fields['ship_city'] = $so_focus->column_fields['ship_city']; $focus->column_fields['bill_state'] = $so_focus->column_fields['bill_state']; $focus->column_fields['ship_state'] = $so_focus->column_fields['ship_state']; $focus->column_fields['bill_code'] = $so_focus->column_fields['bill_code']; $focus->column_fields['ship_code'] = $so_focus->column_fields['ship_code']; $focus->column_fields['bill_country'] = $so_focus->column_fields['bill_country']; $focus->column_fields['ship_country'] = $so_focus->column_fields['ship_country']; $focus->column_fields['bill_pobox'] = $so_focus->column_fields['bill_pobox']; $focus->column_fields['ship_pobox'] = $so_focus->column_fields['ship_pobox']; $focus->column_fields['description'] = $so_focus->column_fields['description']; $focus->column_fields['terms_conditions'] = $so_focus->column_fields['terms_conditions']; $focus->column_fields['currency_id'] = $so_focus->column_fields['currency_id']; $focus->column_fields['conversion_rate'] = $so_focus->column_fields['conversion_rate']; $log->debug("Exiting getConvertSoToInvoice method ..."); return $focus; }
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; }
$invited_users[$userid] = $username; } $smarty->assign("INVITEDUSERS", $invited_users); $related_array = getRelatedListsInformation("Calendar", $focus); $fieldsname = $related_array['Contacts']['header']; $contact_info = $related_array['Contacts']['entries']; $entityIds = array_keys($contact_info); $displayValueArray = getEntityName('Contacts', $entityIds); $entityname = array(); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $entityname[$key] = '<a href="index.php?module=Contacts&action=DetailView&record=' . $key . '">' . $field_value . '</a>'; } } $smarty->assign("CONTACTS", $entityname); $is_fname_permitted = getFieldVisibilityPermission("Contacts", $current_user->id, 'firstname'); $smarty->assign("IS_PERMITTED_CNT_FNAME", $is_fname_permitted); } global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $log->info("Calendar-Activities detail view"); $category = getParentTab(); $smarty->assign("CATEGORY", $category); $smarty->assign("MOD", $mod_strings); $smarty->assign("CMOD", $c_mod_strings); $smarty->assign("APP", $app_strings); $smarty->assign("ACTIVITY_MODE", $activity_mode); if (isset($focus->name)) { $smarty->assign("NAME", $focus->name); } else {
/** Function to form the query to get the list of activities * @param int $id - ticket id * @return array - return an array which will be returned from the function GetRelatedList **/ function get_activities($id, $cur_tab_id, $rel_tab_id, $actions = false) { global $log, $singlepane_view, $currentModule, $current_user; $log->debug("Entering get_activities(" . $id . ") method ..."); $this_module = $currentModule; $related_module = vtlib_getModuleNameById($rel_tab_id); require_once "modules/{$related_module}/Activity.php"; $other = new Activity(); vtlib_setup_modulevars($related_module, $other); $singular_modname = vtlib_toSingular($related_module); $parenttab = getParentTab(); if ($singlepane_view == 'true') { $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; } else { $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; } $button = ''; $button .= '<input type="hidden" name="activity_mode">'; if ($actions) { if (is_string($actions)) { $actions = explode(',', strtoupper($actions)); } if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') { if (getFieldVisibilityPermission('Calendar', $current_user->id, 'parent_id', 'readwrite') == '0') { $button .= "<input title='" . getTranslatedString('LBL_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EventEditView\";this.form.module.value=\"Calendar4You\";this.form.return_module.value=\"{$this_module}\";this.form.activity_mode.value=\"Task\";' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "'> "; } if (getFieldVisibilityPermission('Events', $current_user->id, 'parent_id', 'readwrite') == '0') { $button .= "<input title='" . getTranslatedString('LBL_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EventEditView\";this.form.module.value=\"Calendar4You\";this.form.return_module.value=\"{$this_module}\";this.form.activity_mode.value=\"Events\";' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString('LBL_EVENT', $related_module) . "'>"; } } } $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query = "SELECT case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name," . " vtiger_activity.*, vtiger_cntactivityrel.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname," . " vtiger_crmentity.crmid, vtiger_recurringevents.recurringtype, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime," . " vtiger_seactivityrel.crmid as parent_id " . " from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid" . " inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid" . " left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid = vtiger_activity.activityid " . " left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid" . " left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid" . " left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid" . " left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid" . " where vtiger_seactivityrel.crmid=" . $id . " and vtiger_crmentity.deleted=0 and (activitytype NOT IN ('Emails'))" . " AND ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Completed' )" . " and ( vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus != 'Held') "; $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); if ($return_value == null) { $return_value = array(); } $return_value['CUSTOM_BUTTON'] = $button; $log->debug("Exiting get_activities method ..."); return $return_value; }
function generateArray($ical_activity) { $current_user = vglobal('current_user'); $activity = array(); $activitytype = $ical_activity['TYPE']; if ($activitytype == 'VEVENT') { $modtype = 'Events'; } else { $modtype = 'Calendar'; } foreach ($this->mapping_arr as $key => $comp) { $type = $comp['type']; $component = $comp['component']; if (!is_array($component)) { if ($type != 'user') { if (isset($this->field_mapping_arr[$component])) { if (getFieldVisibilityPermission($modtype, $current_user->id, $this->field_mapping_arr[$component]) == '0') { $activity[$this->field_mapping_arr[$component]] = $ical_activity[$key]; } else { $activity[$this->field_mapping_arr[$component]] = ''; } } else { if (getFieldVisibilityPermission($modtype, $current_user->id, $component) == '0') { $activity[$component] = $ical_activity[$key]; } else { $activity[$component] = ''; } } } } else { $temp = $ical_activity[$key]; $count = 0; if ($type == 'string') { $values = explode('\\,', $temp); } else { if ($type == 'datetime' && !empty($temp)) { $values = $this->strtodatetime($temp); } } foreach ($component as $index) { if (!isset($activity[$index])) { if (isset($this->field_mapping_arr[$index])) { if (getFieldVisibilityPermission($modtype, $current_user->id, $this->field_mapping_arr[$index]) == '0') { $activity[$this->field_mapping_arr[$index]] = $values[$count]; } else { $activity[$this->field_mapping_arr[$index]] = ''; } } else { if (getFieldVisibilityPermission($modtype, $current_user->id, $index) == '0') { $activity[$index] = $values[$count]; } else { $activity[$index] = ''; } } } $count++; } unset($values); } } if ($activitytype == 'VEVENT') { $activity['activitytype'] = 'Meeting'; if (empty($activity['eventstatus'])) { $activity['eventstatus'] = 'PLL_PLANNED'; } if (!empty($ical_activity['VALARM'])) { $temp = str_replace("P", '', $ical_activity['VALARM']['TRIGGER']); //if there is negative value then ignore it because in vtiger even though its negative or postiview we //make reminder to be before the event $temp = str_replace("-", '', $temp); $durationTypeCharacters = array('W', 'D', 'T', 'H', 'M', 'S'); $reminder_time = 0; foreach ($durationTypeCharacters as $durationType) { if (strpos($temp, $durationType) == false) { continue; } $parts = explode($durationType, $temp); $durationValue = $parts[0]; $temp = $parts[1]; $duration_type = $durationType; $duration = intval($durationValue); switch ($duration_type) { case 'W': $reminder_time += 24 * 24 * 60 * $durationValue; break; case 'D': $reminder_time += 24 * 60 * $durationValue; break; case 'T': //Skip this symbol since its just indicates the start of time component break; case 'H': $reminder_time += $duration * 60; break; case 'M': $reminder_time = $duration; break; } } $activity['reminder_time'] = $reminder_time; } } else { $activity['activitytype'] = 'Task'; if (empty($activity['activitystatus'])) { $activity['activitystatus'] = 'PLL_PLANNED'; } } if ($activity['visibility'] == 'PUBLIC') { $activity['visibility'] = 'Public'; } if ($activity['visibility'] == 'PRIVATE' || empty($activity['visibility'])) { $activity['visibility'] = 'Private'; } if (array_key_exists('taskpriority', $activity)) { $priorityMap = array('1' => 'Low', '5' => 'Medium', '9' => 'High'); $priorityval = $activity['taskpriority']; if (array_key_exists($priorityval, $priorityMap)) { $activity['taskpriority'] = $priorityMap[$priorityval]; } } if (!array_key_exists('visibility', $activity)) { $activity['visibility'] = ' '; } return $activity; }
/** * Function to set record module field values * @param parent record model */ function setRecordFieldValues($parentRecordModel) { $currentUser = Users_Record_Model::getCurrentUserModel(); $fieldsList = array_keys($this->getModule()->getFields()); $parentFieldsList = array_keys($parentRecordModel->getModule()->getFields()); $commonFields = array_intersect($fieldsList, $parentFieldsList); foreach ($commonFields as $fieldName) { if (getFieldVisibilityPermission($parentRecordModel->getModuleName(), $currentUser->getId(), $fieldName) == 0) { $this->set($fieldName, $parentRecordModel->get($fieldName)); } } $fieldsToGenerate = $this->getListFieldsToGenerate($parentRecordModel->getModuleName(), $this->getModuleName()); foreach ($fieldsToGenerate as $key => $fieldName) { if (getFieldVisibilityPermission($parentRecordModel->getModuleName(), $currentUser->getId(), $key) == 0) { $this->set($fieldName, $parentRecordModel->get($key)); } } }
/** Function to get tablename, columnname, fieldname, fieldlabel and uitypes of fields of merge criteria for a particular module*/ function getFieldValues($module) { global $adb, $current_user; //In future if we want to change a id mapping to name or other string then we can add that elements in this array. //$fld_table_arr = Array("vtiger_contactdetails.account_id"=>"vtiger_account.accountname"); //$special_fld_arr = Array("account_id"=>"accountname"); $fld_table_arr = array(); $special_fld_arr = array(); $tabid = getTabid($module); $fieldname_query = "select fieldname,fieldlabel,uitype,tablename,columnname from vtiger_field where fieldid in\n\t\t\t(select fieldid from vtiger_user2mergefields WHERE tabid=? AND userid=? AND visible = ?) and vtiger_field.presence in (0,2)"; $fieldname_result = $adb->pquery($fieldname_query, array($tabid, $current_user->id, 1)); $field_num_rows = $adb->num_rows($fieldname_result); $fld_arr = array(); $col_arr = array(); for ($j = 0; $j < $field_num_rows; $j++) { $tablename = $adb->query_result($fieldname_result, $j, 'tablename'); $column_name = $adb->query_result($fieldname_result, $j, 'columnname'); $field_name = $adb->query_result($fieldname_result, $j, 'fieldname'); $field_lbl = $adb->query_result($fieldname_result, $j, 'fieldlabel'); $ui_type = $adb->query_result($fieldname_result, $j, 'uitype'); $table_col = $tablename . "." . $column_name; if (getFieldVisibilityPermission($module, $current_user->id, $field_name) == 0) { $fld_name = $special_fld_arr[$field_name] != '' ? $special_fld_arr[$field_name] : $field_name; $fld_arr[] = $fld_name; $col_arr[] = $column_name; if ($fld_table_arr[$table_col] != '') { $table_col = $fld_table_arr[$table_col]; } $field_values_array['fieldnames_list'][] = $table_col . "." . $fld_name; $fld_labl_arr[] = $field_lbl; $uitype[$field_name] = $ui_type; } } $field_values_array['fieldnames_list'] = implode(",", $field_values_array['fieldnames_list']); $field_values = implode(",", $fld_arr); $field_values_array['fieldnames'] = $field_values; $field_values_array["fieldnames_array"] = $fld_arr; $field_values_array["columnnames_array"] = $col_arr; $field_values_array['fieldlabels_array'] = $fld_labl_arr; $field_values_array['fieldname_uitype'] = $uitype; return $field_values_array; }
/** * Function creates HTML to display Todos ListView * @param array $todo_list - collection of strings(Todo Information) * @param array $cal - collection of objects and strings * return string $list_view - html tags in string format */ function constructTodoListView($todo_list, $cal, $subtab, $navigation_array = '') { global $mod_strings, $cal_log, $adb, $theme; $cal_log->debug("Entering constructTodoListView() method..."); global $current_user, $app_strings; $date_format = $current_user->date_format; $format = $cal['calendar']->hour_format; $hour_startat = timeString(array('hour' => date('H:i'), 'minute' => 0), '24'); $hour_endat = timeString(array('hour' => date('H:i', time() + 60 * 60), 'minute' => 0), '24'); $time_arr = getaddEventPopupTime($hour_startat, $hour_endat, $format); $temp_ts = $cal['calendar']->date_time->ts; //to get date in user selected date format $temp_date = $date_format == 'dd-mm-yyyy' ? date('d-m-Y', $temp_ts) : ($date_format == 'mm-dd-yyyy' ? date('m-d-Y', $temp_ts) : ($date_format == 'yyyy-mm-dd' ? date('Y-m-d', $temp_ts) : '')); if ($cal['calendar']->day_start_hour != 23) { $endtemp_date = $temp_date; } else { $endtemp_ts = $temp_ts + 1 * 24 * 60 * 60; $endtemp_date = $date_format == 'dd-mm-yyyy' ? date('d-m-Y', $endtemp_ts) : ($date_format == 'mm-dd-yyyy' ? date('m-d-Y', $endtemp_ts) : ($date_format == 'yyyy-mm-dd' ? date('Y-m-d', $endtemp_ts) : '')); } $list_view = ""; //labels of listview header if ($cal['view'] == 'day') { $colspan = 9; $header = array('0' => '#', '1' => $mod_strings['LBL_TIME'], '2' => $mod_strings['LBL_LIST_DUE_DATE'], '3' => $mod_strings['LBL_TODO']); $header_width = array('0' => '5%', '1' => '10%', '2' => '10%', '3' => '38%'); /*if(getFieldVisibilityPermission('Calendar',$current_user->id,'parent_id') == '0') { array_push($header,$mod_strings['LBL_RELATEDTO']); array_push($header_width,'15%'); } if(getFieldVisibilityPermission('Calendar',$current_user->id,'contact_id') == '0') { array_push($header,$mod_strings['LBL_CONTACT_NAME']); array_push($header_width,'15%'); }*/ if (getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') { array_push($header, $mod_strings['LBL_STATUS']); array_push($header_width, '10%'); } if (isPermitted("Calendar", "EditView") == "yes" || isPermitted("Calendar", "Delete") == "yes") { array_push($header, $mod_strings['LBL_ACTION']); array_push($header_width, '10%'); } array_push($header, $mod_strings['LBL_ASSINGEDTO']); array_push($header_width, '15%'); } else { $colspan = 10; $header = array('0' => '#', '1' => $mod_strings['LBL_TIME'], '2' => $mod_strings['LBL_START_DATE'], '3' => $mod_strings['LBL_DUE_DATE'], '4' => $mod_strings['LBL_TODO']); $header_width = array('0' => '5%', '1' => '10%', '2' => '10%', '3' => '10%', '4' => '28%'); /*if(getFieldVisibilityPermission('Calendar',$current_user->id,'parent_id') == '0') { array_push($header,$mod_strings['LBL_RELATEDTO']); array_push($header_width,'15%'); } if(getFieldVisibilityPermission('Calendar',$current_user->id,'contact_id') == '0') { array_push($header,$mod_strings['LBL_CONTACT_NAME']); array_push($header_width,'15%'); }*/ if (getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') { array_push($header, $mod_strings['LBL_STATUS']); array_push($header_width, '10%'); } if (isPermitted("Calendar", "EditView") == "yes" || isPermitted("Calendar", "Delete") == "yes") { array_push($header, $mod_strings['LBL_ACTION']); } array_push($header, $mod_strings['LBL_ASSINGEDTO']); array_push($header_width, '15%'); } if ($current_user->column_fields['is_admin'] == 'on') { $Res = $adb->pquery("select * from vtiger_activitytype", array()); } else { $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; array_push($roleids, $roleid); } else { $roleids = $roleid; } if (count($roleids) > 1) { $Res = $adb->pquery("select distinct activitytype from vtiger_activitytype inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_activitytype.picklist_valueid where roleid in (" . generateQuestionMarks($roleids) . ") and picklistid in (select picklistid from vtiger_activitytype) order by sortid asc", array($roleids)); } else { $Res = $adb->pquery("select distinct activitytype from vtiger_activitytype inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_activitytype.picklist_valueid where roleid = ? and picklistid in (select picklistid from vtiger_activitytype) order by sortid asc", array($roleid)); } } $eventlist = ''; for ($i = 0; $i < $adb->num_rows($Res); $i++) { $eventlist .= $adb->query_result($Res, $i, 'activitytype') . ";"; } $list_view .= "<table align='center' border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t\t<tr><td colspan='3'> </td></tr>"; //checking permission for Create/Edit Operation if (isPermitted("Calendar", "EditView") == "yes") { $list_view .= "<tr>\n\t\t\t\t<td class='calAddButton' onMouseOver='fnAddEvent(this,\"addEventDropDown\",\"" . $temp_date . "\",\"" . $endtemp_date . "\",\"" . $time_arr['starthour'] . "\",\"" . $time_arr['startmin'] . "\",\"" . $time_arr['startfmt'] . "\",\"" . $time_arr['endhour'] . "\",\"" . $time_arr['endmin'] . "\",\"" . $time_arr['endfmt'] . "\",\"\",\"" . $subtab . "\",\"" . $eventlist . "\");'style='border: 1px solid #666666;cursor:pointer;height:30px' align='center' width='10%'>\n " . $mod_strings['LBL_ADD'] . "\n <img src='" . vtiger_imageurl('menuDnArrow.gif', $theme) . "' style='padding-left: 5px;' border='0'> </td>"; } else { $list_view .= "<tr><td> </td>"; } $list_view .= "<td align='center' width='60%'><span id='total_activities'>" . getTodoInfo($cal, 'listcnt') . "</span> </td>\n\t\t\t\t<td align='right' width='28%'> </td>\n\t\t\t</tr>\n\t\t</table>\n\n\t\t\t<br><table style='background-color: rgb(204, 204, 204);' class='small' align='center' border='0' cellpadding='5' cellspacing='1' width='98%'>\n "; $header_rows = count($header); $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string, "Calendar", "index"); if ($navigationOutput != '') { $list_view .= "<tr width=100% bgcolor=white><td align=center colspan={$header_rows}>"; $list_view .= "<table align=center width='98%'><tr>" . $navigationOutput . "</tr></table></td></tr>"; } $list_view .= "<tr>"; for ($i = 0; $i < $header_rows; $i++) { $list_view .= "<td class='lvtCol' width='" . $header_width[$i] . "' nowrap='nowrap'>" . $header[$i] . "</td>"; } $list_view .= "</tr>"; $rows = count($todo_list); if ($rows != 0) { for ($i = 0; $i < count($todo_list); $i++) { $list_view .= "<tr style='height: 25px;' bgcolor='white'>"; foreach ($todo_list[$i] as $key => $entry) { $list_view .= "<td>" . $entry . "</td>"; } $list_view .= "</tr>"; } } else { $list_view .= "<tr><td style='background-color:#efefef;height:340px' align='center' colspan='" . $colspan . "'>"; $list_view .= "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 45%; position: relative; z-index: 5000;'>\n\t\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t\t<tr>\n\t\t\t\t<td rowspan='2' width='25%'>\n\t\t\t\t\t<img src='" . vtiger_imageurl('empty.jpg', $theme) . "' height='60' width='61'></td>\n\t\t\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='75%'><span class='genHeaderSmall'>" . $app_strings['LBL_NO'] . " " . $app_strings['Todos'] . " " . $app_strings['LBL_FOUND'] . " !</span></td>\n\t\t\t</tr>\n\t\t\t<tr>"; //checking permission for Create/Edit Operation if (isPermitted("Calendar", "EditView") == "yes") { $list_view .= "<td class='small' align='left' nowrap='nowrap'>" . $app_strings['LBL_YOU_CAN_CREATE'] . " " . $app_strings['LBL_A'] . " " . $app_strings['Todo'] . " " . $app_strings['LBL_NOW'] . ". " . $app_strings['LBL_CLICK_THE_LINK'] . " :<br>\n\t\t\t\t\t -<a href='javascript:void(0);' onClick='gshow(\"createTodo\",\"todo\",\"" . $temp_date . "\",\"" . $temp_date . "\",\"" . $time_arr['starthour'] . "\",\"" . $time_arr['startmin'] . "\",\"" . $time_arr['startfmt'] . "\",\"" . $time_arr['endhour'] . "\",\"" . $time_arr['endmin'] . "\",\"" . $time_arr['endfmt'] . "\",\"listview\",\"todo\");'>" . $app_strings['LBL_CREATE'] . " " . $app_strings['LBL_A'] . " " . $app_strings['Todo'] . "</a>\n\t\t\t\t\t</td>"; } else { $list_view .= "<td class='small' align='left' nowrap='nowrap'>" . $app_strings['LBL_YOU_ARE_NOT_ALLOWED_TO_CREATE'] . " " . $app_strings['LBL_A'] . " " . $app_strings['Todo'] . "<br></td>"; } $list_view .= "</tr>\n\t\t\t</table>\n\t\t\t</div>"; $list_view .= "</td></tr>"; } $list_view .= "</table><br>"; $cal_log->debug("Exiting constructTodoListView() method..."); return $list_view; }
function getAdvFilterSqlOLD2($relblockid) { global $current_user; $advfilter = $this->getAdvFilterByRBid($relblockid); $advcvsql = ""; foreach ($advfilter as $groupid => $groupinfo) { $groupcolumns = $groupinfo["columns"]; $groupcondition = $groupinfo["condition"]; $advfiltergroupsql = ""; foreach ($groupcolumns as $columnindex => $columninfo) { $columnname = $columninfo['columnname']; $comparator = $columninfo['comparator']; $value = $columninfo['value']; $columncondition = $columninfo['column_condition']; $columns = explode(":", $columnname); $datatype = isset($columns[4]) ? $columns[4] : ""; if ($columnname != "" && $comparator != "") { $valuearray = explode(",", trim($value)); if (isset($valuearray) && count($valuearray) > 1 && $comparator != 'bw') { $advorsql = ""; for ($n = 0; $n < count($valuearray); $n++) { $advorsql[] = $this->getRealValues($columns[0], $columns[1], $comparator, trim($valuearray[$n]), $datatype); } //If negative logic filter ('not equal to', 'does not contain') is used, 'and' condition should be applied instead of 'or' if ($comparator == 'n' || $comparator == 'k') { $advorsqls = implode(" and ", $advorsql); } else { $advorsqls = implode(" or ", $advorsql); } $advfiltersql = " (" . $advorsqls . ") "; } elseif ($comparator == 'bw' && count($valuearray) == 2) { $advfiltersql = "(" . $columns[0] . "." . $columns[1] . " between '" . getValidDBInsertDateTimeValue(trim($valuearray[0]), $datatype) . "' and '" . getValidDBInsertDateTimeValue(trim($valuearray[1]), $datatype) . "')"; } elseif ($comparator == 'y') { $advfiltersql = sprintf("(%s.%s IS NULL OR %s.%s = '')", $columns[0], $columns[1], $columns[0], $columns[1]); } else { //Added for getting vtiger_activity Status -Jaguar if ($this->customviewmodule == "Calendar" && ($columns[1] == "status" || $columns[1] == "eventstatus")) { if (getFieldVisibilityPermission("Calendar", $current_user->id, 'taskstatus') == '0') { $advfiltersql = "case when (vtiger_activity.status not like '') then vtiger_activity.status else vtiger_activity.eventstatus end" . $this->getAdvComparator($comparator, trim($value), $datatype); } else { $advfiltersql = "vtiger_activity.eventstatus" . $this->getAdvComparator($comparator, trim($value), $datatype); } } elseif ($this->customviewmodule == "Documents" && $columns[1] == 'folderid') { $advfiltersql = "vtiger_attachmentsfolder.foldername" . $this->getAdvComparator($comparator, trim($value), $datatype); } elseif ($this->customviewmodule == "Assets") { if ($columns[1] == 'account') { $advfiltersql = "vtiger_account.accountname" . $this->getAdvComparator($comparator, trim($value), $datatype); } if ($columns[1] == 'product') { $advfiltersql = "vtiger_products.productname" . $this->getAdvComparator($comparator, trim($value), $datatype); } if ($columns[1] == 'invoiceid') { $advfiltersql = "vtiger_invoice.subject" . $this->getAdvComparator($comparator, trim($value), $datatype); } } else { $advfiltersql = $this->getRealValues($columns[0], $columns[1], $comparator, trim($value), $datatype); } } $advfiltergroupsql .= $advfiltersql; if ($columncondition != NULL && $columncondition != '' && count($groupcolumns) > $columnindex) { $advfiltergroupsql .= ' ' . $columncondition . ' '; } } } if (trim($advfiltergroupsql) != "") { $advfiltergroupsql = "( {$advfiltergroupsql} ) "; if ($groupcondition != NULL && $groupcondition != '' && $advfilter > $groupid) { $advfiltergroupsql .= ' ' . $groupcondition . ' '; } $advcvsql .= $advfiltergroupsql; } } if (trim($advcvsql) != "") { $advcvsql = '(' . $advcvsql . ')'; } return $advcvsql; }
function module_Chart($user_id, $date_start = "2000-01-01", $end_date = "2017-01-01", $query, $graph_for, $title, $added_qry = "", $module = "", $graph_type) { global $adb, $current_user, $mod_strings, $default_charset; global $days, $date_array, $period_type; if ($added_qry != "") { $query .= $added_qry; } $result = $adb->query($query); $no_of_rows = $adb->num_rows($result); $mod_count_array = array(); $search_str_array = array(); $mod_name_array = array(); $count_by_date[] = array(); $mod_tot_cnt_array = array(); $mod_name_val = ""; $mod_cnt_crtd_date = ""; $target_val = ""; $bar_target_val = ""; $test_target_val = ""; if ($no_of_rows != 0) { while ($row = $adb->fetch_array($result)) { if ($graph_for == 'sostatus' || $graph_for == 'leadsource' || $graph_for == 'leadstatus' || $graph_for == 'industry' || $graph_for == 'productcategory' || $graph_for == 'postatus' || $graph_for == 'invoicestatus' || $graph_for == 'ticketstatus' || $graph_for == 'priority' || $graph_for == 'category' || $graph_for == 'quotestage' || $graph_for == 'salesstage') { $mod_name = getTranslatedString($row[$graph_for]); $search_str = $row[$graph_for]; } else { $mod_name = $row[$graph_for]; $search_str = $row[$graph_for]; } if ($mod_name == "") { $mod_name = $mod_strings["Un Assigned"]; $search_str = " "; } $crtd_time = $row['createdtime']; $crtd_time_array = explode(" ", $crtd_time); $crtd_date = $crtd_time_array[0]; if (!isset($mod_tot_cnt_array[$crtd_date])) { $mod_tot_cnt_array[$crtd_date] = 0; } $mod_tot_cnt_array[$crtd_date] += 1; if (in_array($mod_name, $mod_name_array) == false) { $uniqueid[$mod_name] = '0'; array_push($mod_name_array, $mod_name); // getting all the unique Names into the array if ($graph_for == "productname") { if ($row['qtyinstock'] == '') { $mod_count_array[$mod_name] = 1; } else { $mod_count_array[$mod_name] = $row['qtyinstock']; } } } else { if ($graph_for == "productname") { $uniqueid[$mod_name] = $uniqueid[$mod_name] + 1; $mod_name = $mod_name . '[' . $uniqueid[$mod_name] . ']'; array_push($mod_name_array, $mod_name); // getting all the unique Names into the array if ($row['qtyinstock'] == '') { $mod_count_array[$mod_name] = 1; } else { $mod_count_array[$mod_name] = $row['qtyinstock']; } } } if (in_array($search_str, $search_str_array) == false) { array_push($search_str_array, $search_str); } //Counting the number of values for a type of graph if ($graph_for == "productname") { if ($row['qtyinstock'] == '') { $mod_count_array[$mod_name] = 1; } else { $mod_count_array[$mod_name] = $row['qtyinstock']; } } else { if (!isset($mod_count_array[$mod_name])) { $mod_count_array[$mod_name] = 0; } $mod_count_array[$mod_name]++; } //Counting the number of values for a type of graph for a particular date if (!isset($count_by_date[$mod_name][$crtd_date])) { $count_by_date[$mod_name][$crtd_date] = 0; } $count_by_date[$mod_name][$crtd_date] += 1; } $mod_by_mod_cnt = count($mod_name_array); if ($mod_by_mod_cnt != 0) { $url_string = ""; $mod_cnt_table = "<table border=0 cellspacing=1 cellpadding=3><tr>\r\n\t\t\t\t<th> Status </th>"; //Assigning the Header values to the vtiger_table and giving the dates as graphformat for ($i = 0; $i < $days; $i++) { $tdate = $date_array[$i]; $values = Graph_n_table_format($period_type, $tdate); $graph_format = $values[0]; $table_format = $values[1]; $mod_cnt_table .= "<th>{$table_format}</th>"; } $mod_cnt_table .= "<th>Total</th></tr>"; //For all type of the array for ($i = 0; $i < count($mod_name_array); $i++) { $search_str = $search_str_array[$i]; $mod_name = $mod_name_array[$i]; $id_name = ""; if ($mod_name == "Un Assigned") { $mod_name = $mod_strings["Un Assigned"]; $search_str = " "; } if ($graph_for == "accountid") { $name_val_table = get_account_name($mod_name); } else { $name_val_table = $mod_name; } $mod_cnt_table .= "<tr><td>{$name_val_table}</td>"; $mod_cnt_crtd_date = ""; //For all the days for ($j = 0; $j < $days; $j++) { $tdate = $date_array[$j]; if (!isset($count_by_date[$mod_name][$tdate])) { $count_by_date[$mod_name][$tdate] = "0"; } $cnt_by_date = $count_by_date[$mod_name][$tdate]; $mod_cnt_table .= "<td>{$cnt_by_date} </td>"; if ($i == 0) { $values = Graph_n_table_format($period_type, $tdate); $graph_format = $values[0]; $table_format = $values[1]; //passing the created dates to graph if ($mod_graph_date != "") { $mod_graph_date = "{$mod_graph_date},{$graph_format}"; } else { $mod_graph_date = "{$graph_format}"; } } //passing the name count by date to graph if ($mod_cnt_crtd_date != "") { $mod_cnt_crtd_date .= ",{$cnt_by_date}"; } else { $mod_cnt_crtd_date = "{$cnt_by_date}"; } } $mod_count_val = $mod_count_array[$mod_name]; $tot_mod_cnt = array_sum($count_by_date[$mod_name]); $mod_cnt_table .= "<td align=center>{$tot_mod_cnt}</td></tr>"; if ($graph_for == "accountid") { $name_val = get_account_name($mod_name); if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "smownerid") { $name_val = getOwnerName($mod_name); if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "product_id" || $graph_for == "productid") { $query = "SELECT productname FROM vtiger_products WHERE productid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "productname"); if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "purchaseorderid") { $query = "SELECT subject FROM vtiger_purchaseorder WHERE purchaseorderid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "subject"); $id_name = $mod_name; if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "quoteid") { $query = "SELECT subject FROM vtiger_quotes WHERE quoteid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "subject"); $id_name = $mod_name; if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "invoiceid") { $query = "SELECT subject FROM vtiger_invoice WHERE invoiceid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "subject"); $id_name = $mod_name; if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "campaignid") { //this will return the list of the names of the campaign``:w for the y-axis $query = "SELECT campaignname FROM vtiger_campaign WHERE campaignid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "campaignname"); $id_name = $mod_name; if ($name_val != "") { $mod_name = $name_val; $search_str = $name_val; } } if ($graph_for == "parent_id" || $graph_for == "related_to") { $seType = getSalesEntityType($mod_name); if ($seType == 'Contacts') { $query = "SELECT lastname, firstname FROM vtiger_contactdetails\r\n\t\t\t\t\t\t\tWHERE contactid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "lastname"); if ($name_val != "") { if (getFieldVisibilityPermission('Contacts', $current_user->id, 'firstname') == '0') { $first_name = $adb->query_result($result, 0, "firstname"); if ($first_name != '') { $name_val .= " " . $first_name; } } } } else { $query = "SELECT accountname FROM vtiger_account WHERE accountid=?"; $result = $adb->pquery($query, array($mod_name)); $name_val = $adb->query_result($result, 0, "accountname"); } $mod_name = $name_val; $search_str = $name_val; } //Passing name to graph $mod_name = str_replace(":", ":", $mod_name); if ($mod_name_val != "") { $mod_name_val .= "::{$mod_name}"; } else { $mod_name_val = "{$mod_name}"; } //Passing count to graph if ($mod_cnt_val != "") { $mod_cnt_val .= "::{$mod_count_val}"; } else { $mod_cnt_val = "{$mod_count_val}"; } if ($module != "") { //Check for Ticket Priority if ($graph_type == "ticketsbypriority") { $graph_for = "ticketpriorities"; } //added to get valid url in dashbord for tickets by team if ($graph_for == "smownerid") { $searchField = "assigned_user_id"; } elseif ($graph_for == 'category') { $searchField = 'ticketcategories'; } elseif ($graph_for == 'priority') { $searchField = 'ticketpriorities'; } elseif ($graph_for == "accountid") { $searchField = "account_id"; } else { $searchField = $graph_for; } $cvid = getCvIdOfAll($module); if ($module == "Home") { $cvid = getCvIdOfAll($mod_name); $link_val = "index.php?module=" . $mod_name . "&action=ListView&from_homepagedb=true&type=dbrd&query=true&owner=" . $current_user->user_name . "&viewname=" . $cvid; } else { if ($module == "Contacts" || $module == "Products" && ($graph_for == "quoteid" || $graph_for == "invoiceid" || $graph_for == "purchaseorderid")) { $link_val = "index.php?module=" . $module . "&action=ListView&from_dashboard=true&type=dbrd&query=true&" . $searchField . "=" . $id_name . "&viewname=" . $cvid; } else { $esc_search_str = urlencode($search_str); //$esc_search_str = htmlentities($search_str, ENT_QUOTES, $default_charset); $link_val = "index.php?module=" . $module . "&action=index&from_dashboard=true&search_text=" . $esc_search_str . "&search_field=" . $searchField . "&searchtype=BasicSearch&query=true&type=entchar&operator=e&viewname=" . $cvid; } } //Adding the links to the graph $link_val = str_replace(':', ':', $link_val); if ($i == 0) { $bar_target_val .= $link_val; } else { $bar_target_val .= "::" . $link_val; } } //The data as per given date if ($i == 0) { $urlstring .= $mod_cnt_crtd_date; } else { $urlstring .= "K" . $mod_cnt_crtd_date; } if ($i == 0) { $test_target_val .= $link_val; } else { $test_target_val .= "K" . $link_val; } } $mod_cnt_table .= "</tr><tr><td class=\"{$class}\">Total</td>"; //For all Days getting the vtiger_table for ($k = 0; $k < $days; $k++) { $tdate = $date_array[$k]; if (!isset($mod_tot_cnt_array[$tdate])) { $mod_tot_cnt_array[$tdate] = "0"; } $tot = $mod_tot_cnt_array[$tdate]; if ($period_type != "yday") { $mod_cnt_table .= "<td>{$tot}</td>"; } } if ($graph_for == "productname") { $cnt_total = array_sum($mod_count_array); } else { $cnt_total = array_sum($mod_tot_cnt_array); } $mod_cnt_table .= "<td align=\"center\" class=\"{$class}\">{$cnt_total}</td></tr></table>"; $mod_cnt_table .= "</table>"; $title_of_graph = "{$title} : {$cnt_total}"; $bar_target_val = urlencode($bar_target_val); $test_target_val = urlencode($test_target_val); $Prod_mod_val = array($mod_name_val, $mod_cnt_val, $title_of_graph, $bar_target_val, $mod_graph_date, $urlstring, $mod_cnt_table, $test_target_val); return $Prod_mod_val; } else { $data = 0; } } else { $data = 0; return "<h3> The data is not available with the specified time period</h3>"; } return $data; }
/** Function to check permission to access the column for a given user * @param $userid -- User Id :: Type integer * @param $tablename -- tablename :: Type String * @param $columnname -- columnname :: Type String * @param $module -- Module Name :: Type varchar */ function getColumnVisibilityPermission($userid, $columnname, $module, $accessmode = 'readonly') { $adb = PearDatabase::getInstance(); $log = vglobal('log'); $log->debug("in function getcolumnvisibilitypermission {$columnname} -{$userid}"); $tabid = getTabid($module); // Look at cache if information is available. $cacheFieldInfo = VTCacheUtils::lookupFieldInfoByColumn($tabid, $columnname); $fieldname = false; if ($cacheFieldInfo === false) { $res = $adb->pquery("select fieldname from vtiger_field where tabid=? and columnname=? and vtiger_field.presence in (0,2)", array($tabid, $columnname)); $fieldname = $adb->query_result($res, 0, 'fieldname'); } else { $fieldname = $cacheFieldInfo['fieldname']; } return getFieldVisibilityPermission($module, $userid, $fieldname, $accessmode); }
/** Function used to get the Status history of the Invoice * @param $id - invoice id * @return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are arrays which contains header values and all column values of all entries */ function get_invoicestatushistory($id) { $log = vglobal('log'); $log->debug("Entering get_invoicestatushistory(" . $id . ") method ..."); $adb = PearDatabase::getInstance(); global $mod_strings; global $app_strings; $query = 'select vtiger_invoicestatushistory.*, vtiger_invoice.invoice_no from vtiger_invoicestatushistory inner join vtiger_invoice on vtiger_invoice.invoiceid = vtiger_invoicestatushistory.invoiceid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_invoice.invoiceid where vtiger_crmentity.deleted = 0 and vtiger_invoice.invoiceid = ?'; $result = $adb->pquery($query, array($id)); $noofrows = $adb->num_rows($result); $header[] = $app_strings['Invoice No']; $header[] = $app_strings['LBL_ACCOUNT_NAME']; $header[] = $app_strings['LBL_AMOUNT']; $header[] = $app_strings['LBL_INVOICE_STATUS']; $header[] = $app_strings['LBL_LAST_MODIFIED']; //Getting the field permission for the current user. 1 - Not Accessible, 0 - Accessible //Account Name , Amount are mandatory fields. So no need to do security check to these fields. $current_user = vglobal('current_user'); //If field is accessible then getFieldVisibilityPermission function will return 0 else return 1 $invoicestatus_access = getFieldVisibilityPermission('Invoice', $current_user->id, 'invoicestatus') != '0' ? 1 : 0; $picklistarray = getAccessPickListValues('Invoice'); $invoicestatus_array = $invoicestatus_access != 1 ? $picklistarray['invoicestatus'] : array(); //- ==> picklist field is not permitted in profile //Not Accessible - picklist is permitted in profile but picklist value is not permitted $error_msg = $invoicestatus_access != 1 ? 'Not Accessible' : '-'; while ($row = $adb->fetch_array($result)) { $entries = array(); // Module Sequence Numbering //$entries[] = $row['invoiceid']; $entries[] = $row['invoice_no']; // END $entries[] = $row['accountname']; $entries[] = $row['total']; $entries[] = in_array($row['invoicestatus'], $invoicestatus_array) ? $row['invoicestatus'] : $error_msg; $entries[] = DateTimeField::convertToUserFormat($row['lastmodified']); $entries_list[] = $entries; } $return_data = array('header' => $header, 'entries' => $entries_list); $log->debug("Exiting get_invoicestatushistory method ..."); return $return_data; }
$focus->id = ""; } if (isset($_REQUEST['mode']) && $_REQUEST['mode'] != ' ') { $smarty->assign("OP_MODE", vtlib_purify($_REQUEST['mode'])); } if (!$_SESSION['rlvs'][$module]) { unset($_SESSION['rlvs']); } if (isset($_REQUEST['record']) && $_REQUEST['record'] != '') { $userid = $current_user->id; $sql = "select fieldname from vtiger_field where uitype = '13' and tabid = 7 and vtiger_field.presence in (0,2)"; $result = $adb->pquery($sql, array()); $num_fieldnames = $adb->num_rows($result); for ($i = 0; $i < $num_fieldnames; $i++) { $fieldname = $adb->query_result($result, $i, "fieldname"); $permit = getFieldVisibilityPermission("Leads", $userid, $fieldname); } } $smarty->assign("TODO_PERMISSION", CheckFieldPermission('parent_id', 'Calendar')); $smarty->assign("EVENT_PERMISSION", CheckFieldPermission('parent_id', 'Events')); $smarty->assign("CATEGORY", $category); $parent_email = getEmailParentsList('Leads', $focus->id, $focus); $smarty->assign("HIDDEN_PARENTS_LIST", $parent_email); // Module Sequence Numbering $mod_seq_field = getModuleSequenceField($currentModule); if ($mod_seq_field != null) { $mod_seq_id = $focus->column_fields[$mod_seq_field['name']]; } else { $mod_seq_id = $focus->id; } $smarty->assign('MOD_SEQ_ID', $mod_seq_id);
/** * Default (generic) function to handle the dependents list for the module. * NOTE: UI type '10' is used to stored the references to other modules for a given record. * These dependent records can be retrieved through this function. * For eg: A trouble ticket can be related to an Account or a Contact. * From a given Contact/Account if we need to fetch all such dependent trouble tickets, get_dependents_list function can be used. */ function get_dependents_list($id, $cur_tab_id, $rel_tab_id, $actions = false) { global $currentModule, $app_strings, $singlepane_view, $current_user; $parenttab = getParentTab(); $related_module = vtlib_getModuleNameById($rel_tab_id); $other = CRMEntity::getInstance($related_module); // Some standard module class doesn't have required variables // that are used in the query, they are defined in this generic API vtlib_setup_modulevars($currentModule, $this); vtlib_setup_modulevars($related_module, $other); $singular_modname = 'SINGLE_' . $related_module; $button = ''; // To make the edit or del link actions to return back to same view. if ($singlepane_view == 'true') { $returnset = "&return_module={$currentModule}&return_action=DetailView&return_id={$id}"; } else { $returnset = "&return_module={$currentModule}&return_action=CallRelatedList&return_id={$id}"; } $return_value = null; $dependentFieldSql = $this->db->pquery("SELECT tabid, fieldname, columnname FROM vtiger_field WHERE uitype='10' AND" . " fieldid IN (SELECT fieldid FROM vtiger_fieldmodulerel WHERE relmodule=? AND module=?)", array($currentModule, $related_module)); $numOfFields = $this->db->num_rows($dependentFieldSql); if ($numOfFields > 0) { $dependentColumn = $this->db->query_result($dependentFieldSql, 0, 'columnname'); $dependentField = $this->db->query_result($dependentFieldSql, 0, 'fieldname'); $button .= '<input type="hidden" name="' . $dependentColumn . '" id="' . $dependentColumn . '" value="' . $id . '">'; $button .= '<input type="hidden" name="' . $dependentColumn . '_type" id="' . $dependentColumn . '_type" value="' . $currentModule . '">'; if ($actions) { if (is_string($actions)) { $actions = explode(',', strtoupper($actions)); } if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes' && getFieldVisibilityPermission($related_module, $current_user->id, $dependentField, 'readwrite') == '0') { $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $related_module) . "'> "; } } $query = "SELECT vtiger_crmentity.*, {$other->table_name}.*"; $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query .= ", CASE WHEN (vtiger_users.user_name NOT LIKE '') THEN {$userNameSql} ELSE vtiger_groups.groupname END AS user_name"; $more_relation = ''; if (!empty($other->related_tables)) { foreach ($other->related_tables as $tname => $relmap) { $query .= ", {$tname}.*"; // Setup the default JOIN conditions if not specified if (empty($relmap[1])) { $relmap[1] = $other->table_name; } if (empty($relmap[2])) { $relmap[2] = $relmap[0]; } $more_relation .= " LEFT JOIN {$tname} ON {$tname}.{$relmap['0']} = {$relmap['1']}.{$relmap['2']}"; } } $query .= " FROM {$other->table_name}"; $query .= " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = {$other->table_name}.{$other->table_index}"; $query .= " INNER JOIN {$this->table_name} ON {$this->table_name}.{$this->table_index} = {$other->table_name}.{$dependentColumn}"; $query .= $more_relation; $query .= " LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid"; $query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid"; $query .= " WHERE vtiger_crmentity.deleted = 0 AND {$this->table_name}.{$this->table_index} = {$id}"; $return_value = GetRelatedList($currentModule, $related_module, $other, $query, $button, $returnset); } if ($return_value == null) { $return_value = array(); } $return_value['CUSTOM_BUTTON'] = $button; return $return_value; }
/** * this function returns the widget information for an module type widget */ private function getModuleFilters($sid) { global $adb, $current_user; $querycvid = "select vtiger_homemoduleflds.fieldname,vtiger_homemodule.* from vtiger_homemoduleflds\n\t\t\t\t\tleft join vtiger_homemodule on vtiger_homemodule.stuffid=vtiger_homemoduleflds.stuffid\n\t\t\t\t\twhere vtiger_homemoduleflds.stuffid=?"; $resultcvid = $adb->pquery($querycvid, array($sid)); $modname = $adb->query_result($resultcvid, 0, "modulename"); $cvid = $adb->query_result($resultcvid, 0, "customviewid"); $maxval = $adb->query_result($resultcvid, 0, "maxentries"); $column_count = $adb->num_rows($resultcvid); $cvid_check_query = $adb->pquery("SELECT * FROM vtiger_customview WHERE cvid = ?", array($cvid)); if (isPermitted($modname, 'index') == "yes") { if ($adb->num_rows($cvid_check_query) > 0) { $focus = CRMEntity::getInstance($modname); $oCustomView = new CustomView($modname); if ($modname == "Calendar") { $listquery = getListQuery($modname); if (trim($listquery) == '') { $listquery = $focus->getListQuery($modname); } $query = $oCustomView->getModifiedCvListQuery($cvid, $listquery, $modname); } else { $queryGenerator = new QueryGenerator($modname, $current_user); $queryGenerator->initForCustomViewById($cvid); $customViewFields = $queryGenerator->getCustomViewFields(); $fields = $queryGenerator->getFields(); $newFields = array_diff($fields, $customViewFields); for ($l = 0; $l < $column_count; $l++) { $customViewColumnInfo = $adb->query_result($resultcvid, $l, "fieldname"); $details = explode(':', $customViewColumnInfo); $newFields[] = $details[2]; } $queryGenerator->setFields($newFields); $query = $queryGenerator->getQuery(); } $count_result = $adb->query(mkCountQuery($query)); $noofrows = $adb->query_result($count_result, 0, "count"); $navigation_array = getNavigationValues(1, $noofrows, $maxval); //To get the current language file global $current_language, $app_strings; $fieldmod_strings = return_module_language($current_language, $modname); if ($modname == "Calendar") { $query .= "AND vtiger_activity.activitytype NOT IN ('Emails')"; } $list_result = $adb->query($query . " LIMIT 0," . $maxval); if ($modname == "Calendar") { for ($l = 0; $l < $column_count; $l++) { $fieldinfo = $adb->query_result($resultcvid, $l, "fieldname"); list($tabname, $colname, $fldname, $fieldmodlabel) = explode(":", $fieldinfo); $fieldheader = explode("_", $fieldmodlabel, 2); $fldlabel = $fieldheader[1]; $pos = strpos($fldlabel, "_"); if ($pos == true) { $fldlabel = str_replace("_", " ", $fldlabel); } $field_label = isset($app_strings[$fldlabel]) ? $app_strings[$fldlabel] : (isset($fieldmod_strings[$fldlabel]) ? $fieldmod_strings[$fldlabel] : $fldlabel); $cv_presence = $adb->pquery("SELECT * from vtiger_cvcolumnlist WHERE cvid = ? and columnname LIKE '%" . $fldname . "%'", array($cvid)); if ($is_admin == false) { $fld_permission = getFieldVisibilityPermission($modname, $current_user->id, $fldname); } if ($fld_permission == 0 && $adb->num_rows($cv_presence)) { $field_query = $adb->pquery("SELECT fieldlabel FROM vtiger_field WHERE fieldname = ? AND tablename = ? and vtiger_field.presence in (0,2)", array($fldname, $tabname)); $field_label = $adb->query_result($field_query, 0, 'fieldlabel'); $header[] = $field_label; } $fieldcolumns[$fldlabel] = array($tabname => $colname); } $listview_entries = getListViewEntries($focus, $modname, $list_result, $navigation_array, "", "", "EditView", "Delete", $oCustomView, 'HomePage', $fieldcolumns); } else { $controller = new ListViewController($adb, $current_user, $queryGenerator); $controller->setHeaderSorting(false); $header = $controller->getListViewHeader($focus, $modname, '', '', '', true); $listview_entries = $controller->getListViewEntries($focus, $modname, $list_result, $navigation_array, true); } $return_value = array('ModuleName' => $modname, 'cvid' => $cvid, 'Maxentries' => $maxval, 'Header' => $header, 'Entries' => $listview_entries); if (sizeof($header) != 0) { return $return_value; } else { return array('Entries' => "Fields not found in Selected Filter"); } } else { return array('Entries' => "<font color='red'>Filter You have Selected is Not Found</font>"); } } else { return array('Entries' => "<font color='red'>Permission Denied</font>"); } }
/** Function used to get the Quote Stage history of the Quotes * @param $id - quote id * @return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are arrays which contains header values and all column values of all entries */ function get_quotestagehistory($id) { global $log; $log->debug("Entering get_quotestagehistory(" . $id . ") method ..."); global $adb; global $mod_strings; global $app_strings; $query = 'select vtiger_quotestagehistory.*, vtiger_quotes.quote_no from vtiger_quotestagehistory inner join vtiger_quotes on vtiger_quotes.quoteid = vtiger_quotestagehistory.quoteid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_quotes.quoteid where vtiger_crmentity.deleted = 0 and vtiger_quotes.quoteid = ?'; $result = $adb->pquery($query, array($id)); $noofrows = $adb->num_rows($result); $header[] = $app_strings['Quote No']; $header[] = $app_strings['LBL_ACCOUNT_NAME']; $header[] = $app_strings['LBL_AMOUNT']; $header[] = $app_strings['Quote Stage']; $header[] = $app_strings['LBL_LAST_MODIFIED']; //Getting the field permission for the current user. 1 - Not Accessible, 0 - Accessible //Account Name , Total are mandatory fields. So no need to do security check to these fields. global $current_user; //If field is accessible then getFieldVisibilityPermission function will return 0 else return 1 $quotestage_access = getFieldVisibilityPermission('Quotes', $current_user->id, 'quotestage') != '0' ? 1 : 0; $picklistarray = getAccessPickListValues('Quotes'); $quotestage_array = $quotestage_access != 1 ? $picklistarray['quotestage'] : array(); //- ==> picklist field is not permitted in profile //Not Accessible - picklist is permitted in profile but picklist value is not permitted $error_msg = $quotestage_access != 1 ? 'Not Accessible' : '-'; while ($row = $adb->fetch_array($result)) { $entries = array(); // Module Sequence Numbering //$entries[] = $row['quoteid']; $entries[] = $row['quote_no']; // END $entries[] = $row['accountname']; $entries[] = $row['total']; $entries[] = in_array($row['quotestage'], $quotestage_array) ? $row['quotestage'] : $error_msg; $entries[] = getDisplayDate($row['lastmodified']); $entries_list[] = $entries; } $return_data = array('header' => $header, 'entries' => $entries_list); $log->debug("Exiting get_quotestagehistory method ..."); return $return_data; }
function emails_checkFieldVisiblityPermission($fieldname) { global $current_user; $ret = getFieldVisibilityPermission('Emails', $current_user->id, $fieldname); return $ret; }
if ($disp_view == 'edit_view') { $smarty->assign("BLOCKS", getBlocks($currentModule, $disp_view, $mode, $focus->column_fields)); } else { $smarty->assign("BASBLOCKS", getBlocks($currentModule, $disp_view, $mode, $focus->column_fields, 'BAS')); } $smarty->assign("OP_MODE", $disp_view); $category = getParentTab(); $smarty->assign("CATEGORY", $category); $log->info("Document detail view"); $smarty->assign("MOD", $mod_strings); $smarty->assign("APP", $app_strings); $smarty->assign("MODULE", $currentModule); $smarty->assign("SINGLE_MOD", 'Document'); //Display the RTE or not? -- configure $USE_RTE in config.php $USE_RTE = vt_hasRTE(); if (getFieldVisibilityPermission('Documents', $current_user->id, 'notecontent') != '0') { $USE_RTE = false; } $smarty->assign("USE_RTE", $USE_RTE); if (isset($focus->name)) { $smarty->assign("NAME", $focus->name); } else { $smarty->assign("NAME", ""); } if ($focus->mode == 'edit') { $smarty->assign("UPDATEINFO", updateInfo($focus->id)); $smarty->assign("MODE", $focus->mode); } else { $smarty->assign("MODE", 'create'); } $smarty->assign('CREATEMODE', vtlib_purify($_REQUEST['createmode']));
/** to get the standard filter criteria * @param $module(module name) :: Type String * @param $elected (selection status) :: Type String (optional) * @returns $filter Array in the following format * $filter = Array( 0 => array('value'=>$tablename:$colname:$fieldname:$fieldlabel,'text'=>$mod_strings[$field label],'selected'=>$selected), * 1 => array('value'=>$$tablename1:$colname1:$fieldname1:$fieldlabel1,'text'=>$mod_strings[$field label1],'selected'=>$selected), */ function getStdFilterHTML($module, $selected = "") { global $app_list_strings, $current_language, $app_strings, $current_user; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; global $oCustomView; $stdfilter = array(); $result = $oCustomView->getStdCriteriaByModule($module); $mod_strings = return_module_language($current_language, $module); if (isset($result)) { foreach ($result as $key => $value) { if ($value == 'Start Date & Time') { $value = 'Start Date'; } $use_module_label = getTranslatedString($module, $module); if (isset($app_list_strings['moduleList'][$module])) { $use_module_label = $app_list_strings['moduleList'][$module]; } if (isset($mod_strings[$value])) { if ($key == $selected) { $filter['value'] = $key; $filter['text'] = $use_module_label . " - " . getTranslatedString($value); $filter['selected'] = "selected"; } else { $filter['value'] = $key; $filter['text'] = $use_module_label . " - " . getTranslatedString($value); $filter['selected'] = ""; } } else { if ($key == $selected) { $filter['value'] = $key; $filter['text'] = $use_module_label . " - " . $value; $filter['selected'] = 'selected'; } else { $filter['value'] = $key; $filter['text'] = $use_module_label . " - " . $value; $filter['selected'] = ''; } } $stdfilter[] = $filter; //added to fix ticket #5117. If a user doesn't have permission for a field and it has been used to fileter a custom view, it should be get displayed to him as Not Accessible. if (!$is_admin && $selected != '' && $filter['selected'] == '') { $keys = explode(":", $selected); if (getFieldVisibilityPermission($module, $current_user->id, $keys[2]) != '0') { $filter['value'] = "not_accessible"; $filter['text'] = $app_strings["LBL_NOT_ACCESSIBLE"]; $filter['selected'] = "selected"; $stdfilter[] = $filter; } } } } return $stdfilter; }
/** * Invoked when special actions are performed on the module. * @param String Module name * @param String Event Type (module.postinstall, module.disabled, module.enabled, module.preuninstall) */ function get_osstimecontrol($id, $cur_tab_id, $rel_tab_id, $actions = false) { global $log, $singlepane_view, $currentModule, $current_user; $log->debug("Entering get_osstimecontrol(" . $id . ") method ..."); $this_module = $currentModule; $related_module = vtlib_getModuleNameById($rel_tab_id); require_once "modules/{$related_module}/{$related_module}.php"; $other = new $related_module(); vtlib_setup_modulevars($related_module, $other); $singular_modname = vtlib_toSingular($related_module); $record = Vtiger_Record_Model::getInstanceById($id); $userId = $record->get('assigned_user_id'); if ($singlepane_view == 'true') { $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; } else { $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; } $button = ''; if ($actions && getFieldVisibilityPermission($related_module, $current_user->id, 'parent_id', 'readwrite') == '0') { if (is_string($actions)) { $actions = explode(',', strtoupper($actions)); } if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> "; } if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') { $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'> "; } } $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query = "SELECT case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name, vtiger_users.id,\n\t\t\t\tvtiger_osstimecontrol.name, vtiger_osstimecontrol.osstimecontrolid as crmid, vtiger_osstimecontrol.osstimecontrol_status, vtiger_osstimecontrol.payment,\n\t\t\t\tvtiger_osstimecontrol.osstimecontrol_no, vtiger_osstimecontrol.date_start, vtiger_osstimecontrol.due_date, vtiger_osstimecontrol.time_end, vtiger_osstimecontrol.sum_time, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime\n\t\t\t\tFROM vtiger_osstimecontrol\n\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_osstimecontrol.osstimecontrolid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_crmentity.`smownerid`= " . $userId; $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); if ($return_value == null) { $return_value = array(); } $return_value['CUSTOM_BUTTON'] = $button; $log->debug("Exiting get_osstimecontrol method ..."); return $return_value; }
$prod_price_list = getPricesForProducts($currency_id, $new_prod_array); $list_body = ''; for ($i = 0; $i < count($new_prod_array); $i++) { $log->info("Products :: Showing the List of products to be added in price book"); $entity_id = $new_prod_array[$i]; $list_body .= '<tr class="lvtColData" onmouseover="this.className=\'lvtColDataHover\'" onmouseout="this.className=\'lvtColData\'" bgcolor="white">'; $unit_price = $prod_price_list[$entity_id]; $field_name = $entity_id . "_listprice"; $unit_price_array[] = '"' . CurrencyField::convertToUserFormat($unit_price, null, true) . '"'; $field_name_array[] = "'" . $field_name . "'"; $list_body .= '<td><INPUT type=checkbox NAME="selected_id" id="check_' . $entity_id . '" value= ' . $entity_id . ' onClick=\'toggleSelectAll(this.name,"selectall");updateListPriceForField("' . $field_name . '",this)\'></td>'; $list_body .= '<td>' . $adb->query_result($list_result, $entity_id_array[$entity_id], "productname") . '</td>'; if (getFieldVisibilityPermission('Products', $current_user->id, 'productcode') == '0') { $list_body .= '<td>' . $adb->query_result($list_result, $entity_id_array[$entity_id], "productcode") . '</td>'; } if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') { $list_body .= '<td>' . CurrencyField::convertToUserFormat($unit_price, null, true) . '</td>'; } $list_body .= '<td>'; if (isPermitted("PriceBooks", "EditView", "") == 'yes') { $list_body .= '<input type="text" name="' . $field_name . '" style="visibility:hidden;" id="' . $field_name . '">'; } else { $list_body .= '<input type="text" name="' . $field_name . '" style="visibility:hidden;" readonly id="' . $field_name . '">'; } $list_body .= '</td></tr>'; } $smarty->assign("UNIT_PRICE_ARRAY", implode(",", $unit_price_array)); $smarty->assign("FIELD_NAME_ARRAY", implode(",", $field_name_array)); if ($order_by != '') { $url_string .= "&order_by=" . $order_by; }
/** * Function to get Potential related SalesOrder * @param integer $id - potentialid * returns related SalesOrder record in array format */ function get_salesorder($id, $cur_tab_id, $rel_tab_id, $actions = false) { $log = vglobal('log'); $current_user = vglobal('current_user'); $singlepane_view = vglobal('singlepane_view'); $currentModule = vglobal('currentModule'); $log->debug("Entering get_salesorder(" . $id . ") method ..."); $this_module = $currentModule; $related_module = vtlib_getModuleNameById($rel_tab_id); require_once "modules/{$related_module}/{$related_module}.php"; $other = new $related_module(); vtlib_setup_modulevars($related_module, $other); $singular_modname = vtlib_toSingular($related_module); if ($singlepane_view == 'true') { $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; } else { $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; } $button = ''; if ($actions && getFieldVisibilityPermission($related_module, $current_user->id, 'potential_id', 'readwrite') == '0') { if (is_string($actions)) { $actions = explode(',', strtoupper($actions)); } if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { $button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> "; } if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') { $button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'> "; } } $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename\n\t\t\t, vtiger_account.accountname, vtiger_potential.potentialname,case when\n\t\t\t(vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname\n\t\t\tend as user_name from vtiger_salesorder\n\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid\n\t\t\tleft outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid\n\t\t\tleft outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid\n\t\t\tleft outer join vtiger_potential on vtiger_potential.potentialid=vtiger_salesorder.potentialid\n\t\t\tleft join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid\n LEFT JOIN vtiger_salesordercf ON vtiger_salesordercf.salesorderid = vtiger_salesorder.salesorderid\n LEFT JOIN vtiger_invoice_recurring_info ON vtiger_invoice_recurring_info.start_period = vtiger_salesorder.salesorderid\n\t\t\tLEFT JOIN vtiger_salesorderaddress ON vtiger_salesorderaddress.salesorderaddressid = vtiger_salesorder.salesorderid\n\t\t\tleft join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\t where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid = " . $id; $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); if ($return_value == null) { $return_value = array(); } $return_value['CUSTOM_BUTTON'] = $button; $log->debug("Exiting get_salesorder method ..."); return $return_value; }
/** Function used to get the prices for the given list of products based in the specified currency * @param int $currencyid - currency id based on which the prices have to be provided * @param array $product_ids - List of product id's for which we want to get the price based on given currency * @return array $prices_list - List of prices for the given list of products based on the given currency in the form of 'product id' mapped to 'price value' */ function getPricesForProducts($currencyid, $product_ids, $module = 'Products') { global $adb, $log, $current_user; $price_list = array(); if (count($product_ids) > 0) { if ($module == 'Services') { $query = "SELECT vtiger_currency_info.id, vtiger_currency_info.conversion_rate, " . "vtiger_service.serviceid AS productid, vtiger_service.unit_price, " . "vtiger_productcurrencyrel.actual_price " . "FROM (vtiger_currency_info, vtiger_service) " . "left join vtiger_productcurrencyrel on vtiger_service.serviceid = vtiger_productcurrencyrel.productid " . "and vtiger_currency_info.id = vtiger_productcurrencyrel.currencyid " . "where vtiger_service.serviceid in (" . generateQuestionMarks($product_ids) . ") and vtiger_currency_info.id = ?"; } else { $query = "SELECT vtiger_currency_info.id, vtiger_currency_info.conversion_rate, " . "vtiger_products.productid, vtiger_products.unit_price, " . "vtiger_productcurrencyrel.actual_price " . "FROM (vtiger_currency_info, vtiger_products) " . "left join vtiger_productcurrencyrel on vtiger_products.productid = vtiger_productcurrencyrel.productid " . "and vtiger_currency_info.id = vtiger_productcurrencyrel.currencyid " . "where vtiger_products.productid in (" . generateQuestionMarks($product_ids) . ") and vtiger_currency_info.id = ?"; } $params = array($product_ids, $currencyid); $result = $adb->pquery($query, $params); for ($i = 0; $i < $adb->num_rows($result); $i++) { $product_id = $adb->query_result($result, $i, 'productid'); if (getFieldVisibilityPermission($module, $current_user->id, 'unit_price') == '0') { $actual_price = (double) $adb->query_result($result, $i, 'actual_price'); if ($actual_price == null || $actual_price == '') { $unit_price = $adb->query_result($result, $i, 'unit_price'); $product_conv_rate = $adb->query_result($result, $i, 'conversion_rate'); $product_base_conv_rate = getBaseConversionRateForProduct($product_id, 'edit', $module); $conversion_rate = $product_conv_rate * $product_base_conv_rate; $actual_price = $unit_price * $conversion_rate; } $price_list[$product_id] = $actual_price; } else { $price_list[$product_id] = ''; } } } return $price_list; }
/** Function to display the Services which are related to the PriceBook * @param string $query - query to get the list of products which are related to the current PriceBook * @param object $focus - PriceBook object which contains all the information of the current PriceBook * @param string $returnset - return_module, return_action and return_id which are sequenced with & to pass to the URL which is optional * return array $return_data which will be formed like array('header'=>$header,'entries'=>$entries_list) where as $header contains all the header columns and $entries_list will contain all the Service entries */ function getPriceBookRelatedServices($query, $focus, $returnset = '') { global $log; $log->debug("Entering getPriceBookRelatedServices(" . $query . "," . get_class($focus) . "," . $returnset . ") method ..."); global $adb; global $app_strings; global $current_language, $current_user; $current_module_strings = return_module_language($current_language, 'Services'); global $list_max_entries_per_page; global $urlPrefix; global $theme; $pricebook_id = $_REQUEST['record']; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $computeCount = $_REQUEST['withCount']; if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true || (bool) $computeCount == true) { $noofrows = $adb->query_result($adb->query(mkCountQuery($query)), 0, 'count'); } else { $noofrows = null; } $module = 'PriceBooks'; $relatedmodule = 'Services'; if (!$_SESSION['rlvs'][$module][$relatedmodule]) { $modObj = new ListViewSession(); $modObj->sortby = $focus->default_order_by; $modObj->sorder = $focus->default_sort_order; $_SESSION['rlvs'][$module][$relatedmodule] = get_object_vars($modObj); } if (isset($_REQUEST['relmodule']) && $_REQUEST['relmodule'] != '' && $_REQUEST['relmodule'] == $relatedmodule) { $relmodule = vtlib_purify($_REQUEST['relmodule']); if ($_SESSION['rlvs'][$module][$relmodule]) { setSessionVar($_SESSION['rlvs'][$module][$relmodule], $noofrows, $list_max_entries_per_page, $module, $relmodule); } } global $relationId; $start = RelatedListViewSession::getRequestCurrentPage($relationId, $query); $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows); $limit_start_rec = ($start - 1) * $list_max_entries_per_page; if ($adb->dbType == "pgsql") { $list_result = $adb->pquery($query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array()); } else { $list_result = $adb->pquery($query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array()); } $header = array(); $header[] = $current_module_strings['LBL_LIST_SERVICE_NAME']; if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') { $header[] = $current_module_strings['LBL_SERVICE_UNIT_PRICE']; } $header[] = $current_module_strings['LBL_PB_LIST_PRICE']; if (isPermitted("PriceBooks", "EditView", "") == 'yes' || isPermitted("PriceBooks", "Delete", "") == 'yes') { $header[] = $app_strings['LBL_ACTION']; } $currency_id = $focus->column_fields['currency_id']; $numRows = $adb->num_rows($list_result); for ($i = 0; $i < $numRows; $i++) { $entity_id = $adb->query_result($list_result, $i, "crmid"); $unit_price = $adb->query_result($list_result, $i, "unit_price"); if ($currency_id != null) { $prod_prices = getPricesForProducts($currency_id, array($entity_id), 'Services'); $unit_price = $prod_prices[$entity_id]; } $listprice = $adb->query_result($list_result, $i, "listprice"); $field_name = $entity_id . "_listprice"; $entries = array(); $entries[] = textlength_check($adb->query_result($list_result, $i, "servicename")); if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') { $entries[] = CurrencyField::convertToUserFormat($unit_price, null, true); } $entries[] = CurrencyField::convertToUserFormat($listprice, null, true); $action = ""; if (isPermitted("PriceBooks", "EditView", "") == 'yes' && isPermitted('Services', 'EditView', $entity_id) == 'yes') { $action .= '<img style="cursor:pointer;" src="themes/images/editfield.gif" border="0" onClick="fnvshobj(this,\'editlistprice\'),editProductListPrice(\'' . $entity_id . '\',\'' . $pricebook_id . '\',\'' . $listprice . '\')" alt="' . $app_strings["LBL_EDIT_BUTTON"] . '" title="' . $app_strings["LBL_EDIT_BUTTON"] . '"/>'; } else { $action .= '<img src="' . vtiger_imageurl('blank.gif', $theme) . '" border="0" />'; } if (isPermitted("PriceBooks", "Delete", "") == 'yes' && isPermitted('Services', 'Delete', $entity_id) == 'yes') { if ($action != "") { $action .= ' | '; } $action .= '<img src="themes/images/delete.gif" onclick="if(confirm(\'' . $app_strings['ARE_YOU_SURE'] . '\')) deletePriceBookProductRel(' . $entity_id . ',' . $pricebook_id . ');" alt="' . $app_strings["LBL_DELETE"] . '" title="' . $app_strings["LBL_DELETE"] . '" style="cursor:pointer;" border="0">'; } if ($action != "") { $entries[] = $action; } $entries_list[] = $entries; } $navigationOutput[] = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows); $navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, '', $module, $relatedmodule, $focus->id); $return_data = array('header' => $header, 'entries' => $entries_list, 'navigation' => $navigationOutput); $log->debug("Exiting getPriceBookRelatedServices method ..."); return $return_data; }
function CheckFieldPermission($fieldname, $module) { global $current_user, $adb; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; if ($fieldname == '' || $module == '') { return "false"; } if (getFieldVisibilityPermission($module, $current_user->id, $fieldname) == '0') { return "true"; } return "false"; }
/** to get the realvalues for the given value * @param $tablename :: type string * @param $fieldname :: type string * @param $comparator :: type string * @param $value :: type string * @returns $value as a string in the following format * $tablename.$fieldname comparator */ function getRealValues($tablename, $fieldname, $comparator, $value, $datatype) { //we have to add the fieldname/tablename.fieldname and the corresponding value (which we want) we can add here. So that when these LHS field comes then RHS value will be replaced for LHS in the where condition of the query global $adb, $mod_strings, $currentModule, $current_user; //Added for proper check of contact name in advance filter if ($tablename == "vtiger_contactdetails" && $fieldname == "lastname") { $fieldname = "contactid"; } $contactid = "vtiger_contactdetails.lastname"; if ($currentModule != "Contacts" && $currentModule != "Leads" && getFieldVisibilityPermission("Contacts", $current_user->id, 'firstname') == '0' && $currentModule != 'Campaigns') { $contactid = "concat(vtiger_contactdetails.lastname,' ',vtiger_contactdetails.firstname)"; } $change_table_field = array("product_id" => "vtiger_products.productname", "contactid" => $contactid, "contact_id" => $contactid, "accountid" => "", "account_id" => "", "vendorid" => "vtiger_vendor.vendorname", "vendor_id" => "vtiger_vendor.vendorname", "potentialid" => "vtiger_potential.potentialname", "vtiger_account.parentid" => "vtiger_account2.accountname", "quoteid" => "vtiger_quotes.subject", "salesorderid" => "vtiger_salesorder.subject", "campaignid" => "vtiger_campaign.campaignname", "vtiger_contactdetails.reportsto" => "concat(vtiger_contactdetails2.lastname,' ',vtiger_contactdetails2.firstname)", "vtiger_pricebook.currency_id" => "vtiger_currency_info.currency_name"); if ($fieldname == "smownerid") { $temp_value = "( vtiger_users.user_name" . $this->getAdvComparator($comparator, $value, $datatype); $temp_value .= " OR vtiger_groups.groupname" . $this->getAdvComparator($comparator, $value, $datatype); $value = $temp_value . ")"; } elseif ($fieldname == "inventorymanager") { $value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, getUserId_Ol($value), $datatype); } elseif ($change_table_field[$fieldname] != '') { $value = $change_table_field[$fieldname] . $this->getAdvComparator($comparator, $value, $datatype); } elseif ($change_table_field[$tablename . "." . $fieldname] != '') { $tmp_value = ''; if (($comparator == 'e' || $comparator == 's' || $comparator == 'c') && trim($value) == '' || ($comparator == 'n' || $comparator == 'k') && trim($value) != '') { $tmp_value = $change_table_field[$tablename . "." . $fieldname] . ' IS NULL or '; } $value = $tmp_value . $change_table_field[$tablename . "." . $fieldname] . $this->getAdvComparator($comparator, $value, $datatype); } elseif ($fieldname == "handler") { $value = "vtiger_users.user_name" . $this->getAdvComparator($comparator, $value, $datatype); } elseif ($fieldname == "crmid" && $tablename != 'vtiger_crmentity' || $fieldname == "parent_id" || $fieldname == 'parentid') { //For crmentity.crmid the control should not come here. This is only to get the related to modules $value = $this->getSalesRelatedName($comparator, $value, $datatype, $tablename, $fieldname); } else { //For checkbox type values, we have to convert yes/no as 1/0 to get the values $field_uitype = getUItype($this->customviewmodule, $fieldname); if ($field_uitype == 56) { if (strtolower($value) == 'yes') { $value = 1; } elseif (strtolower($value) == 'no') { $value = 0; } } else { if (is_uitype($field_uitype, '_picklist_')) { /* Fix for tickets 4465 and 4629 */ // Get all the keys for the for the Picklist value $mod_keys = array_keys($mod_strings, $value); // Iterate on the keys, to get the first key which doesn't start with LBL_ (assuming it is not used in PickList) foreach ($mod_keys as $mod_idx => $mod_key) { $stridx = strpos($mod_key, 'LBL_'); // Use strict type comparision, refer strpos for more details if ($stridx !== 0) { $value = $mod_key; break; } } } } //added to fix the ticket if ($this->customviewmodule == "Calendar" && ($fieldname == "status" || $fieldname == "taskstatus" || $fieldname == "eventstatus")) { if (getFieldVisibilityPermission("Calendar", $current_user->id, 'taskstatus') == '0') { $value = " (case when (vtiger_activity.status not like '') then vtiger_activity.status else vtiger_activity.eventstatus end)" . $this->getAdvComparator($comparator, $value, $datatype); } else { $value = " vtiger_activity.eventstatus " . $this->getAdvComparator($comparator, $value, $datatype); } } elseif ($comparator == 'e' && (trim($value) == "NULL" || trim($value) == '')) { $value = '(' . $tablename . "." . $fieldname . ' IS NULL OR ' . $tablename . "." . $fieldname . ' = \'\')'; } else { $value = $tablename . "." . $fieldname . $this->getAdvComparator($comparator, $value, $datatype); } //end } return $value; }
/** 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; }