Author: Chuck Hagenbuch (chuck@horde.org)
Author: Jason M. Felice (jason.m.felice@gmail.com)
Inheritance: extends Horde_Form
コード例 #1
0
ファイル: search.php プロジェクト: raz0rsdge/horde
            $registry->callAppMethod('hermes', 'download', array('args' => array($vars)));
        } catch (Horde_Exception $e) {
            $notification->push($e->getMessage(), 'horde.error');
        }
}
$title = _("Search for Time");
if (!($searchVars = $session->get('hermes', 'search_criteria'))) {
    $searchVars = $vars;
}
$form = new Hermes_Form_Search($searchVars);
$page_output->header(array('title' => $title));
$notification->notify(array('listeners' => 'status'));
$form->renderActive(new Horde_Form_Renderer(), $searchVars, Horde::url('search.php'), 'post');
echo '<br />';
if ($session->exists('hermes', 'search_criteria')) {
    echo Hermes::tabs();
    if (is_null($criteria)) {
        $criteria = $form->getSearchCriteria($searchVars);
    }
    $table = new Hermes_Table('results', $vars, array('title' => _("Search Results"), 'name' => 'hermes/hours', 'params' => $criteria));
    $template = new Horde_Template();
    $template->setOption('gettext', true);
    $template->set('postUrl', Horde::url('time.php', false, -1));
    $template->set('sessionId', Horde_Util::formInput());
    $template->set('table', $table->render());
    echo $template->fetch(HERMES_TEMPLATES . '/time/form.html');
}
echo '<br />';
$exportForm = new Hermes_Form_Export($vars);
$exportForm->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('search.php'), 'post');
$page_output->footer();
コード例 #2
0
ファイル: Application.php プロジェクト: jubinpatel/horde
 public function download(Horde_Variables $vars)
 {
     global $notification, $injector;
     switch ($vars->actionID) {
         case 'export':
             // 'export' used from Ajax view
             $ids = split(',', $vars->s);
             if (!is_array($ids)) {
                 $notification->push(_("No time slices were submitted"), 'horde.error');
                 return false;
             }
             try {
                 $hours = $injector->getInstance('Hermes_Driver')->getHours(array('id' => $ids));
             } catch (Hermes_Exception $e) {
                 $notification->push($e->getMessage(), 'horde.error');
                 return false;
             }
             $exportHours = Hermes::makeExportHours($hours);
             $this->_doExport($vars->f, $exportHours);
             if ($vars->m) {
                 $injector->getInstance('Hermes_Driver')->markAs('exported', $hours);
             }
             break;
         case 'search_export':
             // Called from Basic view.
             if (!($searchVars = $GLOBALS['session']->get('hermes', 'search_criteria'))) {
                 $notification->push(_("No time slices were submitted"), 'horde.error');
                 return false;
             }
             $searchForm = new Hermes_Form_Search($searchVars);
             $criteria = $searchForm->getSearchCriteria($searchVars);
             if (is_null($criteria)) {
                 $notification->push(_("No time slices were submitted"), 'horde.error');
                 return false;
             }
             $form = new Hermes_Form_Export($vars);
             $form->validate($vars);
             if (!$form->isValid()) {
                 return false;
             }
             $form->getInfo($vars, $info);
             try {
                 $hours = $injector->getInstance('Hermes_Driver')->getHours($criteria);
             } catch (Hermes_Exception $e) {
                 $notification->push($e, 'horde.error');
                 return false;
             }
             $exportHours = Hermes::makeExportHours($hours);
             $this->_doExport($info['format'], $exportHours);
             if (!empty($info['mark_exported']) && $info['mark_exported'] == 'yes' && $GLOBALS['perms']->hasPermission('hermes:review', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
                 $injector->getInstance('Hermes_Driver')->markAs('exported', $hours);
             }
     }
     $GLOBALS['notification']->push(_("Export complete."), 'horde.success');
     return true;
 }