<?php

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

namespace Apps\Shop\Module\Member;

use Core\Control\Button\Button;
use Core\Controller\Controller;
use Core\View\View;
use Core\View\ElementView;
use Core\Control\TabStrip\TabStrip;
use Core\Control\EntityGrid\EntityGrid;
use Core\Control\EntityGrid\EntityColumn;
use Core\Control\EntityGrid\EntityIconColumn;
use Core\Control\EntityGrid\EntityFunctionColumn;
use Core\Entity\Entity\Argument;
use Apps\Shop\Helper\ShopHelper;
use Apps\Shop\Helper\CommandHelper;




use Apps\Shop\Widget\ShopForm\ShopForm;

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

    /**Master Page */
    function Index(){

        $view = new View(__DIR__."/View/index.tpl", $this->Core);

        $gdCommand = new EntityGrid("gdCommand", $this->Core);
        $gdCommand->Entity = "Apps\Shop\Entity\ShopCommand";
        $gdCommand->App = "Shop";
        $gdCommand->Action = "GetTabCommand";
        
        $gdCommand->AddArgument(new Argument( "Apps\Shop\Entity\ShopCommand", "UserId", EQUAL, $this->Core->User->IdEntite));

        $gdCommand->AddOrder("Id desc");
        $gdCommand->AddColumn(new EntityColumn("Reference", "Name"));
        $gdCommand->AddColumn(new EntityColumn("DateCreated", "DateCreated"));
        $gdCommand->AddColumn(new EntityFunctionColumn("Product", "GetProduct"));
        $gdCommand->AddColumn(new EntityFunctionColumn("Total", "GetTotal"));
        $gdCommand->AddColumn(new EntityFunctionColumn("Status", "GetStatut"));
        
     
        /* TODO LIEN pour génere la facture pdf et le détail de la factue
          $gdCommand->AddColumn(new EntityFunctionColumn("Status", "GetLinkPdf"));

        $gdCommand->AddColumn(new EntityIconColumn("Action", 
                                                  array(array("EditIcone", "Shop.EditCommand", "Shop.EditCommand"),
                                                  )    
                          ));
*/
        
        $view->AddElement(new ElementView("Commands", $gdCommand->Render()));

        
        return $view->Render();
     }
}