application/controllers/Reports.php
/* 
    * It redirects to the report page
    * and based on the year, all the orders data are fetch from the database.
    */
It redirects to the report page
and based on the year, all the orders data are fetch from the database.
It redirects to the report page and based on the year all the orders data are fetch from the database .
public function index()
	{
		if(!in_array('viewReport', $this->permission)) {
            redirect('dashboard', 'refresh');
        }
		$today_year = date('Y');
		if($this->input->post('select_year')) {
			$today_year = $this->input->post('select_year');
		}
		$order_data = $this->model_reports->getOrderData($today_year);
		$this->data['report_years'] = $this->model_reports->getOrderYear();
		$final_order_data = array();
		foreach ($order_data as $k => $v) {
			if(count($v) > 1) {
				$total_amount_earned = array();
				foreach ($v as $k2 => $v2) {
					if($v2) {
						$total_amount_earned[] = $v2['net_amount'];						
					}
				}
				$final_order_data[$k] = array_sum($total_amount_earned);	
			}
			else {
				$final_order_data[$k] = 0;	
			}
		}
		$this->data['selected_year'] = $today_year;
		$this->data['company_currency'] = $this->company_currency();
		$this->data['results'] = $final_order_data;
		$this->render_template('reports/index', $this->data);
	}
public function index ( ) { if ( ! in_array ( 'viewReport' , $ this -> permission ) ) { redirect ( 'dashboard' , 'refresh' ) ; } $ today_year = date ( 'Y' ) ; if ( $ this -> input -> post ( 'select_year' ) ) { $ today_year = $ this -> input -> post ( 'select_year' ) ; } $ order_data = $ this -> model_reports -> getOrderData ( $ today_year ) ; $ this -> data [ 'report_years' ] = $ this -> model_reports -> getOrderYear ( ) ; $ final_order_data = array ( ) ; foreach ( $ order_data as $ k => $ v ) { if ( count ( $ v ) > 1 ) { $ total_amount_earned = array ( ) ; foreach ( $ v as $ k2 => $ v2 ) { if ( $ v2 ) { $ total_amount_earned [ ] = $ v2 [ 'net_amount' ] ; } } $ final_order_data [ $ k ] = array_sum ( $ total_amount_earned ) ; } else { $ final_order_data [ $ k ] = 0 ; } } $ this -> data [ 'selected_year' ] = $ today_year ; $ this -> data [ 'company_currency' ] = $ this -> company_currency ( ) ; $ this -> data [ 'results' ] = $ final_order_data ; $ this -> render_template ( 'reports/index' , $ this -> data ) ; }
It redirects to the report page
 and based on the year, all the orders data are fetch from the database.
It redirects to the report page and based on the year all the orders data are fetch from the database .