<?php
namespace WpBookingHotelFrontend\app\views\checkout;

use WpBookingHotel\Factory as FactoryAlias;
use WpBookingHotel\Html\ToolBar;
use WpBookingHotel\Mvc\Model\Model;
use WpBookingHotel\Mvc\View\View;

class CheckoutView extends View
{
    public $hotel;
    public $number_children;
    public $number_adult;
    public $infant_number;
    public $date_check_in;
    public $first_name;
    public $last_name;
    public function display($tpl){
        $input=FactoryAlias::getInput();
        switch ($tpl){
            case "thanks":
                $order_id = $input->getInt('order_id', 0);
                $modelOrder=Model::getInstance("order");
                $this->order=$modelOrder->getItem($order_id);
                break;
            
            default:
                $input = FactoryAlias::getInput();
                $data = $input->getData();
                $this->data = $data;
                $hotel_id = $input->getInt('hotel_id',0);
                $modelHotel=Model::getInstance("hotel");
                $this->hotel = $modelHotel->getItem($hotel_id);
                $this->coupons = $input->getString('coupon','');
                $this->form = $modelHotel->getForm();
                
                $appConfig = FactoryAlias::getAppConfig();
                $currency = $appConfig->get('currencies_in_list', '');
                $currencyModel = Model::getInstance('currency');
                if (isset($_SESSION["currency"])){
                    $currency1 = $_SESSION["currency"];
                    $this->symbol = $currencyModel->format_currency($currency1);
                }else{
                    $this->symbol = $currencyModel->format_currency($currency);
                }

                $modelCheckout=Model::getInstance("checkout");
                $id = $input->getInt('hotel_id', 0);
                $this->item = $modelCheckout->getItem($id);

                $modelCoupon = Model::getInstance('coupon');
                $this->listcounpon = $modelCoupon->getList();

                $order_id = $input->getInt('order_id', 0);
                $orderModel = Model::getInstance('order');
                if($order_id > 0) {
                    $this->order = $orderModel->getItem($order_id);
                    $paymentModel = Model::getInstance('payment');
                    $this->paymentPlugin = $paymentModel->getPaymentPlugin($this->order->payment_id);
                }
                break;
        }
        return parent::display($tpl);
    }

}