<?php

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

class Expiryreport extends MY_Controller {

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

    function index()
    {
        $this->load->view('settings/header');
        $this->load->view('reports/expiryreport_view', null);
        $this->load->view('settings/footer');
    }
    function setparamsinsession(){
       $this->load->library('session');

       $this->session->set_userdata('PRODUCT', $this->input->post('PRODUCT'));
       $this->session->set_userdata('DATEFROM',  $this->input->post('DATEFROM'));
       $this->session->set_userdata('DATETO',  $this->input->post('DATETO'));
        return 1;
    }
    public function printreport() {
        $this->load->library('session');
        $product = $this->session->userdata('PRODUCT');
        $datefrom  = $this->session->userdata('DATEFROM');
        $dateto  = $this->session->userdata('DATETO');
        $array_items = array('PRODUCT' => '', 'DATEFROM' => '','DATETO' => '');
        $this->session->unset_userdata($array_items);
        $this->load->helper('dompdf');
        $this->load->helper('file');
        $this->load->model('settings/companyinfo_model');
        $this->load->model('reports/expiryreport_model');
        $data['companyinfo'] = $this->companyinfo_model->getcompanyinfo('0');
        $data['reportdata'] = $this->expiryreport_model->getreport($product,$datefrom,$dateto);
        $this->load->model('reports/report_model');
        $data['columns'] = '<?xml version="1.0" encoding="UTF-8" standalone="no"?> <report> <columns> <column title="Barcode" field="CODE" width="80" align="left"/> <column title="Product" field="NAME" width="200" align="left"/><column title="Units" field="UNITS" width="50" align="right"/><column title="Expiry" field="EXPIRY" width="50" align="left"/> </columns> </report>';
        $data['reporttitle'] = 'Expiry Report';
        $html = $this->load->view('reports/report_template1_print', $data, true);
        echo $html;
        //pdf_create($html, 'STOCKDIARY', false);

    }
}