<?php
   header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: GET, OPTIONS");
header("Content-Security-Policy: default-src 'self';");
   require APPPATH . '/libraries/REST_Controller.php';
   use Restserver\Libraries\REST_Controller;
     
class Device extends REST_Controller {
    
	  /**
     * Get All Data from this method.
     *
     * @return Response
    */
    public function __construct() {
       parent::__construct();
       $this->load->database();
    }
       
    /**
     * Get All Data from this method.
     *
     * @return Response
    */
	public function index_get($deviceId = '')
	{
	    $this->db->where('deviceUUID =', $deviceId);
        $query = $this->db->get('RegisteredDevice');
        $deviceCount = 0;
        $deviceCount = $query->num_rows();
        $deviceIsSaleClerk = 0;
        $result = 0;
        if($deviceCount > 0){
            $deviceIsSaleClerk = $query->row()->IsSaleClerk;
            if($deviceIsSaleClerk != 0){
                $result = 1;
            } else {
                $result = 2;
            }
        }
        
     
        $this->response($result, REST_Controller::HTTP_OK);
	}
     
     
}