<?php
namespace admin\view;

class Menu
{
	public static function showMenu()
	{
		$out = \admin\view\PagePanel::show( true, false, false, 'Menu' );

		$dbrowse = new \DataBrowse( 'pp_menu' );
		$dbrowse -> addPosition( 'name',    'Nazwa',    '', '', '', 'name' );
		$dbrowse -> addPosition( 'enabled', 'Aktywne',  './?rw=change-enabled', \System::getComboYesNo() );
		$dbrowse -> addPosition( 'type',    'Typ',      '', \admin\factory\Menu::getMenuType() );
		$dbrowse -> addPositionSimple( 'edytuj',  '', './?rw=edit' );
		$dbrowse -> addPositionSimple( 'usuń',    '', '', \System::deleteAction() );
		$dbrowse -> setParam( 'id' );
		$dbrowse -> addSort( 'id ASC' );
		$dbrowse -> addLp();
		$out .= $dbrowse -> draw();

		return $out;
	}

	public static function editMenu( $id = '' )
	{
    $id ? $value = 'Zapisz' : $value = 'Dodaj';
		$out = \admin\view\PagePanel::show( false, $value, true, 'Menu' );

		$dbedit = new \DataEdit( 'pp_menu', 'id', $id );
		$dbedit -> addPosition( 'name',     'Nazwa',    'text' );
		$dbedit -> addPosition( 'enabled',  'Aktywne',  'radio', '', \System::getComboYesNo() );
    $dbedit -> addPosition( 'type',     'Typ',      'combo', '', \admin\factory\Menu::getMenuType() );
		$out .= $dbedit -> draw();

		return $out;
	}
}
?>
