<?php



class Dukut extends CI_Controller
{

  public function __construct()
  {
    parent::__construct();
    $this->load->model('Dukut_model');
  }

  public function index()
  {

             
    $this->load->library('pagination');
   

    //$config['base_url'] = site_url('/product');
    $config['page_query_string'] = TRUE;
    $config['date1'] = '2024-01-01';
    $config['date2'] = '2024-12-31';

    $config['total_rows'] =  $this->Dukut_model->get_published_count();
    $config['per_page'] = 20;
  
    //$config['full_tag_open'] = '<div class="pagination1">';
    //$config['full_tag_close'] = '</div>';
 
    $this->pagination->initialize($config);
    $limit = $config['per_page'];
    if (!is_null($this->input->get('per_page'))) { 
    $offset =   html_escape($this->input->get('per_page'));
    }
    else {
    $offset = 0;
      
     //backup data ke tabel backup
//     $backupketabelbackupnyadulu = $this->Dukut_model->get_backup();

    }

     if (!is_null($this->input->get('date1'))) { 
$date1 = $this->input->get('date1');
     } else {
        $date1 = $config['date1'];
     }
     if (!is_null($this->input->get('date2'))) { 
        $date2 = $this->input->get('date2');
             } else {
                $date2 = $config['date2'];
             }


          
        
    $data['dukuts'] = $this->Dukut_model->get_published($limit, $offset,$date1,$date2);
    $data['jmldata'] = $config['total_rows'];
  //  $backupketabelbackupnyadulu = $this->Dukut_model->get_backup($date1,$date2);
 //var_dump($backupketabelbackupnyadulu);
 //return;
    // Panggil fungsi proses_riwayat_penjualan di model
//    $this->Dukut_model->proses_riwayat_penjualan();

    if(count($data['jmldata']) > 0){
    //   var_dump($data);
       $this->load->view('products/list_dukut.php', $data);
    }  
  }
 
}