I want to access variables from one function to another function in Codeigniter PHP. The Variables are $fromDate and $toDate. And I Want to access it in function called sales_reports_print.
public function get_sales_reports()
{
if ($this->input->post()) {
$daterange = $this->input->post('daterange');
$sales=explode("-",$daterange);
$fromDate = trim($sales[0]);
$toDate = trim($sales[1]);
}
$where = array(
'add_date >=' =>$fromDate ,'add_date <='=>$toDate
);
$this->data['sales_reports']=$this->Common_model->select_fields_where_like_join("add_sales","*",'',$where);
$this->show('reports/sales_reports',$this->data);
}
function sales_reports_print($fromDate,$toDate)
{
$where = array(
'add_date >=' =>$fromDate,'add_date <='=>$toDate
);
$this->data['sales_reports']=$this->Common_model->select_fields_where_like_join("add_sales","*",'',$where);
$this->show('reports/sales_reports_print',$this->data );
}