 <?php require('config.php'); ?>
 <? $datee =  date('d.m.Y'); ?>
 
	
<?php

error_reporting(0); @session_start();



if(isset($_POST['search']))
{
include "bower_components/moment/jd.php";

date_default_timezone_set('Europe/Istanbul');
$tarih = date('Y-m-d');
$saat = date('H:i:s');}
?>


<html>
<head>

<title>POSnet Web Yazılım</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="POSnet web yazılım">
	<meta name="author" content="Ahmet AVCI">

	<!-- The styles -->
	<link id="bs-css" href="css/bootstrap-cerulean.min.css" rel="stylesheet">
 
	<link href="css/charisma-app.css" rel="stylesheet">
	<link href='bower_components/fullcalendar/dist/fullcalendar.css' rel='stylesheet'>
	<link href='bower_components/fullcalendar/dist/fullcalendar.print.css' rel='stylesheet' media='print'>
	<link href='bower_components/chosen/chosen.min.css' rel='stylesheet'>
	<link href='bower_components/colorbox/example3/colorbox.css' rel='stylesheet'>
	<link href='bower_components/responsive-tables/responsive-tables.css' rel='stylesheet'>
	<link href='bower_components/bootstrap-tour/build/css/bootstrap-tour.min.css' rel='stylesheet'>
	<link href='css/jquery.noty.css' rel='stylesheet'>
	<link href='css/noty_theme_default.css' rel='stylesheet'>
	<link href='css/elfinder.min.css' rel='stylesheet'>
	<link href='css/elfinder.theme.css' rel='stylesheet'>
	<link href='css/jquery.iphone.toggle.css' rel='stylesheet'>
	<link href='css/uploadify.css' rel='stylesheet'>
	<link href='css/animate.min.css' rel='stylesheet'>

	<!-- jQuery -->
	<script src="bower_components/jquery/jquery.min.js"></script>
<center>




</head>
<body>


 <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> Stok Listesi</h2>
		
<a  href="mfg.php" class="btn btn-default" >Barkod ile Sorgula </a>

        <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="isimmfg.php?ck=sor" onSubmit="return kontrol()">
&nbsp;&nbsp;&nbsp;<div class="control-group">
                  

                   &nbsp;&nbsp;&nbsp;&nbsp; <div class="controls">
                        
                    
        </form>




	
	
	
	
<div class="control-group">
     <div class="form-group has-success col-md-4">
		  
					 <label class="control-label" for="araa">Stok Adı</label>
                    <input type="text" value=""  class="form-control" name="araa"></div>
          <div class="form-group has-success col-md-4">
		                       
                  
                    
                <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">
    <thead>
    <tr>
        <th>Barkodu</th>
        <th>Stok Adı</th>
        <th>Alış Fiyat </th>
        <th>Satış Fiyat</th>
  
    </tr>
    </thead>
	
<?



if ($_POST){
	$kdv=$_POST["kdv"];
    $say=$_POST["say"];
    $ara=$_POST["ara"];
	$araa=$_POST["araa"];

	
	
	
	$sorgu=odbc_exec($db," 
   
        SELECT TOP 200 B.KDVDahil,
S.Id, S.StokKodu, S.StokAdi,D.SubeId,  S.Tanimi, S.StokTipi, S.Durum, S.AlisFiyati, S.AlisPB,  B.Fiyat1, B.PB1, B.Fiyat2, B.PB2, B.Fiyat3, B.PB3,
B.Adi AS BirimAdi, B.Carpan, Barkodu, KG.Orani KDV, OG.Orani OTV,
ISNULL((SELECT Kod FROM OzelKodlar OK WHERE OK.Id = S.OzelKod0), '') AS OzelKod0,
ISNULL((SELECT Kod FROM OzelKodlar OK WHERE OK.Id = S.OzelKod1), '') AS OzelKod1,
ISNULL((SELECT Kod FROM OzelKodlar OK WHERE OK.Id = S.OzelKod2), '') AS OzelKod2,
ISNULL((SELECT Kod FROM OzelKodlar OK WHERE OK.Id = S.OzelKod3), '') AS OzelKod3,
ISNULL((SELECT Kod FROM OzelKodlar OK WHERE OK.Id = S.OzelKod4), '') AS OzelKod4,
ISNULL((SELECT Kod FROM OzelKodlar OK WHERE OK.Id = S.OzelKod5), '') AS OzelKod5,
ISNULL((SELECT Kod FROM OzelKodlar OK WHERE OK.Id = S.OzelKod6), '') AS OzelKod6,
(SELECT TOP 1 SB.Carpan FROM Birimler AS SB WHERE SB.StokId = S.Id AND SB.Id <> B.Id) Carpan2,
(SELECT TOP 1 SB.Adi FROM Birimler AS SB WHERE SB.StokId = S.Id AND SB.Id <> B.Id) BirimAdi2
--(SELECT Envanter FROM DepoDetayliEnvanter AS D WHERE D.Id = S.Id AND SubeId = 3) Envanter
--Envanter
FROM Stoklar S
INNER JOIN Birimler AS B ON B.StokId = S.Id
INNER JOIN (SELECT VarsayilanBirim AS BId FROM Stoklar AS S WHERE StokKodu LIKE '$araa%' OR StokAdi LIKE '%$araa%'
    UNION
SELECT BirimId FROM Barkodlar AS B WHERE Barkodu LIKE '$araa%') AS BIds ON BIds.BId = B.Id
LEFT JOIN Barkodlar AS Bar ON Bar.Id = B.BarkodId
LEFT JOIN KDVGruplari AS KG ON KG.Grubu = B.KDVGrubu AND ISNULL(KG.Tipi, 0) = 0
LEFT JOIN KDVGruplari AS OG ON OG.Grubu = B.OTVGrubu AND KG.Tipi = 1

LEFT JOIN DepoDetayliEnvanter D ON D.SubeId IN  (3,4) AND D.Id = S.Id
             
            
           
  
  ");
   
$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))
	{	
      
	$fiy1 = $kayit["Fiyat1"];
    $fiy2 = $kayit["Fiyat2"];
	$id = $kayit["Id"];
	$aliss = $kayit["AlisFiyati"];
	
	//$id = $kayit["VarsayilanBirim"];

$fiya1 = number_format($fiy1, 2, ',', '.');
$fiya2 = number_format($fiy2, 2, ',', '.');
$fiya3 = number_format($fiy3, 2, ',', '.');
$alis = number_format($aliss, 2, ',', '.');

$gonder = $kayit["Id"];
$barkod = $kayit["StokKodu"];



	?>

    <tbody>
    <tr>
        
        <td><? echo $barkod; ?></td>
        <td class="center"><h4><? echo mb_convert_encoding($kayit["StokAdi"], "UTF-8", "ISO-8859-9");?></td>
        <td class="center"><b><h4><? echo "$alis"; ?></td>
        <td class="center"><b><h4><? echo "$fiya1"; ?></td>
        <td class="center"><b><h4><? echo "$deneme"; ?></td>

	
       
           

    </tr>
   
    </tr>
               </div>
        </div>
    </div><!--/span-->

     <? }
	
	} odbc_close($db);
?>  