application/controllers/Orders.php
/*
	* Fetches the orders data from the orders table 
	* this function is called from the datatable ajax function
	*/
Fetches the orders data from the orders table
this function is called from the datatable ajax function
Fetches the orders data from the orders table this function is called from the datatable ajax function
public function fetchOrdersData()
	{
		if(!in_array('viewOrder', $this->permission)) {
            redirect('dashboard', 'refresh');
        }
		$result = array('data' => array());
		$data = $this->model_orders->getOrdersData();
		foreach ($data as $key => $value) {
			$user_data =  $this->model_users->getUserData($value['user_id']);
			$store_data = $this->model_stores->getStoresData($value['store_id']);
			$count_total_item = $this->model_orders->countOrderItem($value['id']);
			$name = $user_data['firstname'].' '.$user_data['lastname'];
			$date = date('d-m-Y', $value['date']);
			$buttons = '';
			if(in_array('updateOrder', $this->permission)) {
				$buttons .= ' <a href="'.base_url('orders/update/'.$value['id']).'" style="border: 2px solid #4CAF50" class="btn btn-default"><i class="fa fa-pencil" style="color:#4CAF50"></i></a>';
			}
			if(in_array('deleteOrder', $this->permission)) {
				$buttons .= ' <button type="button" style="border: 2px solid #f44336" class="btn btn-default" onclick="removeFunc('.$value['id'].')" data-toggle="modal" data-target="#removeModal"><i class="fa fa-trash" style="color:#f44336"></i></button>';
			}
			if($value['paid_status'] == 1) {
				$paid_status = '<span class="label label-success">Paid</span>';
			}
			else {
				$paid_status = '<span class="label label-warning">Not Paid</span>';
			}
			$result['data'][$key] = array(
				$name,
				$value['bill_no'],
				$date,
				$store_data['name'],
				$value['net_amount'],
				$paid_status,
				$buttons
			);
		} 
		echo json_encode($result);
	}
public function fetchOrdersData ( ) { if ( ! in_array ( 'viewOrder' , $ this -> permission ) ) { redirect ( 'dashboard' , 'refresh' ) ; } $ result = array ( 'data' => array ( ) ) ; $ data = $ this -> model_orders -> getOrdersData ( ) ; foreach ( $ data as $ key => $ value ) { $ user_data = $ this -> model_users -> getUserData ( $ value [ 'user_id' ] ) ; $ store_data = $ this -> model_stores -> getStoresData ( $ value [ 'store_id' ] ) ; $ count_total_item = $ this -> model_orders -> countOrderItem ( $ value [ 'id' ] ) ; $ name = $ user_data [ 'firstname' ] . ' ' . $ user_data [ 'lastname' ] ; $ date = date ( 'd-m-Y' , $ value [ 'date' ] ) ; $ buttons = '' ; if ( in_array ( 'updateOrder' , $ this -> permission ) ) { $ buttons .= ' <a href="' . base_url ( 'orders/update/' . $ value [ 'id' ] ) . '" style="border: 2px solid #4CAF50" class="btn btn-default"><i class="fa fa-pencil" style="color:#4CAF50"></i></a>' ; } if ( in_array ( 'deleteOrder' , $ this -> permission ) ) { $ buttons .= ' <button type="button" style="border: 2px solid #f44336" class="btn btn-default" onclick="removeFunc(' . $ value [ 'id' ] . ')" data-toggle="modal" data-target="#removeModal"><i class="fa fa-trash" style="color:#f44336"></i></button>' ; } if ( $ value [ 'paid_status' ] == 1 ) { $ paid_status = '<span class="label label-success">Paid</span>' ; } else { $ paid_status = '<span class="label label-warning">Not Paid</span>' ; } $ result [ 'data' ] [ $ key ] = array ( $ name , $ value [ 'bill_no' ] , $ date , $ store_data [ 'name' ] , $ value [ 'net_amount' ] , $ paid_status , $ buttons ) ; } echo json_encode ( $ result ) ; }
Fetches the orders data from the orders table
 this function is called from the datatable ajax function
Fetches the orders data from the orders table this function is called from the datatable ajax function
// button /*if(in_array('viewOrder', $this->permission)) {
				$buttons .= '<a target="__blank" href="'.base_url('orders/printDiv/'.$value['id']).'" style="border: 2px solid #008CBA" class="btn btn-default"><i class="fa fa-print style="color:#008CBA"></i></a>';
			}*/ // /foreach