Browse Source

enabling sub reporting

Arnaud Ligot 13 years ago
parent
commit
e034934045
2 changed files with 57 additions and 5 deletions
  1. 28 3
      main/reports/index.php
  2. 29 2
      main/reports/reports.php

+ 28 - 3
main/reports/index.php

@@ -102,9 +102,18 @@ $htmlHeadXtra[] = '    <style type="text/css">
 				overflow : auto;
 				display: none;
 			}
-			#result {
+			.result {
 				padding-top: 15px;
 			}
+			#result2 {
+				margin: 50px;
+			}
+			#result3 {
+				margin: 100px;
+			}
+			#result4 {
+				margin: 150px;
+			}
 			select.link, select.link:hover {
 				color: black;
 			}
@@ -164,7 +173,13 @@ foreach($reports_template as $key => $value)
 		</div>
 
 
-		<div id="result">
+		<div id="result" class="result">
+		</div>
+		<div id="result2" class="result">
+		</div>
+		<div id="result3" class="result">
+		</div>
+		<div id="result4" class="result">
 		</div>
     <script type="text/javascript">
 			$(function(){
@@ -181,7 +196,8 @@ foreach($reports_template as $key => $value)
 						success: function(data){
 		                                        $("#wizardContent").hide();
                 		                        $("#wizardShowButton").show();
-							$("#result").html(data); 
+							$(".result").html('');
+							$("#result").html(data);
 						},
 						beforeSubmit: function(data){$("#data").html("data sent to the server: " + $.param(data));},
 						resetForm: false
@@ -189,6 +205,15 @@ foreach($reports_template as $key => $value)
 				 }
 				);
   		});
+		function setSubDataUri(elem, uri) {
+			$.ajax({
+				url: uri,
+				success: function(data) {
+					elem.closest('.result').nextAll().html('');
+					elem.closest('.result').next().html(data);
+				}
+			});
+		}
     </script>
 
 <?

+ 29 - 2
main/reports/reports.php

@@ -31,6 +31,9 @@ $tool_name=get_lang('Reports');
 // loading templates
 reports_loadTemplates();
 
+// random suffix for div id (to enable multiple report per page)
+$idsuffix = rand();
+
 // "Link" type
 if ($_REQUEST['format'] == 'link') {
 	// converting post vars to get uri
@@ -48,7 +51,22 @@ if ($_REQUEST['format'] == 'directlink') {
 		$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$js.'" type="text/javascript" language="javascript"></script>'."\n";
 
 	$htmlCSSXtra[] = 'dataTable.css';
+
+?>
+    <script type="text/javascript">
+		function setSubDataUri(elem, uri) {
+			$.ajax({
+				url: uri,
+				success: function(data) {
+					elem.closest('.result').nextAll().html('');
+					elem.closest('.result').next().html(data);
+				}
+			});
+		}
+    </script>
+<?php
 	Display::display_header($tool_name);
+	echo '<div id="result" class="result">';
 }
 
 // outputing a link to csv file instead of outputing csv data directly
@@ -100,7 +118,7 @@ if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') {
 	echo '<script type="text/javascript" charset="utf-8">
 			$(document).ready(function() {
 
-				$("#reportsData").dataTable({
+				$("#reportsData'.$idsuffix.'").dataTable({
 					"oLanguage":
 						{
 							"sProcessing":   "Traitement en cours...",
@@ -122,7 +140,7 @@ if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') {
 				});
 			} );
 		</script>';
-	echo '<table id="reportsData" class="display">'; // FIXME style
+	echo '<table id="reportsData'.$idsuffix.'" class="display">'; // FIXME style
 
 	// counting fields
 	$nfields = multiquery_num_fields($result);
@@ -160,7 +178,16 @@ if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') {
 	}
 	echo '</tbody></table>';
 	if ($_REQUEST['format'] == 'directlink') {
+		echo '</div>
+		<div id="result2" class="result" style="margin: 50px;">
+		</div>
+		<div id="result3" class="result" style="margin: 100px;">
+		</div>
+		<div id="result4" class="result" style="margin: 150px;">
+		</div>';
+
 		Display::display_footer();
+		
 	}
 } else if ($_REQUEST['format'] == 'csv') {
 	$nfields = multiquery_num_fields($result);