<?php include('header.php'); ?>

 <head>
  
  
  
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/js/bootstrap-multiselect.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css" />
 </head>

<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-edit"></i>Ciro Raporu</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>
            <div class="box-content">

                <form name="form" method="post" action="stok.php?ck=sor" role="form">
				
     



   

   
	
	
	
	
    <div class="form-group">
    



				           <div class="form-group has-success col-md-4">
                        <input type="date" class="form-control" name="date" >
                    </div>
				
				          <div class="form-group has-success col-md-4">
                        <input type="date" class="form-control" name="date2" >
                    </div>

                   
               
                   &nbsp&nbsp&nbsp <button type="submit" class="btn btn-default"> &nbsp&nbsp&nbsp Raporla &nbsp&nbsp&nbsp</button>
                </form>

            </div>
        </div>
    </div>
    <!--/span-->
<?php if ($_POST){
    $ara=$_POST["date"];
	$araa=$_POST["date2"];
	$say=$_POST["say"]; 
	
	
	?>
	
</div><!--/row-->

<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> Ciro Raporu</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 class="box-content">
                    <table class="table table-striped table-bordered responsive">
                        <thead>
                        <tr>
                            <th>Mağaza Adı</th>
                            <th>Kredi</th>
                            <th>Nakit</th>
                            <th>Çek</th>
                            
                    
                        </tr>
                        </thead>
<?php

	if(empty($ara) && empty($araa)) {
      echo '    <div class="alert alert-danger">
                    <button type="button" class="close" data-dismiss="alert">&times;</button>
                    <strong>Hata</strong> Lütfen Boş Bırakmayınız
                </div>';
	 
   } else {
	
	$tarih = date("Y-m-d"); 
	
	$sql_check = odbc_exec($conn,"SELECT 
      [magazaadi] ,ISNULL (sum (CASE WHEN od.odemetipi = 'KREDI' THEN od.tutar end) - (sum (CASE WHEN od.odemetipi = 'KREDI' and od.belgetipi = 'GPS' THEN od.tutar*2 else 0 end )) ,0) as Kredi,
	 ISNULL( sum (CASE WHEN od.odemetipi = 'NAKIT' THEN od.tutar end ) - (sum (CASE WHEN od.odemetipi = 'NAKIT' and od.belgetipi = 'GPS' THEN od.tutar*2 else 0 end )),0) as Nakit,
	 ISNULL ( sum (CASE  WHEN od.odemetipi = 'CEK' THEN od.tutar end ),0) as Cek,
	  ISNULL ( sum (CASE WHEN od.belgetipi = 'GPS' THEN  od.tutar end ),0) as NetToplam
  FROM [POSNET].[dbo].[MAGAZAKASA] as mk

  INNER JOIN [POSNET].[dbo].[ODEME] AS od on od.kasano=mk.kasano WHERE 

  (CAST(od.tarih AS date) >='$ara' and CAST(od.tarih AS date) <= '$araa')

  group by mk.magazaadi order by mk.magazaadi asc  ");
//$satiar= pg_fetch_array($sql_check);
 while($satir = odbc_fetch_array($sql_check)) { 
	
	
$adi = $satir['magazaadi'];
$kredi = $satir["Kredi"];
$nakit = $satir["Nakit"];
$cek = $satir["Cek"];

  $kredi_ciro = number_format($kredi, 2, ',', '.');
  $nakit_ciro = number_format($nakit, 2, ',', '.');
  $cek_ciro = number_format($cek, 2, ',', '.');
  
$kredi_top   += $satir["Kredi"];
$nakit_top   += $satir["Nakit"];
$cek_top     += $satir["Cek"];


  $kredi_toplam = number_format($kredi_top, 2, ',', '.');
  $nakit_toplam = number_format($nakit_top, 2, ',', '.');
  $cek_toplam = number_format($cek_top, 2, ',', '.'); 

?>
                        <tbody>
                        <tr>
                          
                            <td class="center"><b><?php echo $satir["magazaadi"]; ?></td>
                            <td class="center"><?php echo $kredi_ciro; ?></td>
                            <td class="center"><?php echo $nakit_ciro; ?></td>
                            <td class="center"><?php echo $cek_ciro; ?></td>
                            
                        </tr>
 <?php }     }}?>     
                          
                            <td class="center"><b></td>
                            <td class="yellow"><?php echo $kredi_toplam; ?></td>
                            <td class="yellow"><?php echo $nakit_toplam; ?></td>
							
						
                            <td class="yellow" ><?php echo $cek_toplam; ?></td>
                       
                        </tr>
                            
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!--/span-->

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

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