<?php

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

class Costpriceupdate extends MY_Controller {

    function __construct() {
        parent::__construct();
    }

    function index() {
        $this->load->view('settings/header');
        $this->load->view('inventory/costpriceupdate_view', null);
        $this->load->view('settings/footer');
    }
// UPDATE LEASE,AVERAGE,MAXIMUM AND LAST PRICES AS STANDARD PRICE   HUSSAIN 04/03/2012
    public function updatecostprice() {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('type', 'Type', 'trim|required');
        if ($this->form_validation->run() == TRUE) {
            $datefrom = $this->input->post('datefrom');
            $dateto = $this->input->post('dateto');
            $type = $this->input->post('type');

            $this->load->model('inventory/costpriceupdate_model');
            $this->costpriceupdate_model->updatecostprice($datefrom, $dateto, $type);
            $fdata = array('msgt' => 'S', 'msg' => 'Price Updated successfully.');
            $this->session->set_flashdata($fdata);
            redirect(site_url() . 'inventory/costpriceupdate');
        } else {
            $this->load->view('settings/header');

            $this->load->view('inventory/costpriceupdate_view', null);
            $this->load->view('settings/footer');
        }
    }

}