<?php

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

namespace Apps\Immo\Module\DialogAdminImmo;

use Core\Control\Button\Button;
use Core\Controller\Controller;
use Core\View\View;

use Apps\Immo\Entity\ImmoCity;
use Apps\Immo\Widget\ImmoCityForm\ImmoCityForm;

use Apps\Immo\Entity\ImmoProject;
use Apps\Immo\Widget\ImmoProjectForm\ImmoProjectForm;

use Apps\Immo\Entity\ImmoProjectEvent;
use Apps\Immo\Widget\ImmoProjectEventForm\ImmoProjectEventForm;

/*
 * 
 */
 class DialogAdminImmoController 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();
   }
   
   /***
    * Dialogue d'ajout de ville
    */
   function AddCity($cityId= ""){
       
    $ImmoCityForm = new ImmoCityForm($this->Core);

    if ($cityId != "") {
        $city = new ImmoCity($this->Core);
        $city->GetById($cityId);
        $ImmoCityForm->Load($city);
    }

    return $ImmoCityForm->Render();
       
   }

   /***
    * Dialogue d'ajout de projet
    */
    function AddProject($projectId= ""){
       
        if ($projectId != "") {
            $project = new ImmoProject($this->Core, $project);
            $project->GetById($projectId);
        }

        $ImmoProjectForm = new ImmoProjectForm($this->Core, $project);
        $ImmoProjectForm->Load($project);
       
        return $ImmoProjectForm->Render();
    }

    /***
     * Add Event to aproject
     */
    function AddEventProject($projectId){

        $projectEvent = new ImmoProjectEvent($this->Core);
        $projectEvent->ProjectId->Value = $projectId;
  
        $ImmoProjectEventForm = new ImmoProjectEventForm($this->Core, $project);
        $ImmoProjectEventForm->Load($projectEvent);

        return $ImmoProjectEventForm->Render();
    }
    
    /***
     * Edit a event
     */
    function EditEventProject($eventId){
        $projectEvent = new ImmoProjectEvent($this->Core);
        $projectEvent->GetById($eventId);
  
        $ImmoProjectEventForm = new ImmoProjectEventForm($this->Core, $project);
        $ImmoProjectEventForm->Load($projectEvent);

        return $ImmoProjectEventForm->Render();
    }

    /*action*/
 }?>