Esempio n. 1
0
 public function CreateForm($report)
 {
     $form = CreateObject('net.php.pear.HTML_QuickForm', 'form', 'get');
     freemed::quickform_i18n(&$form);
     $form->addElement('hidden', 'report', $report);
     $form->addElement('hidden', 'action', 'view');
     $form->setDefaults(array('action' => 'view'));
     // Make sure module cache is loaded, just in case
     $_cache = freemed::module_cache();
     // Get meta-information from the report
     $this->api->setReportPath(FREEMED_DIR . '/data/report/' . $report . '.report');
     $report = $this->api->getReport();
     // Display the header if one exists
     if ($report['Report']['Properties']['Description']) {
         $form->addElement('header', '', $report['Report']['Properties']['Description']);
     }
     $merged = $this->DetermineMergedFormat($report);
     //if (!is_array($report['Report']['Parameters'])) { return NULL; }
     foreach ($report['Report']['Parameters'] as $k => $v) {
         if ($k == 'module') {
             next;
         }
         list($desc, $type, $detail) = explode(':', $v['value']);
         switch ($type) {
             case 'date':
                 $form->addElement('static', $k, $desc, fm_date_entry($k));
                 break;
                 // date
             // date
             case 'module':
                 $form->addElement('static', $k, $desc, module_function($detail, 'widget', $k));
                 break;
                 // module
             // module
             case 'select':
                 $form->addElement('select', $k, $desc, explode(',', $detail));
                 break;
                 // select
             // select
             case 'text':
                 $form->addElement('text', $k, $desc);
                 break;
                 // text
             // text
             default:
                 break;
         }
     }
     // Show format selection
     if (!$merged) {
         $form->addElement('select', 'format', __("Report Format"), array('csv' => 'CSV', 'html' => 'HTML', 'pdf' => 'PDF', 'ps' => 'Postscript', 'txt' => 'Plain Text'));
     } else {
         $form->addElement('select', 'format', __("Report Format"), array('pdf' => 'PDF'));
     }
     $submit_group[] =& HTML_QuickForm::createElement('submit', 'submit_action', __("Generate"));
     $submit_group[] =& HTML_QuickForm::createElement('submit', 'submit_action', __("Cancel"));
     $form->addGroup($submit_group, null, null, ' ');
     return $form;
 }
Esempio n. 2
0
 function control_date($action, $data)
 {
     if ($action == 'serialize') {
         return fm_date_assemble('variable_' . $data['variable']);
     } elseif ($action == 'widget') {
         if (!$_REQUEST['variable_' . $data['variable']]) {
             $GLOBALS['variable_' . $data['variable']] = $_REQUEST['variable_' . $data['variable']] = $data['default'];
         }
         return fm_date_entry('variable_' . $data['variable']);
     }
 }