예제 #1
0
 function print_report_page()
 {
     global $DB, $CFG, $OUTPUT, $USER;
     cr_print_js_function();
     $components = cr_unserialize($this->config->components);
     $template = isset($components['template']['config']) && $components['template']['config']->enabled && $components['template']['config']->record ? $components['template']['config'] : false;
     if ($template) {
         $this->print_template($template);
         return true;
     }
     // Debug
     $debug = optional_param('debug', false, PARAM_BOOL);
     if ($debug or !empty($this->config->debug)) {
         echo html_writer::empty_tag('hr');
         echo html_writer::tag('div', $this->sql, array('id' => 'debug', 'style' => 'direction:ltr;text-align:left;'));
         echo html_writer::empty_tag('hr');
     }
     echo '<div class="centerpara">';
     echo format_text($this->config->summary);
     echo '</div>';
     $this->print_filters();
     if ($this->finalreport->table && !empty($this->finalreport->table->data[0])) {
         echo "<div id=\"printablediv\">\n";
         $this->print_graphs();
         if ($this->config->jsordering) {
             $this->add_jsordering();
         }
         $this->totalrecords = count($this->finalreport->table->data);
         if ($this->config->pagination) {
             $page = optional_param('page', 0, PARAM_INT);
             $this->totalrecords = count($this->finalreport->table->data);
             $this->finalreport->table->data = array_slice($this->finalreport->table->data, $page * $this->config->pagination, $this->config->pagination);
         }
         cr_print_table($this->finalreport->table);
         if ($this->config->pagination) {
             $postfiltervars = '';
             $request = array_merge($_POST, $_GET);
             if ($request) {
                 foreach ($request as $key => $val) {
                     if (strpos($key, 'filter_') !== false) {
                         if (is_array($val)) {
                             foreach ($val as $k => $v) {
                                 $postfiltervars .= "&amp;{$key}[{$k}]=" . $v;
                             }
                         } else {
                             $postfiltervars .= "&amp;{$key}=" . $val;
                         }
                     }
                 }
             }
             //print_paging_bar($this->totalrecords,$page,$this->config->pagination,"viewreport.php?id=".$this->config->id."$postfiltervars&amp;");
             $pagingbar = new paging_bar($this->totalrecords, $page, $this->config->pagination, "viewreport.php?id=" . $this->config->id . "&courseid=" . $this->config->courseid . "{$postfiltervars}&amp;");
             $pagingbar->pagevar = 'page';
             echo $OUTPUT->render($pagingbar);
         }
         // Report statistics
         $a = new stdClass();
         $a->totalrecords = $this->totalrecords;
         echo html_writer::tag('div', get_string('totalrecords', 'block_configurable_reports', $a), array('id' => 'totalrecords'));
         echo html_writer::tag('div', get_string('lastexecutiontime', 'block_configurable_reports', $this->config->lastexecutiontime / 1000), array('id' => 'lastexecutiontime'));
         if (!empty($this->finalreport->calcs->data[0])) {
             echo '<br /><br /><br /><div class="centerpara"><b>' . get_string("columncalculations", "block_configurable_reports") . '</b></div><br />';
             echo html_writer::table($this->finalreport->calcs);
         }
         echo "</div>";
         $this->print_export_options();
     } else {
         echo '<div class="centerpara">' . get_string('norecordsfound', 'block_configurable_reports') . '</div>';
     }
     echo '<div class="centerpara"><br />';
     echo $OUTPUT->pix_icon('print', get_string('printreport', 'block_configurable_reports'), 'block_configurable_reports');
     echo "&nbsp;<a href=\"javascript: printDiv('printablediv')\">" . get_string('printreport', 'block_configurable_reports') . "</a>";
     echo "</div>\n";
 }
 function print_report_page()
 {
     global $CFG, $FULLME, $USER;
     cr_print_js_function();
     $components = cr_unserialize($this->config->components);
     $template = isset($components['template']['config']) && $components['template']['config']->enabled && $components['template']['config']->record ? $components['template']['config'] : false;
     if ($template) {
         $this->print_template($template);
         return true;
     }
     echo '<div class="centerpara">';
     echo format_text($this->config->summary);
     echo '</div>';
     $this->print_filters();
     if ($this->finalreport->table && !empty($this->finalreport->table->data[0])) {
         echo "<div id=\"printablediv\">\n";
         $this->print_graphs();
         if ($this->config->jsordering) {
             $this->add_jsordering();
         }
         if ($this->config->pagination) {
             $page = optional_param('page', 0, PARAM_INT);
             $this->totalrecords = count($this->finalreport->table->data);
             $this->finalreport->table->data = array_slice($this->finalreport->table->data, $page * $this->config->pagination, $this->config->pagination);
         }
         cr_print_table($this->finalreport->table);
         if ($this->config->pagination) {
             $postfiltervars = '';
             $request = array_merge($_POST, $_GET);
             if ($request) {
                 foreach ($request as $key => $val) {
                     if (strpos($key, 'filter_') !== false) {
                         if (is_array($val)) {
                             foreach ($val as $k => $v) {
                                 $postfiltervars .= "&amp;{$key}[{$k}]=" . $v;
                             }
                         } else {
                             $postfiltervars .= "&amp;{$key}=" . $val;
                         }
                     }
                 }
             }
             print_paging_bar($this->totalrecords, $page, $this->config->pagination, "viewreport.php?id=" . $this->config->id . "{$postfiltervars}&amp;");
         }
         if (!empty($this->finalreport->calcs->data[0])) {
             echo '<br /><br /><br /><div class="centerpara"><b>' . get_string("columncalculations", "block_configurable_reports") . '</b></div><br />';
             print_table($this->finalreport->calcs);
         }
         echo "</div>";
         // Display Records (Rows / Items) count (nadavkav 11-6-11)
         echo "<br/><div id=\"totalitems\">" . get_string('totalitems', "block_configurable_reports") . " " . count($this->finalreport->table->data) . "</div>";
         $this->print_export_options();
     } else {
         echo '<div class="centerpara">' . get_string('norecordsfound', 'block_configurable_reports') . '</div>';
     }
     echo '<div class="centerpara"><br />';
     echo "<img src=\"{$CFG->wwwroot}/blocks/configurable_reports/img/print.png\" alt=\".get_string('printreport','block_configurable_reports')\">&nbsp;<a href=\"javascript: printDiv('printablediv')\">" . get_string('printreport', 'block_configurable_reports') . "</a>";
     echo "</div>\n";
 }