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 to get display value for time * @param <String> time * @return <String> time */ public static function getDisplayTimeValue($time) { global $log; $log->debug("Entering ./uitypes/Time.php::staticgetDisplayTimeValue"); $date = new DateTimeField($time); return $date->getDisplayTime(); }
/** * Function to get the calendar event call duration value in hour format * @param type $fieldName * @param type $value * @return <Vtiger_Time_UIType> - getTimeValue */ public function getDisplayTimeDifferenceValue($fieldName, $value) { $userModel = Users_Privileges_Model::getCurrentUserModel(); $date = new DateTime($value); //No need to set the time zone as DateTimeField::getDisplayTime API is already doing this /*if(empty($value)) { $timeZone = $userModel->get('time_zone'); $targetTimeZone = new DateTimeZone($timeZone); $date->setTimezone($targetTimeZone); }*/ if ($fieldName == 'time_end' && empty($value)) { $date->modify("+15 minutes"); } $dateTimeField = new DateTimeField($date->format('Y-m-d H:i:s')); $value = $dateTimeField->getDisplayTime(); return $value; }
/** * Function to get the calendar event call duration value in hour format * @param type $fieldName * @param type $value * @return <Vtiger_Time_UIType> - getTimeValue */ public function getDisplayTimeDifferenceValue($fieldName, $value) { $userModel = Users_Privileges_Model::getCurrentUserModel(); $date = new DateTime($value); //No need to set the time zone as DateTimeField::getDisplayTime API is already doing this /*if(empty($value)) { $timeZone = $userModel->get('time_zone'); $targetTimeZone = new DateTimeZone($timeZone); $date->setTimezone($targetTimeZone); }*/ if ($fieldName == 'time_end' && empty($value)) { $defaultCallDuration = $userModel->get('callduration'); $date->modify("+{$defaultCallDuration} minutes"); } $dateTimeField = new DateTimeField($date->format('Y-m-d H:i:s')); $value = $dateTimeField->getDisplayTime(); if ($userModel->get('hour_format') == '12') { return Vtiger_Time_UIType::getTimeValueInAMorPM($value); } return $value; }
/** to get the Advanced filter for the given customview Id * @param $cvid :: Type Integer * @returns $advfilterlist Array */ function getAdvFilterByCvid($cvid) { global $adb, $log, $default_charset, $current_user, $currentModule, $mod_strings; $advft_criteria = array(); $sql = 'SELECT * FROM vtiger_cvadvfilter_grouping WHERE cvid = ? ORDER BY groupid'; $groupsresult = $adb->pquery($sql, array($cvid)); $i = 1; $j = 0; while ($relcriteriagroup = $adb->fetch_array($groupsresult)) { $groupId = $relcriteriagroup["groupid"]; $groupCondition = $relcriteriagroup["group_condition"]; $ssql = 'select vtiger_cvadvfilter.* from vtiger_customview inner join vtiger_cvadvfilter on vtiger_cvadvfilter.cvid = vtiger_customview.cvid left join vtiger_cvadvfilter_grouping on vtiger_cvadvfilter.cvid = vtiger_cvadvfilter_grouping.cvid and vtiger_cvadvfilter.groupid = vtiger_cvadvfilter_grouping.groupid'; $ssql .= " where vtiger_customview.cvid = ? AND vtiger_cvadvfilter.groupid = ? order by vtiger_cvadvfilter.columnindex"; $result = $adb->pquery($ssql, array($cvid, $groupId)); $noOfColumns = $adb->num_rows($result); if ($noOfColumns <= 0) { continue; } while ($relcriteriarow = $adb->fetch_array($result)) { $columnIndex = $relcriteriarow["columnindex"]; $criteria = array(); $criteria['columnname'] = html_entity_decode($relcriteriarow["columnname"], ENT_QUOTES, $default_charset); $criteria['comparator'] = $relcriteriarow["comparator"]; $advfilterval = html_entity_decode($relcriteriarow["value"], ENT_QUOTES, $default_charset); $col = explode(":", $relcriteriarow["columnname"]); $uitype_value = getUItypeByFieldName($this->customviewmodule, $col[2]); if ($uitype_value == '15' || $uitype_value == '16' || $uitype_value == '33') { if (!isValueInPicklist($advfilterval, $col[2])) { $advfilterval = getTranslationKeyFromTranslatedValue($this->customviewmodule, $advfilterval); } } $temp_val = explode(",", $relcriteriarow["value"]); if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') { $val = array(); for ($x = 0; $x < count($temp_val); $x++) { if ($col[4] == 'D') { $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayDate(); } elseif ($col[4] == 'DT') { $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayDateTimeValue(); } else { $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayTime(); } } $advfilterval = implode(",", $val); } if (($col[1] == 'smownerid' || $col[1] == 'smcreatorid' || $col[1] == 'modifiedby') && $advfilterval == 'current_user' && $_REQUEST['action'] != 'CustomView' && empty($_REQUEST['record'])) { $advfilterval = trim($current_user->first_name . ' ' . $current_user->last_name); } $criteria['value'] = $advfilterval; $criteria['column_condition'] = $relcriteriarow["column_condition"]; $advft_criteria[$i]['columns'][$j] = $criteria; $advft_criteria[$i]['condition'] = $groupCondition; $j++; } if (!empty($advft_criteria[$i]['columns'][$j - 1]['column_condition'])) { $advft_criteria[$i]['columns'][$j - 1]['column_condition'] = ''; } $i++; } // Clear the condition (and/or) for last group, if any. if (!empty($advft_criteria[$i - 1]['condition'])) { $advft_criteria[$i - 1]['condition'] = ''; } return $advft_criteria; }
/** * * @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); }
$selectedcolumns[] = $sort_by3; }*/ } //<<<<<<<reportmodules>>>>>>>>> // vtlib_getModuleNameById() $pmodule = vtlib_purify($_REQUEST["primarymodule"]); $smodule = vtlib_purify(trim($_REQUEST["secondarymodule"], ":")); //<<<<<<<reportmodules>>>>>>>>> //<<<<<<<standarfilters>>>>>>>>> $stdDateFilterField = vtlib_purify($_REQUEST["stdDateFilterField"]); $stdDateFilter = vtlib_purify($_REQUEST["stdDateFilter"]); $startdate = vtlib_purify($_REQUEST["startdate"]); $enddate = vtlib_purify($_REQUEST["enddate"]); $dbCurrentDateTime = new DateTimeField(date('Y-m-d H:i:s')); if (!empty($startdate)) { $startDateTime = new DateTimeField($startdate . ' ' . $dbCurrentDateTime->getDisplayTime()); $startdate = $startDateTime->getDBInsertDateValue(); } if (!empty($enddate)) { $endDateTime = new DateTimeField($enddate . ' ' . $dbCurrentDateTime->getDisplayTime()); $enddate = $endDateTime->getDBInsertDateValue(); } //<<<<<<<standardfilters>>>>>>>>> //<<<<<<<shared entities>>>>>>>>> $sharetype = vtlib_purify($_REQUEST["sharing"]); $shared_entities = vtlib_purify($_REQUEST["sharingSelectedColumnsString"]); //<<<<<<<shared entities>>>>>>>>> //<<<<<<<columnstototal>>>>>>>>>> if (isset($_REQUEST["curl_to_go"]) && $_REQUEST["curl_to_go"] != "") { $columnstototal = explode('$_@_$', $_REQUEST["curl_to_go"]); /*$allKeys = array_keys($_REQUEST);
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; }
/** * 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; }
/** 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 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; }
/** * 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; }
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; }
$htmlStr .= '<span id="task_assign_team" style="' . $style_group . '"> <select name="task_assigned_group_id" class=small>'; } else { $htmlStr .= '<span id="assign_team" style="' . $style_group . '"> <select name="assigned_group_id" class=small>'; } $htmlStr .= getGroupslist(); $htmlStr .= '</select> </span>'; } return $htmlStr; } $date = new DateTimeField(null); $endDate = new DateTimeField(date("Y-m-d H:i:s", time() + 1 * 24 * 60 * 60)); list($startYear, $startMonth, $startDay) = DateTimeField::convertToDBFormat($date->getDisplayDate()); list($startHour, $startMin) = explode(':', $date->getDisplayTime()); list($startYear, $startMonth, $startDay) = DateTimeField::convertToDBFormat($date->getDisplayDate()); list($startHour, $startMin) = explode(':', $date->getDisplayTime()); ?> <!-- Add Event DIV starts--> <link rel="stylesheet" type="text/css" media="all" href="jscalendar/calendar-win2k-cold-1.css"> <script type="text/javascript" src="jscalendar/calendar.js"></script> <script type="text/javascript" src="jscalendar/lang/calendar-<?php echo $app_strings['LBL_JSCALENDAR_LANG']; ?> .js"></script> <script type="text/javascript" src="jscalendar/calendar-setup.js"></script> <script type="text/javascript" src="include/js/ListView.js"></script> <div class="calAddEvent layerPopup" style="display:none;width:700px;left:200px;" id="addEvent" align=center> <form name="EditView" onSubmit="if(check_form()) { VtigerJS_DialogBox.block(); } else { return false; }" method="POST" action="index.php">
function getActivityMailInfo($return_id, $status, $activity_type) { $mail_data = array(); global $adb; $qry = "select * from vtiger_activity where activityid=?"; $ary_res = $adb->pquery($qry, array($return_id)); $send_notification = $adb->query_result($ary_res, 0, "sendnotification"); $subject = $adb->query_result($ary_res, 0, "subject"); $priority = $adb->query_result($ary_res, 0, "priority"); $st_date = $adb->query_result($ary_res, 0, "date_start"); $st_time = $adb->query_result($ary_res, 0, "time_start"); $end_date = $adb->query_result($ary_res, 0, "due_date"); $end_time = $adb->query_result($ary_res, 0, "time_end"); $location = $adb->query_result($ary_res, 0, "location"); if (!empty($st_time)) { $date = new DateTimeField($st_date . ' ' . $st_time); $st_date = $date->getDisplayDate(); $st_time = $date->getDisplayTime(); } if (!empty($end_time)) { $date = new DateTimeField($end_date . ' ' . $end_time); $end_date = $date->getDisplayDate(); $end_time = $date->getDisplayTime(); } $owner_qry = "select smownerid from vtiger_crmentity where crmid=?"; $res = $adb->pquery($owner_qry, array($return_id)); $owner_id = $adb->query_result($res, 0, "smownerid"); $usr_res = $adb->pquery("select count(*) as count from vtiger_users where id=?", array($owner_id)); if ($adb->query_result($usr_res, 0, 'count') > 0) { $assignType = "U"; $usr_id = $owner_id; } else { $assignType = "T"; $group_qry = "select groupname from vtiger_groups where groupid=?"; $grp_res = $adb->pquery($group_qry, array($owner_id)); $grp_name = $adb->query_result($grp_res, 0, "groupname"); } $desc_qry = "select description from vtiger_crmentity where crmid=?"; $des_res = $adb->pquery($desc_qry, array($return_id)); $description = $adb->query_result($des_res, 0, "description"); $rel_qry = "select case vtiger_crmentity.setype when 'Leads' then vtiger_leaddetails.lastname when 'Accounts' then vtiger_account.accountname when 'Potentials' then vtiger_potential.potentialname when 'Quotes' then vtiger_quotes.subject when 'PurchaseOrder' then vtiger_purchaseorder.subject when 'SalesOrder' then vtiger_salesorder.subject when 'Invoice' then vtiger_invoice.subject when 'Campaigns' then vtiger_campaign.campaignname when 'HelpDesk' then vtiger_troubletickets.title end as relname from vtiger_seactivityrel inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_seactivityrel.crmid left join vtiger_leaddetails on vtiger_leaddetails.leadid = vtiger_seactivityrel.crmid left join vtiger_account on vtiger_account.accountid=vtiger_seactivityrel.crmid left join vtiger_potential on vtiger_potential.potentialid=vtiger_seactivityrel.crmid left join vtiger_quotes on vtiger_quotes.quoteid= vtiger_seactivityrel.crmid left join vtiger_purchaseorder on vtiger_purchaseorder.purchaseorderid = vtiger_seactivityrel.crmid left join vtiger_salesorder on vtiger_salesorder.salesorderid = vtiger_seactivityrel.crmid left join vtiger_invoice on vtiger_invoice.invoiceid = vtiger_seactivityrel.crmid left join vtiger_campaign on vtiger_campaign.campaignid = vtiger_seactivityrel.crmid left join vtiger_troubletickets on vtiger_troubletickets.ticketid = vtiger_seactivityrel.crmid where vtiger_seactivityrel.activityid=?"; $rel_res = $adb->pquery($rel_qry, array($return_id)); $rel_name = $adb->query_result($rel_res, 0, "relname"); $relatedContacts = getActivityRelatedContacts($return_id); $mail_data['mode'] = "edit"; $mail_data['activity_mode'] = $activity_type; $mail_data['sendnotification'] = $send_notification; $mail_data['user_id'] = $usr_id; $mail_data['subject'] = $subject; $mail_data['status'] = $status; $mail_data['taskpriority'] = $priority; $mail_data['relatedto'] = $rel_name; $mail_data['contact_name'] = implode(',', $relatedContacts); $mail_data['description'] = $description; $mail_data['assign_type'] = $assignType; $mail_data['group_name'] = $grp_name; $value = getaddEventPopupTime($st_time, $end_time, '24'); $start_hour = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt']; if ($activity_type != 'Task') { $end_hour = $value['endhour'] . ':' . $value['endmin'] . '' . $value['endfmt']; } $date = new DateTimeField($st_date . " " . $start_hour); $endDate = new DateTimeField($end_date . " " . $end_hour); $mail_data['st_date_time'] = $date->getDBInsertDateTimeValue(); $mail_data['end_date_time'] = $endDate->getDBInsertDateValue() . ' ' . $endDate->getDBInsertTimeValue(); $mail_data['location'] = $location; return $mail_data; }
/** * Function creates HTML to display Todos ListView * @param array $todo_list - collection of strings(Todo Information) * @param array $cal - collection of objects and strings * return string $list_view - html tags in string format */ function constructTodoListView($todo_list, $cal, $subtab, $navigation_array = '') { global $mod_strings, $cal_log, $adb, $theme; $cal_log->debug("Entering constructTodoListView() method..."); global $current_user, $app_strings; $date_format = $current_user->date_format; $format = $cal['calendar']->hour_format; $date = new DateTimeField(null); $endDate = new DateTimeField(date("Y-m-d H:i:s", time() + 1 * 24 * 60 * 60)); $hour_startat = $date->getDisplayTime(); $hour_endat = $endDate->getDisplayTime(); $time_arr = getaddEventPopupTime($hour_startat, $hour_endat, $format); //to get date in user selected date format $temp_date = $date->getDisplayDate(); if ($cal['calendar']->day_start_hour != 23) { $endtemp_date = $temp_date; } else { $endtemp_date = $endDate->getDisplayDate(); } $list_view = ""; //labels of listview header if ($cal['view'] == 'day') { $colspan = 9; $header = array('0' => '#', '1' => $mod_strings['LBL_TIME'], '2' => $mod_strings['LBL_START_DATE'], '3' => $mod_strings['LBL_DUE_DATE'], '4' => $mod_strings['LBL_TODO']); $header_width = array('0' => '5%', '1' => '10%', '2' => '10%', '3' => '38%'); if (getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') { array_push($header, $mod_strings['LBL_STATUS']); array_push($header_width, '10%'); } if (isPermitted("Calendar", "EditView") == "yes" || isPermitted("Calendar", "Delete") == "yes") { array_push($header, $mod_strings['LBL_ACTION']); array_push($header_width, '10%'); } array_push($header, $mod_strings['LBL_ASSINGEDTO']); array_push($header_width, '15%'); } else { $colspan = 10; $header = array('0' => '#', '1' => $mod_strings['LBL_TIME'], '2' => $mod_strings['LBL_START_DATE'], '3' => $mod_strings['LBL_DUE_DATE'], '4' => $mod_strings['LBL_TODO']); $header_width = array('0' => '5%', '1' => '10%', '2' => '10%', '3' => '10%', '4' => '28%'); if (getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') { array_push($header, $mod_strings['LBL_STATUS']); array_push($header_width, '10%'); } if (isPermitted("Calendar", "EditView") == "yes" || isPermitted("Calendar", "Delete") == "yes") { array_push($header, $mod_strings['LBL_ACTION']); } array_push($header, $mod_strings['LBL_ASSINGEDTO']); array_push($header_width, '15%'); } if ($current_user->column_fields['is_admin'] == 'on') { $Res = $adb->pquery("select * from vtiger_activitytype", array()); } else { $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; array_push($roleids, $roleid); } else { $roleids = $roleid; } if (count($roleids) > 1) { $Res = $adb->pquery("select distinct activitytype from vtiger_activitytype inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_activitytype.picklist_valueid where roleid in (" . generateQuestionMarks($roleids) . ") and picklistid in (select picklistid from vtiger_picklist) order by sortid asc", array($roleids)); } else { $Res = $adb->pquery("select distinct activitytype from vtiger_activitytype inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_activitytype.picklist_valueid where roleid = ? and picklistid in (select picklistid from vtiger_picklist) order by sortid asc", array($roleid)); } } $eventlist = ''; for ($i = 0; $i < $adb->num_rows($Res); $i++) { $eventlist .= $adb->query_result($Res, $i, 'activitytype') . ";"; } $list_view .= "<table align='center' border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t\t<tr><td colspan='3'> </td></tr>"; //checking permission for Create/Edit Operation if (isPermitted("Calendar", "EditView") == "yes") { $list_view .= "<tr>\n\t\t\t\t<td class='calAddButton' onMouseOver='fnAddEvent(this,\"addEventDropDown\",\"" . $temp_date . "\",\"" . $endtemp_date . "\",\"" . $time_arr['starthour'] . "\",\"" . $time_arr['startmin'] . "\",\"" . $time_arr['startfmt'] . "\",\"" . $time_arr['endhour'] . "\",\"" . $time_arr['endmin'] . "\",\"" . $time_arr['endfmt'] . "\",\"\",\"" . $subtab . "\",\"" . $eventlist . "\");'style='border: 1px solid #666666;cursor:pointer;height:30px' align='center' width='10%'>\n " . $mod_strings['LBL_ADD'] . "\n <img src='" . vtiger_imageurl('menuDnArrow.gif', $theme) . "' style='padding-left: 5px;' border='0'> </td>"; } else { $list_view .= "<tr><td> </td>"; } $list_view .= "<td align='center' width='60%'><span id='total_activities'>" . getTodoInfo($cal, 'listcnt') . "</span> </td>\n\t\t\t\t<td align='right' width='28%'> </td>\n\t\t\t</tr>\n\t\t</table>\n\n\t\t\t<br><table style='background-color: rgb(204, 204, 204);' class='small' align='center' border='0' cellpadding='5' cellspacing='1' width='98%'>\n "; $header_rows = count($header); $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string, "Calendar", "index"); if ($navigationOutput != '') { $list_view .= "<tr width=100% bgcolor=white><td align=center colspan={$header_rows}>"; $list_view .= "<table align=center width='98%'><tr>" . $navigationOutput . "</tr></table></td></tr>"; } $list_view .= "<tr>"; for ($i = 0; $i < $header_rows; $i++) { $list_view .= "<td class='lvtCol' width='" . $header_width[$i] . "' nowrap='nowrap'>" . $header[$i] . "</td>"; } $list_view .= "</tr>"; $rows = count($todo_list); if ($rows != 0) { for ($i = 0; $i < count($todo_list); $i++) { $list_view .= "<tr style='height: 25px;' bgcolor='white'>"; foreach ($todo_list[$i] as $key => $entry) { $list_view .= "<td>" . $entry . "</td>"; } $list_view .= "</tr>"; } } else { $list_view .= "<tr><td style='background-color:#efefef;height:340px' align='center' colspan='" . $colspan . "'>"; $list_view .= "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 45%; position: relative; z-index: 5000;'>\n\t\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t\t<tr>\n\t\t\t\t<td rowspan='2' width='25%'>\n\t\t\t\t\t<img src='" . vtiger_imageurl('empty.jpg', $theme) . "' height='60' width='61'></td>\n\t\t\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='75%'><span class='genHeaderSmall'>" . $app_strings['LBL_NO'] . " " . $app_strings['Todos'] . " " . $app_strings['LBL_FOUND'] . " !</span></td>\n\t\t\t</tr>\n\t\t\t<tr>"; //checking permission for Create/Edit Operation if (isPermitted("Calendar", "EditView") == "yes") { $list_view .= "<td class='small' align='left' nowrap='nowrap'>" . $app_strings['LBL_YOU_CAN_CREATE'] . " " . $app_strings['LBL_A'] . " " . $app_strings['Todo'] . " " . $app_strings['LBL_NOW'] . ". " . $app_strings['LBL_CLICK_THE_LINK'] . " :<br>\n\t\t\t\t\t -<a href='javascript:void(0);' onClick='gshow(\"createTodo\",\"todo\",\"" . $temp_date . "\",\"" . $temp_date . "\",\"" . $time_arr['starthour'] . "\",\"" . $time_arr['startmin'] . "\",\"" . $time_arr['startfmt'] . "\",\"" . $time_arr['endhour'] . "\",\"" . $time_arr['endmin'] . "\",\"" . $time_arr['endfmt'] . "\",\"listview\",\"todo\");'>" . $app_strings['LBL_CREATE'] . " " . $app_strings['LBL_A'] . " " . $app_strings['Todo'] . "</a>\n\t\t\t\t\t</td>"; } else { $list_view .= "<td class='small' align='left' nowrap='nowrap'>" . $app_strings['LBL_YOU_ARE_NOT_ALLOWED_TO_CREATE'] . " " . $app_strings['LBL_A'] . " " . $app_strings['Todo'] . "<br></td>"; } $list_view .= "</tr>\n\t\t\t</table>\n\t\t\t</div>"; $list_view .= "</td></tr>"; } $list_view .= "</table><br>"; $cal_log->debug("Exiting constructTodoListView() method..."); return $list_view; }
/** * Function to get display value for time * @param <String> time * @return <String> time */ public static function getDisplayTimeValue($time) { $date = new DateTimeField($time); return $date->getDisplayTime(); }
/** * this function processes the given result and returns the value :: for now we are getting the values for the * reference, owner fields, booleans and currency fields; other processing might be added later if required * @param array $result - the webservices result object * @param array $descObj - the webservices describe object * @return array $result - the processes webservices result object */ function vttooltip_processResult($result, $descObj) { global $current_user; foreach ($descObj['fields'] as $field) { $name = $field['name']; $value = $result[0][$name]; if ($field['type']['name'] == 'reference') { $name = $field['name']; if (!empty($value)) { $result[0][$name] = vtws_getName($value, $current_user); } else { $result[0][$name] = ''; } } elseif ($field['type']['name'] == 'owner') { list($info, $id) = explode("x", $value); $result[0][$name] = getOwnerName($id); } elseif ($field['type']['name'] == 'boolean') { if ($result[0][$name] == 1) { $result[0][$name] = "on"; } else { $result[0][$name] = "off"; } } elseif ($field['type']['name'] == 'picklist') { $temp = ''; foreach ($field['type']['picklistValues'] as $value) { if (strcmp($value['value'], $result[0][$name]) == 0) { $temp = $value['value']; } } $result[0][$name] = $temp; } elseif ($field['type']['name'] == 'date') { $result[0][$name] = DateTimeField::convertToUserFormat($value); } elseif ($field['type']['name'] == 'datetime') { $date = new DateTimeField($value); $result[0][$name] = $date->getDisplayDateTimeValue(); } elseif ($field['type']['name'] == 'time') { $date = new DateTimeField($value); $result[0][$name] = $date->getDisplayTime(); } elseif ($field['type']['name'] == 'currency') { $currencyField = new CurrencyField($value); $result[0][$name] = $currencyField->getDisplayValueWithSymbol(); } } return $result; }
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 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; }
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); }
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; }
/** to get the Advanced filter for the given customview Id * @param $cvid :: Type Integer * @returns $advfilterlist Array */ function getAdvFilterByCvid($cvid) { global $adb, $log, $default_charset; $advft_criteria = array(); $sql = 'SELECT * FROM vtiger_cvadvfilter_grouping WHERE cvid = ? ORDER BY groupid'; $groupsresult = $adb->pquery($sql, array($cvid)); $i = 1; $j = 0; while ($relcriteriagroup = $adb->fetch_array($groupsresult)) { $groupId = $relcriteriagroup["groupid"]; $groupCondition = $relcriteriagroup["group_condition"]; $ssql = 'select vtiger_cvadvfilter.* from vtiger_customview inner join vtiger_cvadvfilter on vtiger_cvadvfilter.cvid = vtiger_customview.cvid left join vtiger_cvadvfilter_grouping on vtiger_cvadvfilter.cvid = vtiger_cvadvfilter_grouping.cvid and vtiger_cvadvfilter.groupid = vtiger_cvadvfilter_grouping.groupid'; $ssql .= " where vtiger_customview.cvid = ? AND vtiger_cvadvfilter.groupid = ? order by vtiger_cvadvfilter.columnindex"; $result = $adb->pquery($ssql, array($cvid, $groupId)); $noOfColumns = $adb->num_rows($result); if ($noOfColumns <= 0) { continue; } while ($relcriteriarow = $adb->fetch_array($result)) { $columnIndex = $relcriteriarow["columnindex"]; $criteria = array(); $criteria['columnname'] = html_entity_decode($relcriteriarow["columnname"], ENT_QUOTES, $default_charset); $criteria['comparator'] = $relcriteriarow["comparator"]; $advfilterval = html_entity_decode($relcriteriarow["value"], ENT_QUOTES, $default_charset); $col = explode(":", $relcriteriarow["columnname"]); $temp_val = explode(",", $relcriteriarow["value"]); if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') { $val = array(); for ($x = 0; $x < count($temp_val); $x++) { if ($col[4] == 'D') { $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayDate(); } elseif ($col[4] == 'DT') { $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayDateTimeValue(); } else { $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayTime(); } } $advfilterval = implode(",", $val); } $criteria['value'] = $advfilterval; $criteria['column_condition'] = $relcriteriarow["column_condition"]; $advft_criteria[$i]['columns'][$j] = $criteria; $advft_criteria[$i]['condition'] = $groupCondition; $j++; } if (!empty($advft_criteria[$i]['columns'][$j - 1]['column_condition'])) { $advft_criteria[$i]['columns'][$j - 1]['column_condition'] = ''; } $i++; } // Clear the condition (and/or) for last group, if any. if (!empty($advft_criteria[$i - 1]['condition'])) { $advft_criteria[$i - 1]['condition'] = ''; } return $advft_criteria; }
function getAdvftCriteria($relcriteriarow) { $columnIndex = $relcriteriarow['columnindex']; $criteria = array(); $criteria['columnname'] = html_entity_decode($relcriteriarow["columnname"], ENT_QUOTES, $default_charset); $criteria['comparator'] = $relcriteriarow["comparator"]; $advfilterval = html_entity_decode($relcriteriarow["value"], ENT_QUOTES, $default_charset); $col = explode(":", $relcriteriarow["columnname"]); $temp_val = explode(",", $relcriteriarow["value"]); if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') { $val = array(); for ($x = 0; $x < count($temp_val); $x++) { if ($col[4] == 'D') { /** while inserting in db for due_date it was taking date and time values also as it is * date time field. We only need to take date from that value */ if ($col[0] == "vtiger_activity" && $col[1] == "due_date") { $values = explode(' ', $temp_val[$x]); $temp_val[$x] = $values[0]; } $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayDate(); } elseif ($col[4] == 'DT') { $comparator = array('e', 'n', 'b', 'a'); if (in_array($criteria['comparator'], $comparator)) { $originalValue = $temp_val[$x]; $dateTime = explode(' ', $originalValue); $temp_val[$x] = $dateTime[0]; } $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayDateTimeValue(); } else { $date = new DateTimeField(trim($temp_val[$x])); $val[$x] = $date->getDisplayTime(); } } $advfilterval = implode(",", $val); } $criteria['value'] = $advfilterval; $criteria['column_condition'] = $relcriteriarow["column_condition"]; return $criteria; }
$focus->retrieve_entity_info($cbrecord, $cbmodule); $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 (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 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; }
/** To read and set the events value in Appointment Obj * @param $act_array -- The vtiger_activity array :: Type Array * @param $view -- The calendar view :: Type String */ function readResult($act_array, $view) { global $adb, $current_user, $app_strings; $format_sthour = ''; $format_stmin = ''; $this->description = $act_array["description"]; $this->eventstatus = getRoleBasesdPickList('eventstatus', $act_array["eventstatus"]); $this->priority = getRoleBasesdPickList('taskpriority', $act_array["priority"]); $this->subject = $act_array["subject"]; $this->activity_type = $act_array["activitytype"]; $this->duration_hour = $act_array["duration_hours"]; $this->duration_minute = $act_array["duration_minutes"]; $this->creatorid = $act_array["smcreatorid"]; //$this->creator = getUserName($act_array["smcreatorid"]); $this->assignedto = $act_array["user_name"]; $this->owner = $act_array["user_name"]; if (!is_admin($current_user)) { if ($act_array["smownerid"] != 0 && $act_array["smownerid"] != $current_user->id && $act_array["visibility"] == "Public") { $que = "select * from vtiger_sharedcalendar where sharedid=? and userid=?"; $row = $adb->pquery($que, array($current_user->id, $act_array["smownerid"])); $no = $adb->getRowCount($row); if ($no > 0) { $this->shared = true; } } } $this->image_name = $act_array["activitytype"] . ".gif"; if (!empty($act_array["recurringid"]) && !empty($act_array["recurringtype"])) { $this->recurring = "Recurring.gif"; } $this->record = $act_array["activityid"]; $date = new DateTimeField($act_array["date_start"] . ' ' . $act_array['time_start']); $eventStartDate = DateTimeField::convertToDBFormat($date->getDisplayDate()); list($eventStartHour) = explode(':', $date->getDisplayTime()); list($styear, $stmonth, $stday) = explode("-", $act_array["date_start"]); list($sthour, $stmin) = explode(':', $act_array['time_start']); if ($act_array["notime"] != 1) { $st_hour = $eventStartHour; } else { $st_hour = 'notime'; $act_array["time_start"] = "00:00"; } list($eyear, $emonth, $eday) = explode("-", $act_array["due_date"]); list($end_hour, $end_min) = explode(":", $act_array['time_end']); $start_date_arr = array('min' => $stmin, 'hour' => $sthour, 'day' => $stday, 'month' => $stmonth, 'year' => $styear); $end_date_arr = array('min' => $end_min, 'hour' => $end_hour, 'day' => $eday, 'month' => $emonth, 'year' => $eyear); $this->start_time = new vt_DateTime($start_date_arr, true); $this->end_time = new vt_DateTime($end_date_arr, true); if ($view == 'day' || $view == 'week') { $this->formatted_datetime = DateTimeField::convertToUserFormat($eventStartDate) . ":" . $st_hour; } elseif ($view == 'year') { list($year, $month, $date) = explode("-", $eventStartDate); $this->formatted_datetime = $month; } else { $this->formatted_datetime = DateTimeField::convertToUserFormat($eventStartDate); } return; }
/** * 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 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; }