<?php require('header.php');

$bugun = date("Y-m-d");
$yenitarih = strtotime('-1 day',strtotime($bugun));
$yenitarih = date('d.m.Y' ,$yenitarih );


?>


<body onload="setTimeout('timeout()', 50)"></body>
<div>
        <ul class="breadcrumb">
            <li>
                <a href="posnet.php">Anasayfa</a>
            </li>
            <li>
                <a href="ciro.php">Şube Bazlı Finansal Detay</a>
            </li>
        </ul>
    </div>
<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  Finansal Dağılım</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 class="table table-striped table-bordered bootstrap-datatable datatable responsive">
                        <thead>
                    <th><center>Şube Adı</th>
                    <th><center>Nakit</th>
                    <th><center>Kredi Kartı</th>
                    <th><center>Çek</th>
                        </thead>
                        <tbody>
<?php $onay =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) = '$bugun'
  group by mk.magazaadi order by mk.magazaadi asc  ");
  
   while($kayit=odbc_fetch_array($onay))
	{	

	
	
  $kredi = $kayit["Kredi"];
  $nakit = $kayit["Nakit"];
  $cek = $kayit["Cek"];
  $gps = $kayit["GPS"];
  
  $kredi_t   += $kayit["Kredi"];
  $nakit_t   += $kayit["Nakit"];
  $cek_t     += $kayit["Cek"];
 
 $dus = $nakit -  $gps ;
 $dus_t = $nakit_t -  $gps ;
 
echo " $gps";
 
 
 
  $kredi_toplam = number_format($kredi, 2, ',', '.'); 
  $nakit_toplam = number_format($dus, 2, ',', '.'); 
  $cek_toplam = number_format($cek, 2, ',', '.'); 
  
    $kredi_top = number_format($kredi_t, 2, ',', '.'); 
  $nakit_top = number_format($dus_t, 2, ',', '.'); 
  $cek_top = number_format($cek_t, 2, ',', '.'); 

  $geneltoplam = $kredi_top + $nakit_top + cek_top ;
  ?>
  
  
                        <tr>
                          <td><center> <?php echo $kayit["magazaadi"]; ?> </td>
                         
                            <td>							
                                <span class="yellow"><center>   <?php echo $nakit_toplam. '&nbsp ₺'; ?> </center> </span>
                            </td></center>
				 <td>							
                                <span class="yellow"><center>  <?php echo $kredi_toplam. '&nbsp ₺'; ?>  </span>
                            </td>
								 <td>							
                                <span class="yellow"><center>  <?php echo $cek_toplam. '&nbsp ₺'; ?> </span>
                            </td>
                        </tr>
						
						
<?php } ?>
                        </tbody>
						<tr><center>
						<td><center><b>  </td>
						<td><center><b><?php echo "$nakit_top &nbsp₺"; ?>  </td>
						<td><center><b><?php echo "$kredi_top &nbsp₺"; ?> </td>
						<td><center><b><?php echo "$cek_top &nbsp₺"; ?>  </td>
						</center>
						</tr>
					
                    </table>
                   
                </div>
            </div>
        </div>
    </div>
	</div>
</div>
	


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