public function get_expiry()
    {
        //$option=$this->uri->segment(3);
        $i = $_POST['interval'];
        $facility = $this->session->userdata('news');
        $drug_name = Drug::get_drug_name();
        $title = 'test';
        switch ($i) {
            case '6_months':
                //for 6 months
                $date = date('Y-m-d', strtotime('+6 months'));
                $date1 = date('Y-m-d');
                $report = Facility_Stock::getStockouts($date, $facility, $date1);
                $report_name = "Drugs Expiring in next 6 Months ";
                break;
            case '2_months':
                //for 3 months
                $date = date('Y-m-d', strtotime('+2 month'));
                $date1 = date('Y-m-d');
                $report = Facility_Stock::getStockouts($date, $facility, $date1);
                $report_name = "Drugs Expiring in next 2 Months ";
                break;
            case '12_months':
                //for a year
                $date = date('Y-m-d', strtotime('+12 month'));
                $date1 = date('Y-m-d');
                $report = Facility_Stock::getStockouts($date, $facility, $date1);
                $report_name = "Drugs Expiring in next 1 Year ";
                break;
            default:
                $data['stockouts'] = Facility_Stock::expiries($facility);
                $report_name = "Drugs Expiring in next 1 Year ";
        }
        /**************************************set the style for the table****************************************/
        $html_data = '<style>table.data-table {border: 1px solid #DDD;margin: 10px auto;border-spacing: 0px;}
table.data-table th {border: none;color: #036;text-align: center;background-color: #F5F5F5;border: 1px solid #DDD;border-top: none;max-width: 450px;}
table.data-table td, table th {padding: 4px;}
table.data-table td {border: none;border-left: 1px solid #DDD;border-right: 1px solid #DDD;height: 30px;margin: 0px;border-bottom: 1px solid #DDD;}
.col5{background:#C9C299;}</style>';
        $html_data1 = '';
        /*****************************setting up the report*******************************************/
        $html_data1 .= '<table class="data-table"><thead>

			<tr > <th ><strong>Kemsa Code</strong></th>
			<th><strong>Description</strong></th>
			<th><strong>Unit size</strong></th>
			<th><strong>Unit Cost</strong></th>
			<th><strong>Batch No</strong></th>
			<th><strong>Expiry Date</strong></th>
			<th ><strong><b>Units</b></strong></th>
			<th ><strong><b>Stock Worth(Ksh)</b></strong></th>

</tr> </thead><tbody>';
        /*******************************begin adding data to the report*****************************************/
        foreach ($report as $drug) {
            foreach ($drug->Code as $d) {
                $name = $d->Drug_Name;
                $code = $d->Kemsa_Code;
                $unitS = $d->Unit_Size;
                $unitC = $d->Unit_Cost;
            }
            $calc = $drug->balance;
            $html_data1 .= '<tr><td>' . $code . '</td>
							<td>' . $name . '</td>
							<td>' . $unitS . '</td>
							<td>' . $unitC . '</td>
							<td >' . $drug->batch_no . '</td>
							<td>' . $drug->expiry_date . '</td>
							<td >' . $drug->balance . '</td>
							<td >' . $calc * $unitC . '</td>
							</tr>';
            /***********************************************************************************************/
        }
        $html_data1 .= '</tbody></table>';
        $html_data .= $html_data1;
        //$this->generate_pdf($report_name,$title,$html_data);
        $this->getpdf($report_name, $title, $html_data);
    }