<?php

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

class customersreport extends MY_Controller {

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

    public function index() {
        $data['supplier'] = $this->_getSuppliers();
        $this->load->view('settings/header');
        $this->load->view('partner/customersreport_view',$data);
        $this->load->view('settings/footer');
    }
//waiter or  tariff report
    function getcustomersdet() {
         $this->load->model('partner/customersreport_model');
          $data['supplier'] = $this->_getSuppliers();
         $datefrom = $this->input->post('datefrom');
         $dateto = $this->input->post('dateto');
         $customers = $this->input->post('customers');
         $receipt = $this->input->post('receiptn');
         $this->load->model('partner/customersreport_model');
         echo $this->customersreport_model->getcustomersdet($datefrom,$dateto, $customers,$receipt);
   }
   function exportcsv()
   {
        $file="customersreport.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('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;
    }
}






