<?php

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

//require APPPATH . '/libraries/MY_Controller.php';
//use Restserver\Libraries\MY_Controller;

class Product extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('Product_model');
    }

    public function listing(){
        $request = $this->input->get();
        $data = $this->Product_model->listing($request);
        echo json_encode($this->Product_model->build_datatables($request['draw'], $this->Product_model->totalCount(), $this->Product_model->filteredCount($request), $data), JSON_UNESCAPED_UNICODE);
    }
    
    public function getallids(){
        $ids = $this->Product_model->getAllIds();
//        echo json_encode(['success' => true, 'data' => $result], JSON_UNESCAPED_UNICODE);
        echo json_encode(['success'=>true, 'data'=>$ids, JSON_UNESCAPED_UNICODE]);
    }

    public function getcategories(){        
        $categories = $this->Product_model->getCategories();
        echo json_encode(['success'=>true, 'data'=>$categories, JSON_UNESCAPED_UNICODE]);
    }
    
}
