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); }
/** */ public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array()) { switch ($params['id']) { case 'menu': $tree->addNode(array('id' => $parent . '__add', 'parent' => $parent, 'label' => _("Enter Time"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('hermes.png'), 'url' => Horde::url('entry.php')))); $tree->addNode(array('id' => $parent . '__search', 'parent' => $parent, 'label' => _("Search Time"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('search.png'), 'url' => Horde::url('search.php')))); break; case 'stopwatch': $tree->addNode(array('id' => $parent . '__start', 'parent' => $parent, 'label' => _("Start Watch"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('timer-start.png'), 'url' => '#', 'onclick' => Horde::popupJs(Horde::url('start.php'), array('height' => 200, 'width' => 410))))); $timers = Hermes::listTimers(); $entry = Horde::url('entry.php'); foreach ($timers as $i => $timer) { $tree->addNode(array('id' => $parent . '__timer_' . $i, 'parent' => $parent, 'label' => $timer['name'] . sprintf(" (%s)", $timer['elapsed']), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('timer-stop.png'), 'url' => $entry->add('timer', $timer['id'])))); } } }
<?php /** * Copyright 2002-2015 Horde LLC (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. */ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('hermes'); /* Determine View */ if (Hermes::showAjaxView()) { $injector->getInstance('Hermes_Ajax')->init(); require HERMES_TEMPLATES . '/dynamic/index.inc'; echo $injector->getInstance('Hermes_View_Sidebar'); $page_output->footer(); exit; } include HERMES_BASE . '/time.php'; exit;
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));
/** * Get the json representation of this slice. The resulting json contains * the following properties *<pre> * c - client id * cn - client object * co - costobject id * con - costobject name * d - date * desc - description * e - employee * h - hours * i - slice id * n - note * r - rate * s - submitted * t - type id * tn - type name * b - billable * x - can edit *</pre> * * @return array */ public function toJson() { // @TODO: DO we need the *entire* contact object? $cn = $GLOBALS['registry']->clients->getClients(array($this->_properties['client'])); $json = array('c' => $this->_properties['client'], 'cn' => current($cn), 'co' => $this->_properties['costobject'], 'con' => $this->_properties['_costobject_name'], 'd' => $this->_properties['date']->dateString(), 'desc' => $this->_properties['description'], 'e' => $this->_properties['employee'], 'h' => $this->_properties['hours'], 'i' => $this->_properties['id'], 'n' => $this->_properties['note'], 'r' => $this->_properties['rate'], 's' => $this->_properties['submitted'], 't' => $this->_properties['type'], 'tn' => $this->_properties['_type_name'], 'b' => $this->_properties['billable'], 'x' => Hermes::canEditTimeslice($this->_properties['id'])); return $json; }
<?php /** * Copyright 2005-2015 Horde LLC (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 <*****@*****.**> * @author Jan Schneider <*****@*****.**> */ require_once __DIR__ . '/lib/Application.php'; $hermes = Horde_Registry::appInit('hermes'); $vars = Horde_Variables::getDefaultVariables(); $form = new Horde_Form($vars, _("Stop Watch")); $form->addVariable(_("Stop watch description"), 'description', 'text', true); if ($form->validate($vars)) { Hermes::newTimer($vars->get('description')); echo Horde::wrapInlineScript(array('var t = ' . Horde_Serialize::serialize(sprintf(_("The stop watch \"%s\" has been started and will appear in the menu at the next refresh."), $vars->get('description')), Horde_Serialize::JSON) . ';', 'alert(t);', 'window.close();')); exit; } $page_output->topbar = $page_output->sidebar = false; $page_output->header(array('title' => _("Stop Watch"))); $form->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('start.php'), 'post'); $page_output->footer();
/** * 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; }
/** * Update a slice. @see Hermes_Slice::readForm() for the data expeted in * the posted form. * * @return array The new slice data. */ public function updateSlice() { $slice = new Hermes_Slice(); $slice->readForm(); try { $GLOBALS['injector']->getInstance('Hermes_Driver')->updateTime(array($slice)); if ($slice['employee'] == $GLOBALS['registry']->getAuth()) { $GLOBALS['notification']->push(_("Your time was successfully updated."), 'horde.success'); } else { $GLOBALS['notification']->push(sprintf(_("The time was successfully updated and saved to the time sheet of %s."), $slice['employee']), 'horde.success'); } $new = current($GLOBALS['injector']->getInstance('Hermes_Driver')->getHours(array('id' => $slice['id']))); Hermes::updateCostObject($new); return $new->toJson(); } catch (Hermes_Exception $e) { $GLOBALS['notification']->push($e, 'horde.error'); } }
<?php header('Content-type: text/plain'); if (file_exists('/opt/microservice_php/src/hermes.php')) { require_once '/opt/microservice_php/src/hermes.php'; $config = Hermes::require_file('config.php', dirname(__FILE__) . '/../config/dev/'); } else { $config = (require '../config/dev/config.php'); } $env_vars = array('MICROSERVICE_NAME', 'MICROSERVICE_ENV', 'MICROSERVICE_APP_ID', 'CONFIG_PATH'); echo $config['welcome'], "\n\n"; echo "Microservice environment variables:\n"; foreach ($env_vars as $env_var) { $value = getenv($env_var); if ($value !== false) { echo "{$env_var}: \"{$value}\"\n"; } }
function setCostObjects($vars) { $this->_costObjects->type->setValues(Hermes::getCostObjectType($vars->get('client'))); }
<?php require_once '/opt/microservice_php/src/hermes.php'; $servers_file_path = Hermes::get_config_file_path('servers.php'); if (!empty($servers_file_path)) { system('cp ' . $servers_file_path . ' /etc/phpmyadmin/conf.d/'); }
/** * Pause a timer. * * @param integer $id The timer id. * * @return boolean */ public static function pauseTimer($id) { $timer = Hermes::getTimer($id); // Avoid pausing the same timer twice. if ($timer['paused'] || $timer['time'] == 0) { return true; } $timer['paused'] = true; $timer['elapsed'] += time() - $timer['time']; $timer['time'] = 0; Hermes::updateTimer($id, $timer); return true; }
$registry->callAppMethod('hermes', 'download', array('args' => array($vars))); } catch (Horde_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); } } $title = _("Search for Time"); if (!($searchVars = $session->get('hermes', 'search_criteria'))) { $searchVars = $vars; } $form = new Hermes_Form_Search($searchVars); $page_output->header(array('title' => $title)); $notification->notify(array('listeners' => 'status')); $form->renderActive(new Horde_Form_Renderer(), $searchVars, Horde::url('search.php'), 'post'); echo '<br />'; if ($session->exists('hermes', 'search_criteria')) { echo Hermes::tabs(); if (is_null($criteria)) { $criteria = $form->getSearchCriteria($searchVars); } $table = new Hermes_Table('results', $vars, array('title' => _("Search Results"), 'name' => 'hermes/hours', 'params' => $criteria)); $template = new Horde_Template(); $template->setOption('gettext', true); $template->set('postUrl', Horde::url('time.php', false, -1)); $template->set('sessionId', Horde_Util::formInput()); $template->set('table', $table->render()); echo $template->fetch(HERMES_TEMPLATES . '/time/form.html'); } echo '<br />'; $exportForm = new Hermes_Form_Export($vars); $exportForm->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('search.php'), 'post'); $page_output->footer();
$item = $vars->get('item'); if (is_null($item) || !count($item)) { $notification->push(_("No timeslices were selected to submit."), 'horde.error'); } else { foreach (array_keys($item) as $id) { $time[] = array('id' => $id); } try { $GLOBALS['injector']->getInstance('Hermes_Driver')->markAs('submitted', $time); $notification->push(_("Your time was successfully submitted."), 'horde.success'); $vars = new Horde_Variables(); } catch (Horde_Exception $e) { $notification->push(sprintf(_("There was an error submitting your time: %s"), $e->getMessage()), 'horde.error'); } } break; } // We are displaying all time. $tabs = Hermes::tabs(); $criteria = array('employee' => $GLOBALS['registry']->getAuth(), 'submitted' => false, 'link_page' => 'time.php'); $table = new Hermes_Table('week', $vars, array('title' => _("My Unsubmitted Time"), 'name' => 'hermes/hours', 'params' => $criteria)); $template = new Horde_Template(); $template->setOption('gettext', true); $template->set('postUrl', Horde::url('time.php', false, -1)); $template->set('sessionId', Horde_Util::formInput()); $template->set('table', $table->render()); $page_output->header(array('title' => _("My Time"))); $notification->notify(array('listeners' => 'status')); echo $tabs; echo $template->fetch(HERMES_TEMPLATES . '/time/form.html'); $page_output->footer();
$notification->push(_("Your time was successfully entered."), 'horde.success', array('sticky')); $GLOBALS['injector']->getInstance('Hermes_Driver')->enterTime($GLOBALS['registry']->getAuth(), $info); } } catch (Exception $e) { Horde::log($e, 'ERR'); $notification->push(sprintf(_("There was an error storing your timesheet: %s"), $e->getMessage()), 'horde.error'); header('Location: ' . $url); exit; } } break; default: if ($vars->exists('id')) { // We are updating a specific entry, load it into the form variables. $id = $vars->get('id'); if (!Hermes::canEditTimeslice($id)) { $notification->push(_("Access denied; user cannot modify this timeslice."), 'horde.error'); Horde::url('time.php')->redirect(); } $myhours = $GLOBALS['injector']->getInstance('Hermes_Driver')->getHours(array('id' => $id)); if (is_array($myhours)) { foreach ($myhours as $item) { if (isset($item['id']) && $item['id'] == $id) { foreach ($item as $key => $value) { $vars->set($key, $value); } } } } } $form = new Hermes_Form_Time_Entry($vars);
/** * Lists timeslices as timeobjects. * * @param array $time_categories The time categories (from * listTimeObjectCategories) to list. * @param mixed $start The start date of the period. * @param mixed $end The end date of the period. * * @return array An array of timeObject results. * @throws Hermes_Exception */ public function listTimeObjects($time_categories, $start, $end) { $objects = array(); foreach ($time_categories as $category) { $params = array('start' => $start->timestamp(), 'end' => $end->timestamp(), 'submitted' => intval($category == 'submitted'), 'employee' => $GLOBALS['registry']->getAuth()); $slices = $GLOBALS['injector']->getInstance('Hermes_Driver')->getHours($params); foreach ($slices as $slice) { $cn = current($GLOBALS['registry']->clients->getClients(array($slice['client']))); $co = $slice['_costobject_name']; $tobj = array($slice['id'] => array('title' => sprintf(_("%.2f hours: %s"), $slice['hours'], empty($cn['name']) ? empty($co) ? $slice['description'] : $co : $cn['name']), 'description' => $slice->toString(), 'link' => $category == 'submitted' ? false : Hermes::url('entry', array('id' => $slice['id'])), 'start' => date('Y-m-d\\TH:i:s', $slice['date']->timestamp()), 'end' => date('Y-m-d\\TH:i:s', $slice['date']->timestamp() + $slice['hours'] * 3600))); $objects = array_merge($objects, $tobj); } } return $objects; }
/** * Stop a timer. Expects the following in $this->vars: * - t: The timer id. * - restart: * * @return array An array describing the current timer state. Contains: * - h: The total number of hours elapsed so far. * - n: A note to apply to the description field of a time slice. * - t: The new timer title, if restarting. */ public function stopTimer() { global $prefs, $notification; try { $timer = Hermes::getTimer($this->vars->t); } catch (Horde_Exception_NotFound $e) { $notification->push(_("Invalid timer requested"), 'horde.error'); return false; } $results = $timer; $tname = $timer['name']; $elapsed = (!$timer['paused'] ? time() - $timer['time'] : 0) + $timer['elapsed']; $results['h'] = round((double) $elapsed / 3600, 2); if ($prefs->getValue('add_description')) { $results['n'] = sprintf(_("Using the \"%s\" stop watch from %s %s to %s %s"), $tname, strftime($prefs->getValue('date_format_mini'), $this->vars->t), strftime($prefs->getValue('time_format'), $this->vars->t), strftime($prefs->getValue('date_format_mini'), time()), strftime($prefs->getValue('time_format'), time())); } else { $results['n'] = ''; } $notification->push(sprintf(_("The stop watch \"%s\" has been stopped."), $tname), 'horde.success'); Hermes::clearTimer($this->vars->t); if ($this->vars->restart == 'true') { $now = time(); $timer['elapsed'] = 0; $timer['paused'] = $results['paused'] = true; $timer['time'] = $now; Hermes::updateTimer($this->vars->t, $timer); } return $results; }