1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13: class Hermes_Form_Time_Entry extends Hermes_Form_Time
14: {
15: 16: 17: 18: 19:
20: protected $_costObjects;
21:
22: public function __construct (&$vars)
23: {
24: global $conf;
25:
26: if ($vars->exists('id')) {
27: parent::__construct($vars, _("Update Time"));
28: $delete_link = Horde::url('time.php')->add('delete', $vars->get('id'))->link(array('title' => _("Delete Entry"))) . _("Delete");
29: $this->setExtra('<span class="smallheader">' . $delete_link . '</a></span>');
30: } else {
31: parent::__construct($vars, _("New Time"));
32: }
33: $this->setButtons(_("Save"));
34:
35: list($clienttype, $clientparams) = $this->getClientType();
36: if ($clienttype == 'enum') {
37: $action = &Horde_Form_Action::factory('submit');
38: }
39:
40: list($typetype, $typeparams) = $this->getJobTypeType();
41:
42: if ($vars->exists('id')) {
43: $this->addHidden('', 'id', 'int', true);
44: }
45:
46: if ($vars->exists('url')) {
47: $this->addHidden('', 'url', 'text', true);
48: }
49:
50: $var = &$this->addVariable(_("Date"), 'date', 'monthdayyear', true,
51: false, null, array(date('Y') - 1));
52: $var->setDefault(date('Y-m-d'));
53:
54: $cli = &$this->addVariable(_("Client"), 'client', $clienttype, true, false, null, $clientparams);
55: if (isset($action)) {
56: $cli->setAction($action);
57: $cli->setOption('trackchange', true);
58: }
59:
60: $this->addVariable(_("Job Type"), 'type', $typetype, true, false, null, $typeparams);
61:
62: $this->_costObjects = &$this->addVariable(
63: _("Cost Object"), 'costobject', 'enum', false, false, null,
64: array(array()));
65:
66: $this->addVariable(_("Hours"), 'hours', 'number', true);
67:
68: if ($conf['time']['choose_ifbillable']) {
69: $yesno = array(1 => _("Yes"), 0 => _("No"));
70: $this->addVariable(_("Billable?"), 'billable', 'enum', true, false, null, array($yesno));
71: }
72:
73: if ($vars->exists('client') && $vars->get('client')) {
74: try {
75: $info = $GLOBALS['injector']->getInstance('Hermes_Driver')->getClientSettings($vars->get('client'));
76: } catch (Horde_Exception_NotFound $e) {
77: }
78: if (!$info['enterdescription']) {
79: $vars->set('description', _("See Attached Timesheet"));
80: }
81: }
82: $descvar = &$this->addVariable(_("Description"), 'description', 'longtext', true, false, null, array(4, 60));
83: $this->addVariable(_("Additional Notes"), 'note', 'longtext', false, false, null, array(4, 60));
84: }
85:
86: function setCostObjects($vars)
87: {
88: $this->_costObjects->type->setValues(Hermes::getCostObjectType($vars->get('client')));
89: }
90:
91: }