application/controllers/Orders.php
/*
	* If the validation is not valid, then it redirects to the edit orders page 
	* If the validation is successfully then it updates the data into the database 
	* and it stores the operation message into the session flashdata and display on the manage group page
	*/
If the validation is not valid, then it redirects to the edit orders page
If the validation is successfully then it updates the data into the database
and it stores the operation message into the session flashdata and display on the manage group page
If the validation is not valid then it redirects to the edit orders page If the validation is successfully then it updates the data into the database and it stores the operation message into the session flashdata and display on the manage group page
public function update($id)
	{
		if(!in_array('updateOrder', $this->permission)) {
            redirect('dashboard', 'refresh');
        }
		if(!$id) {
			redirect('dashboard', 'refresh');
		}
		$this->data['page_title'] = 'Update Order';
		$this->form_validation->set_rules('uedudwekb', 'Extra', 'trim|required');
		$this->form_validation->set_rules('product[]', 'Product name', 'trim|required');
		$this->form_validation->set_rules('qty[]', 'Quantity', 'trim|required');
		$this->form_validation->set_rules('amount[]', 'Amount', 'trim|required');
		$this->form_validation->set_rules('net_amount', 'Net Amount', 'trim|required');
        if ($this->form_validation->run() == TRUE) {        	
        	$update = $this->model_orders->update($id);
        	if($update == true) {
        		$this->session->set_flashdata('success', 'Successfully updated');
        		redirect('orders/update/'.$id, 'refresh');
        	}
        	else {
        		$this->session->set_flashdata('errors', 'Error occurred!!');
        		redirect('orders/update/'.$id, 'refresh');
        	}
        }
        else {
        	$company = $this->model_company->getCompanyData(1);
        	$this->data['company_data'] = $company;
        	$this->data['is_service_enabled'] = ($company['service_charge_value'] > 0) ? true : false;
        	$result = array();
        	$orders_data = $this->model_orders->getOrdersData($id);
        	if(empty($orders_data)) {
        		$this->session->set_flashdata('errors', 'The request data does not exists');
        		redirect('orders', 'refresh');
        	}
    		$result['order'] = $orders_data;
    		$orders_item = $this->model_orders->getOrdersItemData($orders_data['id']);
    		foreach($orders_item as $k => $v) {
    			$result['order_item'][] = $v;
    		}
    		$this->data['order_data'] = $result;
        	$this->data['products'] = $this->model_products->getActiveProductData();  
        	$this->data['page_title'] = 'Manage Orders';
            $this->render_template('orders/edit', $this->data);
        }
	}
public function update ( $ id ) { if ( ! in_array ( 'updateOrder' , $ this -> permission ) ) { redirect ( 'dashboard' , 'refresh' ) ; } if ( ! $ id ) { redirect ( 'dashboard' , 'refresh' ) ; } $ this -> data [ 'page_title' ] = 'Update Order' ; $ this -> form_validation -> set_rules ( 'uedudwekb' , 'Extra' , 'trim|required' ) ; $ this -> form_validation -> set_rules ( 'product[]' , 'Product name' , 'trim|required' ) ; $ this -> form_validation -> set_rules ( 'qty[]' , 'Quantity' , 'trim|required' ) ; $ this -> form_validation -> set_rules ( 'amount[]' , 'Amount' , 'trim|required' ) ; $ this -> form_validation -> set_rules ( 'net_amount' , 'Net Amount' , 'trim|required' ) ; if ( $ this -> form_validation -> run ( ) == TRUE ) { $ update = $ this -> model_orders -> update ( $ id ) ; if ( $ update == true ) { $ this -> session -> set_flashdata ( 'success' , 'Successfully updated' ) ; redirect ( 'orders/update/' . $ id , 'refresh' ) ; } else { $ this -> session -> set_flashdata ( 'errors' , 'Error occurred!!' ) ; redirect ( 'orders/update/' . $ id , 'refresh' ) ; } } else { $ company = $ this -> model_company -> getCompanyData ( 1 ) ; $ this -> data [ 'company_data' ] = $ company ; $ this -> data [ 'is_service_enabled' ] = ( $ company [ 'service_charge_value' ] > 0 ) ? true : false ; $ result = array ( ) ; $ orders_data = $ this -> model_orders -> getOrdersData ( $ id ) ; if ( empty ( $ orders_data ) ) { $ this -> session -> set_flashdata ( 'errors' , 'The request data does not exists' ) ; redirect ( 'orders' , 'refresh' ) ; } $ result [ 'order' ] = $ orders_data ; $ orders_item = $ this -> model_orders -> getOrdersItemData ( $ orders_data [ 'id' ] ) ; foreach ( $ orders_item as $ k => $ v ) { $ result [ 'order_item' ] [ ] = $ v ; } $ this -> data [ 'order_data' ] = $ result ; $ this -> data [ 'products' ] = $ this -> model_products -> getActiveProductData ( ) ; $ this -> data [ 'page_title' ] = 'Manage Orders' ; $ this -> render_template ( 'orders/edit' , $ this -> data ) ; } }
If the validation is not valid, then it redirects to the edit orders page
 If the validation is successfully then it updates the data into the database
 and it stores the operation message into the session flashdata and display on the manage group page
If the validation is not valid then it redirects to the edit orders page If the validation is successfully then it updates the data into the database and it stores the operation message into the session flashdata and display on the manage group page
// false case //$this->data['is_vat_enabled'] = ($company['vat_charge_value'] > 0) ? true : false;