anjhar

member_model

Nov 24th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. <?php
  2.  
  3. class Member_Model extends BF_Model {
  4.  
  5. protected $table = "member";
  6. protected $key = "iid_member";
  7.  
  8. function load_member($id) {
  9. $this->db->where("member.".$this->key, $id);
  10. $this->db->join("profil_sekolah", $this->table.".iid_profil_sekolah = profil_sekolah.iid_profil_sekolah");
  11. $query = $this->db->get($this->table);
  12. //$query = $this->db->query("select * from member where ".$this->key."=".$id);
  13. if ($query->num_rows == 1) {
  14. return $query->row_array();
  15. }
  16. return NULL;
  17. }
  18.  
  19. function get_json_member($data) {
  20. $records = array();
  21. $records["aaData"] = array();
  22.  
  23. $this->db->where(array('profil_sekolah.idelete' => '0', "profil_sekolah.imember" => "1"));
  24. $this->db->join("profil_sekolah", $this->table.".iid_profil_sekolah = profil_sekolah.iid_profil_sekolah");
  25. $query = $this->db->get($this->table);
  26.  
  27. $itotalrecords = $query->num_rows();
  28.  
  29. $idisplaylength = intval($data['iDisplayLength']);
  30. $idisplaylength = $idisplaylength < 0 ? $itotalrecords : $idisplaylength;
  31. $idisplaystart = intval($data['iDisplayStart']);
  32. $secho = intval($data['sEcho']);
  33.  
  34. $end = $idisplaystart + $idisplaylength;
  35. $end = $end > $itotalrecords ? $itotalrecords : $end;
  36.  
  37. $records["sStatus"] = "OK"; // pass custom message(useful for getting status of group actions)
  38. $records["sMessage"] = "Group action successfully has been completed. Well done!"; // pass custom message(useful for getting status of group actions)
  39.  
  40. $records["sEcho"] = $secho;
  41. $records["iTotalRecords"] = $itotalrecords;
  42. $records["iTotalDisplayRecords"] = $itotalrecords;
  43.  
  44. $this->db->join("profil_sekolah", $this->table.".iid_profil_sekolah = profil_sekolah.iid_profil_sekolah");
  45. $this->db->join("paket", $this->table.".ipaket = paket.iid_paket");
  46. $this->db->where("profil_sekolah.imember","1");
  47.  
  48. if ($this->soft_deletes === TRUE)
  49. $this->db->where("profil_sekolah.idelete","0");
  50.  
  51. $query = $this->db->get($this->table, $idisplaylength,$idisplaystart);
  52.  
  53. foreach ($query->result_array() as $row) {
  54. $straksi = '';
  55. if ($data['ubah'] == 1)
  56. $straksi .= '<a href="#" onclick=editdata("' . $row[$this->key] . '") class="btn green btn-xs default" title="Edit"><i class="fa fa-edit"></i></a> ';
  57. if ($data['hapus'] == 1)
  58. $straksi .= '<a href="#" onclick=deletedata("' . $row[$this->key] . '") class="btn red btn-xs default" title="Delete"><i class="fa fa-times"></i></a> ';
  59.  
  60. $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> ';
  61. $straksi .= '<a href="#" onclick=importdata("' . $row[$this->key] . '") class="btn btn-xs default" title="'.$this->lang->line('import').'"><i class="fa fa-download"></i></a> ';
  62. $row['aksi'] = $straksi;
  63. $row['jumlah_siswa'] = $row['siswa_l'] + $row['siswa_p'];
  64. $row['jumlah_pegawai'] = $row['pegawai_l'] + $row['pegawai_p'];
  65.  
  66. $records["aaData"][] = array(
  67. $row['cnama_sekolah'],
  68. $row['ckode'],
  69. $row['ckabupaten'],
  70. $row['cpropinsi'],
  71. $row['dtgl_awal'],
  72. $row['dtgl_akhir'],
  73. $row['vnama_paket'],
  74. $row['jumlah_siswa'],
  75. $row['jumlah_pegawai'],
  76. $row['imaks_siswa'],
  77. $row['imaks_sms'],
  78. $row['webkey'],
  79. $row['aksi']
  80. );
  81. }
  82.  
  83. echo json_encode($records);
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment