Advertisement
Guest User

Frontend.php

a guest
May 1st, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Frontend extends MY_Controller {
  4.  
  5.     public function __construct()
  6.     {
  7.         parent::__construct();
  8.         $this->load->library('pagination');
  9.         $this->load->helper('url');
  10.     }
  11.  
  12.  
  13.     public function class_data()
  14.     {
  15.         $data['base_level'] = $this->uri->segment(1);
  16.         $data['base_class'] = 'frontend';
  17.  
  18.         return $data;
  19.     }
  20.  
  21.     public function index()
  22.     {
  23.         $data['title']='Home';
  24.         $this->parser->parse('tpl_frontend/template', $data);
  25.     }
  26.  
  27.     public function shop($keyword = null)
  28.     {
  29.         $temp = null;
  30.         $this->load->model('M_frontend', 'mod');
  31.         $data                   = self::class_data();
  32.         $data['search']         = $this->input->get('search-product');
  33.         $data['sorting']        = $this->input->get('sorting');
  34.         $data['title']          = 'Shop';
  35.         $data['table_view']     = 'barang';
  36.         $data['fields']         = ["id_barang", "nama_barang", "harga_barang", "keterangan_barang", "gambar1_barang", "gambar2_barang", "gambar3_barang", "idsubkategori_barang", "idpersonal_barang", "status_barang"];
  37.         $data['total']          = $this->mod->tampil($data)['total'];
  38.         $data['result']         = $this->mod->tampil($data)['result'];
  39.         foreach ($data['result'] as $records) {
  40.             $records['level']   = $data['base_level'];
  41.             $temp[]             = $records;
  42.         }
  43.         $data['result']         = $temp;
  44.         //print('<pre>'); print_r($data); exit();
  45.        
  46.         $config['base_url'] = site_url('frontend/shop'); //site url
  47.         $config['total_rows'] = $this->mod->get_count(); //total row
  48.         $config['per_page'] = 3;  //show record per halaman
  49.         $config["uri_segment"] = 3;  // uri parameter
  50.         $choice = $config["total_rows"] / $config["per_page"];
  51.         $config["num_links"] = floor($choice);
  52.  
  53.         $config['first_link']       = 'First';
  54.         $config['last_link']        = 'Last';
  55.         $config['next_link']        = 'Next';
  56.         $config['prev_link']        = 'Prev';
  57.         $config['full_tag_open']    = '<div class="pagging text-center"><nav><ul class="pagination justify-content-center">';
  58.         $config['full_tag_close']   = '</ul></nav></div>';
  59.         $config['num_tag_open']     = '<li class="page-item"><span class="page-link">';
  60.         $config['num_tag_close']    = '</span></li>';
  61.         $config['cur_tag_open']     = '<li class="page-item active"><span class="page-link">';
  62.         $config['cur_tag_close']    = '<span class="sr-only">(current)</span></span></li>';
  63.         $config['next_tag_open']    = '<li class="page-item"><span class="page-link">';
  64.         $config['next_tagl_close']  = '<span aria-hidden="true">&raquo;</span></span></li>';
  65.         $config['prev_tag_open']    = '<li class="page-item"><span class="page-link">';
  66.         $config['prev_tagl_close']  = '</span>Next</li>';
  67.         $config['first_tag_open']   = '<li class="page-item"><span class="page-link">';
  68.         $config['first_tagl_close'] = '</span></li>';
  69.         $config['last_tag_open']    = '<li class="page-item"><span class="page-link">';
  70.         $config['last_tagl_close']  = '</span></li>';
  71.        
  72.         $this->pagination->initialize($config);
  73.        
  74.         $data['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
  75.  
  76.    
  77.         $data['data'] = $this->mod->get_barang_list($config["per_page"], $data['page']);          
  78.  
  79.         $data['pagination'] = $this->pagination->create_links();
  80.  
  81.        
  82.         if ($temp != null)
  83.         {
  84.             $this->parser->parse('tpl_frontend/shop', $data);
  85.         } else {
  86.             $this->parser->parse('tpl_frontend/barang_kosong', $data);
  87.         }
  88.     }
  89.  
  90.     public function shop_ular()
  91.     {
  92.         $temp = null;
  93.         $this->load->model('M_frontend', 'mod');
  94.         $data['title']          ='Shop';
  95.         $data['table_view']     = 'barang';
  96.         $data['search']         = $this->input->get('search-product');
  97.         $data['sorting']        = $this->input->get('sorting');
  98.         $data['fields']         = ["id_barang", "nama_barang", "harga_barang", "keterangan_barang", "gambar1_barang", "gambar2_barang", "gambar3_barang", "idsubkategori_barang", "idpersonal_barang", "status_barang"];
  99.         $data['total']          = $this->mod->tampil_ular($data)['total'];
  100.         $data['result']         = $this->mod->tampil_ular($data)['result'];
  101.         foreach ($data['result'] as $records) {
  102.             $temp[]             = $records;
  103.         }
  104.         $data['result']         = $temp;
  105.         if ($temp != null)
  106.         {
  107.             $this->parser->parse('tpl_frontend/shop_ular', $data);
  108.         } else {
  109.             $this->parser->parse('tpl_frontend/barang_kosong', $data);
  110.         }
  111.    
  112.     }
  113.  
  114.     public function shop_katak()
  115.     {
  116.         $temp = null;
  117.         $this->load->model('M_frontend', 'mod');
  118.         $data['title']          ='Shop';
  119.         $data['search']         = $this->input->get('search-product');
  120.         $data['sorting']        = $this->input->get('sorting');
  121.         $data['table_view']     = 'barang';
  122.         $data['fields']         = ["id_barang", "nama_barang", "harga_barang", "keterangan_barang", "gambar1_barang", "gambar2_barang", "gambar3_barang", "idsubkategori_barang", "idpersonal_barang", "status_barang"];
  123.         $data['total']          = $this->mod->tampil_katak($data)['total'];
  124.         $data['result']         = $this->mod->tampil_katak($data)['result'];
  125.         foreach ($data['result'] as $records) {
  126.             $temp[]             = $records;
  127.         }
  128.         $data['result']         = $temp;
  129.         if ($temp != null)
  130.         {
  131.             $this->parser->parse('tpl_frontend/shop_katak', $data);
  132.         } else {
  133.             $this->parser->parse('tpl_frontend/barang_kosong', $data);
  134.         }
  135.     }
  136.    
  137.        
  138.  
  139.     public function shop_kura()
  140.     {
  141.         $temp = null;
  142.         $this->load->model('M_frontend', 'mod');
  143.         $data['title']          ='Shop';
  144.         $data['search']         = $this->input->get('search-product');
  145.         $data['sorting']        = $this->input->get('sorting');
  146.         $data['table_view']     = 'barang';
  147.         $data['fields']         = ["id_barang", "nama_barang", "harga_barang", "keterangan_barang", "gambar1_barang", "gambar2_barang", "gambar3_barang", "idsubkategori_barang", "idpersonal_barang", "status_barang"];
  148.         $data['total']          = $this->mod->tampil_kura($data)['total'];
  149.         $data['result']         = $this->mod->tampil_kura($data)['result'];
  150.         foreach ($data['result'] as $records) {
  151.             $temp[]             = $records;
  152.         }
  153.         $data['result']         = $temp;
  154.         if ($temp != null)
  155.         {
  156.             $this->parser->parse('tpl_frontend/shop_kura', $data);
  157.         } else {
  158.             $this->parser->parse('tpl_frontend/barang_kosong', $data);
  159.         }
  160.        
  161.     }
  162.  
  163.     public function shop_kadal()
  164.     {
  165.         $temp = null;
  166.         $this->load->model('M_frontend', 'mod');
  167.         $data['title']          ='Shop';
  168.         $data['table_view']     = 'barang';
  169.         $data['search']         = $this->input->get('search-product');
  170.         $data['sorting']        = $this->input->get('sorting');
  171.         $data['fields']         = ["id_barang", "nama_barang", "harga_barang", "keterangan_barang", "gambar1_barang", "gambar2_barang", "gambar3_barang", "idsubkategori_barang", "idpersonal_barang", "status_barang"];
  172.         $data['total']          = $this->mod->tampil_kadal($data)['total'];
  173.         $data['result']         = $this->mod->tampil_kadal($data)['result'];
  174.         foreach ($data['result'] as $records) {
  175.             $temp[]             = $records;
  176.         }
  177.         $data['result']         = $temp;
  178.         if ($temp != null)
  179.         {
  180.             $this->parser->parse('tpl_frontend/shop_kadal', $data);
  181.         } else {
  182.             $this->parser->parse('tpl_frontend/barang_kosong', $data);
  183.         }
  184.        
  185.     }
  186.  
  187.     public function shop_acc()
  188.     {
  189.         $temp = null;
  190.         $this->load->model('M_frontend', 'mod');
  191.         $data['title']          ='Shop';
  192.         $data['table_view']     = 'barang';
  193.         $data['search']         = $this->input->get('search-product');
  194.         $data['sorting']        = $this->input->get('sorting');
  195.         $data['fields']         = ["id_barang", "nama_barang", "harga_barang", "keterangan_barang", "gambar1_barang", "gambar2_barang", "gambar3_barang", "idsubkategori_barang", "idpersonal_barang", "status_barang"];
  196.         $data['total']          = $this->mod->tampil_acc($data)['total'];
  197.         $data['result']         = $this->mod->tampil_acc($data)['result'];
  198.         foreach ($data['result'] as $records) {
  199.             $temp[]             = $records;
  200.         }
  201.         $data['result']         = $temp;
  202.         if ($temp != null)
  203.         {
  204.             $this->parser->parse('tpl_frontend/shop_acc', $data);
  205.         } else {
  206.             $this->parser->parse('tpl_frontend/barang_kosong', $data);
  207.         }
  208.        
  209.     }
  210.  
  211.     public function shop_ser()
  212.     {
  213.         $temp = null;
  214.         $this->load->model('M_frontend', 'mod');
  215.         $data['title']          ='Shop';
  216.         $data['table_view']     = 'barang';
  217.         $data['search']         = $this->input->get('search-product');
  218.         $data['sorting']        = $this->input->get('sorting');
  219.         $data['fields']         = ["id_barang", "nama_barang", "harga_barang", "keterangan_barang", "gambar1_barang", "gambar2_barang", "gambar3_barang", "idsubkategori_barang", "idpersonal_barang", "status_barang"];
  220.         $data['total']          = $this->mod->tampil_ser($data)['total'];
  221.         $data['result']         = $this->mod->tampil_ser($data)['result'];
  222.         foreach ($data['result'] as $records) {
  223.             $temp[]             = $records;
  224.         }
  225.         $data['result']         = $temp;
  226.         if ($temp != null)
  227.         {
  228.             $this->parser->parse('tpl_frontend/shop_ser', $data);
  229.         } else {
  230.             $this->parser->parse('tpl_frontend/barang_kosong', $data);
  231.         }
  232.        
  233.     }
  234.  
  235.     public function blog()
  236.     {  
  237.         $temp = null;
  238.         $this->load->helper(array('string', 'text'));
  239.         $this->load->model('admin/M_artikel', 'mod');
  240.         $data['title']          ='Blog';
  241.         $data['table_view']     = 'artikel';
  242.         $data['search']         = $this->input->get('search-product');
  243.         $data['sorting']        = $this->input->get('sorting');
  244.         $data['fields']         = ["id_artikel", "judul_artikel", "isi_artikel", "penulis_artikel", "kategori_artikel", "gambar_artikel", "insert_on"];
  245.         $data['total']          = $this->mod->fetch_data($data)['total'];
  246.         $data['result']         = $this->mod->fetch_data($data)['result'];
  247.  
  248.         foreach ($data['result'] as $records) {
  249.             $temp[]             = $records;
  250.         }
  251.         //print('<pre>'); print_r($data); exit();
  252.         $data['result']         = $temp;
  253.         //print('<pre>'); print_r($data); exit();
  254.         if ($temp != null)
  255.         {
  256.             $this->parser->parse('tpl_frontend/blog', $data);
  257.         } else {
  258.             $this->parser->parse('tpl_frontend/barang_kosong', $data);
  259.         }
  260.    
  261.        
  262.     }
  263.     public function about()
  264.     {
  265.         $data['title']='About';
  266.         $this->parser->parse('tpl_frontend/about', $data);
  267.     }
  268.    
  269.     public function product_detail($id_barang)
  270.     {
  271.  
  272.         $this->load->model('M_frontend', 'mod');
  273.         $data                   = self::class_data();
  274.         $data['title']          = 'Product Detail';
  275.         $data['table_view']     = 'v_barang_personal_kategori';
  276.         $data['result']         = $this->mod->detail_barang($id_barang);
  277.         //print('<pre>'); print_r($data); exit();
  278.         $this->parser->parse('tpl_frontend/product-detail', $data);
  279.     }
  280.  
  281.     public function blog_detail($id_artikel)
  282.     {
  283.        
  284.         $this->load->model('admin/M_artikel', 'mod');
  285.         $data['title']          = 'Blog Detail';
  286.         $data['table_view']     = 'artikel';
  287.         $data['result']         = $this->mod->detail_blog($id_artikel);
  288.         //print('<pre>'); print_r($data); exit();
  289.         $this->parser->parse('tpl_frontend/blog-detail', $data);
  290.     }
  291.  
  292.     public function search_shop()
  293.     {
  294.         $this->load->model('M_frontend', 'mod');
  295.         $data                   = self::class_data();
  296.         $data['title']          ='Shop';
  297.         $data['table_view']     = 'barang';
  298.         $data['fields']         = ["id_barang", "nama_barang", "harga_barang", "keterangan_barang", "gambar1_barang", "gambar2_barang", "gambar3_barang", "idsubkategori_barang", "idpersonal_barang", "status_barang"];
  299.         $data['total']          = $this->mod->tampil_search_shop($data)['total'];
  300.         $data['result']         = $this->mod->tampil_search_shop($data)['result'];
  301.         foreach ($data['result'] as $records) {
  302.             $records['level']   = $data['base_level'];
  303.             $temp[]             = $records;
  304.         }
  305.         $data['result']         = $temp;
  306.         //print('<pre>'); print_r($data); exit();
  307.         $this->parser->parse('tpl_frontend/shop', $data);
  308.     }
  309.  
  310.     public function blog_07()
  311.     {
  312.         $this->load->helper(array('string', 'text'));
  313.         $this->load->model('admin/M_artikel', 'mod');
  314.         $data['title']          ='Blog';
  315.         $data['table_view']     = 'artikel';
  316.         $data['fields']         = ["id_artikel", "judul_artikel", "isi_artikel", "penulis_artikel", "kategori_artikel", "gambar_artikel", "tanggal_artikel","insert_on"];
  317.         $data['total']          = $this->mod->fetch_data($data)['total'];
  318.         $data['result']         = $this->mod->fetch_data($data)['result'];
  319.  
  320.         foreach ($data['result'] as $records) {
  321.             $temp[]             = $records;
  322.         }
  323.         //print('<pre>'); print_r($data); exit();
  324.         $data['result']         = $temp;
  325.         //print('<pre>'); print_r($data); exit();
  326.         $this->parser->parse('tpl_frontend/07_blog', $data);
  327.     }
  328. }
  329.  
  330. /* End of file Frontend.php */
  331. /* Location: ./application/controllers/Frontend.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement