<?php

class orderDisplayAjax extends mainController {

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

    public function landing() {
        
    }

    public function approve_order() {
        $submit = $this->_registry->order_display_class->setData($_GET)->approve_order();

        die(json_encode(empty($submit) ? [CommonLanguage::getMessage('Submitted_Successfully'), 'success'] : [$submit[0], 'danger']));
    }

    public function approve_details() {
        $submit = $this->_registry->order_display_class->setData($_GET)->approve_details();
        die(json_encode(empty($submit[0]) ? [CommonLanguage::getMessage('Submitted_Successfully'), 'success', $submit[1]] : [$submit[0][0], 'danger']));
    }

    public function getOrdersRefreshed() {
        $display_data = CommonFunctions::CommonView('tbl_display', ['display_id'], [$_GET['display_id']])[0];
        $data = $this->_registry->order_display_class->get_orders_to_display($display_data['printer_ids']);
        die(json_encode(['data' => $data, 'blocks' => $display_data['display_blocks'],
            'hide_done_details' => $display_data['hide_done_details'],
            'hide_done_order' => $display_data['hide_done_order']]));
    }

}
