DB_List($Doc, $DBObj, $functionalFields); $this->type = $type; } function getAddonWhere() { if ($this->type == 'mncar') { $w = '((Member.id_mncar_type IN (1, 2, 3, 4) AND Member.id_mncar_status IN(1, 3)) ' . 'OR (Member.id_mncar_l_type = 1 AND Member.id_mncar_l_status IN(1, 3)))'; } else { $w = 'Member.id_mncar_l_type IN (2, 3, 4) AND Member.id_mncar_l_status IN(1, 3)'; } if (count($this->businessTypes)) { $types = array(); $other = false; foreach ($this->businessTypes as $key => $businessType) { if ((int)$businessType) { if ($key == -1) { $other = true; } $types[] = (int)$key; } } if (count($types)) { $w .= " AND (Member.id IN (SELECT member_id FROM {$this->DBObj->db->tblMember2TypeOfBusiness} WHERE type_of_business_id IN (" . implode(',', $types) . ')' . ($other?' OR other_type_of_business <> ""':'') . '))'; } } return $w; } function _getList() { $opt = array( 'order_by' => $this->order_by, 'start' => $this->pageNum * $this->ipp, 'ipp' => $this->ipp, ); $opt['addonWhere'] = ' AND ' . $this->getAddonWhere(); $list = $this->DBObj->getList4Grid($opt); if (($this->pageNum + 1) > $list['num_pages'] && $list['num_pages'] > 0) { $this->pageNum = $list['num_pages'] - 1; $opt['start'] = $this->pageNum * $this->ipp; $list = $this->DBObj->getList4Grid($opt); } return $list; } function exec() { $this->bind(); $list = $this->_getList(); $item = get_object_vars($this); $alph = $this->DBObj->getAlphabet($this->ipp, $this->DBObj->_getWhere4Grid() . ' AND ' . $this->getAddonWhere()); $this->showAlphabet($alph); $item['tpl'] = BASE_PATH . '/tpl/Member/Roster/list.tpl'; $item['column'] = $this->getColumns(); unset($item['Doc']); unset($item['DBObj']); $item['pager_link'] = $this->_getBaseLink().'order_by='.urlencode($this->order_by).'&'; $item['num_rows'] = $list['num_rows']; $item['num_pages'] = $list['num_pages']; $item['items'] = $list['list']; $this->Doc->tplPlugins[] = 'class/DB/List/plugins'; $this->Doc->addContent($item); return true; } function showAlphabet($alph) { if (is_array($alph) && !empty($alph)) { $this->Doc->addContent(array( 'tpl' => 'Member/Roster/alphabet.tpl', 'url' => $this->_getBaseLink() . 'page=', 'data' => $alph, )); } return true; } }