<?php

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

namespace Apps\Asso\Module\DialogAdminAsso;

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

use Apps\Asso\Entity\AssoMember;
use Apps\Asso\Widget\AssoMemberForm\AssoMemberForm; 
use Apps\Asso\Entity\AssoMemberShip;
use Apps\Asso\Widget\AssoMemberShipForm\AssoMemberShipForm; 

use Apps\Asso\Entity\AssoReceipt;
use Apps\Asso\Widget\AssoBudgetReceiptForm\AssoBudgetReceiptForm; 

use Apps\Asso\Entity\AssoExpense;
use Apps\Asso\Widget\AssoBudgetExpenseForm\AssoBudgetExpenseForm; 

use Apps\Asso\Entity\AssoEquipment;
use Apps\Asso\Widget\AssoEquipmentForm\AssoEquipmentForm; 

/*
 * 
 */
 class DialogAdminAssoController extends AdministratorController
 {
    /**
     * 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 a member
     */

     function AddMember($memberId) {
        $memberForm = new AssoMemberForm($this->Core);

        if ($memberId != "") {
            $member = new AssoMember($this->Core);
            $member->GetById($memberId);
            $memberForm->Load($member);
        }

        return $memberForm->Render();
    }

   /* * *
     * Add a member ship
     */

     function AddMemberShip($memberShipId) {
        $memberShipForm = new AssoMemberShipForm($this->Core);

        if ($memberShipId != "") {
            $memberShip = new AssoMemberShip($this->Core);
            $memberShip->GetById($memberShipId);
            $memberShipForm->Load($memberShip);
        }

        return $memberShipForm->Render();
    }

    /***
     * Ajoute/Edite une ligne de recette
     */
    function AddBudgetReceipt($receiptId){

        //AssoBudgetReceiptForm 
        //AssoReceipt
        $budgetReceiptForm = new AssoBudgetReceiptForm($this->Core);

        if ($receiptId != "") {
            $budgetReceipt = new AssoReceipt($this->Core);
            $budgetReceipt->GetById($receiptId);
            $budgetReceiptForm->Load($budgetReceipt);
        }

        return $budgetReceiptForm->Render();

    } 
    
    /***
     * Ajoute/Edite une ligne de dépense
     */
    function AddBudgetExpense($expenseId){

        $budgetExpenseForm = new AssoBudgetExpenseForm($this->Core);

        if ($expenseId != "") {
            $budgetExpense = new AssoExpense($this->Core);
            $budgetExpense->GetById($expenseId);
            $budgetExpenseForm->Load($budgetExpense);
        }

        return $budgetExpenseForm->Render();
    }

    /***
     * Ajoute/Edite un equipment
     */
    function AddEquipment($equipmentIdId){

        $assoEquipmentForm = new AssoEquipmentForm($this->Core);

        if ($equipmentIdId != "") {
            $equipment = new AssoEquipment($this->Core);
            $equipment->GetById($equipmentId);
            $assoEquipmentForm->Load($equipment);
        }

        return $assoEquipmentForm->Render();
    }
    
          /*action*/
 }?>