<?php
namespace WpBookingEventFrontend\app\views\payment;

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

class PaymentView extends View
{
    public $tour;
    public $first_name;
    public $last_name;
    public function display($tpl){
        $input=FactoryAlias::getInput();
        switch ($tpl) {
            case "paynow":
                $orderModel = Model::getInstance('order');
                $order_id = $input->getInt('order_id', 0);
                $this->order = $orderModel->getItem($order_id);
                $paymentModel = Model::getInstance('payment');
                $this->paymentPlugin = $paymentModel->getPaymentPlugin($this->order->payment_id);
                $service_id = $input->getInt('service_id',0);
                $modelService=Model::getInstance('service');
                $this->list_event=$modelService->getEventByServiceId($service_id);

                break;

            case "return":
                $orderModel = Model::getInstance('order');
                $order_id = $input->getInt('order_id', 0);
                $this->order = $orderModel->getItem($order_id);
                $paymentModel = Model::getInstance('payment');
                $this->paymentPlugin = $paymentModel->getPaymentPlugin($this->order->payment_id);
                $appConfig = FactoryAlias::getAppConfig();
                $complete_order_status_id = $appConfig->get('complete_order_status_id', 5);
                $data = array(
                    'id' => $order_id,
                    "order_status_id" => $complete_order_status_id
                );
                $orderModel->save($data);
                break;
            case "cancel":
                $orderModel = Model::getInstance('order');
                $order_id = $input->getInt('order_id', 0);
                $this->order = $orderModel->getItem($order_id);
                $paymentModel = Model::getInstance('payment');
                $this->paymentPlugin = $paymentModel->getPaymentPlugin($this->order->payment_id);
                break;
            case "notify":
                $orderModel = Model::getInstance('order');
                $order_id = $input->getInt('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);
    }


}