[hermes] PATCH: Real clients in hermes.

Jason M. Felice jfelice at cronosys.com
Wed Jul 16 13:55:02 PDT 2003


Depends on Bo Daley's patches.  Lists Client:Job pairs.  Clients:Job
associations are from Whups (the job is still the module name).  If the
module isn't assigned to any client, it will not appear in the list.

(In the near future I'll add a flag in whups to indicate that _all_ clients
are assigned to a module.  I need this, for example, for my marketing
tickets, or for my "Cronosys" module).

-- 
 Jason M. Felice
 Cronosys, LLC <http://www.cronosys.com/>
 216.221.4600 x302
-------------- next part --------------
? hermes/scripts/update_clientjob_id.sql
Index: whups/lib/api.php
===================================================================
RCS file: /repository/whups/lib/api.php,v
retrieving revision 1.43
diff -u -u -r1.43 api.php
--- whups/lib/api.php	11 Jul 2003 20:18:18 -0000	1.43
+++ whups/lib/api.php	16 Jul 2003 20:47:52 -0000
@@ -516,44 +516,63 @@
 
 function _whups_getListTypes()
 {
-    return array('taskHash' => true);
+    return array('taskHash' => true, 'clientProjects' => true);
 }
 
 function _whups_listAs($type)
 {
-    if ($type != 'taskHash') {
-        return array();
-    }
-
-    require_once dirname(__FILE__) . '/base.php';
-    global $whups;
-    $info = array('owner' => Auth::getAuth(),
-                  'nores' => true);
-    $tickets = &$whups->getTicketsByProperties($info);
-    if (is_a($tickets, 'PEAR_Error')) {
-        return $tickets;
-    }
-    $result = array();
-    foreach ($tickets as $ticket) {
-        $view_link = Horde::addParameter(Horde::applicationUrl('details.php'), 'id', $ticket['id']);
-        $delete_link = Horde::addParameter($view_link, 'action', 'dt');
-        $complete_link = Horde::addParameter($view_link, 'action', 'ss');
-
-        $result['whups/' . $ticket['id']] = array(
-            'task_id'           => $ticket['id'],
-            'priority'          => $ticket['_priority_name'],
-            'tasklist_id'       => '**EXTERNAL**',
-            'completed'         => ($ticket['_state_category'] == 'resolved'),
-            'name'              => $ticket['_module_name'] . ' #' .
-                                   $ticket['id'] . ' - ' . $ticket['summary'],
-            'desc'              => null,
-            'due'               => null,
-            'category'          => null,
-            'view_link'         => $view_link,
-            'delete_link'       => $delete_link,
-            'edit_link'         => $view_link,
-            'complete_link'     => $complete_link
-            );
+    switch ($type) {
+    case 'taskHash':
+        require_once dirname(__FILE__) . '/base.php';
+        global $whups;
+        $info = array('owner' => Auth::getAuth(),
+                      'nores' => true);
+        $tickets = &$whups->getTicketsByProperties($info);
+        if (is_a($tickets, 'PEAR_Error')) {
+            return $tickets;
+        }
+        $result = array();
+        foreach ($tickets as $ticket) {
+            $view_link = Horde::addParameter(Horde::applicationUrl('details.php'), 'id', $ticket['id']);
+            $delete_link = Horde::addParameter($view_link, 'action', 'dt');
+            $complete_link = Horde::addParameter($view_link, 'action', 'ss');
+
+            $result['whups/' . $ticket['id']] = array(
+                'task_id'           => $ticket['id'],
+                'priority'          => $ticket['_priority_name'],
+                'tasklist_id'       => '**EXTERNAL**',
+                'completed'         => ($ticket['_state_category'] == 'resolved'),
+                'name'              => $ticket['_module_name'] . ' #' .
+                                       $ticket['id'] . ' - ' . $ticket['summary'],
+                'desc'              => null,
+                'due'               => null,
+                'category'          => null,
+                'view_link'         => $view_link,
+                'delete_link'       => $delete_link,
+                'edit_link'         => $view_link,
+                'complete_link'     => $complete_link
+                );
+        }
+        break;
+
+    case 'clientProjects':
+        require_once dirname(__FILE__) . '/base.php';
+        global $whups;
+
+        $result = array();
+        $modules = Whups::permissionsFilter($whups->getModules(), 'module', _PERMS_READ);
+
+        foreach ($modules as $module_id => $module) {
+            $clients = $whups->getClients((string)$module_id);
+            foreach ($clients as $key => $name) {
+                $result[$key.':'.$module_id] = $name.':'.$module;
+            }
+        }
+        break;
+
+    default:
+        $result = array();
+        break;
     }
 
     return $result;
Index: hermes/lib/Hermes.php
===================================================================
RCS file: /repository/hermes/lib/Hermes.php,v
retrieving revision 1.8
diff -u -u -r1.8 Hermes.php
--- hermes/lib/Hermes.php	14 Jul 2003 15:55:18 -0000	1.8
+++ hermes/lib/Hermes.php	16 Jul 2003 20:47:52 -0000
@@ -24,7 +24,8 @@
         static $clientjobs;
 
         if (is_null($clientjobs)) {
-            $clientjobs = $GLOBALS['registry']->call('projects/list');
+            $clientjobs = $GLOBALS['registry']->call('projects/listAs',
+                array('clientProjects'));
         }
 
         return $clientjobs;
Index: hermes/lib/TimeForm.php
===================================================================
RCS file: /repository/hermes/lib/TimeForm.php,v
retrieving revision 1.15
diff -u -u -r1.15 TimeForm.php
--- hermes/lib/TimeForm.php	27 Apr 2003 00:27:33 -0000	1.15
+++ hermes/lib/TimeForm.php	16 Jul 2003 20:47:52 -0000
@@ -120,7 +120,7 @@
         $this->addHidden('', 'timestamp', 'int', true);
         $this->addVariable(_("Date"), 'date[]', 'enum', true, false, null, array($date_values));
 
-        $cli = &$this->addVariable(_("Client"), 'client[]', $clienttype, true, false, null, $clientparams);
+        $cli = &$this->addVariable(_("Client:Job"), '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"), 'client[]', $clienttype, true, false, null, $clientparams);
+        $this->addVariable(_("Client:Job"), 'client[]', $clienttype, true, false, null, $clientparams);
         $this->addVariable(_("Job Type"), 'type[]', $typetype, true, false, null, $typeparams);
         $this->addVariable(_("Hours"), 'hours[]', 'number', true);
 
@@ -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"), 'client[]', $clienttype, true, false, null, $clientparams);
+        $cli = &$this->addVariable(_("Client:Job"), '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"), 'client[]', $clienttype, false, true, null, $clientparams);
+        $this->addVariable(_("Client:Job"), '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/Driver/sql.php
===================================================================
RCS file: /repository/hermes/lib/Driver/sql.php,v
retrieving revision 1.13
diff -u -u -r1.13 sql.php
--- hermes/lib/Driver/sql.php	4 Jul 2003 17:58:55 -0000	1.13
+++ hermes/lib/Driver/sql.php	16 Jul 2003 20:47:52 -0000
@@ -18,8 +18,7 @@
  *      'port'          The port on which to connect to the database.
  *
  * The table structure can be created by the
- * scripts/drivers/hermes.sql script. The needed tables are
- * hermes_billables and hermes_timesheets.
+ * scripts/drivers/hermes.sql script.
  *
  * @author  Chuck Hagenbuch <chuck at horde.org
  * @version $Revision: 1.1 $
@@ -77,11 +76,11 @@
                 continue;
             }
             $timeslice_id = $this->_db->nextId('hermes_timeslices');
-            $sql = sprintf('INSERT INTO hermes_timeslices (timeslice_id, client_id, employee_id, jobtype_id,' .
+            $sql = sprintf('INSERT INTO hermes_timeslices (timeslice_id, clientjob_id, employee_id, jobtype_id,' .
                            ' timeslice_hours, timeslice_isbillable, timeslice_date, timeslice_description, timeslice_note)' .
-                           ' VALUES (%d, %d, %s, %s, %s, %s, %d, %s, %s)',
+                           ' VALUES (%d, %s, %s, %s, %s, %s, %d, %s, %s)',
                            (int)$timeslice_id,
-                           (int)$info['client'],
+                           $this->_db->quote($info['client']),
                            $this->_db->quote($employee),
                            $this->_db->quote($info['type']),
                            $this->_db->quote($info['hours']),
@@ -133,11 +132,11 @@
                                (int)$info['id']);
             } else {
                 $sql = sprintf('UPDATE hermes_timeslices SET' .
-                               ' client_id = %d, jobtype_id = %s,' .
+                               ' clientjob_id = %s, jobtype_id = %s,' .
                                ' timeslice_hours = %s, timeslice_isbillable = %d,' .
                                ' timeslice_date = %d, timeslice_description = %s, timeslice_note = %s' .
                                ' WHERE timeslice_id = %d',
-                               (int)$info['client'],
+                               $this->_db->quote($info['client']),
                                $this->_db->quote($info['type']),
                                (float)$info['hours'],
                                isset($info['billable']) ? (int)$info['billable'] : 0,
@@ -163,7 +162,7 @@
         $this->_connect();
 
         $sql = sprintf('SELECT b.timeslice_id as id,' .
-                       ' b.client_id as client,' .
+                       ' b.clientjob_id as client,' .
                        ' b.employee_id as employee,' .
                        ' b.jobtype_id as type,' .
                        ' j.jobtype_name as _type_name,' .
@@ -207,7 +206,7 @@
             }
         }
 
-        $sql .= ' ORDER BY timeslice_date, client_id';
+        $sql .= ' ORDER BY timeslice_date, clientjob_id';
 
         Horde::logMessage($sql, __FILE__, __LINE__, PEAR_LOG_DEBUG);
         $hours = $this->_db->getAll($sql, DB_FETCHMODE_ASSOC);
@@ -349,7 +348,7 @@
             $exportid = null;
         }
 
-        $exists = 'SELECT clientjob_id FROM hermes_clientjobs WHERE clientjob_id = ' . (int)$clientJobID;
+        $exists = 'SELECT clientjob_id FROM hermes_clientjobs WHERE clientjob_id = ' . $this->_db->quote($clientJobID);
         if ($this->_db->getOne($exists) !== $clientJobID) {
             $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) . ')');
Index: hermes/scripts/drivers/hermes.sql
===================================================================
RCS file: /repository/hermes/scripts/drivers/hermes.sql,v
retrieving revision 1.9
diff -u -u -r1.9 hermes.sql
--- hermes/scripts/drivers/hermes.sql	14 Jul 2003 16:33:05 -0000	1.9
+++ hermes/scripts/drivers/hermes.sql	16 Jul 2003 20:47:52 -0000
@@ -2,7 +2,7 @@
 
 CREATE TABLE hermes_timeslices (
     timeslice_id           INT NOT NULL,
-    client_id              INT NOT NULL,
+    clientjob_id           VARCHAR(255) NOT NULL,
     employee_id            VARCHAR(255) NOT NULL,
     jobtype_id             VARCHAR(100) NOT NULL,
     timeslice_hours        NUMERIC(10, 2) NOT NULL,
@@ -17,15 +17,6 @@
     PRIMARY KEY (timeslice_id)
 );
 
-CREATE TABLE hermes_timesheets (
-    timesheet_id          INT NOT NULL,
-    client_id             INT NOT NULL,
-    timesheet_timesheet   TEXT NOT NULL,
-    timesheet_signature   TEXT,
-
-    PRIMARY KEY (timesheet_id)
-);
-
 CREATE TABLE hermes_jobtypes (
     jobtype_id    INT NOT NULL,
     jobtype_name  VARCHAR(255),
@@ -34,7 +25,7 @@
 );
 
 CREATE TABLE hermes_clientjobs (
-    clientjob_id                INT NOT NULL,
+    clientjob_id                VARCHAR(255) NOT NULL,
     clientjob_enterdescription  SMALLINT NOT NULL DEFAULT 1,
     clientjob_exportid          VARCHAR(255),
 
@@ -42,6 +33,5 @@
 );
 
 GRANT SELECT, INSERT, UPDATE, DELETE ON hermes_timeslices TO horde;
-GRANT SELECT, INSERT, UPDATE, DELETE ON hermes_timesheets TO horde;
 GRANT SELECT, INSERT, UPDATE, DELETE ON hermes_jobtypes TO horde;
 GRANT SELECT, INSERT, UPDATE, DELETE ON hermes_clientjobs TO horde;


More information about the hermes mailing list