<?php

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

namespace Apps\estimation;

use Core\Core\Core;
use Apps\Base\Base;
use Core\Core\Request;
use Core\Core\Response;

use Apps\estimation\Module\Admin\AdminController;
use Apps\estimation\Module\Front\FrontController;

use Apps\estimation\Helper\SitemapHelper;


class estimation extends Base {

    /**
     * Author and version
     * */
    public $Author = 'Webemyos';
    public $Version = '1.0.0';

    /**
     * Constructeur
     * */
    function __construct() {
        $this->Core = Core::getInstance();
        parent::__construct($this->Core, "estimation");
    }

    /**
     * Set public route
     */
    function GetRoute($routes = "") {
        $this->Route->SetPublic(array("ville"));

        return $this->Route;
    }

    /*     * *
     * Execute action after install
     */

    function PostInstall() {
        \Apps\EeApp\Helper\AppHelper::UpdateAppParams($this->Core,
                "estimation",
                $this->Version,
                "", // Add Description of the app
                0, // Set 1 if the App have a AdminWidgetDashBoard
                0  // Set 1 if the App have a Member Module
        );
    }

    /**
     * Start Admin
     */
    function Run() {
        echo parent::RunApp($this->Core, "estimation", "estimation");
    }

    /***
     * Save une ville
     */
    function SaveCity(){
        
        $adminController = new AdminController($this->Core);

        if ($adminController->SaveCity($this->Core, Request::GetPosts())) {
            return Response::Success($adminController->GetTabCity());
        } else {
            return Response::Error();
        }
        
    }
    
    
    function ville($params){
        
        $frontController = new FrontController($this->Core);
        return $frontController->Secteur($params);
    }
    
    /*     * *
     * Run member Controller
     * 
     * /
      /*function RunMember(){
      $memberController = new MemberController($this->Core);
      return $memberController->Index();
      } */

    /**
     * Get The siteMap 
     */
     public function GetSiteMap($returnUrl = false){
      return SitemapHelper::GetSiteMap($this->Core, $returnUrl);
     }

    /*     * *
     * Get the widget
     */
    /* public function GetWidget($type = "", $params = "") {

      switch ($type) {
      case "AdminDashboard" :
      $widget = new \Apps\estimation\Widget\AdminDashBoard\AdminDashBoard($this->Core);
      break;
      }

      return $widget->Render();
      } */

    /*     * *
     * Get Forum Addable widget
     */
    /* public function GetListWidget(){
      return array(array("Name" => "LastMessage",
      "Description" => $this->Core->GetCode("estimation.DescriptionLastMessageWidget")),
      );
      } */
}
