<?php

include_once(dirname(__FILE__).'/../../Base/Controller.php');
include_once(dirname(__FILE__).'/../Model/Measure.php');

class AddController extends Controller
{
  function Show()
  {
    $this->System->Output->FullPage = false;

    $Output = '';
    if(!array_key_exists('MeasureId', $_GET)) return('Nebylo zadáno Id měření.');
    if(!array_key_exists('Value', $_GET)) return('Nebyla zadána hodnota.');
    $Measure = new Measure($this->System);
    $Measure->Load($_GET['MeasureId']);
    if(!isset($Measure->Data['Id'])) return('Měření s Id '.$_GET['MeasureId'].' nenalezeno.');
    $Measure->AddValue(array('Min' => $_GET['Value'], 'Avg' => $_GET['Value'], 'Max' => $_GET['Value']));
    //$View = new MeasureView($this->System);
    //return($View->Add());
    return($Output);
  }
}
