[hermes] [patch] Select client instead of client:job
Jason M. Felice
jfelice at cronosys.com
Thu Aug 7 11:21:36 PDT 2003
This patch replaces the client:job fields with client fields, so the user
just selects the client and work type. Projects should be done with links
to whups modules and/or tickets in the future. Hermes no longer depends on
whups.
If anyone is using the .iif export, test it. I had to change the semantics
of it a little bit, but it should still work.
All the Add Client:Job/Edit Client:Job was changed to "Edit Client
Settings", which makes more sense.
Some documentation changes, as well.
--
Jason M. Felice
Cronosys, LLC <http://www.cronosys.com/>
216.221.4600 x302
-------------- next part --------------
Index: hermes/lib/TimeForm.php
===================================================================
RCS file: /repository/hermes/lib/TimeForm.php,v
retrieving revision 1.16
diff -u -r1.16 TimeForm.php
--- hermes/lib/TimeForm.php 17 Jul 2003 16:42:22 -0000 1.16
+++ hermes/lib/TimeForm.php 7 Aug 2003 18:15:51 -0000
@@ -61,7 +61,7 @@
function getClientType()
{
- $clients = Hermes::listClientJobs();
+ $clients = Hermes::listClients();
if (is_a($clients, 'PEAR_Error')) {
return array('invalid', array(sprintf(_("An error occurred listing clients: %s"),
$clients->getMessage())));
@@ -100,9 +100,9 @@
if ($clienttype == 'enum') {
require_once HORDE_BASE . '/lib/Form/Action.php';
$map = array();
- $clients = Hermes::listClientJobs();
+ $clients = Hermes::listClients();
foreach ($clients as $id => $name) {
- $info = $hermes->getClientJob($id);
+ $info = $hermes->getClientSettings($id);
if (!is_a($info, 'PEAR_Error')) {
$map[$id] = $info['enterdescription'] ? '' : _("See Attached Timesheet");
} else {
@@ -120,7 +120,7 @@
$this->addHidden('', 'timestamp', 'int', true);
$this->addVariable(_("Date"), 'date[]', 'enum', true, false, null, array($date_values));
- $cli = &$this->addVariable(_("Client:Job"), 'client[]', $clienttype, true, false, null, $clientparams);
+ $cli = &$this->addVariable(_("Client"), 'client[]', $clienttype, true, false, null, $clientparams);
if (isset($action)) {
$cli->setAction($action);
}
@@ -167,7 +167,7 @@
$this->addHidden('', 'timestamp', 'int', true);
$this->addVariable(_("Date"), 'date[]', 'enum', true, false, null, array($date_values));
- $this->addVariable(_("Client:Job"), 'client[]', $clienttype, true, false, null, $clientparams);
+ $this->addVariable(_("Client"), 'client[]', $clienttype, true, false, null, $clientparams);
$this->addVariable(_("Job Type"), 'type[]', $typetype, true, false, null, $typeparams);
$this->addVariable(_("Hours"), 'hours[]', 'number', true);
@@ -201,9 +201,9 @@
if ($clienttype == 'enum') {
require_once HORDE_BASE . '/lib/Form/Action.php';
$map = array();
- $clients = Hermes::listClientJobs();
+ $clients = Hermes::listClients();
foreach ($clients as $id => $name) {
- $info = $hermes->getClientJob($id);
+ $info = $hermes->getClientSettings($id);
if (!is_a($info, 'PEAR_Error')) {
$map[$id] = $info['enterdescription'] ? '' : _("See Attached Timesheet");
} else {
@@ -223,7 +223,7 @@
$this->addVariable(_("Delete?"), 'delete[]', 'boolean', false, false);
$this->addVariable(_("Date"), 'date[]', 'enum', true, false, null, array($date_values));
- $cli = &$this->addVariable(_("Client:Job"), 'client[]', $clienttype, true, false, null, $clientparams);
+ $cli = &$this->addVariable(_("Client"), 'client[]', $clienttype, true, false, null, $clientparams);
if (isset($action)) {
$cli->setAction($action);
}
@@ -266,7 +266,7 @@
$this->addVariable(_("Submit?"), 'submit_slice[]', 'boolean', false);
$this->addVariable(_("Date"), 'date[]', 'enum', false, true, null, array($date_values));
- $this->addVariable(_("Client:Job"), 'client[]', $clienttype, false, true, null, $clientparams);
+ $this->addVariable(_("Client"), 'client[]', $clienttype, false, true, null, $clientparams);
$this->addVariable(_("Job Type"), 'type[]', $typetype, false, true, null, $typeparams);
$this->addVariable(_("Hours"), 'hours[]', 'number', false, true);
Index: hermes/lib/Hermes.php
===================================================================
RCS file: /repository/hermes/lib/Hermes.php,v
retrieving revision 1.9
diff -u -r1.9 Hermes.php
--- hermes/lib/Hermes.php 17 Jul 2003 16:42:22 -0000 1.9
+++ hermes/lib/Hermes.php 7 Aug 2003 18:15:52 -0000
@@ -19,16 +19,30 @@
$conf['storage']['params']);
}
- function listClientJobs()
+ function listClients()
{
- static $clientjobs;
+ static $clients;
+
+ if (is_null($clients)) {
+ $args = array('addresses' => array(''),
+ 'fields' => array('name')
+ );
+ $result = $GLOBALS['registry']->call('clients/clientSearch', $args);
+ if (is_a($result,'PEAR_Error')) {
+ return $result;
+ }
+ $result = $result[''];
+ $clients = array();
+ if (!empty($result)) {
+ foreach ($result as $client) {
+ $clients[$client['id']] = $client['name'];
+ }
+ }
- if (is_null($clientjobs)) {
- $clientjobs = $GLOBALS['registry']->call('projects/listAs',
- array('clientProjects'));
+ asort($clients,SORT_STRING);
}
- return $clientjobs;
+ return $clients;
}
function getStartOfWeekStamp($weekstamp = null)
Index: hermes/lib/Admin.php
===================================================================
RCS file: /repository/hermes/lib/Admin.php,v
retrieving revision 1.9
diff -u -r1.9 Admin.php
--- hermes/lib/Admin.php 27 Apr 2003 00:27:32 -0000 1.9
+++ hermes/lib/Admin.php 7 Aug 2003 18:15:52 -0000
@@ -96,59 +96,48 @@
}
-class AddClientJobForm extends Horde_Form {
+class EditClientStep1Form extends Horde_Form {
- function AddClientJobForm(&$vars)
- {
- parent::Horde_Form($vars, 'addclientjobform');
-
- $this->addVariable(_("Client:Job"), 'module', 'text', true);
- }
-
-}
-
-class EditClientJobStep1Form extends Horde_Form {
-
- function EditClientJobStep1Form(&$vars)
+ function EditClientStep1Form(&$vars)
{
global $hermes;
- parent::Horde_Form($vars, 'editclientjobstep1form');
+ parent::Horde_Form($vars, 'editclientstep1form');
- $clientjobs = Hermes::listClientJobs();
- if (count($clientjobs) > 0) {
+ $clients = Hermes::listClients();
+ if (count($clients) > 0) {
$subtype = 'enum';
- $type_params = array($clientjobs);
+ $type_params = array($clients);
} else {
$subtype = 'invalid';
- $type_params = array(_("There are no Client:Jobs to edit"));
+ $type_params = array(_("There are no clients to edit"));
}
- $this->addVariable(_("ClientJob Name"), 'clientjob', $subtype, true, false, null, $type_params);
+ $this->addVariable(_("Client Name"), 'client', $subtype, true, false, null, $type_params);
}
}
-class EditClientJobStep2Form extends Horde_Form {
+class EditClientStep2Form extends Horde_Form {
- function EditClientJobStep2Form(&$vars)
+ function EditClientStep2Form(&$vars)
{
global $hermes;
- parent::Horde_Form($vars, 'editclientjobstep2form');
+ parent::Horde_Form($vars, 'editclientstep2form');
- $clientjob = $vars->getVar('clientjob');
- $info = $hermes->getClientJob($clientjob);
+ $client = $vars->getVar('client');
+ $info = $hermes->getClientSettings($client);
if (!$info || is_a($info, 'PEAR_Error')) {
$stype = 'invalid';
- $type_params = array(_("This is not a valid Client:Job."));
+ $type_params = array(_("This is not a valid client."));
} else {
$stype = 'text';
$type_params = array();
}
- $this->addHidden('', 'clientjob', 'int', true, true);
- $name = &$this->addVariable(_("Client:Job"), 'name', $stype, false, true, false, null, $type_params);
+ $this->addHidden('', 'client', 'text', true, true);
+ $name = &$this->addVariable(_("Client"), 'name', $stype, false, true, false, null, $type_params);
$name->setDefault($info['name']);
$enterdescription = &$this->addVariable(sprintf(_("Should users enter descriptions of their timeslices for this client? If not, the description will automatically be \"%s\"."), _("See Attached Timesheet")), 'enterdescription', 'boolean', true);
@@ -156,7 +145,7 @@
$enterdescription->setDefault($info['enterdescription']);
}
- $exportid = &$this->addVariable(_("ID for this Client:Job when exporting data, if different from the name displayed above."), 'exportid', 'text', false);
+ $exportid = &$this->addVariable(_("ID for this client when exporting data, if different from the name displayed above."), 'exportid', 'text', false);
if (!empty($info['exportid'])) {
$exportid->setDefault($info['exportid']);
}
Index: hermes/lib/Driver/sql.php
===================================================================
RCS file: /repository/hermes/lib/Driver/sql.php,v
retrieving revision 1.15
diff -u -r1.15 sql.php
--- hermes/lib/Driver/sql.php 21 Jul 2003 20:00:41 -0000 1.15
+++ hermes/lib/Driver/sql.php 7 Aug 2003 18:15:52 -0000
@@ -311,35 +311,35 @@
return $this->_db->query('DELETE FROM hermes_jobtypes WHERE jobtype_id = ' . $this->_db->quote($jobTypeID));
}
- function getClientJob($clientJobID)
+ function getClientSettings($clientID)
{
/* Make sure we have a valid database connection. */
$this->_connect();
- $clients = Hermes::listClientJobs();
- if (empty($clientJobID) || !isset($clients[$clientJobID])) {
+ $clients = Hermes::listClients();
+ if (empty($clientID) || !isset($clients[$clientID])) {
return PEAR::raiseError('Does not exist');
}
- $clientJob = $this->_db->getAssoc('SELECT clientjob_id, clientjob_enterdescription, clientjob_exportid FROM hermes_clientjobs WHERE clientjob_id = ' . $this->_db->quote($clientJobID));
- if (is_a($clientJob, 'PEAR_Error')) {
- return $clientJob;
+ $settings = $this->_db->getAssoc('SELECT clientjob_id, clientjob_enterdescription, clientjob_exportid FROM hermes_clientjobs WHERE clientjob_id = ' . $this->_db->quote($clientID));
+ if (is_a($settings, 'PEAR_Error')) {
+ return $settings;
}
- if (isset($clientJob[$clientJobID])) {
- $cj = array('id' => $clientJobID,
- 'enterdescription' => $clientJob[$clientJobID][0],
- 'exportid' => $clientJob[$clientJobID][1]);
+ if (isset($clientJob[$clientID])) {
+ $settings = array('id' => $clientID,
+ 'enterdescription' => $clientJob[$clientID][0],
+ 'exportid' => $clientJob[$clientID][1]);
} else {
- $cj = array('id' => $clientJobID,
- 'enterdescription' => 1,
- 'exportid' => null);
+ $settings = array('id' => $clientID,
+ 'enterdescription' => 1,
+ 'exportid' => null);
}
- $cj['name'] = $clients[$clientJobID];
- return $cj;
+ $settings['name'] = $clients[$clientID];
+ return $settings;
}
- function updateClientJob($clientJobID, $enterdescription = 1, $exportid = null)
+ function updateClientSettings($clientID, $enterdescription = 1, $exportid = null)
{
/* Make sure we have a valid database connection. */
$this->_connect();
@@ -348,15 +348,15 @@
$exportid = null;
}
- $exists = 'SELECT clientjob_id FROM hermes_clientjobs WHERE clientjob_id = ' . $this->_db->quote($clientJobID);
- if ($this->_db->getOne($exists) !== $clientJobID) {
+ $exists = 'SELECT clientjob_id FROM hermes_clientjobs WHERE clientjob_id = ' . $this->_db->quote($clientID);
+ if ($this->_db->getOne($exists) !== $clientID) {
$result = $this->_db->query('INSERT INTO hermes_clientjobs (clientjob_id, clientjob_enterdescription, clientjob_exportid) VALUES (' .
- $this->_db->quote($clientJobID) . ', ' . (int)$enterdescription . ', ' . $this->_db->quote($exportid) . ')');
+ $this->_db->quote($clientID) . ', ' . (int)$enterdescription . ', ' . $this->_db->quote($exportid) . ')');
} else {
$result = $this->_db->query('UPDATE hermes_clientjobs SET' .
' clientjob_exportid = ' . $this->_db->quote($exportid) . ', ' .
' clientjob_enterdescription = ' . (int)$enterdescription .
- ' WHERE clientjob_id = ' . $this->_db->quote($clientJobID));
+ ' WHERE clientjob_id = ' . $this->_db->quote($clientID));
}
return PEAR::isError($result) ? $result : true;
Index: hermes/admin.php
===================================================================
RCS file: /repository/hermes/admin.php,v
retrieving revision 1.10
diff -u -r1.10 admin.php
--- hermes/admin.php 23 May 2003 14:44:27 -0000 1.10
+++ hermes/admin.php 7 Aug 2003 18:15:52 -0000
@@ -60,29 +60,6 @@
}
break;
- case 'addclientjobform':
- $form = &Horde_Form::singleton('AddClientJobForm', $vars);
- $form->validate($vars);
-
- if ($form->isValid()) {
- $result = $registry->call('projects/add', array($vars->getVar('module')));
- if (PEAR::isError($result)) {
- $notification->push(sprintf(_("There was an error adding the Client:Job: %s."), $result->getMessage()), 'horde.error');
- } else {
- $notification->push(sprintf(_("The Client:Job %xs has been added."), $vars->getVar('name')), 'horde.success');
- }
- } else {
- _open();
-
- $form->open($r, $vars, 'admin.php', 'post');
- $r->beginActive(_("Add Client:Job"));
- $r->renderFormActive($form, $vars);
- $r->submit();
- $r->end();
- $form->close($r);
- }
- break;
-
case 'editjobtypestep1form':
$form1 = &Horde_Form::singleton('EditJobTypeStep1Form', $vars);
$form1->validate($vars);
@@ -127,18 +104,18 @@
}
break;
- case 'editclientjobstep1form':
- $form1 = &Horde_Form::singleton('EditClientJobStep1Form', $vars);
+ case 'editclientstep1form':
+ $form1 = &Horde_Form::singleton('EditClientStep1Form', $vars);
$form1->validate($vars);
_open();
if ($form1->isValid()) {
- $form2 = &Horde_Form::singleton('EditClientJobStep2Form', $vars);
+ $form2 = &Horde_Form::singleton('EditClientStep2Form', $vars);
$form2->open($r, $vars, 'admin.php', 'post');
// render the second stage form
- $r->beginActive(_("Edit Client:Job, Step 2"));
+ $r->beginActive(_("Edit Client Settings, Step 2"));
$r->renderFormActive($form2, $vars);
$r->submit();
$r->end();
@@ -146,7 +123,7 @@
$form2->close($r);
} else {
$form1->open($r, $vars, 'admin.php', 'post');
- $r->beginActive(_("Edit Client:Job"));
+ $r->beginActive(_("Edit Client Settings"));
$r->renderFormActive($form1, $vars);
$r->submit();
$r->end();
@@ -179,24 +156,24 @@
}
break;
- case 'editclientjobstep2form':
- $form = &Horde_Form::singleton('EditClientJobStep2Form', $vars);
+ case 'editclientstep2form':
+ $form = &Horde_Form::singleton('EditClientStep2Form', $vars);
$form->validate($vars);
if ($form->isValid()) {
- $result = $hermes->updateClientJob($vars->getVar('clientjob'),
- $vars->getVar('enterdescription') ? 1 : 0,
- $vars->getVar('exportid'));
+ $result = $hermes->updateClientSettings($vars->getVar('client'),
+ $vars->getVar('enterdescription') ? 1 : 0,
+ $vars->getVar('exportid'));
if (PEAR::isError($result)) {
- $notification->push(sprintf(_("There was an error editing the Client:Job: %s."), $result->getMessage()), 'horde.error');
+ $notification->push(sprintf(_("There was an error editing the client settings: %s."), $result->getMessage()), 'horde.error');
} else {
- $notification->push(_("The Client:Job has been modified."), 'horde.success');
+ $notification->push(_("The client settings have been modified."), 'horde.success');
}
} else {
_open();
$form->open($r, $vars, 'admin.php', 'post');
- $r->beginActive(_("Edit Client:Job, Step 2"));
+ $r->beginActive(_("Edit Client Settings, Step 2"));
$r->renderFormActive($form, $vars);
$r->submit();
$r->end();
@@ -236,8 +213,7 @@
if (!$beendone) {
$form1 = &Horde_Form::singleton('EditJobTypeStep1Form', $vars); $edit1 = _("Edit Job Type"); $edit2 = _("Delete Job Type");
$form2 = &Horde_Form::singleton('AddJobTypeForm', $vars); $add = _("Add Job Type");
- $form3 = &Horde_Form::singleton('EditClientJobStep1Form', $vars); $edit3 = _("Edit Client:Job Settings");
- $form4 = &Horde_Form::singleton('AddClientJobForm', $vars); $add4 = _("Add Client:Job");
+ $form3 = &Horde_Form::singleton('EditClientStep1Form', $vars); $edit3 = _("Edit Client Settings");
_open();
@@ -261,13 +237,6 @@
$r->submit($edit3);
$r->end();
$form3->close($r);
-
- $form4->open($r, $vars, 'admin.php', 'post');
- $r->beginActive($add4);
- $r->renderFormActive($form4, $vars);
- $r->submit($add4);
- $r->end();
- $form4->close($r);
}
require HERMES_TEMPLATES . '/common-footer.inc';
Index: hermes/README
===================================================================
RCS file: /repository/hermes/README,v
retrieving revision 1.4
diff -u -r1.4 README
--- hermes/README 4 Jun 2003 01:23:30 -0000 1.4
+++ hermes/README 7 Aug 2003 18:15:52 -0000
@@ -4,10 +4,8 @@
What is Hermes?
---------------
-Hermes is a Horde Time-tracking application. It ties into Whups
-(ticket tracking) for listing clients, Turba (for contact
-information), and Kronolith (for showing calendar events). It is in
-the very initial stages of development.
+Hermes is a Horde Time-tracking application. It ties into Turba (for clients).
+It is in the very initial stages of development.
This software is OSI Certified Open Source Software.
OSI Certified is a certification mark of the Open Source Initiative.
Index: hermes/data.php
===================================================================
RCS file: /repository/hermes/data.php,v
retrieving revision 1.12
diff -u -r1.12 data.php
--- hermes/data.php 20 Jun 2003 00:46:44 -0000 1.12
+++ hermes/data.php 7 Aug 2003 18:15:52 -0000
@@ -49,14 +49,12 @@
$timedata = array();
$format = Horde::getPost('format');
$data = &Horde_Data::singleton(array('hermes', $format));
- $modules = $registry->call('projects/list');
$namecache = array();
switch ($format) {
case 'iif':
for ($i = 0; $i < count($hours); $i++) {
$timeentry = &$hours[$i];
$timeentry['item'] = $timeentry['_type_name'];
- $timeentry['client'] = $modules[$timeentry['client']];
$emp = &$timeentry['employee'];
if (isset($namecache[$emp])) {
$emp = $namecache[$emp];
Index: hermes/docs/INSTALL
===================================================================
RCS file: /repository/hermes/docs/INSTALL,v
retrieving revision 1.6
diff -u -r1.6 INSTALL
--- hermes/docs/INSTALL 31 Jul 2003 17:41:42 -0000 1.6
+++ hermes/docs/INSTALL 7 Aug 2003 18:15:52 -0000
@@ -50,19 +50,9 @@
3. A working Turba installation.
- Hermes queries Turba for clients (indirectly--it actually queries Whups,
- see the next prerequisite). It doesn't matter what type of address book
- is configured for clients, but it is a good practice to create one which
- is separate from the rest of your contacts.
-
- 4. A working Whups installation.
-
- Hermes queries Whups to determine what projects and clients are available.
- (Hermes' projects are call modules in Whups.) Whups must be installed
- and configured to use a Turba address book for clients.
-
- Note that modules must be assigned clients in Whups for those clients
- and projects to show up in Hermes.
+ Hermes queries Turba for clients. It doesn't matter what type of
+ address book is configured for clients, but it is a good practice
+ to create one which is separate from the rest of your contacts.
INSTALLING Hermes
More information about the hermes
mailing list