public function getDisplayValue($value, $recordId = false, $recordInstance = false, $rawText = false) { $currentUser = Users_Record_Model::getCurrentUserModel(); $internalMailer = $currentUser->get('internal_mailer'); if ($value) { $moduleName = $this->get('field')->get('block')->module->name; $fieldName = $this->get('field')->get('name'); if ($internalMailer == 1) { /** * We should not add "emailField" class to user name field. * If we do so, for sending mail from list view is taking that value as a TO field. */ if ($moduleName == "Users" && $fieldName == "user_name") { $value = "<a class='cursorPointer' onclick=\"Vtiger_Helper_Js.getInternalMailer({$recordId}," . "'{$fieldName}','{$moduleName}');\">" . textlength_check($value) . "</a>"; } else { $value = "<a class='emailField cursorPointer' onclick=\"Vtiger_Helper_Js.getInternalMailer({$recordId}," . "'{$fieldName}','{$moduleName}');\">" . textlength_check($value) . "</a>"; } } else { if ($moduleName == "Users" && $fieldName == "user_name") { $value = "<a class='cursorPointer' href='mailto:" . $value . "'>" . textlength_check($value) . "</a>"; } else { $value = "<a class='emailField cursorPointer' href='mailto:" . $value . "'>" . textlength_check($value) . "</a>"; } } } return $value; }
/** * Function to get display value * @param <String> $value * @param <Number> $recordId * @return <String> display value */ public function getDisplayValue($value, $recordId) { $displayValue = $this->getEditViewDisplayValue($value); $currentUserModel = Users_Record_Model::getCurrentUserModel(); if ($currentUserModel->isAdminUser()) { $roleRecordModel = new Settings_Roles_Record_Model(); $roleRecordModel->set('roleid', $value); return '<a href="' . $roleRecordModel->getEditViewUrl() . '">' . textlength_check($displayValue) . '</a>'; } return $displayValue; }
public function getDisplayValue($value) { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $value, $matches); if (!empty($matches[0])) { $value = '<a class="urlField cursorPointer" href="' . $value . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a class="urlField cursorPointer" href="http://' . $value . '" target="_blank">' . textlength_check($value) . '</a>'; } return $value; }
/** * Function to get display value * @param <String> $value * @param <Number> $recordId * @return <String> display value */ public function getDisplayValue($value, $recordId) { $displayValue = $this->getEditViewDisplayValue($value); $currentUserModel = Users_Record_Model::getCurrentUserModel(); if ($currentUserModel->isAdminUser()) { $recordModel = Users_Record_Model::getCleanInstance('Users'); $recordModel->set('id', $value); return '<a href="' . $recordModel->getDetailViewUrl() . '">' . textlength_check($displayValue) . '</a>'; } return $displayValue; }
static function getFullNameFromQResult($result, $row_count, $module) { global $adb; $rowdata = $adb->query_result_rowdata($result, $row_count); $entity_field_info = getEntityFieldNames($module); $fieldsName = $entity_field_info['fieldname']; $name = ''; if ($rowdata != '' && count($rowdata) > 0) { $name = self::getCurrentUserEntityFieldNameDisplay($module, $fieldsName, $rowdata ); } $name = textlength_check($name); return $name; }
/** * Function to get display value * @param <String> $value * @param <Number> $recordId * @return <String> display value */ public function getDisplayValue($value, $recordId) { global $log; $log->debug("Entering ./uitypes/UserReference.php::getDisplayValue"); $displayValue = $this->getEditViewDisplayValue($value); $currentUserModel = Users_Record_Model::getCurrentUserModel(); if ($currentUserModel->isAdminUser()) { $recordModel = Users_Record_Model::getCleanInstance('Users'); $recordModel->set('id', $value); return '<a href="' . $recordModel->getDetailViewUrl() . '">' . textlength_check($displayValue) . '</a>'; } return $displayValue; }
public function getDisplayValue($value) { global $log; $log->debug("Entering ./uitypes/Url.php::getDisplayValue"); $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $value, $matches); if (!empty($matches[0])) { $value = '<a class="urlField cursorPointer" href="' . $value . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a class="urlField cursorPointer" href="http://' . $value . '" target="_blank">' . textlength_check($value) . '</a>'; } return $value; }
public function getDisplayValue($value, $recordId) { $currentUser = Users_Record_Model::getCurrentUserModel(); $internalMailer = $currentUser->get('internal_mailer'); if ($value) { if ($internalMailer == 1) { $fieldName = $this->get('field')->get('name'); $value = "<a class='emailField cursorPointer' onclick=\"Vtiger_Helper_Js.getInternalMailer({$recordId}," . "'{$fieldName}');\">" . textlength_check($value) . "</a>"; } else { $value = "<a class='emailField cursorPointer' href='mailto:" . $value . "'>" . textlength_check($value) . "</a>"; } } return $value; }
function getListViewEntries2($focus, $module, $list_result, $navigation_array, $relatedlist = '', $returnset = '', $edit_action = 'EditView', $del_action = 'Delete', $oCv = '', $page = '', $selectedfields = '', $contRelatedfields = '', $skipActions = false) { global $log; global $mod_strings; $log->debug("Entering getListViewEntries(" . get_class($focus) . "," . $module . "," . $list_result . "," . $navigation_array . "," . $relatedlist . "," . $returnset . "," . $edit_action . "," . $del_action . "," . (is_object($oCv) ? get_class($oCv) : $oCv) . ") method ..."); $tabname = getParentTab(); global $adb, $current_user; global $app_strings; $noofrows = $adb->num_rows($list_result); $list_block = array(); global $theme; $evt_status = ''; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; //getting the vtiger_fieldtable entries from database $tabid = getTabid($module); //added for vtiger_customview 27/5 if ($oCv) { if (isset($oCv->list_fields)) { $focus->list_fields = $oCv->list_fields; } } if (is_array($selectedfields) && $selectedfields != '') { $focus->list_fields = $selectedfields; } // Remove fields which are made inactive $focus->filterInactiveFields($module); //Added to reduce the no. of queries logging for non-admin user -- by minnie-start $field_list = array(); $j = 0; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; foreach ($focus->list_fields as $name => $tableinfo) { $fieldname = $focus->list_fields_name[$name]; if ($oCv) { if (isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; } } if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } array_push($field_list, $fieldname); $j++; } $field = array(); if ($is_admin == false) { if ($module == 'Emails') { $query = "SELECT fieldname FROM vtiger_field WHERE tabid = ? and vtiger_field.presence in (0,2)"; $params = array($tabid); } else { $profileList = getCurrentUserProfileList(); $params = array(); $query = "SELECT DISTINCT vtiger_field.fieldname\r\n\t\t\t\tFROM vtiger_field\r\n\t\t\t\tINNER JOIN vtiger_profile2field\r\n\t\t\t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\r\n\t\t\t\tINNER JOIN vtiger_def_org_field\r\n\t\t\t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid"; if ($module == "Calendar") { $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)"; } else { $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)"; array_push($params, $tabid); } $query .= " AND vtiger_profile2field.visible = 0\r\n\t\t\t\t\tAND vtiger_profile2field.visible = 0\r\n\t\t\t\t\tAND vtiger_def_org_field.visible = 0\r\n\t\t\t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\r\n\t\t\t\t\tAND vtiger_field.fieldname IN (" . generateQuestionMarks($field_list) . ")"; array_push($params, $profileList, $field_list); } $result = $adb->pquery($query, $params); for ($k = 0; $k < $adb->num_rows($result); $k++) { $field[] = $adb->query_result($result, $k, "fieldname"); } } //constructing the uitype and columnname array $ui_col_array = array(); $params = array(); $query = "SELECT uitype, columnname, fieldname FROM vtiger_field "; if ($module == "Calendar") { $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)"; } else { $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)"; array_push($params, $tabid); } $query .= " AND fieldname IN (" . generateQuestionMarks($field_list) . ") "; array_push($params, $field_list); $result = $adb->pquery($query, $params); $num_rows = $adb->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $tempArr = array(); $uitype = $adb->query_result($result, $i, 'uitype'); $columnname = $adb->query_result($result, $i, 'columnname'); $field_name = $adb->query_result($result, $i, 'fieldname'); $tempArr[$uitype] = $columnname; $ui_col_array[$field_name] = $tempArr; } //end if ($navigation_array['start'] != 0) { for ($i = 1; $i <= $noofrows; $i++) { $list_header = array(); //Getting the entityid if ($module != 'Users') { $entity_id = $adb->query_result($list_result, $i - 1, "crmid"); $owner_id = $adb->query_result($list_result, $i - 1, "smownerid"); } else { $entity_id = $adb->query_result($list_result, $i - 1, "id"); } // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2 // begin: Armando Lüscher 05.07.2005 -> §priority // Code contri buted by fredy Desc: Set Priority color $priority = $adb->query_result($list_result, $i - 1, "priority"); $font_color_high = "color:#00DD00;"; $font_color_medium = "color:#DD00DD;"; $P_FONT_COLOR = ""; switch ($priority) { case 'High': $P_FONT_COLOR = $font_color_high; break; case 'Medium': $P_FONT_COLOR = $font_color_medium; break; default: $P_FONT_COLOR = ""; } //end: Armando Lüscher 05.07.2005 -> §priority foreach ($focus->list_fields as $name => $tableinfo) { $fieldname = $focus->list_fields_name[$name]; //added for vtiger_customview 27/5 if ($oCv) { if (isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } } else { $fieldname = $focus->list_fields_name[$name]; } } else { $fieldname = $focus->list_fields_name[$name]; if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } } if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || in_array($fieldname, $field) || $fieldname == '' || $name == 'Close' && $module == 'Calendar') { if ($fieldname == '') { $table_name = ''; $column_name = ''; foreach ($tableinfo as $tablename => $colname) { $table_name = $tablename; $column_name = $colname; } $value = $adb->query_result($list_result, $i - 1, $colname); } else { if ($module == 'Calendar') { $act_id = $adb->query_result($list_result, $i - 1, "activityid"); $cal_sql = "select activitytype from vtiger_activity where activityid=?"; $cal_res = $adb->pquery($cal_sql, array($act_id)); if ($adb->num_rows($cal_res) >= 0) { $activitytype = $adb->query_result($cal_res, 0, "activitytype"); } } if (($module == 'Calendar' || $module == 'Emails' || $module == 'HelpDesk' || $module == 'Invoice' || $module == 'Leads' || $module == 'Contacts') && ($fieldname == 'parent_id' || $name == 'Contact Name' || $name == 'Close' || $fieldname == 'firstname')) { if ($module == 'Calendar') { if ($fieldname == 'status') { if ($activitytype == 'Task') { $fieldname = 'taskstatus'; } else { $fieldname = 'eventstatus'; } } if ($activitytype == 'Task') { if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') { $has_permission = 'yes'; } else { $has_permission = 'no'; } } else { if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') { $has_permission = 'yes'; } else { $has_permission = 'no'; } } } if ($module != 'Calendar' || $module == 'Calendar' && $has_permission == 'yes') { if ($fieldname == 'parent_id') { $value = getRelatedTo($module, $list_result, $i - 1); } if ($name == 'Contact Name') { $contact_id = $adb->query_result($list_result, $i - 1, "contactid"); $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts"); $value = ""; //Added to get the contactname for activities custom view - t=2190 if ($contact_id != '' && !empty($contact_name)) { $contact_name = getContactName($contact_id); } if ($contact_name != "" && $contact_id != 'NULL') { // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2 $value = "<a href='index.php?module=Contacts&action=DetailView&parenttab=" . $tabname . "&record=" . $contact_id . "' style='" . $P_FONT_COLOR . "'>" . $contact_name . "</a>"; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR" } } if ($fieldname == "firstname") { $first_name = textlength_check($adb->query_result($list_result, $i - 1, "firstname")); $value = '<a href="index.php?action=DetailView&module=' . $module . '&parenttab=' . $tabname . '&record=' . $entity_id . '">' . $first_name . '</a>'; } if ($name == 'Close') { $status = $adb->query_result($list_result, $i - 1, "status"); $activityid = $adb->query_result($list_result, $i - 1, "activityid"); if (empty($activityid)) { $activityid = $adb->query_result($list_result, $i - 1, "tmp_activity_id"); } $activitytype = $adb->query_result($list_result, $i - 1, "activitytype"); // TODO - Picking activitytype when it is not present in the Custom View. // Going forward, this column should be added to the select list if not already present as a performance improvement. if (empty($activitytype)) { $activitytypeRes = $adb->pquery('SELECT activitytype FROM vtiger_activity WHERE activityid=?', array($activityid)); if ($adb->num_rows($activitytypeRes) > 0) { $activitytype = $adb->query_result($activitytypeRes, 0, 'activitytype'); } } if ($activitytype != 'Task' && $activitytype != 'Emails') { $eventstatus = $adb->query_result($list_result, $i - 1, "eventstatus"); if (isset($eventstatus)) { $status = $eventstatus; } } if ($status == 'Deferred' || $status == 'Completed' || $status == 'Held' || $status == '') { $value = ""; } else { if ($activitytype == 'Task') { $evt_status = '&status=Completed'; } else { $evt_status = '&eventstatus=Held'; } if (isPermitted("Calendar", 'EditView', $activityid) == 'yes') { if ($returnset == '') { $returnset = '&return_module=Calendar&return_action=ListView&return_id=' . $activityid . '&return_viewname=' . $oCv->setdefaultviewid; } // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2 $value = "<a href='index.php?action=Save&module=Calendar&record=" . $activityid . "&parenttab=" . $tabname . "&change_status=true" . $returnset . $evt_status . "&start=" . $navigation_array['current'] . "' style='" . $P_FONT_COLOR . "'>X</a>"; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR" } else { $value = ""; } } } } else { $value = ""; } } elseif ($module == "Documents" && ($fieldname == 'filelocationtype' || $fieldname == 'filename' || $fieldname == 'filesize' || $fieldname == 'filestatus' || $fieldname == 'filetype')) { $value = $adb->query_result($list_result, $i - 1, $fieldname); if ($fieldname == 'filelocationtype') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } if ($fieldname == 'filename') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); if ($downloadtype == 'I') { $fld_value = $value; $ext_pos = strrpos($fld_value, "."); $ext = substr($fld_value, $ext_pos + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fld_value = $value; $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $fld_value = '--'; $fileicon = ''; } } else { $fld_value = ' --'; $fileicon = ''; } $file_name = $adb->query_result($list_result, $i - 1, 'filename'); $notes_id = $adb->query_result($list_result, $i - 1, 'crmid'); $folder_id = $adb->query_result($list_result, $i - 1, 'folderid'); $download_type = $adb->query_result($list_result, $i - 1, 'filelocationtype'); $file_status = $adb->query_result($list_result, $i - 1, 'filestatus'); $fileidQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileidres = $adb->pquery($fileidQuery, array($notes_id)); $fileid = $adb->query_result($fileidres, 0, 'attachmentsid'); if ($file_name != '' && $file_status == 1) { if ($download_type == 'I') { $fld_value = "<a href='index.php?module=uploads&action=downloadfile&entityid={$notes_id}&fileid={$fileid}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$notes_id});'>" . $fld_value . "</a>"; } elseif ($download_type == 'E') { $fld_value = "<a target='_blank' href='{$file_name}' onclick='javascript:dldCntIncrease({$notes_id});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . $fld_value . "</a>"; } else { $fld_value = ' --'; } } $value = $fileicon . $fld_value; } if ($fieldname == 'filesize') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); if ($downloadtype == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } if ($fieldname == 'filestatus') { $filestatus = $value; if ($filestatus == 1) { $value = getTranslatedString('yes', $module); } elseif ($filestatus == 0) { $value = getTranslatedString('no', $module); } else { $value = ' --'; } } if ($fieldname == 'filetype') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); $filetype = $adb->query_result($list_result, $i - 1, 'filetype'); if ($downloadtype == 'E' || $downloadtype != 'I') { $value = ' --'; } else { $value = $filetype; } } if ($fieldname == 'notecontent') { $value = decode_html($value); $value = textlength_check($value); } } elseif ($module == "Products" && $name == "Related to") { $value = getRelatedTo($module, $list_result, $i - 1); } elseif ($name == 'Contact Name' && ($module == 'SalesOrder' || $module == 'Quotes' || $module == 'PurchaseOrder')) { if ($name == 'Contact Name') { $contact_id = $adb->query_result($list_result, $i - 1, "contactid"); $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts"); $value = ""; if ($contact_name != "" && $contact_id != 'NULL') { $value = "<a href='index.php?module=Contacts&action=DetailView&parenttab=" . $tabname . "&record=" . $contact_id . "' style='" . $P_FONT_COLOR . "'>" . $contact_name . "</a>"; } } } elseif ($name == 'Product') { $product_id = textlength_check($adb->query_result($list_result, $i - 1, "productname")); $value = $product_id; } elseif ($name == 'Account Name') { //modified for vtiger_customview 27/5 if ($module == 'Accounts') { $account_id = $adb->query_result($list_result, $i - 1, "crmid"); //$account_name = getAccountName($account_id); $account_name = textlength_check($adb->query_result($list_result, $i - 1, "accountname")); // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2 $value = '<a href="index.php?module=Accounts&action=DetailView&record=' . $account_id . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $account_name . '</a>'; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR" } elseif ($module == 'Potentials' || $module == 'Contacts' || $module == 'Invoice' || $module == 'SalesOrder' || $module == 'Quotes') { //Potential,Contacts,Invoice,SalesOrder & Quotes records sort by Account Name $accountname = textlength_check($adb->query_result($list_result, $i - 1, "accountname")); $accountid = $adb->query_result($list_result, $i - 1, "accountid"); $value = '<a href="index.php?module=Accounts&action=DetailView&record=' . $accountid . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $accountname . '</a>'; } else { $account_id = $adb->query_result($list_result, $i - 1, "accountid"); $account_name = getAccountName($account_id); $acc_name = textlength_check($account_name); // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2 $value = '<a href="index.php?module=Accounts&action=DetailView&record=' . $account_id . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $acc_name . '</a>'; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR" } } elseif (($module == 'HelpDesk' || $module == 'PriceBook' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'Faq') && $name == 'Product Name') { if ($module == 'HelpDesk' || $module == 'Faq') { $product_id = $adb->query_result($list_result, $i - 1, "product_id"); } else { $product_id = $adb->query_result($list_result, $i - 1, "productid"); } if ($product_id != '') { $product_name = getProductName($product_id); } else { $product_name = ''; } $value = '<a href="index.php?module=Products&action=DetailView&parenttab=' . $tabname . '&record=' . $product_id . '">' . textlength_check($product_name) . '</a>'; } elseif ($module == 'Quotes' && $name == 'Potential Name' || $module == 'SalesOrder' && $name == 'Potential Name') { $potential_id = $adb->query_result($list_result, $i - 1, "potentialid"); $potential_name = getPotentialName($potential_id); $value = '<a href="index.php?module=Potentials&action=DetailView&parenttab=' . $tabname . '&record=' . $potential_id . '">' . textlength_check($potential_name) . '</a>'; } elseif ($module == 'Emails' && $relatedlist != '' && ($name == 'Subject' || $name == 'Date Sent' || $name == 'To')) { $list_result_count = $i - 1; $tmp_value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); $value = '<a href="javascript:;" onClick="ShowEmail(\'' . $entity_id . '\');">' . textlength_check($tmp_value) . '</a>'; if ($name == 'Date Sent') { $sql = "select email_flag from vtiger_emaildetails where emailid=?"; $result = $adb->pquery($sql, array($entity_id)); $email_flag = $adb->query_result($result, 0, "email_flag"); if ($email_flag != 'SAVED') { $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } else { $value = ''; } } } elseif ($module == 'Calendar' && ($fieldname != 'taskstatus' && $fieldname != 'eventstatus')) { if ($activitytype == 'Task') { if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } else { $value = ''; } } else { if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } else { $value = ''; } } } elseif ($module == "Accounting" && $fieldname == "accounting_id") { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); $value = '<a href="index.php?action=DetailView&module=' . $module . '&parenttab=' . $tabname . '&record=' . $entity_id . '">' . $value . '</a>'; } else { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid); } } // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$entity_id}' vtfieldname='{$fieldname}' vtmodule='{$module}' style='display:none;'></span>"; // END if ($module == "Calendar" && $name == $app_strings['Close']) { if (isPermitted("Calendar", "EditView") == 'yes') { if (getFieldVisibilityPermission('Events', $current_user->id, 'eventstatus') == '0' || getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') { array_push($list_header, $value); } } } else { $list_header[] = $value; } } } $varreturnset = ''; if ($returnset == '') { $varreturnset = '&return_module=' . $module . '&return_action=index'; } else { $varreturnset = $returnset; } if ($module == 'Calendar') { $actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype'); if ($actvity_type == 'Task') { $varreturnset .= '&activity_mode=Task'; } else { $varreturnset .= '&activity_mode=Events'; } } //Added for Actions ie., edit and delete links in listview $links_info = ""; if (!(is_array($selectedfields) && $selectedfields != '')) { if (isPermitted($module, "EditView", "") == 'yes') { $edit_link = getListViewEditLink($module, $entity_id, $relatedlist, $varreturnset, $list_result, $list_result_count); if (isset($_REQUEST['start']) && $_REQUEST['start'] > 1 && $module != 'Emails') { $links_info .= "<a href=\"{$edit_link}&start=" . vtlib_purify($_REQUEST['start']) . "\">" . $app_strings["LNK_EDIT"] . "</a> "; } else { $links_info .= "<a href=\"{$edit_link}\">" . $app_strings["LNK_EDIT"] . "</a> "; } } if (isPermitted($module, "Delete", "") == 'yes') { $del_link = getListViewDeleteLink($module, $entity_id, $relatedlist, $varreturnset); if ($links_info != "" && $del_link != "") { $links_info .= " | "; } if ($del_link != "") { $links_info .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . $app_strings["LNK_DELETE"] . "</a>"; } } } // Record Change Notification if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) { if (!$focus->isViewed($entity_id)) { $links_info .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>"; } } // END if ($links_info != "" && !$skipActions) { $list_header[] = $links_info; } // $list_block[$entity_id] = $list_header; if (isset($_SESSION['partialpaymentview']) && $_SESSION['partialpaymentview'] == "true") { $list_block[$entity_id . "_" . $i] = $list_header; } else { $list_block[$entity_id] = $list_header; } } } $log->debug("Exiting getListViewEntries method ..."); return $list_block; }
/** * Returns the information about the Parent * @param String $module * @param Integer $record * @param String $label * @return Array */ public static function buildDetailViewLink($module, $record, $label) { $detailViewLink = sprintf("<a target='_blank' href='index.php?module=%s&view=Detail&record=%s'>%s</a>", $module, $record, textlength_check($label)); return array('record' => $record, 'module' => $module, 'label' => $label, 'detailviewlink' => $detailViewLink); }
function getListViewEntries($focus, $module, $result, $navigationInfo, $skipActions = false) { require 'user_privileges/user_privileges_' . $this->user->id . '.php'; global $listview_max_textlength, $theme, $default_charset; $fields = $this->queryGenerator->getFields(); $whereFields = $this->queryGenerator->getWhereFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $meta->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $field->getColumnName()); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { //array_merge API loses key information so need to merge the arrays // manually. $newOwnerList = getOwnerNameList($idList); foreach ($newOwnerList as $id => $name) { $this->ownerNameList[$fieldName][$id] = $name; } } } } } foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } } $useAsterisk = get_use_asterisk($this->user->id); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); $ownerId = $db->query_result($result, $i, "smownerid"); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; $uitype = $field->getUIType(); $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); if ($module == 'Calendar') { $activityType = $this->db->query_result($result, $i, 'activitytype'); } if ($uitype != 8) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename') { $downloadtype = $db->query_result($result, $i, 'filelocationtype'); if ($downloadtype == 'I') { $ext = substr($value, strrpos($value, ".") + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $value = '--'; $fileicon = ''; } } else { $value = ' --'; $fileicon = ''; } $fileName = $db->query_result($result, $i, 'filename'); $downloadType = $db->query_result($result, $i, 'filelocationtype'); $status = $db->query_result($result, $i, 'filestatus'); $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($recordId)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($fileName != '' && $status == 1) { if ($downloadType == 'I') { $value = "<a href='index.php?module=uploads&action=downloadfile&" . "entityid={$recordId}&fileid={$fileId}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$recordId});'>" . textlength_check($value) . "</a>"; } elseif ($downloadType == 'E') { $value = "<a target='_blank' href='{$fileName}' onclick='javascript:" . "dldCntIncrease({$recordId});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . textlength_check($value) . "</a>"; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } elseif ($field->getFieldDataType() == 'picklist') { if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName])) { $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; } else { $value = getTranslatedString($value, $module); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); if ($field->getFieldDataType() == 'datetime') { $value .= ' ' . $date->getDisplayTime(); } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = number_format($value, 2, '.', ''); $currencyValue = CurrencyField::convertToUserFormat($value, null, true); $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol); } else { //changes made to remove vtiger_currency symbol infront of each //vtiger_potential amount if ($value != 0) { $value = CurrencyField::convertToUserFormat($value); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { if ($_SESSION['internal_mailer'] == 1) { //check added for email link in user detailview $fieldId = $field->getFieldId(); $value = "<a href=\"javascript:InternalMailer({$recordId},{$fieldId}," . "'{$fieldName}','{$module}','record_id');\">" . textlength_check($value) . "</a>"; } else { $value = '<a href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=' . 'Settings&roleid=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim($val), $this->picklistValueMap[$fieldName])) { $tmpArray[] = $notaccess; $tmp .= ', ' . $notaccess; } else { $tmpArray[] = $val; $tmp .= ', ' . $val; } } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getFieldDataType() == 'phone') { if ($useAsterisk == 'true') { $value = "<a href='javascript:;' onclick='startCall("{$value}", " . ""{$recordId}")'>" . textlength_check($value) . "</a>"; } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = $moduleList[0]; } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a href='index.php?module={$parentModule}&action=DetailView&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } elseif ($field->getUIType() == 55) { $value = getTranslatedString($value, $currentModule); } else { $value = textlength_check($value); } $parenttab = getParentTab(); $nameFields = $this->queryGenerator->getModuleNameFields($module); $nameFieldList = explode(',', $nameFields); if (in_array($fieldName, $nameFieldList) && $module != 'Emails') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } elseif ($fieldName == $focus->list_link_field && $module != 'Emails') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=" . "'{$fieldName}' vtmodule='{$module}' style='display:none;'></span>"; // END $row[] = $value; } //Added for Actions ie., edit and delete links in listview $actionLinkInfo = ""; if (isPermitted($module, "EditView", "") == 'yes') { $edit_link = $this->getListViewEditLink($module, $recordId); if (isset($navigationInfo['start']) && $navigationInfo['start'] > 1 && $module != 'Emails') { $actionLinkInfo .= "<a href=\"{$edit_link}&start=" . $navigationInfo['start'] . "\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } else { $actionLinkInfo .= "<a href=\"{$edit_link}\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } } if (isPermitted($module, "Delete", "") == 'yes') { $del_link = $this->getListViewDeleteLink($module, $recordId); if ($actionLinkInfo != "" && $del_link != "") { $actionLinkInfo .= " | "; } if ($del_link != "") { $actionLinkInfo .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . getTranslatedString("LNK_DELETE", $module) . "</a>"; } } // Record Change Notification if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) { if (!$focus->isViewed($recordId)) { $actionLinkInfo .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>"; } } // END if ($actionLinkInfo != "" && !$skipActions) { $row[] = $actionLinkInfo; } $data[$recordId] = $row; } return $data; }
function content_5696169818de6($_smarty_tpl) { ?> <table width="100%" cellspacing="0" cellpadding="10" class="importContents"> <tr> <td> <strong><?php echo vtranslate('LBL_IMPORT_STEP_4', $_smarty_tpl->tpl_vars['MODULE']->value); ?> :</strong> </td> <td> <span class="big"><?php echo vtranslate('LBL_IMPORT_STEP_4_DESCRIPTION', $_smarty_tpl->tpl_vars['MODULE']->value); ?> </span> </td> <td> <div id="savedMapsContainer" class="textAlignRight pull-right"> <?php echo $_smarty_tpl->getSubTemplate(vtemplate_path("Import_Saved_Maps.tpl", 'Import'), $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0); ?> </div> </td> </tr> <tr> <td> </td> <td colspan="2"> <input type="hidden" name="field_mapping" id="field_mapping" value="" /> <input type="hidden" name="default_values" id="default_values" value="" /> <table width="100%" cellspacing="0" cellpadding="2" class="listRow table table-bordered table-condensed listViewEntriesTable"> <thead> <tr class="listViewHeaders"> <?php if ($_smarty_tpl->tpl_vars['HAS_HEADER']->value == true) { ?> <th width="25%"><a><?php echo vtranslate('LBL_FILE_COLUMN_HEADER', $_smarty_tpl->tpl_vars['MODULE']->value); ?> </a></th> <?php } ?> <th width="25%"><a><?php echo vtranslate('LBL_ROW_1', $_smarty_tpl->tpl_vars['MODULE']->value); ?> </a></th> <th width="23%"><a><?php echo vtranslate('LBL_CRM_FIELDS', $_smarty_tpl->tpl_vars['MODULE']->value); ?> </a></th> <th width="27%"><a><?php echo vtranslate('LBL_DEFAULT_VALUE', $_smarty_tpl->tpl_vars['MODULE']->value); ?> </a></th> </tr> </thead> <tbody> <?php $_smarty_tpl->tpl_vars['_FIELD_VALUE'] = new Smarty_Variable(); $_smarty_tpl->tpl_vars['_FIELD_VALUE']->_loop = false; $_smarty_tpl->tpl_vars['_HEADER_NAME'] = new Smarty_Variable(); $_from = $_smarty_tpl->tpl_vars['ROW_1_DATA']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } $_smarty_tpl->tpl_vars['smarty']->value['foreach']["headerIterator"]['iteration'] = 0; foreach ($_from as $_smarty_tpl->tpl_vars['_FIELD_VALUE']->key => $_smarty_tpl->tpl_vars['_FIELD_VALUE']->value) { $_smarty_tpl->tpl_vars['_FIELD_VALUE']->_loop = true; $_smarty_tpl->tpl_vars['_HEADER_NAME']->value = $_smarty_tpl->tpl_vars['_FIELD_VALUE']->key; $_smarty_tpl->tpl_vars['smarty']->value['foreach']["headerIterator"]['iteration']++; ?> <?php $_smarty_tpl->tpl_vars["_COUNTER"] = new Smarty_variable($_smarty_tpl->getVariable('smarty')->value['foreach']['headerIterator']['iteration'], null, 0); ?> <tr class="fieldIdentifier" id="fieldIdentifier<?php echo $_smarty_tpl->tpl_vars['_COUNTER']->value; ?> "> <?php if ($_smarty_tpl->tpl_vars['HAS_HEADER']->value == true) { ?> <td class="cellLabel"> <span name="header_name"><?php echo $_smarty_tpl->tpl_vars['_HEADER_NAME']->value; ?> </span> </td> <?php } ?> <td class="cellLabel"> <span><?php echo textlength_check($_smarty_tpl->tpl_vars['_FIELD_VALUE']->value); ?> </span> </td> <td class="cellLabel"> <input type="hidden" name="row_counter" value="<?php echo $_smarty_tpl->tpl_vars['_COUNTER']->value; ?> " /> <select name="mapped_fields" class="txtBox chzn-select" style="width: 100%" onchange="ImportJs.loadDefaultValueWidget('fieldIdentifier<?php echo $_smarty_tpl->tpl_vars['_COUNTER']->value; ?> ')"> <option value=""><?php echo vtranslate('LBL_NONE', $_smarty_tpl->tpl_vars['FOR_MODULE']->value); ?> </option> <?php $_smarty_tpl->tpl_vars['_FIELD_INFO'] = new Smarty_Variable(); $_smarty_tpl->tpl_vars['_FIELD_INFO']->_loop = false; $_smarty_tpl->tpl_vars['_FIELD_NAME'] = new Smarty_Variable(); $_from = $_smarty_tpl->tpl_vars['AVAILABLE_FIELDS']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars['_FIELD_INFO']->key => $_smarty_tpl->tpl_vars['_FIELD_INFO']->value) { $_smarty_tpl->tpl_vars['_FIELD_INFO']->_loop = true; $_smarty_tpl->tpl_vars['_FIELD_NAME']->value = $_smarty_tpl->tpl_vars['_FIELD_INFO']->key; ?> <?php $_smarty_tpl->tpl_vars["_TRANSLATED_FIELD_LABEL"] = new Smarty_variable(vtranslate($_smarty_tpl->tpl_vars['_FIELD_INFO']->value->getFieldLabelKey(), $_smarty_tpl->tpl_vars['FOR_MODULE']->value), null, 0); ?> <option value="<?php echo $_smarty_tpl->tpl_vars['_FIELD_NAME']->value; ?> " <?php if (decode_html($_smarty_tpl->tpl_vars['_HEADER_NAME']->value) == $_smarty_tpl->tpl_vars['_TRANSLATED_FIELD_LABEL']->value) { ?> selected <?php } ?> data-label="<?php echo $_smarty_tpl->tpl_vars['_TRANSLATED_FIELD_LABEL']->value; ?> "><?php echo $_smarty_tpl->tpl_vars['_TRANSLATED_FIELD_LABEL']->value; if ($_smarty_tpl->tpl_vars['_FIELD_INFO']->value->isMandatory() == 'true') { ?> (*)<?php } ?> </option> <?php } ?> </select> </td> <td class="cellLabel row-fluid" name="default_value_container"> </td> </tr> <?php } ?> </tbody> </table> </td> </tr> <tr> <td> </td> <td align="right" colspan="2"> <input type="checkbox" name="save_map" id="save_map"/> <?php echo vtranslate('LBL_SAVE_AS_CUSTOM_MAPPING', $_smarty_tpl->tpl_vars['MODULE']->value); ?> <input type="text" name="save_map_as" id="save_map_as"/> </td> </tr> </table> <?php echo $_smarty_tpl->getSubTemplate(vtemplate_path("Import_Default_Values_Widget.tpl", 'Import'), $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0); ?> <?php }
/** * Function to get the Full Name of a Contact/Lead when a query result and the row count are given * Takes the input as $result - Query Result, $row_count - Count of the Row, $module - module name * returns the Contact Name in string format. */ function getFullNameFromQResult($result, $row_count, $module) { global $log, $adb, $current_user; $log->info("In getFullNameFromQResult(" . print_r($result, true) . " - " . $row_count . "-" . $module . ") method ..."); $rowdata = $adb->query_result_rowdata($result, $row_count); $name = ''; if ($rowdata != '' && count($rowdata) > 0) { if ($module == 'Users') { $firstname = $rowdata["first_name"]; $lastname = $rowdata["last_name"]; $name = $lastname . ' ' . $firstname; } else { $firstname = $rowdata["firstname"]; $lastname = $rowdata["lastname"]; $name = $lastname; // Asha: Check added for ticket 4788 if (getFieldVisibilityPermission($module, $current_user->id, 'firstname') == '0') { $name .= ' ' . $firstname; } } } $name = textlength_check($name); return $name; }
public function getEntries($pagingModel) { $db = PearDatabase::getInstance(); $parentModule = $this->getParentRecordModel()->getModule(); $relationModel = $this->getRelationModel(); $relationModule = $relationModel->getRelationModuleModel(); $relatedColumnFields = $relationModel->getRelationFields(true, true); $relationModuleName = $relationModule->get('name'); if (count($relatedColumnFields) <= 0) { $relatedColumnFields = $relationModule->getConfigureRelatedListFields(); } if (count($relatedColumnFields) <= 0) { $relatedColumnFields = $relationModule->getRelatedListFields(); } if ($relationModuleName == 'Calendar') { //Adding visibility in the related list, showing records based on the visibility $relatedColumnFields['visibility'] = 'visibility'; } if ($relationModuleName == 'PriceBooks') { //Adding fields in the related list $relatedColumnFields['unit_price'] = 'unit_price'; $relatedColumnFields['listprice'] = 'listprice'; $relatedColumnFields['currency_id'] = 'currency_id'; } if ($relationModuleName == 'Documents') { $relatedColumnFields['filelocationtype'] = 'filelocationtype'; $relatedColumnFields['filestatus'] = 'filestatus'; } $query = $this->getRelationQuery(); if ($this->get('whereCondition')) { $query = $this->updateQueryWithWhereCondition($query); } $startIndex = $pagingModel->getStartIndex(); $pageLimit = $pagingModel->getPageLimit(); $orderBy = $this->getForSql('orderby'); $sortOrder = $this->getForSql('sortorder'); if ($orderBy) { $orderByFieldModuleModel = $relationModule->getFieldByColumn($orderBy); if ($orderByFieldModuleModel && $orderByFieldModuleModel->isReferenceField()) { //If reference field then we need to perform a join with crmentity with the related to field $queryComponents = $split = spliti(' where ', $query); $selectAndFromClause = $queryComponents[0]; $whereCondition = $queryComponents[1]; $qualifiedOrderBy = 'vtiger_crmentity' . $orderByFieldModuleModel->get('column'); $selectAndFromClause .= ' LEFT JOIN vtiger_crmentity AS ' . $qualifiedOrderBy . ' ON ' . $orderByFieldModuleModel->get('table') . '.' . $orderByFieldModuleModel->get('column') . ' = ' . $qualifiedOrderBy . '.crmid '; $query = $selectAndFromClause . ' WHERE ' . $whereCondition; $query .= ' ORDER BY ' . $qualifiedOrderBy . '.label ' . $sortOrder; } elseif ($orderByFieldModuleModel && $orderByFieldModuleModel->isOwnerField()) { $query .= ' ORDER BY COALESCE(CONCAT(vtiger_users.first_name,vtiger_users.last_name),vtiger_groups.groupname) ' . $sortOrder; } else { // Qualify the the column name with table to remove ambugity $qualifiedOrderBy = $orderBy; $orderByField = $relationModule->getFieldByColumn($orderBy); if ($orderByField) { $qualifiedOrderBy = $relationModule->getOrderBySql($qualifiedOrderBy); } $query = "{$query} ORDER BY {$qualifiedOrderBy} {$sortOrder}"; } } $limitQuery = $query . ' LIMIT ' . $startIndex . ',' . $pageLimit; $result = $db->pquery($limitQuery, array()); $relatedRecordList = array(); $currentUser = Users_Record_Model::getCurrentUserModel(); $groupsIds = Vtiger_Util_Helper::getGroupsIdsForUsers($currentUser->getId()); while ($row = $db->fetchByAssoc($result)) { $recordId = $row['crmid']; $newRow = array(); foreach ($row as $col => $val) { if (array_key_exists($col, $relatedColumnFields)) { if ($relationModuleName == 'Documents' && $col == 'filename') { $fileName = $row['filename']; $downloadType = $row['filelocationtype']; $status = $row['filestatus']; $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($recordId)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($fileName != '' && $status == 1) { if ($downloadType == 'I') { $val = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="index.php?module=Documents&action=DownloadFile&record=' . $recordId . '&fileid=' . $fileId . '"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $relationModuleName) . '" >' . textlength_check($val) . '</a>'; } elseif ($downloadType == 'E') { $val = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="' . $fileName . '" target="_blank"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $relationModuleName) . '" >' . textlength_check($val) . '</a>'; } else { $val = ' --'; } } } $newRow[$relatedColumnFields[$col]] = $val; } } //To show the value of "Assigned to" $ownerId = $row['smownerid']; $newRow['assigned_user_id'] = $row['smownerid']; if ($relationModuleName == 'Calendar') { $visibleFields = array('activitytype', 'date_start', 'time_start', 'due_date', 'time_end', 'assigned_user_id', 'visibility', 'smownerid', 'parent_id'); $visibility = true; if (in_array($ownerId, $groupsIds)) { $visibility = false; } else { if ($ownerId == $currentUser->getId()) { $visibility = false; } } if (!$currentUser->isAdminUser() && $newRow['activitytype'] != 'Task' && $newRow['visibility'] == 'Private' && $ownerId && $visibility) { foreach ($newRow as $data => $value) { if (in_array($data, $visibleFields) != -1) { unset($newRow[$data]); } } $newRow['subject'] = vtranslate('Busy', 'Events') . '*'; } if ($newRow['activitytype'] == 'Task') { unset($newRow['visibility']); } } $record = Vtiger_Record_Model::getCleanInstance($relationModule->get('name')); $record->setData($newRow)->setModuleFromInstance($relationModule); $record->setId($row['crmid']); $relatedRecordList[$row['crmid']] = $record; } $pagingModel->calculatePageRange($relatedRecordList); $nextLimitQuery = $query . ' LIMIT ' . ($startIndex + $pageLimit) . ' , 1'; $nextPageLimitResult = $db->pquery($nextLimitQuery, array()); if ($db->num_rows($nextPageLimitResult) > 0) { $pagingModel->set('nextPageExists', true); } else { $pagingModel->set('nextPageExists', false); } return $relatedRecordList; }
function getListViewRecords($focus, $module, $result) { global $listview_max_textlength, $theme, $default_charset; require 'user_privileges/user_privileges_' . $this->user->id . '.php'; $fields = $this->queryGenerator->getFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $this->queryGenerator->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $field->getColumnName()); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { //array_merge API loses key information so need to merge the arrays // manually. $newOwnerList = getOwnerNameList($idList); foreach ($newOwnerList as $id => $name) { $this->ownerNameList[$fieldName][$id] = $name; } } } } } foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } } $useAsterisk = get_use_asterisk($this->user->id); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; $uitype = $field->getUIType(); $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); if (in_array($uitype, array(15, 33, 16))) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename') { $downloadtype = $db->query_result($result, $i, 'filelocationtype'); $fileName = $db->query_result($result, $i, 'filename'); $downloadType = $db->query_result($result, $i, 'filelocationtype'); $status = $db->query_result($result, $i, 'filestatus'); $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($recordId)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($fileName != '' && $status == 1) { if ($downloadType == 'I') { $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="index.php?module=Documents&action=DownloadFile&record=' . $recordId . '&fileid=' . $fileId . '"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>'; } elseif ($downloadType == 'E') { $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="' . $fileName . '" target="_blank"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>'; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($module == 'OSSTimeControl' && $fieldName == 'sum_time') { $value = Vtiger_Functions::decimalTimeFormat($value); $value = $value['short']; } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } $value = Vtiger_Functions::textLength($value); } elseif ($field->getFieldDataType() == 'picklist') { $value = Vtiger_Language_Handler::getTranslatedString($value, $module); $value = textlength_check($value); } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $fieldDataType = $field->getFieldDataType(); if ($module == 'Calendar' && ($fieldName == 'date_start' || $fieldName == 'due_date')) { if ($fieldName == 'date_start') { $timeField = 'time_start'; } else { if ($fieldName == 'due_date') { $timeField = 'time_end'; } } $timeFieldValue = $this->db->query_result($result, $i, $timeField); if (!empty($timeFieldValue)) { $value .= ' ' . $timeFieldValue; //TO make sure it takes time value as well $fieldDataType = 'datetime'; } } if ($fieldDataType == 'datetime') { $value = Vtiger_Datetime_UIType::getDateTimeValue($value); } else { if ($fieldDataType == 'date') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); } } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'time') { if (!empty($value)) { $userModel = Users_Privileges_Model::getCurrentUserModel(); if ($userModel->get('hour_format') == '12') { $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value); } } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = CurrencyField::convertToUserFormat($value, null, true); $row['currencySymbol'] = $currencySymbol; $value = CurrencyField::appendCurrencySymbol($value, $currencySymbol); } else { if (!empty($value)) { $value = CurrencyField::convertToUserFormat($value); $currencyModal = new CurrencyField($value); $currencyModal->initialize(); $value = $currencyModal->appendCurrencySymbol($value, $currencyModal->currencySymbol); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a class="urlField cursorPointer" title="' . $rawValue . '" href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a class="urlField cursorPointer" title="' . $rawValue . '" href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { $current_user = vglobal('current_user'); if ($current_user->internal_mailer == 1) { //check added for email link in user detailview $value = "<a class='emailField' onclick=\"Vtiger_Helper_Js.getInternalMailer({$recordId}," . "'{$fieldName}','{$module}');\">" . textlength_check($value) . "</a>"; } else { $value = '<a class="emailField" href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value === 'on') { $value = 1; } else { if ($value == 'off') { $value = 0; } } if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?module=Roles&parent=Settings&view=Edit&record=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { $tmpArray[] = $val; $tmp .= ', ' . $val; } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getUIType() == 11) { $outgoingCallPermission = Vtiger_Mobile_Model::checkPermissionForOutgoingCall(); if ($outgoingCallPermission && !empty($value)) { $phoneNumber = preg_replace('/[-()\\s]/', '', $value); $value = '<a class="phoneField" data-phoneNumber="' . $phoneNumber . '" record="' . $recordId . '" onclick="Vtiger_Mobile_Js.registerOutboundCall(\'' . $phoneNumber . '\', ' . $recordId . ')">' . textlength_check($value) . '</a>'; $callUsers = Vtiger_Mobile_Model::getPrivilegesUsers(); if ($callUsers) { $value .= ' <a class="btn btn-xs noLinkBtn" onclick="Vtiger_Mobile_Js.registerOutboundCallToUser(this,\'' . $phoneNumber . '\',' . $recordId . ')" data-placement="right" data-original-title="' . vtranslate('LBL_SELECT_USER_TO_CALL', $module) . '" data-content=\'<select class="select sesectedUser" name="sesectedUser">'; foreach ($callUsers as $key => $item) { $value .= '<option value="' . $key . '">' . $item . '</option>'; } $value .= '</select><br /><a class="btn btn-success popoverCallOK">' . vtranslate('LBL_BTN_CALL', $module) . '</a> <a class="btn btn-inverse popoverCallCancel">' . vtranslate('LBL_CANCEL', $module) . '</a>\' data-trigger="manual"><i class="icon-user"></i></a>'; } } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = reset($moduleList); } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a class='moduleColor_{$parentModule}' href='?module={$parentModule}&view=Detail&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif ($field->getFieldDataType() == 'taxes') { if (!empty($value)) { $valueArray = $value != "" ? explode(',', $value) : []; $tmp = ''; $tmpArray = []; $taxs = Vtiger_Taxes_UIType::getTaxes(); foreach ($valueArray as $index => $tax) { if (isset($taxs[$tax])) { $tmpArray[] = $taxs[$tax]['value'] . '% - ' . $taxs[$tax]['name']; } } $value = implode(', ', $tmpArray); $value = Vtiger_Functions::textLength($value); } } elseif ($field->getFieldDataType() == 'inventoryLimit') { if (!empty($value)) { $valueArray = $value != "" ? explode(',', $value) : []; $tmp = ''; $tmpArray = []; $limits = Vtiger_InventoryLimit_UIType::getLimits(); foreach ($valueArray as $index => $limit) { if (isset($limits[$limit])) { $tmpArray[] = $limits[$limit]['value'] . ' - ' . $limits[$limit]['name']; } } $value = implode(', ', $tmpArray); $value = Vtiger_Functions::textLength($value); } } elseif ($field->getFieldDataType() == 'multiReferenceValue') { $params = $field->getFieldParams(); $fieldModel = Vtiger_Field_Model::getInstanceFromFieldId($params['field']); $valueTmp = trim($value, '|#|'); $valueTmp = $valueTmp != "" ? explode('|#|', $valueTmp) : []; foreach ($valueTmp as $index => $tmp) { $valueTmp[$index] = $fieldModel->getUITypeModel()->getDisplayValue($tmp); } $value = implode(', ', $valueTmp); $value = Vtiger_Functions::textLength($value); } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } else { $value = Vtiger_Functions::textLength($value); } // // vtlib customization: For listview javascript triggers // $value = "$value <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=". // "'{$fieldName}' vtmodule='$module' style='display:none;'></span>"; // // END $row[$fieldName] = $value; } $data[$recordId] = $row; } return $data; }
function getSearchingListViewEntries($focus, $module, $list_result, $navigation_array, $relatedlist = '', $returnset = '', $edit_action = 'EditView', $del_action = 'Delete', $oCv = '', $page = '', $selectedfields = '', $contRelatedfields = '', $skipActions = false, $linksallowed = false) { global $log; global $mod_strings; $log->debug("Entering getSearchingListViewEntries(" . get_class($focus) . "," . $module . "," . $list_result . "," . $navigation_array . "," . $relatedlist . "," . $returnset . "," . $edit_action . "," . $del_action . "," . (is_object($oCv) ? get_class($oCv) : $oCv) . ") method ..."); $tabname = getParentTab(); global $adb, $current_user; global $app_strings; $noofrows = $adb->num_rows($list_result); $list_block = array(); global $theme; $evt_status = ''; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; //getting the vtiger_fieldtable entries from database $tabid = getTabid($module); //added for vtiger_customview 27/5 if ($oCv) { if (isset($oCv->list_fields)) { $focus->list_fields = $oCv->list_fields; } } if (is_array($selectedfields) && $selectedfields != '') { $focus->list_fields = $selectedfields; } // Remove fields which are made inactive $focus->filterInactiveFields($module); //Added to reduce the no. of queries logging for non-admin user -- by minnie-start $field_list = array(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; foreach ($focus->list_fields as $name => $tableinfo) { $fieldname = $focus->list_fields_name[$name]; if ($oCv) { if (isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; } } if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } array_push($field_list, $fieldname); } $field = array(); if ($is_admin == false) { if ($module == 'Emails') { $query = "SELECT fieldname FROM vtiger_field WHERE tabid = ? and vtiger_field.presence in (0,2)"; $params = array($tabid); } else { $profileList = getCurrentUserProfileList(); $params = array(); $query = "SELECT DISTINCT vtiger_field.fieldname\n\t\t\tFROM vtiger_field\n\t\t\tINNER JOIN vtiger_profile2field\n\t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\tINNER JOIN vtiger_def_org_field\n\t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid"; if ($module == "Calendar") { $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)"; } else { $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)"; array_push($params, $tabid); } $query .= " AND vtiger_profile2field.visible = 0\n\t\t\tAND vtiger_profile2field.visible = 0\n\t\t\tAND vtiger_def_org_field.visible = 0\n\t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\n\t\t\tAND vtiger_field.fieldname IN (" . generateQuestionMarks($field_list) . ")"; array_push($params, $profileList, $field_list); } $result = $adb->pquery($query, $params); for ($k = 0; $k < $adb->num_rows($result); $k++) { $field[] = $adb->query_result($result, $k, "fieldname"); } } //constructing the uitype and columnname array $ui_col_array = array(); $params = array(); $query = "SELECT uitype, columnname, fieldname FROM vtiger_field "; if ($module == "Calendar") { $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)"; } else { $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)"; array_push($params, $tabid); } $query .= " AND fieldname IN (" . generateQuestionMarks($field_list) . ") "; array_push($params, $field_list); $result = $adb->pquery($query, $params); $num_rows = $adb->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $tempArr = array(); $uitype = $adb->query_result($result, $i, 'uitype'); $columnname = $adb->query_result($result, $i, 'columnname'); $field_name = $adb->query_result($result, $i, 'fieldname'); $tempArr[$uitype] = $columnname; $ui_col_array[$field_name] = $tempArr; } //end if ($navigation_array['start'] != 0) { for ($i = 1; $i <= $noofrows; $i++) { $list_header = array(); //Getting the entityid if ($module != 'Users') { $entity_id = $adb->query_result($list_result, $i - 1, "crmid"); $owner_id = $adb->query_result($list_result, $i - 1, "smownerid"); } else { $entity_id = $adb->query_result($list_result, $i - 1, "id"); } foreach ($focus->list_fields as $name => $tableinfo) { $fieldname = $focus->list_fields_name[$name]; //added for vtiger_customview 27/5 if ($oCv) { if (isset($oCv->list_fields_name)) { $fieldname = $oCv->list_fields_name[$name]; if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } } else { $fieldname = $focus->list_fields_name[$name]; } } else { $fieldname = $focus->list_fields_name[$name]; if ($fieldname == 'accountname' && $module != 'Accounts') { $fieldname = 'account_id'; } if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) { $fieldname = 'contact_id'; } if ($fieldname == 'productname' && $module != 'Products') { $fieldname = 'product_id'; } } if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || in_array($fieldname, $field) || $fieldname == '' || $name == 'Close' && $module == 'Calendar') { if ($fieldname == '') { $table_name = ''; $column_name = ''; foreach ($tableinfo as $tablename => $colname) { $table_name = $tablename; $column_name = $colname; } $value = $adb->query_result($list_result, $i - 1, $colname); } else { if ($module == 'Calendar') { $act_id = $adb->query_result($list_result, $i - 1, "activityid"); $cal_sql = "select activitytype from vtiger_activity where activityid=?"; $cal_res = $adb->pquery($cal_sql, array($act_id)); if ($adb->num_rows($cal_res) >= 0) { $activitytype = $adb->query_result($cal_res, 0, "activitytype"); } } if (($module == 'Calendar' || $module == 'Emails' || $module == 'HelpDesk' || $module == 'Invoice' || $module == 'Leads' || $module == 'Contacts') && ($fieldname == 'parent_id' || $name == 'Contact Name' || $name == 'Close' || $fieldname == 'firstname')) { if ($module == 'Calendar') { if ($fieldname == 'status') { if ($activitytype == 'Task') { $fieldname = 'taskstatus'; } else { $fieldname = 'eventstatus'; } } if ($activitytype == 'Task') { if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') { $has_permission = 'yes'; } else { $has_permission = 'no'; } } else { if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') { $has_permission = 'yes'; } else { $has_permission = 'no'; } } } if ($module != 'Calendar' || $module == 'Calendar' && $has_permission == 'yes') { if ($fieldname == 'parent_id') { $value = getRelatedTo($module, $list_result, $i - 1); } if ($name == 'Contact Name') { $contact_id = $adb->query_result($list_result, $i - 1, "contactid"); $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts"); $value = ""; //Added to get the contactname for activities custom view - t=2190 if ($contact_id != '' && !empty($contact_name)) { $contact_name = getContactName($contact_id); } if ($contact_name != "" && $contact_id != 'NULL') { $value = $contact_name; } } if ($fieldname == "firstname") { $first_name = textlength_check($adb->query_result($list_result, $i - 1, "firstname")); $value = $first_name; } if ($name == 'Close') { $status = $adb->query_result($list_result, $i - 1, "status"); $activityid = $adb->query_result($list_result, $i - 1, "activityid"); if (empty($activityid)) { $activityid = $adb->query_result($list_result, $i - 1, "tmp_activity_id"); } $activitytype = $adb->query_result($list_result, $i - 1, "activitytype"); // TODO - Picking activitytype when it is not present in the Custom View. // Going forward, this column should be added to the select list if not already present as a performance improvement. if (empty($activitytype)) { $activitytypeRes = $adb->pquery('SELECT activitytype FROM vtiger_activity WHERE activityid=?', array($activityid)); if ($adb->num_rows($activitytypeRes) > 0) { $activitytype = $adb->query_result($activitytypeRes, 0, 'activitytype'); } } if ($activitytype != 'Task' && $activitytype != 'Emails') { $eventstatus = $adb->query_result($list_result, $i - 1, "eventstatus"); if (isset($eventstatus)) { $status = $eventstatus; } } if ($status == 'Deferred' || $status == 'Completed' || $status == 'Held' || $status == '') { $value = ""; } else { if ($activitytype == 'Task') { $evt_status = '&status=Completed'; } else { $evt_status = '&eventstatus=Held'; } } } } else { $value = ""; } } elseif ($module == "Documents" && ($fieldname == 'filelocationtype' || $fieldname == 'filename' || $fieldname == 'filesize' || $fieldname == 'filestatus' || $fieldname == 'filetype')) { $value = $adb->query_result($list_result, $i - 1, $fieldname); if ($fieldname == 'filelocationtype') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } if ($fieldname == 'filename') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); if ($downloadtype == 'I') { $fld_value = $value; $ext_pos = strrpos($fld_value, "."); $ext = substr($fld_value, $ext_pos + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fld_value = $value; $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $fld_value = '--'; $fileicon = ''; } } else { $fld_value = ' --'; $fileicon = ''; } $file_name = $adb->query_result($list_result, $i - 1, 'filename'); $notes_id = $adb->query_result($list_result, $i - 1, 'crmid'); $folder_id = $adb->query_result($list_result, $i - 1, 'folderid'); $download_type = $adb->query_result($list_result, $i - 1, 'filelocationtype'); $file_status = $adb->query_result($list_result, $i - 1, 'filestatus'); $fileidQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileidres = $adb->pquery($fileidQuery, array($notes_id)); $fileid = $adb->query_result($fileidres, 0, 'attachmentsid'); if ($file_name != '' && $file_status == 1) { if ($download_type == 'I') { $fld_value = "<a href='index.php?module=uploads&action=downloadfile&entityid={$notes_id}&fileid={$fileid}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$notes_id});'>" . $fld_value . "</a>"; } elseif ($download_type == 'E') { $fld_value = "<a target='_blank' href='{$file_name}' onclick='javascript:dldCntIncrease({$notes_id});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . $fld_value . "</a>"; } else { $fld_value = ' --'; } } $value = $fileicon . $fld_value; } if ($fieldname == 'filesize') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); if ($downloadtype == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } if ($fieldname == 'filestatus') { $filestatus = $value; if ($filestatus == 1) { $value = getTranslatedString('yes', $module); } elseif ($filestatus == 0) { $value = getTranslatedString('no', $module); } else { $value = ' --'; } } if ($fieldname == 'filetype') { $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype'); $filetype = $adb->query_result($list_result, $i - 1, 'filetype'); if ($downloadtype == 'E' || $downloadtype != 'I') { $value = ' --'; } else { $value = $filetype; } } if ($fieldname == 'notecontent') { $value = decode_html($value); $value = textlength_check($value); } } elseif ($module == "Products" && $name == "Related to") { $value = getRelatedTo($module, $list_result, $i - 1); } elseif ($name == 'Contact Name' && ($module == 'SalesOrder' || $module == 'Quotes' || $module == 'PurchaseOrder')) { if ($name == 'Contact Name') { $contact_id = $adb->query_result($list_result, $i - 1, "contactid"); $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts"); $value = ""; if ($contact_name != "" && $contact_id != 'NULL') { $value = $contact_name; } } } elseif ($name == 'Product') { $product_id = textlength_check($adb->query_result($list_result, $i - 1, "productname")); $value = $product_id; } elseif ($name == 'Account Name') { //modified for vtiger_customview 27/5 if ($module == 'Accounts') { $account_id = $adb->query_result($list_result, $i - 1, "crmid"); //$account_name = getAccountName($account_id); $account_name = textlength_check($adb->query_result($list_result, $i - 1, "accountname")); $value = $account_name; } elseif ($module == 'Potentials' || $module == 'Contacts' || $module == 'Invoice' || $module == 'SalesOrder' || $module == 'Quotes') { //Potential,Contacts,Invoice,SalesOrder & Quotes records sort by Account Name //$accountname = textlength_check($adb->query_result($list_result,$i-1,"accountname")); $accountid = $adb->query_result($list_result, $i - 1, "accountid"); $accountname = textlength_check(getAccountName($accountid)); $value = $accountname; } else { $account_id = $adb->query_result($list_result, $i - 1, "accountid"); $account_name = getAccountName($account_id); $acc_name = textlength_check($account_name); $value = $acc_name; } } elseif (($module == 'HelpDesk' || $module == 'PriceBook' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'Faq') && $name == 'Product Name') { if ($module == 'HelpDesk' || $module == 'Faq') { $product_id = $adb->query_result($list_result, $i - 1, "product_id"); } else { $product_id = $adb->query_result($list_result, $i - 1, "productid"); } if ($product_id != '') { $product_name = getProductName($product_id); } else { $product_name = ''; } $value = textlength_check($product_name); } elseif ($module == 'Quotes' && $name == 'Potential Name' || $module == 'SalesOrder' && $name == 'Potential Name') { $potential_id = $adb->query_result($list_result, $i - 1, "potentialid"); $potential_name = getPotentialName($potential_id); $value = textlength_check($potential_name); } elseif ($module == 'Emails' && $relatedlist != '' && ($name == 'Subject' || $name == 'Date Sent' || $name == 'To')) { $list_result_count = $i - 1; $tmp_value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid, false); $tmp_value = evvt_strip_html_links($tmp_value); $value = textlength_check($tmp_value); if ($name == 'Date Sent') { $sql = "select email_flag from vtiger_emaildetails where emailid=?"; $result = $adb->pquery($sql, array($entity_id)); $email_flag = $adb->query_result($result, 0, "email_flag"); if ($email_flag != 'SAVED') { $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid, false); $value = evvt_strip_html_links($value); } else { $value = ''; } } } elseif ($module == 'Calendar' && ($fieldname != 'taskstatus' && $fieldname != 'eventstatus')) { if ($activitytype == 'Task') { if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid, false); $value = evvt_strip_html_links($value); } else { $value = ''; } } else { if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid, false); $value = evvt_strip_html_links($value); } else { $value = ''; } } } else { $list_result_count = $i - 1; $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid, false); $value = evvt_strip_html_links($value); } } // vtlib customization: For listview javascript triggers //$value = "$value <span type='vtlib_metainfo' vtrecordid='{$entity_id}' vtfieldname='{$fieldname}' vtmodule='$module' style='display:none;'></span>"; // END if ($module == "Calendar" && $name == $app_strings['Close']) { if (isPermitted("Calendar", "EditView") == 'yes') { if (getFieldVisibilityPermission('Events', $current_user->id, 'eventstatus') == '0' || getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') { array_push($list_header, $value); } } } else { $list_header[] = $value; } } } $varreturnset = ''; $varreturnset = $returnset; $webserviceEntityId = vtyiicpng_getWSEntityId($module); $list_header[] = $webserviceEntityId . $entity_id; $list_header[] = $module; $list_block[$entity_id] = $list_header; } } $log->debug("Exiting getSearchingListViewEntries method ..."); return $list_block; }
/** * Process the request to perform relationship operations * @global Users Instance $currentUserModel * @global PearDataBase Instance $adb * @global String $currentModule * @param Vtiger_Request $request * @return boolean */ public function process(Vtiger_Request $request) { $currentUserModel = Users_Record_Model::getCurrentUserModel(); $response = new Vtiger_Response(true); $viewer = $this->getViewer($request); if ('find' == $this->getOperationArg($request)) { $this->skipConnection = true; // No need to connect to mailbox here, improves performance // Check if the message is already linked. $linkedto = MailManager_Relate_Action::associatedLink($request->get('_msguid')); // If the message was not linked, lookup for matching records, using FROM address if (empty($linkedto)) { $results = array(); $modules = array(); $allowedModules = $this->getCurrentUserMailManagerAllowedModules(); foreach (self::$MODULES as $MODULE) { if (!in_array($MODULE, $allowedModules)) { continue; } $from = $request->get('_mfrom'); if (empty($from)) { continue; } $results[$MODULE] = $this->lookupModuleRecordsWithEmail($MODULE, $from); $describe = $this->ws_describe($MODULE); $modules[$MODULE] = array('label' => $describe['label'], 'name' => textlength_check($describe['name']), 'id' => $describe['idPrefix']); // If look is found in a module, skip rest. - for performance //if (!empty($results[$MODULE])) break; } $viewer->assign('LOOKUPS', $results); $viewer->assign('MODULES', $modules); } else { $viewer->assign('LINKEDTO', $linkedto); } $viewer->assign('LINK_TO_AVAILABLE_ACTIONS', $this->linkToAvailableActions()); $viewer->assign('ALLOWED_MODULES', $allowedModules); $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('FOLDER', $request->get('_folder')); $response->setResult(array('ui' => $viewer->view('Relationship.tpl', 'MailManager', true))); } else { if ('link' == $this->getOperationArg($request)) { $linkto = $request->get('_mlinkto'); $foldername = $request->get('_folder'); $connector = $this->getConnector($foldername); // This is to handle larger uploads $memory_limit = MailManager_Config_Model::get('MEMORY_LIMIT'); ini_set('memory_limit', $memory_limit); $mail = $connector->openMail($request->get('_msgno')); $mail->attachments(); // Initialize attachments $linkedto = MailManager_Relate_Action::associate($mail, $linkto); $viewer->assign('LINK_TO_AVAILABLE_ACTIONS', $this->linkToAvailableActions()); $viewer->assign('ALLOWED_MODULES', $this->getCurrentUserMailManagerAllowedModules()); $viewer->assign('LINKEDTO', $linkedto); $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('FOLDER', $foldername); $response->setResult(array('ui' => $viewer->view('Relationship.tpl', 'MailManager', true))); } else { if ('create_wizard' == $this->getOperationArg($request)) { $moduleName = $request->get('_mlinktotype'); $parent = $request->get('_mlinkto'); $foldername = $request->get('_folder'); $connector = $this->getConnector($foldername); $mail = $connector->openMail($request->get('_msgno')); $formData = $this->processFormData($mail); foreach ($formData as $key => $value) { $request->set($key, $value); } $request->set('module', $moduleName); // Delegate QuickCreate FormUI to the target view controller of module. $quickCreateviewClassName = $moduleName . '_QuickCreateAjax_View'; if (!class_exists($quickCreateviewClassName)) { $quickCreateviewClassName = 'Vtiger_QuickCreateAjax_View'; } $quickCreateViewController = new $quickCreateviewClassName(); $quickCreateViewController->process($request); // UI already sent $response = false; } else { if ('create' == $this->getOperationArg($request)) { $linkModule = $request->get('_mlinktotype'); $parent = $request->get('_mlinkto'); $foldername = $request->get('_folder'); if (!empty($foldername)) { // This is to handle larger uploads $memory_limit = MailManager_Config_Model::get('MEMORY_LIMIT'); ini_set('memory_limit', $memory_limit); $connector = $this->getConnector($foldername); $mail = $connector->openMail($request->get('_msgno')); $attachments = $mail->attachments(); // Initialize attachments } $linkedto = MailManager_Relate_Action::getSalesEntityInfo($parent); $recordModel = Vtiger_Record_Model::getCleanInstance($linkModule); $fields = $recordModel->getModule()->getFields(); foreach ($fields as $fieldName => $fieldModel) { if ($request->has($fieldName)) { $fieldValue = $request->get($fieldName); $fieldDataType = $fieldModel->getFieldDataType(); if ($fieldDataType == 'time') { $fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue); } $recordModel->set($fieldName, $fieldValue); } } switch ($linkModule) { case 'Calendar': $activityType = $recordModel->get('activitytype'); if (!$activityType) { $activityType = 'Task'; } $recordModel->set('activitytype', $activityType); //Start Date and Time values $startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('time_start')); $startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('date_start') . " " . $startTime); list($startDate, $startTime) = explode(' ', $startDateTime); $recordModel->set('date_start', $startDate); $recordModel->set('time_start', $startTime); //End Date and Time values $endDate = Vtiger_Date_UIType::getDBInsertedValue($request->get('due_date')); if ($activityType != 'Task') { $endTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('time_end')); $endDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('due_date') . " " . $endTime); list($endDate, $endTime) = explode(' ', $endDateTime); } else { $endTime = ''; } $recordModel->set('time_end', $endTime); $recordModel->set('due_date', $endDate); if ($parent) { if ($linkedto['module'] == 'Contacts') { $recordModel->set('contact_id', $parent); } else { $recordModel->set('parent_id', $parent); } } $recordModel->set('visibility', 'Public'); break; case 'HelpDesk': $from = $mail->from(); if ($parent) { if ($linkedto['module'] == 'Contacts') { $referenceFieldName = 'contact_id'; } elseif ($linkedto['module'] == 'Accounts') { $referenceFieldName = 'parent_id'; } } $recordModel->set($referenceFieldName, $this->setParentForHelpDesk($parent, $from)); break; case 'ModComments': $recordModel->set('assigned_user_id', $currentUserModel->getId()); $recordModel->set('commentcontent', $request->getRaw('commentcontent')); $recordModel->set('userid', $currentUserModel->getId()); $recordModel->set('creator', $currentUserModel->getId()); $recordModel->set('related_to', $parent); break; } try { $recordModel->save(); // This condition is added so that emails are not created for Tickets and Todo without Parent, // as there is no way to relate them if (empty($parent) && $linkModule != 'HelpDesk' && $linkModule != 'Calendar') { $linkedto = MailManager_Relate_Action::associate($mail, $recordModel->getId()); } if ($linkModule === 'Calendar') { // Handled to save follow up event $followupMode = $request->get('followup'); //Start Date and Time values $startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('followup_time_start')); $startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('followup_date_start') . " " . $startTime); list($startDate, $startTime) = explode(' ', $startDateTime); $subject = $request->get('subject'); if ($followupMode == 'on' && $startTime != '' && $startDate != '') { $recordModel->set('eventstatus', 'Planned'); $recordModel->set('subject', '[Followup] ' . $subject); $recordModel->set('date_start', $startDate); $recordModel->set('time_start', $startTime); $currentUser = Users_Record_Model::getCurrentUserModel(); $activityType = $recordModel->get('activitytype'); if ($activityType == 'Call') { $minutes = $currentUser->get('callduration'); } else { $minutes = $currentUser->get('othereventduration'); } $dueDateTime = date('Y-m-d H:i:s', strtotime("{$startDateTime}+{$minutes} minutes")); list($startDate, $startTime) = explode(' ', $dueDateTime); $recordModel->set('due_date', $startDate); $recordModel->set('time_end', $startTime); $recordModel->set('recurringtype', ''); $recordModel->set('mode', 'create'); $recordModel->save(); } } // add attachments to the tickets as Documents if ($linkModule == 'HelpDesk' && !empty($attachments)) { $relationController = new MailManager_Relate_Action(); $relationController->__SaveAttachements($mail, $linkModule, $recordModel); } $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('LINKEDTO', $linkedto); $viewer->assign('ALLOWED_MODULES', $this->getCurrentUserMailManagerAllowedModules()); $viewer->assign('LINK_TO_AVAILABLE_ACTIONS', $this->linkToAvailableActions()); $viewer->assign('FOLDER', $foldername); $response->setResult(array('ui' => $viewer->view('Relationship.tpl', 'MailManager', true))); } catch (Exception $e) { $response->setResult(array('ui' => '', 'error' => $e)); } } else { if ('savedraft' == $this->getOperationArg($request)) { $connector = $this->getConnector('__vt_drafts'); $draftResponse = $connector->saveDraft($request); $response->setResult($draftResponse); } else { if ('saveattachment' == $this->getOperationArg($request)) { $connector = $this->getConnector('__vt_drafts'); $uploadResponse = $connector->saveAttachment($request); $response->setResult($uploadResponse); } else { if ('commentwidget' == $this->getOperationArg($request)) { $viewer->assign('LINKMODULE', $request->get('_mlinktotype')); $viewer->assign('PARENT', $request->get('_mlinkto')); $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('FOLDER', $request->get('_folder')); $viewer->view('MailManagerCommentWidget.tpl', 'MailManager'); $response = false; } } } } } } } return $response; }
/** Function to display the Products 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 Product entries */ function getPriceBookRelatedProducts($query, $focus, $returnset = '') { global $log; $log->debug("Entering getPriceBookRelatedProducts(" . $query . "," . get_class($focus) . "," . $returnset . ") method ..."); global $adb; global $app_strings; global $mod_strings; global $current_language, $current_user; $current_module_strings = return_module_language($current_language, 'PriceBook'); global $list_max_entries_per_page; global $urlPrefix; global $theme; $pricebook_id = vtlib_purify($_REQUEST['record']); $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $noofrows = $adb->query_result($adb->query(mkCountQuery($query)), 0, 'count'); $module = 'PriceBooks'; $relatedmodule = 'Products'; 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); } } $start = $_SESSION['rlvs'][$module][$relatedmodule]['start']; $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page); $start_rec = $navigation_array['start']; $end_rec = $navigation_array['end_val']; //limiting the query if ($start_rec == 0) { $limit_start_rec = 0; } else { $limit_start_rec = $start_rec - 1; } 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[] = $mod_strings['LBL_LIST_PRODUCT_NAME']; if (getFieldVisibilityPermission('Products', $current_user->id, 'productcode') == '0') { $header[] = $mod_strings['LBL_PRODUCT_CODE']; } if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') { $header[] = $mod_strings['LBL_PRODUCT_UNIT_PRICE']; } $header[] = $mod_strings['LBL_PB_LIST_PRICE']; if (isPermitted("PriceBooks", "EditView", "") == 'yes' || isPermitted("PriceBooks", "Delete", "") == 'yes') { $header[] = $mod_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)); $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, "productname")); if (getFieldVisibilityPermission('Products', $current_user->id, 'productcode') == '0') { $entries[] = $adb->query_result($list_result, $i, "productcode"); } if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') { $entries[] = $unit_price; } $entries[] = $listprice; $action = ""; if (isPermitted("PriceBooks", "EditView", "") == 'yes') { $action .= '<img style="cursor:pointer;" src="' . vtiger_imageurl('editfield.gif', $theme) . '" border="0" onClick="fnvshobj(this,\'editlistprice\'),editProductListPrice(\'' . $entity_id . '\',\'' . $pricebook_id . '\',\'' . $listprice . '\')" alt="' . $app_strings["LBL_EDIT_BUTTON"] . '" title="' . $app_strings["LBL_EDIT_BUTTON"] . '"/>'; } if (isPermitted("PriceBooks", "Delete", "") == 'yes') { if ($action != "") { $action .= ' | '; } $action .= '<img src="' . vtiger_imageurl('delete.gif', $theme) . '" 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; } if ($numRows > 0) { $module_rel = "{$module}&relmodule={$relatedmodule}&record=" . $focus->id; $navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, '', $module_rel); $return_data = array('header' => $header, 'entries' => $entries_list, 'navigation' => $navigationOutput); $log->debug("Exiting getPriceBookRelatedProducts method ..."); return $return_data; } }
function getListViewEntries($focus, $module, $result, $navigationInfo, $skipActions = false) { require 'user_privileges/user_privileges_' . $this->user->id . '.php'; global $listview_max_textlength, $theme, $default_charset, $current_user, $currentModule, $adb; $fields = $this->queryGenerator->getFields(); $whereFields = $this->queryGenerator->getWhereFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $meta->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); if ($this->queryGenerator->getReferenceFieldInfoList()) { $accessibleFieldList = array_merge($this->queryGenerator->getReferenceFieldNameList(), $accessibleFieldList); } $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $listviewcolumns = $db->getFieldsArray($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } $fldcolname = $field->getColumnName(); $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $fldcolname); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!isset($this->ownerNameList[$fieldName]) or !is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { $newOwnerList = getOwnerNameList($idList); $this->ownerNameList[$fieldName] = $this->ownerNameList[$fieldName] + $newOwnerList; } } } } foreach ($listViewFields as $fieldName) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } $idList = array(); if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $modrel = getTabModuleName($field->getTabId()); $fldcolname = 'smowner' . strtolower($modrel); $j = $rowCount * $k; $k++; for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $fldcolname); if (!isset($this->ownerNameListrel[$fieldName][$id])) { $idList[$j] = $id; $j++; } } } else { if (getTabid($currentModule) != $field->getTabId() && $field->getFieldDataType() == 'reference') { $this->fetchNameList($field, $result, 1); } } if (count($idList) > 0) { if (!isset($this->ownerNameListrel[$fieldName]) or !is_array($this->ownerNameListrel[$fieldName])) { $this->ownerNameListrel[$fieldName] = getOwnerNameList($idList); } else { $newOwnerList = getOwnerNameList($idList); $this->ownerNameListrel[$fieldName] = $this->ownerNameListrel[$fieldName] + $newOwnerList; } } } $useAsterisk = get_use_asterisk($this->user->id); $wfs = new VTWorkflowManager($adb); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); $ownerId = $db->query_result($result, $i, "smownerid"); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } $uitype = $field->getUIType(); if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $modrel = getTabModuleName($field->getTabId()); $rawValue = $this->db->query_result($result, $i, "smowner" . strtolower($modrel)); } else { if (getTabid($currentModule) != $field->getTabId()) { $modrel = getTabModuleName($field->getTabId()); $relfieldname = strtolower($modrel) . $field->getColumnName(); if (in_array($relfieldname, $listviewcolumns)) { $rawValue = $this->db->query_result($result, $i, $relfieldname); } else { $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); } } else { $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); } } if ($module == 'Calendar') { $activityType = $this->db->query_result($result, $i, 'activitytype'); } if ($uitype != 8) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename' or $fieldName == 'Documents.filename') { if ($fieldName == 'Documents.filename') { $docrs = $db->pquery('select filename,filelocationtype,filestatus,notesid from vtiger_notes where note_no=?', array($db->query_result($result, $i, 'documentsnote_no'))); $downloadtype = $db->query_result($docrs, 0, 'filelocationtype'); $fileName = $db->query_result($docrs, 0, 'filename'); $status = $db->query_result($docrs, 0, 'filestatus'); $docid = $db->query_result($docrs, 0, 'notesid'); } else { $docid = $recordId; $downloadtype = $db->query_result($result, $i, 'filelocationtype'); $fileName = $db->query_result($result, $i, 'filename'); $status = $db->query_result($result, $i, 'filestatus'); } $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($docid)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($downloadtype == 'I') { $ext = substr($value, strrpos($value, ".") + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $value = '--'; $fileicon = ''; } } else { $value = ' --'; $fileicon = ''; } if ($fileName != '' && $status == 1) { if ($downloadtype == 'I') { $value = "<a href='index.php?module=uploads&action=downloadfile&" . "entityid={$docid}&fileid={$fileId}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$docid});'>" . textlength_check($value) . "</a>"; } elseif ($downloadtype == 'E') { $value = "<a target='_blank' href='{$fileName}' onclick='javascript:" . "dldCntIncrease({$docid});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . textlength_check($value) . "</a>"; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } elseif ($field->getFieldDataType() == 'picklist') { if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName])) { $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; } else { $value = getTranslatedString($value, $module); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); if ($field->getFieldDataType() == 'datetime') { $value .= ' ' . $date->getDisplayTime(); } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = number_format($value, 2, '.', ''); $currencyValue = CurrencyField::convertToUserFormat($value, null, true); $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol); } else { //changes made to remove vtiger_currency symbol in front of each potential amount if ($value != 0) { $value = CurrencyField::convertToUserFormat($value); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { if ($_SESSION['internal_mailer'] == 1) { //check added for email link in user detailview $fieldId = $field->getFieldId(); $value = "<a href=\"javascript:InternalMailer({$recordId},{$fieldId}," . "'{$fieldName}','{$module}','record_id');\">" . textlength_check($value) . "</a>"; } else { $value = '<a href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=' . 'Settings&roleid=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getUIType() == 69) { if ($module == 'Products') { $queryPrdt = 'SELECT vtiger_attachments.path,vtiger_attachments.attachmentsid,vtiger_attachments.`name` FROM vtiger_attachments INNER JOIN vtiger_seattachmentsrel ON vtiger_attachments.attachmentsid = vtiger_seattachmentsrel.attachmentsid INNER JOIN vtiger_products ON vtiger_seattachmentsrel.crmid = vtiger_products.productid where vtiger_seattachmentsrel.crmid=?'; $resultprdt = $this->db->pquery($queryPrdt, array($recordId)); if ($resultprdt and $this->db->num_rows($resultprdt) > 0) { $imgpath = $this->db->query_result($resultprdt, 0, 'path'); $attid = $this->db->query_result($resultprdt, 0, 'attachmentsid'); $imgfilename = $this->db->query_result($resultprdt, 0, 'name'); $value = "<div style='text-align:center;width:100%;'><img src='./" . $imgpath . $attid . '_' . $imgfilename . "' height='50'></div>"; } else { $value = ''; } } else { if ($module == 'Contacts') { $imageattachment = 'Image'; } else { $imageattachment = 'Attachment'; } //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t\t\t\t from vtiger_attachments\n\t\t\t\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t\t\t\t and vtiger_attachments.name = ?\n\t\t\t\t\t\t and vtiger_seattachmentsrel.crmid=?"; $image_res = $this->db->pquery($sql, array(str_replace(' ', '_', $value), $recordId)); $image_id = $this->db->query_result($image_res, 0, 'attachmentsid'); $image_path = $this->db->query_result($image_res, 0, 'path'); $image_name = urlencode(decode_html($this->db->query_result($image_res, 0, 'name'))); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { $ftype = $this->db->query_result($image_res, 0, 'type'); $isimage = stripos($ftype, 'image') !== false; if ($isimage) { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image'); $value = '<div style="width:100%;text-align:center;"><img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 50px;"></div>'; } else { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents'); $value = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>'; } } else { $value = ''; } } } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim(decode_html($val)), $this->picklistValueMap[$fieldName])) { $tmpArray[] = $notaccess; $tmp .= ', ' . $notaccess; } else { $tmpArray[] = $val; $tmp .= ', ' . $val; } } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getUIType() == 1024) { $content = array(); if ($value != '') { $arr_evo_actions = explode(' |##| ', $value); for ($fvalues = 0; $fvalues < sizeof($arr_evo_actions); $fvalues++) { $roleid = $arr_evo_actions[$fvalues]; $rolename = getRoleName($roleid); $content[$fvalues] = $rolename; } } $value = textlength_check(implode(', ', $content)); } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getFieldDataType() == 'phone') { if ($useAsterisk == 'true') { $value = "<a href='javascript:;' onclick='startCall("{$value}", " . ""{$recordId}")'>" . textlength_check($value) . "</a>"; } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); if (getTabid($currentModule) != $field->getTabId()) { $modrel = getTabModuleName($field->getTabId()); $fieldName = str_replace($modrel . '.', "", $fieldName); } $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = $moduleList[0]; } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a href='index.php?module={$parentModule}&action=DetailView&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; $modMetaInfo = getEntityFieldNames($parentModule); $fieldName = is_array($modMetaInfo['fieldname']) ? $modMetaInfo['fieldname'][0] : $modMetaInfo['fieldname']; // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$rawValue}' vtfieldname=" . "'{$fieldName}' vtmodule='{$parentModule}' style='display:none;'></span>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $value = textlength_check($this->ownerNameListrel[$fieldName][$value]); } else { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } elseif ($field->getUIType() == 55) { $value = getTranslatedString($value, $currentModule); } elseif ($module == 'Emails' && $fieldName == 'subject') { $value = '<a href="javascript:;" onClick="ShowEmail(\'' . $recordId . '\');">' . textlength_check($value) . '</a>'; } else { $value = textlength_check($value); } if ($field->getFieldDataType() != 'reference') { $parenttab = getParentTab(); $nameFields = $this->queryGenerator->getModuleNameFields($module); $nameFieldList = explode(',', $nameFields); if (($fieldName == $focus->list_link_field or in_array($fieldName, $nameFieldList)) && $module != 'Emails') { $opennewtab = GlobalVariable::getVariable('Application_OpenRecordInNewXOnListView', '', $module); if ($opennewtab == '') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } elseif ($opennewtab == 'window') { $value = "<a href='#' onclick='window.open(\"index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}\", \"{$module}-{$entity_id}\", \"width=1300, height=900, scrollbars=yes\"); return false;' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } else { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "' target='_blank'>{$value}</a>"; } } // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=" . "'{$fieldName}' vtmodule='{$module}' style='display:none;'></span>"; } $row[] = $value; } //Added for Actions ie., edit and delete links in listview $actionLinkInfo = ""; if (isPermitted($module, "EditView", "") == 'yes') { $racbr = $wfs->getRACRuleForRecord($currentModule, $recordId); if (!$racbr or $racbr->hasListViewPermissionTo('edit')) { $edit_link = $this->getListViewEditLink($module, $recordId); if (isset($navigationInfo['start']) && $navigationInfo['start'] > 1 && $module != 'Emails') { $actionLinkInfo .= "<a href=\"{$edit_link}&start=" . $navigationInfo['start'] . "\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } else { $actionLinkInfo .= "<a href=\"{$edit_link}\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } } } if (isPermitted($module, "Delete", "") == 'yes') { $racbr = $wfs->getRACRuleForRecord($currentModule, $recordId); if (!$racbr or $racbr->hasListViewPermissionTo('delete')) { $del_link = $this->getListViewDeleteLink($module, $recordId); if ($actionLinkInfo != "" && $del_link != "") { $actionLinkInfo .= ' | '; } if ($del_link != "") { $actionLinkInfo .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . getTranslatedString('LNK_DELETE', $module) . '</a>'; } } } // Record Change Notification if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) { if (!$focus->isViewed($recordId)) { $actionLinkInfo .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>"; } } // END if ($actionLinkInfo != "" && !$skipActions) { $row[] = $actionLinkInfo; } list($row, $unused, $unused2) = cbEventHandler::do_filter('corebos.filter.listview.render', array($row, $this->db->query_result_rowdata($result, $i), $recordId)); $data[$recordId] = $row; } return $data; }
function getListViewRecords($focus, $module, $result) { global $listview_max_textlength, $theme, $default_charset; require 'user_privileges/user_privileges_' . $this->user->id . '.php'; $fields = $this->queryGenerator->getFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $meta->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $field->getColumnName()); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { //array_merge API loses key information so need to merge the arrays // manually. $newOwnerList = getOwnerNameList($idList); foreach ($newOwnerList as $id => $name) { $this->ownerNameList[$fieldName][$id] = $name; } } } } } foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } } $useAsterisk = get_use_asterisk($this->user->id); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; $uitype = $field->getUIType(); $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); if ($uitype != 8) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename') { $downloadtype = $db->query_result($result, $i, 'filelocationtype'); $fileName = $db->query_result($result, $i, 'filename'); $downloadType = $db->query_result($result, $i, 'filelocationtype'); $status = $db->query_result($result, $i, 'filestatus'); $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($recordId)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($fileName != '' && $status == 1) { if ($downloadType == 'I') { $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="index.php?module=Documents&action=DownloadFile&record=' . $recordId . '&fileid=' . $fileId . '"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>'; } elseif ($downloadType == 'E') { $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="' . $fileName . '" target="_blank"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>'; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } elseif ($field->getFieldDataType() == 'picklist') { //not check for permissions for non admin users for status and activity type field if ($module == 'Calendar' && ($fieldName == 'taskstatus' || $fieldName == 'eventstatus' || $fieldName == 'activitytype')) { $value = Vtiger_Language_Handler::getTranslatedString($value, $module); $value = textlength_check($value); } else { if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName]) && strtolower($value) != '--none--' && strtolower($value) != 'none') { $value = "<font color='red'>" . Vtiger_Language_Handler::getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; } else { $value = Vtiger_Language_Handler::getTranslatedString($value, $module); $value = textlength_check($value); } } } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $fieldDataType = $field->getFieldDataType(); if ($module == 'Calendar' && ($fieldName == 'date_start' || $fieldName == 'due_date')) { if ($fieldName == 'date_start') { $timeField = 'time_start'; } else { if ($fieldName == 'due_date') { $timeField = 'time_end'; } } $timeFieldValue = $this->db->query_result($result, $i, $timeField); if (!empty($timeFieldValue)) { $value .= ' ' . $timeFieldValue; //TO make sure it takes time value as well $fieldDataType = 'datetime'; } } if ($fieldDataType == 'datetime') { $value = Vtiger_Datetime_UIType::getDateTimeValue($value); } else { if ($fieldDataType == 'date') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); } } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'time') { if (!empty($value)) { $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value); } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = CurrencyField::convertToUserFormat($value, null, true); $row['currencySymbol'] = $currencySymbol; // $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol); } else { if (!empty($value)) { $value = CurrencyField::convertToUserFormat($value); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a class="urlField cursorPointer" href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a class="urlField cursorPointer" href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { global $current_user; if ($current_user->internal_mailer == 1) { //check added for email link in user detailview $value = "<a class='emailField' onclick=\"Vtiger_Helper_Js.getInternalMailer({$recordId}," . "'{$fieldName}');\">" . textlength_check($value) . "</a>"; } else { $value = '<a class="emailField" href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value === 'on') { $value = 1; } else { if ($value == 'off') { $value = 0; } } if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?module=Roles&parent=Settings&view=Edit&record=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim($val), $this->picklistValueMap[$fieldName])) { $tmpArray[] = $notaccess; $tmp .= ', ' . $notaccess; } else { $tmpArray[] = $val; $tmp .= ', ' . $val; } } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getFieldDataType() == 'phone') { if ($useAsterisk == 'true') { $value = "<a href='javascript:;' onclick='startCall("{$value}", " . ""{$recordId}")'>" . textlength_check($value) . "</a>"; } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = $moduleList[0]; } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a href='?module={$parentModule}&view=Detail&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } else { $value = textlength_check($value); } // // vtlib customization: For listview javascript triggers // $value = "$value <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=". // "'{$fieldName}' vtmodule='$module' style='display:none;'></span>"; // // END $row[$fieldName] = $value; } $data[$recordId] = $row; } return $data; }
$idListEndIndex = $count < $recordIndex + $displayRecordCount ? $count + 1 : $recordIndex + $displayRecordCount + 1; $idListStartIndex = $recordIndex - $displayRecordCount; if ($idListStartIndex < 0) { $idListStartIndex = 0; } $idsArray = array_slice($recordList, $idListStartIndex, $idListEndIndex - $idListStartIndex); $selectColString = implode(',', $permittedFieldNameList) . ', ' . $id_array[$sModule]; $fieldQuery = "SELECT {$selectColString} from " . $tables_array[$sModule] . " WHERE " . $id_array[$sModule] . " IN (" . generateQuestionMarks($idsArray) . ")"; $fieldResult = $adb->pquery($fieldQuery, $idsArray); $numOfRows = $adb->num_rows($fieldResult); $recordNameMapping = array(); for ($i = 0; $i < $numOfRows; ++$i) { $recordId = $adb->query_result($fieldResult, $i, $id_array[$sModule]); $fieldValue = ''; foreach ($permittedFieldNameList as $fieldName) { $fieldValue .= " " . $adb->query_result($fieldResult, $i, $fieldName); } $fieldValue = textlength_check($fieldValue); $recordNameMapping[$recordId] = $fieldValue; } foreach ($idsArray as $id) { if ($id === $iCurRecord) { $output .= '<tr><td style="text-align:left;font-weight:bold;">' . $recordNameMapping[$id] . '</td></tr>'; } else { $output .= '<tr><td style="text-align:left;"><a href="index.php?module=' . $sModule . '&action=DetailView&parenttab=' . vtlib_purify($_REQUEST['CurParentTab']) . '&record=' . $id . '&start=' . $recordPageMapping[$id] . '">' . $recordNameMapping[$id] . '</a></td></tr>'; } } } $output .= '</table>'; $output .= '</div></td></tr></table></td></tr></table>'; echo $output;
/** * Process the request to perform relationship operations * @global Users Instance $current_user * @global PearDataBase Instance $adb * @global String $currentModule * @param MailManager_Request $request * @return boolean */ function process(MailManager_Request $request) { global $current_user, $adb; $response = new MailManager_Response(true); $viewer = $this->getViewer(); if ('find' == $request->getOperationArg()) { $this->skipConnection = true; // No need to connect to mailbox here, improves performance // Check if the message is already linked. //$linkedto = MailManager_RelationControllerAction::associatedLink($request->get('_msguid')); // If the message was not linked, lookup for matching records, using FROM address //if (empty($linkedto)) { $msguid = $request->get('_msguid'); $results = array(); $modules = array(); $allowedModules = $this->getCurrentUserMailManagerAllowedModules(); foreach (self::$MODULES as $MODULE) { if (!in_array($MODULE, $allowedModules)) { continue; } $from = $request->get('_mfrom'); if (empty($from)) { continue; } $results[$MODULE] = $this->lookupModuleRecordsWithEmail($MODULE, $from, $msguid); $describe = $this->ws_describe($MODULE); $modules[$MODULE] = array('label' => $describe['label'], 'name' => textlength_check($describe['name']), 'id' => $describe['idPrefix']); // If look is found in a module, skip rest. - for performance //if (!empty($results[$MODULE])) break; } $viewer->assign('LOOKUPS', $results); $viewer->assign('MODULES', $modules); //} else { // $viewer->assign('LINKEDTO', $linkedto); //} $viewer->assign('LinkToAvailableActions', $this->linkToAvailableActions()); $viewer->assign('AllowedModules', $allowedModules); $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('FOLDER', $request->get('_folder')); $response->setResult(array('ui' => $viewer->fetch($this->getModuleTpl('Relationship.tpl')))); } else { if ('link' == $request->getOperationArg()) { $linkto = $request->get('_mlinkto'); $foldername = $request->get('_folder'); $connector = $this->getConnector($foldername); // This is to handle larger uploads $memory_limit = ConfigPrefs::get('MEMORY_LIMIT'); ini_set('memory_limit', $memory_limit); $mail = $connector->openMail($request->get('_msgno')); $mail->attachments(); // Initialize attachments $linkedto = MailManager_RelationControllerAction::associate($mail, $linkto); $viewer->assign('LinkToAvailableActions', $this->linkToAvailableActions()); $viewer->assign('AllowedModules', $this->getCurrentUserMailManagerAllowedModules()); $viewer->assign('LINKEDTO', $linkedto); $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('FOLDER', $foldername); $response->setResult(array('ui' => $viewer->fetch($this->getModuleTpl('Relationship.tpl')))); } else { if ('create_wizard' == $request->getOperationArg()) { global $currentModule; $moduleName = $request->get('_mlinktotype'); $parent = $request->get('_mlinkto'); $foldername = $request->get('_folder'); $connector = $this->getConnector($foldername); $mail = $connector->openMail($request->get('_msgno')); $qcreate_array = QuickCreate($moduleName); $validationData = $qcreate_array['data']; $data = split_validationdataArray($validationData); $qcreate_array['form'] = $this->processFormData($qcreate_array['form'], $mail); $viewer->assign("QUICKCREATE", $qcreate_array['form']); if ($moduleName == 'Calendar') { $viewer->assign("QCMODULE", getTranslatedString('Todo', 'Calendar')); } elseif ($moduleName == "HelpDesk") { $viewer->assign("QCMODULE", getTranslatedString('Ticket', 'HelpDesk')); } else { $viewer->assign("QCMODULE", getTranslatedString("SINGLE_" . $moduleName, $moduleName)); } $viewer->assign("PARENT", $parent); $viewer->assign("MODULE", $moduleName); $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('FOLDER', $foldername); $viewer->assign("VALIDATION_DATA_FIELDNAME", $data['fieldname']); $viewer->assign("VALIDATION_DATA_FIELDDATATYPE", $data['datatype']); $viewer->assign("VALIDATION_DATA_FIELDLABEL", $data['fieldlabel']); $viewer->display($this->getModuleTpl('Relationship.CreateWizard.tpl')); $response = false; } else { if ('create' == $request->getOperationArg()) { $linkModule = $request->get('_mlinktotype'); $parent = $request->get('_mlinkto'); $focus = CRMEntity::getInstance($linkModule); // This is added as ModComments module has a bug that will not initialize column_fields // Basically $currentModule is set to MailManager, so the fields are not set properly. if (empty($focus->column_fields)) { $focus->column_fields = getColumnFields($linkModule); } setObjectValuesFromRequest($focus); if ($request->get('assigntype') == 'U') { $focus->column_fields['assigned_user_id'] = $request->get('assigned_user_id'); } elseif ($request->get('assigntype') == 'T') { $focus->column_fields['assigned_user_id'] = $request->get('assigned_group_id'); } $foldername = $request->get('_folder'); if (!empty($foldername)) { // This is to handle larger uploads $memory_limit = ConfigPrefs::get('MEMORY_LIMIT'); ini_set('memory_limit', $memory_limit); $connector = $this->getConnector($foldername); $mail = $connector->openMail($request->get('_msgno')); $attachments = $mail->attachments(); // Initialize attachments } $linkedto = MailManager_RelationControllerAction::getSalesEntityInfo($parent); switch ($linkModule) { case 'Calendar': if (empty($focus->column_fields['activitytype'])) { $focus->column_fields['activitytype'] = 'Task'; } if (empty($focus->column_fields['due_date'])) { if (!empty($focus->column_fields['date_start'])) { $dateStart = getValidDBInsertDateValue($focus->column_fields['date_start']); $focus->column_fields['due_date'] = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dateStart)) . " +1 day")); } else { $focus->column_fields['due_date'] = date('Y-m-d', strtotime("+1 day")); } } if (!empty($parent)) { if ($linkedto['module'] == 'Contacts') { $focus->column_fields['contact_id'] = $parent; } else { $focus->column_fields['parent_id'] = $parent; } } break; case 'HelpDesk': $from = $mail->from(); $focus->column_fields['parent_id'] = $this->setParentForHelpDesk($parent, $from); break; case 'ModComments': $focus->column_fields['assigned_user_id'] = $current_user->id; $focus->column_fields['creator'] = $current_user->id; $focus->column_fields['related_to'] = $parent; break; } try { $focus->save($linkModule); // This condition is added so that emails are not created for Todo without Parent, // as there is no way to relate them if (empty($parent) && $linkModule != 'Calendar') { $linkedto = MailManager_RelationControllerAction::associate($mail, $focus->id); } // add attachments to the tickets as Documents if (in_array($linkModule, array('HelpDesk', 'Potentials', 'Project', 'ProjectTask')) && !empty($attachments)) { $relationController = new MailManager_RelationControllerAction(); $relationController->__SaveAttachements($mail, $linkModule, $focus); } $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('LINKEDTO', $linkedto); $viewer->assign('AllowedModules', $this->getCurrentUserMailManagerAllowedModules()); $viewer->assign('LinkToAvailableActions', $this->linkToAvailableActions()); $viewer->assign('FOLDER', $foldername); $response->setResult(array('ui' => $viewer->fetch($this->getModuleTpl('Relationship.tpl')))); } catch (Exception $e) { $response->setResult(array('ui' => '', 'error' => $e)); } } else { if ('savedraft' == $request->getOperationArg()) { $connector = $this->getConnector('__vt_drafts'); $draftResponse = $connector->saveDraft($request); $response->setResult($draftResponse); } else { if ('saveattachment' == $request->getOperationArg()) { $connector = $this->getConnector('__vt_drafts'); $uploadResponse = $connector->saveAttachment($request); $response->setResult($uploadResponse); } else { if ('commentwidget' == $request->getOperationArg()) { $viewer->assign('LINKMODULE', $request->get('_mlinktotype')); $viewer->assign('PARENT', $request->get('_mlinkto')); $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('FOLDER', $request->get('_folder')); $viewer->display($this->getModuleTpl('MailManager.CommentWidget.tpl')); $response = false; } } } } } } } return $response; }
function getRelatedTo($module, $list_result, $rset) { global $adb, $log, $app_strings; $tabname = getParentTab(); if ($module == "Documents") { $notesid = $adb->query_result($list_result, $rset, "notesid"); $action = "DetailView"; $evt_query = "SELECT vtiger_senotesrel.crmid, vtiger_crmentity.setype\n\t\t\t\t\tFROM vtiger_senotesrel\n\t\t\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\t\tON vtiger_senotesrel.crmid = vtiger_crmentity.crmid\n\t\t\t\tWHERE vtiger_senotesrel.notesid = ?"; $params = array($notesid); } else { if ($module == "Products") { $productid = $adb->query_result($list_result, $rset, "productid"); $action = "DetailView"; $evt_query = "SELECT vtiger_seproductsrel.crmid, vtiger_crmentity.setype\n\t\t\t\t\tFROM vtiger_seproductsrel\n\t\t\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\t\tON vtiger_seproductsrel.crmid = vtiger_crmentity.crmid\n\t\t\t\t\tWHERE vtiger_seproductsrel.productid =?"; $params = array($productid); } else { $activity_id = $adb->query_result($list_result, $rset, "activityid"); $action = "DetailView"; $evt_query = "SELECT vtiger_seactivityrel.crmid, vtiger_crmentity.setype\n\t\t\tFROM vtiger_seactivityrel\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_seactivityrel.crmid = vtiger_crmentity.crmid\n\t\t\tWHERE vtiger_seactivityrel.activityid=?"; $params = array($activity_id); if ($module == 'HelpDesk') { $activity_id = $adb->query_result($list_result, $rset, "parent_id"); if ($activity_id != '') { $evt_query = "SELECT crmid, setype FROM vtiger_crmentity WHERE crmid=?"; $params = array($activity_id); } } } } //added by raju to change the related to in emails inot multiple if email is for more than one contact $evt_result = $adb->pquery($evt_query, $params); $numrows = $adb->num_rows($evt_result); $parent_module = $adb->query_result($evt_result, 0, 'setype'); $parent_id = $adb->query_result($evt_result, 0, 'crmid'); if ($numrows > 1) { $parent_module = 'Multiple'; $parent_name = $app_strings['LBL_MULTIPLE']; } //Raju -- Ends if ($module == 'HelpDesk' && ($parent_module == 'Accounts' || $parent_module == 'Contacts')) { global $theme; $module_icon = '<img src="themes/images/' . $parent_module . '.gif" alt="' . $app_strings[$parent_module] . '" title="' . $app_strings[$parent_module] . '" border=0 align=center> '; } $action = "DetailView"; if ($parent_module == 'Accounts') { $parent_query = "SELECT accountname FROM vtiger_account WHERE accountid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = textlength_check($adb->query_result($parent_result, 0, "accountname")); } if ($parent_module == 'Leads') { $parent_query = "SELECT firstname,lastname FROM vtiger_leaddetails WHERE leadid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = getFullNameFromQResult($parent_result, 0, "Leads"); } if ($parent_module == 'Potentials') { $parent_query = "SELECT potentialname FROM vtiger_potential WHERE potentialid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = textlength_check($adb->query_result($parent_result, 0, "potentialname")); } if ($parent_module == 'Products') { $parent_query = "SELECT productname FROM vtiger_products WHERE productid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = $adb->query_result($parent_result, 0, "productname"); } if ($parent_module == 'Quotes') { $parent_query = "SELECT subject FROM vtiger_quotes WHERE quoteid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = $adb->query_result($parent_result, 0, "subject"); } if ($parent_module == 'PurchaseOrder') { $parent_query = "SELECT subject FROM vtiger_purchaseorder WHERE purchaseorderid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = $adb->query_result($parent_result, 0, "subject"); } if ($parent_module == 'Invoice') { $parent_query = "SELECT subject FROM vtiger_invoice WHERE invoiceid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = $adb->query_result($parent_result, 0, "subject"); } if ($parent_module == 'SalesOrder') { $parent_query = "SELECT subject FROM vtiger_salesorder WHERE salesorderid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = $adb->query_result($parent_result, 0, "subject"); } if ($parent_module == 'Contacts' && ($module == 'Emails' || $module == 'HelpDesk')) { $parent_query = "SELECT firstname,lastname FROM vtiger_contactdetails WHERE contactid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = getFullNameFromQResult($parent_result, 0, "Contacts"); } if ($parent_module == 'Vendors' && $module == 'Emails') { $parent_query = "SELECT vendorname FROM vtiger_vendor WHERE vendorid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = $adb->query_result($parent_result, 0, "vendorname"); } if ($parent_module == 'HelpDesk') { $parent_query = "SELECT title FROM vtiger_troubletickets WHERE ticketid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = $adb->query_result($parent_result, 0, "title"); //if(strlen($parent_name) > 25) //{ $parent_name = textlength_check($parent_name); //} } if ($parent_module == 'Campaigns') { $parent_query = "SELECT campaignname FROM vtiger_campaign WHERE campaignid=?"; $parent_result = $adb->pquery($parent_query, array($parent_id)); $parent_name = $adb->query_result($parent_result, 0, "campaignname"); //if(strlen($parent_name) > 25) //{ $parent_name = textlength_check($parent_name); //} } //added by rdhital for better emails - Raju if ($parent_module == 'Multiple') { $parent_value = $parent_name; } else { $parent_value = $module_icon . "<a href='index.php?module=" . $parent_module . "&action=" . $action . "&record=" . $parent_id . "&parenttab=" . $tabname . "'>" . textlength_check($parent_name) . "</a>"; } //code added by raju ends $log->debug("Exiting getRelatedTo method ..."); return $parent_value; }
/** * Function to get the Full Name of a Contact/Lead when a query result and the row count are given * Takes the input as $result - Query Result, $row_count - Count of the Row, $module - module name * returns the Contact Name in string format. */ function getFullNameFromQResult($result, $row_count, $module) { global $log, $adb, $current_user; $log->info("In getFullNameFromQResult(" . print_r($result, true) . " - " . $row_count . "-" . $module . ") method ..."); $rowdata = $adb->query_result_rowdata($result, $row_count); $entity_field_info = getEntityFieldNames($module); $fieldsName = $entity_field_info['fieldname']; $name = ''; if ($rowdata != '' && count($rowdata) > 0) { $name = getEntityFieldNameDisplay($module, $fieldsName, $rowdata); } $name = textlength_check($name); return $name; }
/** 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; }
/** * Process the request to perform relationship operations * @global Users Instance $current_user * @global PearDataBase Instance $adb * @global String $currentModule * @param Vtiger_Request $request * @return boolean */ function process(Vtiger_Request $request) { global $current_user, $adb; $response = new Vtiger_Response(true); $viewer = $this->getViewer($request); if ('find' == $this->getOperationArg($request)) { $this->skipConnection = true; // No need to connect to mailbox here, improves performance // Check if the message is already linked. $linkedto = MailManager_Relate_Action::associatedLink($request->get('_msguid')); // If the message was not linked, lookup for matching records, using FROM address if (empty($linkedto)) { $results = array(); $modules = array(); $allowedModules = $this->getCurrentUserMailManagerAllowedModules(); foreach (self::$MODULES as $MODULE) { if (!in_array($MODULE, $allowedModules)) { continue; } $from = $request->get('_mfrom'); if (empty($from)) { continue; } $results[$MODULE] = $this->lookupModuleRecordsWithEmail($MODULE, $from); $describe = $this->ws_describe($MODULE); $modules[$MODULE] = array('label' => $describe['label'], 'name' => textlength_check($describe['name']), 'id' => $describe['idPrefix']); // If look is found in a module, skip rest. - for performance //if (!empty($results[$MODULE])) break; } $viewer->assign('LOOKUPS', $results); $viewer->assign('MODULES', $modules); } else { $viewer->assign('LINKEDTO', $linkedto); } $viewer->assign('LinkToAvailableActions', $this->linkToAvailableActions()); $viewer->assign('AllowedModules', $allowedModules); $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('FOLDER', $request->get('_folder')); $response->setResult(array('ui' => $viewer->view('Relationship.tpl', 'MailManager', true))); } else { if ('link' == $this->getOperationArg($request)) { $linkto = $request->get('_mlinkto'); $foldername = $request->get('_folder'); $connector = $this->getConnector($foldername); // This is to handle larger uploads $memory_limit = MailManager_Config::get('MEMORY_LIMIT'); ini_set('memory_limit', $memory_limit); $mail = $connector->openMail($request->get('_msgno')); $mail->attachments(); // Initialize attachments $linkedto = MailManager_Relate_Action::associate($mail, $linkto); $viewer->assign('LinkToAvailableActions', $this->linkToAvailableActions()); $viewer->assign('AllowedModules', $this->getCurrentUserMailManagerAllowedModules()); $viewer->assign('LINKEDTO', $linkedto); $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('FOLDER', $foldername); $response->setResult(array('ui' => $viewer->view('Relationship.tpl', 'MailManager', true))); } else { if ('create_wizard' == $this->getOperationArg($request)) { global $currentModule; $moduleName = $request->get('_mlinktotype'); $parent = $request->get('_mlinkto'); $foldername = $request->get('_folder'); $connector = $this->getConnector($foldername); $mail = $connector->openMail($request->get('_msgno')); $formData = $this->processFormData($mail); foreach ($formData as $key => $value) { $request->set($key, $value); } $request->set('module', $moduleName); // Delegate QuickCreate FormUI to the target view controller of module. $quickCreateviewClassName = $moduleName . '_QuickCreateAjax_View'; if (!class_exists($quickCreateviewClassName)) { $quickCreateviewClassName = 'Vtiger_QuickCreateAjax_View'; } $quickCreateViewController = new $quickCreateviewClassName(); $quickCreateViewController->process($request); // UI already sent $response = false; } else { if ('create' == $this->getOperationArg($request)) { $linkModule = $request->get('_mlinktotype'); $parent = $request->get('_mlinkto'); $focus = CRMEntity::getInstance($linkModule); // This is added as ModComments module has a bug that will not initialize column_fields // Basically $currentModule is set to MailManager, so the fields are not set properly. if (empty($focus->column_fields)) { $focus->column_fields = getColumnFields($linkModule); } foreach ($focus->column_fields as $fieldname => $val) { if ($request->has($fieldname)) { $focus->column_fields[$fieldname] = $request->get($fieldname); } } $foldername = $request->get('_folder'); if (!empty($foldername)) { // This is to handle larger uploads $memory_limit = MailManager_Config::get('MEMORY_LIMIT'); ini_set('memory_limit', $memory_limit); $connector = $this->getConnector($foldername); $mail = $connector->openMail($request->get('_msgno')); $attachments = $mail->attachments(); // Initialize attachments } $linkedto = MailManager_Relate_Action::getSalesEntityInfo($parent); switch ($linkModule) { case 'Calendar': if (empty($focus->column_fields['activitytype'])) { $focus->column_fields['activitytype'] = 'Task'; } if (empty($focus->column_fields['due_date'])) { if (!empty($focus->column_fields['date_start'])) { $dateStart = getValidDBInsertDateValue($focus->column_fields['date_start']); $focus->column_fields['due_date'] = date("Y-m-d", strtotime(date("Y-m-d", strtotime($dateStart)) . " +1 day")); } else { $focus->column_fields['due_date'] = date('Y-m-d', strtotime("+1 day")); } } if (!empty($parent)) { if ($linkedto['module'] == 'Contacts') { $focus->column_fields['contact_id'] = $parent; } else { $focus->column_fields['parent_id'] = $parent; } } break; case 'HelpDesk': $from = $mail->from(); $focus->column_fields['parent_id'] = $this->setParentForHelpDesk($parent, $from); break; case 'ModComments': $focus->column_fields['assigned_user_id'] = $current_user->id; $focus->column_fields['creator'] = $current_user->id; $focus->column_fields['related_to'] = $parent; break; } try { $focus->save($linkModule); // This condition is added so that emails are not created for Tickets and Todo without Parent, // as there is no way to relate them if (empty($parent) && $linkModule != 'HelpDesk' && $linkModule != 'Calendar') { $linkedto = MailManager_Relate_Action::associate($mail, $focus->id); } // add attachments to the tickets as Documents if ($linkModule == 'HelpDesk' && !empty($attachments)) { $relationController = new MailManager_Relate_Action(); $relationController->__SaveAttachements($mail, $linkModule, $focus); } $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('LINKEDTO', $linkedto); $viewer->assign('AllowedModules', $this->getCurrentUserMailManagerAllowedModules()); $viewer->assign('LinkToAvailableActions', $this->linkToAvailableActions()); $viewer->assign('FOLDER', $foldername); $response->setResult(array('ui' => $viewer->view('Relationship.tpl', 'MailManager', true))); } catch (Exception $e) { $response->setResult(array('ui' => '', 'error' => $e)); } } else { if ('savedraft' == $this->getOperationArg($request)) { $connector = $this->getConnector('__vt_drafts'); $draftResponse = $connector->saveDraft($request); $response->setResult($draftResponse); } else { if ('saveattachment' == $this->getOperationArg($request)) { $connector = $this->getConnector('__vt_drafts'); $uploadResponse = $connector->saveAttachment($request); $response->setResult($uploadResponse); } else { if ('commentwidget' == $this->getOperationArg($request)) { $viewer->assign('LINKMODULE', $request->get('_mlinktotype')); $viewer->assign('PARENT', $request->get('_mlinkto')); $viewer->assign('MSGNO', $request->get('_msgno')); $viewer->assign('FOLDER', $request->get('_folder')); $viewer->view('MailManagerCommentWidget.tpl', 'MailManager'); $response = false; } } } } } } } return $response; }