function replaceRelatedModuleFields($content, $module, $recordid, $fields, &$site_URL) { $db = PearDatabase::getInstance(); require_once 'include/utils/utils.php'; $userLang = Users_Record_Model::getCurrentUserModel()->get('language'); include "languages/" . $userLang . "/OSSPdf.php"; require_once 'include/utils/CommonUtils.php'; require_once 'include/fields/CurrencyField.php'; ################################################################################# $uitypelist2 = array('10', '58', '51', '57', '68', '59', '75', '80', '76', '73', '81', '78'); $uitype2module2 = array('58' => 'Campaigns', '51' => 'Accounts', '57' => 'Contacts', '68' => 'Accounts;Contacts', '59' => 'Products', '75' => 'Vendors', '80' => 'SalesOrder', '76' => 'Potentials', '73' => 'Accounts', '81' => 'Vendors', '78' => 'Quotes'); ################################################################################# $uitypelist = array('10', '58', '51', '57', '68', '59', '75', '80', '76', '73', '81', '52', '53', '78'); $uitype2module = array('58' => 'Campaigns', '51' => 'Accounts', '57' => 'Contacts', '68' => 'Accounts;Contacts', '59' => 'Products', '75' => 'Vendors', '80' => 'SalesOrder', '76' => 'Potentials', '73' => 'Accounts', '81' => 'Vendors', '52' => 'Users', '53' => 'Users', '78' => 'Quotes'); ################################################################################# $ui_datefields = array('70', '5', '23'); ################################################################################# $ui_currfields = array('71', '72', '7'); ################################################################################# if ($module == 'Activity') { $wynik = $db->query("select tabid,name from vtiger_tab where name='Calendar'", true); } else { $wynik = $db->query("select tabid,name from vtiger_tab where name='{$module}'", true); } $moduleid = $db->query_result($wynik, 0, "tabid"); $list = array(); $pobierz = $db->query("select fieldid,uitype, fieldname from vtiger_field where tabid = '{$moduleid}'", true); for ($i = 0; $i < $db->num_rows($pobierz); $i++) { $uitype = $db->query_result($pobierz, $i, "uitype"); $fieldid = $db->query_result($pobierz, $i, "fieldid"); if (in_array($uitype, $uitypelist)) { if ($uitype == '10') { $wynik = $db->query("select relmodule from vtiger_fieldmodulerel where fieldid = '{$fieldid}'", true); for ($k = 0; $k < $db->num_rows($wynik); $k++) { $list[$db->query_result($wynik, $k, "relmodule")] = $fields[$db->query_result($pobierz, $i, "fieldname")]; } } else { $zmienna = $uitype2module[$uitype]; $zmienna = explode(';', $zmienna); foreach ($zmienna as $value) { $list[$value] = $fields[$db->query_result($pobierz, $i, "fieldname")]; } } } } if (count($list) > 0) { foreach ($list as $name => $record) { $modulename = $name; require_once "modules/{$modulename}/{$modulename}.php"; if ($modulename == 'Users') { $obiekt = new $modulename(); $pobierz_usera = $db->query("select * from vtiger_users where id = '{$record}'", true); if ($db->num_rows($pobierz_usera) > 0) { $obiekt->retrieve_entity_info($record, $modulename); } } else { $obiekt = new $modulename(); $assigned_module = getSalesEntityType($record); if ($record != 0 && $assigned_module == $modulename) { $obiekt->retrieve_entity_info($record, $modulename); } } $pobierz = $db->query("select tabid from vtiger_tab where name = '{$modulename}'", true); $moduleid = $db->query_result($pobierz, 0, "tabid"); $pobierz_bloki = $db->query("select blockid, blocklabel from vtiger_blocks where tabid = '{$moduleid}'", true); $relatedfield_list = array(); for ($k = 0; $k < $db->num_rows($pobierz_bloki); $k++) { $blockid = $db->query_result($pobierz_bloki, $k, "blockid"); $label = $db->query_result($pobierz_bloki, $k, "blocklabel"); $pobierz_pola = $db->query("select fieldname,fieldlabel,uitype from vtiger_field where block='{$blockid}' and tabid = '{$moduleid}'", true); for ($i = 0; $i < $db->num_rows($pobierz_pola); $i++) { $field_uitype = $db->query_result($pobierz_pola, $i, "uitype"); $label = $db->query_result($pobierz_pola, $i, "fieldlabel"); $key = $db->query_result($pobierz_pola, $i, "fieldname"); $value = $obiekt->column_fields[$key]; ################################################ /// Dla pól z datą if (in_array($field_uitype, $ui_datefields)) { $value = getValidDisplayDate($value); } ################################################ /// Dla pól z walutami if (in_array($field_uitype, $ui_currfields)) { $currfield = new CurrencyField($value); $value = $currfield->getDisplayValue(); } //// Dla pola z językiem użytkownika if ($field_uitype == 27) { if ($value == 'I') { $value = getTranslatedString('Internal', $modulename); } elseif ($value == 'E') { $value = getTranslatedString('External', $modulename); } } if ($field_uitype == 32) { $name = '%' . $value . '%'; $new_value = $db->query("select name from vtiger_language where prefix like '{$name}'", true); $value = getTranslatedString($db->query_result($new_value, 0, "name")); } /// dla pól z przypisanym użytkownikie, if ($field_uitype == 53 || $field_uitype == 52) { $value = getUserName($value); } /// dla pól z folderem /*if( $field_uitype == 26 ) { $new_value = $db->query( "select foldername from vtiger_attachmentsfolder where folderid = '$value'", true ); $value = $db->query_result( $new_value, 0, "foldername" ); }*/ /// Dla pól z roląużytkownika w organizacji if ($field_uitype == 98) { $new_value = $db->query("select rolename from vtiger_role where roleid = '{$value}'", true); $value = $db->query_result($new_value, 0, "rolename"); } /// Dla pól typu checkbox if ($field_uitype == 56) { if ($value == 1) { $value = getTranslatedString('yes', "OSSPdf"); } elseif ($value == 0) { $value = getTranslatedString('no', "OSSPdf"); } } /// Dla pola ze zdjęciem użytkownika if ($field_uitype == 105) { include_once "modules/OSSPdf/small_config.php"; if ($value != "") { $sql = "SELECT CONCAT(vtiger_attachments.path,vtiger_attachments.attachmentsid,'_',vtiger_users.imagename) AS sciezka FROM vtiger_attachments\n INNER JOIN vtiger_salesmanattachmentsrel ON ( vtiger_salesmanattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid )\n INNER JOIN vtiger_users ON ( vtiger_users.id = vtiger_salesmanattachmentsrel.smid )\n WHERE vtiger_salesmanattachmentsrel.smid = '{$record}'"; $pobierz_zdjecie = $db->query($sql, true); if ($db->num_rows($pobierz_zdjecie) > 0) { $value = '<img src="' . $site_URL . '/' . $db->query_result($pobierz_zdjecie, 0, "sciezka") . '" width="' . $UserImage_width . 'px" height="' . $UserImage_height . 'px"></img>'; } } } /// Dla pól typu lista wyboru if ($field_uitype == 15 || $field_uitype == 16 || $field_uitype == 55 && $key == 'salutationtype') { $value = getTranslatedString($value, $modulename); } if ($field_uitype == 83) { $pobierz_tax = $db->query("select * from vtiger_producttaxrel where productid = '{$record}'", true); for ($a = 0; $a < $db->num_rows($pobierz_tax); $a++) { $taxid = $db->query_result($pobierz_tax, $a, "taxid"); $taxvalue = $db->query_result($pobierz_tax, $a, "taxpercentage"); if ($taxid == 1) { $value .= getTranslatedString('LBL_VAT') . getTranslatedString('COVERED_PERCENTAGE') . ': ' . $taxvalue . '%'; } elseif ($taxid == 2) { $value .= getTranslatedString('LBL_SALES') . getTranslatedString('COVERED_PERCENTAGE') . ': ' . $taxvalue . '%'; } elseif ($taxid == 3) { $value .= getTranslatedString('LBL_SERVICE') . getTranslatedString('COVERED_PERCENTAGE') . ': ' . $taxvalue . '%'; } $value .= '<br/>'; } } ######################## if (in_array($field_uitype2, $uitypelist2)) { if ($field_uitype == 10) { $pobierz_wartosc = $db->query("select relmodule from vtiger_fieldmodulerel where fieldid = '{$fieldid}'", true); for ($i = 0; $i < $db->num_rows($pobierz_wartosc); $i++) { $module .= $db->query_result($pobierz_wartosc, $i, "relmodule") . ';'; } } else { $module = $uitype2module[$field_uitype]; } $module = trim($module, ';'); $ids = explode(';', $module); foreach ($ids as $singleid) { $newvalue = $db->query("select tablename, entityidfield,fieldname from vtiger_entityname where modulename = '{$singleid}'", true); $tablename = $db->query_result($newvalue, 0, "tablename"); $fieldname = $db->query_result($newvalue, 0, "fieldname"); $tableid = $db->query_result($newvalue, 0, "entityidfield"); $newvalue2 = $db->query("select {$fieldname} from {$tablename} where {$tableid} = '{$value}'", true); $value = $db->query_result($newvalue2, 0, $fieldname); } } ######################## if ($field_uitype == 10 && is_numeric($value)) { if ($value != 0) { $value = Vtiger_Functions::getCRMRecordLabel($value); } elseif ($value == 0) { $value = ''; } } $string = "#" . $modulename . "_" . $key . "#"; $string2 = "#" . $modulename . "_label_" . $key . "#"; //."# TLUMACZENIE: ". getTranslatedString( $label, $modulename ); $pozycja = (int) strpos($content, $string2); $content = str_replace($string2, getTranslatedString($label, $modulename), $content); if ($record != 0 && ($assigned_module == $modulename || $modulename == 'Users')) { $content = str_replace($string, $value, $content); } else { $content = str_replace($string, '', $content); } } } } } return $content; }
/** * Gets the Mail Date * @param Boolean $format * @return Date */ function date($format = false) { $date = $this->_date; if ($format) { if (preg_match(sprintf("/%s ([^ ]+)/", date('D, d M Y')), $date, $m)) { $date = $m[1]; // Pick only time part for today } else { if (preg_match("/[a-zA-Z]{3}, ([0-9]{1,2} [a-zA-Z]{3} [0-9]{4})/", $date, $m)) { $date = $m[1]; // Pick only date part } } $userDate = str_replace('--', '', getValidDisplayDate($date)); return $userDate; } else { $dateWithTime = new DateTimeField(date('Y-m-d H:i:s', $date)); $userDateTime = $dateWithTime->getDisplayDateTimeValue(); return $userDateTime; } }
public static function ReportFilters(Vtiger_Request $request, $viewer) { require_once 'modules/ITS4YouReports/FilterUtils.php'; $adb = PearDatabase::getInstance(); $moduleName = $request->getModule(); $R_Data = $request->getAll(); $record = $request->get('record'); $viewer->assign("MODULE", $moduleName); $reportModel = ITS4YouReports_Record_Model::getCleanInstance($record); $Report_Informations = $reportModel->getReportInformations(); $primary_module = $reportModel->getPrimaryModule(); $primary_moduleid = $reportModel->getPrimaryModuleId(); $current_user = Users_Record_Model::getCurrentUserModel(); $viewer->assign("DATEFORMAT", $current_user->date_format); $viewer->assign("JS_DATEFORMAT", parse_calendardate(vtranslate('NTC_DATE_FORMAT'))); // ITS4YOU-CR SlOl 10. 9. 2013 16:13:47 $LBL_INFORMATIONS_4YOU = vtranslate("LBL_STEP7_INFO", $moduleName); $viewer->assign("LBL_INFORMATIONS_4YOU", $LBL_INFORMATIONS_4YOU); // ITS4YOU-END 10. 9. 2013 16:13:50 $BLOCK1 = "<option selected value='Not Accessible'>" . vtranslate('LBL_NOT_ACCESSIBLE') . "</option>"; $user_privileges_path = 'user_privileges/user_privileges_' . $current_user->id . '.php'; if (file_exists($user_privileges_path)) { require $user_privileges_path; } $related_modules = $reportModel->getReportRelatedModulesList(); $advft_criteria = array(); if ($record != "") { $reportModel->getSelectedStandardCriteria($reportid); $stdselectedcolumn = $reportModel->getSTDSelectedColumn(); $relatedmodulesstring = $reportModel->getRelatedModulesString(); $BLOCK1 .= getITSPrimaryStdFilterHTML($primary_module, $stdselectedcolumn); $BLOCK1 .= getITSSecondaryStdFilterHTML($relatedmodulesstring, $stdselectedcolumn); //added to fix the ticket #5117 $selectedcolumnvalue = '"' . $stdselectedcolumn . '"'; if (!$is_admin && isset($stdselectedcolumn) && strpos($BLOCK1, $selectedcolumnvalue) === false) { $viewer->assign("BLOCK1_STD", $BLOCK1); } $stdselectedfilter = $reportModel->getSTDSelectedFilter(); $startdate = $reportModel->getStartDate(); $enddate = $reportModel->getEndDate(); if ($startdate != "") { $viewer->assign("STARTDATE_STD", getValidDisplayDate($startdate)); } if ($enddate != "") { $viewer->assign("ENDDATE_STD", getValidDisplayDate($enddate)); } $reportModel->getGroupFilterList($reportid); $reportModel->getAdvancedFilterList($reportid); $advft_criteria = $reportModel->getSelectedAdvancedFilter($reportid); } else { $primary_module = $R_Data["reportmodule"]; $BLOCK1 .= getITSPrimaryStdFilterHTML($primary_module); if (!empty($related_modules[$primary_module])) { foreach ($related_modules[$primary_module] as $key => $value) { $BLOCK1 .= getITSSecondaryStdFilterHTML($R_Data["secondarymodule_" . $value]); } } $viewer->assign("BLOCK1_STD", $BLOCK1); $stdselectedfilter = ""; } $BLOCKCRITERIA = $reportModel->getSelectedStdFilterCriteria($stdselectedfilter); $viewer->assign("BLOCKCRITERIA_STD", $BLOCKCRITERIA); $BLOCKJS = $reportModel->getCriteriaJS(); $viewer->assign("BLOCKJS_STD", $BLOCKJS); ///AdvancedFilter.php $summaries_criteria = $reportModel->getSummariesCriteria(); $viewer->assign("CRITERIA_GROUPS", $advft_criteria); $viewer->assign("EMPTY_CRITERIA_GROUPS", empty($advft_criteria)); $viewer->assign("SUMMARIES_CRITERIA", $summaries_criteria); /* if(isset($R_Data["mode"]) && $R_Data["mode"]!=""){ $mode = vtlib_purify($R_Data["mode"]); }else{ $mode = "generate"; } */ if ($record != "") { $viewer->assign('MODE', 'edit'); } else { $viewer->assign('MODE', 'create'); } $FILTER_OPTION = getAdvCriteriaHTML(); $viewer->assign("FOPTION", $FILTER_OPTION); $secondarymodule = ''; $secondarymodules = array(); if (!empty($related_modules[$primary_module])) { foreach ($related_modules[$primary_module] as $key => $value) { if (isset($R_Data["secondarymodule_" . $value])) { $secondarymodules[] = $R_Data["secondarymodule_" . $value]; } } } $reportModel->getPriModuleColumnsList($primary_module); if (!empty($related_modules[$primary_module])) { foreach ($related_modules[$primary_module] as $key => $value) { $secondarymodules[] = $value["id"]; } $secondary_modules_str = implode(":", $secondarymodules); } $reportModel->getSecModuleColumnsList($secondary_modules_str); if ($mode != "ChangeSteps") { $Options = getPrimaryColumns($Options, $reportModel->report->primarymodule, true, $reportModel->report); $secondarymodules = array(); if (!empty($reportModel->report->related_modules[$reportModel->report->primarymodule])) { foreach ($reportModel->report->related_modules[$reportModel->report->primarymodule] as $key => $value) { $exploded_mid = explode("x", $value["id"]); if (strtolower($exploded_mid[1]) != "mif") { $secondarymodules[] = $value["id"]; } } } $secondarymodules_str = implode(":", $secondarymodules); $Options_sec = getSecondaryColumns(array(), $secondarymodules_str, $reportModel->report); foreach ($Options_sec as $moduleid => $sec_options) { $Options = array_merge($Options, $sec_options); } // ITS4YOU-CR SlOl 16. 9. 2015 10:49:04 OTHER COLUMNS if (isset($R_Data["selectedColumnsStr"]) && $R_Data["selectedColumnsStr"] != "") { $selectedColumnsStr = $R_Data["selectedColumnsStr"]; $selectedColumnsStringDecoded = html_entity_decode($selectedColumnsStr, ENT_QUOTES, $default_charset); $selectedColumns_arr = explode("<_@!@_>", $selectedColumnsStringDecoded); } else { $selectedColumnsStr = $reportModel->report->reportinformations["selectedColumnsString"]; $selectedColumnsStringDecoded = html_entity_decode($selectedColumnsStr, ENT_QUOTES, $default_charset); $selectedColumns_arr = explode(";", $selectedColumnsStringDecoded); } if (!empty($selectedColumns_arr)) { $opt_label = vtranslate("LBL_Filter_SelectedColumnsGroup", "ITS4YouReports"); foreach ($selectedColumns_arr as $sc_key => $sc_col_str) { if ($sc_col_str != "") { $in_options = false; foreach ($Options as $opt_group => $opt_array) { if ($reportModel->report->in_multiarray($sc_col_str, $opt_array, "value") === true) { $in_options = true; continue; } } if ($in_options) { continue; } else { $Options[$opt_label][] = array("value" => $sc_col_str, "text" => $reportModel->report->getColumnStr_Label($sc_col_str)); } } } } // ITS4YOU-END foreach ($Options as $optgroup => $optionsdata) { if ($COLUMNS_BLOCK_JSON != "") { $COLUMNS_BLOCK_JSON .= "(|@!@|)"; } $COLUMNS_BLOCK_JSON .= $optgroup; $COLUMNS_BLOCK_JSON .= "(|@|)"; $COLUMNS_BLOCK_JSON .= Zend_JSON::encode($optionsdata); } $viewer->assign("COLUMNS_BLOCK_JSON", $COLUMNS_BLOCK_JSON); $adv_sel_fields = $reportModel->getAdvSelFields(); $sel_fields = Zend_Json::encode($adv_sel_fields); $viewer->assign("SEL_FIELDS", $sel_fields); $default_charset = vglobal("default_charset"); $std_filter_columns = $reportModel->getStdFilterColumns(); $std_filter_columns_js = implode("<%jsstdjs%>", $std_filter_columns); $std_filter_columns_js = html_entity_decode($std_filter_columns_js, ENT_QUOTES, $default_charset); $viewer->assign("std_filter_columns", $std_filter_columns_js); $Date_Filter_Values = $reportModel->getDateFilterValues(); $std_filter_criteria = Zend_Json::encode($Date_Filter_Values); $viewer->assign("std_filter_criteria", $std_filter_criteria); } $rel_fields = $reportModel->getAdvRelFields(); $viewer->assign("REL_FIELDS", Zend_Json::encode($rel_fields)); /*NEWS*/ //error_reporting(63);ini_set("display_errors",1); $primary_module = $reportModel->report->primarymodule; $primary_moduleid = $reportModel->report->primarymoduleid; // NEW ADVANCE FILTERS START $reportModel->report->getGroupFilterList($reportModel->report->record); $reportModel->report->getAdvancedFilterList($reportModel->report->record); $reportModel->report->getSummariesFilterList($reportModel->report->record); $sel_fields = Zend_Json::encode($reportModel->report->adv_sel_fields); $viewer->assign("SEL_FIELDS", $sel_fields); if (isset($_REQUEST["reload"])) { $criteria_groups = $reportModel->report->getRequestCriteria($sel_fields); } else { $criteria_groups = $reportModel->report->advft_criteria; } $viewer->assign("CRITERIA_GROUPS", $criteria_groups); $viewer->assign("EMPTY_CRITERIA_GROUPS", empty($criteria_groups)); $viewer->assign("SUMMARIES_CRITERIA", $reportModel->report->summaries_criteria); $FILTER_OPTION = getAdvCriteriaHTML(); $viewer->assign("FOPTION", $FILTER_OPTION); $COLUMNS_BLOCK_JSON = $reportModel->report->getAdvanceFilterOptionsJSON($primary_module); $viewer->assign("COLUMNS_BLOCK", $COLUMNS_BLOCK); if ($mode != "ajax") { //echo "<div class='none' style='display:none;' id='filter_columns'>" . $COLUMNS_BLOCK_JSON . "</div>"; //echo "<input type='hidden' name='filter_columns' id='filter_columns' value='".$COLUMNS_BLOCK_JSON."' />"; $viewer->assign("filter_columns", $COLUMNS_BLOCK_JSON); $sel_fields = Zend_Json::encode($reportModel->report->adv_sel_fields); $viewer->assign("SEL_FIELDS", $sel_fields); global $default_charset; $std_filter_columns = $reportModel->report->getStdFilterColumns(); $std_filter_columns_js = implode("<%jsstdjs%>", $std_filter_columns); $std_filter_columns_js = html_entity_decode($std_filter_columns_js, ENT_QUOTES, $default_charset); $viewer->assign("std_filter_columns", $std_filter_columns_js); $std_filter_criteria = Zend_Json::encode($reportModel->report->Date_Filter_Values); $viewer->assign("std_filter_criteria", $std_filter_criteria); } $rel_fields = $reportModel->report->adv_rel_fields; $rel_fields = Zend_Json::encode($rel_fields); $rel_fields = str_replace("'", "\\'", $rel_fields); $viewer->assign("REL_FIELDS", $rel_fields); // NEW ADVANCE FILTERS END $BLOCKJS = $reportModel->getCriteriaJS(); $viewer->assign("BLOCKJS_STD", $BLOCKJS); /*NEWE*/ return $viewer->view('ReportFilters.tpl', $moduleName, true); }
// billing Address $billPositions = array("10", "51", "61"); if (trim($bill_street) != '') { $billText = $bill_street . "\n"; } if (trim($bill_city) != '') { $billText .= $bill_city . ", "; } if (trim($bill_state) != '' || trim($bill_code) != '') { $billText .= $bill_state . " " . $bill_code . "\n"; } $billText .= $bill_country; // scott $pdf->addTextBlock($app_strings["Billing Address"].":",$billText, $billPositions); // ********** End Addresses ****************** /* ******** Begin Invoice Data ************************ */ // terms block //$termBlock=array("147","40"); //$pdf->addRecBlock($account_name, $app_strings["Customer Name"], $termBlock); // issue date block $issueBlock = array("10", "70"); $pdf->addRecBlock(getValidDisplayDate(date("Y-m-d")), $mod_strings["Issue Date"], $issueBlock); // due date block //scott $dueBlock=array("81","52"); //scott $pdf->addRecBlock($valid_till, $app_strings["Due Date"],$dueBlock); // Contact Name block // scott $conBlock=array("79","67"); // scott $pdf->addRecBlock($contact_name, $app_strings["Contact Name"],$conBlock); // vtiger_invoice number block // scott $invBlock=array("145","67"); // scott $pdf->addRecBlock($invoice_no, $app_strings["Invoice Number"],$invBlock); /* ************ End Invoice Data ************************ */
function getCriteriaJS() { $today = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y"))); $tomorrow = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"))); $yesterday = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))); $currentmonth0 = date("Y-m-d", mktime(0, 0, 0, date("m"), "01", date("Y"))); $currentmonth1 = date("Y-m-t"); $lastmonth0 = date("Y-m-d", mktime(0, 0, 0, date("m") - 1, "01", date("Y"))); $lastmonth1 = date("Y-m-t", strtotime("-1 Month")); $nextmonth0 = date("Y-m-d", mktime(0, 0, 0, date("m") + 1, "01", date("Y"))); $nextmonth1 = date("Y-m-t", strtotime("+1 Month")); global $current_user; $dayoftheweek = $current_user->column_fields["dayoftheweek"]; //ITS4YouReports::sshow("DOW3 $dayoftheweek"); $lastweek0 = date("Y-m-d", strtotime("-2 week {$dayoftheweek}")); $lastweek1 = date("Y-m-d", strtotime("-1 week {$dayoftheweek} -1 day")); $thisweek0 = date("Y-m-d", strtotime("-1 week {$dayoftheweek}")); $thisweek1 = date("Y-m-d", strtotime("this {$dayoftheweek} -1 day")); $nextweek0 = date("Y-m-d", strtotime("this {$dayoftheweek}")); $nextweek1 = date("Y-m-d", strtotime("+1 week {$dayoftheweek} -1 day")); $next7days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 6, date("Y"))); $next15days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 14, date("Y"))); $next30days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 29, date("Y"))); $next60days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 59, date("Y"))); $next90days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 89, date("Y"))); $next120days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 119, date("Y"))); $last7days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 6, date("Y"))); $last15days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 14, date("Y"))); $last30days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 29, date("Y"))); $last60days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 59, date("Y"))); $last90days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 89, date("Y"))); $last120days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 119, date("Y"))); $currentFY0 = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y"))); $currentFY1 = date("Y-m-t", mktime(0, 0, 0, "12", date("d"), date("Y"))); $lastFY0 = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y") - 1)); $lastFY1 = date("Y-m-t", mktime(0, 0, 0, "12", date("d"), date("Y") - 1)); $nextFY0 = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y") + 1)); $nextFY1 = date("Y-m-t", mktime(0, 0, 0, "12", date("d"), date("Y") + 1)); $todaymore_start = $today; $todayless_end = $today; $older1days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))); $older7days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 7, date("Y"))); $older15days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 15, date("Y"))); $older30days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 30, date("Y"))); $older60days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 60, date("Y"))); $older90days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 90, date("Y"))); $older120days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 120, date("Y"))); if (date("m") <= 3) { $cFq = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "03", "31", date("Y"))); $nFq = date("Y-m-d", mktime(0, 0, 0, "04", "01", date("Y"))); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "06", "30", date("Y"))); $pFq = date("Y-m-d", mktime(0, 0, 0, "10", "01", date("Y") - 1)); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "12", "31", date("Y") - 1)); } else { if (date("m") > 3 and date("m") <= 6) { $pFq = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y"))); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "03", "31", date("Y"))); $cFq = date("Y-m-d", mktime(0, 0, 0, "04", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "06", "30", date("Y"))); $nFq = date("Y-m-d", mktime(0, 0, 0, "07", "01", date("Y"))); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "09", "30", date("Y"))); } else { if (date("m") > 6 and date("m") <= 9) { $nFq = date("Y-m-d", mktime(0, 0, 0, "10", "01", date("Y"))); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "12", "31", date("Y"))); $pFq = date("Y-m-d", mktime(0, 0, 0, "04", "01", date("Y"))); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "06", "30", date("Y"))); $cFq = date("Y-m-d", mktime(0, 0, 0, "07", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "09", "30", date("Y"))); } else { if (date("m") > 9 and date("m") <= 12) { $nFq = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y") + 1)); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "03", "31", date("Y") + 1)); $pFq = date("Y-m-d", mktime(0, 0, 0, "07", "01", date("Y"))); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "09", "30", date("Y"))); $cFq = date("Y-m-d", mktime(0, 0, 0, "10", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "12", "31", date("Y"))); } } } } $sjsStr = '<script type="text/javaScript"> function showDateRange(s_obj, e_obj, st_obj, et_obj, type ){ if (type!="custom"){ s_obj.style.display="block"; e_obj.style.display="block"; st_obj.style.display="none"; et_obj.style.display="none"; }else{ s_obj.style.display="none"; e_obj.style.display="none"; st_obj.style.display="block"; et_obj.style.display="block"; } if( type == "today" ){ s_obj.value = "' . getValidDisplayDate($today) . '"; e_obj.value = "' . getValidDisplayDate($today) . '"; }else if( type == "yesterday" ){ s_obj.value = "' . getValidDisplayDate($yesterday) . '"; e_obj.value = "' . getValidDisplayDate($yesterday) . '"; }else if( type == "tomorrow" ){ s_obj.value = "' . getValidDisplayDate($tomorrow) . '"; e_obj.value = "' . getValidDisplayDate($tomorrow) . '"; }else if( type == "thisweek" ){ s_obj.value = "' . getValidDisplayDate($thisweek0) . '"; e_obj.value = "' . getValidDisplayDate($thisweek1) . '"; }else if( type == "lastweek" ){ s_obj.value = "' . getValidDisplayDate($lastweek0) . '"; e_obj.value = "' . getValidDisplayDate($lastweek1) . '"; }else if( type == "nextweek" ){ s_obj.value = "' . getValidDisplayDate($nextweek0) . '"; e_obj.value = "' . getValidDisplayDate($nextweek1) . '"; }else if( type == "thismonth" ){ s_obj.value = "' . getValidDisplayDate($currentmonth0) . '"; e_obj.value = "' . getValidDisplayDate($currentmonth1) . '"; }else if( type == "lastmonth" ){ s_obj.value = "' . getValidDisplayDate($lastmonth0) . '"; e_obj.value = "' . getValidDisplayDate($lastmonth1) . '"; }else if( type == "nextmonth" ){ s_obj.value = "' . getValidDisplayDate($nextmonth0) . '"; e_obj.value = "' . getValidDisplayDate($nextmonth1) . '"; }else if( type == "next7days" ){ s_obj.value = "' . getValidDisplayDate($today) . '"; e_obj.value = "' . getValidDisplayDate($next7days) . '"; }else if( type == "next15days" ){ s_obj.value = "' . getValidDisplayDate($today) . '"; e_obj.value = "' . getValidDisplayDate($next15days) . '"; }else if( type == "next30days" ){ s_obj.value = "' . getValidDisplayDate($today) . '"; e_obj.value = "' . getValidDisplayDate($next30days) . '"; }else if( type == "next60days" ){ s_obj.value = "' . getValidDisplayDate($today) . '"; e_obj.value = "' . getValidDisplayDate($next60days) . '"; }else if( type == "next90days" ){ s_obj.value = "' . getValidDisplayDate($today) . '"; e_obj.value = "' . getValidDisplayDate($next90days) . '"; }else if( type == "next120days" ){ s_obj.value = "' . getValidDisplayDate($today) . '"; e_obj.value = "' . getValidDisplayDate($next120days) . '"; }else if( type == "last7days" ){ s_obj.value = "' . getValidDisplayDate($last7days) . '"; e_obj.value = "' . getValidDisplayDate($today) . '"; }else if( type == "last15days" ){ s_obj.value = "' . getValidDisplayDate($last15days) . '"; e_obj.value = "' . getValidDisplayDate($today) . '"; }else if( type == "last30days" ){ s_obj.value = "' . getValidDisplayDate($last30days) . '"; e_obj.value = "' . getValidDisplayDate($today) . '"; }else if( type == "last60days" ){ s_obj.value = "' . getValidDisplayDate($last60days) . '"; e_obj.value = "' . getValidDisplayDate($today) . '"; }else if( type == "last90days" ){ s_obj.value = "' . getValidDisplayDate($last90days) . '"; e_obj.value = "' . getValidDisplayDate($today) . '"; }else if( type == "last120days" ){ s_obj.value = "' . getValidDisplayDate($last120days) . '"; e_obj.value = "' . getValidDisplayDate($today) . '"; }else if( type == "thisfy" ){ s_obj.value = "' . getValidDisplayDate($currentFY0) . '"; e_obj.value = "' . getValidDisplayDate($currentFY1) . '"; }else if( type == "prevfy" ){ s_obj.value = "' . getValidDisplayDate($lastFY0) . '"; e_obj.value = "' . getValidDisplayDate($lastFY1) . '"; }else if( type == "nextfy" ){ s_obj.value = "' . getValidDisplayDate($nextFY0) . '"; e_obj.value = "' . getValidDisplayDate($nextFY1) . '"; }else if( type == "nextfq" ){ s_obj.value = "' . getValidDisplayDate($nFq) . '"; e_obj.value = "' . getValidDisplayDate($nFq1) . '"; }else if( type == "prevfq" ){ s_obj.value = "' . getValidDisplayDate($pFq) . '"; e_obj.value = "' . getValidDisplayDate($pFq1) . '"; }else if( type == "thisfq" ){ s_obj.value = "' . getValidDisplayDate($cFq) . '"; e_obj.value = "' . getValidDisplayDate($cFq1) . '"; }else if( type == "todaymore" ){ s_obj.value = "' . getValidDisplayDate($todaymore_start) . '"; e_obj.value = ""; }else if( type == "todayless" ){ s_obj.value = ""; e_obj.value = "' . getValidDisplayDate($todayless_end) . '"; }else if( type == "older1days" ){ s_obj.value = ""; e_obj.value = "' . getValidDisplayDate($older1days) . '"; }else if( type == "older7days" ){ s_obj.value = ""; e_obj.value = "' . getValidDisplayDate($older7days) . '"; }else if( type == "older15days" ){ s_obj.value = ""; e_obj.value = "' . getValidDisplayDate($older15days) . '"; }else if( type == "older30days" ){ s_obj.value = ""; e_obj.value = "' . getValidDisplayDate($older30days) . '"; }else if( type == "older60days" ){ s_obj.value = ""; e_obj.value = "' . getValidDisplayDate($older60days) . '"; }else if( type == "older90days" ){ s_obj.value = ""; e_obj.value = "' . getValidDisplayDate($older90days) . '"; }else if( type == "older120days" ){ s_obj.value = ""; e_obj.value = "' . getValidDisplayDate($older120days) . '"; }else{ //s_obj.value = ""; //e_obj.value = ""; } } </script>'; return $sjsStr; }
public function GenerateReport($reportid, $outputformat = "HTML", $directOutput = false) { global $current_user, $php_max_execution_time, $currentModule; global $modules, $app_strings; global $mod_strings, $current_language; $adb = PEARDatabase::getInstance(); // CUSTOM REPORT START if ($this->reports4you_type == "custom_report") { $sSQL = $this->tf_sql; //$adb->setDebug(true); $result = $adb->query($sSQL); //$adb->setDebug(false); $f_error = ""; /* * * ERROR MESSAGE FOR ITS4YOU START ** */ if (!$result) { $f_error = $this->getSqlError(); } if ($f_error != "") { $this->displaySqlError($adb, $f_error); exit; } /* * * ERROR MESSAGE FOR ITS4YOU END ** */ $header_style = " style='" . $this->header_style . "' "; //error_reporting(63);ini_set("display_errors", 1); $set_pdf_portrait = false; $header_populated = false; $header_array = array(); $report_html = $valtemplate_tr = ""; if ($outputformat == "HTML") { $report_html .= $this->getReportNameHTML(); $report_html .= '<div id="rpt4youTable" ><table cellpadding="5" cellspacing="0" align="center" class="rpt4youTableContent" border="1" style="border-collapse: collapse;" >'; $noofrows = $adb->num_rows($result); } $xls_i = 0; while ($report_data_row = $adb->fetchByAssoc($result)) { if ($outputformat == "XLS") { $row_data = array(); foreach ($report_data_row as $columnname => $columnvalue) { if ($header_populated !== true) { $header_array[$xls_i] = str_replace("_", " ", $columnname); $xls_i++; } $row_data[] = $columnvalue; } $header_populated = true; $data[] = $row_data; //ITs4YouReports::sshow($header_array); //ITs4YouReports::sshow($data); } else { $valtemplate_tr = "<tr>"; foreach ($report_data_row as $columnname => $columnvalue) { if ($header_populated !== true) { $header_array[$columnname] = str_replace("_", " ", $columnname); } $valtemplate_tr .= "<td class='rpt4youGrpHead' nowrap >" . $columnvalue . "</td>"; } $valtemplate_tr .= "</tr>"; if ($header_populated !== true) { $report_html .= "<tr>"; if (count($header_array) > $custom_report_portrait_from) { $set_pdf_portrait = true; } foreach ($header_array as $headerLabel) { $report_html .= "<td class='rpt4youCellLabel' {$header_style} nowrap >" . $headerLabel . "</td>"; } $report_html .= "</tr>"; $header_populated = true; } $report_html .= $valtemplate_tr; } } if ($outputformat == "HTML") { $report_html .= '</table></div>'; } //exit; if ($outputformat == "HTML") { $this->setReportFileInfo($set_pdf_portrait); $this->setNoOfRows($noofrows); } //echo $report_html; if ($outputformat == "XLS") { $return_data["headers"] = $header_array; $return_data["data"] = $data; return $return_data; } else { //$this->create_pdf_schedule = true; if (isset($this->create_pdf_schedule) && $this->create_pdf_schedule == true) { $this->createPDFFileForScheduler($report_html, "", $set_pdf_portrait); } if ($directOutput) { echo $report_html; } else { $return_data[] = $report_html; $return_data[] = $noofrows; $return_data[] = $sSQL; return $return_data; } } // CUSTOM REPORT END } else { // OTHER REPORTS START if ($this->time_debug === true) { $this->report_obj->define_rt_vars(false, true); } $this->outputformat = $outputformat; $user_privileges_path = 'user_privileges/user_privileges_' . $current_user->id . '.php'; if (file_exists($user_privileges_path)) { require $user_privileges_path; } $modules_selected = array(); // $ITS4YouReports = new ITS4YouReports($reportid); $modules_selected[] = $this->report_obj->primarymodule; if (!empty($this->report_obj->relatedmodulesarray)) { foreach ($modules_selected as $key => $modulestr) { $modulearr = explode("x", $modulestr); $secmodule = vtlib_getModuleNameById($modulearr[0]); if (vtlib_isModuleActive($secmodule)) { $modules_selected[] = $secmodule; } } } // Update Currency Field list $currencyfieldres = $adb->pquery("SELECT tabid, fieldid, columnname, fieldlabel, uitype from vtiger_field WHERE uitype in (71, 72, 10)", array()); if ($currencyfieldres) { foreach ($currencyfieldres as $currencyfieldrow) { $modprefixedlabel = getTabModuleName($currencyfieldrow['tabid']) . ' ' . $currencyfieldrow['fieldlabel']; $modprefixedlabel = str_replace(' ', '_', $modprefixedlabel); if ($currencyfieldrow['uitype'] != 10) { //if (!in_array($modprefixedlabel, $this->convert_currency) && !in_array($modprefixedlabel, $this->append_currency_symbol_to_value)) { $this->convert_currency[] = $modprefixedlabel; //} } else { if (!in_array($modprefixedlabel, $this->ui10_fields)) { $mod_key = $currencyfieldrow["columnname"] . "_fid_" . $currencyfieldrow["fieldid"]; $this->ui10_fields[$mod_key] = $modprefixedlabel; } } } } // if ($outputformat == "HTML") { $sSQL = $this->tf_sql; $this->sum_col_i = 0; $selectedcolumns_arr = $this->report_obj->getSelectedColumnListArray($this->report_obj->record); // GROUPING SQL START //if (!empty($this->groupslist) && !empty($this->report_obj->reportinformations["summaries_columns"])) { if (!empty($this->groupslist)) { if (!empty($this->report_obj->reportinformations["summaries_columns"])) { foreach ($this->report_obj->reportinformations["summaries_columns"] as $key => $summaries_columns_arr) { $column_arr = explode(":", $summaries_columns_arr["columnname"]); $imploded = ""; if (is_numeric($column_arr[5]) || in_array($column_arr[5], ITS4YouReports::$customRelationTypes)) { $ci_n = 6; } else { $ci_n = 5; } for ($ci = 0; $ci < $ci_n; $ci++) { if ($ci > 0) { $imploded .= ":"; } $imploded .= $column_arr[$ci]; } $c_calculation_type = $column_arr[$ci_n]; $sum_col_sql_a[$imploded][] = $c_calculation_type; $this->sum_col_i++; } $this->sum_col_sql_a = $sum_col_sql_a; } if ($this->report_obj->reportinformations["Group1"] != "none" && !empty($selectedcolumns_arr) && $this->generate_type != "grouping") { $this->detail_columns_array = $this->columns_array; $this->detail_sql = $sSQL; // $this->setResultArray($sSQL); } if (!empty($this->report_obj->reportinformations["summaries_columns"]) || $this->report_obj->reportinformations["Group1"] != "none") { $group_columns_array = $this->group_column_alias; $this->generateQuery($this->report_obj, "", "grouping"); $sSQL = $this->tf_sql; } } // GROUPING SQL END /* ARRAY FOR TOTALS CALCULATION START */ // $to_totals_array = $this->getToTotalsArray(); $this->to_totals_array = $this->getToTotalsArray(); if ($this->time_debug === true) { $this->report_obj->getR4UDifTime("After Query Generate", true); } /* ARRAY FOR TOTALS CALCULATION END */ // !!! BASE PRIMARY DEBUG !!! /* $debug_user_id = "9472"; global $current_user;if ($current_user->id==$debug_user_id) { $adb->setDebug(true); } */ // if ($outputformat != "CHARTS")$adb->setDebug(true); $result = $adb->pquery($sSQL, array()); // if ($outputformat != "CHARTS")$adb->setDebug(false); if ($this->time_debug === true) { $this->report_obj->getR4UDifTime("After Base Result", true); } /* global $current_user;if ($current_user->id==$debug_user_id) { $adb->setDebug(false); } */ $f_error = ""; if (!$result) { $f_error = $this->getSqlError(); } /* * * ERROR MESSAGE FOR ITS4YOU START ** */ if ($f_error != "") { $this->displaySqlError($adb, $f_error); exit; } // $adb->setDebug(false); $error_msg = $adb->database->ErrorMsg(); if (!$result && $error_msg != '') { // Performance Optimization: If direct output is requried if ($directOutput) { $report_html .= getTranslatedString('LBL_REPORT_GENERATION_FAILED', $this->getCurrentModule4You()) . "<br>" . $error_msg; $error_msg = false; echo $report_html; } // END return $error_msg; } $this->setUpGroupColsArray(); if ($this->generate_type == "grouping") { for ($mi = 1; $mi < 4; $mi++) { if ($mi > 1 && isset($this->group_cols_array[$mi]) && $this->group_cols_array[$mi] != "") { $group_cols[] = $this->group_cols_array[$mi]; } } } $noofrows = $adb->num_rows($result); if ($this->time_debug === true) { $this->report_obj->getR4UDifTime("Going to Generate HTML", true); } if ($outputformat == "HTML" || $outputformat == "CHARTS") { $report_html_pdf = $report_html; $return_name = $this->getReportNameHTML(); $report_html .= $return_name; if (isset($this->report_obj->reportinformations["description"]) && $this->report_obj->reportinformations["description"] != "") { $report_html .= "\n <table cellpadding='5' cellspacing='0' align='left' class='rpt4youTable' border='0' style='border:0px;width:100%;' >\n <tr>\n <td class='rpt4youGrpHeadInfo' style='padding-left:15px;font-size:14px;text-align:center;'>\n " . nl2br($this->report_obj->reportinformations["description"]) . "\n </td>\n </tr>\n </table>"; } $report_html .= "<div id='reportHederInfo'><@ReportHeaderInfo@></div>"; $report_html_headerInfo = $this->report_obj->getReportHeaderInfo($noofrows); $report_html .= "<br>"; $report_html .= '<div id="rpt4youTable" ><table cellpadding="5" cellspacing="0" align="center" class="rpt4youTableContent" border="1" style="border-collapse: collapse;" ><tr>'; // END if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { $picklistarray = $this->getAccessPickListValues(); } if ($result) { $y = $adb->num_fields($result) - 1; $t_y = $y; $custom_field_values = $adb->fetch_array($result); $column_definitions = $adb->getFieldsDefinition($result); // HEADERS if ($this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols" || $this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols") { if ($this->report_obj->reportinformations["Group3"] && $this->report_obj->reportinformations["timeline_type3"] == "cols") { $agi = 2; foreach ($this->sum_col_sql_a as $column_str => $calculation_arr) { foreach ($calculation_arr as $calculation_type) { // $calculation_type = $calculation_arr[0]; $label_db_key = "{$column_str}:{$calculation_type}"; if ($this->report_obj->in_multiarray($label_db_key, $this->summaries_columns, "columnname") !== true) { continue; } $fld_sql_str_array = explode(" AS ", $this->columns_array[$column_str]["fld_sql_str"]); $fld_str = $fld_sql_str_array[0]; $fld_str_as = $fld_sql_str_array[1] . "_{$calculation_type}"; $g_data_key_lbl = $this->getHeaderLabel($this->report_obj->record, "SM", $fld_str_as, $label_db_key); $sum_columns_bg = $this->g_colors[1]; $sum_columns_labels[] = array("style" => " background-color:{$sum_columns_bg};font-weight:bold; ", "label" => $g_data_key_lbl); } } } else { $agi = 1; } for ($x = 0; $x < 1; $x++) { $fld = $adb->field_name($result, $x); $is_hid = strpos($fld->name, "_hid"); if ($is_hid === false && !in_array($fld->name, $this->skip_fields)) { if (!in_array($fld->name, $group_cols)) { $header_style = ""; $header_style .= " style='" . $this->header_style . "' "; //$header[] = array("style" => $header_style, "label" => " ", ); $GroupsHeaderLabel = $this->getGroupsHeaderLabelStr(); $header[] = array("style" => $header_style, "label" => $GroupsHeaderLabel); $headercols = $this->getColsHeaders($header_style, $agi); foreach ($headercols as $header_arr) { $header[] = $header_arr; $group2_headers[] = $sum_columns_labels; //$group2_headers[$header_arr["label"]] = $sum_columns_labels; } } } // END } } else { for ($x = 0; $x <= $y; $x++) { $fld = $adb->field_name($result, $x); $is_hid = strpos($fld->name, "_hid"); $clear_fld_name_arr = explode("_", $fld->name); $clear_fld_calculation_type = strtoupper($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); unset($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); $clear_fld_name = implode("_", $clear_fld_name_arr); if ($clear_fld_calculation_type != "COUNT" && (in_array($fld->name, $this->skip_fields) || in_array($clear_fld_name, $this->skip_fields))) { continue; } if (!empty($selectedcolumns_arr) && in_array($fld->name, $this->g_flds) && isset($this->columns_array[$fld->name]) && $this->columns_array[$fld->name] != "") { if ($x == 0 && !$this->report_obj->in_multiarray($this->columns_array[$fld->name], $selectedcolumns_arr, "fieldcolname") && $this->generate_type != "grouping") { $group_value = $custom_field_values[$fld->name]; continue; } } if ($x > 0 && $this->generate_type == "grouping" && $this->report_obj->in_multiarray($this->columns_array[$clear_fld_name] . ":{$clear_fld_calculation_type}", $this->summaries_columns, "columnname") !== true) { continue; } if ($is_hid === false && !in_array($fld->name, $this->skip_fields) && !in_array($clear_fld_name, $this->skip_fields)) { if (in_array($fld->name, $group_cols) !== true) { // ITS4YOU-CR SlOl 13. 3. 2014 13:37:11 if ($this->generate_type == "grouping") { $summaries_fld_test = explode("_", $fld->name); $smft_lk = count($summaries_fld_test) - 1; if (in_array(strtolower($summaries_fld_test[$smft_lk]), $this->calculation_type_array)) { $calculation_type = $summaries_fld_test[$smft_lk]; $fld_name = ""; for ($index = 0; $index < count($summaries_fld_test); $index++) { if ($fld_name != "") { $fld_name .= "_"; } $fld_name .= $summaries_fld_test[$index]; } } else { $fld_name = $fld->name; } } else { $fld_name = $fld->name; } $s_type = "SC"; if ($this->generate_type == "grouping" && isset($this->sm_columns_array) && !empty($this->sm_columns_array) && array_key_exists($fld_name, $this->sm_columns_array)) { $s_type = "SM"; $columns_array_lbl = $this->sm_columns_array[$fld_name] . ":{$calculation_type}"; } elseif ($this->columns_array[$fld->table . "." . $fld_name]) { $columns_array_lbl = $this->columns_array[$fld->table . "." . $fld_name]; } elseif (isset($this->columns_array[$fld_name])) { $columns_array_lbl = $this->columns_array[$fld_name]; } else { $columns_array_lbl = ""; } // we will skipp 2, 3 group by values to display later correct values !! if ($this->generate_type == "grouping" && in_array($fld_name, $group_cols)) { continue; } if (isset($this->columns_array[$fld->name]) && $this->columns_array[$fld->name] != "") { if (!empty($selectedcolumns_arr)) { if ($this->report_obj->in_multiarray($this->columns_array[$fld->name], $selectedcolumns_arr, "fieldcolname") !== true && !in_array($fld->name, $this->g_flds)) { continue; } } } if ($this->generate_type != "grouping" && !isset($this->columns_array[$fld->name])) { continue; } // $this->getQFArray(); $headerLabel = $this->getHeaderLabel($this->report_obj->record, $s_type, $fld_name, $columns_array_lbl); if (count($this->g_colors) > 1 && $x == 0 && $this->generate_type == "grouping") { // $headerLabel = " "; $headerLabel = $this->getGroupsHeaderLabelStr(); } $header_style = ""; $header_style .= " style='" . $this->header_style . "' "; $header[] = array("style" => $header_style, "label" => $headerLabel); // ITS4YOU-END 14. 3. 2014 8:33:46 } } // END } } // ITS4YOU-CR SlOl | 12.8.2014 11:40 variable to populate header for record details $populate_detail_header = true; // ITS4YOU-CR SlOl | 12.8.2014 11:40 variable to populate header for record details end $display_groupinfo_row = false; $this->group_data_array = array(); $grouping_totals = $group2_values = array(); $this->setChartsColumns(); if ($noofrows > 0) { $f_i = $f_r_i = 0; $group_info_tr_value = $old_gv = ""; // tr_html of Group Value (Count) Info in case summaries columns empty start do { $arraylists = array(); if (count($this->groupslist) == 1) { $newvalue = $custom_field_values[0]; } elseif (count($this->groupslist) == 2) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; } elseif (count($this->groupslist) == 3) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; $tnewvalue = $custom_field_values[2]; } if ($newvalue == "") { $newvalue = "-"; } if ($snewvalue == "") { $snewvalue = "-"; } if ($tnewvalue == "") { $tnewvalue = "-"; } /* if ($this->generate_type == "grouping") { $group_value = $custom_field_values[$this->g_flds[0]]; } */ $valtemplate_tr = "<tr>"; if ($this->generate_type == "grouping" && isset($this->g_colors[1]) && $this->g_colors[1] != "" && ($this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols" || $this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols")) { $y = 1; } $currency_id = ""; if (isset($custom_field_values["currency_id"]) && $custom_field_values["currency_id"] != "") { $currency_id = $custom_field_values["currency_id"]; } $this->data_record_id = ""; if (isset($custom_field_values["record_id"]) && $custom_field_values["record_id"] != "") { $this->data_record_id = $custom_field_values["record_id"]; } // ITS4YOU-CR SlOl | 12.8.2014 11:40 variables used for group info rows $detail_row_info = array(); // ITS4YOU-END 12.8.2014 11:41 // Variables used for Group Value (Count) Info in case summaries columns empty start $group_info_tr = ""; $group_info_tr_added = false; $gc_i = 0; // Set up group_value for Group Value (Count) Info in case group column not in selectedcolumns_arr start // $this->summaries_columns_count if (count($this->g_flds) == 1 && count($this->detail_selectedcolumns_arr) > 0) { if ($display_groupinfo_row !== true && isset($this->columns_array[$this->g_flds[0]]) && $this->columns_array[$this->g_flds[0]] != "") { $display_groupinfo_row = true; } } elseif ($this->report_obj->reportinformations["Group1"] != "none" && $this->summaries_columns_count == 0 && $display_groupinfo_row !== true) { $display_groupinfo_row = true; } /* if (count($this->g_flds)>1 && count($this->detail_selectedcolumns_arr)>0 && $this->summaries_columns_count===0) { $display_groupinfo_row = true; } */ // LIMIT FOR GROUP INFO ROW START if ($display_groupinfo_row == true && isset($this->report_obj->reportinformations["columns_limit"]) && $this->report_obj->reportinformations["columns_limit"] != "" && isset($this->group_cols_array[1]) && $this->group_cols_array[1] != "") { $a_gv = $custom_field_values[$this->group_cols_array[1]]; if ($old_gv != $a_gv) { $old_gv = $custom_field_values[$this->group_cols_array[1]]; $f_r_i = 0; } if ($this->report_obj->reportinformations["columns_limit"] > 0) { if ($a_gv == $old_gv && $f_r_i >= $this->report_obj->reportinformations["columns_limit"]) { continue; } } } // LIMIT FOR GROUP INFO ROW END // Variables used for Group Value (Count) Info in case summaries columns empty end for ($i = 0; $i <= $y; $i++) { $fld = $adb->field_name($result, $i); $clear_fld_name_arr = explode("_", $fld->name); $clear_fld_calculation_type = strtoupper($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); unset($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); $clear_fld_name = implode("_", $clear_fld_name_arr); if (in_array($fld->name, $this->skip_fields) || in_array($clear_fld_name, $this->skip_fields)) { continue; } if ($i == 0 && !empty($selectedcolumns_arr) && in_array($fld->name, $this->g_flds) && isset($this->columns_array[$fld->name]) && $this->columns_array[$fld->name] != "") { if (!$this->report_obj->in_multiarray($this->columns_array[$fld->name], $selectedcolumns_arr, "fieldcolname") && $this->generate_type != "grouping") { $group_value = $custom_field_values[$fld->name]; continue; } } if (isset($this->columns_array[$fld->name]) && $this->report_obj->in_multiarray($this->columns_array[$fld->name], $this->detail_selectedcolumns_arr, "fieldcolname") !== true && in_array($fld->name, $this->g_flds) !== true) { continue; } if ($i > 0 && $this->generate_type == "grouping" && $this->report_obj->in_multiarray($this->columns_array[$clear_fld_name] . ":{$clear_fld_calculation_type}", $this->summaries_columns, "columnname") !== true) { continue; } if ($this->generate_type != "grouping" && !isset($this->columns_array[$fld->name])) { continue; } // detail_selectedcolumns_arr $first_td = true; // skipp group columns in case not in selectedcolumns_arr end // ITS4YOU-CR SlOl 17. 2. 2014 10:23:31 $is_hid = strpos($fld->name, "_hid"); if ($is_hid === false) { if ($this->generate_type == "grouping") { $summaries_fld_test = explode("_", $fld->name); $smft_lk = count($summaries_fld_test) - 1; if (in_array(strtolower($summaries_fld_test[$smft_lk]), $this->calculation_type_array)) { $calculation_type = $summaries_fld_test[$smft_lk]; $fld_name = ""; for ($index = 0; $index < count($summaries_fld_test); $index++) { if ($fld_name != "") { $fld_name .= "_"; } $fld_name .= $summaries_fld_test[$index]; } } else { $fld_name = $fld->name; } // we will skipp 2, 3 group by values to display later correct values !! if ($this->generate_type == "grouping" && in_array($fld_name, $group_cols)) { continue; } } $hid_url = ""; $fld_hid = $adb->query_result($result, $f_i, $fld->name . "_hid"); if (array_key_exists($fld->name, $this->ui10_fields) && !empty($custom_field_values[$i])) { $fld_hid = $custom_field_values[$i]; } if (isset($fld_hid) && $fld_hid != "") { $entitytype = getSalesEntityType($fld_hid); if ($entitytype != "") { switch ($entitytype) { case "Calendar": $hid_url = 'index.php?module=Calendar&action=DetailView&record=' . $fld_hid . '&return_module=ITS4YouReports&return_action=resultGenerate&return_id=' . vtlib_purify($_REQUEST["record"]) . '&activity_mode=Task'; break; case "Events": $hid_url = 'index.php?module=Calendar&action=DetailView&record=' . $fld_hid . '&return_module=ITS4YouReports&return_action=resultGenerate&return_id=' . vtlib_purify($_REQUEST["record"]) . '&activity_mode=Events'; break; default: $hid_url = 'index.php?module=' . $entitytype . '&action=DetailView&record=' . $fld_hid . '&return_module=ITS4YouReports&return_action=resultGenerate&return_id=' . vtlib_purify($_REQUEST["record"]); break; } } else { $user = '******'; $u_result = $adb->pquery("SELECT count(*) as count from vtiger_users where id = ?", array($fld_hid)); if ($adb->query_result($u_result, 0, 'count') > 0) { $user = '******'; } if (is_admin($current_user)) { if ($user == 'no') { $hid_url = "index.php?module=Settings&action=GroupDetailView&groupId=" . $fld_hid; } else { $hid_url = "index.php?module=Users&action=DetailView&record=" . $fld_hid; } } } } $fld_type = $column_definitions[$i]->type; /* if (in_array($fld->name, $this->convert_currency)) { if ($custom_field_values[$i] != '') $fieldvalue = convertFromMasterCurrency($custom_field_values[$i], $current_user->conv_rate); else $fieldvalue = getTranslatedString($custom_field_values[$i]); } elseif (in_array($fld->name, $this->append_currency_symbol_to_value)) { $curid_value = explode("::", $custom_field_values[$i]); $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); if ($custom_field_values[$i] != '') $fieldvalue = $cur_sym_rate['symbol'] . " " . $currency_value; else $fieldvalue = getTranslatedString($custom_field_values[$i]); } elseif ($fld->name == "PurchaseOrder_Currency" || $fld->name == "SalesOrder_Currency" || $fld->name == "Invoice_Currency" || $fld->name == "Quotes_Currency") { if ($custom_field_values[$i] != '') $fieldvalue = getCurrencyName($custom_field_values[$i]); else $fieldvalue = getTranslatedString($custom_field_values[$i]); } elseif (array_key_exists($fld->name, $this->ui10_fields) && !empty($custom_field_values[$i])) { */ if (array_key_exists($fld->name, $this->ui10_fields) && !empty($custom_field_values[$i])) { $type = getSalesEntityType($custom_field_values[$i]); $tmp = getEntityName($type, $custom_field_values[$i]); if (is_array($tmp)) { foreach ($tmp as $key => $val) { $fieldvalue = $val; break; } } else { $fieldvalue = $custom_field_values[$i]; } } else { if ($custom_field_values[$i] != '') { $fieldvalue = getTranslatedString($custom_field_values[$i]); } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); //check for Roll based pick list $temp_val = $fld->name; if (is_array($picklistarray)) { if (array_key_exists($temp_val, $picklistarray)) { if (!in_array($custom_field_values[$i], $picklistarray[$fld->name]) && $custom_field_values[$i] != '') { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } } } if (is_array($picklistarray[1])) { if (array_key_exists($temp_val, $picklistarray[1])) { $temp = explode(", ", str_ireplace(' |##| ', ', ', $fieldvalue)); $temp_val = array(); foreach ($temp as $key => $val) { if (!in_array(trim($val), $picklistarray[1][$fld->name]) && trim($val) != '') { $temp_val[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $temp_val[] = $val; } } $fieldvalue = is_array($temp_val) ? implode(", ", $temp_val) : ''; } } if ($fieldvalue == "") { $fieldvalue = "-"; } else { if ($fld->name == 'LBL_ACTION') { $fieldvalue = "<a href='index.php?module={$this->primarymodule}&action=DetailView&record={$fieldvalue}' target='_blank'>" . getTranslatedString('LBL_VIEW_DETAILS') . "</a>"; } else { if (stristr($fieldvalue, "|##|")) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } else { if ($fld_type == "date" || $fld_type == "datetime") { $fieldvalue = getValidDisplayDate($fieldvalue); } } } } if ($hid_url != "") { $fieldvalue = "<a href='{$hid_url}' target='_blank'>{$fieldvalue}</a> "; } $bg_color = ""; if ($this->generate_type == "grouping") { if ($i == 0 && in_array($fld->name, $this->g_flds)) { $group_value = $custom_field_values[$i]; } if (isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] != "cols" && $this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols") { $bg_color_val = $this->g_colors[1]; } elseif (isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols") { $bg_color_val = $this->g_colors[2]; } else { $bg_color_val = $this->g_colors[0]; } $bg_color = "background-color:{$bg_color_val};"; } // $txt_align = $this->getFldAlignment($fld->name, $fieldvalue); $fld_style_arr = $this->getFldStyle($fld->name, $fieldvalue); if ($this->generate_type == "grouping" && is_numeric($fieldvalue) && !in_array($fld->name, $this->group_cols_array)) { $fld_name_exploded = explode("_", $fld->name); $calculation_type = $fld_name_exploded[count($fld_name_exploded) - 1]; if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) { $grouping_totals[$fld->name][$currency_id][] = number_format($fieldvalue, 3, ".", ""); } else { $grouping_totals[$fld->name][] = number_format($fieldvalue, 3, ".", ""); } } // // timeline_type2"]=="cols REPORT if ($this->generate_type == "grouping" && isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols") { $array_to_totals = array($result, $custom_field_values, $i, $t_y); $currency_string = $this->get_currency_sumbol_str($currency_id); $group2_arr = $this->getSubGroupCols($group_value, 1, "", $currency_id, $array_to_totals); if (!empty($group2_arr["headers"])) { //$group2_headers = array_merge($group2_headers, $group2_arr["headers"]); $group2_headers = $group2_arr["headers"]; } } // charts array population start $ch_fldname = strtolower($fld->name); if (!empty($this->charts) && !empty($this->charts["charttypes"])) { $this->setChArrayValues("charttitle", '', $this->charts["charttitle"]); if ($this->charts["x_group"] == "group1" && in_array($ch_fldname, $this->charts["charts_ds_columns"])) { $this->setDataseriesArray($group_value, $fieldvalue, $currency_id, $ch_fldname); } } // charts array population end /** * ** GROUP INFO ROW DISPLAY for GROUPS In case selected columns not empty *** GROUPING REPORT * */ if ($first_td === true && $this->generate_type == "grouping" && count($this->g_colors) == 1 && count($this->detail_selectedcolumns_arr) > 0) { if (!isset($this->summaries_header) || empty($this->summaries_header)) { $this->summaries_header = $header; } $header_col_lstr = ""; if (isset($this->summaries_header[$i]["label"]) && trim($this->summaries_header[$i]["label"]) != "") { $header_col_lbl = $this->summaries_header[$i]["label"]; } else { $header_col_as = $clear_fld_name; $header_col_str = $this->columns_array[$header_col_as]; $header_col_lbl = $this->getHeaderLabel($this->report_obj->record, "SC", $header_col_as, $header_col_str); } // header population for Groups row start if ($this->selectedcolumns_header_row == "") { $header = array(); if (!empty($selectedcolumns_arr)) { foreach ($selectedcolumns_arr as $sc_key => $sc_array) { $sc_header_style = " style='" . $this->header_style . "' "; $sc_column_str = $sc_array["fieldcolname"]; $headerLabel = $this->getHeaderLabel($this->report_obj->record, "SC", "", $sc_column_str); $header[] = array("style" => $sc_header_style, "label" => $headerLabel); } $sc_header = $sc_header_sp = ""; /* $sc_header_sp .= "<td class='rpt4youGrpHead0' colspan='".count($header)."'> </td>"; $sc_header_sp .= "</tr>"; $sc_header_sp .= "<tr>"; */ foreach ($header as $header_f_arr) { $header_style = $header_f_arr["style"]; $headerLabel = $header_f_arr["label"]; $sc_header .= "<td class='rpt4youCellLabel' rowspan='1' colspan='1' {$header_style} align='center' nowrap >{$headerLabel}</td>"; } $sc_header .= "</tr>"; $sc_header .= "<tr>"; $this->selectedcolumns_header_row = $sc_header; //$this->selectedcolumns_header_row_sp = $sc_header_sp; } $this->display_group_totals = false; } // header population for Groups row end if ($display_groupinfo_row === true && count($this->g_flds) == 1) { $sp_group_value = $custom_field_values[$this->group_cols_array[1]]; if ($group_info_tr_added !== true) { $sm_calculation_type = ""; /* if ($f_i==0) { $group_info_tr .= $this->selectedcolumns_header_row; } */ if (isset($this->summaries_columns) && !empty($this->summaries_columns)) { $detail_row_info = array(); foreach ($this->summaries_columns as $sm_key => $sm_col_array) { $sm_col_str = $sm_col_array['columnname']; $sm_col_alias = ""; $sm_col_str_exploded = explode(":", $sm_col_str); $sm_lk = count($sm_col_str_exploded) - 1; if (in_array(strtolower($sm_col_str_exploded[$sm_lk]), $this->calculation_type_array)) { $sm_calculation_type = strtolower($sm_col_str_exploded[$sm_lk]); $sm_col_lbl_str = implode(":", $sm_col_str_exploded); unset($sm_col_str_exploded[$sm_lk]); $sm_col_str = implode(":", $sm_col_str_exploded); if (isset($this->columns_array[$sm_col_str]["fld_alias"]) && $this->columns_array[$sm_col_str]["fld_alias"] != "") { $sm_col_alias = $this->columns_array[$sm_col_str]["fld_alias"]; } $sm_col_alias .= "_{$sm_calculation_type}"; } $sm_value = $custom_field_values[$sm_col_alias]; $sm_col_Label = $this->getHeaderLabel($this->report_obj->record, "SM", $sm_col_alias, $sm_col_lbl_str); // $header_col_lstr = ";"; // $detail_row_info[] = $sm_col_Label." = ".$this->getFldNumberFormat($sm_col_alias, $sm_value, $currency_id).$header_col_lstr; $detail_row_info[] = $sm_col_Label . " = " . $this->getFldNumberFormat($sm_col_alias, $sm_value, $currency_id); } } $group_info_tr_value = $this->getFldNumberFormat($this->group_cols_array[1], $sp_group_value, $currency_id, true); // $group_records_count = count($this->result_array[$sp_group_value]); $group_records_count = $custom_field_values["crmid_count"]; $group_info_fld_str = $this->columns_array[$this->group_cols_array[1]]; $group_info_headerLabel = $this->getHeaderLabel($this->report_obj->record, "SC", $this->group_cols_array[1], $group_info_fld_str); $group_info_tr .= "<tr><td class='rpt4youGrpHead' colspan='" . count($header) . "' style='text-align:left;background-color:#EEEEEE;' nowrap ><b>"; $group_info_tr .= "{$group_info_headerLabel} = {$group_info_tr_value} ({$group_records_count}): "; $group_info_tr .= implode(";", $detail_row_info) . "</b></td></tr>"; $group_info_tr_added = true; } } /** * ** GROUP INFO ROW DISPLAY for GROUPS In case selected columns not empty END *** STANDARD REPORT * */ } else { // Group Value (Count) Info in case summaries columns empty start if ($display_groupinfo_row === true) { $sp_group_value = $custom_field_values[$this->group_cols_array[1]]; if ($sp_group_value != $direct_group_info_tr_value) { $direct_group_info_tr_value = $sp_group_value; $group_info_tr_value = $this->getFldNumberFormat($this->group_cols_array[1], $sp_group_value, $currency_id); // $group_records_count = count($this->result_array[$sp_group_value]); $group_records_count = $custom_field_values["crmid_count"]; $group_info_fld_str = $this->columns_array[$this->g_flds[0]]; $group_info_headerLabel = $this->getHeaderLabel($this->report_obj->record, "SC", $this->g_flds[0], $group_info_fld_str); $group_info_tr = "<tr><td class='rpt4youGrpHead' colspan='" . count($header) . "' style='text-align:left;background-color:#EEEEEE;' nowrap >"; $group_info_tr .= "<b>{$group_info_headerLabel} = {$group_info_tr_value} ({$group_records_count})</b>"; $group_info_tr .= "</td></tr>"; $group_info_tr_added = true; } } // Group Value (Count) Info in case summaries columns empty end /** * ** DEFAULT VALUE DISPLAY *** * */ $fld_style = $this->getFldStyleString($fld_style_arr); $valtemplate_tr .= "<td class='rpt4youGrpHead' style='{$fld_style} {$bg_color}' nowrap >" . $this->getFldNumberFormat($fld->name, $fieldvalue, $currency_id) . "{$currency_string}</td>"; } /* * ** DISPLAY timeline_type2 == "cols" *** */ if ($this->generate_type == "grouping" && isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols") { $g_ri = 1; foreach ($group2_headers as $group_h_key => $group_h_arr) { if (isset($group2_arr["values"][$group_h_key]) && !empty($group2_arr["values"][$group_h_key])) { // foreach ($group2_arr["values"][$group_h_key] as $gv_arr) { for ($gv_i = 0; $gv_i < count($group_h_arr); $gv_i++) { if (isset($group2_arr["values"][$group_h_key][$gv_i]) && !empty($group2_arr["values"][$group_h_key][$gv_i])) { $gv_arr = $group2_arr["values"][$group_h_key][$gv_i]; // $txt_align = $gv_arr["text-align"]; $fld_style = $gv_arr["fld_style"]; $gv_value = $gv_arr["value"]; $gv_fld_name = strtolower($gv_arr["fld_name"]); if ($gv_fld_name != "") { if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) { $grouping_totals[$group_h_key][$gv_fld_name][$currency_id][] = $gv_value; } else { $grouping_totals[$group_h_key][$gv_fld_name][] = $gv_value; } } $fw_weight = ""; if ($group_h_key == "LBL_GROUPING_TOTALS") { $fw_weight = "font-weight:bold;"; } // chart data population start if ($this->charts["x_group"] == "group2" && in_array($gv_fld_name, $this->charts["charts_ds_columns"]) && $group_h_key != "LBL_GROUPING_TOTALS") { $this->setDataseriesArray($group_h_key, $gv_value, $currency_id, $gv_fld_name, $group_value); } if ($this->charts["x_group"] == "group1" && in_array($gv_fld_name, $this->charts["charts_ds_columns"]) && $group_h_key == "LBL_GROUPING_TOTALS") { $this->setDataseriesArray($group_value, $gv_value, $currency_id, $gv_fld_name); } // chart data population end $valtemplate_tr .= "<td class='rpt4youGrpHead' style='{$fld_style} {$fw_weight}' nowrap >" . $this->getFldNumberFormat($gv_fld_name, $gv_value, $currency_id) . "</td>"; $g_ri++; } } } else { if ($group_h_key > 0 && isset($group2_headers[$group_h_key]) && !empty($group2_headers[$group_h_key]) && $group2_headers[$group_h_key] != "") { for ($gv_i = 0; $gv_i < count($group_h_arr); $gv_i++) { $valtemplate_tr .= "<td class='rpt4youGrpHead' style='text-align:center;' nowrap > </td>"; $g_ri++; } } } } } /* TOTALS CALCULATION START */ if (isset($this->columns_array[$fld->name])) { $columns_array_lbl = $this->columns_array[$fld->name]; } elseif ($this->columns_array[$fld->table . "." . $fld->name]) { $columns_array_lbl = $this->columns_array[$fld->table . "." . $fld->name]; } elseif ($fld->table != "") { $columns_array_lbl = $fld->table . "." . $fld->name; } else { $columns_array_lbl = $fld->name; } $TheaderLabel = $this->getHeaderLabel($reportid, "CT", $fld->name, $columns_array_lbl); $fld_totals_key = $fld->name; // $to_totals_res = $this->setToTotalsArray($to_totals_res, $fld_totals_key, $fieldvalue, $to_totals_array, $currency_id); $this->to_totals_res = $this->setToTotalsArray($noofrows, $this->to_totals_res, $fld_totals_key, $fieldvalue, $this->to_totals_array, $currency_id); /* TOTALS CALCULATION END */ } $first_td = false; // ITS4YOU-END 17. 2. 2014 10:23:33 $gc_i++; } // timeline_type3"]=="cols" REPORT if ($this->generate_type == "grouping" && isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] != "cols" && $this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols") { $gcols3_valtemplate = ""; $tl_g3_colspan = 1; if (empty($this->group_data_array[$group_value])) { $this->setGroupDataArray($group_value, $currency_id); } $group_value = html_entity_decode($group_value, ENT_QUOTES, $default_charset); if (isset($currency_id) && $currency_id != "") { $group_data_array = $this->group_data_array[$group_value][$currency_id]; } else { $group_data_array = $this->group_data_array[$group_value]; } // foreach($this->result_array[$group_value] as $group_row_key => $group_row_array) { foreach ($group_data_array as $group_row_key => $group_row_array) { // continue in case summary filter will not contain group values /* if (!array_key_exists($group_row_key, $this->group_data_array[$group_value])) { continue; } */ $gcols3_valtemplate .= "</tr><tr>"; $bg_color_val = $this->g_colors[2]; $bg_color = "background-color:{$bg_color_val};"; // this is possible only in case group 2 = rows and group 3 = cols, so static rpt4youGrpHead_1 is ok here $gcols3_valtemplate .= "<td class='rpt4youGrpHead_1' style='text-align:left;' nowrap >" . $group_row_key . "</td>"; $g_ri = 1; foreach ($header as $header_f_key => $header_f_arr) { $headerLabel = $header_f_arr["label"]; if (!in_array($headerLabel, array("LBL_GROUPING_TOTALS")) && $header_f_key !== 0) { if (isset($group_data_array[$group_row_key][$headerLabel])) { foreach ($group_data_array[$group_row_key][$headerLabel] as $fld_key => $fld_value) { $clear_fld_name_arr = explode("_", $fld_key); $clear_fld_calculation_type = strtoupper($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); unset($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); $clear_fld_name = implode("_", $clear_fld_name_arr); if (in_array($fld_key, $this->skip_fields) || in_array($clear_fld_name, $this->skip_fields)) { continue; } if ($this->report_obj->in_multiarray($this->columns_array[$clear_fld_name] . ":{$clear_fld_calculation_type}", $this->summaries_columns, "columnname") !== true) { continue; } //$txt_align = $this->getFldAlignment($fld_key, $fld_value); $fld_style_arr = $this->getFldStyle($fld_key, $fld_value); $calculation_arr = explode("_", $fld_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "avg") { $ct_fldstr = ""; $ct_fi = count($calculation_arr) - 1; for ($ct_i = 0; $ct_i < $ct_fi; $ct_i++) { if ($ct_i > 0 && $ct_i != $ct_fi) { $ct_fldstr .= "_"; } $ct_fldstr .= $calculation_arr[$ct_i]; } $ct_fldstr_sum = $ct_fldstr . "_sum"; if ($currency_id != "") { $group_totals[$group_value][$currency_id][$group_row_key][$fld_key] = $group_totals[$group_value][$currency_id][$group_row_key][$ct_fldstr_sum]; $group_f_totals[$group_value][$currency_id][$headerLabel][$fld_key][] = $fld_value; $group_f_totals[$group_value][$currency_id]["row_totals"][$fld_key][] = $fld_value; } else { $group_totals[$group_value][$group_row_key][$fld_key] = $group_totals[$group_value][$group_row_key][$ct_fldstr_sum]; $group_f_totals[$group_value][$headerLabel][$fld_key][] = $fld_value; $group_f_totals[$group_value]["row_totals"][$fld_key][] = $fld_value; } } else { if ($currency_id != "") { $group_totals[$group_value][$currency_id][$group_row_key][$fld_key][] = $fld_value; $group_f_totals[$group_value][$currency_id][$headerLabel][$fld_key][] = $fld_value; $group_f_totals[$group_value][$currency_id]["row_totals"][$fld_key][] = $fld_value; } else { $group_totals[$group_value][$group_row_key][$fld_key][] = $fld_value; $group_f_totals[$group_value][$headerLabel][$fld_key][] = $fld_value; $group_f_totals[$group_value]["row_totals"][$fld_key][] = $fld_value; } } // chart data population start /* if ($this->charts["x_group"]=="group2" && in_array($fld_key, $this->charts["charts_ds_columns"])) { $this->setDataseriesArray($group_row_key, $fld_value, $currency_id, $fld_key, $group_value); } */ // chart data population end $fld_style = $this->getFldStyleString($fld_style_arr); $gcols3_valtemplate .= "<td class='rpt4youGrpHead' style='{$fld_style} {$bg_color}' nowrap >" . $this->getFldNumberFormat($fld_key, $fld_value, $currency_id) . "</td>"; $g_ri++; } } else { for ($g3_i = 0; $g3_i < $this->sum_col_i; $g3_i++) { $gcols3_valtemplate .= "<td class='rpt4youGrpHead' style='text-align:center;font-weight:bold;{$bg_color}' nowrap > </td>"; $g_ri++; } } } elseif ($headerLabel == "LBL_GROUPING_TOTALS") { $count_value = 0; if ($currency_id != "") { $group_totals_array = $group_totals[$group_value][$currency_id][$group_row_key]; } else { $group_totals_array = $group_totals[$group_value][$group_row_key]; } foreach ($group_totals_array as $g_t_key => $g_t_array) { $calculation_arr = explode("_", $g_t_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "count") { foreach ($g_t_array as $count_val) { $count_value += $count_val; } } if ($calculation_type == "avg") { $fld_value = array_sum($g_t_array) / $count_value; } else { $fld_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); } //$txt_align = $this->getFldAlignment($g_t_key, $fld_value); $fld_style_arr = $this->getFldStyle($g_t_key, $fld_value); $fld_style = $this->getFldStyleString($fld_style_arr); $gcols3_valtemplate .= "<td class='rpt4youGrpHead' style='{$fld_style} font-weight:bold;{$bg_color}' nowrap >" . $this->getFldNumberFormat($g_t_key, $fld_value, $currency_id) . "</td>"; $g_ri++; } } } } $bg_color_val1 = $this->g_colors[1]; $bg_color1 = "background-color:{$bg_color_val1};"; foreach ($header as $header_f_key => $header_f_arr) { $headerLabel = $header_f_arr["label"]; if ($currency_id != "") { $group_totals_f_array = $group_f_totals[$group_value][$currency_id]; } else { $group_totals_f_array = $group_f_totals[$group_value]; } if (!in_array($headerLabel, array("LBL_GROUPING_TOTALS")) && $header_f_key !== 0) { if (isset($group_totals_f_array[$headerLabel]) && !empty($group_totals_f_array[$headerLabel])) { $count_value = 0; foreach ($group_totals_f_array[$headerLabel] as $g_t_key => $g_t_array) { $clear_fld_name_arr = explode("_", $g_t_key); $clear_fld_calculation_type = strtoupper($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); unset($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); $clear_fld_name = implode("_", $clear_fld_name_arr); if (in_array($g_t_key, $this->skip_fields) || in_array($clear_fld_name, $this->skip_fields)) { continue; } if ($this->report_obj->in_multiarray($this->columns_array[$clear_fld_name] . ":{$clear_fld_calculation_type}", $this->summaries_columns, "columnname") !== true) { continue; } $calculation_arr = explode("_", $g_t_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "count") { foreach ($g_t_array as $count_val) { $count_value += $count_val; } } if ($calculation_type == "avg") { $ct_fldstr = ""; $ct_fi = count($calculation_arr) - 1; for ($ct_i = 0; $ct_i < $ct_fi; $ct_i++) { if ($ct_i > 0 && $ct_i != $ct_fi) { $ct_fldstr .= "_"; } $ct_fldstr .= $calculation_arr[$ct_i]; } $ct_fldstr_sum = $ct_fldstr . "_sum"; $g_t_array = $group_totals_f_array[$headerLabel][$ct_fldstr_sum]; $fld_value = array_sum($g_t_array) / $count_value; } else { $fld_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); } //$txt_align = $this->getFldAlignment($g_t_key, $fld_value); $fld_style_arr = $this->getFldStyle($g_t_key, $fld_value); if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) { $grouping_totals[$headerLabel][$g_t_key][$currency_id][] = $fld_value; } else { $grouping_totals[$headerLabel][$g_t_key][] = $fld_value; } // charts array population start if ($g_t_key == $this->charts["charts_ds_column"]) { // SPECIAL CHART DATA POPULATION FOR G3 COLS $cols_alias = ""; if ($this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols") { $cols_alias = $this->g_flds[1]; } elseif ($this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols") { $cols_alias = $this->g_flds[2]; } if (!isset($this->ch_array["dataseries_label"])) { $this->setDataseriesLabel($cols_alias); } //$dataseries_label_key = $this->getHeaderLabel($this->report_obj->record, "SM", $this->g_flds[2], $this->columns_array[$this->g_flds[2]]); //$this->setChArrayValues("dataseries_label", 'key', $dataseries_label_key); if ($currency_id != "") { $ch_subkey = $headerLabel . " (" . $this->currency_symbols[$currency_id] . ")"; } else { $ch_subkey = $headerLabel; } // addToSubvalChArrayValues($ch_key, $ch_subkey, $ch_value, $option_key="", $currency_id="") { $this->addToSubvalChArrayValues("dataseries", $headerLabel, $fld_value, $group_value, $currency_id); if ($this->ch_array["charttype"] != "horizontal") { $this->setChArrayValues("dataseries", $ch_subkey, $fld_value); $this->setHChArrayValues("hch_dataseries", $group_value, $fld_value, $currency_id); } } // charts array population end if ($this->charts["x_group"] == "group1" && in_array($g_t_key, $this->charts["charts_ds_columns"])) { $this->setDataseriesArray($group_value, $fld_value, $currency_id, $g_t_key); } if ($this->charts["x_group"] == "group2" && in_array($g_t_key, $this->charts["charts_ds_columns"])) { $this->setDataseriesArray($headerLabel, $fld_value, $currency_id, $g_t_key, $group_value); } $fld_style = $this->getFldStyleString($fld_style_arr); $valtemplate_tr .= "<td class='rpt4youGrpHead' style='{$fld_style} {$bg_color1}' nowrap >" . $this->getFldNumberFormat($g_t_key, $fld_value, $currency_id) . "</td>"; } } else { for ($g3_i = 0; $g3_i < $this->sum_col_i; $g3_i++) { $valtemplate_tr .= "<td class='rpt4youGrpHead' style='text-align:center;{$bg_color1}' nowrap > </td>"; } } } elseif ($headerLabel == "LBL_GROUPING_TOTALS") { $count_value = 0; if (isset($group_totals_f_array["row_totals"]) && !empty($group_totals_f_array["row_totals"])) { foreach ($group_totals_f_array["row_totals"] as $g_t_key => $g_t_array) { $calculation_arr = explode("_", $g_t_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "avg") { $ct_fldstr = ""; $ct_fi = count($calculation_arr) - 1; for ($ct_i = 0; $ct_i < $ct_fi; $ct_i++) { if ($ct_i > 0 && $ct_i != $ct_fi) { $ct_fldstr .= "_"; } $ct_fldstr .= $calculation_arr[$ct_i]; } $ct_fldstr_sum = $ct_fldstr . "_sum"; $g_t_array = $group_totals_f_array["row_totals"][$ct_fldstr_sum]; } if ($calculation_type == "count") { foreach ($g_t_array as $count_val) { $count_value += $count_val; } } if ($calculation_type == "avg") { $fld_value = array_sum($g_t_array) / $count_value; } else { $fld_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); } //$txt_align = $this->getFldAlignment($g_t_key, $fld_value); $fld_style_arr = $this->getFldStyle($g_t_key, $fld_value); $fld_style = $this->getFldStyleString($fld_style_arr); if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) { $grouping_totals[$headerLabel][$g_t_key][$currency_id][] = $fld_value; } else { $grouping_totals[$headerLabel][$g_t_key][] = $fld_value; } $valtemplate_tr .= "<td class='rpt4youGrpHead' style='{$fld_style} font-weight:bold;{$bg_color1}' nowrap >" . $this->getFldNumberFormat($g_t_key, $fld_value, $currency_id) . "</td>"; } } else { for ($g3_i = 0; $g3_i < $this->sum_col_i; $g3_i++) { $valtemplate_tr .= "<td class='rpt4youGrpHead' style='text-align:center;{$bg_color1}' nowrap > </td>"; } } } } $valtemplate_tr .= $gcols3_valtemplate; } // details for group 1 if ($this->generate_type == "grouping" && count($this->g_colors) == 1) { if (!empty($selectedcolumns_arr)) { $valtemplate_tr .= $this->returnGroupDetailRecordsNew($group_value, $y, $selectedcolumns_arr, $currency_id); } } $valtemplate_tr .= "</tr>"; // adding tr html of Group Value (Count) Info in case summaries columns empty start if ($group_info_tr != "") { $valtemplate .= $group_info_tr; } // adding tr html of Group Value (Count) Info in case summaries columns empty end $valtemplate .= $valtemplate_tr; // ROWS REPORT if ($this->generate_type == "grouping" && isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["timeline_type2"] != "cols" && ($this->report_obj->reportinformations["timeline_type3"] != "cols" || $this->report_obj->reportinformations["timeline_type3"] == "none")) { $group2_html = $this->getSubGroupRow($group_value, $currency_id); $valtemplate .= $group2_html; } $lastvalue = $newvalue; $secondvalue = $snewvalue; $thirdvalue = $tnewvalue; $arr_val[] = $arraylists; set_time_limit($php_max_execution_time); $f_i++; // GROUPING TOTALS START if ($this->display_group_totals == true && $this->generate_type == "grouping" && $f_i == $noofrows && $this->report_obj->reportinformations["timeline_type2"] != "cols" && ($this->report_obj->reportinformations["timeline_type3"] != "cols" || $this->report_obj->reportinformations["timeline_type3"] == "none")) { $bg_color_val = $this->g_colors[0]; $bg_color = "background-color:{$bg_color_val};"; $valtemplate .= "<tr>"; $valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' style='text-align:left;" . $this->grouping_totals_bg_color . "' nowrap >" . getTranslatedString("LBL_GROUPING_TOTALS", $this->getCurrentModule4You()) . "</td>"; if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) { $to_display = array(); foreach ($grouping_totals as $g_t_key => $currency_array) { foreach ($currency_array as $currency_key => $g_t_array) { $g_t_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); //$txt_align = $this->getFldAlignment($g_t_key, $g_t_value); $fld_style_arr = $this->getFldStyle($g_t_key, $g_t_value); $fld_style = $this->getFldStyleString($fld_style_arr); $to_display[$g_t_key]["values"] .= $this->getFldNumberFormat($g_t_key, $g_t_value, $currency_key) . "<br>"; //$to_display[$g_t_key]["textalign"] = $txt_align; $to_display[$g_t_key]["fld_style"] = $fld_style; } } foreach ($to_display as $td_key => $td_arr) { //$txt_align = $td_arr["textalign"]; $fld_style = $td_arr["fld_style"]; $td_value = $td_arr["values"]; $valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' style='{$fld_style} " . $this->grouping_totals_bg_color . "' nowrap >" . $td_value . "</td>"; } } else { foreach ($grouping_totals as $g_t_key => $g_t_array) { $g_t_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); //$txt_align = $this->getFldAlignment($g_t_key, $g_t_value); $fld_style_arr = $this->getFldStyle($g_t_key, $g_t_value); $fld_style = $this->getFldStyleString($fld_style_arr); $valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' style='{$fld_style} " . $this->grouping_totals_bg_color . "' nowrap >" . $this->getFldNumberFormat($g_t_key, $g_t_value) . "</td>"; } } $valtemplate .= "</tr>"; } $f_r_i++; // GROUPING TOTALS END } while ($custom_field_values = $adb->fetch_array($result)); // GROUPING TOTALS START // GROUPING TOTAL FOR COLS START if ($this->generate_type == "grouping" && ($this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols" || $this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols") && !empty($grouping_totals)) { $bg_color = "background-color:{$bg_color_val};"; $valtemplate .= "<tr>"; $valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' nowrap style='text-align:left;" . $this->grouping_totals_bg_color . "' nowrap >" . getTranslatedString("LBL_GROUPING_TOTALS", $this->getCurrentModule4You()) . "</td>"; // foreach ($grouping_totals as $grouping_totals_key => $grouping_totals_array) { foreach ($header as $gh_i => $gh_array) { if ($gh_i > 0 && isset($grouping_totals[$gh_array["label"]])) { $grouping_totals_array = $grouping_totals[$gh_array["label"]]; foreach ($grouping_totals_array as $g_t_key => $g_t_array) { if (in_array($this->report_obj->primarymodule, ITS4YouReports::$inventory_modules)) { $g_t_value_display_arr = array(); foreach ($g_t_array as $g_ft_currency_id => $g_ft_array) { $calculation_arr = explode("_", $g_t_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "count") { $count_value = 0; foreach ($g_ft_array as $count_val) { $count_value += $count_val; } } if ($calculation_type == "avg") { $ct_fldstr = ""; $ct_fi = count($calculation_arr) - 1; for ($ct_i = 0; $ct_i < $ct_fi; $ct_i++) { if ($ct_i > 0 && $ct_i != $ct_fi) { $ct_fldstr .= "_"; } $ct_fldstr .= $calculation_arr[$ct_i]; } if (!empty($grouping_totals_array[$ct_fldstr . "_sum"][$g_ft_currency_id])) { $ct_fldstr_sum = $ct_fldstr . "_sum"; } else { $ct_fldstr_sum = $ct_fldstr . "_SUM"; } $g_ft_array = $grouping_totals_array[$ct_fldstr_sum][$g_ft_currency_id]; $g_t_value = array_sum($g_ft_array) / $count_value; } else { $g_t_value = $this->getGroupTotalsValue($g_t_key, $g_ft_array); } //$txt_align = $this->getFldAlignment($g_t_key, $g_t_value); $fld_style_arr = $this->getFldStyle($g_t_key, $g_t_value); $fld_style = $this->getFldStyleString($fld_style_arr); $g_t_value_display_arr[] = $this->getFldNumberFormat($g_t_key, $g_t_value, $g_ft_currency_id); } $g_t_value_display = implode("<br>", $g_t_value_display_arr); } else { $calculation_arr = explode("_", $g_t_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "count") { $count_value = 0; if (!empty($g_t_array)) { foreach ($g_t_array as $count_key => $count_val) { if (is_array($count_val)) { $count_value += array_sum($count_val); } else { $count_value += $count_val; } } } } if ($calculation_type == "avg") { $ct_fldstr = ""; $ct_fi = count($calculation_arr) - 1; for ($ct_i = 0; $ct_i < $ct_fi; $ct_i++) { if ($ct_i > 0 && $ct_i != $ct_fi) { $ct_fldstr .= "_"; } $ct_fldstr .= $calculation_arr[$ct_i]; } if (!empty($grouping_totals_array[$ct_fldstr . "_sum"])) { $ct_fldstr_sum = $ct_fldstr . "_sum"; } else { $ct_fldstr_sum = $ct_fldstr . "_SUM"; } $g_t_array = $grouping_totals_array[$ct_fldstr_sum]; $g_t_value = array_sum($g_t_array) / $count_value; } else { $g_t_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); } //$txt_align = $this->getFldAlignment($g_t_key, $g_t_value); $fld_style_arr = $this->getFldStyle($g_t_key, $g_t_value); $fld_style = $this->getFldStyleString($fld_style_arr); $g_t_value_display = $this->getFldNumberFormat($g_t_key, $g_t_value); } if ($grouping_totals_key == "LBL_GROUPING_TOTALS") { $valtemplate_totals .= "<td class='rpt4youGrpHeadGroupTotals' style='{$fld_style} " . $this->grouping_totals_bg_color . "' nowrap >" . $g_t_value_display . "</td>"; } else { $valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' style='{$fld_style} " . $this->grouping_totals_bg_color . "' nowrap >" . $g_t_value_display . "</td>"; } } } elseif ($gh_i > 0) { for ($gti = 0; $gti < count($this->sum_col_sql_a); $gti++) { $valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' style='{$fld_style} " . $this->grouping_totals_bg_color . "' nowrap >0</td>"; } } } $valtemplate .= $valtemplate_totals; $valtemplate .= "</tr>"; } } else { $headers_count = count($header); $valtemplate .= "<tr>"; $valtemplate .= "<td class='rpt4youGrpHead' colspan='{$headers_count}' nowrap style='text-align:left;' nowrap ><b>" . getTranslatedString("LBL_NO_DATA_TO_DISPLAY", $this->getCurrentModule4You()) . "</b></td>"; $valtemplate .= "</tr>"; } // GROUPING TOTAL FOR COLS START // GROUPING TOTALS END $header_f = ""; if ($populate_detail_header) { $h_i = 0; foreach ($header as $header_f_arr) { $header_style = $header_f_arr["style"]; $headerLabel = $header_f_arr["label"]; $header_rowspan = 1; $header_colspan = 1; if (!empty($group2_headers)) { if ($h_i == 0) { $header_rowspan++; } else { $header_colspan = count($group2_headers[$headerLabel]); } } if ($headerLabel == "LBL_GROUPING_TOTALS") { $headerLabel = getTranslatedString("LBL_GROUPING_TOTALS", $this->getCurrentModule4You()); } if (($this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols" || $this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols") && $h_i != 0 && isset($this->sum_col_i) && $this->sum_col_i != 1) { $header_colspan = $this->sum_col_i; } $header_f .= "<td class='rpt4youCellLabel' rowspan='{$header_rowspan}' colspan='{$header_colspan}' {$header_style} align='center' nowrap >{$headerLabel}</td>"; $h_i++; } if (!empty($group2_headers)) { $header_f .= '</tr><tr>'; foreach ($group2_headers as $g2_h_key => $g2_h_arr) { //if (!is_numeric($g2_h_key) || $g2_h_key>0) { foreach ($g2_h_arr as $g2_h_labels) { $headerLabel = $g2_h_labels["label"]; $header_f .= "<td class='rpt4youCellLabel' style='" . $this->header_style . "' align='center' nowrap >{$headerLabel}</td>"; } //} } } } $report_html .= $header_f; $report_html .= '</tr><tr>'; $report_html .= $valtemplate; $report_html .= "</table></div>"; if (!empty($this->to_totals_res)) { $report_html .= "<br>"; $report_html .= $this->getTotalsHTML($this->to_totals_res); } if ($this->time_debug === true) { $this->report_obj->getR4UDifTime("HTML Generated / Before PDF", true); } $report_html = str_replace("<@ReportHeaderInfo@>", $report_html_headerInfo, $report_html); $this->setReportFileInfo(); //$this->create_pdf_schedule = true; if (isset($this->create_pdf_schedule) && $this->create_pdf_schedule == true) { $this->createPDFFileForScheduler($report_html, $report_html_headerInfo); } if ($this->time_debug === true) { $this->report_obj->getR4UDifTime("After PDF", true); } if (is_writable($this->temp_files_path)) { //*** generate charts to report_html ***// //ini_set("display_errors", 1);error_reporting(63); //ITS4YouReports::sshow($this->charts); //ITS4YouReports::sshow($this->ch_array); if (!empty($this->charts) && !empty($this->charts["charttypes"]) && !empty($this->ch_array["dataseries"])) { if ($this->charts["charttypes"][$this->charts['charts_ds_columns'][0]] == "funnel") { $rw_width = "63%"; $rw_custom_style = "margin-left:18%;"; } else { $rw_width = "95%"; $rw_custom_style = ""; } if ($outputformat != "CHARTS") { $report_html_chart .= "<br/><div class='no-print' style='text-align:center;width:{$rw_width};margin:30px;{$rw_custom_style} border:0px solid red;'><div id='reports4you_widget_" . $this->report_obj->record . "' style='border:0px solid green;width:{$rw_width};margin:auto;'></div></div>"; } $report_html_chart .= $this->getReportHighCharts($export_pdf_format, $currency_id); if ($outputformat == "CHARTS") { return $report_html_chart; } $report_html .= $report_html_chart; } } else { $headers_count = count($header); $report_html .= "<tr>"; $report_html .= "<td class='rpt4youGrpHead' colspan='{$headers_count}' nowrap style='width:100%;text-align:center;font-size:1.3em;' nowrap ><b>" . getTranslatedString("Test_Not_WriteAble", $this->getCurrentModule4You()) . "</b></td>"; $report_html .= "</tr>"; } $this->setNoOfRows($noofrows); if ($this->time_debug === true) { $this->report_obj->getR4UDifTime("After CHARTS", true); } if ($directOutput) { echo $report_html; } else { $return_data[] = $report_html; $return_data[] = $noofrows; $return_data[] = $sSQL; return $return_data; } } } elseif ($outputformat == "XLS") { // oldoxls if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { $picklistarray = $this->getAccessPickListValues(); } $data = array(); if ($result) { $y = $adb->num_fields($result) - 1; $t_y = $y; $custom_field_values = $adb->fetch_array($result); $column_definitions = $adb->getFieldsDefinition($result); // HEADERS if ($this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols" || $this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols") { if ($this->report_obj->reportinformations["Group3"] && $this->report_obj->reportinformations["timeline_type3"] == "cols") { $agi = 2; foreach ($this->sum_col_sql_a as $column_str => $calculation_arr) { foreach ($calculation_arr as $calculation_type) { // $calculation_type = $calculation_arr[0]; $label_db_key = "{$column_str}:{$calculation_type}"; if ($this->report_obj->in_multiarray($label_db_key, $this->summaries_columns, "columnname") !== true) { continue; } $fld_sql_str_array = explode(" AS ", $this->columns_array[$column_str]["fld_sql_str"]); $fld_str = $fld_sql_str_array[0]; $fld_str_as = $fld_sql_str_array[1] . "_{$calculation_type}"; $g_data_key_lbl = $this->getHeaderLabel($this->report_obj->record, "SM", $fld_str_as, $label_db_key); $sum_columns_bg = $this->g_colors[1]; $sum_columns_labels[] = array("style" => " background-color:{$sum_columns_bg};font-weight:bold; ", "label" => $g_data_key_lbl); } } } else { $agi = 1; } for ($x = 0; $x < 1; $x++) { $fld = $adb->field_name($result, $x); $is_hid = strpos($fld->name, "_hid"); if ($is_hid === false && !in_array($fld->name, $this->skip_fields)) { if (!in_array($fld->name, $group_cols)) { $header_style = ""; $header_style .= " style='" . $this->header_style . "' "; //$header[] = array("style" => $header_style, "label" => " ", ); $GroupsHeaderLabel = $this->getGroupsHeaderLabelStr(); $header[] = array("style" => $header_style, "label" => $GroupsHeaderLabel); $headercols = $this->getColsHeaders($header_style, $agi); foreach ($headercols as $header_arr) { $header[] = $header_arr; $group2_headers[] = $sum_columns_labels; } } } // END } } else { for ($x = 0; $x <= $y; $x++) { $fld = $adb->field_name($result, $x); $is_hid = strpos($fld->name, "_hid"); $clear_fld_name_arr = explode("_", $fld->name); $clear_fld_calculation_type = strtoupper($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); unset($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); $clear_fld_name = implode("_", $clear_fld_name_arr); if (in_array($fld->name, $this->skip_fields) || in_array($clear_fld_name, $this->skip_fields)) { continue; } if (!empty($selectedcolumns_arr) && in_array($fld->name, $this->g_flds) && isset($this->columns_array[$fld->name]) && $this->columns_array[$fld->name] != "") { if ($x == 0 && !$this->report_obj->in_multiarray($this->columns_array[$fld->name], $selectedcolumns_arr, "fieldcolname") && $this->generate_type != "grouping") { $group_value = $custom_field_values[$fld->name]; continue; } } if ($x > 0 && $this->generate_type == "grouping" && $this->report_obj->in_multiarray($this->columns_array[$clear_fld_name] . ":{$clear_fld_calculation_type}", $this->summaries_columns, "columnname") !== true) { continue; } if ($is_hid === false && !in_array($fld->name, $this->skip_fields) && !in_array($clear_fld_name, $this->skip_fields)) { if (in_array($fld->name, $group_cols) !== true) { // ITS4YOU-CR SlOl 13. 3. 2014 13:37:11 if ($this->generate_type == "grouping") { $summaries_fld_test = explode("_", $fld->name); $smft_lk = count($summaries_fld_test) - 1; if (in_array(strtolower($summaries_fld_test[$smft_lk]), $this->calculation_type_array)) { $calculation_type = $summaries_fld_test[$smft_lk]; $fld_name = ""; for ($index = 0; $index < count($summaries_fld_test); $index++) { if ($fld_name != "") { $fld_name .= "_"; } $fld_name .= $summaries_fld_test[$index]; } } else { $fld_name = $fld->name; } } else { $fld_name = $fld->name; } $s_type = "SC"; if ($this->generate_type == "grouping" && isset($this->sm_columns_array) && !empty($this->sm_columns_array) && array_key_exists($fld_name, $this->sm_columns_array)) { $s_type = "SM"; $columns_array_lbl = $this->sm_columns_array[$fld_name] . ":{$calculation_type}"; } elseif ($this->columns_array[$fld->table . "." . $fld_name]) { $columns_array_lbl = $this->columns_array[$fld->table . "." . $fld_name]; } elseif (isset($this->columns_array[$fld_name])) { $columns_array_lbl = $this->columns_array[$fld_name]; } else { $columns_array_lbl = ""; } // we will skipp 2, 3 group by values to display later correct values !! if ($this->generate_type == "grouping" && in_array($fld_name, $group_cols)) { continue; } if (isset($this->columns_array[$fld->name]) && $this->columns_array[$fld->name] != "") { if (!empty($selectedcolumns_arr)) { if ($this->report_obj->in_multiarray($this->columns_array[$fld->name], $selectedcolumns_arr, "fieldcolname") !== true && !in_array($fld->name, $this->g_flds)) { continue; } } } if ($this->generate_type != "grouping" && !isset($this->columns_array[$fld->name])) { continue; } // $this->getQFArray(); $headerLabel = $this->getHeaderLabel($this->report_obj->record, $s_type, $fld_name, $columns_array_lbl); if (count($this->g_colors) > 1 && $x == 0 && $this->generate_type == "grouping") { // $headerLabel = " "; $headerLabel = $this->getGroupsHeaderLabelStr(); } $header_style = ""; $header_style .= " style='" . $this->header_style . "' "; $header[] = array("style" => $header_style, "label" => $headerLabel); // ITS4YOU-END 14. 3. 2014 8:33:46 } } // END } } // ITS4YOU-CR SlOl | 12.8.2014 11:40 variable to populate header for record details $populate_detail_header = true; // ITS4YOU-CR SlOl | 12.8.2014 11:40 variable to populate header for record details end $display_groupinfo_row = false; $this->group_data_array = array(); $grouping_totals = $group2_values = array(); // $this->setChartsColumns(); if ($noofrows > 0) { $xls_ri = 0; $xls_fri = 0; $f_i = $f_r_i = 0; $group_info_tr_value = $old_gv = ""; // tr_html of Group Value (Count) Info in case summaries columns empty start do { $r_data = array(); $arraylists = array(); if (count($this->groupslist) == 1) { $newvalue = $custom_field_values[0]; } elseif (count($this->groupslist) == 2) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; } elseif (count($this->groupslist) == 3) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; $tnewvalue = $custom_field_values[2]; } if ($newvalue == "") { $newvalue = "-"; } if ($snewvalue == "") { $snewvalue = "-"; } if ($tnewvalue == "") { $tnewvalue = "-"; } // if ($this->generate_type == "grouping") { // $group_value = $custom_field_values[$this->g_flds[0]]; // } //$valtemplate_tr = "<tr>"; if ($this->generate_type == "grouping" && isset($this->g_colors[1]) && $this->g_colors[1] != "" && ($this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols" || $this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols")) { $y = 1; } $currency_id = ""; if (isset($custom_field_values["currency_id"]) && $custom_field_values["currency_id"] != "") { $currency_id = $custom_field_values["currency_id"]; } $this->data_record_id = ""; if (isset($custom_field_values["record_id"]) && $custom_field_values["record_id"] != "") { $this->data_record_id = $custom_field_values["record_id"]; } // ITS4YOU-CR SlOl | 12.8.2014 11:40 variables used for group info rows $detail_row_info = array(); // ITS4YOU-END 12.8.2014 11:41 // Variables used for Group Value (Count) Info in case summaries columns empty start $group_info_tr = ""; $group_info_tr_added = false; $gc_i = 0; // Set up group_value for Group Value (Count) Info in case group column not in selectedcolumns_arr start // $this->summaries_columns_count if (count($this->g_flds) == 1 && count($this->detail_selectedcolumns_arr) > 0) { if ($display_groupinfo_row !== true && isset($this->columns_array[$this->g_flds[0]]) && $this->columns_array[$this->g_flds[0]] != "") { $display_groupinfo_row = true; } } elseif ($this->report_obj->reportinformations["Group1"] != "none" && $this->summaries_columns_count == 0 && $display_groupinfo_row !== true) { $display_groupinfo_row = true; } // if (count($this->g_flds)>1 && count($this->detail_selectedcolumns_arr)>0 && $this->summaries_columns_count===0) { // $display_groupinfo_row = true; // } // LIMIT FOR GROUP INFO ROW START if ($display_groupinfo_row == true && isset($this->report_obj->reportinformations["columns_limit"]) && $this->report_obj->reportinformations["columns_limit"] != "" && isset($this->group_cols_array[1]) && $this->group_cols_array[1] != "") { $a_gv = $custom_field_values[$this->group_cols_array[1]]; if ($old_gv != $a_gv) { $old_gv = $custom_field_values[$this->group_cols_array[1]]; $f_r_i = 0; } if ($this->report_obj->reportinformations["columns_limit"] > 0) { if ($a_gv == $old_gv && $f_r_i >= $this->report_obj->reportinformations["columns_limit"]) { continue; } } } // LIMIT FOR GROUP INFO ROW END // Variables used for Group Value (Count) Info in case summaries columns empty end for ($i = 0; $i <= $y; $i++) { $fld = $adb->field_name($result, $i); $clear_fld_name_arr = explode("_", $fld->name); $clear_fld_calculation_type = strtoupper($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); unset($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); $clear_fld_name = implode("_", $clear_fld_name_arr); if (in_array($fld->name, $this->skip_fields) || in_array($clear_fld_name, $this->skip_fields)) { continue; } if ($i == 0 && !empty($selectedcolumns_arr) && in_array($fld->name, $this->g_flds) && isset($this->columns_array[$fld->name]) && $this->columns_array[$fld->name] != "") { if (!$this->report_obj->in_multiarray($this->columns_array[$fld->name], $selectedcolumns_arr, "fieldcolname") && $this->generate_type != "grouping") { $group_value = $custom_field_values[$fld->name]; continue; } } if (isset($this->columns_array[$fld->name]) && $this->report_obj->in_multiarray($this->columns_array[$fld->name], $this->detail_selectedcolumns_arr, "fieldcolname") !== true && in_array($fld->name, $this->g_flds) !== true) { continue; } if ($i > 0 && $this->generate_type == "grouping" && $this->report_obj->in_multiarray($this->columns_array[$clear_fld_name] . ":{$clear_fld_calculation_type}", $this->summaries_columns, "columnname") !== true) { continue; } // detail_selectedcolumns_arr $first_td = true; // skipp group columns in case not in selectedcolumns_arr end // ITS4YOU-CR SlOl 17. 2. 2014 10:23:31 $is_hid = strpos($fld->name, "_hid"); if ($is_hid === false) { if ($this->generate_type == "grouping") { $summaries_fld_test = explode("_", $fld->name); $smft_lk = count($summaries_fld_test) - 1; if (in_array(strtolower($summaries_fld_test[$smft_lk]), $this->calculation_type_array)) { $calculation_type = $summaries_fld_test[$smft_lk]; $fld_name = ""; for ($index = 0; $index < count($summaries_fld_test); $index++) { if ($fld_name != "") { $fld_name .= "_"; } $fld_name .= $summaries_fld_test[$index]; } } else { $fld_name = $fld->name; } // we will skipp 2, 3 group by values to display later correct values !! if ($this->generate_type == "grouping" && in_array($fld_name, $group_cols)) { continue; } } $hid_url = ""; $fld_hid = $adb->query_result($result, $f_i, $fld->name . "_hid"); if (array_key_exists($fld->name, $this->ui10_fields) && !empty($custom_field_values[$i])) { $fld_hid = $custom_field_values[$i]; } if (isset($fld_hid) && $fld_hid != "") { $entitytype = getSalesEntityType($fld_hid); if ($entitytype != "") { switch ($entitytype) { case "Calendar": $hid_url = 'index.php?module=Calendar&action=DetailView&record=' . $fld_hid . '&return_module=ITS4YouReports&return_action=resultGenerate&return_id=' . vtlib_purify($_REQUEST["record"]) . '&activity_mode=Task'; break; case "Events": $hid_url = 'index.php?module=Calendar&action=DetailView&record=' . $fld_hid . '&return_module=ITS4YouReports&return_action=resultGenerate&return_id=' . vtlib_purify($_REQUEST["record"]) . '&activity_mode=Events'; break; default: $hid_url = 'index.php?module=' . $entitytype . '&action=DetailView&record=' . $fld_hid . '&return_module=ITS4YouReports&return_action=resultGenerate&return_id=' . vtlib_purify($_REQUEST["record"]); break; } } else { $user = '******'; $u_result = $adb->pquery("SELECT count(*) as count from vtiger_users where id = ?", array($fld_hid)); if ($adb->query_result($u_result, 0, 'count') > 0) { $user = '******'; } if (is_admin($current_user)) { if ($user == 'no') { $hid_url = "index.php?module=Settings&action=GroupDetailView&groupId=" . $fld_hid; } else { $hid_url = "index.php?module=Users&action=DetailView&record=" . $fld_hid; } } } } $fld_type = $column_definitions[$i]->type; if (array_key_exists($fld->name, $this->ui10_fields) && !empty($custom_field_values[$i])) { $type = getSalesEntityType($custom_field_values[$i]); $tmp = getEntityName($type, $custom_field_values[$i]); if (is_array($tmp)) { foreach ($tmp as $key => $val) { $fieldvalue = $val; break; } } else { $fieldvalue = $custom_field_values[$i]; } } else { if ($custom_field_values[$i] != '') { $fieldvalue = getTranslatedString($custom_field_values[$i]); } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); //check for Roll based pick list $temp_val = $fld->name; if (is_array($picklistarray)) { if (array_key_exists($temp_val, $picklistarray)) { if (!in_array($custom_field_values[$i], $picklistarray[$fld->name]) && $custom_field_values[$i] != '') { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } } } if (is_array($picklistarray[1])) { if (array_key_exists($temp_val, $picklistarray[1])) { $temp = explode(", ", str_ireplace(' |##| ', ', ', $fieldvalue)); $temp_val = array(); foreach ($temp as $key => $val) { if (!in_array(trim($val), $picklistarray[1][$fld->name]) && trim($val) != '') { $temp_val[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $temp_val[] = $val; } } $fieldvalue = is_array($temp_val) ? implode(", ", $temp_val) : ''; } } if ($fieldvalue == "") { $fieldvalue = "-"; } else { if ($fld->name == 'LBL_ACTION') { $fieldvalue = "<a href='index.php?module={$this->primarymodule}&action=DetailView&record={$fieldvalue}' target='_blank'>" . getTranslatedString('LBL_VIEW_DETAILS') . "</a>"; } else { if (stristr($fieldvalue, "|##|")) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } else { if ($fld_type == "date" || $fld_type == "datetime") { $fieldvalue = getValidDisplayDate($fieldvalue); } } } } $bg_color = ""; if ($this->generate_type == "grouping") { if ($i == 0 && in_array($fld->name, $this->g_flds)) { $group_value = $custom_field_values[$i]; } if (isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] != "cols" && $this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols") { $bg_color_val = $this->g_colors[1]; } elseif (isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols") { $bg_color_val = $this->g_colors[2]; } else { $bg_color_val = $this->g_colors[0]; } $bg_color = "background-color:{$bg_color_val};"; } //$txt_align = $this->getFldAlignment($fld->name, $fieldvalue); $fld_style_arr = $this->getFldStyle($fld->name, $fieldvalue); $fld_style = $this->getFldStyleString($fld_style_arr); if ($this->generate_type == "grouping" && is_numeric($fieldvalue) && !in_array($fld->name, $this->group_cols_array)) { $fld_name_exploded = explode("_", $fld->name); $calculation_type = $fld_name_exploded[count($fld_name_exploded) - 1]; if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) { $grouping_totals[$fld->name][$currency_id][] = number_format($fieldvalue, 3, ".", ""); } else { $grouping_totals[$fld->name][] = number_format($fieldvalue, 3, ".", ""); } } // timeline_type2"]=="cols REPORT if ($this->generate_type == "grouping" && isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols") { $array_to_totals = array($result, $custom_field_values, $i, $t_y); $currency_string = $this->get_currency_sumbol_str($currency_id); $group2_arr = $this->getSubGroupCols($group_value, 1, "", $currency_id, $array_to_totals); if (!empty($group2_arr["headers"])) { $group2_headers = array_merge($group2_headers, $group2_arr["headers"]); } } // charts array population start $ch_fldname = strtolower($fld->name); if (!empty($this->charts) && !empty($this->charts["charttypes"])) { $this->setChArrayValues("charttitle", '', $this->charts["charttitle"]); if ($this->charts["x_group"] == "group1" && in_array($ch_fldname, $this->charts["charts_ds_columns"])) { $this->setDataseriesArray($group_value, $fieldvalue, $currency_id, $ch_fldname); } } // charts array population end // * ** GROUP INFO ROW DISPLAY for GROUPS In case selected columns not empty *** GROUPING REPORT * if ($first_td === true && $this->generate_type == "grouping" && count($this->g_colors) == 1 && count($this->detail_selectedcolumns_arr) > 0) { if (!isset($this->summaries_header) || empty($this->summaries_header)) { $this->summaries_header = $header; } $header_col_lstr = ""; if (isset($this->summaries_header[$i]["label"]) && trim($this->summaries_header[$i]["label"]) != "") { $header_col_lbl = $this->summaries_header[$i]["label"]; } else { $header_col_as = $clear_fld_name; $header_col_str = $this->columns_array[$header_col_as]; $header_col_lbl = $this->getHeaderLabel($this->report_obj->record, "SC", $header_col_as, $header_col_str); } // header population for Groups row start if ($this->selectedcolumns_header_row == "") { $header = array(); if (!empty($selectedcolumns_arr)) { foreach ($selectedcolumns_arr as $sc_key => $sc_array) { $sc_header_style = " style='" . $this->header_style . "' "; $sc_column_str = $sc_array["fieldcolname"]; $headerLabel = $this->getHeaderLabel($this->report_obj->record, "SC", "", $sc_column_str); $header[] = array("style" => $sc_header_style, "label" => $headerLabel); } $sc_header = $sc_header_sp = ""; // $sc_header_sp .= "<td class='rpt4youGrpHead0' colspan='".count($header)."'> </td>"; // $sc_header_sp .= "</tr>"; // $sc_header_sp .= "<tr>"; foreach ($header as $header_f_arr) { $header_style = $header_f_arr["style"]; $headerLabel = $header_f_arr["label"]; $sc_header .= "<td class='rpt4youCellLabel' rowspan='1' colspan='1' {$header_style} align='center' nowrap >{$headerLabel}</td>"; } $sc_header .= "</tr>"; $sc_header .= "<tr>"; $this->selectedcolumns_header_row = $sc_header; //$this->selectedcolumns_header_row_sp = $sc_header_sp; } $this->display_group_totals = false; } // header population for Groups row end if ($display_groupinfo_row === true && count($this->g_flds) == 1) { $sp_group_value = $custom_field_values[$this->group_cols_array[1]]; if ($group_info_tr_added !== true) { $sm_calculation_type = ""; // if ($f_i==0) { // $group_info_tr .= $this->selectedcolumns_header_row; // } if (isset($this->summaries_columns) && !empty($this->summaries_columns)) { $detail_row_info = array(); foreach ($this->summaries_columns as $sm_key => $sm_col_array) { $sm_col_str = $sm_col_array['columnname']; $sm_col_alias = ""; $sm_col_str_exploded = explode(":", $sm_col_str); $sm_lk = count($sm_col_str_exploded) - 1; if (in_array(strtolower($sm_col_str_exploded[$sm_lk]), $this->calculation_type_array)) { $sm_calculation_type = strtolower($sm_col_str_exploded[$sm_lk]); $sm_col_lbl_str = implode(":", $sm_col_str_exploded); unset($sm_col_str_exploded[$sm_lk]); $sm_col_str = implode(":", $sm_col_str_exploded); if (isset($this->columns_array[$sm_col_str]["fld_alias"]) && $this->columns_array[$sm_col_str]["fld_alias"] != "") { $sm_col_alias = $this->columns_array[$sm_col_str]["fld_alias"]; } $sm_col_alias .= "_{$sm_calculation_type}"; } $sm_value = $custom_field_values[$sm_col_alias]; $sm_col_Label = $this->getHeaderLabel($this->report_obj->record, "SM", $sm_col_alias, $sm_col_lbl_str); // $header_col_lstr = ";"; // $detail_row_info[] = $sm_col_Label." = ".$this->getFldNumberFormat($sm_col_alias, $sm_value, $currency_id).$header_col_lstr; $detail_row_info[] = $sm_col_Label . " = " . $this->getFldNumberFormat($sm_col_alias, $sm_value, $currency_id); } } $group_info_tr_value = $this->getFldNumberFormat($this->group_cols_array[1], $sp_group_value, $currency_id, true); // $group_records_count = count($this->result_array[$sp_group_value]); $group_records_count = $custom_field_values["crmid_r_count"]; $group_info_fld_str = $this->columns_array[$this->group_cols_array[1]]; $group_info_headerLabel = $this->getHeaderLabel($this->report_obj->record, "SC", $this->group_cols_array[1], $group_info_fld_str); //$group_info_tr .= "<tr><td class='rpt4youGrpHead' colspan='" . count($header) . "' style='text-align:left;background-color:#EEEEEE;' nowrap ><b>"; $group_info_tr .= "{$group_info_headerLabel} = {$group_info_tr_value} ({$group_records_count}): "; $group_info_tr .= implode(";", $detail_row_info); //$group_info_tr .= "</b></td></tr>"; $group_info_tr_added = true; } } // * ** GROUP INFO ROW DISPLAY for GROUPS In case selected columns not empty END *** STANDARD REPORT * } else { // Group Value (Count) Info in case summaries columns empty start if ($display_groupinfo_row === true) { $sp_group_value = $custom_field_values[$this->group_cols_array[1]]; if ($sp_group_value != $direct_group_info_tr_value) { $direct_group_info_tr_value = $sp_group_value; $group_info_tr_value = $this->getFldNumberFormat($this->group_cols_array[1], $sp_group_value, $currency_id); // $group_records_count = count($this->result_array[$sp_group_value]); $group_records_count = $custom_field_values["crmid_count"]; $group_info_fld_str = $this->columns_array[$this->g_flds[0]]; $group_info_headerLabel = $this->getHeaderLabel($this->report_obj->record, "SC", $this->g_flds[0], $group_info_fld_str); //$group_info_tr = "<tr><td class='rpt4youGrpHead' colspan='" . count($header) . "' style='text-align:left;background-color:#EEEEEE;' nowrap ><b>"; $group_info_tr .= "{$group_info_headerLabel} = {$group_info_tr_value} ({$group_records_count})"; //$group_info_tr .= "</b></td></tr>"; $group_info_tr_added = true; } } // Group Value (Count) Info in case summaries columns empty end // * ** DEFAULT VALUE DISPLAY *** * //$valtemplate_tr .= "<td class='rpt4youGrpHead' style='text-align:$txt_align;$bg_color' nowrap >" . $this->getFldNumberFormat($fld->name, $fieldvalue, $currency_id) . "$currency_string</td>"; $r_data[$xls_ri][] = $this->getFldNumberFormat($fld->name, $fieldvalue, $currency_id); } // * ** DISPLAY timeline_type2 == "cols" *** if ($this->generate_type == "grouping" && isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols") { $g_ri = 1; foreach ($group2_headers as $group_h_key => $group_h_arr) { if (isset($group2_arr["values"][$group_h_key]) && !empty($group2_arr["values"][$group_h_key])) { // foreach ($group2_arr["values"][$group_h_key] as $gv_arr) { for ($gv_i = 0; $gv_i < count($group_h_arr); $gv_i++) { if (isset($group2_arr["values"][$group_h_key][$gv_i]) && !empty($group2_arr["values"][$group_h_key][$gv_i])) { $gv_arr = $group2_arr["values"][$group_h_key][$gv_i]; //$txt_align = $gv_arr["text-align"]; $gv_value = $gv_arr["value"]; $gv_fld_name = $gv_arr["fld_name"]; if ($gv_fld_name != "") { if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) { $grouping_totals[$group_h_key][$gv_fld_name][$currency_id][] = $gv_value; } else { $grouping_totals[$group_h_key][$gv_fld_name][] = $gv_value; } } $fw_weight = ""; if ($group_h_key == "LBL_GROUPING_TOTALS") { $fw_weight = "font-weight:bold;"; } //$valtemplate_tr .= "<td class='rpt4youGrpHead' style='text-align:$txt_align;$fw_weight' nowrap >" . $this->getFldNumberFormat($gv_fld_name, $gv_value, $currency_id) . "</td>"; $r_data[$xls_ri][] = $this->getFldNumberFormat($gv_fld_name, $gv_value, $currency_id); $g_ri++; } } } else { for ($gv_i = 0; $gv_i < count($group_h_arr); $gv_i++) { //$valtemplate_tr .= "<td class='rpt4youGrpHead' style='text-align:center;' nowrap > </td>"; $r_data[$xls_ri][] = " "; $g_ri++; } } } } // TOTALS CALCULATION START if (isset($this->columns_array[$fld->name])) { $columns_array_lbl = $this->columns_array[$fld->name]; } elseif ($this->columns_array[$fld->table . "." . $fld->name]) { $columns_array_lbl = $this->columns_array[$fld->table . "." . $fld->name]; } elseif ($fld->table != "") { $columns_array_lbl = $fld->table . "." . $fld->name; } else { $columns_array_lbl = $fld->name; } $TheaderLabel = $this->getHeaderLabel($reportid, "CT", $fld->name, $columns_array_lbl); $fld_totals_key = $fld->name; // $to_totals_res = $this->setToTotalsArray($to_totals_res, $fld_totals_key, $fieldvalue, $to_totals_array, $currency_id); $this->to_totals_res = $this->setToTotalsArray($noofrows, $this->to_totals_res, $fld_totals_key, $fieldvalue, $this->to_totals_array, $currency_id); // TOTALS CALCULATION END } $first_td = false; // ITS4YOU-END 17. 2. 2014 10:23:33 $gc_i++; } // timeline_type3"]=="cols" REPORT $gcols3_r_data = array(); if ($this->generate_type == "grouping" && isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] != "cols" && $this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols") { //$gcols3_valtemplate = ""; $tl_g3_colspan = 1; if (empty($this->group_data_array[$group_value])) { $this->setGroupDataArray($group_value, $currency_id); } $group_value = html_entity_decode($group_value, ENT_QUOTES, $default_charset); if (isset($currency_id) && $currency_id != "") { $group_data_array = $this->group_data_array[$group_value][$currency_id]; } else { $group_data_array = $this->group_data_array[$group_value]; } // foreach($this->result_array[$group_value] as $group_row_key => $group_row_array) { foreach ($group_data_array as $group_row_key => $group_row_array) { // continue in case summary filter will not contain group values // if (!array_key_exists($group_row_key, $this->group_data_array[$group_value])) { // continue; // } //$gcols3_valtemplate .= "</tr><tr>"; $bg_color_val = $this->g_colors[2]; $bg_color = "background-color:{$bg_color_val};"; // this is possible only in case group 2 = rows and group 3 = cols, so static rpt4youGrpHead_1 is ok here //$gcols3_valtemplate .= "<td class='rpt4youGrpHead_1' style='text-align:left;' nowrap >" . $group_row_key . "</td>"; $gcols3_r_data[$group_row_key][] = $group_row_key; foreach ($header as $header_f_key => $header_f_arr) { $headerLabel = $header_f_arr["label"]; if (!in_array($headerLabel, array("LBL_GROUPING_TOTALS")) && $header_f_key !== 0) { if (isset($group_data_array[$group_row_key][$headerLabel])) { foreach ($group_data_array[$group_row_key][$headerLabel] as $fld_key => $fld_value) { $clear_fld_name_arr = explode("_", $fld_key); $clear_fld_calculation_type = strtoupper($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); unset($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); $clear_fld_name = implode("_", $clear_fld_name_arr); if (in_array($fld_key, $this->skip_fields) || in_array($clear_fld_name, $this->skip_fields)) { continue; } if ($this->report_obj->in_multiarray($this->columns_array[$clear_fld_name] . ":{$clear_fld_calculation_type}", $this->summaries_columns, "columnname") !== true) { continue; } //$txt_align = $this->getFldAlignment($fld_key, $fld_value); $calculation_arr = explode("_", $fld_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "avg") { $ct_fldstr = ""; $ct_fi = count($calculation_arr) - 1; for ($ct_i = 0; $ct_i < $ct_fi; $ct_i++) { if ($ct_i > 0 && $ct_i != $ct_fi) { $ct_fldstr .= "_"; } $ct_fldstr .= $calculation_arr[$ct_i]; } $ct_fldstr_sum = $ct_fldstr . "_sum"; if ($currency_id != "") { $group_totals[$group_value][$currency_id][$group_row_key][$fld_key] = $group_totals[$group_value][$currency_id][$group_row_key][$ct_fldstr_sum]; $group_f_totals[$group_value][$currency_id][$headerLabel][$fld_key][] = $fld_value; $group_f_totals[$group_value][$currency_id]["row_totals"][$fld_key][] = $fld_value; } else { $group_totals[$group_value][$group_row_key][$fld_key] = $group_totals[$group_value][$group_row_key][$ct_fldstr_sum]; $group_f_totals[$group_value][$headerLabel][$fld_key][] = $fld_value; $group_f_totals[$group_value]["row_totals"][$fld_key][] = $fld_value; } } else { if ($currency_id != "") { $group_totals[$group_value][$currency_id][$group_row_key][$fld_key][] = $fld_value; $group_f_totals[$group_value][$currency_id][$headerLabel][$fld_key][] = $fld_value; $group_f_totals[$group_value][$currency_id]["row_totals"][$fld_key][] = $fld_value; } else { $group_totals[$group_value][$group_row_key][$fld_key][] = $fld_value; $group_f_totals[$group_value][$headerLabel][$fld_key][] = $fld_value; $group_f_totals[$group_value]["row_totals"][$fld_key][] = $fld_value; } } //$gcols3_valtemplate .= "<td class='rpt4youGrpHead' style='text-align:$txt_align;$bg_color' nowrap >" . $this->getFldNumberFormat($fld_key, $fld_value, $currency_id) . "</td>"; $gcols3_r_data[$group_row_key][] = $this->getFldNumberFormat($fld_key, $fld_value, $currency_id); } } else { for ($g3_i = 0; $g3_i < $this->sum_col_i; $g3_i++) { //$gcols3_valtemplate .= "<td class='rpt4youGrpHead' style='text-align:center;font-weight:bold;$bg_color' nowrap > </td>"; $gcols3_r_data[$group_row_key][] = " "; } } } elseif ($headerLabel == "LBL_GROUPING_TOTALS") { $count_value = 0; if ($currency_id != "") { $group_totals_array = $group_totals[$group_value][$currency_id][$group_row_key]; } else { $group_totals_array = $group_totals[$group_value][$group_row_key]; } foreach ($group_totals_array as $g_t_key => $g_t_array) { $calculation_arr = explode("_", $g_t_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "count") { foreach ($g_t_array as $count_val) { $count_value += $count_val; } } if ($calculation_type == "avg") { $fld_value = array_sum($g_t_array) / $count_value; } else { $fld_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); } //$txt_align = $this->getFldAlignment($g_t_key, $fld_value); //$gcols3_valtemplate .= "<td class='rpt4youGrpHead' style='text-align:$txt_align;font-weight:bold;$bg_color' nowrap >" . $this->getFldNumberFormat($g_t_key, $fld_value, $currency_id) . "</td>"; $gcols3_r_data[$group_row_key][] = $this->getFldNumberFormat($g_t_key, $fld_value, $currency_id); } } } } $bg_color_val1 = $this->g_colors[1]; $bg_color1 = "background-color:{$bg_color_val1};"; foreach ($header as $header_f_key => $header_f_arr) { $headerLabel = $header_f_arr["label"]; if ($currency_id != "") { $group_totals_f_array = $group_f_totals[$group_value][$currency_id]; } else { $group_totals_f_array = $group_f_totals[$group_value]; } if (!in_array($headerLabel, array("LBL_GROUPING_TOTALS")) && $header_f_key !== 0) { if (isset($group_totals_f_array[$headerLabel]) && !empty($group_totals_f_array[$headerLabel])) { $count_value = 0; foreach ($group_totals_f_array[$headerLabel] as $g_t_key => $g_t_array) { $clear_fld_name_arr = explode("_", $g_t_key); $clear_fld_calculation_type = strtoupper($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); unset($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); $clear_fld_name = implode("_", $clear_fld_name_arr); if (in_array($g_t_key, $this->skip_fields) || in_array($clear_fld_name, $this->skip_fields)) { continue; } if ($this->report_obj->in_multiarray($this->columns_array[$clear_fld_name] . ":{$clear_fld_calculation_type}", $this->summaries_columns, "columnname") !== true) { continue; } $calculation_arr = explode("_", $g_t_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "count") { foreach ($g_t_array as $count_val) { $count_value += $count_val; } } if ($calculation_type == "avg") { $ct_fldstr = ""; $ct_fi = count($calculation_arr) - 1; for ($ct_i = 0; $ct_i < $ct_fi; $ct_i++) { if ($ct_i > 0 && $ct_i != $ct_fi) { $ct_fldstr .= "_"; } $ct_fldstr .= $calculation_arr[$ct_i]; } $ct_fldstr_sum = $ct_fldstr . "_sum"; $g_t_array = $group_totals_f_array[$headerLabel][$ct_fldstr_sum]; $fld_value = array_sum($g_t_array) / $count_value; } else { $fld_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); } //$txt_align = $this->getFldAlignment($g_t_key, $fld_value); if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) { $grouping_totals[$headerLabel][$g_t_key][$currency_id][] = $fld_value; } else { $grouping_totals[$headerLabel][$g_t_key][] = $fld_value; } // charts array population start if ($g_t_key == $this->charts["charts_ds_column"]) { // SPECIAL CHART DATA POPULATION FOR G3 COLS $cols_alias = ""; if ($this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols") { $cols_alias = $this->g_flds[1]; } elseif ($this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols") { $cols_alias = $this->g_flds[2]; } if (!isset($this->ch_array["dataseries_label"])) { $this->setDataseriesLabel($cols_alias); } //$dataseries_label_key = $this->getHeaderLabel($this->report_obj->record, "SM", $this->g_flds[2], $this->columns_array[$this->g_flds[2]]); //$this->setChArrayValues("dataseries_label", 'key', $dataseries_label_key); if ($currency_id != "") { $ch_subkey = $headerLabel . " (" . $this->currency_symbols[$currency_id] . ")"; } else { $ch_subkey = $headerLabel; } // addToSubvalChArrayValues($ch_key, $ch_subkey, $ch_value, $option_key="", $currency_id="") { $this->addToSubvalChArrayValues("dataseries", $headerLabel, $fld_value, $group_value, $currency_id); if ($this->ch_array["charttype"] != "horizontal") { $this->setChArrayValues("dataseries", $ch_subkey, $fld_value); } } // charts array population end //$valtemplate_tr .= "<td class='rpt4youGrpHead' style='text-align:$txt_align;$bg_color1' nowrap >" . $this->getFldNumberFormat($g_t_key, $fld_value, $currency_id) . "</td>"; $r_data[$xls_ri][] = $this->getFldNumberFormat($g_t_key, $fld_value, $currency_id); } } else { for ($g3_i = 0; $g3_i < $this->sum_col_i; $g3_i++) { //$valtemplate_tr .= "<td class='rpt4youGrpHead' style='text-align:center;$bg_color1' nowrap > </td>"; $r_data[$xls_ri][] = " "; } } } elseif ($headerLabel == "LBL_GROUPING_TOTALS") { $count_value = 0; if (isset($group_totals_f_array["row_totals"]) && !empty($group_totals_f_array["row_totals"])) { foreach ($group_totals_f_array["row_totals"] as $g_t_key => $g_t_array) { $calculation_arr = explode("_", $g_t_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "avg") { $ct_fldstr = ""; $ct_fi = count($calculation_arr) - 1; for ($ct_i = 0; $ct_i < $ct_fi; $ct_i++) { if ($ct_i > 0 && $ct_i != $ct_fi) { $ct_fldstr .= "_"; } $ct_fldstr .= $calculation_arr[$ct_i]; } $ct_fldstr_sum = $ct_fldstr . "_sum"; $g_t_array = $group_totals_f_array["row_totals"][$ct_fldstr_sum]; } if ($calculation_type == "count") { foreach ($g_t_array as $count_val) { $count_value += $count_val; } } if ($calculation_type == "avg") { $fld_value = array_sum($g_t_array) / $count_value; } else { $fld_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); } //$txt_align = $this->getFldAlignment($g_t_key, $fld_value); if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) { $grouping_totals[$headerLabel][$g_t_key][$currency_id][] = $fld_value; } else { $grouping_totals[$headerLabel][$g_t_key][] = $fld_value; } //$valtemplate_tr .= "<td class='rpt4youGrpHead' style='text-align:$txt_align;font-weight:bold;$bg_color1' nowrap >" . $this->getFldNumberFormat($g_t_key, $fld_value, $currency_id) . "</td>"; $r_data[$xls_ri][] = $this->getFldNumberFormat($g_t_key, $fld_value, $currency_id); } } else { for ($g3_i = 0; $g3_i < $this->sum_col_i; $g3_i++) { //$valtemplate_tr .= "<td class='rpt4youGrpHead' style='text-align:center;$bg_color1' nowrap > </td>"; $r_data[$xls_ri][] = " "; } } } } if (isset($gcols3_r_data) && !empty($gcols3_r_data)) { foreach ($gcols3_r_data as $gcols_r_arr) { $xls_ri++; $r_data[$xls_ri] = $gcols_r_arr; } $xls_ri++; } //$valtemplate_tr .= $gcols3_valtemplate; } // details for group 1 if ($this->generate_type == "grouping" && count($this->g_colors) == 1) { if (!empty($selectedcolumns_arr)) { //$valtemplate_tr .= $this->returnGroupDetailRecordsNew($group_value, $y, $selectedcolumns_arr, $currency_id); $r_data = $this->returnGroupDetailRecordsNew($group_value, $y, $selectedcolumns_arr, $currency_id); } } //$valtemplate_tr .= "</tr>"; // adding tr html of Group Value (Count) Info in case summaries columns empty start if ($group_info_tr != "") { $data[$xls_fri][] = $group_info_tr; $xls_fri++; //$valtemplate .= $group_info_tr; } // adding tr html of Group Value (Count) Info in case summaries columns empty end //$valtemplate .= $valtemplate_tr; // ROWS REPORT if ($this->generate_type == "grouping" && isset($this->g_colors[1]) && $this->g_colors[1] != "" && $this->report_obj->reportinformations["timeline_type2"] != "cols" && ($this->report_obj->reportinformations["timeline_type3"] != "cols" || $this->report_obj->reportinformations["timeline_type3"] == "none")) { $group2_html = $this->getSubGroupRow($group_value, $currency_id); foreach ($group2_html as $group2_arr) { $xls_fri++; $r_data[$xls_fri] = $group2_arr; } //$valtemplate .= $group2_html; } $lastvalue = $newvalue; $secondvalue = $snewvalue; $thirdvalue = $tnewvalue; $arr_val[] = $arraylists; set_time_limit($php_max_execution_time); $f_i++; $xls_ri++; // GROUPING TOTALS START if ($this->display_group_totals == true && $this->generate_type == "grouping" && $f_i == $noofrows && $this->report_obj->reportinformations["timeline_type2"] != "cols" && ($this->report_obj->reportinformations["timeline_type3"] != "cols" || $this->report_obj->reportinformations["timeline_type3"] == "none")) { $bg_color_val = $this->g_colors[0]; $bg_color = "background-color:{$bg_color_val};"; //$valtemplate .= "<tr>"; //$valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' style='text-align:left;" . $this->grouping_totals_bg_color . "' nowrap >" . getTranslatedString("LBL_GROUPING_TOTALS", $this->getCurrentModule4You()) . "</td>"; if ($currency_id != "" && isset($this->currency_symbols[$currency_id])) { $to_display = $gt_sr_data = array(); $gt_xls_ri = 0; foreach ($grouping_totals as $g_t_key => $currency_array) { if (!empty($currency_array)) { $gt_r_data[$gt_xls_ri][] = getTranslatedString("LBL_GROUPING_TOTALS", $this->getCurrentModule4You()); $gt_xls_sri = 0; foreach ($currency_array as $currency_key => $g_t_array) { $g_t_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); //$txt_align = $this->getFldAlignment($g_t_key, $g_t_value); $fld_style_arr = $this->getFldStyle($g_t_key, $g_t_value); $fld_style = $this->getFldStyleString($fld_style_arr); $to_display[$g_t_key]["values"] = $this->getFldNumberFormat($g_t_key, $g_t_value, $currency_key); //$to_display[$g_t_key]["textalign"] = $txt_align; $to_display[$g_t_key]["fld_style"] = $fld_style; $gt_sr_data[$gt_xls_sri][] = $this->getFldNumberFormat($g_t_key, $g_t_value, $currency_key); $gt_xls_sri++; } $gt_xls_ri++; } } foreach ($gt_r_data as $gt_r_key => $gt_r_data_val) { if (!empty($gt_sr_data[$gt_r_key])) { foreach ($gt_sr_data[$gt_r_key] as $gt_sr_data_val) { $gt_r_data[$gt_r_key][] = $gt_sr_data_val; } } else { unset($gt_r_data[$gt_r_key]); } } /*foreach ($to_display AS $td_key => $td_arr) { $txt_align = $td_arr["textalign"]; $td_value = $td_arr["values"]; $r_data[$xls_ri][] = $td_value; //$valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' style='text-align:$txt_align;" . $this->grouping_totals_bg_color . "' nowrap >" . $td_value . "</td>"; }*/ } else { $r_data[$xls_ri][] = getTranslatedString("LBL_GROUPING_TOTALS", $this->getCurrentModule4You()); foreach ($grouping_totals as $g_t_key => $g_t_array) { $g_t_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); //$txt_align = $this->getFldAlignment($g_t_key, $g_t_value); $r_data[$xls_ri][] = $this->getFldNumberFormat($g_t_key, $g_t_value); //$valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' style='text-align:$txt_align;" . $this->grouping_totals_bg_color . "' nowrap >" . $this->getFldNumberFormat($g_t_key, $g_t_value) . "</td>"; } } //$valtemplate .= "</tr>"; } if (!empty($r_data)) { foreach ($r_data as $row_data) { $data[$xls_fri] = $row_data; $xls_fri++; } } if (!empty($gt_r_data)) { foreach ($gt_r_data as $gt_r_data_arr) { $xls_fri++; $data[$xls_fri] = $gt_r_data_arr; } } $f_r_i++; // GROUPING TOTALS END } while ($custom_field_values = $adb->fetch_array($result)); // GROUPING TOTALS START // GROUPING TOTAL FOR COLS START $to_totals_data_array = $to_totals_subdata_array = array(); if ($this->generate_type == "grouping" && ($this->report_obj->reportinformations["Group2"] != "none" && $this->report_obj->reportinformations["timeline_type2"] == "cols" || $this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols") && !empty($grouping_totals)) { $xls_t_i = 0; $bg_color = "background-color:{$bg_color_val};"; // $valtemplate .= "<tr>"; // $valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' nowrap style='text-align:left;" . $this->grouping_totals_bg_color . "' nowrap >" . getTranslatedString("LBL_GROUPING_TOTALS", $this->getCurrentModule4You()) . "</td>"; // foreach ($grouping_totals as $grouping_totals_key => $grouping_totals_array) { $g_t_value_display_arr = array(); foreach ($header as $gh_i => $gh_array) { if ($gh_i > 0 && isset($grouping_totals[$gh_array["label"]])) { $grouping_totals_array = $grouping_totals[$gh_array["label"]]; foreach ($grouping_totals_array as $g_t_key => $g_t_array) { if (in_array($this->report_obj->primarymodule, ITS4YouReports::$inventory_modules)) { foreach ($g_t_array as $g_ft_currency_id => $g_ft_array) { $calculation_arr = explode("_", $g_t_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "count") { $count_value = 0; foreach ($g_ft_array as $count_val) { $count_value += $count_val; } } if ($calculation_type == "avg") { $ct_fldstr = ""; $ct_fi = count($calculation_arr) - 1; for ($ct_i = 0; $ct_i < $ct_fi; $ct_i++) { if ($ct_i > 0 && $ct_i != $ct_fi) { $ct_fldstr .= "_"; } $ct_fldstr .= $calculation_arr[$ct_i]; } if (!empty($grouping_totals_array[$ct_fldstr . "_sum"][$g_ft_currency_id])) { $ct_fldstr_sum = $ct_fldstr . "_sum"; } else { $ct_fldstr_sum = $ct_fldstr . "_SUM"; } $g_ft_array = $grouping_totals_array[$ct_fldstr_sum][$g_ft_currency_id]; $g_t_value = array_sum($g_ft_array) / $count_value; } else { $g_t_value = $this->getGroupTotalsValue($g_t_key, $g_ft_array); } //$txt_align = $this->getFldAlignment($g_t_key, $g_t_value); $g_t_value_display_arr[$gh_i][$g_ft_currency_id][] = $this->getFldNumberFormat($g_t_key, $g_t_value, $g_ft_currency_id); } //$g_t_value_display = implode("<br>", $g_t_value_display_arr); } else { $calculation_arr = explode("_", $g_t_key); $calculation_type = strtolower($calculation_arr[count($calculation_arr) - 1]); if ($calculation_type == "count") { $count_value = 0; if (!empty($g_t_array)) { foreach ($g_t_array as $count_key => $count_val) { if (is_array($count_val)) { $count_value += array_sum($count_val); } else { $count_value += $count_val; } } } } if ($calculation_type == "avg") { $ct_fldstr = ""; $ct_fi = count($calculation_arr) - 1; for ($ct_i = 0; $ct_i < $ct_fi; $ct_i++) { if ($ct_i > 0 && $ct_i != $ct_fi) { $ct_fldstr .= "_"; } $ct_fldstr .= $calculation_arr[$ct_i]; } if (!empty($grouping_totals_array[$ct_fldstr . "_sum"])) { $ct_fldstr_sum = $ct_fldstr . "_sum"; } else { $ct_fldstr_sum = $ct_fldstr . "_SUM"; } $g_t_array = $grouping_totals_array[$ct_fldstr_sum]; $g_t_value = array_sum($g_t_array) / $count_value; } else { $g_t_value = $this->getGroupTotalsValue($g_t_key, $g_t_array); } //$txt_align = $this->getFldAlignment($g_t_key, $g_t_value); // $g_t_value_display = $this->getFldNumberFormat($g_t_key, $g_t_value); $g_t_value_display_arr[$gh_i][1][] = $this->getFldNumberFormat($g_t_key, $g_t_value); } /*if ($grouping_totals_key == "LBL_GROUPING_TOTALS") { $valtemplate_totals .= "<td class='rpt4youGrpHeadGroupTotals' style='text-align:$txt_align;" . $this->grouping_totals_bg_color . "' nowrap >" . $g_t_value_display . "</td>"; } else { $valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' style='text-align:$txt_align;" . $this->grouping_totals_bg_color . "' nowrap >" . $g_t_value_display . "</td>"; }*/ } } /* elseif ($gh_i > 0) { for ($gti = 0; $gti < count($this->sum_col_sql_a); $gti++) { $valtemplate .= "<td class='rpt4youGrpHeadGroupTotals' style='text-align:$txt_align;" . $this->grouping_totals_bg_color . "' nowrap >0</td>"; } }*/ } $cd_i = 0; $c_count_cols = 0; foreach ($g_t_value_display_arr as $h_t_i => $g_t_array) { foreach ($g_t_array as $currency_id => $data_array) { if ($c_count_cols == 0) { $c_count_cols = count($data_array); } $to_totals_data_array_tmp[$currency_id][0][0] = getTranslatedString("LBL_GROUPING_TOTALS", $this->getCurrentModule4You()); foreach ($data_array as $data_val) { $to_totals_data_array_tmp[$currency_id][$cd_i][] = $data_val; } } $cd_i++; } $c_data = array(); $n_row_i = 0; $c_cols_i = count($g_t_value_display_arr); foreach ($to_totals_data_array_tmp as $currency_id => $currency_data) { for ($ni = 0; $ni < $c_cols_i; $ni++) { if ($ni == 0) { $nc_count_cols = $c_count_cols + 1; } else { $nc_count_cols = $c_count_cols; } if (isset($currency_data[$ni]) && !empty($currency_data[$ni])) { for ($nci = 0; $nci < $nc_count_cols; $nci++) { $c_data[$n_row_i][] = $currency_data[$ni][$nci]; } } else { for ($nci = 0; $nci < $nc_count_cols; $nci++) { $c_data[$n_row_i][] = " "; } } } $n_row_i++; } //$header_merge[$header_f_key] = $headerLabel; $header_merge = array(); $go_merge = false; $c_h_i = 0; if ($this->generate_type == "grouping" && $this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols" && !empty($grouping_totals)) { $c_h_i++; } foreach ($header as $header_key => $header_arr) { if ($c_h_i > 0) { for ($nci = 0; $nci < $nc_count_cols; $nci++) { if (isset($group2_headers) && !empty($group2_headers) && isset($group2_headers[$header_arr["label"]][$nci]["label"])) { $go_merge = true; $header_merge[$c_h_i] = $group2_headers[$header_arr["label"]][$nci]["label"]; } elseif (isset($group2_headers) && !empty($group2_headers) && isset($group2_headers[$header_key][$nci]["label"])) { $go_merge = true; $header_merge[$c_h_i] = $group2_headers[$header_key][$nci]["label"]; } $c_h_i++; } } else { $c_h_i++; } } if (!empty($c_data)) { foreach ($c_data as $row_data) { $data[$xls_fri] = $row_data; $xls_fri++; } } //$valtemplate .= $valtemplate_totals; //$valtemplate .= "</tr>"; } } else { $data[0][] = vtranslate("LBL_NO_DATA_TO_DISPLAY", $this->getCurrentModule4You()); } // GROUPING TOTAL FOR COLS END // GROUPING TOTALS END /* $header_f = ""; if ($populate_detail_header) { $h_i = 0; foreach ($header as $header_f_arr) { $header_style = $header_f_arr["style"]; $headerLabel = $header_f_arr["label"]; $header_rowspan = 1; $header_colspan = 1; if (!empty($group2_headers)) { if ($h_i == 0) { $header_rowspan++; } else { $header_colspan = count($group2_headers[$headerLabel]); } } if ($headerLabel == "LBL_GROUPING_TOTALS") { $headerLabel = getTranslatedString("LBL_GROUPING_TOTALS", $this->getCurrentModule4You()); } if ($this->report_obj->reportinformations["Group3"] != "none" && $this->report_obj->reportinformations["timeline_type3"] == "cols" && $h_i != 0 && isset($this->sum_col_i) && $this->sum_col_i != 1) { $header_colspan = $this->sum_col_i; } $header_f .= "<td class='rpt4youCellLabel' rowspan='$header_rowspan' colspan='$header_colspan' $header_style align='center' nowrap >$headerLabel</td>"; $h_i++; } if (!empty($group2_headers)) { $header_f .= '</tr><tr>'; foreach ($group2_headers as $g2_h_arr) { foreach ($g2_h_arr as $g2_h_labels) { $headerLabel = $g2_h_labels["label"]; $header_f .= "<td class='rpt4youCellLabel' style='" . $this->header_style . "' align='center' nowrap >$headerLabel</td>"; } } } } $report_html .= $header_f; $report_html .= '</tr><tr>'; $report_html .= $valtemplate; $report_html .= "</table></div>"; */ if (!empty($this->to_totals_res)) { //$report_html .= "<br>"; //$report_html .= $this->getTotalsHTML($this->to_totals_res); $to_totals_data_array = $this->getTotalsHTML($this->to_totals_res); } if (is_array($to_totals_data_array) && !empty($to_totals_data_array)) { $data[$xls_fri][] = " "; $xls_fri++; foreach ($to_totals_data_array as $row_data) { $data[$xls_fri] = $row_data; $xls_fri++; } } } // populate array for XLS export $headers = array(); if (!empty($header)) { foreach ($header as $header_arr) { $headers[] = $header_arr["label"]; } } $return_data["headers"] = $headers; $return_data["data"] = $data; if ($go_merge) { $return_data["merge_count"] = $nc_count_cols; $return_data["header_merge"] = $header_merge; } //ITS4YouReports::sshow($return_data); return $return_data; } } }
private function x21($efocus) { global $x0b, $x0c, $x0d, $x0e, $x0f, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x1a, $x1b, $x1c, $x1d, $x1e, $x1f, $x20, $x21, $x22, $x23, $x24, $x25, $x26; $commentlist = ""; $prefix = ""; if ($efocus->column_fields["record_module"] == "HelpDesk") { $prefix = "ticket"; } elseif ($efocus->column_fields["record_module"] == "Faq") { $prefix = "faq"; } if ($prefix != "") { $mod_lang = return_specified_module_language($this->language, $efocus->column_fields["record_module"]); $sql = "SELECT * FROM vtiger_" . $prefix . "comments WHERE " . $prefix . "id=" . $efocus->id; $result = $this->db->query($sql); while ($row = $this->db->fetchByAssoc($result)) { $comment = $row["comments"]; $crtime = getValidDisplayDate($row["createdtime"]); $body = ""; if ($prefix == "ticket") { $author = $this->x19($row["ownerid"]); $body = $comment . "<br />" . $mod_lang["LBL_AUTHOR"] . ": " . $author . "<br />" . $mod_lang["Created Time"] . ": " . $crtime . "<br /><br />"; } else { $body = $comment . "<br />" . $mod_lang["Created Time"] . ": " . $crtime . "<br /><br />"; } $commentlist .= $body; } } return $commentlist; }
private function getRBlockCriteriaJS() { $today = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y"))); $tomorrow = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"))); $yesterday = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))); $currentmonth0 = date("Y-m-d", mktime(0, 0, 0, date("m"), "01", date("Y"))); $currentmonth1 = date("Y-m-t"); $lastmonth0 = date("Y-m-d", mktime(0, 0, 0, date("m") - 1, "01", date("Y"))); $lastmonth1 = date("Y-m-t", strtotime("-1 Month")); $nextmonth0 = date("Y-m-d", mktime(0, 0, 0, date("m") + 1, "01", date("Y"))); $nextmonth1 = date("Y-m-t", strtotime("+1 Month")); $lastweek0 = date("Y-m-d", strtotime("-2 week Sunday")); $lastweek1 = date("Y-m-d", strtotime("-1 week Saturday")); $thisweek0 = date("Y-m-d", strtotime("-1 week Sunday")); $thisweek1 = date("Y-m-d", strtotime("this Saturday")); $nextweek0 = date("Y-m-d", strtotime("this Sunday")); $nextweek1 = date("Y-m-d", strtotime("+1 week Saturday")); $next7days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 6, date("Y"))); $next30days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 29, date("Y"))); $next60days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 59, date("Y"))); $next90days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 89, date("Y"))); $next120days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 119, date("Y"))); $last7days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 6, date("Y"))); $last30days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 29, date("Y"))); $last60days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 59, date("Y"))); $last90days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 89, date("Y"))); $last120days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 119, date("Y"))); $currentFY0 = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y"))); $currentFY1 = date("Y-m-t", mktime(0, 0, 0, "12", date("d"), date("Y"))); $lastFY0 = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y") - 1)); $lastFY1 = date("Y-m-t", mktime(0, 0, 0, "12", date("d"), date("Y") - 1)); $nextFY0 = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y") + 1)); $nextFY1 = date("Y-m-t", mktime(0, 0, 0, "12", date("d"), date("Y") + 1)); if (date("m") <= 3) { $cFq = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "03", "31", date("Y"))); $nFq = date("Y-m-d", mktime(0, 0, 0, "04", "01", date("Y"))); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "06", "30", date("Y"))); $pFq = date("Y-m-d", mktime(0, 0, 0, "10", "01", date("Y") - 1)); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "12", "31", date("Y") - 1)); } else { if (date("m") > 3 and date("m") <= 6) { $pFq = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y"))); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "03", "31", date("Y"))); $cFq = date("Y-m-d", mktime(0, 0, 0, "04", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "06", "30", date("Y"))); $nFq = date("Y-m-d", mktime(0, 0, 0, "07", "01", date("Y"))); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "09", "30", date("Y"))); } else { if (date("m") > 6 and date("m") <= 9) { $nFq = date("Y-m-d", mktime(0, 0, 0, "10", "01", date("Y"))); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "12", "31", date("Y"))); $pFq = date("Y-m-d", mktime(0, 0, 0, "04", "01", date("Y"))); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "06", "30", date("Y"))); $cFq = date("Y-m-d", mktime(0, 0, 0, "07", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "09", "30", date("Y"))); } else { if (date("m") > 9 and date("m") <= 12) { $nFq = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y") + 1)); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "03", "31", date("Y") + 1)); $pFq = date("Y-m-d", mktime(0, 0, 0, "07", "01", date("Y"))); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "09", "30", date("Y"))); $cFq = date("Y-m-d", mktime(0, 0, 0, "10", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "12", "31", date("Y"))); } } } } $sjsStr = '<script language="JavaScript" type="text/javaScript"> function showDateRange( type ) { if (type!="custom") { document.NewBlock.startdate.readOnly=true document.NewBlock.enddate.readOnly=true getObj("jscal_trigger_date_start").style.visibility="hidden" getObj("jscal_trigger_date_end").style.visibility="hidden" } else { document.NewBlock.startdate.readOnly=false document.NewBlock.enddate.readOnly=false getObj("jscal_trigger_date_start").style.visibility="visible" getObj("jscal_trigger_date_end").style.visibility="visible" } if( type == "today" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($today) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($today) . '"; } else if( type == "yesterday" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($yesterday) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($yesterday) . '"; } else if( type == "tomorrow" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($tomorrow) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($tomorrow) . '"; } else if( type == "thisweek" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($thisweek0) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($thisweek1) . '"; } else if( type == "lastweek" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($lastweek0) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($lastweek1) . '"; } else if( type == "nextweek" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($nextweek0) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($nextweek1) . '"; } else if( type == "thismonth" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($currentmonth0) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($currentmonth1) . '"; } else if( type == "lastmonth" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($lastmonth0) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($lastmonth1) . '"; } else if( type == "nextmonth" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($nextmonth0) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($nextmonth1) . '"; } else if( type == "next7days" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($today) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($next7days) . '"; } else if( type == "next30days" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($today) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($next30days) . '"; } else if( type == "next60days" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($today) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($next60days) . '"; } else if( type == "next90days" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($today) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($next90days) . '"; } else if( type == "next120days" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($today) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($next120days) . '"; } else if( type == "last7days" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($last7days) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($today) . '"; } else if( type == "last30days" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($last30days) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($today) . '"; } else if( type == "last60days" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($last60days) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($today) . '"; } else if( type == "last90days" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($last90days) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($today) . '"; } else if( type == "last120days" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($last120days) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($today) . '"; } else if( type == "thisfy" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($currentFY0) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($currentFY1) . '"; } else if( type == "prevfy" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($lastFY0) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($lastFY1) . '"; } else if( type == "nextfy" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($nextFY0) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($nextFY1) . '"; } else if( type == "nextfq" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($nFq) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($nFq1) . '"; } else if( type == "prevfq" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($pFq) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($pFq1) . '"; } else if( type == "thisfq" ) { document.NewBlock.startdate.value = "' . getValidDisplayDate($cFq) . '"; document.NewBlock.enddate.value = "' . getValidDisplayDate($cFq1) . '"; } else { document.NewBlock.startdate.value = ""; document.NewBlock.enddate.value = ""; } } </script>'; return $sjsStr; }
require $user_privileges_path; } if (isset($_REQUEST["record"]) && $_REQUEST["record"] != "") { $ITS4YouReports->getSelectedStandardCriteria($reportid); $BLOCK1 .= getITSPrimaryStdFilterHTML($ITS4YouReports, $ITS4YouReports->primarymodule, $ITS4YouReports->stdselectedcolumn); $BLOCK1 .= getITSSecondaryStdFilterHTML($ITS4YouReports, $ITS4YouReports->relatedmodulesstring, $ITS4YouReports->stdselectedcolumn); //added to fix the ticket #5117 $selectedcolumnvalue = '"' . $ITS4YouReports->stdselectedcolumn . '"'; if (!$is_admin && isset($ITS4YouReports->stdselectedcolumn) && strpos($BLOCK1, $selectedcolumnvalue) === false) { $smarty_obj->assign("BLOCK1_STD", $BLOCK1); } $BLOCKCRITERIA = $ITS4YouReports->getSelectedStdFilterCriteria($ITS4YouReports->stdselectedfilter); $smarty_obj->assign("BLOCKCRITERIA_STD", $BLOCKCRITERIA); if (isset($ITS4YouReports->startdate) && isset($ITS4YouReports->enddate)) { $smarty_obj->assign("STARTDATE_STD", getValidDisplayDate($ITS4YouReports->startdate)); $smarty_obj->assign("ENDDATE_STD", getValidDisplayDate($ITS4YouReports->enddate)); } else { $smarty_obj->assign("STARTDATE_STD", $ITS4YouReports->startdate); $smarty_obj->assign("ENDDATE_STD", $ITS4YouReports->enddate); } } else { $primarymodule = vtlib_purify($_REQUEST["reportmodule"]); $BLOCK1 .= getITSPrimaryStdFilterHTML($ITS4YouReports, $primarymodule); if (!empty($ITS4YouReports->related_modules[$primarymodule])) { foreach ($ITS4YouReports->related_modules[$primarymodule] as $key => $value) { $BLOCK1 .= getITSSecondaryStdFilterHTML($ITS4YouReports, $_REQUEST["secondarymodule_" . $value]); } } $smarty_obj->assign("BLOCK1_STD", $BLOCK1); $BLOCKCRITERIA = $ITS4YouReports->getSelectedStdFilterCriteria(); $smarty_obj->assign("BLOCKCRITERIA_STD", $BLOCKCRITERIA);
function getFilterDateHtml(Vtiger_Request $request) { $return_html = ""; $columnIndex = $request->get("columnIndex"); if ($columnIndex != "") { $currentUser = Users_Record_Model::getCurrentUserModel(); $date_format = $currentUser->get('date_format'); //$date_format = "dd-mm-yyyy"; $moduleName = $request->getModule(); $record = $request->get("record"); $fop_type = $request->get("fop_type"); $reportModel = ITS4YouReports_Record_Model::getCleanInstance($record); $rel_fields = $reportModel->getAdvRelFields(); $r_sel_fields = $request->get("r_sel_fields"); $ctype = "f"; $s_date_value = $e_date_value = ""; if ($r_sel_fields != "") { $default_charset = vglobal("default_charset"); if ($fop_type != "custom") { $std_val_array = GenerateObj::getStandarFiltersStartAndEndDate($fop_type); } else { $std_val_array = explode("<;@STDV@;>", html_entity_decode($r_sel_fields, ENT_QUOTES, $default_charset)); } if (in_array($fop_type, array("todayless"))) { $s_date_value = ""; if ($std_val_array[0] != "--" && $std_val_array[0] != "") { $e_date_value = $std_val_array[0]; } else { $e_date_value = $std_val_array[1]; } } elseif (in_array($fop_type, array("todaymore", "older1days", "older7days", "older15days", "older30days", "older60days", "older90days", "older120days"))) { $s_date_value = $std_val_array[0]; $e_date_value = ""; } else { $s_date_value = $std_val_array[0]; $e_date_value = $std_val_array[1]; } } if ($fop_type != "custom") { $readonly = "true"; } else { $readonly = "false"; } if ($s_date_value != "") { $s_date_value_f = getValidDisplayDate($s_date_value); } if ($e_date_value != "") { $e_date_value_f = getValidDisplayDate($e_date_value); } //'<input id="Invoice_editView_fieldName_invoicedate" class="span9 dateField" name="invoicedate" data-date-format="dd-mm-yyyy" value="21-07-2014" data-fieldinfo="{\'mandatory\':false,\'presence\':true,\'quickcreate\':false,\'masseditable\':true,\'defaultvalue\':false,\'type\':\'date\',\'name\':\'invoicedate\',\'label\':\'Invoice Date\',\'date-format\':\'dd-mm-yyyy\'}" type="text">'; $return_html .= "<div class='row-fluid'>\n <div class='span6'>\n <div class='row-fluid input-append'>\n <div id='jscal_trigger_sdate" . $columnIndex . "' class='span10 row-fluid date hide'>\n <input class='span9 dateField' name='startdate' id='jscal_field_sdate_val_" . $columnIndex . "' data-date-format='" . $date_format . "' maxlength='10' value='" . $s_date_value . "' type='text'>\n <span class='add-on'><i class='icon-calendar'></i></span> \n </div>\n <input data-value='value' class='span10' name='' id='jscal_field_sdate" . $columnIndex . "' readonly='true' value='" . $s_date_value_f . "'>\n </div>\n <!--<div class='row-fluid'>\n <font size='1'><b>" . vtranslate("LBL_SF_STARTDATE", $moduleName) . "</b></font>\n </div>-->\n </div>\n <div class='span6'>\n <div class='row-fluid input-append'>\n <div id='jscal_trigger_edate" . $columnIndex . "' class='span10 row-fluid date hide'>\n <input class='span9 dateField' name='enddate' id='jscal_field_edate_val_" . $columnIndex . "' data-date-format=" . $date_format . "' maxlength='10' value='" . $e_date_value . "' type='text'>\n <span class='add-on'><i class='icon-calendar'></i></span>\n </div>\n <input data-value='value' class='span10' name='' id='jscal_field_edate" . $columnIndex . "' readonly='true' value='" . $e_date_value_f . "'>\n </div>\n <!--<div class='row-fluid'>\n <font size='1'><b>" . vtranslate("LBL_SF_ENDDATE", $moduleName) . "</b></font>\n </div>-->\n </div>\n </div>"; /* $return_html .= " <table> <tr> <td width='20%'> <table><tbody> <tr> <td style='vertical-align:top;'> <input name='startdate' id='jscal_field_sdate$columnIndex' style='border: 1px solid rgb(186, 186, 186);' size='10' maxlength='10' value='$s_date_value' type='text'> <img style='visibility: hidden;' src='themes/softed/images/btnL3Calendar.gif' id='jscal_trigger_sdate$columnIndex' align='absmiddle'><br> <font size='1'><b>".vtranslate("LBL_SF_STARTDATE", $moduleName).":</b><em old='(yyyy-mm-dd)'>(dd-mm-yyyy)</em></font> </td> </tr> </tbody></table> </td> <td width='30%'> <table><tbody> <tr> <td style='vertical-align:top;'> <input name='enddate' id='jscal_field_edate$columnIndex' style='border: 1px solid rgb(186, 186, 186);' size='10' maxlength='10' value='$e_date_value' type='text'> <img style='visibility: hidden;' src='themes/softed/images/btnL3Calendar.gif' id='jscal_trigger_edate$columnIndex' align='absmiddle'><br> <font size='1'><b>".vtranslate("LBL_SF_ENDDATE", $moduleName).":</b><em old='(yyyy-mm-dd)'>(dd-mm-yyyy)</em></font> </td> </tr> </tbody></table> </td> </tr> </table> ";*/ } echo $return_html; }
function process(Mobile_API_Request $request) { require_once 'include/utils/utils.php'; require_once 'modules/Mobile/language/en_us.lang.php'; global $adb; //get scroll parameter $wsResponse = parent::process($request); if (is_numeric($request->get('offset'))) { $offset = $request->get('offset'); } else { //do nothing echo ''; return $wsResponse; } if (is_numeric($request->get('number'))) { $postnumbers = $request->get('number'); } else { //do nothing echo ''; return $wsResponse; } $wsResponseResult = $wsResponse->getResult(); $module = $wsResponseResult['module']; $records = $wsResponseResult['records']; $noofrows = $adb->num_rows($records); $tabid = getTabid($module); $fieldquery = "select fieldname,entityidfield from vtiger_entityname where tabid =?"; $ws_entity1 = $adb->pquery($fieldquery, array($tabid)); $fieldname = $adb->query_result($ws_entity1, 0, 'fieldname'); $entityidfield = $adb->query_result($ws_entity1, 0, 'entityidfield'); $fieldcontent = explode(',', $fieldname); if ($module == 'Calendar' || $module == 'Events') { $entity = "select id from vtiger_ws_entity where ismodule=1 and name = ? OR name = ? ORDER BY name"; $ws_entity = $adb->pquery($entity, array('Calendar', 'Events')); $arr_entity2[] = $adb->query_result($ws_entity, 0, 'id'); $arr_entity2[] = $adb->query_result($ws_entity, 1, 'id'); } else { $entity = "select id from vtiger_ws_entity where ismodule=1 and name =?"; $ws_entity = $adb->pquery($entity, array($wsResponseResult['module'])); $ws_entity2 = $adb->query_result($ws_entity, 0, 'id'); } $output = ""; for ($i = 0; $i < $noofrows; $i++) { $firstname = $adb->query_result($records, $i, $fieldcontent[0]); $lastname = $adb->query_result($records, $i, $fieldcontent[1]); if ($module == 'Calendar' || $module == 'Events') { //for calendar display date and time global $current_language; $activitytype = $adb->query_result($records, $i, 'status') == '' ? 'E' : ($current_language == 'ge_de' ? 'A' : 'T'); $ws_entity2 = $adb->query_result($records, $i, 'status') == '' ? $arr_entity2[1] : $arr_entity2[0]; $firstname = $activitytype . " | " . $firstname . " |"; $lastname = getValidDisplayDate($adb->query_result($records, $i, 'date_start')); $timequery = "select time_start from vtiger_activity where activityid =?"; $timequeryresult = $adb->pquery($timequery, array($adb->query_result($records, $i, $entityidfield))); $time_start = $adb->query_result($timequeryresult, 0, 'time_start'); //cut seconds if exist $time = strlen($time_start) > 5 ? substr($time_start, 0, 5) . '' : $time_start; $lastname .= " {$time}"; } $id = $ws_entity2 . "x" . $adb->query_result($records, $i, $entityidfield); $output .= ' <li><a class="ui-btn ui-btn-icon-right ui-icon-carat-r" target="_self" href="?_operation=fetchRecordWithGrouping&record=' . $id . '" target="_self">' . $firstname . ' ' . $lastname . '</a></li> '; /* <li class="ui-btn-inner ui-btn ui-btn-up-c ui-li ui-first-child" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="false" data-theme="c" > <div class="ui-btn-inner ui-li"> <div class="ui-btn-text"> <a class="ui-link-inherit" target="_self" href="?_operation=fetchRecordWithGrouping&record='.$id.'" target="_self">'.$firstname.' '.$lastname.'</a> </div> <span class="ui-icon ui-icon-arrow-r ui-icon-shadow"> </span> </div> </li> */ } $response = new Mobile_API_Response(); $response->setResult($output); return $response; }
function getSummariesFilterList($reportid) { global $modules; global $default_charset; //ITS4YOU VlMe Fix $adb = PearDatabase::getInstance(); $summaries_criteria = array(); $ssql = 'select its4you_reports4you_relcriteria_summaries.* from its4you_reports4you inner join its4you_reports4you_relcriteria_summaries on its4you_reports4you_relcriteria_summaries.reportid = its4you_reports4you.reports4youid'; $ssql .= " where its4you_reports4you.reports4youid = ? order by its4you_reports4you_relcriteria_summaries.columnindex"; $result = $adb->pquery($ssql, array($reportid)); $noOfColumns = $adb->num_rows($result); if ($noOfColumns > 0) { $this->j = 0; while ($relcriteriarow = $adb->fetch_array($result)) { $columnIndex = $relcriteriarow["columnindex"]; $criteria = array(); $criteria['columnname'] = html_entity_decode($relcriteriarow["columnname"], ENT_QUOTES, $default_charset); //ITS4YOU VlMe Fix $criteria['comparator'] = $relcriteriarow["comparator"]; $advfilterval = $relcriteriarow["value"]; $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++) { list($temp_date, $temp_time) = explode(" ", $temp_val[$x]); $temp_date = getValidDisplayDate(trim($temp_date)); if (trim($temp_time) != '') { $temp_date .= ' ' . $temp_time; } $val[$x] = $temp_date; } $advfilterval = implode(",", $val); } $criteria['value'] = decode_html($advfilterval); $criteria['column_condition'] = $relcriteriarow["column_condition"]; /* $summaries_criteria['columns'][$this->j] = $criteria; $summaries_criteria['condition'] = $groupCondition; */ $summaries_criteria[$this->j] = $criteria; $this->j++; } } $this->summaries_criteria = $summaries_criteria; return true; }
function get_do_pdf() { require_once 'include/tcpdf/pdf.php'; require_once 'include/tcpdf/pdfconfig.php'; require_once 'include/database/PearDatabase.php'; require_once 'modules/Deliverynote/Deliverynote.php'; require_once 'modules/Invoice/Invoice.php'; require_once 'modules/SalesOrder/SalesOrder.php'; require_once 'modules/Deliverynote/language/en_us.lang.php'; global $adb, $app_strings, $current_user, $mod_strings; // would you like and end page? 1 for yes 0 for no $endpage = "1"; $id = $_REQUEST['src_record']; // scott Print_r($_REQUEST); //retreiving the vtiger_invoice info $focus = new Deliverynote(); $focus->retrieve_entity_info($_REQUEST['src_record'], "Deliverynote"); // $focus->retrieve_entity_info($_REQUEST['LinkTo'],"SalesOrder"); $focus->apply_field_security(); // scott Print_r($focus->column_fields); $productlist = $focus->column_fields["ProductList"]; $customerpo = $focus->column_fields["CustomerPO"]; $dn_number = $focus->column_fields["dn_sequence"]; $inv_no = $focus->column_fields['LinkTo']; // scott Print($productlist); $focus = new SalesOrder(); $focus->retrieve_entity_info($inv_no, "SalesOrder"); //scott Print_r($focus); $sql = "select currency_symbol from vtiger_currency_info where id=?"; $result = $adb->pquery($sql, array($focus->column_fields['currency_id'])); $currency_symbol = $adb->query_result($result, 0, 'currency_symbol'); // **************** BEGIN POPULATE DATA ******************** // populate data if ($focus->column_fields["quote_id"] != '') { $quote_name = getQuoteName($focus->column_fields["quote_id"]); } else { $quote_name = ''; } if ($focus->column_fields["account_id"] != '') { $account_name = getAccountName($focus->column_fields["account_id"]); } else { $account_name = ''; } $contact_phone = ''; if ($focus->column_fields["contact_id"] != '') { $contact_name = getContactName($focus->column_fields["contact_id"]); $contact_phone = getContactPhone($focus->column_fields["contact_id"]); } else { $contact_name = ''; } $po_name = $focus->column_fields["purchaseorder"]; $subject = $focus->column_fields["subject"]; //scott $job_number = $focus->column_fields["subject"]; $valid_till = $focus->column_fields["duedate"]; $valid_till = getValidDisplayDate($valid_till); $bill_street = $focus->column_fields["bill_street"]; $bill_city = $focus->column_fields["bill_city"]; $bill_state = $focus->column_fields["bill_state"]; $bill_code = $focus->column_fields["bill_code"]; $bill_country = $focus->column_fields["bill_country"]; $contact_name = getContactName($focus->column_fields["contact_id"]); $ship_street = $focus->column_fields["ship_street"]; $ship_city = $focus->column_fields["ship_city"]; $ship_state = $focus->column_fields["ship_state"]; $ship_code = $focus->column_fields["ship_code"]; $ship_country = $focus->column_fields["ship_country"]; $conditions = from_html($focus->column_fields["terms_conditions"]); $description = from_html($focus->column_fields["description"]); $status = $focus->column_fields["sostatus"]; // Company information $add_query = "select * from vtiger_organizationdetails"; $result = $adb->pquery($add_query, array()); $num_rows = $adb->num_rows($result); if ($num_rows > 0) { $org_name = $adb->query_result($result, 0, "organizationname"); $org_address = $adb->query_result($result, 0, "address"); $org_city = $adb->query_result($result, 0, "city"); $org_state = $adb->query_result($result, 0, "state"); $org_country = $adb->query_result($result, 0, "country"); $org_code = $adb->query_result($result, 0, "code"); $org_phone = $adb->query_result($result, 0, "phone"); $org_fax = $adb->query_result($result, 0, "fax"); $org_website = $adb->query_result($result, 0, "website"); $logo_name = $adb->query_result($result, 0, "logoname"); } //Population of Product Details - Starts //we can cut and paste the following lines in a file and include that file here is enough. For that we have to put a new common file. we will do this later //NOTE : Removed currency symbols and added with Grand Total text. it is enough to show the currency symbol in one place //we can also get the NetTotal, Final Discount Amount/Percent, Adjustment and GrandTotal from the array $associated_products[1]['final_details'] //get the Associated Products for this Invoice $focus->id = $focus->column_fields["record_id"]; $associated_products = getAssociatedProducts("SalesOrder", $focus); $num_products = count($associated_products); //This $final_details array will contain the final total, discount, Group Tax, S&H charge, S&H taxes and adjustment $final_details = $associated_products[1]['final_details']; //getting the Net Total $price_subtotal = number_format($final_details["hdnSubTotal"], 2, '.', ','); //Final discount amount/percentage $discount_amount = $final_details["discount_amount_final"]; $discount_percent = $final_details["discount_percentage_final"]; if ($discount_amount != "") { $price_discount = number_format($discount_amount, 2, '.', ','); } else { if ($discount_percent != "") { //This will be displayed near Discount label - used in include/fpdf/templates/body.php $final_price_discount_percent = "(" . number_format($discount_percent, 2, '.', ',') . " %)"; $price_discount = number_format($discount_percent * $final_details["hdnSubTotal"] / 100, 2, '.', ','); } else { $price_discount = "0.00"; } } //Adjustment $price_adjustment = number_format($final_details["adjustment"], 2, '.', ','); //Grand Total $price_total = number_format($final_details["grandTotal"], 2, '.', ','); //To calculate the group tax amount if ($final_details['taxtype'] == 'group') { $group_tax_total = $final_details['tax_totalamount']; $price_salestax = number_format($group_tax_total, 2, '.', ','); $group_total_tax_percent = '0.00'; $group_tax_details = $final_details['taxes']; for ($i = 0; $i < count($group_tax_details); $i++) { $group_total_tax_percent = $group_total_tax_percent + $group_tax_details[$i]['percentage']; } } //S&H amount $sh_amount = $final_details['shipping_handling_charge']; $price_shipping = number_format($sh_amount, 2, '.', ','); //S&H taxes $sh_tax_details = $final_details['sh_taxes']; $sh_tax_percent = '0.00'; for ($i = 0; $i < count($sh_tax_details); $i++) { $sh_tax_percent = $sh_tax_percent + $sh_tax_details[$i]['percentage']; } $sh_tax_amount = $final_details['shtax_totalamount']; $price_shipping_tax = number_format($sh_tax_amount, 2, '.', ','); $prod_line = array(); $lines = 0; $prod_item = explode(",", $productlist); //updated by scott $num_products = count($prod_item); // updated by scott if ($productlist == '') { $num_products = count($associated_products); //if product list empty for ($k = 1; $k <= $num_products; $k++) { $prod_item[$k - 1] = $k; } // Print_r($prod_item); } // Print_r($prod_item); // Print($num_products); //This is to get all prodcut details as row basis // Print_r($associated_products); for ($k = 1, $j = $k - 1; $k <= $num_products; $k++, $j++) { $i = $prod_item[$k - 1]; $product_name[$i] = $associated_products[$i]['productName' . $i]; $subproduct_name[$i] = split("<br>", $associated_products[$i]['subprod_names' . $i]); //$prod_description[$i] = $associated_products[$i]['productDescription'.$i]; $comment[$i] = $associated_products[$i]['comment' . $i]; $product_id[$i] = $associated_products[$i]['hdnProductId' . $i]; $qty[$i] = $associated_products[$i]['qty' . $i]; $unit_price[$i] = number_format($associated_products[$i]['unitPrice' . $i], 2, '.', ','); $list_price[$i] = number_format($associated_products[$i]['listPrice' . $i], 2, '.', ','); $list_pricet[$i] = $associated_products[$i]['listPrice' . $i]; $discount_total[$i] = $associated_products[$i]['discountTotal' . $i]; //aded for 5.0.3 pdf changes $product_code[$i] = $associated_products[$i]['hdnProductcode' . $i]; $taxable_total = $qty[$i] * $list_pricet[$i] - $discount_total[$i]; $producttotal = $taxable_total; $total_taxes = '0.00'; if ($focus->column_fields["hdnTaxType"] == "individual") { $total_tax_percent = '0.00'; //This loop is to get all tax percentage and then calculate the total of all taxes for ($tax_count = 0; $tax_count < count($associated_products[$i]['taxes']); $tax_count++) { $tax_percent = $associated_products[$i]['taxes'][$tax_count]['percentage']; $total_tax_percent = $total_tax_percent + $tax_percent; $tax_amount = $taxable_total * $tax_percent / 100; $total_taxes = $total_taxes + $tax_amount; } $producttotal = $taxable_total + $total_taxes; $product_line[$j]["Tax"] = number_format($total_taxes, 2, '.', ',') . "\n ({$total_tax_percent} %) "; $price_salestax += $total_taxes; } $prod_total[$i] = number_format($producttotal, 2, '.', ','); $product_line[$j]["Count"] = $i . "."; $product_line[$j]["Product Code"] = $product_code[$i]; $product_line[$j]["Qty"] = $qty[$i]; $product_line[$j]["Units"] = "test"; //scott $qty[$i]; $product_line[$j]["Price"] = $list_price[$i]; $product_line[$j]["Discount"] = $discount_total[$i]; $product_line[$j]["Total"] = $prod_total[$i]; $lines++; $product_line[$j]["Product Name"] = decode_html($product_name[$i]); $prod_line[$j] = 1; for ($count = 0; $count < count($subproduct_name[$i]); $count++) { if ($lines % 24 != 0) { $product_line[$j]["Product Name"] .= "\n" . decode_html($subproduct_name[$i][$count]); $prod_line[$j]++; } else { $j++; $product_line[$j]["Product Name"] = decode_html($product_name[$i]); $product_line[$j]["Product Name"] .= "\n" . decode_html($subproduct_name[$i][$count]); $prod_line[$j] = 2; $lines++; } $lines++; } if ($comment[$i] != '') { $product_line[$j]["Product Name"] .= "\n" . decode_html($comment[$i]); $prod_line[$j]++; $lines++; } } $price_salestax = number_format($price_salestax, 2, '.', ','); //echo '<pre>Product Details ==>';print_r($product_line);echo '</pre>'; //echo '<pre>';print_r($associated_products);echo '</pre>'; //Population of Product Details - Ends // ************************ END POPULATE DATA ***************************8 $page_num = '1'; $pdf = new PDF('P', 'mm', 'A4'); $pdf->Open(); // $num_pages=ceil(($num_products/$products_per_page)); //STARTS - Placement of products in pages as per the lines count $lines_per_page = "24"; $prod_cnt = 0; $num_pages = ceil($lines / $lines_per_page); $tmp = 0; for ($count = 0; $count < $num_pages; $count++) { for ($k = $tmp; $k < $j; $k++) { if ($prod_cnt != 24) { $products[$count][] = $k; $prod_cnt += $prod_line[$k]; } else { $tmp = $k; $prod_cnt = 0; break; } } } //ENDS - Placement of products in pages as per the lines count $current_product = 0; for ($l = 0; $l < $num_pages; $l++) { $line = array(); if ($num_pages == $page_num) { $lastpage = 1; } /*while($current_product != $page_num*$products_per_page) { $line[]=$product_line[$current_product]; $current_product++; }/*/ foreach ($products[$l] as $index => $key) { $line[] = $product_line[$key]; } $pdf->AddPage(); include "modules/Deliverynote/pdf_templates/header.php"; include "modules/Deliverynote/pdf_templates/dobody.php"; //if bottom > 145 then we skip the Description and T&C in every page and display only in lastpage //if you want to display the description and T&C in each page then set the display_desc_tc='true' and bottom <= 145 in pdfconfig.php if ($display_desc_tc == 'true') { if ($bottom <= 145) { include "modules/Deliverynote/pdf_templates/footer.php"; } } $page_num++; //scott last page remove: if (($endpage) && ($lastpage)) //scott last page remove: { //scott last page remove: $pdf->AddPage(); //scott last page remove: include("modules/Deliverynote/pdf_templates/header.php"); //scott last page remove: include("modules/Deliverynote/pdf_templates/lastpage/body.php"); //scott last page remove: include("modules/Deliverynote/pdf_templates/lastpage/footer.php"); //scott last page remove: } } return $pdf; }
private function x26($x93) { global $x15d, $x15e, $x15f, $x160, $x161, $x162, $x163, $x164, $x165, $x166, $x167, $x168, $x169, $x16a, $x16b, $x16c, $x16d, $x16e, $x16f, $x170, $x171, $x172, $x173, $x174, $x175, $x176, $x177, $x178; $x13d = ""; $x13e = ""; if ($x93->column_fields["record_module"] == "HelpDesk") { $x13e = "ticket"; } elseif ($x93->column_fields["record_module"] == "Faq") { $x13e = "faq"; } if ($x13e != "") { $xb6 = return_specified_module_language(self::$x0d, $x93->column_fields["record_module"]); $x3d = "SELECT * FROM vtiger_" . $x13e . "comments WHERE " . $x13e . "id=" . $x93->id; $x3e = self::$x0f->query($x3d); while ($x42 = self::$x0f->fetchByAssoc($x3e)) { $xd9 = $x42["comments"]; $x13f = getValidDisplayDate($x42["createdtime"]); $x1b = ""; if ($x13e == "ticket") { $x140 = $this->x1e($x42["ownerid"]); $x1b = $xd9 . "<br />" . $xb6["LBL_AUTHOR"] . ": " . $x140 . "<br />" . $xb6["Created Time"] . ": " . $x13f . "<br /><br />"; } else { $x1b = $xd9 . "<br />" . $xb6["Created Time"] . ": " . $x13f . "<br /><br />"; } $x13d .= $x1b; } } return $x13d; }
/** This function returns the vtiger_field details for a given vtiger_fieldname. * Param $uitype - UI type of the vtiger_field * Param $fieldname - Form vtiger_field name * Param $fieldlabel - Form vtiger_field label name * Param $maxlength - maximum length of the vtiger_field * Param $col_fields - array contains the vtiger_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $module_name - module name * Return type is an array */ function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module_name, $mode = '', $typeofdata = null) { global $log, $app_strings, $adb, $default_charset, $theme, $mod_strings, $current_user; $log->debug("Entering getOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $maxlength . "," . print_r($col_fields, true) . "," . $generatedtype . "," . $module_name . ") method ..."); require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $fieldlabel = from_html($fieldlabel); $fieldvalue = array(); $final_arr = array(); $value = $col_fields[$fieldname]; $custfld = ''; $ui_type[] = $uitype; $editview_fldname[] = $fieldname; // vtlib customization: Related type field if ($uitype == '10') { global $adb; $fldmod_result = $adb->pquery('SELECT relmodule, status FROM vtiger_fieldmodulerel WHERE fieldid= (SELECT fieldid FROM vtiger_field, vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid AND fieldname=? AND name=? and vtiger_field.presence in (0,2)) order by sequence', array($fieldname, $module_name)); $entityTypes = array(); $parent_id = $value; for ($index = 0; $index < $adb->num_rows($fldmod_result); ++$index) { $entityTypes[] = $adb->query_result($fldmod_result, $index, 'relmodule'); } if (!empty($value)) { if ($adb->num_rows($fldmod_result) == 1) { $valueType = $adb->query_result($fldmod_result, 0, 0); } else { $valueType = getSalesEntityType($value); } $displayValueArray = getEntityName($valueType, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $value) { $displayValue = $value; } } } else { $displayValue = ''; $valueType = ''; $value = ''; } $editview_label[] = array('options' => $entityTypes, 'selected' => $valueType, 'displaylabel' => getTranslatedString($fieldlabel, $module_name)); $fieldvalue[] = array('displayvalue' => $displayValue, 'entityid' => $parent_id); } else { if ($uitype == 5 || $uitype == 6 || $uitype == 23) { $log->info("uitype is " . $uitype); if ($value == '') { //modified to fix the issue in trac(http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/1469) if ($fieldname != 'birthday' && $generatedtype != 2 && getTabid($module_name) != 14) { $disp_value = getNewDisplayDate(); } if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 6) { $curr_time = date('H:i', strtotime('+5 minutes')); } if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) { $curr_time = date('H:i', strtotime('+10 minutes')); } //Added to display the Contact - Support End Date as one year future instead of //today's date -- 30-11-2005 if ($fieldname == 'support_end_date' && $_REQUEST['module'] == 'Contacts') { $addyear = strtotime("+1 year"); $disp_value = DateTimeField::convertToUserFormat(date('Y-m-d', $addyear)); } elseif ($fieldname == 'validtill' && $_REQUEST['module'] == 'Quotes') { $disp_value = ''; } } else { if ($uitype == 6) { if ($col_fields['time_start'] != '' && ($module_name == 'Events' || $module_name == 'Calendar')) { $curr_time = $col_fields['time_start']; $value = $value . ' ' . $curr_time; } else { $curr_time = date('H:i', strtotime('+5 minutes')); } } if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) { if ($col_fields['time_end'] != '') { $curr_time = $col_fields['time_end']; $value = $value . ' ' . $curr_time; } else { $curr_time = date('H:i', strtotime('+10 minutes')); } } $disp_value = getValidDisplayDate($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); if (!empty($curr_time)) { if (($module_name == 'Events' || $module_name == 'Calendar') && ($uitype == 23 || $uitype == 6)) { $curr_time = DateTimeField::convertToUserTimeZone($curr_time); $curr_time = $curr_time->format('H:i'); } } else { $curr_time = ''; } if (empty($disp_value)) { $disp_value = ''; } $fieldvalue[] = array($disp_value => $curr_time); if ($uitype == 5 || $uitype == 23) { if ($module_name == 'Events' && $uitype == 23) { $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']); } else { $fieldvalue[] = array($date_format => $current_user->date_format); } } else { $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']); } } elseif ($uitype == 16) { require_once 'modules/PickList/PickListUtils.php'; $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldname = $adb->sql_escape_string($fieldname); $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid"; $params = array(); $pickListResult = $adb->pquery($pick_query, $params); $noofpickrows = $adb->num_rows($pickListResult); $options = array(); $pickcount = 0; $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $value = decode_html($value); $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname))); if ($value == trim($pickListValue)) { $chk_val = "selected"; $pickcount++; $found = true; } else { $chk_val = ''; } $pickListValue = to_html($pickListValue); if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } $fieldvalue[] = $options; } elseif ($uitype == 1613) { require_once 'modules/PickList/PickListUtils.php'; $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldname = $adb->sql_escape_string($fieldname); $pickListResult = getAllowedPicklistModules(); $options = array(); $options[] = ""; $pickcount = 0; $found = false; foreach ($pickListResult as $pKey => $pValue) { $value = decode_html($value); $pickListValue = decode_html($pValue); if ($value == trim($pickListValue)) { $chk_val = "selected"; $pickcount++; $found = true; } else { $chk_val = ''; } $pickListValue = to_html($pickListValue); if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val); } } uasort($options, function ($a, $b) { return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1; }); $fieldvalue[] = $options; } elseif ($uitype == 15 || $uitype == 33) { require_once 'modules/PickList/PickListUtils.php'; $roleid = $current_user->roleid; $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); $valueArr = explode("|##|", $value); foreach ($valueArr as $key => $value) { $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset)); } $pickcount = 0; if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { if (in_array(trim($pickListValue), $valueArr)) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected'); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $options; } elseif ($uitype == 3313) { require_once 'modules/PickList/PickListUtils.php'; $picklistValues = getAllowedPicklistModules(); $valueArr = explode("|##|", $value); foreach ($valueArr as $key => $value) { $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset)); } $pickcount = 0; if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { if (in_array(trim($pickListValue), $valueArr)) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected'); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); uasort($options, function ($a, $b) { return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1; }); $fieldvalue[] = $options; } elseif ($uitype == 1024) { $options = array(); $arr_evo = explode(' |##| ', $value); $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); $uservalues = array_merge($subrole, array($roleid)); for ($i = 0; $i < sizeof($uservalues); $i++) { $currentValId = $uservalues[$i]; $currentValName = getRoleName($currentValId); if (in_array(trim($currentValId), $arr_evo)) { $chk_val = 'selected'; } else { $chk_val = ''; } $options[] = array($currentValName, $currentValId, $chk_val); } $fieldvalue[] = $options; $editview_label[] = getTranslatedString($fieldlabel, $module_name); } elseif ($uitype == 17) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 85) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 14) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 19 || $uitype == 20) { if (isset($_REQUEST['body'])) { $value = $_REQUEST['body']; } if ($fieldname == 'terms_conditions') { //Assign the value from focus->column_fields (if we create Invoice from SO the SO's terms and conditions will be loaded to Invoice's terms and conditions, etc.,) $value = $col_fields['terms_conditions']; //if the value is empty then only we should get the default Terms and Conditions if ($value == '' && $mode != 'edit') { $value = getTermsandConditions(); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 21 || $uitype == 24) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 22) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 52 || $uitype == 77) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); global $current_user; if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } if ($uitype == 52) { $combo_lbl_name = 'assigned_user_id'; } elseif ($uitype == 77) { $combo_lbl_name = 'assigned_user_id1'; } //Control will come here only for Products - Handler and Quotes - Inventory Manager if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); } $fieldvalue[] = $users_combo; } elseif ($uitype == 53) { global $noof_group_rows; $editview_label[] = getTranslatedString($fieldlabel, $module_name); //Security Checks if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $result = get_current_user_access_groups($module_name); } else { $result = get_group_options(); } if ($result) { $nameArray = $adb->fetch_array($result); } $assigned_user_id = empty($value) ? $current_user->id : $value; if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); } if ($noof_group_rows != 0) { if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); } } $fieldvalue[] = $users_combo; $fieldvalue[] = $groups_combo; } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { if (!isset($_REQUEST['convertmode']) || $_REQUEST['convertmode'] != 'update_quote_val' && $_REQUEST['convertmode'] != 'update_so_val') { if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $value = vtlib_purify($_REQUEST['account_id']); } } if ($value != '') { $account_name = getAccountName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $account_name; $fieldvalue[] = $value; } elseif ($uitype == 54) { $options = array(); $editview_label[] = getTranslatedString($fieldlabel, $module_name); $pick_query = "select * from vtiger_groups"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, "name"); if ($value == $pickListValue) { $chk_val = "selected"; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == 55 || $uitype == 255) { require_once 'modules/PickList/PickListUtils.php'; if ($uitype == 255) { $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'firstname', 'readwrite'); } if ($uitype == 255 && $fieldpermission == '0') { $fieldvalue[] = ''; } else { $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'salutationtype', 'readwrite'); if ($fieldpermission == '0') { $roleid = $current_user->roleid; $picklistValues = getAssignedPicklistValues('salutationtype', $roleid, $adb); $pickcount = 0; $salt_value = $col_fields["salutationtype"]; foreach ($picklistValues as $order => $pickListValue) { if ($salt_value == trim($pickListValue)) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && $salt_value != '') { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $salt_value, 'selected'); } $fieldvalue[] = $options; } else { $fieldvalue[] = ''; } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 59) { if ($_REQUEST['module'] == 'HelpDesk') { if (isset($_REQUEST['product_id']) & $_REQUEST['product_id'] != '') { $value = $_REQUEST['product_id']; } } elseif (isset($_REQUEST['parent_id']) & $_REQUEST['parent_id'] != '') { $value = vtlib_purify($_REQUEST['parent_id']); } if ($value != '') { $product_name = getProductName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $product_name; $fieldvalue[] = $value; } elseif ($uitype == 63) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); if ($value == '') { $value = 1; } $options = array(); $pick_query = "select * from vtiger_duration_minutes order by sortorderid"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); $salt_value = $col_fields["duration_minutes"]; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, "duration_minutes"); if ($salt_value == $pickListValue) { $chk_val = "selected"; } else { $chk_val = ''; } $options[$pickListValue] = $chk_val; } $fieldvalue[] = $value; $fieldvalue[] = $options; } elseif ($uitype == 64) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); $fieldvalue[] = $value; } elseif ($uitype == 156) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; $fieldvalue[] = $is_admin; } elseif ($uitype == 56) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 57) { if ($value != '') { $displayValueArray = getEntityName('Contacts', $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } } elseif (isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') { if ($_REQUEST['module'] == 'Contacts' && ($fieldname = 'contact_id')) { $contact_name = ''; } else { $value = $_REQUEST['contact_id']; $displayValueArray = getEntityName('Contacts', $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } } } //Checking for contacts duplicate $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $contact_name; $fieldvalue[] = $value; } elseif ($uitype == 58) { if ($value != '') { $campaign_name = getCampaignName($value); } elseif (isset($_REQUEST['campaignid']) && $_REQUEST['campaignid'] != '') { if ($_REQUEST['module'] == 'Campaigns' && ($fieldname = 'campaignid')) { $campaign_name = ''; } else { $value = $_REQUEST['campaignid']; $campaign_name = getCampaignName($value); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $campaign_name; $fieldvalue[] = $value; } elseif ($uitype == 61) { if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } if ($module_name == 'Emails' && $col_fields['record_id'] != '') { $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])); //to fix the issue in mail attachment on forwarding mails if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') { global $att_id_list; } for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) { $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid'); if ($attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); if ($attachmentsname != '') { $fieldvalue[$attachmentid] = '[ ' . $attachmentsname . ' ]'; } if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') { $att_id_list .= $attachmentid . ';'; } } } } else { if ($col_fields['record_id'] != '') { $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } } if ($value != '') { $filename = ' [ ' . $value . ' ]'; } if ($filename != '') { $fieldvalue[] = $filename; } if ($value != '') { $fieldvalue[] = $value; } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); } elseif ($uitype == 28) { if ($col_fields['record_id'] != '') { $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } } if ($value != '' && $module_name != 'Documents') { $filename = ' [ ' . $value . ' ]'; } elseif ($value != '' && $module_name == 'Documents') { $filename = $value; } if ($filename != '') { $fieldvalue[] = $filename; } if ($value != '') { $fieldvalue[] = $value; } $editview_label[] = getTranslatedString($fieldlabel, $module_name); } elseif ($uitype == 69) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); if ($col_fields['record_id'] != "") { if ($module_name == 'Products') { $query = 'select vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name ,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?'; $params = array($col_fields['record_id']); } else { if ($module_name == 'Contacts') { $imageattachment = 'Image'; } else { $imageattachment = 'Attachment'; } $query = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t\t from vtiger_attachments\n\t\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid\n\t\t\t\t where vtiger_crmentity.setype='{$module_name} {$imageattachment}'\n\t\t\t\t and vtiger_attachments.name = ?\n\t\t\t\t and vtiger_seattachmentsrel.crmid=?"; $params = array($col_fields[$fieldname], $col_fields['record_id']); } $result_image = $adb->pquery($query, $params); for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) { $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid'); //decode_html - added to handle UTF-8 characters in file names //urlencode - added to handle special characters like #, %, etc., $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name'))); $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name')); $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path'); } if (is_array($image_array)) { for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) { $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr] . $image_id_array[$img_itr] . "_", "orgname" => $image_orgname_array[$img_itr]); } } else { $fieldvalue[] = ''; } } else { $fieldvalue[] = ''; } } elseif ($uitype == 62) { if (isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') { $value = vtlib_purify($_REQUEST['parent_id']); } if ($value != '') { $parent_module = getSalesEntityType($value); } if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $parent_module = "Accounts"; $value = $_REQUEST['account_id']; } if ($parent_module != 'Contacts') { if ($parent_module == "Leads") { $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $parent_name = $field_value; } } $lead_selected = "selected"; } elseif ($parent_module == "Accounts") { $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "accountname"); $account_selected = "selected"; } elseif ($parent_module == "Potentials") { $sql = "select * from vtiger_potential where potentialid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "potentialname"); $potential_selected = "selected"; } elseif ($parent_module == "Products") { $sql = "select * from vtiger_products where productid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "productname"); $product_selected = "selected"; } elseif ($parent_module == "PurchaseOrder") { $sql = "select * from vtiger_purchaseorder where purchaseorderid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $porder_selected = "selected"; } elseif ($parent_module == "SalesOrder") { $sql = "select * from vtiger_salesorder where salesorderid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $sorder_selected = "selected"; } elseif ($parent_module == "Invoice") { $sql = "select * from vtiger_invoice where invoiceid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $invoice_selected = "selected"; } elseif ($parent_module == "Quotes") { $sql = "select * from vtiger_quotes where quoteid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $quote_selected = "selected"; } elseif ($parent_module == "HelpDesk") { $sql = "select * from vtiger_troubletickets where ticketid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "title"); $ticket_selected = "selected"; } } $editview_label[] = array($app_strings['COMBO_LEADS'], $app_strings['COMBO_ACCOUNTS'], $app_strings['COMBO_POTENTIALS'], $app_strings['COMBO_PRODUCTS'], $app_strings['COMBO_INVOICES'], $app_strings['COMBO_PORDER'], $app_strings['COMBO_SORDER'], $app_strings['COMBO_QUOTES'], $app_strings['COMBO_HELPDESK']); $editview_label[] = array($lead_selected, $account_selected, $potential_selected, $product_selected, $invoice_selected, $porder_selected, $sorder_selected, $quote_selected, $ticket_selected); $editview_label[] = array("Leads&action=Popup", "Accounts&action=Popup", "Potentials&action=Popup", "Products&action=Popup", "Invoice&action=Popup", "PurchaseOrder&action=Popup", "SalesOrder&action=Popup", "Quotes&action=Popup", "HelpDesk&action=Popup"); $fieldvalue[] = $parent_name; $fieldvalue[] = $value; } elseif ($uitype == 66) { if (!empty($_REQUEST['parent_id'])) { $value = vtlib_purify($_REQUEST['parent_id']); } if (!empty($value)) { $parent_module = getSalesEntityType($value); if ($parent_module != "Contacts") { $entity_names = getEntityName($parent_module, $value); $parent_name = $entity_names[$value]; $fieldvalue[] = $parent_name; $fieldvalue[] = $value; } } // Check for vtiger_activity type if task orders to be added in select option $act_mode = $_REQUEST['activity_mode']; $parentModulesList = array('Leads' => $app_strings['COMBO_LEADS'], 'Accounts' => $app_strings['COMBO_ACCOUNTS'], 'Potentials' => $app_strings['COMBO_POTENTIALS'], 'HelpDesk' => $app_strings['COMBO_HELPDESK'], 'Campaigns' => $app_strings['COMBO_CAMPAIGNS'], 'Vendors' => $app_strings['COMBO_VENDORS']); if ($act_mode == "Task") { $parentModulesList['Quotes'] = $app_strings['COMBO_QUOTES']; $parentModulesList['PurchaseOrder'] = $app_strings['COMBO_PORDER']; $parentModulesList['SalesOrder'] = $app_strings['COMBO_SORDER']; $parentModulesList['Invoice'] = $app_strings['COMBO_INVOICES']; } $parentModuleNames = array_keys($parentModulesList); $parentModuleLabels = array_values($parentModulesList); $editview_label[0] = $parentModuleLabels; $editview_label[1] = array_fill(0, count($parentModulesList), ''); $selectedModuleIndex = array_search($parent_module, $parentModuleNames); if ($selectedModuleIndex > -1) { $editview_label[1][$selectedModuleIndex] = 'selected'; } $parentModulePopupUrl = array(); foreach ($parentModuleNames as $parentModule) { $parentModulePopupUrl[] = $parentModule . '&action=Popup'; } $editview_label[2] = $parentModulePopupUrl; } elseif ($uitype == 357) { $pmodule = $_REQUEST['pmodule']; if (empty($pmodule)) { $pmodule = $_REQUEST['par_module']; } if ($pmodule == 'Contacts') { $contact_selected = 'selected'; } elseif ($pmodule == 'Accounts') { $account_selected = 'selected'; } elseif ($pmodule == 'Leads') { $lead_selected = 'selected'; } elseif ($pmodule == 'Vendors') { $vendor_selected = 'selected'; } elseif ($pmodule == 'Users') { $user_selected = 'selected'; } elseif ($pmodule == 'Project') { $project_selected = 'selected'; } elseif ($pmodule == 'ProjectTask') { $projecttask_selected = 'selected'; } elseif ($pmodule == 'Potentials') { $potentials_selected = 'selected'; } elseif ($pmodule == 'HelpDesk') { $helpdesk_selected = 'selected'; } if (isset($_REQUEST['emailids']) && $_REQUEST['emailids'] != '') { $parent_id = $_REQUEST['emailids']; $parent_name = ''; $myids = explode("|", $parent_id); for ($i = 0; $i < count($myids) - 1; $i++) { $realid = explode("@", $myids[$i]); $entityid = $realid[0]; $nemail = count($realid); if ($pmodule == 'Accounts') { require_once 'modules/Accounts/Accounts.php'; $myfocus = new Accounts(); $myfocus->retrieve_entity_info($entityid, "Accounts"); $fullname = br2nl($myfocus->column_fields['accountname']); $account_selected = 'selected'; } elseif ($pmodule == 'Contacts') { require_once 'modules/Contacts/Contacts.php'; $myfocus = new Contacts(); $myfocus->retrieve_entity_info($entityid, "Contacts"); $fname = br2nl($myfocus->column_fields['firstname']); $lname = br2nl($myfocus->column_fields['lastname']); $fullname = $lname . ' ' . $fname; $contact_selected = 'selected'; } elseif ($pmodule == 'Leads') { require_once 'modules/Leads/Leads.php'; $myfocus = new Leads(); $myfocus->retrieve_entity_info($entityid, "Leads"); $fname = br2nl($myfocus->column_fields['firstname']); $lname = br2nl($myfocus->column_fields['lastname']); $fullname = $lname . ' ' . $fname; $lead_selected = 'selected'; } elseif ($pmodule == 'Project') { require_once 'modules/Project/Project.php'; $myfocus = new Project(); $myfocus->retrieve_entity_info($entityid, "Project"); $fname = br2nl($myfocus->column_fields['projectname']); $lname = br2nl($myfocus->column_fields['projectid']); $fullname = $fname; $project_selected = 'selected'; } elseif ($pmodule == 'ProjectTask') { require_once 'modules/ProjectTask/ProjectTask.php'; $myfocus = new ProjectTask(); $myfocus->retrieve_entity_info($entityid, "ProjectTask"); $fname = br2nl($myfocus->column_fields['projecttaskname']); $lname = br2nl($myfocus->column_fields['projecttaskid']); $fullname = $fname; $projecttask_selected = 'selected'; } elseif ($pmodule == 'Potentials') { require_once 'modules/Potentials/Potentials.php'; $myfocus = new Potentials(); $myfocus->retrieve_entity_info($entityid, "Potentials"); $fname = br2nl($myfocus->column_fields['potentialname']); $lname = br2nl($myfocus->column_fields['potentialid']); $fullname = $fname; $potentials_selected = 'selected'; } elseif ($pmodule == 'HelpDesk') { require_once 'modules/HelpDesk/HelpDesk.php'; $myfocus = new HelpDesk(); $myfocus->retrieve_entity_info($entityid, "HelpDesk"); $fname = br2nl($myfocus->column_fields['title']); $lname = br2nl($myfocus->column_fields['ticketid']); $fullname = $fname; $helpdesk_selected = 'selected'; } for ($j = 1; $j < $nemail; $j++) { $querystr = 'select columnname from vtiger_field where fieldid=? and vtiger_field.presence in (0,2)'; $result = $adb->pquery($querystr, array($realid[$j])); $temp = $adb->query_result($result, 0, 'columnname'); $temp1 = br2nl($myfocus->column_fields[$temp]); //Modified to display the entities in red which don't have email id if (!empty($temp_parent_name) && strlen($temp_parent_name) > 150) { $parent_name .= '<br>'; $temp_parent_name = ''; } if ($temp1 != '') { $parent_name .= $fullname . '<' . $temp1 . '>; '; $temp_parent_name .= $fullname . '<' . $temp1 . '>; '; } else { $parent_name .= "<b style='color:red'>" . $fullname . '<' . $temp1 . '>; ' . "</b>"; $temp_parent_name .= "<b style='color:red'>" . $fullname . '<' . $temp1 . '>; ' . "</b>"; } } } } else { if ($_REQUEST['record'] != '' && $_REQUEST['record'] != NULL) { $parent_name = ''; $parent_id = ''; $myemailid = $_REQUEST['record']; $mysql = "select crmid from vtiger_seactivityrel where activityid=?"; $myresult = $adb->pquery($mysql, array($myemailid)); $mycount = $adb->num_rows($myresult); if ($mycount > 0) { for ($i = 0; $i < $mycount; $i++) { $mycrmid = $adb->query_result($myresult, $i, 'crmid'); $parent_module = getSalesEntityType($mycrmid); if ($parent_module == "Leads") { $sql = "select firstname,lastname,email from vtiger_leaddetails where leadid=?"; $result = $adb->pquery($sql, array($mycrmid)); $full_name = getFullNameFromQResult($result, 0, "Leads"); $myemail = $adb->query_result($result, 0, "email"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $full_name . '<' . $myemail . '>; '; $lead_selected = 'selected'; } elseif ($parent_module == "Contacts") { $sql = "select * from vtiger_contactdetails where contactid=?"; $result = $adb->pquery($sql, array($mycrmid)); $full_name = getFullNameFromQResult($result, 0, "Contacts"); $myemail = $adb->query_result($result, 0, "email"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $full_name . '<' . $myemail . '>; '; $contact_selected = 'selected'; } elseif ($parent_module == "Accounts") { $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($mycrmid)); $account_name = $adb->query_result($result, 0, "accountname"); $myemail = $adb->query_result($result, 0, "email1"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $account_name . '<' . $myemail . '>; '; $account_selected = 'selected'; } elseif ($parent_module == "Users") { $sql = "select user_name,email1 from vtiger_users where id=?"; $result = $adb->pquery($sql, array($mycrmid)); $account_name = $adb->query_result($result, 0, "user_name"); $myemail = $adb->query_result($result, 0, "email1"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $account_name . '<' . $myemail . '>; '; $user_selected = 'selected'; } elseif ($parent_module == "Vendors") { $sql = "select * from vtiger_vendor where vendorid=?"; $result = $adb->pquery($sql, array($mycrmid)); $vendor_name = $adb->query_result($result, 0, "vendorname"); $myemail = $adb->query_result($result, 0, "email"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $vendor_name . '<' . $myemail . '>; '; $vendor_selected = 'selected'; } } } } $custfld .= '<td width="20%" class="dataLabel">' . $app_strings['To'] . ' </td>'; $custfld .= '<td width="90%" colspan="3"><input name="parent_id" type="hidden" value="' . $parent_id . '"><textarea readonly name="parent_name" cols="70" rows="2">' . $parent_name . '</textarea> <select name="parent_type" >'; $custfld .= '<OPTION value="Contacts" selected>' . $app_strings['COMBO_CONTACTS'] . '</OPTION>'; $custfld .= '<OPTION value="Accounts" >' . $app_strings['COMBO_ACCOUNTS'] . '</OPTION>'; $custfld .= '<OPTION value="Leads" >' . $app_strings['COMBO_LEADS'] . '</OPTION>'; $custfld .= '<OPTION value="Vendors" >' . $app_strings['COMBO_VENDORS'] . '</OPTION></select><img src="' . vtiger_imageurl('select.gif', $theme) . '" alt="Select" title="Select" LANGUAGE=javascript onclick=\'$log->debug("Exiting getOutputHtml method ..."); return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&popuptype=set_$log->debug("Exiting getOutputHtml method ..."); return_emails&form=EmailEditView&form_submit=false","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");\' align="absmiddle" style=\'cursor:hand;cursor:pointer\'> <input type="image" src="' . vtiger_imageurl('clear_field.gif', $theme) . '" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=\'\';this.form.parent_name.value=\'\';$log->debug("Exiting getOutputHtml method ..."); return false;" align="absmiddle" style=\'cursor:hand;cursor:pointer\'></td>'; $editview_label[] = array('Contacts' => $contact_selected, 'Accounts' => $account_selected, 'Vendors' => $vendor_selected, 'Leads' => $lead_selected, 'Users' => $user_selected); $fieldvalue[] = $parent_name; $fieldvalue[] = $parent_id; } } elseif ($uitype == 68) { if (empty($value) && isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') { $value = vtlib_purify($_REQUEST['parent_id']); } if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Contacts") { $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $parent_name = $field_value; } } $contact_selected = "selected"; } elseif ($parent_module == "Accounts") { $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "accountname"); $account_selected = "selected"; } else { $parent_name = ""; $value = ""; } } $editview_label[0] = array(); $editview_label[1] = array(); $editview_label[2] = array(); if (vtlib_isModuleActive('Accounts')) { array_push($editview_label[0], $app_strings['COMBO_ACCOUNTS']); array_push($editview_label[1], $account_selected); array_push($editview_label[2], "Accounts"); } if (vtlib_isModuleActive('Contacts')) { array_push($editview_label[0], $app_strings['COMBO_CONTACTS']); array_push($editview_label[1], $contact_selected); array_push($editview_label[2], "Contacts"); } $fieldvalue[] = $parent_name; $fieldvalue[] = $value; } elseif ($uitype == 9 || $uitype == 7) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fldrs = $adb->pquery('select typeofdata from vtiger_field where vtiger_field.fieldname=? and vtiger_field.tabid=?', array($fieldname, getTabid($module_name))); $typeofdata = $adb->query_result($fldrs, 0, 0); $typeinfo = explode('~', $typeofdata); if ($typeinfo[0] == 'I') { $fieldvalue[] = $value; } else { $currencyField = new CurrencyField($value); $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata); $currencyField->initialize($current_user); $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces())); $fieldvalue[] = $currencyField->getDisplayValue(null, false, true); } } elseif ($uitype == 71 || $uitype == 72) { $currencyField = new CurrencyField($value); // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($col_fields['record_id'] != '' && $uitype == 72) { if ($fieldname == 'unit_price') { $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module_name)); $currencySymbol = $rate_symbol['symbol']; } else { $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']); $currencySymbol = $currency_info['currency_symbol']; } $fieldvalue[] = $currencyField->getDisplayValue(null, true); } else { $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata); $currencyField->initialize($current_user); $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces())); $fieldvalue[] = $currencyField->getDisplayValue(null, false, true); $currencySymbol = $currencyField->getCurrencySymbol(); } $editview_label[] = getTranslatedString($fieldlabel, $module_name) . ': (' . $currencySymbol . ')'; } elseif ($uitype == 75 || $uitype == 81) { if ($value != '') { $vendor_name = getVendorName($value); } elseif (isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id'] != '') { $value = $_REQUEST['vendor_id']; $vendor_name = getVendorName($value); } $pop_type = 'specific'; if ($uitype == 81) { $pop_type = 'specific_vendor_address'; } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $vendor_name; $fieldvalue[] = $value; } elseif ($uitype == 76) { if ($value != '') { $potential_name = getPotentialName($value); } elseif (isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') { $value = $_REQUEST['potental_id']; $potential_name = getPotentialName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $potential_name; $fieldvalue[] = $value; } elseif ($uitype == 78) { if ($value != '') { $quote_name = getQuoteName($value); } elseif (isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '') { $value = $_REQUEST['quote_id']; $potential_name = getQuoteName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $quote_name; $fieldvalue[] = $value; } elseif ($uitype == 79) { if ($value != '') { $purchaseorder_name = getPoName($value); } elseif (isset($_REQUEST['purchaseorder_id']) && $_REQUEST['purchaseorder_id'] != '') { $value = $_REQUEST['purchaseorder_id']; $purchaseorder_name = getPoName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $purchaseorder_name; $fieldvalue[] = $value; } elseif ($uitype == 80) { if ($value != '') { $salesorder_name = getSoName($value); } elseif (isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') { $value = $_REQUEST['salesorder_id']; $salesorder_name = getSoName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $salesorder_name; $fieldvalue[] = $value; } elseif ($uitype == 30) { $rem_days = 0; $rem_hrs = 0; $rem_min = 0; if ($value != '') { $SET_REM = 'CHECKED'; } else { $SET_REM = ''; } $rem_days = floor($col_fields[$fieldname] / (24 * 60)); $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60); $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60; $editview_label[] = getTranslatedString($fieldlabel, $module_name); $day_options = getReminderSelectOption(0, 31, 'remdays', $rem_days); $hr_options = getReminderSelectOption(0, 23, 'remhrs', $rem_hrs); $min_options = getReminderSelectOption(10, 59, 'remmin', $rem_min); $fieldvalue[] = array(array(0, 32, 'remdays', getTranslatedString('LBL_DAYS', 'Calendar'), $rem_days), array(0, 24, 'remhrs', getTranslatedString('LBL_HOURS', 'Calendar'), $rem_hrs), array(10, 60, 'remmin', getTranslatedString('LBL_MINUTES', 'Calendar') . ' ' . getTranslatedString('LBL_BEFORE_EVENT', 'Calendar'), $rem_min)); $fieldvalue[] = array($SET_REM, getTranslatedString('LBL_YES'), getTranslatedString('LBL_NO')); $SET_REM = ''; } elseif ($uitype == 115) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname); $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname)); if ($value == $pickListValue) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } $fieldvalue[] = $options; $fieldvalue[] = $is_admin; } elseif ($uitype == 116 || $uitype == 117) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name'); $currency_id = $adb->query_result($pickListResult, $j, 'id'); if ($value == $currency_id) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[$currency_id] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; $fieldvalue[] = $is_admin; } elseif ($uitype == 98) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; $fieldvalue[] = getRoleName($value); $fieldvalue[] = $is_admin; } elseif ($uitype == 105) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); if (isset($col_fields['record_id']) && $col_fields['record_id'] != '') { $query = "select vtiger_attachments.path, vtiger_attachments.name from vtiger_contactdetails left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_contactdetails.contactid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where vtiger_contactdetails.imagename=vtiger_attachments.name and contactid=?"; $result_image = $adb->pquery($query, array($col_fields['record_id'])); for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) { $image_array[] = $adb->query_result($result_image, $image_iter, 'name'); $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path'); } } if (is_array($image_array)) { for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) { $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr]); } } else { $fieldvalue[] = ''; } } elseif ($uitype == 101) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = getOwnerName($value); $fieldvalue[] = $value; } elseif ($uitype == 26) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $folderid = $col_fields['folderid']; $foldername_query = 'select foldername from vtiger_attachmentsfolder where folderid = ?'; $res = $adb->pquery($foldername_query, array($folderid)); $foldername = $adb->query_result($res, 0, 'foldername'); if ($foldername != '' && $folderid != '') { $fldr_name[$folderid] = $foldername; } $sql = "select foldername,folderid from vtiger_attachmentsfolder order by foldername"; $res = $adb->pquery($sql, array()); for ($i = 0; $i < $adb->num_rows($res); $i++) { $fid = $adb->query_result($res, $i, "folderid"); $fldr_name[$fid] = $adb->query_result($res, $i, "foldername"); } $fieldvalue[] = $fldr_name; } elseif ($uitype == 27) { if ($value == 'E') { $external_selected = "selected"; $filename = $col_fields['filename']; } else { $internal_selected = "selected"; $filename = $col_fields['filename']; } $editview_label[] = array(getTranslatedString('Internal'), getTranslatedString('External')); $editview_label[] = array($internal_selected, $external_selected); $editview_label[] = array("I", "E"); $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; $fieldvalue[] = $filename; } elseif ($uitype == '31') { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $options = array(); $themeList = get_themes(); foreach ($themeList as $theme) { if ($value == $theme) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($theme), $theme, $selected); } $fieldvalue[] = $options; } elseif ($uitype == '32') { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $options = array(); $languageList = Vtiger_Language::getAll(); foreach ($languageList as $prefix => $label) { if ($value == $prefix) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($label), $prefix, $selected); } $fieldvalue[] = $options; } else { //Added condition to set the subject if click Reply All from web mail if ($_REQUEST['module'] == 'Emails' && $_REQUEST['mg_subject'] != '') { $value = $_REQUEST['mg_subject']; } $editview_label[] = getTranslatedString($fieldlabel, $module_name); if ($fieldname == 'fileversion') { if (empty($value)) { $value = ''; } else { $fieldvalue[] = $value; } } else { $fieldvalue[] = $value; } } } // Mike Crowe Mod --------------------------------------------------------force numerics right justified. if (!preg_match("/id=/i", $custfld)) { $custfld = preg_replace("/<input/iS", "<input id='{$fieldname}' ", $custfld); } if (in_array($uitype, array(71, 72, 7, 9, 90))) { $custfld = preg_replace("/<input/iS", "<input align=right ", $custfld); } $final_arr[] = $ui_type; $final_arr[] = $editview_label; $final_arr[] = $editview_fldname; $final_arr[] = $fieldvalue; $type_of_data = explode('~', $typeofdata); $final_arr[] = $type_of_data[1]; $log->debug('Exiting getOutputHtml method ...'); return $final_arr; }
/** * Function to get customfield entries * @param string $module - Module name * return array $cflist - customfield entries */ function getFieldListEntries($module) { $tabid = getTabid($module); global $adb, $smarty, $log, $current_user; global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = "themes/images/"; $dbQuery = "select vtiger_blocks.*,vtiger_tab.presence as tabpresence from vtiger_blocks" . " inner join vtiger_tab on vtiger_tab.tabid = vtiger_blocks.tabid" . " where vtiger_blocks.tabid=? and vtiger_tab.presence = 0 order by sequence"; $result = $adb->pquery($dbQuery, array($tabid)); $row = $adb->fetch_array($result); $focus = CRMEntity::getInstance($module); $nonEditableUiTypes = array('4', '70'); // To get reference field names require_once 'include/Webservices/Utils.php'; $handler = vtws_getModuleHandlerFromName($module, $current_user); $meta = $handler->getMeta(); $referenceFieldNames = array_keys($meta->getReferenceFieldDetails()); $cflist = array(); $i = 0; if ($row != '') { do { if ($row["blocklabel"] == 'LBL_CUSTOM_INFORMATION') { $smarty->assign("CUSTOMSECTIONID", $row["blockid"]); } if ($row["blocklabel"] == 'LBL_RELATED_PRODUCTS') { $smarty->assign("RELPRODUCTSECTIONID", $row["blockid"]); } if ($row["blocklabel"] == 'LBL_COMMENTS' || $row['blocklabel'] == 'LBL_COMMENT_INFORMATION') { $smarty->assign("COMMENTSECTIONID", $row["blockid"]); } if ($row['blocklabel'] == 'LBL_TICKET_RESOLUTION') { $smarty->assign("SOLUTIONBLOCKID", $row["blockid"]); } if ($row['blocklabel'] == '') { continue; } $cflist[$i]['tabpresence'] = $row['tabpresence']; $cflist[$i]['module'] = $module; $cflist[$i]['blocklabel'] = getTranslatedString($row["blocklabel"], $module); $cflist[$i]['blockid'] = $row["blockid"]; $cflist[$i]['display_status'] = $row["display_status"]; $cflist[$i]['tabid'] = $tabid; $cflist[$i]['blockselect'] = $row["blockid"]; $cflist[$i]['sequence'] = $row["sequence"]; $cflist[$i]['iscustom'] = $row["iscustom"]; if ($module != 'Invoices' && $module != 'Quotes' && $module != 'SalesOrder' && $module != 'Invoice') { $sql_field = "select * from vtiger_field where block=? and vtiger_field.displaytype IN (1,2,4) order by sequence"; $sql_field_params = array($row["blockid"]); } else { $sql_field = "select * from vtiger_field where block=? and (vtiger_field.fieldlabel!='Total' and vtiger_field.fieldlabel!='Sub Total' and vtiger_field.fieldlabel!='Tax') and vtiger_field.displaytype IN (1,2,4) order by sequence"; $sql_field_params = array($row["blockid"]); } $result_field = $adb->pquery($sql_field, $sql_field_params); $row_field = $adb->fetch_array($result_field); if ($row_field != '') { $cf_element = array(); $cf_hidden_element = array(); $count = 0; $hiddencount = 0; do { $fieldid = $row_field['fieldid']; $presence = $row_field['presence']; $fieldname = $row_field['fieldname']; $customfieldflag = InStrCount($row_field['fieldname'], 'cf_', true); $quickcreate = $row_field['quickcreate']; $massedit = $row_field['masseditable']; $typeofdata = $row_field['typeofdata']; $displaytype = $row_field['displaytype']; $uitype = $row_field['uitype']; $fld_type_name = getCustomFieldTypeName($row_field['uitype']); $defaultValue = $row_field['defaultvalue']; if (!empty($defaultValue) && ($uitype == '5' || $uitype == '6' || $uitype == '23')) { $defaultValue = getValidDisplayDate($defaultValue); } $fieldlabel = getTranslatedString($row_field['fieldlabel'], $module); $defaultPermitted = true; $strictlyMandatory = false; if (isset($focus->mandatory_fields) && !empty($focus->mandatory_fields) && in_array($fieldname, $focus->mandatory_fields)) { $strictlyMandatory = true; $defaultPermitted = false; } elseif (in_array($uitype, $nonEditableUiTypes) || $displaytype == 2) { $strictlyMandatory = true; $defaultPermitted = false; } if (in_array($fieldname, $referenceFieldNames)) { $defaultPermitted = false; } $visibility = getFieldInfo($fieldname, $typeofdata, $quickcreate, $massedit, $presence, $strictlyMandatory, $customfieldflag, $displaytype, $uitype); $allValues = array(); if (in_array($uitype, array('15', '16', '33'))) { $allValues = getAllPickListValues($fieldname); } if ($presence == 0 || $presence == 2) { $cf_element[$count]['fieldselect'] = $fieldid; $cf_element[$count]['blockid'] = $row['blockid']; $cf_element[$count]['tabid'] = $tabid; $cf_element[$count]['no'] = $count; $cf_element[$count]['label'] = $fieldlabel; $cf_element[$count]['fieldlabel'] = $row_field['fieldlabel']; $cf_element[$count]['type'] = $fld_type_name; $cf_element[$count]['typeofdata'] = $typeofdata; $cf_element[$count]['uitype'] = $uitype; $cf_element[$count]['columnname'] = $row_field['columnname']; $cf_element[$count]['defaultvalue'] = array('permitted' => $defaultPermitted, 'value' => $defaultValue, '_allvalues' => $allValues); $cf_element[$count] = array_merge($cf_element[$count], $visibility); $count++; } else { $cf_hidden_element[$hiddencount]['fieldselect'] = $fieldid; $cf_hidden_element[$hiddencount]['blockid'] = $row['blockid']; $cf_hidden_element[$hiddencount]['tabid'] = $tabid; $cf_hidden_element[$hiddencount]['no'] = $hiddencount; $cf_hidden_element[$hiddencount]['label'] = $fieldlabel; $cf_hidden_element[$hiddencount]['fieldlabel'] = $row_field['fieldlabel']; $cf_hidden_element[$hiddencount]['type'] = $fld_type_name; $cf_hidden_element[$hiddencount]['typeofdata'] = $typeofdata; $cf_hidden_element[$hiddencount]['uitype'] = $uitype; $cf_hidden_element[$hiddencount]['columnname'] = $row_field['columnname']; $cf_hidden_element[$hiddencount]['defaultvalue'] = array('permitted' => $defaultPermitted, 'value' => $defaultValue, '_allvalues' => $allValues); $cf_hidden_element[$hiddencount] = array_merge($cf_hidden_element[$hiddencount], $visibility); $hiddencount++; } } while ($row_field = $adb->fetch_array($result_field)); $cflist[$i]['no'] = $count; $cflist[$i]['hidden_count'] = $hiddencount; } else { $cflist[$i]['no'] = 0; } $query_fields_not_in_block = 'select fieldid,fieldlabel,block from vtiger_field ' . 'inner join vtiger_blocks on vtiger_field.block=vtiger_blocks.blockid ' . 'where vtiger_field.block != ? and vtiger_blocks.blocklabel not in ("LBL_TICKET_RESOLUTION","LBL_COMMENTS","LBL_COMMENT_INFORMATION") ' . 'AND vtiger_field.tabid = ? and vtiger_field.displaytype IN (1,2,4) order by vtiger_field.sequence'; $params = array($row['blockid'], $tabid); $fields = $adb->pquery($query_fields_not_in_block, $params); $row_field = $adb->fetch_array($fields); if ($row_field != '') { $movefields = array(); $movefieldcount = 0; do { $movefields[$movefieldcount]['fieldid'] = $row_field['fieldid']; $movefields[$movefieldcount]['fieldlabel'] = getTranslatedString($row_field['fieldlabel'], $module); $movefieldcount++; } while ($row_field = $adb->fetch_array($fields)); $cflist[$i]['movefieldcount'] = $movefieldcount; } else { $cflist[$i]['movefieldcount'] = 0; } $cflist[$i]['field'] = $cf_element; $cflist[$i]['hiddenfield'] = $cf_hidden_element; $cflist[$i]['movefield'] = $movefields; $cflist[$i]['hascustomtable'] = $focus->customFieldTable; unset($cf_element); unset($cf_hidden_element); unset($movefields); $i++; } while ($row = $adb->fetch_array($result)); } return $cflist; }
function getAdvancedFilterList($relblockid) { $adb = PearDatabase::getInstance(); global $modules; // $adb->setDebug(true); $advft_criteria = array(); $sql = 'SELECT * FROM vtiger_pdfmaker_relblockcriteria_g WHERE relblockid = ? ORDER BY relblockid'; $groupsresult = $adb->pquery($sql, array($relblockid)); $i = 1; $j = 0; while ($relcriteriagroup = $adb->fetch_array($groupsresult)) { $groupId = $relcriteriagroup["groupid"]; $groupCondition = $relcriteriagroup["group_condition"]; // $ssql = 'select vtiger_pdfmaker_relblockcriteria.* from vtiger_pdfmaker_relblocks // inner join vtiger_pdfmaker_relblockcriteria on vtiger_pdfmaker_relblockcriteria.relblockid = vtiger_pdfmaker_relblocks.relblockid // left join vtiger_pdfmaker_relblockcriteria_g on vtiger_pdfmaker_relblockcriteria.relblockid = vtiger_pdfmaker_relblockcriteria_g.relblockid // and vtiger_pdfmaker_relblockcriteria.relblockid = vtiger_pdfmaker_relblockcriteria_g.relblockid'; // $ssql .= " where vtiger_pdfmaker_relblocks.relblockid = ? AND vtiger_pdfmaker_relblockcriteria.groupid = ? order by vtiger_pdfmaker_relblockcriteria.colid"; $ssql = "SELECT rbc.* FROM vtiger_pdfmaker_relblockcriteria AS rbc\n LEFT JOIN vtiger_pdfmaker_relblockcriteria_g AS rbcg\n USING(groupid)\n WHERE rbc.relblockid = ?\n AND rbc.groupid = ?\n AND rbcg.relblockid = ?\n ORDER BY rbc.colid"; $result = $adb->pquery($ssql, array($relblockid, $groupId, $relblockid)); //echo $ssql." = ".$relblockid." - ".$groupId; $noOfColumns = $adb->num_rows($result); if ($noOfColumns <= 0) { continue; } while ($relcriteriarow = $adb->fetch_array($result)) { $columnIndex = $relcriteriarow["colid"]; $criteria = array(); $criteria['columnname'] = html_entity_decode($relcriteriarow["columnname"]); $criteria['comparator'] = $relcriteriarow["comparator"]; $advfilterval = $relcriteriarow["value"]; $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++) { list($temp_date, $temp_time) = explode(" ", $temp_val[$x]); $temp_date = getValidDisplayDate(trim($temp_date)); if (trim($temp_time) != '') { $temp_date .= ' ' . $temp_time; } $val[$x] = $temp_date; } $advfilterval = implode(",", $val); } $criteria['value'] = decode_html($advfilterval); $criteria['column_condition'] = $relcriteriarow["column_condition"]; $advft_criteria[$i]['columns'][$j] = $criteria; $advft_criteria[$i]['condition'] = $groupCondition; $j++; } $i++; } // show($advft_criteria); return $advft_criteria; }