/**
  * Specifies the config header for this report
  *
  * @return  string  The HTML content of the config header
  * @uses $CFG
  */
 function get_config_header()
 {
     global $CFG;
     require_once $CFG->libdir . '/filelib.php';
     if (!isloggedin() || isguestuser()) {
         //user is not properly logged in
         return '';
     }
     //determine if we should show the configure filter link
     $show_config_filters_link = true;
     //NOTE: using has_filters instead of get_filters so reports can
     //specify this info without having to construct filters
     if (!$this->has_filters()) {
         //no filters are defined for this report
         $show_config_filters_link = false;
     }
     if (!$this->allow_configured_filters()) {
         //configured filters are not allowed for this report
         $show_config_filters_link = false;
     }
     //determine if we should display the scheduling link
     $test_permissions_instance = php_report::get_default_instance($this->get_report_shortname(), NULL, php_report::EXECUTION_MODE_SCHEDULED);
     $show_schedule_report_link = $test_permissions_instance !== FALSE;
     //also assert that at least one export format is available
     $export_formats = $this->get_export_formats();
     $show_export_icons = count($export_formats) > 0;
     //determine if some icon needs to be displayed
     $show_something = $show_config_filters_link || $show_schedule_report_link || $show_export_icons;
     if (!$show_something) {
         //no filter, export or schedule links to show
         return '';
     }
     $result = '<div class="php_report_config_header">';
     if ($show_config_filters_link) {
         //link for configuring parameters
         $alt_text = get_string('config_params', 'block_php_report');
         //link to parameter screen with cancel button
         $config_params_url = $this->get_config_url();
         $result .= '<a href="' . $config_params_url . '">' . '<img src="' . $CFG->wwwroot . '/blocks/php_report/pix/configuration.png" border="0" width="16" height="16" ' . 'alt="' . $alt_text . '" title="' . $alt_text . '">' . '</a>&nbsp;&nbsp;';
     }
     //loop through the possible export formats and add the export links if
     //they are supported by the report
     //todo: remove the use of get_allowable_export_formats
     $export_formats = $this->get_export_formats();
     $allowable_export_formats = php_report::get_allowable_export_formats();
     foreach ($allowable_export_formats as $allowable_export_format) {
         if (in_array($allowable_export_format, $export_formats)) {
             $alt_text = get_string('export_link_' . $allowable_export_format, 'block_php_report');
             // add hatch character at end of url to force loading in a new page (checked in associate.class.js)
             $export_url = $CFG->wwwroot . '/blocks/php_report/download.php?id=' . $this->id . '&gas_gauge_page=' . $this->gas_gauge_page . '&format=' . $allowable_export_format . '#';
             $icon = mimeinfo('icon', "foo.{$allowable_export_format}");
             $result .= '<a href="' . $export_url . '" target="_blank">' . '<img src="' . $CFG->pixpath . '/f/' . $icon . '" border="0" width="16" height="16" ' . 'alt="' . $alt_text . '" title="' . $alt_text . '">' . '</a>&nbsp;&nbsp;';
         }
     }
     if ($show_schedule_report_link) {
         //link for scheduling reports
         $report_shortname = $this->get_report_shortname();
         //url to link to
         $schedule_report_url = '/blocks/php_report/schedule.php?report=' . $report_shortname . '&action=listinstancejobs&createifnone=1';
         $result .= '<span class="external_report_link php_report_schedule_this_link">' . get_string('schedule_this_report', 'block_php_report') . '&nbsp;
                     <a href="#" onclick="openpopup(\'' . $schedule_report_url . '\', \'php_report_param_popup\', \'menubar=0,location=0,scrollbars,status,resizable,width=1600,height=600\')">
                     <img src="' . $CFG->wwwroot . '/blocks/php_report/pix/schedule.png"/>
                     </a>
                     </span>';
     }
     $result .= '</div>';
     return $result;
 }
