index.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Reports
  5. * @author Arnaud Ligot <arnaud@cblue.be>
  6. * @copyrights CBLUE SPRL 2011
  7. * @package chamilo.reports
  8. */
  9. //exit;
  10. $cidReset = true;
  11. // including files
  12. require_once __DIR__.'/../inc/global.inc.php';
  13. require_once 'reports.lib.php';
  14. // protect script
  15. api_block_anonymous_users();
  16. // defining constants
  17. // current section
  18. $this_section = SECTION_REPORTS;
  19. // setting the name of the tool
  20. $tool_name = get_lang('Reports');
  21. // Displaying the header
  22. foreach (array('jquery.ba-bbq.min.js', 'jquery.validate.js', 'jquery.form.js', 'jquery.form.wizard.js', 'jquery.dataTables.min.js') as $js) {
  23. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$js.'" type="text/javascript" language="javascript"></script>'."\n";
  24. }
  25. // FIXME
  26. $htmlHeadXtra[] = ' <style type="text/css">
  27. #reportsBuilderWizard {
  28. padding : 1em;
  29. width : 500px;
  30. border-style: solid;
  31. border-color: #0daee4;
  32. }
  33. #fieldWrapper {
  34. }
  35. #wizardNavigation {
  36. margin-top : 0.5em;
  37. margin-right : 1em;
  38. text-align: right;
  39. }
  40. #data {
  41. font-size : 0.7em;
  42. }
  43. input {
  44. margin-right: 0.1em;
  45. margin-bottom: 0.5em;
  46. }
  47. .input_field_25em {
  48. width: 2.5em;
  49. }
  50. .input_field_3em {
  51. width: 3em;
  52. }
  53. .input_field_35em {
  54. width: 3.5em;
  55. }
  56. .input_field_12em {
  57. width: 12em;
  58. }
  59. label {
  60. margin-bottom: 0.2em;
  61. font-weight: bold;
  62. font-size: 0.8em;
  63. }
  64. label.error {
  65. color: red;
  66. font-size: 0.8em;
  67. margin-left : 0.5em;
  68. }
  69. .step span {
  70. float: right;
  71. font-weight: bold;
  72. padding-right: 0.8em;
  73. }
  74. .navigation_button {
  75. width : 70px;
  76. }
  77. #data {
  78. overflow : auto;
  79. display: none;
  80. }
  81. .result {
  82. padding-top: 15px;
  83. }
  84. #result2 {
  85. margin: 50px;
  86. }
  87. #result3 {
  88. margin: 100px;
  89. }
  90. #result4 {
  91. margin: 150px;
  92. }
  93. select.link, select.link:hover {
  94. color: black;
  95. }
  96. </style>';
  97. $htmlCSSXtra[] = 'dataTable.css';
  98. reports_loadTemplates();
  99. Display::display_header($tool_name);
  100. ?>
  101. <div id="reportsBuilderWizard">
  102. <h3><?php get_lang('Reports'); ?></h3>
  103. <div id='wizardContent'>
  104. <p><?php echo get_lang('PleaseFillFormToBuildReport'); ?></p>
  105. <h5 id="status"></h5>
  106. <form id="reportsBuilderWizardForm" method="post" action="reports.php" class="bbq">
  107. <div id="fieldWrapper">
  108. <span class="step" id="first">
  109. <span class="font_normal_07em_black"><?php echo get_lang('PleaseChooseReportType'); ?></span><br />
  110. <label for="type"><?php echo get_lang('ReportType'); ?></label><br />
  111. <select class="input_field_12em link required" name="type" id="type">
  112. <?php
  113. foreach ($reports_template as $key => $value) {
  114. echo '<option value="'.$key.'">'.$value['description'].'</option>';
  115. }
  116. ?>
  117. </select><br />
  118. </span>
  119. <?php
  120. foreach ($reports_template as $key => $value) {
  121. echo $value['wizard'];
  122. }
  123. ?>
  124. <span id="format" class="step submit_step">
  125. <span class="font_normal_07em_black"><?php echo get_lang('ReportFormat'); ?></span><br />
  126. <select name="format" id="format">
  127. <option value="html">HTML</option>
  128. <option value="csv">CSV</option>
  129. <option value="sql">SQL</option>
  130. <option value="link"><?php echo get_lang('ReportTypeLink'); ?></option>
  131. </select><br />
  132. </span>
  133. </div>
  134. <div id="wizardNavigation">
  135. <input class="navigation_button" id="back" value="<?php echo get_lang('Back'); ?>" type="reset" />
  136. <input class="navigation_button" id="next" value="<?php echo get_lang('Next'); ?>" type="submit" />
  137. </div>
  138. </form>
  139. <hr />
  140. </div>
  141. <div id="wizardShowButton">
  142. <?php echo get_lang('ShowWizard'); ?>
  143. </div>
  144. <p id="data"></p>
  145. </div>
  146. <div id="result" class="result">
  147. </div>
  148. <div id="result2" class="result">
  149. </div>
  150. <div id="result3" class="result">
  151. </div>
  152. <div id="result4" class="result">
  153. </div>
  154. <script type="text/javascript">
  155. $(function(){
  156. $("#wizardShowButton").hide();
  157. $("#wizardShowButton").click(function() {
  158. $("#wizardContent").show();
  159. $("#wizardShowButton").hide();
  160. });
  161. $("#reportsBuilderWizardForm").formwizard({
  162. formPluginEnabled: true,
  163. validationEnabled: true,
  164. focusFirstInput : true,
  165. formOptions :{
  166. success: function(data){
  167. $("#wizardContent").hide();
  168. $("#wizardShowButton").show();
  169. $(".result").html('');
  170. $("#result").html(data);
  171. },
  172. beforeSubmit: function(data){$("#data").html("data sent to the server: " + $.param(data));},
  173. resetForm: false
  174. }
  175. }
  176. );
  177. });
  178. function setSubDataUri(elem, uri) {
  179. $.ajax({
  180. url: uri,
  181. success: function(data) {
  182. $(elem).closest('.result').nextAll().html('');
  183. $(elem).closest('.result').next().html(data);
  184. }
  185. });
  186. }
  187. </script>
  188. <?php
  189. // Footer
  190. Display::display_footer();