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

 <head>
  
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  
  
  <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-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>         <?php
$tarih = date("Y-m-d");
$tarih2 = date("Y-m-d");
			if(isset($_POST['date'])){
$tarih = $_POST['date'];
$tarih2 = $_POST['date2'];
}else if (isset($_SESSION['tarih'])){ 
 
 $tarih = $_SESSION['tarih'];
 $tarih2 = $_SESSION['tarih2'];

 }else{
$tarih = date("Y-m-d");
$tarih2 = date("Y-m-d");

 	
 } ?>
            <div class="box-content">

                <form name="form" method="post" role="form">
				
     	
    <div class="form-group">
    



				           <div class="form-group has-success col-md-4">
                        <input type="date" class="form-control" value="<?php echo $tarih ; ?>" name="date" >
                    </div>
				
				          <div class="form-group has-success col-md-4">
                        <input type="date" class="form-control" value="<?php echo $tarih2; ?>" name="date2" >
                    </div>

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

            </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>Toplam Ciro</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"); 
	$gdr =odbc_exec($conn," 
 SELECT SUM(toplam)toplam,st.adi,bt.tip
  FROM 
  
  [online_ciro].[dbo].[belge_tanim] as bt
  inner join kasa_tanim as ks on ks.no = bt.kasa_no
  inner join sube_tanim as st on st.id= ks.sube_id
  where 
  tarih >= '$ara' and tarih <= '$araa' and
  iptal=0 and
  tip like '%DER PUSULAS%' 
  group by st.adi	,tip

 ");

while($ver=odbc_fetch_array($gdr)){
	
	$giders += $ver["toplam"];
	
}

	$sql_check = odbc_exec($conn,"
SELECT SUM(toplam)toplam,st.adi
  FROM 
  
  [online_ciro].[dbo].[belge_tanim] as bt
  inner join kasa_tanim as ks on ks.no = bt.kasa_no
  inner join sube_tanim as st on st.id= ks.sube_id
  where tarih between '$ara' and '$araa' and 
  iptal=0  and tip != 'GiDER PUSULASI' group by st.adi	
  
  ");

 while($satir = odbc_fetch_array($sql_check)) { 
	
	
$adi = $satir['adi'];
$kredi = $satir["Kredi"];
$nakit = $satir["toplam"];
$gtoplamm += $satir["toplam"];

 $gtop = $gtoplamm - $giders;


  $gider = number_format($gider, 2, '.', ',');
  $kredi_toplam = number_format($kredi_top, 2, ',', '.');
  $nakit_toplam = number_format($nakit, 2, ',', '.');
  $gtoplam = number_format($gtoplamm, 2, ',', '.'); 
  $gtoplams = number_format($gtop, 2, ',', '.'); 

?>
                        <tbody>
                        <tr>
                          
                            <td class="center"><b><?php echo $adi; ?> </td>

                            <td class="center"><?php echo $nakit_toplam.'  '.'₺'; ?></td>
                        
                            
                        </tr>
 <?php }     } ?>      <tr>
                            <td class="center">
							<p align="right" >Toplam </p>
							<p align="right" >Gider </p>
							<p align="right" >G.Toplam </p>
						
							
							
							</td>
                            
                            <td class="yellow"><p><?php echo $gtoplam.'  '.'₺'; ?></p>
                            <p class="red">-<?php echo $giders.'  '.'₺'; ?></p>
                            <p class="green"><b><?php echo $gtoplams .'  '.'₺'; ?></p>
							
							</td>
					 
                
                        </tr>
						
                  <?php } ?>          
                      
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!--/span-->


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