<?php require('header.php'); ?>
<?php require('veritabani.php'); 
if(!isset($_SESSION["password"]))

	
	 {
		echo "<br><center><h2>Yoktur";
}else{
	
	function my_session_start($timeout = 14) {
    ini_set('session.gc_maxlifetime', $timeout);
    session_start();

    if (isset($_SESSION['timeout_idle']) && $_SESSION['timeout_idle'] < time()) {
        session_destroy();
        session_start();
        session_regenerate_id();
        $_SESSION = array();
    }

    $_SESSION['timeout_idle'] = time() + $timeout;
}?>

<script>
function SayiKontrol(e) {
	olay = document.all ? window.event : e;
	tus = document.all ? olay.keyCode : olay.which;
	if(tus<48||tus>57) {
		if(document.all) { olay.returnValue = false; } else { olay.preventDefault(); }
	}
}

function HarfKontrol(e) {
	olay = document.all ? window.event : e;
	tus = document.all ? olay.keyCode : olay.which;
	if(tus>=48&&tus<=57) {
		if(document.all) { olay.returnValue = false; } else { olay.preventDefault(); }
	}
}
</script>
<script language="JavaScript">
function kontrol() 
{
 var bilgi=document.form.ara.value;
 if (bilgi !="") return true;
 else alert ('Lütfen Boş Bırakmayınız !')
 return false;
}
</script>

    <div class="row">
    <div class="box col-md-12">
    <div class="box-inner">
    <div class="box-header well" data-original-title="">
        <h2><i class="glyphicon glyphicon-user"></i> Müşteri Çeki Sorgulama </h2>
		


        <div class="box-icon">
            <a href="#" class="btn btn-setting btn-round btn-default"><i class="glyphicon glyphicon-cog"></i></a>
            <a href="#" class="btn btn-minimize btn-round btn-default"><i
                    class="glyphicon glyphicon-chevron-up"></i></a>
            <a href="#" class="btn btn-close btn-round btn-default"><i class="glyphicon glyphicon-remove"></i></a>
        </div>
    </div>

				<form  name=form method=post action="cek.php?ck=sor" onSubmit="return kontrol()">
&nbsp;&nbsp;&nbsp;<div class="control-group">
                  
                    
        </form>

	
<div class="control-group">
     <div class="form-group has-success col-md-4">
		    <label class="control-label"  for="ara">Çek Kodu</label><br>
                    <input type="text" value="" onkeypress="SayiKontrol(event)" class="form-control" name="ara">
					 
                <br><br>
				
                    <button type="submit" id="submit" class="btn btn-default">  &nbsp;&nbsp;&nbsp;   Ara    &nbsp;&nbsp;&nbsp; </button>
 </div>
</form>
<a href="" target="_blank"></a>
    <table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
   
	
<?



$ck = @$_GET["ck"];
switch($ck){
case"sor":
 
	if ($_POST){
    $ara=$_POST["ara"];
	
	
	$sorgu=odbc_exec($conn2," 
select ID,Cek_No,Cari_Kod,Tutar,Baslangic,Bitis,Flag,Sube_Kodu,Kasa_No,DATEMODIFIED from INTERBONUS_INDIRIMCEK WHERE Cek_no LIKE '%$ara%'
             
  
  ");
   
$kayit1=odbc_num_rows($sorgu);

  if ($kayit=odbc_num_rows($sorgu)>0)
  {	 
	  echo "<center><h3>$kayit1  Kayıt Bulundu";
	 
  }else{

	  echo "<center><h3>Kayıt Bulunamadı";

  }
 


 while($kayit=odbc_fetch_array($sorgu))
	{
		
		$ahmet = $kayit["Flag"];
		
		if (($ahmet)>0){
			
			$kul = "<font color='red'>ÇEK PASİF</font>";
		}
		
		else {
			
			$kul = "<font color='green'>ÇEK AKTİF</font>";
		}
$gonder = $kayit["ID"];
	?>
	 <thead>
    <tr>
        <th>Çek Kodu</th>
        <th>Şube Kodu</th>
        <th>Kasa No</th>
        <th>Tutar</th>
        <th>Kullanım Tarihi</th>
        <th>Durumu</th>
        <th>İşlemler</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td><h4><? echo $kayit["Cek_No"]; ?></td>
        <td class="center"><h4><? echo $kayit["Sube_Kodu"]; ?></td>
        <td class="center"><b><h4><? echo $kayit["Kasa_No"]; ?></td>
	<td class="center"><h4><? echo $kayit["Tutar"]; ?>&nbsp;₺</td>
	<td class="center"><h4><? echo $kayit["DATEMODIFIED"]; ?></td>
	
	<td class="center"><h4><? echo $kul; ?></td>
       
           
        </td>
        <td class="center">
	
			<a href="?ck=cek_ac&id=<?echo $kayit["ID"];?>" id="sumbit"  class="btn btn-success">
               Aktif Et
            </a>
			<a href="?ck=cek_kapa&id=<?echo $kayit["ID"];?>" id="sumbit"class="btn btn-danger">Pasif Et</a>
			
			</td>
			
          
        </td>
    </tr>
   
    </tr>
               </div>
        </div>
    </div><!--/span-->
		<?
 }
 		}else{
			echo 'Eslesen Kayit Yok.';
		}
?>
     <?// ***************************************************************Çek öldür ************************************************************
break;
case"cek_ac"
?>



<?


        $ad = $_GET["id"]; 
$liste = odbc_exec($conn2,"update INTERBONUS_INDIRIMCEK SET Flag=0 WHERE ID='$ad'");  

			
                   if(odbc_num_rows($liste)>0){ 
				   
				      ?> <center>
 <table >
	

	<tbody>
	<tr>
			
			<td><font face="Cambria" size="4" color="#fff"><b><span class="check"><br><br>İşlem Başarılı...<br><br>Çek Aktif Edildi</span></font></td>
		
		</tr>
		
		
		</table>

		
<?}else{?>
 <table class="table1">
	

	<tbody>
	<tr>
			
			<td><font face="Cambria" size="4" color="#fff"><b><span class="checks"><br><br>İşlem Başarısız...<br>Kod Bozuk<br></span></font></td>
		
		</tr>
		
		
		</table>
		
		<?}?>
		<?// ***************************************************************Çek öldür ************************************************************
break;
case"cek_kapa"
?>
<table class="table1">
	

	<tbody>
	<tr>
			
			<td><font face="Cambria" size="4" color="#fff"><b><span class="check"><br><br>İşlem Başarılı...<br><br>Çek Pasif Edildi</span></font></td>
		
		</tr>
		
		
		</table>


<?


        $kapa = $_GET["id"]; 
$liste = odbc_exec($conn2,"update INTERBONUS_INDIRIMCEK SET Flag=1 WHERE ID='$kapa'");  

			
        //******************************************************** bitti **************************************  
	
?>


  <?
  
 
	}
	
		
		
?>  
<?php require('footer.php'); }?>
