Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Member_Model extends BF_Model {
- private $db_import = null;
- function __construct() {
- parent::__construct();
- $this->db_import = $this->load->database('import',TRUE);
- }
- function import_connection($id) {
- //ambil data username + password
- $this->db->where("member.".$this->key, $id);
- $this->db->join("profil_sekolah", $this->table.".iid_profil_sekolah = profil_sekolah.iid_profil_sekolah");
- $query = $this->db->get($this->table);
- if ($query->num_rows == 1) {
- return $query->row_array();
- }
- return NULL;
- //isi sesuai result
- $dsn = 'dbdriver://username:password@hostname/database?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir=/path/to/cache';
- $this->db_import = $this->load->database($dsn, TRUE);
- }
- function pegawai_l()
- {
- /*
- $query = "SELECT COUNT(cid_jenis_kelamin) as 'pegawai_l' FROM pegawai WHERE `cid_jenis_kelamin`='l'";
- $result = $this->db_import->query($query);
- return $result->row_array();
- *
- */
- $query = $this->db_import->query('SELECT COUNT(cid_jenis_kelamin) as pegawai_l FROM pegawai WHERE cid_jenis_kelamin="l"');
- $result = $query->result();
- return $result[0]->pegawai_l;
- //return $result->result();
- /*
- $results = array();
- $this->db_import->select('COUNT(cid_jenis_kelamin) as pegawai_l')
- ->from('siswa')
- ->where('cid_jenis_kelamin', "l");
- $results['pegawai_l'] = $this->db_import->get();
- return $results->row_array()->pegawai_l;
- */
- }
- function pegawai_p()
- {
- $query = $this->db_import->query('SELECT COUNT(cid_jenis_kelamin) as pegawai_p FROM pegawai WHERE cid_jenis_kelamin="p"');
- $result = $query->result();
- return $result[0]->pegawai_p;
- }
- function siswa_l()
- {
- $query = $this->db_import->query('SELECT COUNT(cid_jenis_kelamin) as siswa_l FROM siswa WHERE cid_jenis_kelamin="l"');
- $result = $query->result();
- return $result[0]->siswa_l;
- }
- function siswa_p()
- {
- $query = $this->db_import->query('SELECT COUNT(cid_jenis_kelamin) as siswa_p FROM siswa WHERE cid_jenis_kelamin="p"');
- $result = $query->result();
- return $result[0]->siswa_p;
- }
- protected $table = "member";
- protected $key = "iid_member";
- function load_member($id) {
- $this->db->where("member.".$this->key, $id);
- $this->db->join("profil_sekolah", $this->table.".iid_profil_sekolah = profil_sekolah.iid_profil_sekolah");
- $query = $this->db->get($this->table);
- //$query = $this->db->query("select * from member where ".$this->key."=".$id);
- if ($query->num_rows == 1) {
- return $query->row_array();
- }
- return NULL;
- }
- function get_sekolah_non_member()
- {
- $this->db->select('iid_profil_sekolah as id');
- $this->db->select('cnama_sekolah as name');
- $this->db->where('imember',"0");
- return $this->db->get('profil_sekolah');
- }
- /*
- function select_all()
- {
- $this->db->select('*');
- $select = $this->db->get('profile_sekolah')->result();
- return $select;
- }
- */
- function get_sum_kuota_siswa(){
- $this->db->select_sum('imaks_siswa');
- $query = $this->db->get($this->table);
- $result = $query->result();
- return $result[0]->imaks_siswa;
- }
- function get_sum_aktiv_siswa($data){
- if($data == "l")
- $query = $this->db->query('select sum(siswa_l) as siswa from '.$this->table);
- else
- $query = $this->db->query('select sum(siswa_p) as siswa from '.$this->table);
- $result = $query->result();
- return $result[0]->siswa;
- }
- function get_sum_aktiv_pegawai($data){
- if($data == "l")
- $query = $this->db->query('select sum(pegawai_l) as pegawai from '.$this->table);
- else
- $query = $this->db->query('select sum(pegawai_p) as pegawai from '.$this->table);
- $result = $query->result();
- return $result[0]->pegawai;
- }
- function get_combo_paket(){
- $this->db->select('iid_paket as id');
- $this->db->select('vnama_paket as name');
- return $this->db->get('paket');
- }
- function get_json_member($data) {
- $records = array();
- $records["aaData"] = array();
- $this->db->where(array('profil_sekolah.idelete' => '0', "profil_sekolah.imember" => "1"));
- $this->db->join("profil_sekolah", $this->table.".iid_profil_sekolah = profil_sekolah.iid_profil_sekolah");
- $query = $this->db->get($this->table);
- $itotalrecords = $query->num_rows();
- $idisplaylength = intval($data['iDisplayLength']);
- $idisplaylength = $idisplaylength < 0 ? $itotalrecords : $idisplaylength;
- $idisplaystart = intval($data['iDisplayStart']);
- $secho = intval($data['sEcho']);
- $end = $idisplaystart + $idisplaylength;
- $end = $end > $itotalrecords ? $itotalrecords : $end;
- $records["sStatus"] = "OK"; // pass custom message(useful for getting status of group actions)
- $records["sMessage"] = "Group action successfully has been completed. Well done!"; // pass custom message(useful for getting status of group actions)
- $records["sEcho"] = $secho;
- $records["iTotalRecords"] = $itotalrecords;
- $records["iTotalDisplayRecords"] = $itotalrecords;
- $this->db->join("profil_sekolah", $this->table.".iid_profil_sekolah = profil_sekolah.iid_profil_sekolah");
- $this->db->join("paket", $this->table.".ipaket = paket.iid_paket");
- $this->db->where("profil_sekolah.imember","1");
- if ($this->soft_deletes === TRUE)
- $this->db->where("profil_sekolah.idelete","0");
- $query = $this->db->get($this->table, $idisplaylength,$idisplaystart);
- foreach ($query->result_array() as $row) {
- $straksi = '';
- if ($data['ubah'] == 1)
- $straksi .= '<a href="#" onclick=editdata("' . $row[$this->key] . '") class="btn green btn-xs default" title="Edit"><i class="fa fa-edit"></i></a> ';
- if ($data['hapus'] == 1)
- $straksi .= '<a href="#" onclick=deletedata("' . $row[$this->key] . '") class="btn red btn-xs default" title="Delete"><i class="fa fa-times"></i></a> ';
- $straksi .= '<a href="#" onclick=viewdata("' . $row[$this->key] . '") class="btn blue btn-xs default" title="'.$this->lang->line('preview').'"><i class="fa fa-search"></i></a> ';
- $straksi .= '<a href="#" onclick=importdata("' . $row[$this->key] . '") class="btn btn-xs default" id="import" title="Import"><i class="fa fa-download"></i></a> ';
- //$straksi .= '<a href="#" onclick=viewdata class="btn btn-xs default" id="import" title="import"><i class="fa fa-download"></i></a> ';
- $row['aksi'] = $straksi;
- $row['jumlah_siswa'] = $row['siswa_l'] + $row['siswa_p'];
- $row['jumlah_pegawai'] = $row['pegawai_l'] + $row['pegawai_p'];
- $records["aaData"][] = array(
- $row['cnama_sekolah'],
- $row['ckode'],
- $row['ckabupaten'],
- $row['cpropinsi'],
- $row['dtgl_awal'],
- $row['dtgl_akhir'],
- $row['vnama_paket'],
- $row['jumlah_siswa'],
- $row['jumlah_pegawai'],
- $row['imaks_siswa'],
- $row['imaks_sms'],
- $row['webkey'],
- $row['aksi']
- );
- }
- echo json_encode($records);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment