Returns a list of available clients.
public static listClients ( string $name = '' ) : array | ||
$name | string | The string to search for in the client name. |
return | array | A hash of client_id => client_name. |
public function getClientsType() { try { $clients = Hermes::listClients(); } catch (Exception $e) { return array('invalid', array(sprintf(_("An error occurred listing clients: %s"), $e->getMessage()))); } $clients = array('' => _("- - None - -")) + $clients; return array('multienum', array($clients)); }
public function getClientType() { try { $clients = Hermes::listClients(); } catch (Hermes_Exception $e) { return array('invalid', array(sprintf(_("An error occurred listing clients: %s"), $clients->getMessage()))); } if (count($clients)) { return array('enum', array($clients)); } else { return array('invalid', array(_("There are no clients which you have access to."))); } }
public function getClientType() { try { $clients = Hermes::listClients(); } catch (Horde_Exception $e) { return array('invalid', array(sprintf(_("An error occurred listing clients: %s"), $e->getMessage()))); } if ($clients) { if (count($clients) > 1) { $clients = array('' => _("--- Select A Client ---")) + $clients; } return array('enum', array($clients)); } else { return array('invalid', array(_("There are no clients which you have access to."))); } }
public function __construct(&$vars) { parent::__construct($vars, 'editclientstep1form'); 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()); } $this->addVariable(_("Client Name"), 'client', $subtype, true, false, null, $type_params); }
/** * * @see Hermes::listClients */ public function listClients() { return Hermes::listClients(); }
try { $hours = $GLOBALS['injector']->getInstance('Hermes_Driver')->getHours(array('billable' => true, 'submitted' => true)); } catch (Exception $e) { $notification->push($e->getMessage(), 'horde.error'); Horde::url('time.php')->redirect(); } if (empty($hours)) { $notification->push(_("There is no submitted billable hours."), 'horde.warning'); Horde::url('time.php')->redirect(); } if (!$registry->hasMethod('invoices/save')) { $notification->push(_("Invoicing system is not installed."), 'horde.warning'); Horde::url('time.php')->redirect(); } $headers = array('client' => _("Client"), 'employee' => _("Employee"), '_type_name' => _("Job Type"), 'rate' => _("Rate"), 'hours' => _("Hours"), 'total' => _("Total"), 'date' => _("Date"), 'description' => _("Description"), 'note' => _("Cost Object")); $clients = Hermes::listClients(); $df = $GLOBALS['prefs']->getValue('date_format'); $list = array(); $client_keys = array(); foreach ($hours as $hour) { $id = (int) $hour['id']; $client_keys[$id] = $hour['client']; $list[$id] = array('client' => $clients[$hour['client']], 'employee' => $hour['employee'], '_type_name' => $hour['_type_name'], 'rate' => $hour['rate'], 'hours' => $hour['hours'], 'total' => $hour['rate'] * $hour['hours'], 'date' => strftime($df, $hour['date']), 'description' => $hour['description'], '_costobject_name' => $hour['_costobject_name']); } $title = _("Create invoice"); $vars = Horde_Variables::getDefaultVariables(); $form = new Horde_Form($vars, $title, 'create_invoice'); $type_params = array(array(1 => _("Yes"), 0 => _("No"))); $form->addVariable(_("Combine same clients in one invoice"), 'combine', 'enum', true, false, null, $type_params); $v = $form->addVariable(_("Select hours to be invoiced"), 'hours', 'tableset', true, false, false, array($list, $headers)); $v->setDefault(array_keys($list));
/** * Fetch client settings from storage. * * @param integer the client id * * @return array A hash of client settings. * @throws Hermes_Exception */ public function getClientSettings($clientID) { $clients = Hermes::listClients(); if (empty($clientID) || !isset($clients[$clientID])) { throw new Horde_Exception_NotFound('Does not exist'); } $sql = 'SELECT clientjob_id, clientjob_enterdescription,' . ' clientjob_exportid FROM hermes_clientjobs' . ' WHERE clientjob_id = ?'; $values = array($clientID); try { $rows = $this->_db->selectAll($sql, $values); } catch (Horde_Db_Exception $e) { throw new Hermes_Exception($e); } $clientJob = array(); foreach ($rows as $row) { $clientJob[$row['clientjob_id']] = array($row['clientjob_enterdescription'], $row['clientjob_exportid']); } if (isset($clientJob[$clientID])) { $settings = array('id' => $clientID, 'enterdescription' => $clientJob[$clientID][0], 'exportid' => $this->_convertFromDriver($clientJob[$clientID][1])); } else { $settings = array('id' => $clientID, 'enterdescription' => 1, 'exportid' => null); } $settings['name'] = $clients[$clientID]; return $settings; }
/** * Rewrite an hours array into a format useable by Horde_Data:: * * @param array $hours This is an array of the results from * $driver->getHours(). * * @return array an array suitable for Horde_Data:: */ public static function makeExportHours($hours) { if (is_null($hours)) { return null; } $clients = Hermes::listClients(); $namecache = array(); $results = array(); for ($i = 0; $i < count($hours); $i++) { $timeentry = $hours[$i]->toArray(); $timeentry['item'] = $timeentry['_type_name']; if (isset($clients[$timeentry['client']])) { $timeentry['client'] = $clients[$timeentry['client']]; } $emp =& $timeentry['employee']; if (isset($namecache[$emp])) { $emp = $namecache[$emp]; } else { $ident = $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($emp); $fullname = $ident->getValue('fullname'); if ($fullname) { $namecache[$emp] = $emp = $fullname; } else { $namecache[$emp] = $emp; } } $results[] = $timeentry; } return $results; }