<?php
namespace WpBookingEventAdmin\app\controllers;
use WpBookingEvent\Factory;
use WpBookingEvent\Mvc\Controller\Controller;
use WpBookingEvent\Mvc\Controller\ControllerForm as ControllerFormAlias;
use WpBookingEvent\Mvc\Model\Model;
use WpBookingEvent\Utilities\Utility;

defined('_WPBOOKINGEVENT_EXEC') or die;
class EventController extends ControllerFormAlias
{
    public $view="event";
    public function delete($id = 0)
    {
        return parent::delete($id); // TODO: Change the autogenerated stub
    }

    public function save_event($data = array())
    {
        try {
            $data = parent::save_event($data); // TODO: Change the autogenerated stub
            if (!empty($data) && isset($data) && is_object($data)) {
                $clientId = is_admin() ? 1 : 0;
                $wordpress = Factory::getWordpress($clientId);
                $this->redirect(Utility::getBackendGoToLink($this->view.".list"));
                return true;
            }
        }catch (\Exception $e){
            ob_start();
            ?>
            <div class="alert alert-danger" style="width: 30% ; margin: 0 auto">
                <strong>Please enter the full information in the form again.</strong>
            </div>
            <?php
            $content = ob_get_clean();
            ob_clean();
            echo  $content;
        }
    }

}
