{
parent::Horde_Form($vars, 'editclientstep1form');
- $clients = Hermes::listClients();
- if (is_a($clients, 'PEAR_Error')) {
+ try {
+ $clients = Hermes::listClients();
+ if (count($clients)) {
+ $subtype = 'enum';
+ $type_params = array($clients);
+ } else {
+ $subtype = 'invalid';
+ $type_params = array(_("There are no clients to edit"));
+ }
+ } catch (Hermes_Exception $e) {
$subtype = 'invalid';
$type_params = array($clients->getMessage());
- } elseif (count($clients)) {
- $subtype = 'enum';
- $type_params = array($clients);
- } else {
- $subtype = 'invalid';
- $type_params = array(_("There are no clients to edit"));
}
$this->addVariable(_("Client Name"), 'client', $subtype, true, false, null, $type_params);
}
$deliverables = array();
- //$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
- //while (!empty($row) && !is_a($row, 'PEAR_Error')) {
foreach ($rows as $row) {
$deliverable = array('id' => $row['deliverable_id'],
'client_id' => $row['client_id'],
--- /dev/null
+<?php
+/**
+ * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ */
+class Hermes_Form_JobType_Add extends Horde_Form
+{
+ public function __construct(&$vars)
+ {
+ parent::Horde_Form($vars, 'addjobtypeform');
+ $this->addVariable(_("Job Type"), 'name', 'text', true);
+ $var = &$this->addVariable(_("Enabled?"), 'enabled', 'boolean', false);
+ $var->setDefault(true);
+ $var = &$this->addVariable(_("Billable?"), 'billable', 'boolean', false);
+ $var->setDefault(true);
+ $this->addVariable(_("Hourly Rate"), 'rate', 'number', false);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
+ *
+ * @package Hermes
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ */
+class Hermes_Form_JobType_Edit_Step1 extends Horde_Form
+{
+ public function __construct(&$vars)
+ {
+ parent::Horde_Form($vars, 'editjobtypestep1form');
+
+ $values = array();
+ try {
+ $jobtypes = $GLOBALS['injector']->getInstance('Hermes_Driver')->listJobTypes();
+ foreach ($jobtypes as $id => $jobtype) {
+ $values[$id] = $jobtype['name'];
+ if (empty($jobtype['enabled'])) {
+ $values[$id] .= _(" (DISABLED)");
+ }
+ }
+ } catch (Hermes_Exception $e) {}
+
+ if ($values) {
+ $subtype = 'enum';
+ $type_params = array($values);
+ } else {
+ $subtype = 'invalid';
+ $type_params = array(_("There are no job types to edit"));
+ }
+
+ $this->addVariable(_("JobType Name"), 'jobtype', $subtype, true, false, null, $type_params);
+ }
+
+}
\ No newline at end of file
*/
protected $_formVars = array();
+ /**
+ *
+ * @return array
+ * @throws Hermes_Exception
+ */
public function getMetaData()
{
if (is_null($this->_metaData)) {
$args = array($name, $this->_config['params']);
$this->_metaData = $GLOBALS['registry']->callByPackage(
$app, 'getTableMetaData', $args);
- if (is_a($this->_metaData, 'PEAR_Error')) {
- return $this->_metaData;
- }
+
// We need to make vars for the columns.
foreach ($this->_metaData['sections'] as $secname => $section) {
* Returns the largest column count of any section, taking into account
* 'colspan' attributes.
*
- * @return mixed number of columns or PEAR_Error
+ * @return integer number of columns
+ * @throws Hermes_Exception
*/
public function getColumnCount()
{
$res = $this->getMetaData();
- if (is_a($res, 'PEAR_Error')) {
- return $res;
- }
$colcount = 0;
foreach ($this->_metaData['sections'] as $section) {
$sec_colcount = 0;
{
global $notification;
- $result = $this->getMetaData();
- if (is_a($result, 'PEAR_Error')) {
- $notification->push($result, 'horde.error');
+ try {
+ $result = $this->getMetaData();
+ } catch (Hermes_Exception $e) {
+ $notification->push($e->getMessage(), 'horde.error');
return false;
}
$html .= '</tr></thead>';
// Display data.
- $data = $this->_getData();
- if (is_a($data, 'PEAR_Error')) {
- $notification->push($data, 'horde.error');
+ try {
+ $data = $this->_getData();
+ } catch (Hermes_Exception $e) {
+ $notification->push($e, 'horde.error');
$data = array();
}