function getRequestedToData() { $mail_data = array(); $mail_data['user_id'] = $_REQUEST["task_assigned_user_id"]; $mail_data['subject'] = $_REQUEST['task_subject']; $mail_data['status'] = $_REQUEST['activity_mode'] == 'Task' ? $_REQUEST['taskstatus'] : $_REQUEST['eventstatus']; $mail_data['activity_mode'] = $_REQUEST['activity_mode']; $mail_data['taskpriority'] = $_REQUEST['taskpriority']; $mail_data['relatedto'] = $_REQUEST['task_parent_name']; $mail_data['contact_name'] = $_REQUEST['task_contact_name']; $mail_data['description'] = $_REQUEST['task_description']; $mail_data['assign_type'] = $_REQUEST['task_assigntype']; $mail_data['group_name'] = getGroupName($_REQUEST['task_assigned_group_id']); $mail_data['mode'] = $_REQUEST['task_mode']; $startTime = $_REQUEST['task_time_start']; $date = new DateTimeField($_REQUEST['task_date_start'] . " " . $startTime); $endTime = $_REQUEST['task_time_end']; $endDate = new DateTimeField($_REQUEST['task_due_date'] . " " . $startTime); $startTime = $date->getDisplayTime(); $endTime = $endDate->getDisplayTime(); $value = getaddEventPopupTime($startTime, $endTime, '24'); $start_hour = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt']; $mail_data['st_date_time'] = $date->getDisplayDateTimeValue(); $mail_data['end_date_time'] = $endDate->getDisplayDate(); return $mail_data; }
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 to retieve display value for a field * @param <String> $fieldName - field name for which values need to get * @return <String> */ public function getDisplayValue($fieldName, $recordId = false) { if (empty($recordId)) { $recordId = $this->getId(); } $fieldModel = $this->getModule()->getField($fieldName); // For showing the "Date Sent" and "Time Sent" in email related list in user time zone if ($fieldName == "time_start" && $this->getModule()->getName() == "Emails") { $date = new DateTime(); $dateTime = new DateTimeField($date->format('Y-m-d') . ' ' . $this->get($fieldName)); $value = $dateTime->getDisplayTime(); $this->set($fieldName, $value); return $value; } else { if ($fieldName == "date_start" && $this->getModule()->getName() == "Emails") { $dateTime = new DateTimeField($this->get($fieldName) . ' ' . $this->get('time_start')); $value = $dateTime->getDisplayDate(); $this->set($fieldName, $value); return $value; } } // End if ($fieldModel) { return $fieldModel->getDisplayValue($this->get($fieldName), $recordId, $this); } return false; }
/** Function used to get the Sales Stage history of the Potential * @param $id - potentialid * return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are array which contains all the column values of an row */ function get_stage_history($id) { $log = vglobal('log'); $log->debug("Entering get_stage_history(" . $id . ") method ..."); $adb = PearDatabase::getInstance(); global $mod_strings; global $app_strings; $query = 'select vtiger_potstagehistory.*, vtiger_potential.potentialname from vtiger_potstagehistory inner join vtiger_potential on vtiger_potential.potentialid = vtiger_potstagehistory.potentialid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid where vtiger_crmentity.deleted = 0 and vtiger_potential.potentialid = ?'; $result = $adb->pquery($query, array($id)); $noofrows = $adb->num_rows($result); $header[] = $app_strings['LBL_AMOUNT']; $header[] = $app_strings['LBL_SALES_STAGE']; $header[] = $app_strings['LBL_PROBABILITY']; $header[] = $app_strings['LBL_CLOSE_DATE']; $header[] = $app_strings['LBL_LAST_MODIFIED']; //Getting the field permission for the current user. 1 - Not Accessible, 0 - Accessible //Sales Stage, Expected Close Dates are mandatory fields. So no need to do security check to these fields. $current_user = vglobal('current_user'); //If field is accessible then getFieldVisibilityPermission function will return 0 else return 1 $amount_access = getFieldVisibilityPermission('Potentials', $current_user->id, 'sum_invoices') != '0' ? 1 : 0; $probability_access = getFieldVisibilityPermission('Potentials', $current_user->id, 'probability') != '0' ? 1 : 0; $picklistarray = getAccessPickListValues('Potentials'); $potential_stage_array = $picklistarray['sales_stage']; //- ==> picklist field is not permitted in profile //Not Accessible - picklist is permitted in profile but picklist value is not permitted $error_msg = 'Not Accessible'; while ($row = $adb->fetch_array($result)) { $entries = array(); $entries[] = $amount_access != 1 ? $row['sum_invoices'] : 0; $entries[] = in_array($row['stage'], $potential_stage_array) ? $row['stage'] : $error_msg; $entries[] = $probability_access != 1 ? $row['probability'] : 0; $entries[] = DateTimeField::convertToUserFormat($row['closedate']); $date = new DateTimeField($row['lastmodified']); $entries[] = $date->getDisplayDate(); $entries_list[] = $entries; } $return_data = array('header' => $header, 'entries' => $entries_list); $log->debug("Exiting get_stage_history method ..."); return $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 = $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 to get standardfilter for the given reportid * @ param $reportid : Type Integer * returns the query of columnlist for the selected columns */ function getStandardCriterialSql($reportid) { $adb = PearDatabase::getInstance(); global $modules; $log = vglobal('log'); $sreportstdfiltersql = "select vtiger_reportdatefilter.* from vtiger_report"; $sreportstdfiltersql .= " inner join vtiger_reportdatefilter on vtiger_report.reportid = vtiger_reportdatefilter.datefilterid"; $sreportstdfiltersql .= " where vtiger_report.reportid = ?"; $result = $adb->pquery($sreportstdfiltersql, array($reportid)); $noofrows = $adb->num_rows($result); for ($i = 0; $i < $noofrows; $i++) { $fieldcolname = $adb->query_result($result, $i, "datecolumnname"); $datefilter = $adb->query_result($result, $i, "datefilter"); $startdate = $adb->query_result($result, $i, "startdate"); $enddate = $adb->query_result($result, $i, "enddate"); if ($fieldcolname != "none") { $selectedfields = explode(":", $fieldcolname); if ($selectedfields[0] == "vtiger_crmentity" . $this->primarymodule) { $selectedfields[0] = "vtiger_crmentity"; } if ($datefilter == "custom") { if ($startdate != "0000-00-00" && $enddate != "0000-00-00" && $selectedfields[0] != "" && $selectedfields[1] != "" && $startdate != '' && $enddate != '') { $startDateTime = new DateTimeField($startdate . ' ' . date('H:i:s')); $startdate = $startDateTime->getDisplayDate(); $endDateTime = new DateTimeField($enddate . ' ' . date('H:i:s')); $enddate = $endDateTime->getDisplayDate(); $sSQL .= $selectedfields[0] . "." . $selectedfields[1] . " between '" . $startdate . "' and '" . $enddate . "'"; } } else { $startenddate = $this->getStandarFiltersStartAndEndDate($datefilter); $startDateTime = new DateTimeField($startenddate[0] . ' ' . date('H:i:s')); $startdate = $startDateTime->getDisplayDate(); $endDateTime = new DateTimeField($startenddate[1] . ' ' . date('H:i:s')); $enddate = $endDateTime->getDisplayDate(); if ($startenddate[0] != "" && $startenddate[1] != "" && $selectedfields[0] != "" && $selectedfields[1] != "") { $sSQL .= $selectedfields[0] . "." . $selectedfields[1] . " between '" . $startdate . "' and '" . $enddate . "'"; } } } } $log->info("ReportRun :: Successfully returned getStandardCriterialSql" . $reportid); return $sSQL; }
/** to get the customview stdFilter Query for the given customview Id * @param $cvid :: Type Integer * @returns $stdfiltersql as a string * This function will return the standard filter criteria for the given customfield * */ function getCVStdFilterSQL($cvid) { global $adb; $stdfiltersql = ''; $stdfilterlist = array(); $sSQL = "select vtiger_cvstdfilter.* from vtiger_cvstdfilter inner join vtiger_customview on vtiger_customview.cvid = vtiger_cvstdfilter.cvid"; $sSQL .= " where vtiger_cvstdfilter.cvid=?"; $result = $adb->pquery($sSQL, array($cvid)); $stdfilterrow = $adb->fetch_array($result); $stdfilterlist = array(); $stdfilterlist["columnname"] = $stdfilterrow["columnname"]; $stdfilterlist["stdfilter"] = $stdfilterrow["stdfilter"]; if ($stdfilterrow["stdfilter"] == "custom" || $stdfilterrow["stdfilter"] == "") { if ($stdfilterrow["startdate"] != "0000-00-00" && $stdfilterrow["startdate"] != "") { $stdfilterlist["startdate"] = $stdfilterrow["startdate"]; } if ($stdfilterrow["enddate"] != "0000-00-00" && $stdfilterrow["enddate"] != "") { $stdfilterlist["enddate"] = $stdfilterrow["enddate"]; } } else { //if it is not custom get the date according to the selected duration $datefilter = $this->getDateforStdFilterBytype($stdfilterrow["stdfilter"]); $stdfilterlist["startdate"] = $datefilter[0]; $stdfilterlist["enddate"] = $datefilter[1]; } if (isset($stdfilterlist)) { foreach ($stdfilterlist as $columnname => $value) { if ($columnname == "columnname") { $filtercolumn = $value; } elseif ($columnname == "stdfilter") { $filtertype = $value; } elseif ($columnname == "startdate") { $startDateTime = new DateTimeField($value . ' ' . date('H:i:s')); $userStartDate = $startDateTime->getDisplayDate(); $userStartDateTime = new DateTimeField($userStartDate . ' 00:00:00'); $startDateTime = $userStartDateTime->getDBInsertDateTimeValue(); } elseif ($columnname == "enddate") { $endDateTime = new DateTimeField($value . ' ' . date('H:i:s')); $userEndDate = $endDateTime->getDisplayDate(); $userEndDateTime = new DateTimeField($userEndDate . ' 23:59:00'); $endDateTime = $userEndDateTime->getDBInsertDateTimeValue(); } if ($startDateTime != "" && $endDateTime != "") { $columns = explode(":", $filtercolumn); // Fix for http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/5423 if ($columns[1] == 'birthday') { $tableColumnSql = "DATE_FORMAT(" . $columns[0] . "." . $columns[1] . ", '%m%d')"; $startDateTime = "DATE_FORMAT('{$startDate}', '%m%d')"; $endDateTime = "DATE_FORMAT('{$endDate}', '%m%d')"; $stdfiltersql = $tableColumnSql . " BETWEEN " . $startDateTime . " and " . $endDateTime; } else { if ($this->customviewmodule == 'Calendar' && ($columns[1] == 'date_start' || $columns[1] == 'due_date')) { $tableColumnSql = ''; if ($columns[1] == 'date_start') { $tableColumnSql = "CAST((CONCAT(date_start,' ',time_start)) AS DATETIME)"; } else { $tableColumnSql = "CAST((CONCAT(due_date,' ',time_end)) AS DATETIME)"; } } else { $tableColumnSql = $columns[0] . "." . $columns[1]; } $stdfiltersql = $tableColumnSql . " BETWEEN '" . $startDateTime . "' and '" . $endDateTime . "'"; } } } } return $stdfiltersql; }
public function getPDFMakerFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName) { global $current_user, $default_charset; $db = PearDatabase::getInstance(); $value = $valueArray[$fieldName]; $fld_type = $dbField->type; list($module, $fieldLabel) = explode('_', $dbField->name, 2); $fieldInfo = $this->getFieldByPDFMakerLabel($module, $fieldLabel); $fieldType = null; $fieldvalue = $value; if (!empty($fieldInfo)) { $field = WebserviceField::fromArray($db, $fieldInfo); $fieldType = $field->getFieldDataType(); } if ($fieldType == 'currency' && $value != '') { // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($field->getUIType() == '72') { $curid_value = explode("::", $value); $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); if ($value != '') { if ($dbField->name == 'Products_Unit_Price') { // need to do this only for Products Unit Price if ($currency_id != 1) { $currency_value = (double) $cur_sym_rate['rate'] * (double) $currency_value; } } $formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true); $fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']); } } else { $currencyField = new CurrencyField($value); $fieldvalue = $currencyField->getDisplayValue(); } } elseif ($dbField->name == "PurchaseOrder_Currency" || $dbField->name == "SalesOrder_Currency" || $dbField->name == "Invoice_Currency" || $dbField->name == "Quotes_Currency" || $dbField->name == "PriceBooks_Currency") { if ($value != '') { $fieldvalue = getTranslatedCurrencyString($value); } } elseif (in_array($dbField->name, $this->ui101_fields) && !empty($value)) { $entityNames = getEntityName('Users', $value); $fieldvalue = $entityNames[$value]; } elseif ($fieldType == 'date' && !empty($value)) { if ($module == 'Calendar' && $field->getFieldName() == 'due_date') { $endTime = $valueArray['calendar_end_time']; if (empty($endTime)) { $recordId = $valueArray['calendar_id']; $endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId); } $date = new DateTimeField($value . ' ' . $endTime); $fieldvalue = $date->getDisplayDate(); } else { $fieldvalue = DateTimeField::convertToUserFormat($value); } } elseif ($fieldType == "datetime" && !empty($value)) { $date = new DateTimeField($value); $fieldvalue = $date->getDisplayDateTimeValue(); } elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours') { if ($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") { $date = new DateTimeField($value); $fieldvalue = $date->getDisplayTime(); } else { $fieldvalue = $value; } } elseif ($fieldType == "picklist" && !empty($value)) { if (is_array($picklistArray)) { if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $fieldvalue = $this->getTranslatedString($value, $module); } } else { $fieldvalue = $this->getTranslatedString($value, $module); } } elseif ($fieldType == "multipicklist" && !empty($value)) { if (is_array($picklistArray[1])) { $valueList = explode(' |##| ', $value); $translatedValueList = array(); foreach ($valueList as $value) { if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) { $translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $translatedValueList[] = $this->getTranslatedString($value, $module); } } } if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) { $fieldvalue = str_replace(' |##| ', ', ', $value); } else { implode(', ', $translatedValueList); } } elseif ($fieldType == 'double') { if ($current_user->truncate_trailing_zeros == true) { $fieldvalue = decimalFormat($fieldvalue); } } if ($fieldvalue == "") { return "-"; } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); $fieldvalue = decode_html($fieldvalue); if (stristr($fieldvalue, "|##|") && empty($fieldType)) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } elseif ($fld_type == "date" && empty($fieldType)) { $fieldvalue = DateTimeField::convertToUserFormat($fieldvalue); } elseif ($fld_type == "datetime" && empty($fieldType)) { $date = new DateTimeField($fieldvalue); $fieldvalue = $date->getDisplayDateTimeValue(); } // Added to render html tag for description fields if ($fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) { return $fieldvalue; } return htmlentities($fieldvalue, ENT_QUOTES, $default_charset); }
/** Function to get related list entries in detailed array format * @param $parentmodule -- parentmodulename:: Type string * @param $query -- query:: Type string * @param $id -- id:: Type string * @returns $return_data -- return data:: Type string array */ function getHistory($parentmodule, $query, $id) { global $log; $log->debug("Entering getHistory(" . $parentmodule . "," . $query . "," . $id . ") method ..."); $parentaction = vtlib_purify($_REQUEST['action']); global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; global $adb; global $mod_strings; global $app_strings; //Appending the security parameter global $current_user; $rel_tab_id = getTabid("Calendar"); global $current_user; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; $tab_id = getTabid('Calendar'); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) { $sec_parameter = getListViewSecurityParameter('Calendar'); $query .= ' ' . $sec_parameter; } $query .= ' ' . "ORDER BY vtiger_activity.date_start DESC,vtiger_activity.time_start DESC"; $result = $adb->query($query); $noofrows = $adb->num_rows($result); if ($noofrows == 0) { //There is no entries for history } else { //Form the header columns $header[] = $app_strings['LBL_TYPE']; $header[] = $app_strings['LBL_SUBJECT']; $header[] = $app_strings['LBL_RELATED_TO']; $header[] = $app_strings['LBL_START_DATE'] . " & " . $app_strings['LBL_TIME']; $header[] = $app_strings['LBL_END_DATE'] . " & " . $app_strings['LBL_TIME']; //$header[] = $app_strings['LBL_DESCRIPTION']; $header[] = $app_strings['LBL_STATUS']; $header[] = $app_strings['LBL_ASSIGNED_TO']; $i = 1; while ($row = $adb->fetch_array($result)) { $entries = array(); if ($row['activitytype'] == 'Task') { $activitymode = 'Task'; $icon = 'Tasks.gif'; $status = $row['status']; $status = $app_strings[$status]; } else { $activitymode = 'Events'; $icon = 'Activities.gif'; $status = $row['eventstatus']; $status = $app_strings[$status]; } $typeofactivity = $row['activitytype']; $typeofactivity = getTranslatedString($typeofactivity, 'Calendar'); $entries[] = $typeofactivity; $activity = '<a href="index.php?module=Calendar4You&action=EventDetailView&return_module=' . $parentmodule . '&return_action=DetailView&record=' . $row["activityid"] . '&activity_mode=' . $activitymode . '&return_id=' . vtlib_purify($_REQUEST['record']) . '&parenttab=' . vtlib_purify($_REQUEST['parenttab']) . '">' . $row['subject'] . '</a></td>'; $entries[] = $activity; $parentname = getRelatedTo('Calendar', $result, $i - 1); $entries[] = $parentname; $date = new DateTimeField($row['date_start'] . ' ' . $row['time_start']); $entries[] = $date->getDisplayDateTimeValue(); $date = new DateTimeField($row['due_date'] . ' ' . $row['time_end']); $entries[] = $date->getDisplayDate(); $entries[] = $status; if ($row['user_name'] == null && $row['groupname'] != null) { $entries[] = $row['groupname']; } else { $entries[] = $row['user_name']; } $i++; $entries_list[] = $entries; } $return_data = array('header' => $header, 'entries' => $entries_list); $log->debug("Exiting getHistory method ..."); return $return_data; } }
function addOutgoingcallHistory($current_user, $extension, $record, $adb) { global $log; require_once 'modules/Calendar/Activity.php'; $date = new DateTimeField(null); $currentDate = $date->getDisplayDate(); $currentTime = $date->getDisplayTime(); $focus = new Activity(); $focus->column_fields['subject'] = "Outgoing call from {$current_user->user_name} ({$extension})"; $focus->column_fields['activitytype'] = "Call"; $focus->column_fields['date_start'] = $currentDate; $focus->column_fields['due_date'] = $currentDate; $focus->column_fields['time_start'] = $currentTime; $focus->column_fields['time_end'] = $currentTime; $focus->column_fields['eventstatus'] = "Held"; $focus->column_fields['assigned_user_id'] = $current_user->id; $focus->save('Calendar'); $focus->setActivityReminder('off'); $setype = $adb->pquery("SELECT setype FROM vtiger_crmentity WHERE crmid = ?", array($record)); $rows = $adb->num_rows($setype); if ($rows > 0) { $module = $adb->query_result($setype, 0, 'setype'); $tablename = array('Contacts' => 'vtiger_cntactivityrel', 'Accounts' => 'vtiger_seactivityrel', 'Leads' => 'vtiger_seactivityrel'); $sql = "insert into " . $tablename[$module] . " values (?,?)"; $params = array($record, $focus->id); $adb->pquery($sql, $params); $status = "success"; } else { $status = "failure"; } return $status; }
public static function getCalendarState($data = []) { if ($data) { $activityStatus = $data['activitystatus']; if (in_array($activityStatus, Calendar_Module_Model::getComponentActivityStateLabel('history'))) { return false; } $dueDateTime = $data['due_date'] . ' ' . $data['time_end']; $startDateTime = $data['date_start'] . ' ' . $data['time_start']; $dates = ['start' => $startDateTime, 'end' => $dueDateTime, 'current' => null]; foreach ($dates as $key => $date) { $date = new DateTimeField($date); $userFormatedString = $date->getDisplayDate(); $timeFormatedString = $date->getDisplayTime(); $dBFomatedDate = DateTimeField::convertToDBFormat($userFormatedString); $dates[$key] = strtotime($dBFomatedDate . " " . $timeFormatedString); } $activityStatusLabels = Calendar_Module_Model::getComponentActivityStateLabel(); $state = $activityStatusLabels['not_started']; if ($dates['end'] > $dates['current'] && $dates['start'] < $dates['current']) { $state = $activityStatusLabels['in_realization']; } elseif ($dates['end'] > $dates['current']) { $state = $activityStatusLabels['not_started']; } elseif ($dates['end'] < $dates['current']) { $state = $activityStatusLabels['overdue']; } return $state; } return false; }
function sanitizeDateFieldsForInsert($row, $meta) { global $current_user; $moduleFields = $meta->getModuleFields(); foreach ($moduleFields as $fieldName => $fieldObj) { if ($fieldObj->getFieldDataType() == "date") { if (!empty($row[$fieldName])) { $dateFieldObj = new DateTimeField($row[$fieldName]); $row[$fieldName] = $dateFieldObj->getDisplayDate($current_user); } } } return $row; }
function getValue($field_result, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, $mode, $popuptype, $returnset = '', $viewid = '') { global $log, $listview_max_textlength, $app_strings, $current_language, $currentModule; $log->debug("Entering getValue(" . $field_result . "," . $list_result . "," . $fieldname . "," . get_class($focus) . "," . $module . "," . $entity_id . "," . $list_result_count . "," . $mode . "," . $popuptype . "," . $returnset . "," . $viewid . ") method ..."); global $adb, $current_user, $default_charset; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $tabname = getParentTab(); $tabid = getTabid($module); $current_module_strings = return_module_language($current_language, $module); $uicolarr = $field_result[$fieldname]; foreach ($uicolarr as $key => $value) { $uitype = $key; $colname = $value; } //added for getting event status in Custom view - Jaguar if ($module == 'Calendar' && ($colname == "status" || $colname == "eventstatus")) { $colname = "activitystatus"; } //Ends $field_val = $adb->query_result($list_result, $list_result_count, $colname); if ($uitype != 8) { $temp_val = html_entity_decode($field_val, ENT_QUOTES, $default_charset); } else { $temp_val = $field_val; } // vtlib customization: New uitype to handle relation between modules if ($uitype == '10') { $parent_id = $field_val; if (!empty($parent_id)) { $parent_module = getSalesEntityType($parent_id); $valueTitle = $parent_module; if ($app_strings[$valueTitle]) { $valueTitle = $app_strings[$valueTitle]; } $displayValueArray = getEntityName($parent_module, $parent_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $value) { $value = $value; } } $value = "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>" . textlength_check($value) . "</a>"; } else { $value = ''; } } else { if ($uitype == 53) { $value = $adb->query_result($list_result, $list_result_count, 'user_name'); // When Assigned To field is used in Popup window if ($value == '') { $user_id = $adb->query_result($list_result, $list_result_count, 'smownerid'); if ($user_id != null && $user_id != '') { $value = getOwnerName($user_id); $value = textlength_check($value); } } } elseif ($uitype == 52) { $value = getOwnerName($adb->query_result($list_result, $list_result_count, $colname)); $value = textlength_check($value); } elseif ($uitype == 51) { //Accounts - Member Of $parentid = $adb->query_result($list_result, $list_result_count, "parentid"); if ($module == 'Accounts') { $entity_name = textlength_check(getAccountName($parentid)); } elseif ($module == 'Products') { $entity_name = textlength_check(getProductName($parentid)); } $value = '<a href="index.php?module=' . $module . '&action=DetailView&record=' . $parentid . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $entity_name . '</a>'; } elseif ($uitype == 77) { $value = getOwnerName($adb->query_result($list_result, $list_result_count, 'inventorymanager')); $value = textlength_check($value); } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) { $temp_val = trim($temp_val); $timeField = 'time_start'; if ($fieldname == 'due_date') { $timeField = 'time_end'; } if ($temp_val != '' && $module == 'Calendar' && ($uitype == 23 || $uitype == 6) && $timeField != '' && ($fieldname == 'date_start' || $fieldname == 'due_date')) { $time = $adb->query_result($list_result, $list_result_count, $timeField); if (empty($time)) { $time = getSingleFieldValue('vtiger_activity', $timeField, 'activityid', $entity_id); } } if ($temp_val == '0000-00-00' || empty($temp_val)) { $value = ''; } else { if (empty($time) && strpos($temp_val, ' ') == false) { $value = DateTimeField::convertToUserFormat($temp_val); } else { if (!empty($time)) { $date = new DateTimeField($temp_val . ' ' . $time); $value = $date->getDisplayDate(); } else { $date = new DateTimeField($temp_val); $value = $date->getDisplayDateTimeValue(); } } } } elseif ($uitype == 15 || $uitype == 55 && $fieldname == "salutationtype") { $temp_val = decode_html($adb->query_result($list_result, $list_result_count, $colname)); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $temp_val != '') { $temp_acttype = $adb->query_result($list_result, $list_result_count, 'activitytype'); if ($temp_acttype != 'Task' && $fieldname == "taskstatus") { $temptable = "eventstatus"; } else { $temptable = $fieldname; } $roleid = $current_user->roleid; $roleids = array(); $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; } array_push($roleids, $roleid); //here we are checking wheather the table contains the sortorder column .If sortorder is present in the main picklist table, then the role2picklist will be applicable for this table... $sql = "select * from vtiger_{$temptable} where {$temptable}=?"; $res = $adb->pquery($sql, array(decode_html($temp_val))); $picklistvalueid = $adb->query_result($res, 0, 'picklist_valueid'); if ($picklistvalueid != null) { $pick_query = "select * from vtiger_role2picklist where picklistvalueid={$picklistvalueid} and roleid in (" . generateQuestionMarks($roleids) . ")"; $res_val = $adb->pquery($pick_query, array($roleids)); $num_val = $adb->num_rows($res_val); } if ($num_val > 0 || $temp_acttype == 'Task' && $fieldname == 'activitytype') { $temp_val = $temp_val; } else { $temp_val = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; } } $value = $current_module_strings[$temp_val] != '' ? $current_module_strings[$temp_val] : ($app_strings[$temp_val] != '' ? $app_strings[$temp_val] : $temp_val); if ($value != "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>") { $value = textlength_check($value); } } elseif ($uitype == 16) { $value = getTranslatedString($temp_val, $currentModule); $value = textlength_check($value); } elseif ($uitype == 71 || $uitype == 72) { if ($temp_val != '') { // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($uitype == 72) { if ($fieldname == 'unit_price') { $currency_id = getProductBaseCurrency($entity_id, $module); $cursym_convrate = getCurrencySymbolandCRate($currency_id); $currency_symbol = $cursym_convrate['symbol']; } else { $currency_info = getInventoryCurrencyInfo($module, $entity_id); $currency_symbol = $currency_info['currency_symbol']; } $currencyValue = CurrencyField::convertToUserFormat($temp_val, null, true); $value = CurrencyField::appendCurrencySymbol($currencyValue, $currency_symbol); } else { //changes made to remove vtiger_currency symbol infront of each vtiger_potential amount if ($temp_val != 0) { $value = CurrencyField::convertToUserFormat($temp_val); } else { $value = $temp_val; } } } else { $value = ''; } } elseif ($uitype == 17) { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $field_val, $matches); if (!empty($matches[0])) { $value = '<a href="' . $field_val . '" target="_blank">' . textlength_check($temp_val) . '</a>'; } else { $value = '<a href="http://' . $field_val . '" target="_blank">' . textlength_check($temp_val) . '</a>'; } } elseif ($uitype == 13 || $uitype == 104 && ($_REQUEST['action'] != 'Popup' && $_REQUEST['file'] != 'Popup')) { if ($_SESSION['internal_mailer'] == 1) { //check added for email link in user detailview if ($module == 'Calendar') { if (getActivityType($entity_id) == 'Task') { $tabid = 9; } else { $tabid = 16; } } else { $tabid = getTabid($module); } $fieldid = getFieldid($tabid, $fieldname); if (empty($popuptype)) { $value = '<a href="javascript:InternalMailer(' . $entity_id . ',' . $fieldid . ',\'' . $fieldname . '\',\'' . $module . '\',\'record_id\');">' . textlength_check($temp_val) . '</a>'; } else { $value = $temp_val; $value = textlength_check($value); } } else { $value = '<a href="mailto:' . $field_val . '">' . textlength_check($temp_val) . '</a>'; } } elseif ($uitype == 56) { if ($temp_val == 1) { $value = $app_strings['yes']; } elseif ($temp_val == 0) { $value = $app_strings['no']; } else { $value = ''; } } elseif ($uitype == 57) { if ($temp_val != '') { $sql = "SELECT * FROM vtiger_contactdetails WHERE contactid=?"; $result = $adb->pquery($sql, array($temp_val)); $value = ''; if ($adb->num_rows($result)) { $name = getFullNameFromQResult($result, 0, "Contacts"); $value = '<a href=index.php?module=Contacts&action=DetailView&record=' . $temp_val . '>' . textlength_check($name) . '</a>'; } } else { $value = ''; } } elseif ($uitype == 58) { if ($temp_val != '') { $sql = "SELECT * FROM vtiger_campaign WHERE campaignid=?"; $result = $adb->pquery($sql, array($temp_val)); $campaignname = $adb->query_result($result, 0, "campaignname"); $value = '<a href=index.php?module=Campaigns&action=DetailView&record=' . $temp_val . '>' . textlength_check($campaignname) . '</a>'; } else { $value = ''; } } elseif ($uitype == 59) { if ($temp_val != '') { $value = getProductName($temp_val); } else { $value = ''; } } elseif ($uitype == 61) { $attachmentid = $adb->query_result($adb->pquery("SELECT * FROM vtiger_seattachmentsrel WHERE crmid = ?", array($entity_id)), 0, 'attachmentsid'); $value = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $module . '&fileid=' . $attachmentid . '&filename=' . $temp_val . '">' . textlength_check($temp_val) . '</a>'; } elseif ($uitype == 62) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parenttype == "Products") { $tablename = "vtiger_products"; $fieldname = "productname"; $idname = "productid"; } if ($parenttype == "HelpDesk") { $tablename = "vtiger_troubletickets"; $fieldname = "title"; $idname = "ticketid"; } if ($parenttype == "Invoice") { $tablename = "vtiger_invoice"; $fieldname = "subject"; $idname = "invoiceid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($fieldvalue) . '</a>'; } else { $value = ''; } } elseif ($uitype == 66) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parenttype == "HelpDesk") { $tablename = "vtiger_troubletickets"; $fieldname = "title"; $idname = "ticketid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($fieldvalue) . '</a>'; } else { $value = ''; } } elseif ($uitype == 67) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Contacts") { $tablename = "vtiger_contactdetails"; $fieldname = "contactname"; $idname = "contactid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($fieldvalue) . '</a>'; } else { $value = ''; } } elseif ($uitype == 68) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == '' && $parentid != '') { $parenttype = getSalesEntityType($parentid); } if ($parenttype == "Contacts") { $tablename = "vtiger_contactdetails"; $fieldname = "contactname"; $idname = "contactid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($fieldvalue) . '</a>'; } else { $value = ''; } } elseif ($uitype == 78) { if ($temp_val != '') { $quote_name = getQuoteName($temp_val); $value = '<a href=index.php?module=Quotes&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($quote_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 79) { if ($temp_val != '') { $purchaseorder_name = getPoName($temp_val); $value = '<a href=index.php?module=PurchaseOrder&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($purchaseorder_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 80) { if ($temp_val != '') { $salesorder_name = getSoName($temp_val); $value = "<a href=index.php?module=SalesOrder&action=DetailView&record={$temp_val}&parenttab=" . urlencode($tabname) . ">" . textlength_check($salesorder_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 75 || $uitype == 81) { if ($temp_val != '') { $vendor_name = getVendorName($temp_val); $value = '<a href=index.php?module=Vendors&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($vendor_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 98) { $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=Settings&roleid=' . $temp_val . '">' . textlength_check(getRoleName($temp_val)) . '</a>'; } elseif ($uitype == 33) { $value = $temp_val != "" ? str_ireplace(' |##| ', ', ', $temp_val) : ""; if (!$is_admin && $value != '') { $value = $field_val != "" ? str_ireplace(' |##| ', ', ', $field_val) : ""; if ($value != '') { $value_arr = explode(',', trim($value)); $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; array_push($roleids, $roleid); } else { $roleids = $roleid; } if (count($roleids) > 0) { $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where roleid in (" . generateQuestionMarks($roleids) . ") and picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc"; $params = array($roleids); } else { $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc"; $params = array(); } $pickListResult = $adb->pquery($pick_query, $params); $picklistval = array(); for ($i = 0; $i < $adb->num_rows($pickListResult); $i++) { $picklistarr[] = $adb->query_result($pickListResult, $i, $fieldname); } $value_temp = array(); $string_temp = ''; $str_c = 0; foreach ($value_arr as $ind => $val) { $notaccess = '<font color="red">' . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $string_temp)) > $listview_max_textlength)) { $value_temp1 = in_array(trim($val), $picklistarr) ? $val : $notaccess; if ($str_c != 0) { $string_temp .= ' , '; } $string_temp .= $value_temp1; $str_c++; } else { $string_temp .= '...'; } } $value = $string_temp; } } } elseif ($uitype == 85) { $value = $temp_val != "" ? "<a href='skype:{$temp_val}?call'>{$temp_val}</a>" : ""; } elseif ($uitype == 116) { $value = $temp_val != "" ? getCurrencyName($temp_val) : ""; } elseif ($uitype == 117) { // NOTE: Without symbol the value could be used for filtering/lookup hence avoiding the translation $value = $temp_val != "" ? getCurrencyName($temp_val, false) : ""; } elseif ($uitype == 26) { $sql = "select foldername from vtiger_attachmentsfolder where folderid = ?"; $res = $adb->pquery($sql, array($temp_val)); $foldername = $adb->query_result($res, 0, 'foldername'); $value = $foldername; } elseif ($uitype == 11) { // Fix added for Trac Id: 6139 if (get_use_asterisk($current_user->id)) { $value = "<a href='javascript:;' onclick='startCall("{$temp_val}", "{$entity_id}")'>" . textlength_check($temp_val) . "</a>"; } else { $value = $temp_val; } } elseif ($uitype == 25) { $contactid = $_REQUEST['record']; $emailid = $adb->query_result($list_result, $list_result_count, "activityid"); $result = $adb->pquery("SELECT access_count FROM vtiger_email_track WHERE crmid=? AND mailid=?", array($contactid, $emailid)); $value = $adb->query_result($result, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($uitype == 8) { if (!empty($temp_val)) { $temp_val = html_entity_decode($temp_val, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } else { if ($fieldname == $focus->list_link_field) { if ($mode == "search") { if ($popuptype == "specific" || $popuptype == "toDospecific") { // Added for get the first name of contact in Popup window if ($colname == "lastname" && $module == 'Contacts') { $temp_val = getFullNameFromQResult($list_result, $list_result_count, "Contacts"); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); //Added to avoid the error when select SO from Invoice through AjaxEdit if ($module == 'SalesOrder') { $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '","' . $_REQUEST['form'] . '");\' id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } elseif ($module == 'Contacts') { require_once 'modules/Contacts/Contacts.php'; $cntct_focus = new Contacts(); $cntct_focus->retrieve_entity_info($entity_id, "Contacts"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); //ADDED TO CHECK THE FIELD PERMISSIONS FOR $xyz = array('mailingstreet', 'mailingcity', 'mailingzip', 'mailingpobox', 'mailingcountry', 'mailingstate', 'otherstreet', 'othercity', 'otherzip', 'otherpobox', 'othercountry', 'otherstate'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $cntct_focus->column_fields[$xyz[$i]] = $cntct_focus->column_fields[$xyz[$i]]; } else { $cntct_focus->column_fields[$xyz[$i]] = ''; } } // For ToDo creation the underlying form is not named as EditView $form = !empty($_REQUEST['form']) ? $_REQUEST['form'] : ''; if (!empty($form)) { $form = htmlspecialchars($form, ENT_QUOTES, $default_charset); } $count = counterValue(); $value = '<a href="javascript:void(0);" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcity']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercity']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcountry']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercountry']) . '","' . popup_decode_html($cntct_focus->column_fields['mailingpobox']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherpobox']) . '","' . $form . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } else { if ($popuptype == 'toDospecific') { $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'set_return_toDospecific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } else { $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } } } elseif ($popuptype == "detailview") { if ($colname == "lastname" && ($module == 'Contacts' || $module == 'Leads')) { $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $focus->record_id = $_REQUEST['recordid']; $popupMode = $_REQUEST['popupmode']; $callBack = $_REQUEST['callback']; if ($_REQUEST['return_module'] == "Calendar") { $count = counterValue(); $value = '<a href="javascript:window.close();" id="calendarCont' . $entity_id . '" LANGUAGE=javascript onclick=\'add_data_to_relatedlist_incal("' . $entity_id . '","' . decode_html($slashes_temp_val) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } else { $count = counterValue(); if (empty($callBack)) { $value = '<a style="cursor:pointer;" onclick=\'add_data_to_relatedlist("' . $entity_id . '","' . $focus->record_id . '","' . $module . '","' . $popupMode . '");\'>' . textlength_check($temp_val) . '</a>'; } else { $value = '<a style="cursor:pointer;" onclick=\'add_data_to_relatedlist("' . $entity_id . '","' . $focus->record_id . '","' . $module . '","' . $popupMode . '",' . $callBack . ');\'>' . textlength_check($temp_val) . '</a>'; } if ($module === 'Documents' && $_REQUEST['return_module'] === 'Emails') { $attachment = $adb->query_result($list_result, $list_result_count, 'filename'); $value .= "<input type='hidden' id='document_attachment_{$entity_id}' value='{$attachment}'>"; } } } elseif ($popuptype == "formname_specific") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'set_return_formname_specific("' . $_REQUEST['form'] . '", "' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } elseif ($popuptype == "inventory_prod") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id)); $unitprice = $prod_prices[$entity_id]; } } else { $unitprice = ''; } $sub_products = ''; $sub_prod = ''; $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id)); for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) { //$sub_prod=array(); $id = $adb->query_result($sub_prod_query, $i, "productid"); $str_sep = ''; if ($i > 0) { $str_sep = ":"; } $sub_products .= $str_sep . $id; $sub_prod .= $str_sep . " - " . htmlspecialchars($adb->query_result($sub_prod_query, $i, "productname"), ENT_QUOTES, $default_charset); } $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod); $qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); //fix for T6943 $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $qty_stock . '","' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '");\' vt_prod_arr=\'' . $prod_arr . '\' >' . textlength_check($temp_val) . '</a>'; } elseif ($popuptype == "inventory_prod_po") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission($module, $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module); $unitprice = $prod_prices[$entity_id]; } } else { $unitprice = ''; } $sub_products = ''; $sub_prod = ''; $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id)); for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) { //$sub_prod=array(); $id = $adb->query_result($sub_prod_query, $i, "productid"); $str_sep = ''; if ($i > 0) { $str_sep = ":"; } $sub_products .= $str_sep . $id; $sub_prod .= $str_sep . " - {$id}." . $adb->query_result($sub_prod_query, $i, "productname"); } $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod); $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory_po("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '"); \' vt_prod_arr=\'' . $prod_arr . '\' >' . textlength_check($temp_val) . '</a>'; } elseif ($popuptype == "inventory_service") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module); $unitprice = $prod_prices[$entity_id]; } } else { $unitprice = ''; } $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '");\' vt_prod_arr=\'' . $prod_arr . '\' >' . textlength_check($temp_val) . '</a>'; } elseif ($popuptype == "inventory_pb") { $prod_id = $_REQUEST['productid']; $flname = $_REQUEST['fldname']; $listprice = getListPrice($prod_id, $entity_id); $temp_val = popup_from_html($temp_val); $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_pb("' . $listprice . '", "' . $flname . '"); \'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } elseif ($popuptype == "specific_account_address") { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($entity_id, "Accounts"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $count = counterValue(); $value = '<a href="javascript:void(0);" onclick=\'set_return_shipbilladdress("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } elseif ($popuptype == "specific_contact_account_address") { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($entity_id, "Accounts"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } elseif ($popuptype == "specific_potential_account_address") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); // For B2C support, Potential was enabled to be linked to Contacts also. // Hence we need case handling for it. $relatedid = $adb->query_result($list_result, $list_result_count, "related_to"); $relatedentity = getSalesEntityType($relatedid); if ($relatedentity == 'Accounts') { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($relatedid, "Accounts"); $account_name = getAccountName($relatedid); $slashes_account_name = popup_from_html($account_name); $slashes_account_name = htmlspecialchars($slashes_account_name, ENT_QUOTES, $default_charset); $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission('Accounts', $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_account_name)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } else { if ($relatedentity == 'Contacts') { require_once 'modules/Contacts/Contacts.php'; $displayValueArray = getEntityName('Contacts', $relatedid); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $slashes_contact_name = popup_from_html($contact_name); $slashes_contact_name = htmlspecialchars($slashes_contact_name, ENT_QUOTES, $default_charset); $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'set_return_contact("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_contact_name)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } else { $value = $temp_val; } } } elseif ($popuptype == "set_return_emails") { if (empty($_REQUEST['email_field'])) { $sre_param = ', "default"'; } else { $sre_param = ', "' . $_REQUEST['email_field'] . '"'; } if ($module == 'Accounts') { $name = $adb->query_result($list_result, $list_result_count, 'accountname'); $accid = $adb->query_result($list_result, $list_result_count, 'accountid'); if (CheckFieldPermission('email1', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email1"); $email_check = 1; } else { $email_check = 0; } if ($emailaddress == '') { if (CheckFieldPermission('email2', $module) == 'true') { $emailaddress2 = $adb->query_result($list_result, $list_result_count, "email2"); $email_check = 2; } else { if ($email_check == 1) { $email_check = 4; } else { $email_check = 3; } } } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'id = ' . $count . '>' . textlength_check($name) . '</a>'; } elseif ($module == 'Vendors') { $name = $adb->query_result($list_result, $list_result_count, 'vendorname'); $venid = $adb->query_result($list_result, $list_result_count, 'vendorid'); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'id = ' . $count . '>' . textlength_check($name) . '</a>'; } elseif ($module == 'Contacts' || $module == 'Leads') { $name = getFullNameFromQResult($list_result, $list_result_count, $module); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } if ($emailaddress == '') { if (CheckFieldPermission('secondaryemail', $module) == 'true') { $emailaddress2 = $adb->query_result($list_result, $list_result_count, "secondaryemail"); $email_check = 2; } else { if ($email_check == 1) { $email_check = 4; } else { $email_check = 3; } } } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email or secondaryemail $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'id = ' . $count . '>' . $name . '</a>'; } elseif ($module == 'Project') { $name = $adb->query_result($list_result, $list_result_count, 'projectname'); $projid = $adb->query_result($list_result, $list_result_count, 'projectid'); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'>' . textlength_check($name) . '</a>'; } elseif ($module == 'ProjectTask') { $name = $adb->query_result($list_result, $list_result_count, 'projecttaskname'); $projid = $adb->query_result($list_result, $list_result_count, 'projecttaskid'); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'>' . textlength_check($name) . '</a>'; } elseif ($module == 'Potentials') { $name = $adb->query_result($list_result, $list_result_count, 'potentialname'); $potid = $adb->query_result($list_result, $list_result_count, 'potentialid'); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'>' . textlength_check($name) . '</a>'; } elseif ($module == 'HelpDesk') { $name = $adb->query_result($list_result, $list_result_count, 'title'); $potid = $adb->query_result($list_result, $list_result_count, 'ticketid'); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'>' . textlength_check($name) . '</a>'; } else { $name = getFullNameFromQResult($list_result, $list_result_count, $module); $emailaddress = $adb->query_result($list_result, $list_result_count, "email1"); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $email_check = 1; $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',-1,"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"' . $sre_param . '); \'id = ' . $count . '>' . textlength_check($name) . '</a>'; } } elseif ($popuptype == "specific_vendor_address") { require_once 'modules/Vendors/Vendors.php'; $acct_focus = new Vendors(); $acct_focus->retrieve_entity_info($entity_id, "Vendors"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $xyz = array('street', 'city', 'postalcode', 'pobox', 'country', 'state'); for ($i = 0; $i < 6; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['street'])); $count = counterValue(); $value = '<a href="javascript:void(0);" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . popup_decode_html($acct_focus->column_fields['city']) . '", "' . popup_decode_html($acct_focus->column_fields['state']) . '", "' . popup_decode_html($acct_focus->column_fields['postalcode']) . '", "' . popup_decode_html($acct_focus->column_fields['country']) . '","' . popup_decode_html($acct_focus->column_fields['pobox']) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } elseif ($popuptype == "specific_campaign") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'set_return_specific_campaign("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } else { if ($colname == "lastname") { $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module); } elseif ($module == 'Users' && $fieldname == 'last_name') { $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $log->debug("Exiting getValue method ..."); if ($_REQUEST['maintab'] == 'Calendar') { $count = counterValue(); $value = '<a href="javascript:window.close();" onclick=\'set_return_todo("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'set_return("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\''; if (empty($_REQUEST['forfield']) && $focus->popup_type != 'detailview') { $count = counterValue(); $value .= " id='{$count}' "; } $value .= '>' . textlength_check($temp_val) . '</a>'; } } } else { if ($module == "Leads" && $colname == "lastname" || $module == "Contacts" && $colname == "lastname") { $count = counterValue(); $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } elseif ($module == "Calendar") { $actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype'); $actvity_type = $actvity_type != '' ? $actvity_type : $adb->query_result($list_result, $list_result_count, 'type'); if ($actvity_type == "Task") { $count = counterValue(); $value = '<a href="index.php?action=EventDetailView&module=Calendar4You&record=' . $entity_id . '&activity_mode=Task&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } else { $count = counterValue(); $value = '<a href="index.php?action=EventDetailView&module=Calendar4You&record=' . $entity_id . '&activity_mode=Events&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } } elseif ($module == "Vendors") { $count = counterValue(); $value = '<a href="index.php?action=DetailView&module=Vendors&record=' . $entity_id . '&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } elseif ($module == "PriceBooks") { $count = counterValue(); $value = '<a href="index.php?action=DetailView&module=PriceBooks&record=' . $entity_id . '&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } elseif ($module == "SalesOrder") { $count = counterValue(); $value = '<a href="index.php?action=DetailView&module=SalesOrder&record=' . $entity_id . '&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } elseif ($module == 'Emails') { $value = $temp_val; } elseif ($module == "Users" && $colname == "last_name") { $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module); $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . textlength_check($temp_val) . '</a>'; } else { $count = counterValue(); $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '" id = ' . $count . '>' . textlength_check($temp_val) . '</a>'; } } } elseif ($module == 'Calendar' && ($fieldname == 'time_start' || $fieldname == 'time_end')) { $dateField = 'date_start'; if ($fieldname == 'time_end') { $dateField = 'due_date'; } $type = $adb->query_result($list_result, $list_result_count, 'activitytype'); if (empty($type)) { $type = $adb->query_result($list_result, $list_result_count, 'type'); } if ($type == 'Task' && $fieldname == 'time_end') { $value = '--'; } else { $date_val = $adb->query_result($list_result, $list_result_count, $dateField); $date = new DateTimeField($date_val . ' ' . $temp_val); $value = $date->getDisplayTime(); $value = textlength_check($value); } } else { $value = $temp_val; $value = textlength_check($value); } } } // Mike Crowe Mod --------------------------------------------------------Make right justified and vtiger_currency value if (in_array($uitype, array(71, 72, 7, 9, 90))) { $value = '<span align="right">' . $value . '</div>'; } $log->debug("Exiting getValue method ..."); return $value; }
/** * function to get pending activities for today * @param integer $maxval - the maximum number of records to display * @param integer $calCnt - returns the count query if this is set * return array $values - activities record in array format */ function homepage_getPendingActivities($maxval, $calCnt) { require_once "data/Tracker.php"; require_once "include/utils/utils.php"; require_once 'include/utils/CommonUtils.php'; global $adb; global $current_user; $today = date("Y-m-d", time()); $pending_condition = " AND (due_date = '{$today}' OR vtiger_recurringevents.recurringdate = '{$today}')"; $list_query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity." . "setype, vtiger_recurringevents.recurringdate, vtiger_activity.* from vtiger_activity " . "inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid LEFT " . "JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid left outer join " . "vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid" . ($list_query .= getNonAdminAccessControlQuery('Calendar', $current_user)); $list_query .= "WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype not in " . "('Emails')) AND (vtiger_activity.status is NULL OR vtiger_activity.status not in " . "('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR vtiger_activity." . "eventstatus not in ('Held','Not Held')) " . $pending_condition; $list_query .= " GROUP BY vtiger_activity.activityid"; $list_query .= " ORDER BY date_start,time_start ASC"; $list_query .= " limit {$maxval}"; $res = $adb->query($list_query); $noofrecords = $adb->num_rows($res); if ($calCnt == 'calculateCnt') { return $noofrecords; } $open_activity_list = array(); $noofrows = $adb->num_rows($res); if (count($res) > 0) { for ($i = 0; $i < $noofrows; $i++) { $dateValue = $adb->query_result($res, $i, 'date_start') . ' ' . $adb->query_result($res, $i, 'time_start'); $endDateValue = $adb->query_result($res, $i, 'due_date') . ' ' . $adb->query_result($res, $i, 'time_end'); $recurringDateValue = $adb->query_result($res, $i, 'due_date') . ' ' . $adb->query_result($res, $i, 'time_start'); $date = new DateTimeField($dateValue); $endDate = new DateTimeField($endDateValue); $recurringDate = new DateTimeField($recurringDateValue); $open_activity_list[] = array('name' => $adb->query_result($res, $i, 'subject'), 'id' => $adb->query_result($res, $i, 'activityid'), 'type' => $adb->query_result($res, $i, 'activitytype'), 'module' => $adb->query_result($res, $i, 'setype'), 'date_start' => $date->getDisplayDate(), 'due_date' => $endDate->getDisplayDate(), 'recurringdate' => $recurringDate->getDisplayDate(), 'priority' => $adb->query_result($res, $i, 'priority')); } } $values = getActivityEntries($open_activity_list); $values['ModuleName'] = 'Calendar'; $values['search_qry'] = "&action=ListView&from_homepage=pending_activities"; return $values; }
/** * Function to get the datetime value in user preferred hour format * @param <DateTime> $dateTime * @param <Vtiger_Users_Model> $userObject * @return <String> date and time with hour format */ public static function convertDateTimeIntoUsersDisplayFormat($dateTime, $userObject = null) { require_once 'includes/runtime/LanguageHandler.php'; require_once 'includes/runtime/Globals.php'; if ($userObject) { $userModel = Users_Privileges_Model::getInstanceFromUserObject($userObject); } else { $userModel = Users_Privileges_Model::getCurrentUserModel(); } $date = new DateTime($dateTime); $dateTimeField = new DateTimeField($date->format('Y-m-d H:i:s')); $date = $dateTimeField->getDisplayDate($userModel); $time = $dateTimeField->getDisplayTime($userModel); return $date . ' ' . $time; }
public static function createPotentialRelatedTo($relatedto, $campaignid) { global $adb, $current_user; $checkrs = $adb->pquery('select 1 from vtiger_potential inner join vtiger_crmentity on crmid=potentialid where deleted=0 and related_to=? and campaignid=?', array($relatedto, $campaignid)); if ($adb->num_rows($checkrs) == 0) { require_once 'modules/Potentials/Potentials.php'; $entity = new Potentials(); $entity->mode = ''; $cname = getEntityName('Campaigns', $campaignid); $cname = $cname[$campaignid] . ' - '; $setype = getSalesEntityType($relatedto); $rname = getEntityName($setype, $relatedto); $rname = $rname[$relatedto]; $cbMapid = GlobalVariable::getVariable('BusinessMapping_PotentialOnCampaignRelation', cbMap::getMapIdByName('PotentialOnCampaignRelation')); if ($cbMapid) { $cmp = CRMEntity::getInstance('Campaigns'); $cmp->retrieve_entity_info($campaignid, 'Campaigns'); if ($setype == 'Accounts') { $cmp->column_fields['AccountName'] = $rname; $cmp->column_fields['ContactName'] = ''; } else { $cmp->column_fields['AccountName'] = ''; $cmp->column_fields['ContactName'] = $rname; } $cbMap = cbMap::getMapByID($cbMapid); $entity->column_fields = $cbMap->Mapping($cmp->column_fields, array()); } if (empty($entity->column_fields['assigned_user_id'])) { $entity->column_fields['assigned_user_id'] = $current_user->id; } $entity->column_fields['related_to'] = $relatedto; $entity->column_fields['campaignid'] = $campaignid; if (empty($entity->column_fields['closingdate'])) { $dt = new DateTimeField(); $entity->column_fields['closingdate'] = $dt->getDisplayDate(); } if (empty($entity->column_fields['potentialname'])) { $entity->column_fields['potentialname'] = $cname . $rname; } if (empty($entity->column_fields['sales_stage'])) { $entity->column_fields['sales_stage'] = 'Prospecting'; } $_REQUEST['assigntype'] = 'U'; $_REQUEST['assigned_user_id'] = $entity->column_fields['assigned_user_id']; $entity->save('Potentials'); } }
static function currentUserDisplayDateNew() { global $log, $current_user; $date = new DateTimeField(null); return $date->getDisplayDate($current_user); }
/** * Function returns Reports Standard Filters * @return type */ function getSelectedStandardFilter() { $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT * FROM vtiger_reportdatefilter WHERE datefilterid = ? AND startdate != ? AND enddate != ?', array($this->getId(), '0000-00-00', '0000-00-00')); $standardFieldInfo = array(); if ($db->num_rows($result)) { $standardFieldInfo['columnname'] = $db->query_result($result, 0, 'datecolumnname'); $standardFieldInfo['type'] = $db->query_result($result, 0, 'datefilter'); $standardFieldInfo['startdate'] = $db->query_result($result, 0, 'startdate'); $standardFieldInfo['enddate'] = $db->query_result($result, 0, 'enddate'); if ($standardFieldInfo['type'] == "custom" || $standardFieldInfo['type'] == "") { if ($standardFieldInfo["startdate"] != "0000-00-00" && $standardFieldInfo["startdate"] != "") { $startDateTime = new DateTimeField($standardFieldInfo["startdate"] . ' ' . date('H:i:s')); $standardFieldInfo["startdate"] = $startDateTime->getDisplayDate(); } if ($standardFieldInfo["enddate"] != "0000-00-00" && $standardFieldInfo["enddate"] != "") { $endDateTime = new DateTimeField($standardFieldInfo["enddate"] . ' ' . date('H:i:s')); $standardFieldInfo["enddate"] = $endDateTime->getDisplayDate(); } } else { $startDateTime = new DateTimeField($standardFieldInfo["startdate"] . ' ' . date('H:i:s')); $standardFieldInfo["startdate"] = $startDateTime->getDisplayDate(); $endDateTime = new DateTimeField($standardFieldInfo["enddate"] . ' ' . date('H:i:s')); $standardFieldInfo["enddate"] = $endDateTime->getDisplayDate(); } } return $standardFieldInfo; }
/** Function to return the duplicate records data as a formatted array */ function getDuplicateRecordsArr($module) { global $adb, $app_strings, $list_max_entries_per_page, $theme; $field_values_array = getFieldValues($module); $field_values = $field_values_array['fieldnames_list']; $fld_arr = $field_values_array['fieldnames_array']; $col_arr = $field_values_array['columnnames_array']; $fld_labl_arr = $field_values_array['fieldlabels_array']; $ui_type = $field_values_array['fieldname_uitype']; $dup_query = getDuplicateQuery($module, $field_values, $ui_type); // added for page navigation $dup_count_query = substr($dup_query, stripos($dup_query, 'FROM'), strlen($dup_query)); $dup_count_query = "SELECT count(*) as count " . $dup_count_query; $count_res = $adb->query($dup_count_query); $no_of_rows = $adb->query_result($count_res, 0, "count"); if ($no_of_rows <= $list_max_entries_per_page) { $_SESSION['dup_nav_start' . $module] = 1; } else { if (isset($_REQUEST["start"]) && $_REQUEST["start"] != "" && $_SESSION['dup_nav_start' . $module] != $_REQUEST["start"]) { $_SESSION['dup_nav_start' . $module] = ListViewSession::getRequestStartPage(); } } $start = $_SESSION['dup_nav_start' . $module] != "" ? $_SESSION['dup_nav_start' . $module] : 1; $navigation_array = getNavigationValues($start, $no_of_rows, $list_max_entries_per_page); $start_rec = $navigation_array['start']; $end_rec = $navigation_array['end_val']; $navigationOutput = getTableHeaderNavigation($navigation_array, "", $module, "FindDuplicate", ""); if ($start_rec == 0) { $limit_start_rec = 0; } else { $limit_start_rec = $start_rec - 1; } $dup_query .= " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}"; //ends $nresult = $adb->query($dup_query); $no_rows = $adb->num_rows($nresult); require_once 'modules/Vtiger/layout_utils.php'; if ($no_rows == 0) { if ($_REQUEST['action'] == 'FindDuplicateRecords') { //echo "<br><br><center>".$app_strings['LBL_NO_DUPLICATE']." <a href='javascript:window.history.back()'>".$app_strings['LBL_GO_BACK'].".</a></center>"; //die; echo "<link rel='stylesheet' type='text/css' href='themes/{$theme}/style.css'>"; echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>"; echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>\n\n\t\t\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t\t\t<tbody><tr>\n\t\t\t\t<td rowspan='2' width='11%'><img src='" . vtiger_imageurl('empty.jpg', $theme) . "' ></td>\n\t\t\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'><span class='genHeaderSmall'>{$app_strings['LBL_NO_DUPLICATE']}</span></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t<td class='small' align='right' nowrap='nowrap'>\n\t\t\t\t<a href='javascript:window.history.back();'>{$app_strings['LBL_GO_BACK']}</a><br> </td>\n\t\t\t\t</tr>\n\t\t\t\t</tbody></table>\n\t\t\t\t</div>"; echo "</td></tr></table>"; exit; } else { echo "<br><br><table align='center' class='reportCreateBottom big' width='95%'><tr><td align='center'>" . $app_strings['LBL_NO_DUPLICATE'] . "</td></tr></table>"; die; } } $rec_cnt = 0; $temp = array(); $sl_arr = array(); $grp = "group0"; $gcnt = 0; $ii = 0; //ii'th record in group while ($rec_cnt < $no_rows) { $result = $adb->fetchByAssoc($nresult); //echo '<pre>';print_r($result);echo '</pre>'; if ($rec_cnt != 0) { $sl_arr = array_slice($result, 2); array_walk($temp, 'lower_array'); array_walk($sl_arr, 'lower_array'); $arr_diff = array_diff($temp, $sl_arr); if (count($arr_diff) > 0) { $gcnt++; $temp = $sl_arr; $ii = 0; } $grp = "group" . $gcnt; } $fld_values[$grp][$ii]['recordid'] = $result['recordid']; for ($k = 0; $k < count($col_arr); $k++) { if ($rec_cnt == 0) { $temp[$fld_labl_arr[$k]] = $result[$col_arr[$k]]; } if ($ui_type[$fld_arr[$k]] == 56) { if ($result[$col_arr[$k]] == 0) { $result[$col_arr[$k]] = $app_strings['no']; } else { $result[$col_arr[$k]] = $app_strings['yes']; } } if ($ui_type[$fld_arr[$k]] == 75 || $ui_type[$fld_arr[$k]] == 81) { $vendor_id = $result[$col_arr[$k]]; if ($vendor_id != '') { $vendor_name = getVendorName($vendor_id); } $result[$col_arr[$k]] = $vendor_name; } if ($ui_type[$fld_arr[$k]] == 57) { $contact_id = $result[$col_arr[$k]]; if ($contact_id != '') { $parent_module = 'Contacts'; $displayValueArray = getEntityName($parent_module, $contact_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contactname = $field_value; } } } $result[$col_arr[$k]] = $contactname; } if ($ui_type[$fld_arr[$k]] == 15 || $ui_type[$fld_arr[$k]] == 16) { $result[$col_arr[$k]] = getTranslatedString($result[$col_arr[$k]], $module); } if ($ui_type[$fld_arr[$k]] == 33) { $fieldvalue = explode(' |##| ', $result[$col_arr[$k]]); $result[$col_arr[$k]] = array(); foreach ($fieldvalue as $picklistValue) { $result[$col_arr[$k]][] = getTranslatedString($picklistValue, $module); } $result[$col_arr[$k]] = implode(', ', $result[$col_arr[$k]]); } if ($ui_type[$fld_arr[$k]] == 68) { $parent_id = $result[$col_arr[$k]]; if ($parent_id != '') { $parentname = getParentName($parent_id); } $result[$col_arr[$k]] = $parentname; } if ($ui_type[$fld_arr[$k]] == 53 || $ui_type[$fld_arr[$k]] == 52) { if ($result[$col_arr[$k]] != '') { $owner = getOwnerName($result[$col_arr[$k]]); } $result[$col_arr[$k]] = $owner; } if ($ui_type[$fld_arr[$k]] == 50 or $ui_type[$fld_arr[$k]] == 51) { if ($module != 'Products') { $entity_name = getAccountName($result[$col_arr[$k]]); } else { $entity_name = getProductName($result[$col_arr[$k]]); } if ($entity_name != '') { $result[$col_arr[$k]] = $entity_name; } else { $result[$col_arr[$k]] = ''; } } if ($ui_type[$fld_arr[$k]] == 58) { $campaign_name = getCampaignName($result[$col_arr[$k]]); if ($campaign_name != '') { $result[$col_arr[$k]] = $campaign_name; } else { $result[$col_arr[$k]] = ''; } } if ($ui_type[$fld_arr[$k]] == 59) { $product_name = getProductName($result[$col_arr[$k]]); if ($product_name != '') { $result[$col_arr[$k]] = $product_name; } else { $result[$col_arr[$k]] = ''; } } /*uitype 10 handling*/ if ($ui_type[$fld_arr[$k]] == 10) { $result[$col_arr[$k]] = getRecordInfoFromID($result[$col_arr[$k]]); } if ($ui_type[$fld_arr[$k]] == 5 || $ui_type[$fld_arr[$k]] == 6 || $ui_type[$fld_arr[$k]] == 23) { if (${$result}[$col_arr[$k]] != '' && ${$result}[$col_arr[$k]] != '0000-00-00') { $date = new DateTimeField(${$result}[$col_arr[$k]]); $value = $date->getDisplayDate(); if (strpos(${$result}[$col_arr[$k]], ' ') > -1) { $value .= ' ' . $date->getDisplayTime(); } } elseif (${$result}[$col_arr[$k]] == '0000-00-00') { $value = ''; } else { $value = ${$result}[$col_arr[$k]]; } $result[$col_arr[$k]] = $value; } if ($ui_type[$fld_arr[$k]] == 71) { $result[$col_arr[$k]] = CurrencyField::convertToUserFormat($result[$col_arr[$k]]); } if ($ui_type[$fld_arr[$k]] == 72) { $result[$col_arr[$k]] = CurrencyField::convertToUserFormat($result[$col_arr[$k]], null, true); } $fld_values[$grp][$ii][$fld_labl_arr[$k]] = $result[$col_arr[$k]]; } $fld_values[$grp][$ii]['Entity Type'] = $result['deleted']; $ii++; $rec_cnt++; } $gro = "group"; for ($i = 0; $i < $no_rows; $i++) { $ii = 0; $dis_group[] = $fld_values[$gro . $i][$ii]; $count_group[$i] = count($fld_values[$gro . $i]); $ii++; $new_group[] = $dis_group[$i]; } $fld_nam = $new_group[0]; $ret_arr[0] = $fld_values; $ret_arr[1] = $fld_nam; $ret_arr[2] = $ui_type; $ret_arr["navigation"] = $navigationOutput; return $ret_arr; }
/** * Function to get the datetime value in user preferred hour format * @param <DateTime> $dateTime * @param <Vtiger_Users_Model> $userObject * @return <String> date and time with hour format */ public static function convertDateTimeIntoUsersDisplayFormat($dateTime, $userObject = null) { require_once 'includes/runtime/LanguageHandler.php'; require_once 'includes/runtime/Globals.php'; if ($userObject) { $userModel = Users_Privileges_Model::getInstanceFromUserObject($userObject); } else { $userModel = Users_Privileges_Model::getCurrentUserModel(); } $date = new DateTime($dateTime); $dateTimeField = new DateTimeField($date->format('Y-m-d H:i:s')); $date = $dateTimeField->getDisplayDate($userModel); $time = $dateTimeField->getDisplayTime($userModel); //Convert time to user preferred value if ($userModel->get('hour_format') == '12') { $time = Vtiger_Time_UIType::getTimeValueInAMorPM($time); } return $date . ' ' . $time; }
/** * Function to get the list of advanced filter conditions for the current custom view * @return <Array> - All the advanced filter conditions for the custom view, grouped by the condition grouping */ public function getAdvancedCriteria() { $db = PearDatabase::getInstance(); $default_charset = vglobal('default_charset'); $cvId = $this->getId(); $advft_criteria = array(); if (empty($cvId)) { return $advft_criteria; } $sql = 'SELECT * FROM vtiger_cvadvfilter_grouping WHERE cvid = ? ORDER BY groupid'; $groupsresult = $db->pquery($sql, array($this->getId())); $i = 1; $j = 0; while ($relcriteriagroup = $db->fetch_array($groupsresult)) { $groupId = $relcriteriagroup["groupid"]; $groupCondition = $relcriteriagroup["group_condition"]; $ssql = 'select vtiger_cvadvfilter.* from vtiger_customview inner join vtiger_cvadvfilter on vtiger_cvadvfilter.cvid = vtiger_customview.cvid left join vtiger_cvadvfilter_grouping on vtiger_cvadvfilter.cvid = vtiger_cvadvfilter_grouping.cvid and vtiger_cvadvfilter.groupid = vtiger_cvadvfilter_grouping.groupid'; $ssql .= " where vtiger_customview.cvid = ? AND vtiger_cvadvfilter.groupid = ? order by vtiger_cvadvfilter.columnindex"; $result = $db->pquery($ssql, array($this->getId(), $groupId)); $noOfColumns = $db->num_rows($result); if ($noOfColumns <= 0) { continue; } while ($relcriteriarow = $db->fetch_array($result)) { $criteria = array(); $criteria['columnname'] = html_entity_decode($relcriteriarow["columnname"], ENT_QUOTES, $default_charset); $criteria['comparator'] = $relcriteriarow["comparator"]; $advfilterval = html_entity_decode($relcriteriarow["value"], ENT_QUOTES, $default_charset); $col = explode(":", $relcriteriarow["columnname"]); $temp_val = explode(",", $relcriteriarow["value"]); if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') { $val = array(); for ($x = 0; $x < count($temp_val); $x++) { if ($col[4] == 'D') { /** while inserting in db for due_date it was taking date and time values also as it is * date time field. We only need to take date from that value */ if ($col[0] == 'vtiger_activity' && $col[1] == 'due_date') { $originalValue = $temp_val[$x]; $dateTime = explode(' ', $originalValue); $temp_val[$x] = $dateTime[0]; } $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayDate(); } elseif ($col[4] == 'DT') { $comparator = array('e', 'n', 'b', 'a'); if (in_array($criteria['comparator'], $comparator)) { $originalValue = $temp_val[$x]; $dateTime = explode(' ', $originalValue); $temp_val[$x] = $dateTime[0]; } $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayDateTimeValue(); } else { $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayTime(); } } $advfilterval = implode(",", $val); } $criteria['value'] = Vtiger_Util_Helper::toSafeHTML(decode_html($advfilterval)); $criteria['column_condition'] = $relcriteriarow["column_condition"]; $groupId = $relcriteriarow['groupid']; $advft_criteria[$groupId]['columns'][$j] = $criteria; $advft_criteria[$groupId]['condition'] = $groupCondition; $j++; } if (!empty($advft_criteria[$groupId]['columns'][$j - 1]['column_condition'])) { $advft_criteria[$groupId]['columns'][$j - 1]['column_condition'] = ''; } $i++; } // Clear the condition (and/or) for last group, if any. if (!empty($advft_criteria[$i - 1]['condition'])) { $advft_criteria[$i - 1]['condition'] = ''; } return $advft_criteria; }
/** * * @global Users $current_user * @param ReportRun $report * @param Array $picklistArray * @param ADOFieldObject $dbField * @param Array $valueArray * @param String $fieldName * @return String */ function getReportFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName) { global $current_user, $default_charset; $db = PearDatabase::getInstance(); $value = $valueArray[$fieldName]; $fld_type = $dbField->type; list($module, $fieldLabel) = explode('__', $dbField->name, 2); $fieldInfo = getFieldByReportLabel($module, $fieldLabel); $fieldType = null; $fieldvalue = $value; if (!empty($fieldInfo)) { $field = WebserviceField::fromArray($db, $fieldInfo); $fieldType = $field->getFieldDataType(); } if ($fieldType == 'currency' && $value != '') { // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($field->getUIType() == '72') { $curid_value = explode("::", $value); $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); if ($value != '') { if ($dbField->name == 'Products_Unit_Price') { // need to do this only for Products Unit Price if ($currency_id != 1) { $currency_value = (double) $cur_sym_rate['rate'] * (double) $currency_value; } } $formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true); $fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']); } } else { $currencyField = new CurrencyField($value); $fieldvalue = $currencyField->getDisplayValue(); } } elseif ($dbField->name == "PriceBooks_Currency") { if ($value != '') { $fieldvalue = getTranslatedCurrencyString($value); } } elseif (in_array($dbField->name, $report->ui101_fields) && !empty($value)) { $entityNames = getEntityName('Users', $value); $fieldvalue = $entityNames[$value]; } elseif ($fieldType == 'date' && !empty($value)) { if ($module == 'Calendar' && $field->getFieldName() == 'due_date') { $endTime = $valueArray['calendar_end_time']; if (empty($endTime)) { $recordId = $valueArray['calendar_id']; $endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId); } $date = new DateTimeField($value . ' ' . $endTime); $fieldvalue = $date->getDisplayDate(); } else { if (!($field->getUIType() == '5')) { $date = new DateTimeField($fieldvalue); $fieldvalue = $date->getDisplayDateTimeValue(); } } } elseif ($fieldType == "datetime" && !empty($value)) { $date = new DateTimeField($value); $fieldvalue = $date->getDisplayDateTimeValue(); } elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours') { if ($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") { $date = new DateTimeField($value); $fieldvalue = $date->getDisplayTime(); } else { $userModel = Users_Privileges_Model::getCurrentUserModel(); if ($userModel->get('hour_format') == '12') { $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value); } $fieldvalue = $value; } } elseif ($fieldType == "picklist" && !empty($value)) { if (is_array($picklistArray)) { if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $fieldvalue = getTranslatedString($value, $module); } } else { $fieldvalue = getTranslatedString($value, $module); } } elseif ($fieldType == "multipicklist" && !empty($value)) { if (is_array($picklistArray[1])) { $valueList = explode(' |##| ', $value); $translatedValueList = array(); foreach ($valueList as $value) { if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) { $translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $translatedValueList[] = getTranslatedString($value, $module); } } } if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) { $fieldvalue = str_replace(' |##| ', ', ', $value); } else { implode(', ', $translatedValueList); } } elseif ($fieldType == 'double') { if ($current_user->truncate_trailing_zeros == true) { $fieldvalue = decimalFormat($fieldvalue); } } elseif ($fieldType == 'boolean') { if (strtolower($value) === 'yes' || strtolower($value) === 'on' || $value == 1) { $fieldvalue = vtranslate('LBL_YES'); } else { $fieldvalue = vtranslate('LBL_NO'); } } elseif ($field && $field->getUIType() == 117 && $value != '') { if ($value != '0') { $currencyList = Settings_Currency_Record_Model::getAll(); $fieldvalue = $currencyList[$value]->getName() . ' (' . $currencyList[$value]->get('currency_symbol') . ')'; } else { $fieldvalue = '-'; } } if ('vtiger_crmentity' == $dbField->table && false != strpos($dbField->name, 'Share__with__users')) { if ($value) { $listId = explode(',', $value); $usersSqlFullName = getSqlForNameInDisplayFormat(['first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'], 'Users'); $getListUserSql = "select {$usersSqlFullName} as uname from vtiger_users WHERE id IN (" . generateQuestionMarks($listId) . ') '; $getListUserResult = $db->pquery($getListUserSql, array($listId), TRUE); $fieldvalue = ''; $finalList = array(); $listUsers = $getListUserResult->GetAll(); for ($i = 0; $i < count($listUsers); $i++) { $finalList[] = $listUsers[$i][0]; } $fieldvalue = implode(', ', $finalList); } } if ($fieldvalue == "") { return "-"; } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); $fieldvalue = decode_html($fieldvalue); if (stristr($fieldvalue, "|##|") && empty($fieldType)) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } elseif ($fld_type == "date" && empty($fieldType)) { $fieldvalue = DateTimeField::convertToUserFormat($fieldvalue); } elseif ($fld_type == "datetime" && empty($fieldType)) { $date = new DateTimeField($fieldvalue); $fieldvalue = $date->getDisplayDateTimeValue(); } // Added to render html tag for description fields if ($fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) { return $fieldvalue; } return htmlentities($fieldvalue, ENT_QUOTES, $default_charset); }
$cbsubject = $focus->column_fields['subject']; $cbactivitytype = $focus->column_fields['activitytype']; $cbdate = $focus->column_fields["date_start"]; $cbtime = $focus->column_fields["time_start"]; } else { // For non-calendar records. $cbsubject = array_values(getEntityName($cbmodule, $cbrecord)); $cbsubject = $cbsubject[0]; $cbactivitytype = getTranslatedString($cbmodule, $cbmodule); $cbdate = $adb->query_result($result, $index, 'date_start'); $cbtime = $adb->query_result($result, $index, 'time_start'); } if ($cbtime != '') { $date = new DateTimeField($cbdate . ' ' . $cbtime); $cbtime = $date->getDisplayTime(); $cbdate = $date->getDisplayDate(); $cbtimeArr = getaddEventPopupTime($cbtime, '', 'am/pm'); $cbtime = $cbtimeArr['starthour'] . ':' . $cbtimeArr['startmin'] . '' . $cbtimeArr['startfmt']; } if ($cbactivitytype == 'Task') { $cbstatus = $focus->column_fields["taskstatus"]; } else { $cbstatus = $focus->column_fields["eventstatus"]; } $cbstatus = getTranslatedString($cbstatus, $currentModule); $actType = $adb->query_result($adb->pquery('select activitytype from vtiger_activity where activityid=?', array($cbrecord)), 0, 'activitytype'); $smarty->assign("activityimage", $actType); $cbactivitytype = getTranslatedString($cbactivitytype, $currentModule); // Appending recordid we can get unique callback dom id for that record. $popupid = "ActivityReminder_{$cbrecord}"; if ($cbdate <= date('Y-m-d')) {
function vtTaskEdit($adb, $request, $current_language, $app_strings) { global $theme; $util = new VTWorkflowUtils(); $request = vtlib_purify($request); // this cleans all values of the array $image_path = "themes/{$theme}/images/"; $module = new VTWorkflowApplication('edittask'); $mod = return_module_language($current_language, $module->name); if (!$util->checkAdminAccess()) { $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']); $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']); return; } $smarty = new vtigerCRM_Smarty(); $tm = new VTTaskManager($adb); $smarty->assign('edit', isset($request["task_id"])); if (isset($request["task_id"])) { $task = $tm->retrieveTask($request["task_id"]); $taskClass = get_class($task); $workflowId = $task->workflowId; } else { $workflowId = $request["workflow_id"]; $taskClass = vtlib_purifyForSql($request["task_type"]); $task = $tm->createTask($taskClass, $workflowId); } if ($task == null) { $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_TASK']); $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_TASK']); return; } $wm = new VTWorkflowManager($adb); $workflow = $wm->retrieve($workflowId); if ($workflow == null) { $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_WORKFLOW']); $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_WORKFLOW']); return; } $smarty->assign("workflow", $workflow); $smarty->assign("returnUrl", $request["return_url"]); $smarty->assign("task", $task); $smarty->assign("taskType", $taskClass); $smarty->assign("saveType", $request['save_type']); $taskTypeInstance = VTTaskType::getInstanceFromTaskType($taskClass); $taskTemplateClass = $tm->retrieveTemplatePath($module->name, $taskTypeInstance); $smarty->assign("taskTemplate", $taskTemplateClass); $et = VTWSEntityType::usingGlobalCurrentUser($workflow->moduleName); $smarty->assign("entityType", $et); $smarty->assign('entityName', $workflow->moduleName); $smarty->assign("fieldNames", $et->getFieldNames()); $repeat_date = $task->calendar_repeat_limit_date; if (!empty($repeat_date)) { $repeat_date = DateTimeField::convertToUserFormat($repeat_date); } $smarty->assign('REPEAT_DATE', $repeat_date); $dateFields = array(); $fieldTypes = $et->getFieldTypes(); $fieldLabels = $et->getFieldLabels(); foreach ($fieldTypes as $name => $type) { if ($type->type == 'Date' || $type->type == 'DateTime') { $dateFields[$name] = $fieldLabels[$name]; } } $smarty->assign('dateFields', $dateFields); if ($task->trigger != null) { $trigger = $task->trigger; $days = $trigger['days']; if ($days < 0) { $days *= -1; $direction = 'before'; } else { $direction = 'after'; } $smarty->assign('trigger', array('days' => $days, 'direction' => $direction, 'field' => $trigger['field'])); } $metaVariables = $task->getMetaVariables(); $date = new DateTimeField(null); $time = substr($date->getDisplayTime(), 0, 5); $smarty->assign("META_VARIABLES", $metaVariables); $smarty->assign("SYSTEM_TIMEZONE", $db_timezone); $smarty->assign("USER_TIME", $task->formatTimeForTimePicker($time)); $smarty->assign("USER_DATE", $date->getDisplayDate()); $smarty->assign("MOD", array_merge(return_module_language($current_language, 'Settings'), return_module_language($current_language, 'Calendar'), return_module_language($current_language, $module->name))); $smarty->assign("APP", $app_strings); $smarty->assign("dateFormat", parse_calendardate($app_strings['NTC_DATE_FORMAT'])); $smarty->assign("IMAGE_PATH", $image_path); $smarty->assign("THEME", $theme); $smarty->assign("MODULE_NAME", $module->label); $smarty->assign("PAGE_NAME", $mod['LBL_EDIT_TASK']); $smarty->assign("PAGE_TITLE", $mod['LBL_EDIT_TASK_TITLE']); $users = $group = array(); $users['user'] = get_user_array(); $users['group'] = get_group_array(); $smarty->assign('ASSIGNED_TO', $users); $smarty->assign("module", $module); $smarty->display("{$module->name}/EditTask.tpl"); }
function getAdvancedFilterList($reportid) { global $adb; global $modules; global $log; global $current_user; $advft_criteria = array(); $sql = 'SELECT * FROM vtiger_relcriteria_grouping WHERE queryid = ? ORDER BY groupid'; $groupsresult = $adb->pquery($sql, array($reportid)); $i = 1; $j = 0; while ($relcriteriagroup = $adb->fetch_array($groupsresult)) { $groupId = $relcriteriagroup["groupid"]; $groupCondition = $relcriteriagroup["group_condition"]; $ssql = 'select vtiger_relcriteria.* from vtiger_report inner join vtiger_relcriteria on vtiger_relcriteria.queryid = vtiger_report.queryid left join vtiger_relcriteria_grouping on vtiger_relcriteria.queryid = vtiger_relcriteria_grouping.queryid and vtiger_relcriteria.groupid = vtiger_relcriteria_grouping.groupid'; $ssql .= " where vtiger_report.reportid = ? AND vtiger_relcriteria.groupid = ? order by vtiger_relcriteria.columnindex"; $result = $adb->pquery($ssql, array($reportid, $groupId)); $noOfColumns = $adb->num_rows($result); if ($noOfColumns <= 0) { continue; } while ($relcriteriarow = $adb->fetch_array($result)) { $columnIndex = $relcriteriarow["columnindex"]; $criteria = array(); $criteria['columnname'] = $relcriteriarow["columnname"]; $criteria['comparator'] = $relcriteriarow["comparator"]; $advfilterval = $relcriteriarow["value"]; $col = explode(":", $relcriteriarow["columnname"]); $moduleFieldLabel = $col[2]; $fieldName = $col[3]; list($module, $fieldLabel) = explode('__', $moduleFieldLabel, 2); $fieldInfo = getFieldByReportLabel($module, $fieldLabel); $fieldType = null; if (!empty($fieldInfo)) { $field = WebserviceField::fromArray($adb, $fieldInfo); $fieldType = $field->getFieldDataType(); } if ($fieldType == 'currency') { if ($field->getUIType() == '71') { $advfilterval = CurrencyField::convertToUserFormat($advfilterval, $current_user); } else { if ($field->getUIType() == '72') { $advfilterval = CurrencyField::convertToUserFormat($advfilterval, $current_user, true); } } } $temp_val = explode(",", $relcriteriarow["value"]); if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') { $val = array(); for ($x = 0; $x < count($temp_val); $x++) { if ($col[4] == 'D') { $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayDate(); } elseif ($col[4] == 'DT') { $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayDateTimeValue(); } else { $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayTime(); } } $advfilterval = implode(",", $val); } //In vtiger6 report filter conditions, if the value has "(double quotes) then it is failed. $criteria['value'] = Vtiger_Util_Helper::toSafeHTML(decode_html($advfilterval)); $criteria['column_condition'] = $relcriteriarow["column_condition"]; $advft_criteria[$relcriteriarow['groupid']]['columns'][$j] = $criteria; $advft_criteria[$relcriteriarow['groupid']]['condition'] = $groupCondition; $j++; } $i++; } // Clear the condition (and/or) for last group, if any. if (!empty($advft_criteria[$i - 1]['condition'])) { $advft_criteria[$i - 1]['condition'] = ''; } $this->advft_criteria = $advft_criteria; $log->info("Reports :: Successfully returned getAdvancedFilterList"); return true; }
$invites = true; } $list_query = getCalendar4YouListQuery($userid, $invites); if ($viewid != "0") { $list_query = $oCustomView->getModifiedCvListQuery($viewid, $list_query, "Calendar"); } if (isset($where) && $where != '') { if (isset($_REQUEST['from_homepagedb']) && $_REQUEST['from_homepagedb'] == 'true') { $list_query .= " and ((vtiger_activity.status!='Completed' and vtiger_activity.status!='Deferred') or vtiger_activity.status is null) and ((vtiger_activity.eventstatus!='Held' and vtiger_activity.eventstatus!='Not Held') or vtiger_activity.eventstatus is null) AND " . $where; } else { $list_query .= " AND " . $where; } } if (isset($_REQUEST['from_homepage'])) { $dbStartDateTime = new DateTimeField(date('Y-m-d H:i:s')); $userStartDate = $dbStartDateTime->getDisplayDate(); $userStartDateTime = new DateTimeField($userStartDate . ' 00:00:00'); $startDateTime = $userStartDateTime->getDBInsertDateTimeValue(); $userEndDateTime = new DateTimeField($userStartDate . ' 23:59:00'); $endDateTime = $userEndDateTime->getDBInsertDateTimeValue(); if ($_REQUEST['from_homepage'] == 'upcoming_activities') { $list_query .= " AND (vtiger_activity.status is NULL OR vtiger_activity.status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus not in ('Held','Not Held')) AND (CAST((CONCAT(date_start,' ',time_start)) AS DATETIME) >= '{$startDateTime}' OR CAST((CONCAT(vtiger_recurringevents.recurringdate,' ',time_start)) AS DATETIME) >= '{$startDateTime}')"; } elseif ($_REQUEST['from_homepage'] == 'pending_activities') { $list_query .= " AND (vtiger_activity.status is NULL OR vtiger_activity.status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus not in ('Held','Not Held')) AND (CAST((CONCAT(due_date,' ',time_end)) AS DATETIME) <= '{$endDateTime}' OR CAST((CONCAT(vtiger_recurringevents.recurringdate,' ',time_start)) AS DATETIME) <= '{$endDateTime}')"; } } if (isset($order_by) && $order_by != '') { if ($order_by == 'smownerid') { $list_query .= ' ORDER BY user_name ' . $sorder; } else { $tablename = getTableNameForField('Calendar', $order_by);
if (isset($_REQUEST['month']) && is_numeric(vtlib_purify($_REQUEST['month']))) { $date_data['month'] = vtlib_purify($_REQUEST['month']); } if (isset($_REQUEST['week']) && is_numeric(vtlib_purify($_REQUEST['week']))) { $date_data['week'] = vtlib_purify($_REQUEST['week']); } if (isset($_REQUEST['year']) && is_numeric(vtlib_purify($_REQUEST['year']))) { if ($_REQUEST['year'] > 2037 || $_REQUEST['year'] < 1970) { print "<font color='red'>" . $app_strings['LBL_CAL_LIMIT_MSG'] . "</font>"; exit; } $date_data['year'] = vtlib_purify($_REQUEST['year']); } if (empty($date_data)) { $dateTimeField = new DateTimeField(''); $dateValue = $dateTimeField->getDisplayDate(); $timeValue = $dateTimeField->getDisplayTime(); $dbDateValue = DateTimeField::convertToDBFormat($dateValue); $dateValueArray = explode('-', $dbDateValue); $timeValueArray = explode(':', $timeValue); $date_data = array('day' => $dateValueArray[2], 'month' => $dateValueArray[1], 'year' => $dateValueArray[0], 'hour' => $timeValueArray[0], 'min' => $timeValueArray[1]); } $calendar_arr['calendar'] = new Calendar($mysel, $date_data); if ($current_user->hour_format != '') { $calendar_arr['calendar']->hour_format = $current_user->hour_format; } if ($viewBox == 'hourview' && ($mysel == 'day' || $mysel == 'week' || $mysel == 'month' || $mysel == 'year')) { $calendar_arr['calendar']->add_Activities($current_user); } $calendar_arr['view'] = $mysel; calendar_layout($calendar_arr, $viewBox, $subtab);
function getSearch_criteria($criteria, $searchstring, $searchfield) { global $log; $log->debug("Entering getSearch_criteria(" . $criteria . "," . $searchstring . "," . $searchfield . ") method ..."); $searchstring = ltrim(rtrim($searchstring)); if ($searchfield != "vtiger_troubletickets.update_log" && ($searchfield == "vtiger_crmentity.modifiedtime" || $searchfield == "vtiger_crmentity.createdtime" || stristr($searchfield, 'date'))) { if ($search_string != '' && $search_string != '0000-00-00') { $date = new DateTimeField($search_string); $value = $date->getDisplayDate(); if (strpos($search_string, ' ') > -1) { $value .= ' ' . $date->getDisplayTime(); } } else { $value = $search_string; } } if ($searchfield == "vtiger_account.parentid") { $searchfield = "vtiger_account2.accountname"; } if ($searchfield == "vtiger_pricebook.currency_id" || $searchfield == "vtiger_quotes.currency_id" || $searchfield == "vtiger_invoice.currency_id" || $searchfield == "vtiger_purchaseorder.currency_id" || $searchfield == "vtiger_salesorder.currency_id") { $searchfield = "vtiger_currency_info.currency_name"; } $where_string = ''; switch ($criteria) { case 'cts': $where_string = $searchfield . " like '" . formatForSqlLike($searchstring) . "' "; if ($searchstring == NULL) { $where_string = "(" . $searchfield . " like '' or " . $searchfield . " is NULL)"; } break; case 'dcts': if ($searchfield == "vtiger_users.user_name" || $searchfield == "vtiger_groups.groupname") { $where_string = "(" . $searchfield . " not like '" . formatForSqlLike($searchstring) . "')"; } else { $where_string = "(" . $searchfield . " not like '" . formatForSqlLike($searchstring) . "' or " . $searchfield . " is null)"; } if ($searchstring == NULL) { $where_string = "(" . $searchfield . " not like '' or " . $searchfield . " is not NULL)"; } break; case 'is': $where_string = $searchfield . " = '" . $searchstring . "' "; if ($searchstring == NULL) { $where_string = "(" . $searchfield . " is NULL or " . $searchfield . " = '')"; } break; case 'isn': if ($searchfield == "vtiger_users.user_name" || $searchfield == "vtiger_groups.groupname") { $where_string = "(" . $searchfield . " <> '" . $searchstring . "')"; } else { $where_string = "(" . $searchfield . " <> '" . $searchstring . "' or " . $searchfield . " is null)"; } if ($searchstring == NULL) { $where_string = "(" . $searchfield . " not like '' and " . $searchfield . " is not NULL)"; } break; case 'bwt': $where_string = $searchfield . " like '" . formatForSqlLike($searchstring, 2) . "' "; break; case 'ewt': $where_string = $searchfield . " like '" . formatForSqlLike($searchstring, 1) . "' "; break; case 'grt': $where_string = $searchfield . " > '" . $searchstring . "' "; break; case 'lst': $where_string = $searchfield . " < '" . $searchstring . "' "; break; case 'grteq': $where_string = $searchfield . " >= '" . $searchstring . "' "; break; case 'lsteq': $where_string = $searchfield . " <= '" . $searchstring . "' "; break; } $log->debug("Exiting getSearch_criteria method ..."); return $where_string; }
static function currentUserDisplayDateNew() { $current_user = vglobal('current_user'); $date = new DateTimeField(null); return $date->getDisplayDate($current_user); }
function getTopSalesOrderSearch($output) { global $current_user; $currentDateTime = new DateTimeField(date('Y-m-d H:i:s')); $output['query'] = 'true'; $output['searchtype'] = 'advance'; $advft_criteria_groups = array('1' => array('groupcondition' => null)); $advft_criteria = array(array('groupid' => 1, 'columnname' => 'vtiger_salesorder:duedate:duedate:SalesOrder_Due_Date:D', 'comparator' => 'h', 'value' => $currentDateTime->getDisplayDate(), 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_crmentity:smownerid:assigned_user_id:SalesOrder_Assigned_To:V', 'comparator' => 'e', 'value' => getFullNameFromArray('Users', $current_user->column_fields), 'columncondition' => null)); $output['advft_criteria'] = Zend_Json::encode($advft_criteria); $output['advft_criteria_groups'] = Zend_Json::encode($advft_criteria_groups); return $output; }