<?php

class sync extends mainController {

    private $modal = null;

    public function landing() {
        
    }

    public function __construct() {
        //we need this header so we can access data from another server
        header('Access-Control-Allow-Origin: *');
        //false to don't check login, since no login in data collector anymore
        parent::__construct(false);
        $this->modal = new syncModel();
    }

    public function customerSearch() {
        $term = isset($_GET['term']) ? $_GET['term'] : null;
        $page = isset($_GET['page']) ? $_GET['page'] - 1 : 0;
        $ALL = $this->modal->customerSearch($term, $page, $_GET['limit']);
        echo json_encode(array('data' => $ALL['data'], 'is_more' => $ALL['is_more']));
    }
    public function accountSearch() {
        $term = isset($_GET['term']) ? $_GET['term'] : null;
        $page = isset($_GET['page']) ? $_GET['page'] - 1 : 0;
        $ALL = $this->modal->accountSearch($term, $page, $_GET['limit']);
        echo json_encode(array('data' => $ALL['data'], 'is_more' => $ALL['is_more']));
    }
    
    public function get_customer_data(){
        $data = $this->modal->get_customer_data($_POST['customer']);
        die(json_encode($data));
    }

}
