<?php require('header.php');
$bugun = date("Y-m-d");
$yenitarih = strtotime('-1 day',strtotime($bugun));
$dun = date('Y-m-d' ,$yenitarih );
						
@session_start();
header('Content-type: text/html; charset=utf-8');
?><script type="text/javascript" src="js/datatables.min.js"></script>
<!DOCTYPE html>
<html lang="tr">
<head>
 <meta charset="UTF-8">
</head>
<body onload="setTimeout('timeout()', 50)"></body>

<div class="row">
        <div class="box col-md-12">
            <div class="box-inner">
                <div class="box-header well" data-original-title="">
                    <h2><?php echo $bugun; ?> &nbsp  Kasa Bazlı Satış Durum</h2>

                    <div class="box-icon">
                        
                        <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>
				<div id="main_fb">
   <div id="friend_list">
                <div class="box-content">
                    <table id="myTable" class="table table-striped table-bordered bootstrap-datatable datatable responsive">
                        <thead>
                    <th>Kasa No</th>
        <th>B.Tipi</th>
        <th>B.Adet</th>
		 <th>İndirim</th>
		 <th>Nakit</th>
		 <th>Kredi Kartı</th>
		<th>Tutar</th>
       
               
               
                    
                        </thead>

						<?php 
function turkcelestir($yazi) {
	$yazi = trim($yazi);
	$bul = array('Ç','ç','Ğ','ğ','ı','İ','Ö','ö','Ş','ş','Ü','ü',' ');
	$degis = array('c','c','g','g','i','i','o','o','s','s','u','u',' ');
	$hatasiz = str_replace($bul, $degis, $yazi);
	return $hatasiz;
	}	

	$ck = @$_GET["ck"];
switch($ck){
case"detay":
 $ad = $_GET["id"];  	

						
	$sorgu=odbc_exec($conn,"  select  count (tip) belgeadet ,sube.adi magaza,  ( case when bt.iptal = 1 then 'İPTAL ' +bt.tip else bt.tip end) tip ,
 bt.kasa_no kasano ,   sum(bt.toplam) toplam  , 
 ISNULL( sum(od.nakit),0) nakit ,ISNULL(sum(od.kredi ),0)kredi , sum(de.indirim + bt.aratoplam_indirim) indirim 
 from [online_ciro].dbo.[belge_tanim] as bt 
 OUTER APPLY (select tanim_id, sum(  case when no = 0 then odeme else 0 end ) nakit , 
 sum(  case when no <> 0 then odeme else 0 end ) kredi  
 from[online_ciro].dbo.[belge_odeme] where tanim_id = bt.id group by tanim_id ) as od  
 OUTER  APPLY (select tanim_id, sum( indirim  ) indirim  from[online_ciro].dbo.[belge_detay]
 where tanim_id = bt.id and tutar >= 0   group by tanim_id ) as de  inner join [online_ciro].dbo.[kasa_tanim] 
 as kasa on kasa.no = bt.kasa_no  inner join [online_ciro].dbo.[sube_tanim] as sube on sube.id = kasa.sube_id 
 where tarih >= '$bugun' and tarih <= '$bugun' and sube.adi = '$ad'  
 group by  sube.adi, tip , iptal ,kasa_no ,  tarih ,tip order by  sube.adi, 
 bt.kasa_no, bt.tarih 
         
");
  
       while($kayit=odbc_fetch_array($sorgu))
	{	
$tipp =$kayit["tip"];
$tips =   turkcelestir($tipp);
							
$tip =  mb_convert_encoding($tips  , "UTF-8", "ISO-8859-9");
 $indirim = number_format($kayit["indirim"], 2, ',', '.');
 $nakit = number_format($kayit["nakit"], 2, ',', '.');
 $kredi = number_format($kayit["kredi"], 2, ',', '.');
 $toplam = number_format($kayit["toplam"], 2, ',', '.');
	
?> 


                        <tbody>
                        <tr>
 <td class="center"><h4><b>Kasa - <?php echo $kayit["kasano"]; ?></td>
        <td class="center"><h4><b><?php echo $tip; ?></td>
		<td class="center"><h4><b><?php echo $kayit["belgeadet"]; ?></td>
		<td class="center"><h4><b><?php echo $indirim.' '.'₺'; ?></td>
		<td class="center"><h4><b><font color='yellow'><?php echo $nakit.' '.'₺'; ?></td></font>
		<td class="center"><h4><b><font color='yellow'><?php echo $kredi.' '.'₺'; ?></td></font>
		<td class="center"><h4><b><font color='yellow'><?php echo $toplam.' '.'₺'; ?></td></font>
		    <td><center>							
                     <a href="detays.php?ck=<?php echo utf8_encode($kayit["kasano"]);?>" id="sumbit"  class="btn btn-success">
               Detay</a>
                            </td>
                        </tr>
<?php }} ?>

                      <tr>
					  <td ><center></center></td>
					  <td><center></center></td>
					
					  
					  </tr>
                        </tbody>
                    </table>
                   
                </div>
            </div>
        </div>
    </div><!--/span-->
	</div>
</div>
<head>

<script type="text/javascript">
$(function () {
$("#top").click(function () {

$("html,body").stop(

).animate({ scrollTop: "0" }, 100);
});
});
$(window).scroll(function () {
var uzunluk = $(document).scrollTop();
if (uzunluk > 500) $("#top").fadeIn(700);
else { $("#top").fadeOut(500); }
});
</script>





<script>
        $('#myTable').DataTable({
            language: {
                info: "_TOTAL_ kayıttan _START_ - _END_ kayıt gösteriliyor.",
                infoEmpty:      "Gösterilecek hiç kayıt yok.",
                loadingRecords: "Kayıtlar yükleniyor.",
                zeroRecords: "Tablo boş",
                search: "Arama:",
                infoFiltered:   "(toplam _MAX_ kayıttan filtrelenenler)",
                buttons: {
                    copyTitle: "Panoya kopyalandı.",
                    copySuccess:"Panoya %d satır kopyalandı",
                    copy: "Kopyala",
                    print: "Yazdır",
                },

                paginate: {
                    first: "",
                    previous: "",
                    next: "",
                    last: ""
                },
            },
            dom: 'Bfrtip',
            buttons: [
                'copy', 'excel', 'pdf', 'print'
            ],
            responsive: true
        });
</script>
</head>
<head>
<script type="text/javascript">
$(function () {
$("#top").click(function () {

$("html,body").stop(

).animate({ scrollTop: "0" }, 1000);
});
});
$(window).scroll(function () {
var uzunluk = $(document).scrollTop();
if (uzunluk > 500) $("#top").fadeIn(700);
else { $("#top").fadeOut(500); }
});
</script>
<style type="text/css">
#top {
bottom: 5px;
bottom: 20px;
display: none;
height: 100px;
position: fixed;
right: 20px;
}
</style>
</head>
<body>
<div id="top">
<br />
<img width="50" height="50" src="img/yukari.png" />
</div>
</body>
<?php require('footer.php'); ?>

</html>