Exemplo n.º 2
0
 function definition()
 {
     require_js_files();
     $mform =& $this->_form;
     $page = $this->_customdata;
     $workflow = $page->workflow;
     $mform->addElement('hidden', '_wfid', $workflow->id);
     $mform->setType('_wfid', PARAM_INT);
     $mform->addElement('hidden', '_step', scheduling_workflow::STEP_FORMAT);
     $mform->setType('_step', PARAM_TEXT);
     $mform->addElement('hidden', 'action', 'save');
     $mform->setType('action', PARAM_TEXT);
     $mform->addElement('html', '<h2>' . htmlspecialchars(get_string('format_description', 'local_elisreports')) . '</h2>');
     $radioarray = array();
     //obtain the actual report instance so we can check its export formats
     $data = unserialize($workflow->data);
     $report_shortname = $data['report'];
     $report_instance = php_report::get_default_instance($report_shortname, NULL, php_report::EXECUTION_MODE_SCHEDULED);
     //global list of all available export formats
     $allowable_export_formats = php_report::get_allowable_export_formats();
     //export formats supported by the report we are scheduling
     $export_formats = $report_instance->get_export_formats();
     //add an export option for each applicable format
     if ($report_instance->can_view_report()) {
         foreach ($allowable_export_formats as $allowable_export_format) {
             if (in_array($allowable_export_format, $export_formats)) {
                 $radioarray[] = $mform->createElement('radio', 'format', '', get_string($allowable_export_format, 'local_elisreports'), $allowable_export_format);
             }
         }
     }
     $mform->addGroup($radioarray, 'format', get_string('format'), '', false);
     $mform->addRule('format', get_string('required_field', 'local_elisreports', get_string('format')), 'required', null, 'client');
     $mform->setDefault('format', 'csv');
     workflowpage::add_navigation_buttons($mform, scheduling_workflow::STEP_PARAMETERS);
 }
    /**
     * Print the paging headers for the table.
     *
     * @param   int|string  $id  Id of php report element, if applicable
     * @uses    $CFG
     * @uses    $OUTPUT
     * @return  string           HTML output for display.
     */
    function print_header($id = 0) {
        global $CFG, $OUTPUT;

        $output = '';
        $args = '';

        $export_formats = $this->get_export_formats();
        $allowable_export_formats = php_report::get_allowable_export_formats();

        if ($id !== 0) {
            $effective_url = $CFG->wwwroot . '/local/elisreports/dynamicreport.php?id=' . $id;
        } else {
            $effective_url = $this->baseurl;
        }

        //similar to parent class, but maintains gas gauge page
        $this->print_paging_bar($this->numrecs, $this->page, $this->perpage,
                                "{$effective_url}&amp;sort={$this->sort}&amp;dir={$this->dir}&amp;" .
                                "perpage={$this->perpage}&amp;gas_gauge_page={$this->gas_gauge_page}{$args}&amp;");

        echo $this->get_interactive_filter_display();

        return $output;
    }
Exemplo n.º 4
0
    /**
     * Print the paging headers for the table.
     *
     * @param   int|string  $id  Id of php report element, if applicable
     *
     * @return  string           HTML output for display.
     */
    function print_header($id = 0) {
        global $CFG, $OUTPUT;

        $output = '';

        $args = '';

        $export_formats = $this->get_export_formats();
        $allowable_export_formats = php_report::get_allowable_export_formats();

        if ($id !== 0) {
            $effective_url = $CFG->wwwroot . '/local/elisreports/dynamicreport.php?id=' . $id;
        } else {
            $effective_url = $this->baseurl;
        }

        $effective_url = "{$effective_url}&amp;sort={$this->sort}&amp;dir={$this->dir}&amp;" .
                         "perpage={$this->perpage}&amp;";
        $this->print_paging_bar($this->numrecs, $this->page, $this->perpage, $effective_url);

        //show available and active filters, if applicable
        echo $this->get_interactive_filter_display();

        return $output;
    }
