
<?php

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

class suppliersreport extends MY_Controller {

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

    public function index() {
        $data['supplier'] = $this->_getSuppliers();
        $this->load->view('settings/header');
        $this->load->view('partner/suppliersreport_view',$data);
        $this->load->view('settings/footer');
    }
//waiter or  tariff report
    function getsupplierdiarydet() {
         $this->load->model('partner/suppliersreport_model');
         $data['supplier'] = $this->_getSuppliers();
         $datefrom = $this->input->post('datefrom');
         $dateto = $this->input->post('dateto');
         $supplier = $this->input->post('supplier');
         $material = $this->input->post('material');
         $reason = $this->input->post('reason');
         $this->load->model('partner/suppliersreport_model');     
         echo $this->suppliersreport_model->getsupplierdiarydet($datefrom,$dateto, $supplier,$material,$reason);
    }
    function exportcsv()
    {
         $file="suppliersreport.csv";
            header("Content-Disposition: attachment; filename=" . urlencode($file));
            header("Content-Type: application/force-download");
            header("Content-Type: application/octet-stream");
            header("Content-Type: application/download");
            header("Content-Description: File Transfer");
            header("Content-type: application/csv");
            header("Pragma: no-cache");
            header("Expires: 0");
         $export= $this->input->post('exportdata');
         $this->load->helper('download');
         force_download($file, $export);
    }
    private function _getSuppliers($id = NULL) {
        $this->load->model('inventory/products_model');
        $catarr = $this->products_model->getSuppliers();
        $data = '';
        for ($i = 0; $i < count($catarr); $i++) {
            if ($id != NULL && $id == $catarr[$i]->ID)
                $data .= "<option id=\"option_custom\" selected=\"yes\" value=\"" . $catarr[$i]->ID . "\">" . $catarr[$i]->NAME . "</option>\n";
            else
                $data .= "<option id=\"option_custom\" value=\"" . $catarr[$i]->ID . "\">" . $catarr[$i]->NAME . "</option>\n";
        }
        return $data;
    }
}






