pquery($sql, array($reportid)); $Report_ID = $adb->query_result($res,0,'reportid'); $numOfRows = $adb->num_rows($res); if($numOfRows > 0) { $startdate = getDBInsertDateValue($_REQUEST["startdate"]);//Convert the user date format to DB date format $enddate = getDBInsertDateValue($_REQUEST["enddate"]);//Convert the user date format to DB date format global $primarymodule,$secondarymodule,$orderbylistsql,$orderbylistcolumns,$ogReport; //added to fix the ticket #5117 global $current_user; require('user_privileges/user_privileges_'.$current_user->id.'.php'); $ogReport = new Reports($reportid); $primarymodule = $ogReport->primodule; $restrictedmodules = array(); if($ogReport->secmodule!='') $rep_modules = split(":",$ogReport->secmodule); else $rep_modules = array(); array_push($rep_modules,$primarymodule); $modules_permitted = true; $modules_export_permitted = true; foreach($rep_modules as $mod){ if(isPermitted($mod,'index')!= "yes" || vtlib_isModuleActive($mod)==false){ $modules_permitted = false; $restrictedmodules[] = $mod; } if(isPermitted("$mod",'Export','')!='yes') $modules_export_permitted = false; } if(isPermitted($primarymodule,'index') == "yes" && $modules_permitted == true) { $oReportRun = new ReportRun($reportid); $filterlist = $oReportRun->RunTimeFilter($filtercolumn,$filter,$startdate,$enddate); // Performance Optimization: Direct output of the report result $list_report_form = new vtigerCRM_Smarty; //$sshtml = $oReportRun->GenerateReport("HTML",$filterlist); //if(is_array($sshtml))$totalhtml = $oReportRun->GenerateReport("TOTALHTML",$filterlist); $sshtml = array(); $totalhtml = ''; $list_report_form->assign("DIRECT_OUTPUT", true); $list_report_form->assign_by_ref("__REPORT_RUN_INSTANCE", $oReportRun); $list_report_form->assign_by_ref("__REPORT_RUN_FILTER_LIST", $filterlist); // END $ogReport->getSelectedStandardCriteria($reportid); //commented to omit dashboards for vtiger_reports //require_once('modules/Dashboard/ReportsCharts.php'); //$image = get_graph_by_type('Report','Report',$primarymodule,'',$sshtml[2]); //$list_report_form->assign("GRAPH", $image); $BLOCK1 = getPrimaryStdFilterHTML($ogReport->primodule,$ogReport->stdselectedcolumn); $BLOCK1 .= getSecondaryStdFilterHTML($ogReport->secmodule,$ogReport->stdselectedcolumn); // Check if selectedcolumn is found in the filters (Fix for ticket #4866) $selectedcolumnvalue = '"'. decode_html($ogReport->stdselectedcolumn) . '"'; if (!$is_admin && isset($ogReport->stdselectedcolumn) && strpos($BLOCK1, $selectedcolumnvalue) === false) { $BLOCK1 .= ""; } $list_report_form->assign("BLOCK1",$BLOCK1); $BLOCKJS = $ogReport->getCriteriaJS(); $list_report_form->assign("BLOCKJS",$BLOCKJS); $BLOCKCRITERIA = $ogReport->getSelectedStdFilterCriteria($ogReport->stdselectedfilter); $list_report_form->assign("BLOCKCRITERIA",$BLOCKCRITERIA); if(isset($ogReport->startdate) && isset($ogReport->enddate)) { $list_report_form->assign("STARTDATE",getDisplayDate($ogReport->startdate)); $list_report_form->assign("ENDDATE",getDisplayDate($ogReport->enddate)); }else { $list_report_form->assign("STARTDATE",$ogReport->startdate); $list_report_form->assign("ENDDATE",$ogReport->enddate); } $list_report_form->assign("MOD", $mod_strings); $list_report_form->assign("APP", $app_strings); $list_report_form->assign("IMAGE_PATH", $image_path); $list_report_form->assign("REPORTID", $reportid); $list_report_form->assign("IS_EDITABLE", $ogReport->is_editable); $list_report_form->assign("REPORTNAME", htmlspecialchars($ogReport->reportname,ENT_QUOTES,$default_charset)); if(is_array($sshtml))$list_report_form->assign("REPORTHTML", $sshtml); else $list_report_form->assign("ERROR_MSG", getTranslatedString('LBL_REPORT_GENERATION_FAILED', $currentModule) . "
" . $sshtml); $list_report_form->assign("REPORTTOTHTML", $totalhtml); $list_report_form->assign("FOLDERID", $folderid); $list_report_form->assign("DATEFORMAT",$current_user->date_format); $list_report_form->assign("JS_DATEFORMAT",parse_calendardate($app_strings['NTC_DATE_FORMAT'])); if($modules_export_permitted==true){ $list_report_form->assign("EXPORT_PERMITTED","YES"); } else { $list_report_form->assign("EXPORT_PERMITTED","NO"); } $rep_in_fldr = $ogReport->sgetRptsforFldr($folderid); for($i=0;$iassign("REPINFOLDER", $reports_array); include('themes/'.$theme.'/header.php'); $list_report_form->display('ReportRun.tpl'); } else { $list_report_form->display('ReportRunContents.tpl'); } } else { if($_REQUEST['mode'] != 'ajax') { include('themes/'.$theme.'/header.php'); } echo "
"; echo "
".$mod_strings['LBL_NO_ACCESS']." : ".implode(",",$restrictedmodules)."
$app_strings[LBL_GO_BACK]
"; echo "
"; } } else { echo ""; echo "
"; echo "
".$mod_strings['LBL_REPORT_DELETED']."
$app_strings[LBL_GO_BACK]
"; echo "
"; } /** Function to get the StdfilterHTML strings for the given primary module * @ param $module : Type String * @ param $selected : Type String(optional) * This Generates the HTML Combo strings for the standard filter for the given reports module * This Returns a HTML sring */ function getPrimaryStdFilterHTML($module,$selected="") { global $app_list_strings; global $ogReport; global $current_language; $ogReport->oCustomView=new CustomView(); $result = $ogReport->oCustomView->getStdCriteriaByModule($module); $mod_strings = return_module_language($current_language,$module); if(isset($result)) { foreach($result as $key=>$value) { if(isset($mod_strings[$value])) { if($key == $selected) { $shtml .= ""; }else { $shtml .= ""; } }else { if($key == $selected) { $shtml .= ""; }else { $shtml .= ""; } } } } return $shtml; } /** Function to get the StdfilterHTML strings for the given secondary module * @ param $module : Type String * @ param $selected : Type String(optional) * This Generates the HTML Combo strings for the standard filter for the given reports module * This Returns a HTML sring */ function getSecondaryStdFilterHTML($module,$selected="") { global $app_list_strings; global $ogReport; global $current_language; $ogReport->oCustomView=new CustomView(); if($module != "") { $secmodule = explode(":",$module); for($i=0;$i < count($secmodule) ;$i++) { $result = $ogReport->oCustomView->getStdCriteriaByModule($secmodule[$i]); $mod_strings = return_module_language($current_language,$secmodule[$i]); if(isset($result)) { foreach($result as $key=>$value) { if(isset($mod_strings[$value])) { if($key == $selected) { $shtml .= ""; }else { $shtml .= ""; } }else { if($key == $selected) { $shtml .= ""; }else { $shtml .= ""; } } } } } } return $shtml; } /** Function to get the reports under a report folder * @ param $folderid : Type Integer * This Returns $reports_array in the following format * $reports_array = array ($reportid=>$reportname,$reportid=>$reportname1,.............,$reportidn=>$reportname) */ function getReportsinFolder($folderid) { global $adb; $query = 'select reportid,reportname from vtiger_report where folderid=?'; $result = $adb->pquery($query, array($folderid)); $reports_array = Array(); for($i=0;$i < $adb->num_rows($result);$i++) { $reportid = $adb->query_result($result,$i,'reportid'); $reportname = $adb->query_result($result,$i,'reportname'); $reports_array[$reportid] = $reportname; } if(count($reports_array) > 0) return $reports_array; else return false; } ?>