function list_drop() { $branch = new Branch(); $branch->get(); foreach ($branch as $row) { $data[''] = '[ Pilih Cabang ]'; $data[$row->branch_name] = $row->branch_name; } return $data; }
public function index($offset = 0) { $this->filter_access('Branch', 'roled_select', base_url()); $branch_list = new Branch(); switch ($this->input->get('c')) { case "1": $data['col'] = "branch_name"; break; case "2": $data['col'] = "branch_id"; break; default: $data['col'] = "branch_id"; } if ($this->input->get('d') == "1") { $data['dir'] = "DESC"; } else { $data['dir'] = "ASC"; } $data['title'] = "Branch"; $data['btn_add'] = anchor('branches/add', 'Add New', "class='btn btn-primary'"); $data['btn_home'] = anchor(base_url(), 'Home', "class='btn btn-home'"); $uri_segment = 3; $offset = $this->uri->segment($uri_segment); if ($this->input->get('search_by')) { $total_rows = $branch_list->like($_GET['search_by'], $_GET['q'])->count(); $branch_list->like($_GET['search_by'], $_GET['q'])->order_by($data['col'], $data['dir']); } else { $total_rows = $branch_list->count(); $branch_list->order_by($data['col'], $data['dir']); } $data['branch_list'] = $branch_list->get($this->limit, $offset)->all; $config['base_url'] = site_url("branches/index"); $config['total_rows'] = $total_rows; $config['per_page'] = $this->limit; $config['uri_segment'] = $uri_segment; $this->pagination->initialize($config); $data['pagination'] = $this->pagination->create_links(); $this->load->view('branches/index', $data); }
print_r(Branch::getCurrency('1')); echo '</pre>'; ?> <p style="font-weight: bold;">Update</p><p><?php $data = array(); $data['id'] = '2'; $data['address'] = "Suite 3, 22 Council St,\nHawthorn East"; $data['state'] = "Victoria"; $data['zip'] = "3123"; $data['country'] = 'AU'; $data['phone'] = '+61 03 9882 7164'; $data['fax'] = '+61 03 9882 9792'; ?> Before...<?php echo '<pre>'; print_r(Branch::get('2')); echo '</pre>'; Branch::update($data); ?> After...<?php echo '<pre>'; print_r(Branch::get('2')); echo '</pre>'; ?> <p style="font-weight: bold;">Find</p><p><?php $criteria = array('columns' => 'branches.branch, branches.address, branches.zip, branches.state, countries.country', 'match' => 'branches.phone LIKE \'%6363\'', 'joins' => 'countries ON countries.country_code = branches.country'); echo '<pre>'; print_r(Branch::find($criteria)); echo '</pre>'; ?> </p>
public static function listBranch() { $list = \Branch::get(array('user_id', 'branch_name')); return $list; }