<?php

/*
 * PuzzleApp
 * Webemyos
 * Jérôme Oliva
 * GNU Licence
 */

namespace Apps\Calendar\Module\DialogAdminCalendar;

use Core\Controller\Controller;
use Core\View\View;
use Core\Control\EntityGrid\EntityGrid;
use Core\Control\EntityGrid\EntityColumn;
use Core\Entity\Entity\Argument;

use Apps\Calendar\Entity\CalendarEvent;
use Apps\Calendar\Widget\CalendarEventForm\CalendarEventForm;

/*
 * 
 */
 class DialogAdminCalendarController extends Controller
 {
    /**
     * Constructeur
     */
    function _construct($core="")
    {
          $this->Core = $core;
    }

    /**
     * Create
     */
    function Create()
    {
    }

    /**
     * Init
     */
    function Init()
    {
    }

    /**
     * Render
     */
    function Show($all=true)
    {
         return $this->Index();
    }
    
    /*
    * Get the home page
    */
   function Index()
   {
       $view = new View(__DIR__."/View/index.tpl", $this->Core);
       return $view->Render();
   }
    
   /***
    * Add/Edit a event
    */
   function AddEvent($eventId){

    $event = new CalendarEvent($this->Core);
    
    if($eventId != ""){
        $event->GetById($eventId);
    }
    
    $eventForm = new CalendarEventForm($this->Core);
    $eventForm->Load($event);
    
    return $eventForm->Render();
    
   }
  
   /****
    * Event USer
    */
   function EditEventUsers($eventId){
       
      $gdEvent = new EntityGrid("gdEvent", $this->Core);
      $gdEvent->Entity = "Apps\Calendar\Entity\CalendarEventUser";
      $gdEvent->App = "Calendar";
      $gdEvent->Action = "GetTabCategory";
      $gdEvent->AddArgument(new Argument("Apps\Calendar\Entity\CalendarEventUser", "EventId", EQUAL, $eventId));
      
      $gdEvent->AddColumn(new EntityColumn("FirstName", "FirstName"));
      $gdEvent->AddColumn(new EntityColumn("Name", "Name"));
      $gdEvent->AddColumn(new EntityColumn("Email", "Email"));
      $gdEvent->AddColumn(new EntityColumn("Phone", "Phone"));
    
      
      return $gdEvent->Render();
   }
   
          /*action*/
 }?>