<?php
$isCup = TRUE;

require_once('incl/_inclConn.php');
require_once('lang/_lang.php');
require_once('lang/langMatcher.php');
$bExtGames	 	= TRUE;
$nav 			= 'Matcher';
$subnav 		= 'MatcherDatum';

IF ($_GET['dDate'] <> '') {
	$antDateTecken 	= strlen($_GET['dDate']);
	$dNewDate 		= substr($_GET['dDate'], 0 , 4) . substr($_GET['dDate'], 5 , 2) . substr($_GET['dDate'], 8 , 2);
	if (is_numeric($dNewDate) && $antDateTecken == 10) {
		$dDate = $_GET['dDate'];
	} else {
		header("location: /planer.php?iCupID=".$iCupID."");
		exit;
	}
}

if ($_GET['sPitch']<>'' && !ctype_digit($_GET['sPitch']))  {
	header("location: /planer.php?iCupID=".$iCupID."");
	exit;
}

/* Om set-poäng/perioder*/
$bSetpoints = FALSE;
IF ($rsSport['sSets'] == '1') {
	$bSetpoints = TRUE;
}

/* Meta - title, description */
$siteTitel = $rsCupInfo['sName'] . ' - ' . $h_siteheader . ' ' . $_GET['dDate'];
$siteDescription = '';?>

<?php require_once('page/cupHead.php');?>
<?php require_once('page/cupPagetop.php');?>

<div class='container maincontent first <?php if ($pageLayout == '9') {?> pageheader<?php }?> pp'>
	<?php if ($pageLayout == '9') {
		IF ($_GET['sPitch'] <> '') {
			$sql = "SELECT * FROM tCupFields 
		
				WHERE iCupID = :iCupID 
				AND iFieldID = :iFieldID 
			";

			$paramsPitch = withCupID([
				'iFieldID'=> htmlentities($_GET['sPitch'])
			]);
			
			$rsPitchInfo = $dbConn->getRowParams($sql, $paramsPitch);
			//$rsPitchInfo = $dbConn->getRow("SELECT * FROM tCupFields WHERE iCupID = '".$iCupID."' AND iFieldID = ".$_GET['sPitch']."");
			$rsPitchInfo['sName'];
		}

		IF ($_GET['dDate'] <> '') {
			$iWeekDay = date("w", strtotime($_GET["dDate"]));
			$day = $dag[$iWeekDay];
			$sSecond = substr($day, 1 , 1);
			IF ($sSecond == '&') {
				$pos = stripos($day, ";");
				$antbokst = $pos + 1;
			} ELSE {
				$antbokst = 3;
			}
			$dValddag = substr($dag[$iWeekDay], 0, $antbokst);
			
			$iMonth = date("n", strtotime($_GET["dDate"]));
			$month = $manad[$iMonth];
			$sSecondM = substr($month, 1 , 1);
			IF ($sSecondM == '&') {
				$posM = stripos($month, ";");
				$antbokstM = $posM + 1;
			} ELSE {
				$antbokstM = 3;
			}
			$dValdmanad = strtolower(substr($manad[$iMonth], 0, $antbokstM));
		}?>
		<div class="pageheaderContainer">
			<h2><?php if ($_GET['sPitch'] <> '') {?><?php echo $rsPitchInfo['sName'];?> - <?php }?><?php echo $dValddag;?> <?php echo date("j", strtotime($_GET['dDate']));?> <?php echo $dValdmanad;?> <?php echo date("Y", strtotime($_GET['dDate']));?></h2>
		</div>
	<?php }?>

	<div class='row'>
	
		<main id="main" class='col-md-<?php if ($pageLayout == '5' || $pageLayout == '6' || $pageLayout == '8' || $pageLayout == '9') {?>12<?php } else {?>9<?php }?>'>
			
			<?php require_once('incl/inclSiteMatcherDatum.php');?>
			
		</main>
		<?php if ($pageLayout <> '5' && $pageLayout <> '6' && $pageLayout <> '8' && $pageLayout <> '9') {?>
			<aside class='col-md-3 secondary'>
				
				<?php include('incl/inclMatchcolumn.php');?>
				
			</aside>
		<?php }?>
	</div><!--/.row-->
</div><!--/.container-->

<?php require_once('page/cupPagebottom.php');?>