kurniaandi1

model

Jan 3rd, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.29 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class root_model extends ci_model {
  4. var $table = 'tbl_user';
  5. public function get_user_list()
  6. {
  7. $hasil = "";
  8. $w = $this->db->query("SELECT * FROM tbl_user ORDER BY id_user DESC ");
  9. $i = 1;
  10. if(($w->num_rows())<=0)
  11. {
  12. $hasil .="<div class='text-center font-11'>Tidak Ada Data Yang Ditemukan</div>";
  13.  
  14. }else{
  15. $hasil .= "<table class='table table-striped table-advance table-hover'>
  16. <thead>
  17. <tr>
  18. <th><i class='fa fa-us'></i> User Name</th>
  19. <th class='hidden-phone'><i class='fa fa-envelope'></i> Email</th>
  20. <th><i class='fa fa-book'></i> Alamat</th>
  21. <th><i class='fa fa-question-circle'></i> Status</th>
  22. <th><i class='fa fa-edit'></i> Action</th>
  23. </tr>
  24. </thead>";
  25. foreach ($w->result() as $h)
  26. {
  27. if ($h->aktif_user==1){
  28. $btnaktif = "<a href='".base_url()."root/user/activated/".$h->id_user."/0' onClick=\"return confirm('Jika user Anda non aktifkan maka tidak bisa login, apakah Anda yakin ?')\" class='btn btn-warning btn-xs' title='Not Aktivasi' type='button'><i class='fa fa-times-circle'></i></a>";
  29. $aktif_or_no = '<span class="label label-success label-mini">Aktif</span>';
  30. }else{
  31. $btnaktif = "<a href='".base_url()."root/user/activated/".$h->id_user."/1' onClick=\"return confirm('Apakah Anda yakin akan mengaktifkan user ?')\" class='btn btn-success btn-xs' title='Aktivasi' type='button'><i class='fa fa-check'></i></a>";
  32. $aktif_or_no = '<span class="label label-danger label-mini">Tidak Aktif</span>';
  33. }
  34. $hasil .= "<tr>
  35. <td>
  36. <a href='#'>
  37. ".$h->user_name."
  38. </a>
  39. </td>
  40. <td class='hidden-phone'>".$h->email_user."</td>
  41. <td>".$h->User_Address."</td>
  42. <td>$aktif_or_no</span></td>
  43. <td><div>
  44. <a class='btn btn-primary btn-xs' title='Edit' href='".base_url()."root/user/edit_profile/".$h->id_user."' type='button'><i class='fa fa-pencil'></i></a>
  45. $btnaktif";
  46. $hasil .= "&nbsp;<a href='".base_url()."root/user/delete/".$h->id_user."' onClick=\"return confirm('Apakah Anda yakin akan menghapus user ini ?')\" class='btn btn-danger btn-xs' title='Hapus' type='button'><i class='fa fa-trash-o'></i></a>";
  47. $hasil .= "</div>
  48. </td></tr>";
  49. }
  50. $hasil .= '</table>';
  51. }
  52. return $hasil;
  53. }
  54. public function get()
  55. {
  56. $this->db->select('*');
  57. $this->db->order_by('tanggal','asc');
  58. return $this->db->get('tbl_pendapatan');
  59. }
  60. public function agent()
  61. {
  62. $this->db->select('*');
  63. $this->db->order_by('session_id','asc');
  64. return $this->db->get('tbl_log_activities');
  65. }
  66.  
  67. public function generate_kategori($limit,$offset,$filter=array())
  68. {
  69. $hasil = "";
  70. $data_kat = $filter['cari_kategori'];
  71. $query_add = "WHERE judul_kat like '%".$data_kat."'";
  72. $tot_hal = $this->db->query("SELECT * FROM kategori ".$query_add."");
  73. $config['base_url'] = base_url() . 'admin/kategori/';
  74. $config['total_rows'] = $tot_hal->num_rows();
  75. $config['per_page'] = $limit = 5;
  76. $config['uri_segment'] = 3;
  77. $config['first_link'] = 'Pertama';
  78. $config['last_link'] = 'Terakhir';
  79. $config['next_link'] = 'LAST=>';
  80. $config['prev_link'] = '<=FIRST';
  81. $this->pagination->initialize($config);
  82. $w = $this->db->query("SELECT * FROM kategori ".$query_add." ORDER BY id ASC LIMIT ".$offset.",".$limit."");
  83. if(($w->num_rows())<=0)
  84. {
  85. $hasil .="<div class='text-center font-11'>Tidak Ada Data Yang Ditemukan</div>";
  86. }else{
  87. $hasil .= "<table class='table table-bordered table-striped table-condensed'>
  88. <thead>
  89. <tr>
  90. <th><center style='color:#ff6c60'>NO</th>
  91. <th><center style='color:#ff6c60'>NAMA KATEGORI</th>
  92. <th><center style='color:#ff6c60'>TANGGAL PUBLIKASI</th>
  93. <th><center style='color:#ff6c60'>OPTION</th>
  94. </tr>
  95. </thead>";
  96. $no = $offset+1;
  97. foreach ($w->result() as $h) {
  98. $hasil .= "<tr>
  99. <td class='text-center'>".$no."</td>
  100. <td class='text-center'>".$h->judul_kat."</td>
  101. <td class='text-center'>".$h->tanggal_publish."</td>
  102. <td class='text-center'><div class='btn-group'>
  103. <a class='btn btn-primary btn-xs' title='Edit' href='".base_url()."admin/kategori/edit_kat/".$h->id."' type='button'><i class='fa fa-pencil'></i></a>
  104. <a class='btn btn-danger btn-xs' title='Delete' href='".base_url()."admin/kategori/delete_kat/".$h->id."' type='button'><i class='fa fa-trash-o'></i></a>";
  105. $hasil .= "</div>
  106. </td></tr>";
  107. $no++;
  108. }
  109. $hasil .= '</table>';
  110. }
  111. return $hasil;
  112. }
  113.  
  114. public function generate_produk($limit,$offset,$filter=array())
  115. {
  116. $hasil = "";
  117. $data_kat = $filter['cari_produk'];
  118. $query_add = "WHERE nama_produk like '%".$data_kat."'";
  119. $tot_hal = $this->db->query("SELECT a.id_prod, a.nama_produk,a.kategori_produk, a.elm1, a.harga_produk, a.gambar_produk, b.id, b.judul_kat FROM produk a LEFT OUTER JOIN kategori b ON a.kategori_produk = b.id ".$query_add."");
  120. $config['base_url'] = base_url() . 'admin/produk/index/';
  121. $config['total_rows'] = $tot_hal->num_rows();
  122. $config['per_page'] = $limit = 5;
  123. $config['uri_segment'] = 4;
  124. $config['first_link'] = 'Pertama';
  125. $config['last_link'] = 'Terakhir';
  126. $config['next_link'] = 'LAST=>';
  127. $config['prev_link'] = '<=FIRST';
  128. $this->pagination->initialize($config);
  129. $w =
  130. $this->db->query("SELECT a.id_prod, a.nama_produk,a.kategori_produk, a.elm1, a.harga_produk, a.gambar_produk, b.id, b.judul_kat FROM produk a LEFT OUTER JOIN kategori b ON a.kategori_produk = b.id ".$query_add." ORDER BY a.id_prod DESC LIMIT ".$offset.",".$limit."");
  131.  
  132. if(($w->num_rows())<=0)
  133. {
  134. $hasil .="<div class='text-center font-11'>Tidak Ada Data Yang Ditemukan</div>";
  135. }else{
  136. $hasil .= "<table class='table table-bordered table-striped table-condensed'>
  137. <thead>
  138. <tr>
  139. <th><center style='color:#ff6c60'>NO</th>
  140. <th><center style='color:#ff6c60'>NAMA PRODUK</th>
  141. <th><center style='color:#ff6c60'>HARGA PRODUK</th>
  142. <th><center style='color:#ff6c60'>KETERANGAN PRODUK</th>
  143. <th><center style='color:#ff6c60'>GAMBAR PRODUK</th>
  144. <th><center style='color:#ff6c60'>KATEGORI</th>
  145. <th><center style='color:#ff6c60'>OPTIONS</th>
  146. </tr>
  147. </thead>";
  148. $no = $offset+1;
  149. foreach ($w->result() as $h) {
  150. $hasil .= "<tr>
  151. <td class='text-center'>".$no."</td>
  152. <td class='text-center'>".$h->nama_produk."</td>
  153. <td class='text-center'>".$h->harga_produk."</td>
  154. <td class='text-center'>".$h->elm1."</td>
  155. <td class='text-center'><img src='".base_url()."assets/produk/thumb/".$h->gambar_produk."'/></td>
  156. <td class='text-center'>".$h->judul_kat."</td>
  157. <td class='text-center'><div class='btn-group'>
  158. <a class='btn btn-primary btn-xs' title='Edit' href='".base_url()."admin/produk/edit_produk/".$h->id_prod."' type='button'><i class='fa fa-pencil'></i></a>
  159. <a class='btn btn-danger btn-xs' title='Delete' href='".base_url()."admin/produk/delete_produk/".$h->id_prod."' type='button'><i class='fa fa-trash-o'></i></a>";
  160. $hasil .= "</div>
  161. </td></tr>";
  162. $no++;
  163. }
  164. $hasil .= '</table>';
  165. }
  166. return $hasil;
  167. }
  168.  
  169.  
  170. public function generate_menu($limit,$offset,$filter=array())
  171. {
  172. $hasil = "";
  173. $data_menu = $filter['cari_menu'];
  174. $query_add = " WHERE judul_menu like '%".$data_menu."'";
  175. $tot_hal = $this->db->query("SELECT a.id_menu, a.judul_menu, a.id_author, a.isi_menu, a.tgl_publish, a.last_data_update, a.id_user_update, b.nama from tbl_menu as a join user as b on a.id_author = b.id_user".$query_add."");
  176. $config['base_url'] = base_url() . 'admin/menu/';
  177. $config['total_rows'] = $tot_hal->num_rows();
  178. $config['per_page'] = $limit = 5;
  179. $config['uri_segment'] = 3;
  180. $config['first_link'] = 'Pertama';
  181. $config['last_link'] = 'Terakhir';
  182. $config['next_link'] = '»';
  183. $config['prev_link'] = '«';
  184. $this->pagination->initialize($config);
  185. $w = $this->db->query("SELECT a.id_menu, a.judul_menu, a.id_author, a.isi_menu, a.tgl_publish, a.last_data_update, a.id_user_update, b.nama from tbl_menu as a join user as b on a.id_author = b.id_user".$query_add." ORDER BY id_menu ASC LIMIT ".$offset.",".$limit."");
  186. if(($w->num_rows())<=0)
  187. {
  188. $hasil .="<div class='text-center font-11'>Tidak Ada Data Yang Ditemukan</div>";
  189. }else{
  190. $hasil .= "<table class='table table-bordered table-striped table-condensed'>
  191. <thead>
  192. <tr>
  193. <th><center style='color:#ff6c60'>NO</th>
  194. <th><center style='color:#ff6c60'>JUDUL MENU</th>
  195. <th><center style='color:#ff6c60'>AUTHOR</th>
  196. <th><center style='color:#ff6c60'>TANGGAL PUBLISH</th>
  197. <th><center style='color:#ff6c60'>OPTION</th>
  198. </tr>
  199. </thead>";
  200. $no = $offset+1;
  201. foreach ($w->result() as $h) {
  202. $hasil .= "<tr>
  203. <td class='text-center'>".$no."</td>
  204. <td>".$h->judul_menu."</td>
  205. <td class='text-center'>".$h->nama."</td>
  206. <td class='text-center'>".$h->tgl_publish."</td>
  207. <td class='text-center'><div class='btn-group'>
  208. <a class='btn btn-white btn-sm' title='Edit' href='".base_url()."admin/menu/edit-menu/".$h->id_menu."' type='button'><i class='fa fa-pencil'></i></a>";
  209. $hasil .= "</div>
  210. </td></tr>";
  211. $no++;
  212. }
  213. $hasil .= '</table>';
  214. }
  215. return $hasil;
  216. }
  217. function count_where2($table, $where1)
  218. {
  219. $this->db->from($table);
  220. $this->db->where($where1);
  221. $count = $this->db->count_all_results();
  222. if ($count == 0)
  223. {
  224. return 0;
  225. }
  226. else
  227. {
  228. return $count;
  229. }
  230. }
  231. public function generate_page($limit,$offset,$filter=array())
  232. {
  233. $hasil = "";
  234. $data_page = $filter['cari_page'];
  235. $query_add = " WHERE judul_page like '%".$data_page."'";
  236. $tot_hal = $this->db->query("SELECT a.id_page, a.judul_page, a.id_author, a.isi_page, a.tgl_publish, a.last_data_update, a.id_user_update, b.nama from tbl_page as a join user as b on a.id_author = b.id_user".$query_add."");
  237. $config['base_url'] = base_url() . 'admin/page/';
  238. $config['total_rows'] = $tot_hal->num_rows();
  239. $config['per_page'] = $limit = 5;
  240. $config['uri_segment'] = 3;
  241. $config['first_link'] = 'Pertama';
  242. $config['last_link'] = 'Terakhir';
  243. $config['next_link'] = '»';
  244. $config['prev_link'] = '«';
  245. $this->pagination->initialize($config);
  246. $w = $this->db->query("SELECT a.id_page, a.judul_page, a.id_author, a.isi_page, a.tgl_publish, a.last_data_update, a.id_user_update, b.nama from tbl_page as a join user as b on a.id_author = b.id_user".$query_add." ORDER BY id_page ASC LIMIT ".$offset.",".$limit."");
  247. if(($w->num_rows())<=0)
  248. {
  249. $hasil .="<div class='text-center font-11'>Tidak Ada Data Yang Ditemukan</div>";
  250. }else{
  251. $hasil .= "<table class='table table-bordered table-striped table-condensed'>
  252. <thead>
  253. <tr>
  254. <th><center style='color:#ff6c60'>NO</th>
  255. <th><center style='color:#ff6c60'>JUDUL PAGE</th>
  256. <th><center style='color:#ff6c60'>AUTHOR</th>
  257. <th><center style='color:#ff6c60'>TANGGAL PUBLISH</th>
  258. <th><center style='color:#ff6c60'>OPTION</th>
  259. </tr>
  260. </thead>";
  261. $no = $offset+1;
  262. foreach ($w->result() as $h) {
  263. $hasil .= "<tr>
  264. <td class='text-center'>".$no."</td>
  265. <td>".$h->judul_page."</td>
  266. <td class='text-center'>".$h->nama."</td>
  267. <td class='text-center'>".$h->tgl_publish."</td>
  268. <td class='text-center'><div class='btn-group'>
  269. <a class='btn btn-white btn-sm' title='Edit' href='".base_url()."admin/page/edit-page/".$h->id_page."' type='button'><i class='fa fa-pencil'></i></a>";
  270. $hasil .= "</div>
  271. </td></tr>";
  272. $no++;
  273. }
  274. $hasil .= '</table>';
  275. }
  276. return $hasil;
  277. }
  278.  
  279. public function generate_blog($limit,$offset,$filter=array())
  280. {
  281. $hasil = "";
  282. $data_blog = $filter['cari_blog'];
  283. $query_add = " WHERE a.judul_blog like '%".$data_blog."%' OR b.nama like '%".$data_blog."%'";
  284. $tot_hal = $this->db->query("SELECT a.id_blog, a.judul_blog, a.id_author, a.isi_blog, a.tgl_publish, a.last_data_update, a.id_user_update, b.nama from tbl_blog as a join user as b on a.id_author = b.id_user".$query_add."");
  285. $config['base_url'] = base_url() . 'admin/blog/';
  286. $config['total_rows'] = $tot_hal->num_rows();
  287. $config['per_page'] = $limit = 5;
  288. $config['uri_segment'] = 3;
  289. $config['first_link'] = 'Pertama';
  290. $config['last_link'] = 'Terakhir';
  291. $config['next_link'] = '»';
  292. $config['prev_link'] = '«';
  293. $this->pagination->initialize($config);
  294. $w = $this->db->query("SELECT a.id_blog, a.judul_blog, a.id_author, a.isi_blog, a.tgl_publish, a.last_data_update, a.id_user_update, b.nama from tbl_blog as a join user as b on a.id_author = b.id_user".$query_add." ORDER BY a.id_blog DESC LIMIT ".$offset.",".$limit."");
  295. if(($w->num_rows())<=0)
  296. {
  297. $hasil .="<div class='text-center font-11'>Tidak Ada Data Yang Ditemukan</div>";
  298. }else{
  299.  
  300. $hasil .= "<table class='table table-bordered table-striped table-condensed'>
  301. <thead>
  302. <tr>
  303. <th><center style='color:#ff6c60'>NO</th>
  304. <th><center style='color:#ff6c60'>JUDUL</th>
  305. <th><center style='color:#ff6c60'>AUTHOR</th>
  306. <th><center style='color:#ff6c60'>TANGGAL PUBLISH</th>
  307. <th><center style='color:#ff6c60'>OPTION</th>
  308. </tr>
  309. </thead>";
  310. $no = $offset+1;
  311. foreach ($w->result() as $h) {
  312. $hasil .= "<tr>
  313. <td class='text-center'>".$no."</td>
  314. <td>".$h->judul_blog."</td>
  315. <td class='text-center'>".$h->nama."</td>
  316. <td class='text-center'>".$h->tgl_publish."</td>
  317. <td class='text-center'><div class='btn-group'>
  318. <a class='btn btn-white btn-sm' title='Edit' href='".base_url()."admin/blog/edit-blog/".$h->id_blog."' type='button'><i class='fa fa-pencil'></i></a>
  319. <a class='btn btn-white btn-sm' title='Delete' href='".base_url()."admin/blog/delete-blog/".$h->id_blog."' type='button'><i class='fa fa-trash-o'></i></a>";
  320. $hasil .= "</div>
  321. </td></tr>";
  322. $no++;
  323. }
  324. $hasil .= '</table>';
  325. }
  326. return $hasil;
  327. }
  328. function update_quote($id,$data)
  329. {
  330. $this->db->where('id_user',$id);
  331. $update = $this->db->update('tbl_user',$data);
  332. return $update;
  333. }
  334. public function generate_pesan($limit,$offset,$filter=array())
  335. {
  336. $hasil = "";
  337. $data_pesan = $filter['cari_pesan'];
  338. $query_add = "WHERE nama_pesan like '%".$data_pesan."'";
  339. $tot_hal = $this->db->query("SELECT * FROM pesan ".$query_add."");
  340. $config['base_url'] = base_url() . 'admin/pesan/';
  341. $config['total_rows'] = $tot_hal->num_rows();
  342. $config['per_page'] = $limit = 5;
  343. $config['uri_segment'] = 3;
  344. $config['first_link'] = 'Pertama';
  345. $config['last_link'] = 'Terakhir';
  346. $config['next_link'] = '»';
  347. $config['prev_link'] = '«';
  348. $this->pagination->initialize($config);
  349. $w = $this->db->query("SELECT * FROM pesan ".$query_add." ORDER BY id_pesan ASC LIMIT ".$offset.",".$limit."");
  350. if(($w->num_rows())<=0)
  351. {
  352. $hasil .="<div class='text-center font-11'>Tidak Ada Data Yang Ditemukan</div>";
  353. }else{
  354. $hasil .= "<table class='table table-bordered table-striped table-condensed'>
  355. <thead>
  356. <tr>
  357. <th><center style='color:#ff6c60'>NO</th>
  358. <th><center style='color:#ff6c60'>NAMA</th>
  359. <th><center style='color:#ff6c60'>EMAIL</th>
  360. <th><center style='color:#ff6c60'>ISI pesan</th>
  361. <th><center style='color:#ff6c60'>OPTION</th>
  362. </tr>
  363. </thead>";
  364. $no = $offset+1;
  365. foreach ($w->result() as $h) {
  366. $hasil .= "<tr>
  367. <td class='text-center'>".$no."</td>
  368. <td>".$h->nama_pesan."</td>
  369. <td class='text-center'>".$h->email_pesan."</td>
  370. <td class='text-center'>".strip_tags(substr($h->isi_pesan,0,30))."....</td>
  371. <td class='text-center'><div class='btn-group'>
  372. <a class='btn btn-primary btn-xs' title='Lihat Detail' href='".base_url()."admin/pesan/detail-pesan/".$h->id_pesan."' type='button'><i class='fa fa-eye'></i></a>
  373. <a class='btn btn-danger btn-xs' title='Delete' href='".base_url()."admin/pesan/delete-pesan/".$h->id_pesan."' type='button'><i class='fa fa-trash-o'></i></a>";
  374. $hasil .= "</div>
  375. </td></tr>";
  376. $no++;
  377. }
  378. $hasil .= '</table>';
  379. }
  380. return $hasil;
  381. }
  382.  
  383. public function generate_portofolio($limit,$offset,$filter=array())
  384. {
  385. $hasil = "";
  386. $data_portofolio = $filter['cari_portofolio'];
  387. $query_add = "WHERE nama_portofolio like '%".$data_portofolio."'";
  388. $tot_hal = $this->db->query("SELECT id_portofolio, nama_portofolio, alamat_portofolio, deskripsi_portofolio, publish_portofolio FROM tbl_portofolio ".$query_add."");
  389. $config['base_url'] = base_url() . 'admin/portofolio/';
  390. $config['total_rows'] = $tot_hal->num_rows();
  391. $config['per_page'] = $limit = 5;
  392. $config['uri_segment'] = 3;
  393. $config['first_link'] = 'Pertama';
  394. $config['last_link'] = 'Terakhir';
  395. $config['next_link'] = '»';
  396. $config['prev_link'] = '«';
  397. $this->pagination->initialize($config);
  398. $w = $this->db->query("SELECT id_portofolio, nama_portofolio, alamat_portofolio, deskripsi_portofolio, publish_portofolio FROM tbl_portofolio ".$query_add." ORDER BY id_portofolio ASC LIMIT ".$offset.",".$limit."");
  399. if(($w->num_rows())<=0)
  400. {
  401. $hasil .="<div class='text-center font-11'>Tidak Ada Data Yang Ditemukan</div>";
  402. }else{
  403. $hasil .= "<table class='table table-bordered table-striped table-condensed'>
  404. <thead>
  405. <tr>
  406. <th><center style='color:#ff6c60'>NO</th>
  407. <th><center style='color:#ff6c60'>NAMA</th>
  408. <th><center style='color:#ff6c60'>ALAMAT</th>
  409. <th><center style='color:#ff6c60'>TANGGAL PUBLISH</th>
  410. <th><center style='color:#ff6c60'>OPTION</th>
  411. </tr>
  412. </thead>";
  413. $no = $offset+1;
  414. foreach ($w->result() as $h) {
  415. $hasil .= "<tr>
  416. <td class='text-center'>".$no."</td>
  417. <td>".$h->nama_portofolio."</td>
  418. <td class='text-center'><a href='".$h->alamat_portofolio."' taget='blank'>".$h->alamat_portofolio."</a></td>
  419. <td class='text-center'>".$h->publish_portofolio."</td>
  420. <td class='text-center'><div class='btn-group'>
  421. <a class='btn btn-white btn-sm' title='Edit' href='".base_url()."admin/portofolio/edit-portofolio/".$h->id_portofolio."' type='button'><i class='fa fa-pencil'></i></a>
  422. <a class='btn btn-white btn-sm' title='Delete' href='".base_url()."admin/portofolio/delete-portofolio/".$h->id_portofolio."' type='button'><i class='fa fa-trash-o'></i></a>";
  423. $hasil .= "</div>
  424. </td></tr>";
  425. $no++;
  426. }
  427. $hasil .= '</table>';
  428. }
  429. return $hasil;
  430. }
  431.  
  432. public function generate_sistem($limit,$offset,$filter=array())
  433. {
  434. $hasil = "";
  435. $data_sistem = $filter['cari_sistem'];
  436. $query_add = "WHERE title like '%".$data_sistem."'";
  437. $tot_hal = $this->db->query("SELECT id_setting, title, tipe, content_setting FROM tbl_setting ".$query_add."");
  438. $config['base_url'] = base_url() . 'admin/sistem/';
  439. $config['total_rows'] = $tot_hal->num_rows();
  440. $config['per_page'] = $limit = 5;
  441. $config['uri_segment'] = 3;
  442. $config['first_link'] = 'Pertama';
  443. $config['last_link'] = 'Terakhir';
  444. $config['next_link'] = '»';
  445. $config['prev_link'] = '«';
  446. $this->pagination->initialize($config);
  447. $w = $this->db->query("SELECT id_setting, title, tipe, content_setting FROM tbl_setting ".$query_add." ORDER BY id_setting ASC LIMIT ".$offset.",".$limit."");
  448. if(($w->num_rows())<=0)
  449. {
  450. $hasil .="<div class='text-center font-11'>Tidak Ada Data Yang Ditemukan</div>";
  451. }else{
  452. $hasil .= "<table class='table table-bordered table-striped table-condensed'>
  453. <thead>
  454. <tr>
  455. <th><center style='color:#ff6c60'>NO</th>
  456. <th><center style='color:#ff6c60'>NAMA PENGATURAN</th>
  457. <th><center style='color:#ff6c60'>TIPE PENGATURAN</th>
  458. <th><center style='color:#ff6c60'>OPTION</th>
  459. </tr>
  460. </thead>";
  461. $no = $offset+1;
  462. foreach ($w->result() as $h) {
  463. $hasil .= "<tr>
  464. <td class='text-center'>".$no."</td>
  465. <td>".$h->title."</td>
  466. <td class='text-center'>".$h->tipe."</td>
  467. <td class='text-center'><div class='btn-group'>
  468. <a class='btn btn-white btn-sm' title='Edit' href='".base_url()."admin/sistem/edit-sistem/".$h->id_setting."' type='button'><i class='fa fa-pencil'></i></a>";
  469. $hasil .= "</div>
  470. </td></tr>";
  471. $no++;
  472. }
  473. $hasil .= '</table>';
  474. }
  475. return $hasil;
  476.  
  477. }
  478.  
  479.  
  480. function simpan_user($user,$data)
  481. {
  482.  
  483. $this->db->insert('user',$data);
  484. return $simpan_user;
  485. }
  486.  
  487. function update_user($id,$data)
  488. {
  489. $this->db->where('id',$id);
  490. $update = $this->db->update('user',$data);
  491. return $update;
  492. }
  493. function getUserById($id_user) {
  494. $this->db->select('*');
  495. $this->db->where('id_user', $id_user);
  496. $query = $this->db->get($this->table, 1);
  497.  
  498. if ($query->num_rows() == 1) {
  499. return $query->row_array();
  500. }
  501. }
  502.  
  503. function tampil_detail_user($id_user)
  504. {
  505. $q = $this->db->query("SELECT * FROM tbl_user WHERE id_user = '$id_user'");
  506. return $q;
  507. }
  508. function delete_user($id) {
  509. $this->db->where('id', $id);
  510. $this->db->delete('user');
  511. }
  512. function simpan_produk($produk,$data)
  513. {
  514.  
  515. $this->db->insert('produk',$data);
  516. return $simpan_produk;
  517. }
  518.  
  519. function update_produk($id,$data)
  520. {
  521. $this->db->where('id',$id);
  522. $update = $this->db->update('produk',$data);
  523. return $update;
  524. }
  525. function tampil_detail_produk($id_prod)
  526. {
  527. $q = $this->db->query("SELECT a.id_prod, a.nama_produk,a.kategori_produk, a.elm1, a.harga_produk, a.gambar_produk, b.id, b.judul_kat FROM produk a LEFT JOIN kategori b ON a.kategori_produk = b.id WHERE a.id_prod='$id_prod'");
  528. return $q;
  529. }
  530. function delete_produk($id_prod) {
  531. $this->db->where('id_prod', $id_prod);
  532. $this->db->delete('produk');
  533. }
  534. function get_foto_produk($id_prod)
  535. {
  536. $q = $this->db->query("SELECT * FROM produk WHERE id_prod='$id_prod'");
  537. return $q;
  538. }
  539. function get_nama_kategori($id)
  540. {
  541. $q = $this->db->query("SELECT * FROM kategori WHERE id='$id'");
  542. return $q;
  543. }
  544. function get_kategori_web()
  545. {
  546. $this->db->order_by('judul_kat ASC');
  547. return $this->db->get('kategori');
  548. }
  549. function simpan_kat($judul_kat,$data)
  550. {
  551.  
  552. $this->db->insert('kategori',$data);
  553. return $simpan_kat;
  554. }
  555. function update_kat($id,$data)
  556. {
  557. $this->db->where('id',$id);
  558. $update = $this->db->update('kategori',$data);
  559. return $update;
  560. }
  561. function tampil_detail_kat($id)
  562. {
  563. $q = $this->db->query("SELECT * FROM kategori WHERE id = '$id'");
  564. return $q;
  565. }
  566. function delete_kat($id) {
  567. $this->db->where('id', $id);
  568. $this->db->delete('kategori');
  569. }
  570. function tampil_detail_blog($id_blog)
  571. {
  572. $q = $this->db->query("SELECT * FROM tbl_blog WHERE id_blog = '$id_blog'");
  573. return $q;
  574. }
  575.  
  576. function update_blog($id,$data)
  577. {
  578. $this->db->where("id_blog",$id);
  579. $this->db->update("tbl_blog",$data);
  580. return $update_blog;
  581. }
  582.  
  583. function tampil_detail_sistem($id_setting)
  584. {
  585. $q = $this->db->query("SELECT * FROM tbl_setting WHERE id_setting = '$id_setting'");
  586. return $q;
  587. }
  588.  
  589. function update_sistem($id_setting,$data)
  590. {
  591. $this->db->where("id_setting",$id_setting);
  592. $this->db->update("tbl_setting",$data);
  593. return $update_sistem;
  594. }
  595.  
  596. function tampil_detail_testimoni($id_testimoni)
  597. {
  598. $q = $this->db->query("SELECT * FROM tbl_testimoni WHERE id_testimoni ='$id_testimoni'");
  599. return $q;
  600. }
  601.  
  602. function simpan_portofolio($portofolio,$data)
  603. {
  604. $this->db->insert('tbl_portofolio',$data);
  605. return $simpan_portofolio;
  606. }
  607.  
  608. function tampil_detail_portofolio($id_portofolio)
  609. {
  610. $q = $this->db->query("SELECT * FROM tbl_portofolio WHERE id_portofolio ='$id_portofolio'");
  611. return $q;
  612. }
  613.  
  614. function update_portofolio($id_portofolio,$data)
  615. {
  616. $this->db->where("id_portofolio",$id_portofolio);
  617. $this->db->update("tbl_portofolio",$data);
  618. return $update_portofolio;
  619. }
  620.  
  621. function get_status()
  622. {
  623. $this->db->order_by('id_status');
  624. return $this->db->get('tbl_status');
  625. }
  626.  
  627. function tampil_detail_menu($id_menu)
  628. {
  629. $q = $this->db->query("SELECT * FROM tbl_menu WHERE id_menu ='$id_menu'");
  630. return $q;
  631. }
  632.  
  633. function tampil_detail_page($id_page)
  634. {
  635. $q = $this->db->query("SELECT * FROM tbl_page WHERE id_page ='$id_page'");
  636. return $q;
  637. }
  638.  
  639. function update_menu($id,$data)
  640. {
  641. $this->db->where("id_menu",$id);
  642. $this->db->update("tbl_menu",$data);
  643. return $update_menu;
  644. }
  645.  
  646. function update_page($id,$data)
  647. {
  648. $this->db->where("id_page",$id);
  649. $this->db->update("tbl_page",$data);
  650. return $update_page;
  651. }
  652.  
  653. function fpotongteks( $text, $limit ) //Fungsi Untuk Memotong Panjang
  654. {
  655.  
  656. $text = $this->fstrip_html_tags($text);
  657. if( strlen($text)>$limit )
  658. {
  659. $text = substr( $text,0,$limit );
  660. $text = substr( $text,0,-(strlen(strrchr($text,' '))) ); $text="$text";
  661. }
  662.  
  663. return $text;
  664. }
  665. function tgl_indo_lengkap($date=null){
  666. //buat array nama hari dalam bahasa Indonesia dengan urutan 1-7
  667. $array_hari = array(1=>'Senin','Selasa','Rabu','Kamis','Jumat', 'Sabtu','Minggu');
  668. //buat array nama bulan dalam bahasa Indonesia dengan urutan 1-12
  669. $array_bulan = array(1=>'Januari','Februari','Maret', 'April', 'Mei', 'Juni','Juli','Agustus',
  670. 'September','Oktober', 'November','Desember');
  671. if($date == null) {
  672. //jika $date kosong, makan tanggal yang diformat adalah tanggal hari ini
  673. $hari = $array_hari[date('N')];
  674. $tanggal = date ('d');
  675. $bulan = $array_bulan[date('n')];
  676. $tahun = date('Y');
  677. $jam = date('H:i:s');
  678. } else {
  679. //jika $date diisi, makan tanggal yang diformat adalah tanggal tersebut
  680. $date = strtotime($date);
  681. $hari = $array_hari[date('N',$date)];
  682. $tanggal = date ('d', $date);
  683. $bulan = $array_bulan[date('n',$date)];
  684. $tahun = date('Y',$date);
  685. $jam = date('H:i:s',$date);
  686. }
  687. $formatTanggal = $hari . ", " . $tanggal ." ". $bulan ." ". $tahun ." Jam ". $jam;
  688. return $formatTanggal;
  689. }
  690. }
Advertisement
Add Comment
Please, Sign In to add comment