function downloadLink($startdate, $enddate) { if ($this->calendar->schedule->allowICalDownload()) { $dl['uop'] = 'ical_dl'; $dl['sch_id'] = $this->calendar->schedule->id; $dl['sdate'] = $startdate; $dl['edate'] = $enddate; $icon = Icon::show('download'); $download = new PHPWS_Link($icon, 'calendar', $dl); $download->setNoFollow(); return $download->get(); } else { return null; } }
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(); }
private function pageLinks(&$tpl) { $db = new PHPWS_DB('ps_page'); $db->addWhere('deleted', 0); $db->addColumn('id'); $db->addColumn('page_order'); $db->setIndexBy('page_order'); $db->addOrder('page_order asc'); if ($this->parent_page) { $db->addWhere('id', $this->parent_page); $db->addWhere('parent_page', $this->parent_page, null, 'or'); } else { $db->addWhere('parent_page', $this->id); } $pages = $db->select('col'); if (PHPWS_Error::logIfError($pages) || empty($pages)) { return; } if (!$this->parent_page) { array_unshift($pages, $this->id); } if ($this->page_order) { $prev_page = $pages[$this->page_order - 1]; } else { $prev_page = 0; } foreach ($pages as $page_no => $id) { if ($page_no == 0 && $prev_page) { $link = new PHPWS_Link('<span><<</span> ' . dgettext('pagesmith', 'Previous'), 'pagesmith', array('id' => $prev_page)); $links[] = $link->get(); } if ($id == $this->id) { $links[] = $page_no + 1; if (isset($pages[$page_no + 1])) { $next_page = $pages[$page_no + 1]; } else { $next_page = null; } } else { $link = new PHPWS_Link($page_no + 1, 'pagesmith', array('id' => $id)); $link->setRewrite(); $links[] = $link->get(); } } if ($next_page) { $link->setLabel(dgettext('pagesmith', 'Next') . ' <span>>></span>'); $link->setValue('id', $next_page); $links[] = $link->get(); } $tpl['PAGE_LINKS'] = implode(' | ', $links); }
public function getViewLink($bare = false) { $link = new PHPWS_Link(dgettext('blog', 'View'), 'blog', array('id' => $this->id)); $link->rewrite = MOD_REWRITE_ENABLED; if ($bare) { return $link->getAddress(); } else { return $link->get(); } }