/** * returns all employee checklists of the type in the constructer */ public function get_all_checklists($hidden = false) { if (!$this->type) { return false; } $args = array($this->type, false, $_SESSION['pidm']); //end array if (!$hidden) { $where = " AND NOT EXISTS( SELECT 1 FROM checklist_user_settings u WHERE u.checklist_id = p.id AND pidm = ? )"; } else { $where = " AND EXISTS( SELECT 1 FROM checklist_user_settings u WHERE u.checklist_id = p.id AND pidm = ? )"; } //end else $sql = "\n\t\t\tSELECT p.* \n\t\t\tFROM \n\t\t\t\tperson_checklists p\n\t\t\t\tJOIN phonebook.phonebook ph\n\t\t\t\t\tON ph.pidm = p.pidm\n\t\t\t\tLEFT JOIN person_checklist_meta m\n\t\t\t\t\tON m.checklist_id = p.id\n\t\t\t\t\tAND m.meta_key = 'end_date'\n\t\t\tWHERE \n\t\t\t\tp.type=?\n\t\t\tAND\n\t\t\t\tp.closed=?\n\t\t\t\t{$where}\n\t\t\tORDER BY\n\t\t\t\tm.meta_value,\n\t\t\t\tph.name_last,\n\t\t\t\tph.name_first,\n\t\t\t\tp.activity_date\n\t\t\t" . $this->sort; $this->checklists['pending'] = PSU::db('hr')->GetAll($sql, $args); if (!(bool) $this->is_incomplete) { $args = array($this->type, true, $_SESSION['pidm']); //end array $params = array('sort' => 'desc'); $this->checklists['closed'] = PSU::db('hr')->PageExecute($sql, $this->limit, $this->offset, $args); $this->pagination = PSU::paginationInfo($params, $this->checklists['closed']); $this->pagination['display_num'] = $this->pagination['display_end'] - $this->pagination['display_start'] + 1; } //end if }
/** * Portal Content browser */ public function channels($view = null, $page = 1) { if ($view == 'newest' || $view == 'popular') { $channels = MyChannel::$view($this->portal->person); } else { $channels = MyChannel::fetchAll($this->portal->person); } $data = array(); foreach ($channels as $channel) { if (ChannelAuthZ::_authz($channel->slug)) { $data[] = $channel; } } //end foreach $per_page = 20; $num_records = count($data); $data = array_slice($data, ($page - 1) * $per_page, $per_page); $overrides = array('last_page' => ceil($num_records / $per_page), 'total_records' => $num_records, 'num_rows' => count($data), 'rows_per_page' => $per_page, 'current_page' => $page); $pagination = PSU::paginationResults(PSU::paginationInfo($_GET, $results, $overrides), $data); $this->tpl->assign('channels', $pagination['items']); $this->tpl->assign('pages', $pagination); $this->tpl->assign('user_channels', MyChannel::fetchAll($this->person)); $this->tpl->display('channels.tpl'); }
/** * Executes the report and returns the data */ public function run($return_results = false) { if (!$this->params_changed && $this->records) { return $this->records; } //end if if (!$this->sql) { throw new Exception('SQL for this report is not set'); } //end if if ($this->debug) { PSU::db($this->database)->debug = $this->debug; } //end if $this->prepSQL(); // retrieve the results $this->results = $this->execute($this->execute_sql, $this->final_bind, $this->key, $this->database, $this->paging ? 'CachePageExecute' : ($GLOBALS['NO_CACHE_EXECUTE'] || $this->args['nocache'] ? 'Execute' : 'CacheExecute'), true); // parse the result set into records if ($this->results instanceof ADORecordSet) { if ($this->paging) { $this->pagination = PSU::paginationInfo($_GET, $this->results); } //end if $this->records = $this->parse_results($this->results, $this->key, $this->id); } //end if return $return_results ? $this->results : $this->records; }