<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Material_controller
 *
 * @author Code sys PC 7
 */
class Material_Controller extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('material');
        $this->load->helper('form');
        $this->load->helper('url');
    }

    public function addMaterial() {
        $matrial_name = $this->input->post("txt_material");
        $materialprice = $this->input->post("txt_price");
        $matr_data = array('material_name' => $matrial_name, 'material_price' => $materialprice);
        $this->material->saveMaterial($matr_data);
    }

    public function updateMaterials() {
        $mat_id = $this->input->post("matr_id");
        $matmname = $this->input->post("material_name");
        $matprice = $this->input->post("material_price");
        $matrl = array('material_name' => $matmname, 'material_price' => $matprice);
        $this->material->updateMaterialDetails($mat_id, $matrl);
        redirect(base_url() . "index.php/Ui_controller/all_materials");
    }

    public function deleteMaterial() {
        $mat_id = $this->input->get("mater_id");
        $this->material->deleteMaterial($mat_id);
        redirect(base_url() . "index.php/Ui_controller/all_materials");
    }

}