Exemplo n.º 5
0
    /**
     * Specifies the config header for this report
     *
     * @return  string  The HTML content of the config header
     */
    function get_config_header() {
        global $CFG, $OUTPUT;

        require_once($CFG->libdir.'/filelib.php');

        if (!isloggedin() || isguestuser()) {
            //user is not properly logged in
            return '';
        }

        //determine if we should show the configure filter link
        $show_config_filters_link = true;

        //NOTE: using has_filters instead of get_filters so reports can
        //specify this info without having to construct filters
        if (!$this->has_filters()) {
            //no filters are defined for this report
            $show_config_filters_link = false;
        }

        if (!$this->allow_configured_filters()) {
            //configured filters are not allowed for this report
            $show_config_filters_link = false;
        }

        //determine if we should display the scheduling link
        $test_permissions_instance = php_report::get_default_instance($this->get_report_shortname(), NULL, php_report::EXECUTION_MODE_SCHEDULED);
        $show_schedule_report_link = $test_permissions_instance !== FALSE;

        //also assert that at least one export format is available
        $export_formats = $this->get_export_formats();
        //if (count($export_formats) == 0) {
        //    $show_schedule_report_link = false;
        //}
        $show_export_icons = count($export_formats) > 0;
        //determine if some icon needs to be displayed
        $show_something = $show_config_filters_link || $show_schedule_report_link || $show_export_icons;

        if (!$show_something) {
            //no filter, export or schedule links to show
            return '';
        }

        $result = html_writer::start_tag('div', array('class' => 'php_report_config_header'));

        if ($show_config_filters_link) {
            //link for configuring parameters
            $alt_text = get_string('config_params', 'local_elisreports');

            //link to parameter screen with cancel button
            $config_params_url = $this->get_config_url();

            //start of anchor for link
            $result .= html_writer::start_tag('a', array('href' => $config_params_url));
            //icon
            $result .= html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('configuration', 'local_elisreports'),
                                                           'border' => 0,
                                                           'width' => 16,
                                                           'height' => 16,
                                                           'alt' => $alt_text,
                                                           'title' => $alt_text));
            //end of anchor for link
            $result .= html_writer::end_tag('a');
            $result .= '&nbsp;&nbsp;';
        }

        //loop through the possible export formats and add the export links if
        //they are supported by the report
        $export_formats = $this->get_export_formats();
        $allowable_export_formats = php_report::get_allowable_export_formats();
        foreach ($allowable_export_formats as $allowable_export_format) {
            if (in_array($allowable_export_format, $export_formats)) {
                //link alt text
                $alt_text = get_string('export_link_'.$allowable_export_format, 'local_elisreports');
                //export link, with hash for smooth flow
                $export_url = $CFG->wwwroot.'/local/elisreports/download.php?id='.$this->id.'&gas_gauge_page=' . $this->gas_gauge_page . '&format='.$allowable_export_format.'#';
                //icon url
                $icon = 'f/'.mimeinfo('icon', "foo.$allowable_export_format");

                //start of anchor for link
                $result .= html_writer::start_tag('a', array('href' => $export_url, 'target' => '_blank'));
                //icon
                $result .= html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url($icon),
                                                               'border' => 0,
                                                               'width' => 16,
                                                               'height' => 16,
                                                               'alt' => $alt_text,
                                                               'title' => $alt_text));
                //end of anchor for link
                $result .= html_writer::end_tag('a');
                $result .= '&nbsp;&nbsp';
            }
        }

        if ($show_schedule_report_link) {
            //link for scheduling reports

            $report_shortname = $this->get_report_shortname();

            //url to link to
            $schedule_report_url = '/local/elisreports/schedule.php?report='.$report_shortname.'&action=listinstancejobs&createifnone=1';

            //containing span
            $result .= html_writer::start_tag('span', array('class' => 'external_report_link php_report_schedule_this_link'));
            $result .= get_string('schedule_this_report', 'local_elisreports').'&nbsp';

            //open popup code
            $jsondata = array('url' => $schedule_report_url,
                              'name' => 'php_report_param_popup',
                              'options' => "\"menubar=0,location=0,scrollbars,status,resizable,width=1600,height=600\"");
            $jsondata = json_encode($jsondata);
            $onclick = "return openpopup(null, $jsondata)";
            //start of anchor for link
            $result .= html_writer::start_tag('a', array('href' => '#',
                                                         'onclick' => $onclick));
            //icon
            $result .= html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('schedule', 'local_elisreports')));
            //end of anchor for link
            $result .= html_writer::end_tag('a');
            //end of span
            $result .= html_writer::end_tag('span');
        }
        $result .= html_writer::end_tag('div');

        return $result;
    }