<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
Copyright (C) 2014  Web3king - Alberto Bonacina

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

class Ingredient extends CI_Controller {

	public function __construct() {
		parent::__construct();
		$this->load->model(array('users_model','ingredient_model'));
	}
	
    function index(){

    	$data['ingredentsFromDb'] = $this->ingredient_model->getAllIngredients($this->session->userdata('id'));
        $data['measureFromDb'] = $this->ingredient_model->getAllMeasure($this->session->userdata('id'));
        $data['sidebar_content'] = 'workspace/sidebar';
        $data['main_content'] = 'workspace/ingredientView';
        $this->load->view('includes/templateWorkspaceView', $data);
    }  

    function createIngredientDb(){
    	$this->ingredient_model->createIngredient($this->session->userdata('id'));
        redirect('ingredient');
    }

    function updateIngredientDb(){
    	$this->ingredient_model->updateIngredient($this->session->userdata('id'));
        redirect('ingredient');
    }
}
?>