1
votes

Controller code

public function getcari(){

    $tglawal=date('Y-m-d', strtotime($this->input->post('tgl1', TRUE)));
    $tglakhir=date('Y-m-d', strtotime($this->input->post('tgl2', TRUE)));
    $data['detail']=$this->traffic_model->cari($tglawal,$tglakhir); 
    $this->load->view('daftar_traffic', $data); //menampilkan data yang sudah dicari
}

Model Code

function cari($tglawal,$tglakhir){      

$this->db->select('DATE_FORMAT(tgl, %d %M %Y) AS tanggal,COUNT(IF(kategori.parent=35 , VALUE, NULL)) AS Software,  COUNT(IF(kategori.parent=33 , VALUE, NULL)) AS Indent,  COUNT(IF(kategori.parent=32 , VALUE, NULL)) AS Ready, COUNT((DATE_FORMAT(tgl, %d - %m - %Y))) AS Total'); //changed the code here from COUNT(clients.id) AS num_rows
$this->db->from('masalah ');
$this->db->where('DATE(masalah.tgl) >=', $tglawal);
$this->db->where('DATE(masalah.tgl) <=', $tglakhir);
$this->db->join('kategori, kategori.kategori=masalah.kategori', 'left');
$this->db->group_by('tanggal');
$query = $this->db->get();
return $query->result();
}

View Code

<form action="<?php echo site_url('traffic/getcari');?>" method="post"><input type="date" name="tgl1" palceholder="Input date" requaried="true" /> <input type="date" name="tgl2" palceholder="Input date" requaried="true" /><button type="submit">Cari</button> <a href="<?php echo site_url('traffic'); ?>" style="text-decoration:none; color: black;">Reset</a>

the errors... Warning: include(C:\xampp\htdocs\portalacw\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\portalacw\system\core\Exceptions.php on line 269

Warning: include(): Failed opening 'C:\xampp\htdocs\portalacw\application\views\errors\html\error_php.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\portalacw\system\core\Exceptions.php on line 269

Fatal error: Call to a member function cari() on null in C:\xampp\htdocs\portalacw\application\modules\traffic\controllers\traffic.php on line 24

Warning: include(C:\xampp\htdocs\portalacw\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\portalacw\system\core\Exceptions.php on line 269

Warning: include(): Failed opening 'C:\xampp\htdocs\portalacw\application\views\errors\html\error_php.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\portalacw\system\core\Exceptions.php on line 269

Warning: include(C:\xampp\htdocs\portalacw\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\portalacw\system\core\Exceptions.php on line 269

Warning: include(): Failed opening 'C:\xampp\htdocs\portalacw\application\views\errors\html\error_php.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\portalacw\system\core\Exceptions.php on line 269 '

pleas help me

1
well, for one, it seems you deleted your error views. should be a folder in views called errors or something similar. if you dont have it download it from a fresh copy of CI and place it in the views folder.Alex

1 Answers

-2
votes

In my opinion, your problem is because you didn't load the model correctly. So your controller took the traffic_model to be null.