<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Komisi_penjualan extends CI_Controller
{
    private $perPage=10;
    public function __construct(){ parent::__construct(); cek_session_login(); $this->load->model('Komisi_penjualan_model','komisi'); $this->komisi->ensureMenuEntry(); }
    public function index(){ if(!$this->komisi->isFeatureEnabled()) return redirect('errorakses'); $data=['title'=>'Komisi Penjualan | '.info()['title'],'tgl'=>tgl_dari_slash().' - '.tgl_sampai_slash(),'sales_options'=>$this->komisi->getSalesOptions()]; $this->template->load('main/themes','komisi_penjualan/index',$data); }
    public function ajaxPaginationData(){ cek_nput_post('GET'); if(!$this->komisi->isFeatureEnabled()) return $this->output->set_status_header(403)->set_output(''); $page=max(0,(int)$this->input->post('page')); $limit=max(1,(int)$this->input->post('limits')?:$this->perPage); $params=['sales_id'=>(int)$this->input->post('sales_id')]; $tgl=trim((string)$this->input->post('tgl')); if($tgl!==''){ $d=date_ranges($tgl); $params['dari']=date_replace_slash($d['dari']); $params['sampai']=date_replace_slash($d['sampai']); } $count=$params; $count['count']=true; $config=['target'=>'#dataKomisiPenjualan','base_url'=>base_url('komisi-penjualan/ajaxPaginationData'),'total_rows'=>$this->komisi->getRows($count),'per_page'=>$limit,'link_func'=>'searchKomisiPenjualan']; $this->ajax_pagination->initialize($config); $params['start']=$page; $params['limit']=$limit; $data['posts']=$this->komisi->getRows($params); $data['total_komisi_page']=array_sum(array_column($data['posts'],'komisi_penjualan_nominal')); $this->load->view('komisi_penjualan/ajax_data',$data,false); }
}
