<?php

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

namespace Apps\Reward\Module\DialogReward;

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

use Apps\Reward\Widget\RewardUserForm\RewardUserForm;
use Apps\Reward\Entity\RewardUser;

use Apps\Reward\Entity\RewardGifts;


/*
 * 
 */
 class DialogRewardController 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();
   }

   /***
    * Show Add Response Reward
    */
   function ShowAddResponseReward($rewardId){

        $rewardUser = new RewardUser($this->Core);
        $rewardUser->RewardId->Value = $rewardId;

         $rewardUserForm = new RewardUserForm($this->Core, $rewardUser);
       
        
        $rewardUserForm->Load($rewardUser);
        return $rewardUserForm->Render();
   }
          
   /****
    * Demande de récompense
    */
   function Claim(){
       $view = new View(__DIR__."/View/claim.tpl", $this->Core);
       
       $gifts = new RewardGifts($this->Core);
       
       $view->AddElement(new ElementView("Gifts", $gifts->Find("1 = 1 order by Points asc")));
       
       return $view->Render();
   } 
   
   
   
          /*action*/
 }?>