public static function quickLink($subject, $module = null, $getVars = null, $target = null, $title = null, $class_name = null) { $link = new PHPWS_Link($subject, $module, $getVars); $link->setTarget($target); if (!empty($title)) { $link->setTitle($title); } if (!empty($class_name)) { $link->setClass($class_name); } $link->rewrite = false; return $link; }
/** * Returns a set of links to navigate the different calendar views * * @param string current_view Name of the current view * @return string */ public function viewLinks($current_view) { if (!$this->calendar->schedule->id) { return null; } $no_follow = PHPWS_Settings::get('calendar', 'no_follow'); $vars = PHPWS_Text::getGetValues(); unset($vars['module']); // if ($current_view == 'grid') { // $vars['date'] = $this->calendar->today; // } if (isset($_REQUEST['m']) && isset($_REQUEST['y']) && isset($_REQUEST['d'])) { $vars['date'] = mktime(0, 0, 0, $_REQUEST['m'], $_REQUEST['d'], $_REQUEST['y']); unset($vars['m']); unset($vars['d']); unset($vars['y']); } $links['today'] = $this->todayLink($current_view); if ($current_view == 'event') { $vars['date'] = $this->event->start_time; } if (isset($this->calendar->schedule)) { $vars['sch_id'] = $this->calendar->schedule->id; } // Get the values for the left and right arrows in a month view if ($current_view == 'list' || $current_view == 'grid') { $oMonth = $this->calendar->getMonth(); $left_arrow_time = $oMonth->prevMonth('timestamp'); $right_arrow_time = $oMonth->nextMonth('timestamp'); $left_link_title = dgettext('calendar', 'Previous month'); $right_link_title = dgettext('calendar', 'Next month'); } if ($current_view == 'grid') { //$links['GRID'] = dgettext('calendar', 'Grid'); } else { $vars['view'] = 'grid'; $glink = new PHPWS_Link(dgettext('calendar', 'Month Grid'), 'calendar', $vars); $glink->setNoFollow($no_follow); $glink->addClass('btn btn-default'); $links['GRID'] = $glink->get(); } if ($current_view == 'list') { //$links['LIST'] = dgettext('calendar', 'Month'); } else { $vars['view'] = 'list'; $glink = new PHPWS_Link(dgettext('calendar', 'Month list'), 'calendar', $vars); $glink->addClass('btn btn-default'); $glink->setNoFollow($no_follow); $links['LIST'] = $glink->get(); } if ($current_view == 'week') { require_once 'Calendar/Week.php'; $oWeek = $this->calendar->getWeek(); $left_arrow_time = $oWeek->prevWeek('timestamp'); $right_arrow_time = $oWeek->nextWeek('timestamp'); $left_link_title = dgettext('calendar', 'Previous week'); $right_link_title = dgettext('calendar', 'Next week'); } else { $vars['view'] = 'week'; $wlink = new PHPWS_Link(dgettext('calendar', 'Week'), 'calendar', $vars); $wlink->setNoFollow($no_follow); $wlink->addClass('btn btn-default'); $links['WEEK'] = $wlink->get(); } if ($current_view == 'day') { require_once 'Calendar/Day.php'; $oDay = new Calendar_Day($this->calendar->int_year, $this->calendar->int_month, $this->calendar->int_day); $left_arrow_time = $oDay->prevDay('timestamp'); $right_arrow_time = $oDay->nextDay('timestamp'); $left_link_title = dgettext('calendar', 'Previous day'); $right_link_title = dgettext('calendar', 'Next day'); $links['DAY_LINK'] = dgettext('calendar', 'Day'); } else { $vars['view'] = 'day'; $dlink = new PHPWS_Link(dgettext('calendar', 'Day'), 'calendar', $vars); $dlink->addClass('btn btn-default'); $dlink->setNoFollow($no_follow); $links['DAY_LINK'] = $dlink->get(); } $vars['view'] = $current_view; if (!empty($left_arrow_time)) { $vars['date'] = $left_arrow_time; $larrow = new PHPWS_Link('<i class="fa fa-chevron-left"></i> ', 'calendar', $vars); $larrow->addClass('btn btn-default'); $larrow->setTitle($left_link_title); $larrow->setNoFollow($no_follow); $links['LEFT_ARROW'] = $larrow->get(); } if (!empty($right_arrow_time)) { $vars['date'] = $right_arrow_time; $rarrow = new PHPWS_Link(' <i class="fa fa-chevron-right"></i>', 'calendar', $vars); $rarrow->addClass('btn btn-default'); $rarrow->setTitle($right_link_title); $rarrow->setNoFollow($no_follow); $links['RIGHT_ARROW'] = $rarrow->get(); } return $links; }
public function dailyReport($print = false) { PHPWS_Core::initCoreClass('Link.php'); $this->loadStaffList(); if (empty($this->staff_list)) { $this->content = dgettext('checkin', 'No staff have been created.'); return; } $tpl = array(); if (isset($_GET['udate'])) { $udate = (int) $_GET['udate']; } elseif (isset($_GET['cdate'])) { $udate = strtotime($_GET['cdate']); } else { $udate = mktime(0, 0, 0); } $current_date = strftime('%m/%d/%Y', $udate); $this->title = sprintf(dgettext('checkin', 'Report for %s'), strftime('%e %B, %Y', $udate)); if (!$print) { $form = new PHPWS_Form('report-date'); $form->setMethod('get'); $form->addHidden('module', 'checkin'); $form->addText('cdate', $current_date); $form->setExtra('cdate', 'class="datepicker"'); $form->addHidden('aop', 'report'); $form->setLabel('cdate', dgettext('checkin', 'Date')); $form->addSubmit('daily_report', dgettext('checkin', 'Go')); $tpl = $form->getTemplate(); javascript('datepicker'); $tpl['PRINT_LINK'] = PHPWS_Text::secureLink(dgettext('checkin', 'Print view'), 'checkin', array('aop' => 'report', 'print' => 1, 'udate' => $udate, 'daily_report' => 1)); $tpl['REPEAT_VISITS'] = PHPWS_Text::moduleLink(dgettext('checkin', 'Repeat visits'), 'checkin', array('aop' => 'repeats', 'date' => $udate)); } $tObj = new PHPWS_Template('checkin'); $tObj->setFile('daily_report.tpl'); $this->loadStaffList(); $reasons = $this->getReasons(); if (empty($reasons)) { $reasons[0] = dgettext('checkin', 'No reason'); } PHPWS_Core::initModClass('checkin', 'Visitors.php'); $db = new PHPWS_DB('checkin_visitor'); $db->addWhere('start_meeting', $udate, '>='); $db->addWhere('end_meeting', $udate + 86400, '<'); $db->addWhere('finished', 1); $db->setIndexBy('assigned', true); $visitors = $db->getObjects('Checkin_Visitor'); foreach ($this->staff_list as $staff) { $row = array(); $row['NAME_LABEL'] = dgettext('checkin', 'Name, Reason, & Note'); $row['WAITED_LABEL'] = dgettext('checkin', 'Waited'); $row['SPENT_LABEL'] = dgettext('checkin', 'Visited'); $row['ARRIVAL_LABEL'] = dgettext('checkin', 'Arrived'); $average_wait = $total_wait = $count = $total_spent = $total_visit = 0; if (isset($visitors[$staff->id])) { foreach ($visitors[$staff->id] as $vis) { $wait = $vis->start_meeting - $vis->arrival_time; $spent = $vis->end_meeting - $vis->start_meeting; if (isset($reasons[$vis->reason])) { $reason = $reasons[$vis->reason]; } else { $reason = '<em>' . dgettext('checkin', 'System missing reason') . '</em>'; } $tObj->setCurrentBlock('subrow'); $data = array('VIS_NAME' => PHPWS_Text::moduleLink($vis->getName(), 'checkin', array('aop' => 'visitor_report', 'vis_id' => $vis->id)), 'REASON' => $reason, 'ARRIVAL' => strftime('%r', $vis->arrival_time), 'NOTE' => $vis->note, 'WAITED' => Checkin::timeWaiting($wait), 'SPENT' => Checkin::timeWaiting($spent)); if (!empty($vis->email)) { $data['EMAIL'] = '<a href="mailto:' . $vis->email . '">' . $vis->email . '</a>'; } $tObj->setData($data); $tObj->parseCurrentBlock(); if ($spent >= 0) { $count++; $total_wait += $wait; $total_spent += $spent; } } //prevent divide by zero if ($count >= 1) { $average_wait = floor($total_wait / $count); } else { $average_wait = 0; } } else { $tObj->setCurrentBlock('message'); $tObj->setData(array('NOBODY' => dgettext('checkin', 'No visitors seen'))); $tObj->parseCurrentBlock(); } $tObj->setCurrentBlock('row'); $link = new PHPWS_Link($staff->display_name, 'checkin', array('aop' => 'month_report', 'staff_id' => $staff->id, 'date' => $udate), true); $link->setTitle(dgettext('checkin', 'See monthly totals')); $row['DISPLAY_NAME'] = $link->get(); $row['VISITORS_SEEN'] = sprintf(dgettext('checkin', 'Visitors seen: %s'), $count); if ($count) { $row['TOTAL_SPENT'] = sprintf(dgettext('checkin', 'Total time in meeting: %s'), Checkin::timeWaiting($total_spent)); $row['TOTAL_WAIT'] = sprintf(dgettext('checkin', 'Total wait time: %s'), Checkin::timeWaiting($total_wait)); $row['AVERAGE_WAIT'] = sprintf(dgettext('checkin', 'Average wait time: %s'), Checkin::timeWaiting($average_wait)); } $tObj->setData($row); $tObj->parseCurrentBlock(); } $start_date = mktime(0, 0, 0, date('m', $udate), 1, date('Y', $udate)); $end_date = mktime(0, -1, 0, date('m', $udate) + 1, 1, date('Y', $udate)); $tObj->setData($tpl); $this->content = $tObj->get(); }