<?php
defined('BASEPATH') or exit('No direct script access allowed');

use Brick\Money\Context\AutoContext;
use Brick\Money\CurrencyConverter;
use Brick\Money\ExchangeRateProvider\BaseCurrencyProvider;
use Brick\Money\ExchangeRateProvider\PDOProvider;
use Brick\Money\ExchangeRateProvider\PDOProviderConfiguration;
use Brick\Money\Money;

class DrugAndDevices extends CI_Controller
{

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

		// Load member model
		$this->load->model('pagination/DrugAndDevices_model', 'model');
	}


	function getLists()
	{
		$data = $row = array();

		// Fetch member's records
		$witData = $this->model->getRows($_POST);

		$i = $_POST['start'];

		foreach ($witData as $index => $row) {

			$data[] = array($index+1, $row->code, $row->name,$this->lang->line($row->type), $this->lang->line($row->on_prescription ? 'Oui' : 'Non'),
				'<button class="btn btn-success edit" data-id="'.$row->id.'" data-name="'.$row->name.'"  data-code="'.$row->code.'" 
				data-type="'.$row->type.'"  data-on_prescription="'.$row->on_prescription.'">
					<i class="fa fa-edit"></i>
				</button>
				<button data-toggle="modal" class="btn btn-danger delete" data-id="'.$row->id.'">
					<i class="fa fa-trash"></i>
				</button>');
		}

		$output = array(
			"draw" => $_POST['draw'],
			"recordsTotal" => $this->model->countAll($_POST),
			"recordsFiltered" => $this->model->countFiltered($_POST),
			"data" => $data,
		);

		// Output to JSON format
		echo json_encode($output);
	}

}
