System->PathItems[0] == '') return($this->ShowMenu());
else if($this->System->PathItems[0] == 'tisk') return($this->ShowPrint());
else if($this->System->PathItems[0] == 'menuedit') return($this->ShowEdit());
else return(PAGE_NOT_FOUND);
}
function ShowMenu()
{
//echo('Dnes je '.HumanDate(date('Y-m-d')).'
');
$Output = '
Den | Datum | Polévka | Hlavní jídlo |
';
$DbResult = $this->Database->select('Meals', '*, UNIX_TIMESTAMP(Date)','Date >= NOW() ORDER BY Date');
while($Row = $DbResult->fetch_array())
{
if($Row['Status'] == 1) $Output .= ''.$this->DayNames[date('w', $Row['UNIX_TIMESTAMP(Date)'])].' | '.HumanDate($Row['Date']).' | '.$Row['Soup'].' | '.$Row['Meal'].' |
';
else if(($Row['Status' ] == 2) or ($Row['Status'] == 3))
{
$Output .= ''.$this->DayNames[date('w', $Row['UNIX_TIMESTAMP(Date)'])].' | '.HumanDate($Row['Date']).' | '.$this->Status[$Row['Status']].' |
';
}
}
$Output .= '
';
$DbResult = $this->Database->select('MealsInfo', '*');
$Row = $DbResult->fetch_array();
$Output .= 'Cena jednoho menu: '.$Row['Price'].' Kč
';
$Output .= $Row['Info'];
return($Output);
}
function ShowPrint()
{
$this->ClearPage = true;
$Output = '
Tisk jídelníčku
'; // onload="print()">');
//echo('Dnes je '.HumanDate(date('Y-m-d')).'
');
$Output .= '';
$Date = explode('-', $_GET['date']);
$Output .= '
DATUM: '.HumanDate($_GET['date']).' - '.HumanDate(date('Y-m-d',mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]) + 4 * 86400)).' |
CENY SMLUVNÍ |
„JÍDELNA NA KOPEČKU”
JÍDELNÍČEK
|
';
$Date = explode('-', $_GET['date']);
$Time2 = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]);
for($I = 0; $I < 5; $I++)
{
$Time = $Time2 + $I * 86400;
$Date = date('Y-m-d', $Time);
$DayOfWeek = date('w', $Time);
$DbResult = $this->Database->select('Meals', '*', 'Date="'.$Date.'"');
$Row = $DbResult->fetch_array();
$Output .= ''.$this->DayNamesShort[$DayOfWeek].' | ';
if($Row['Status'] == 0) $Output .= '
';
if($Row['Status'] == 1) $Output .= 'Polévka: '.$Row['Soup'].'
'.$Row['Meal'];
else if(($Row['Status'] == 2) or ($Row['Status'] == 3))
{
$Output .= ' '.$this->Status[$Row['Status']].' ';
}
$Output .= ' |
';
}
$DbResult = $this->Database->select('MealsInfo','*');
$Row = $DbResult->fetch_array();
$Output .= 'JÍDLA PŘIPRAVILA: '.$Row['Cook'].' |
PROVOZOVATEL: |
CENA JEDNOHO MENU JE '.$Row['Price'].' Kč |
';
$Output .= ''.$Row['PrintInfo'].' |
';
$Output .= '
';
$Output .= '';
$Output .= '';
return($Output);
}
function PrintTableRow($Row)
{
global $LastWeekOfYear;
$Selected = array('', '', '', '');
$Selected[$Row['Status']] = 'selected ';
$Date = explode('-', $Row['Date']);
$Week = date('w', mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]));
$WeekOfYear = date('W', mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]));
if($WeekOfYear != $LastWeekOfYear)
$WeekRowSpan = ''.
$WeekOfYear.' Tisk | ';
else $WeekRowSpan = '';
if($Week == 0) $Color = ' style="color: #ff0000;" '; else $Color = '';
$Output = ''.$this->DayNames[$Week].' | '.HumanDate($Row['Date']).' | '.$WeekRowSpan.'
|
|
|
';
$LastWeekOfYear = $WeekOfYear;
return($Output);
}
function ShowEdit()
{
if(!$this->System->User->CheckPermission('Meals', 'Edit'))
return('Nemáte oprávnění');
Header('Cache-Control: no-cache');
$Output = '';
if(array_key_exists('action', $_GET))
{
if($_GET['action'] == 'savemenu')
{
for($I = 0; $I < $this->DayCount; $I++)
{
$Time = time() + $I * 86400;
$Date = date('Y-m-d', $Time);
$this->Database->replace('Meals', array('Date' => $Date, 'Meal' => $_POST['meal_'.$Date], 'Soup' => $_POST['soup_'.$Date], 'Status' => $_POST['status_'.$Date]));
}
$Output .= 'Menu uloženo!
';
//$this->System->ModuleManager->Modules['Log']->NewRecord('EatingPlace', 'MenuSave');
}
if($_GET['action'] == 'saveinfo')
{
$this->Database->delete('MealsInfo', '1');
$this->Database->insert('MealsInfo', array('Info' => $_POST['info'],
'Price' => $_POST['price'], 'Cook' => $_POST['cook'], 'PrintInfo' => $_POST['printinfo']));
$Output .= 'Informační údaje uloženy!
';
//$this->System->ModuleManager->Modules['Log']->NewRecord('EatingPlace', 'InfoSave');
}
}
$Output = '';
$Output .= '';
return($Output);
}
}
class ModuleMeals extends AppModule
{
function __construct($System)
{
parent::__construct($System);
$this->Name = 'Meals';
$this->Version = '1.0';
$this->Creator = 'Chronos';
$this->License = 'GNU/GP255L';
$this->Description = 'Module for management meals. Can print week menu.';
$this->Dependencies = array();
$this->SupportedModels = array('Meals', 'MealsInfo');
}
function DoInstall()
{
}
function DoUnInstall()
{
}
function DoStart()
{
$this->System->RegisterPage('jidelna', 'PageEatingPlace');
$this->System->RegisterPage('menuedit', 'PageEatingPlace');
$this->System->RegisterPage('tisk', 'PageEatingPlace');
}
}