<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Laporansummary extends MY_Controller
{
    public $data = array(
        'breadcrumb'    => 'Laporan',
        'modul'         => 'Barcode',
        'pesan'         => '',
        'pagination'    => '',
        'datatable'    => '',
        'main_view'     => 'laporan/laporansummary', ///This View Form or Table is want to the load
        'form_action'   => '',
        'form_value'    => '',
    );

    public function __construct()
    {	
        parent::__construct();      
        $this->load->model('Laporan_model', 'laporan', TRUE);
        $this->load->model('Login_model', 'userSession', TRUE);
        $this->load->library('session');
        $this->load->helper('encryption');
    }
    
    public function index()
    {
        $session_data = $this->session->userdata('full_name');
        $session_role = $this->session->userdata('role_id');

        $this->data['full_name'] = $session_data;   
        $this->data['role_id'] = $session_role;
        $this->load->view('template', $this->data);
    }


    public function LaporanSearch()
    {
      $output = '';
      $list = $this->laporan->get_summary();

      $output .= '
                <div class="table-responsive">
                   <table class="table table-bordered table-striped">
                    <tr>
                     <th>Kode Customer</th>
                     <th>Nama Customer</th>
                     <th>Kode Produk</th>
                     <th>Nama Produk</th>
                     <th>Total</th>
                    </tr>
                ';
                if(!empty($list))
                {
                 foreach($list as $row)
                 {
                  $output .= '
                    <tr>
                     <td>'.$row->customer_code.'</td>
                     <td>'.$row->customer_name.'</td>
                     <td>'.$row->product_code.'</td>
                     <td>'.$row->product_name.'</td>
                     <td>'.$row->Total.'</td>
                    </tr>
                  ';
                 }
                }
                else
                {
                 $output .= '<tr>
                     <td colspan="3">No Data Found</td>
                    </tr>';
                }
                $output .= '</table>';
                echo $output;
                
    }

    
}