<?php include 'inc/header.php';?>
<?php include 'inc/sidebar.php';?>
<?php include 'inc/navbar.php';?>
<?php

if(!empty($_POST)){

	$id = $_GET["id"]; 

	$masa_adi = $_POST['masa_adi'];


	$update = $dbh->prepare("UPDATE masa_no SET masa_adi = '".$masa_adi."' WHERE id = '".$id."'");

	$update->execute();

}

?>

<?php

$sorgu = $dbh->prepare("SELECT * FROM masa_no Where id=:id");
$sorgu->execute(['id' => (int)$_GET["id"]]);
$sonuc = $sorgu->fetch(); 


?>
<!-- Page Content-->
<div class="page-content">
	<div class="container-fluid">
		<!-- Page-Title -->

		<form method="post" action="" enctype="multipart/form-data">

			<div class="row">
				<div class="col-sm-12">
					<div class="page-title-box">
						<div class="row">
							<div class="col">
								<h4 class="page-title">Masa Düzenle - <?=$sonuc['masa_adi'];?></h4>
								<ol class="breadcrumb">
									<li class="breadcrumb-item"><a href="index.php">Anasayfa</a></li>
									<li class="breadcrumb-item"><a href="masa-liste.php">Masa Listesi</a></li>
									<li class="breadcrumb-item active">Masa Düzenle</li>
								</ol>
							</div><!--end col-->
							<div class="col-auto align-self-center">
								<button class="btn btn-primary" type="submit">
									<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
									GÜNCELLE
								</button> 
							</div><!--end col-->  
						</div><!--end row-->                                                              
					</div><!--end page-title-box-->
				</div><!--end col-->
			</div><!--end row-->
			<!-- end page title end breadcrumb -->


			<div class="row">
				<div class="col-lg-12">
					<div class="card">
						<div class="card-header">
							<h4 class="card-title">Masa Düzenle</h4>
							<p class="text-muted mb-0">Değerli kullanıcı, bu alan sayesinde masalara özel QR kodu görüntüleyebilirsiniz.</p> 
						</div><!--end card-header-->
						<div class="card-body">

							<div class="row">

								<?
								$sssms= "SHOW TABLE STATUS LIKE 'masa_no'";
								$sth = $dbh->prepare( $sssms);
								$sth->execute();

								/* Sonuç kümesindeki tüm satırları alalım */

								$result = $sth->fetch();
								$phpself=explode("/",dirname($_SERVER['PHP_SELF']));
								unset($phpself[count($phpself)-1]);
								$phpself= implode("/",$phpself);

								$qrtext="https://". $_SERVER['HTTP_HOST'] . $phpself."/index.php?masa=".md5($_GET["id"]);

								ob_start();
								include __DIR__."/../includes/siniflar/phpqrcode/qrlib.php";

								QRCode::png($qrtext, null, QR_ECLEVEL_L, 20);
                                          // phpqrcode_logolu::olustur($qrtext, "../img/$ayar['foto']);
								$imageString = base64_encode( ob_get_contents() );
								ob_end_clean();
								?>

								<div class="col-xl-12">  
									<div class="form-group"> 
										  <center><img width="300"  src="data:image/png;base64,<?=$imageString?>" /></center>
									</div>
								</div>

								<div class="col-xl-12">  
									<div class="form-group">
										<label for="exampleInputEmail1">Masa Adı</label>
										<input type="text" class="form-control" maxlength="999" id="thresholdconfig" aria-describedby="emailHelp" placeholder="Masa Adı" name="masa_adi" value="<?=$sonuc['masa_adi'];?>"> 
									</div>
								</div> 

							</div>



							  
							<!-- dil bitişi --> 

							<br>    
							<button class="btn btn-primary btn-block" type="submit">
								<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
								GÜNCELLE
							</button>
						</form>                                           
					</div><!--end card-body-->
				</div><!--end card-->
			</div><!--end col-->


		</div><!--end row-->



	</div><!-- container -->

	<?php include 'inc/footer.php';?>

