<?php include('header.php');
include_once('config.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> Çek / Senet Aktarı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 class="box-content">
  <div class="form-group">
                <form name="form" method="post" role="form">
				
				           <div class="form-group has-success col-md-4">
                        <input type="hidden" class="form-control" value="1" name="fbaslik" >
                    </div>
	
                   &nbsp&nbsp&nbsp <button type="submit" onclick="this.form.submit(); this.value='Aktarım Yapılıyor Lütfen Bekleyin..'; this.disabled=true;"  class="btn btn-default"> &nbsp&nbsp&nbsp Çek Aktarım Başlat &nbsp&nbsp&nbsp</button>
                </form>
				   <form name="form" method="post" role="form">
				
				           <div class="form-group has-success col-md-4">
                        <input type="hidden" class="form-control" value="2" name="fhareket" >
                    </div>
	
                   &nbsp&nbsp&nbsp <button type="submit" onclick="this.form.submit(); this.value='Aktarım Yapılıyor Lütfen Bekleyin..'; this.disabled=true;"  class="btn btn-default"> &nbsp&nbsp&nbsp Senet Aktarım Başlat &nbsp&nbsp&nbsp</button>
                </form>

            </div>
        </div>
  
    <!--/span-->
<?php if ($_POST['fbaslik']==1){
// Veritabanı bağlantısı kontrolü
if ($conn1 === false) {
    die(print_r(sqlsrv_errors(), true));
}

// IDENTITY_INSERT ayarını aç
$identityOn = "SET IDENTITY_INSERT [$hedef].[dbo].[Cekler] ON";
$stmt = sqlsrv_query($conn1, $identityOn);

if ($stmt === false) {
    die(print_r(sqlsrv_errors(), true));
}

// Veri aktarım sorgusu
$sql = "INSERT INTO [$hedef].[dbo].[Cekler] ([Id], [BankaId], [Sube], [HesapNumarasi], [BelgeNo], [TakipNo], [KesideEden], [KesideYeri], [KesideTarihi])
SELECT [Id], [BankaId], [Sube], [HesapNumarasi], [BelgeNo], [TakipNo], [KesideEden], [KesideYeri], [KesideTarihi]
FROM [$kaynak].[dbo].[Cekler]";

$stmt = sqlsrv_query($conn1, $sql);

if ($stmt === false) {
    die(print_r(sqlsrv_errors(), true));
}

// IDENTITY_INSERT ayarını kapat
$identityOff = "SET IDENTITY_INSERT [$hedef].[dbo].[Cekler] OFF";
$stmt = sqlsrv_query($conn1, $identityOff);

if ($stmt === false) {
    die(print_r(sqlsrv_errors(), true));
}




?>

	
	
</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> Çek Aktarı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 class="box-content">
                    <table class="table table-striped table-bordered responsive">
                        <thead>
                        <tr>
                      
                          <div class="alert alert-success">
                    <button type="button" class="success" data-dismiss="success">&times;</button>
                    <strong>Çek Aktarım Başarılı Lütfen Kontrol Ediniz</strong>
                </div>
                        
                    
                        </tr>
                        </thead>
						




        
                      
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!--/span-->
<?php } ?>


<?php if ($_POST['fhareket']==2){

if ($conn1 === false) {
    die(print_r(sqlsrv_errors(), true));
}

// IDENTITY_INSERT ayarını aç
$identityOn = "SET IDENTITY_INSERT [$hedef].[dbo].[Senetler] ON";
$stmt = sqlsrv_query($conn1, $identityOn);

if ($stmt === false) {
    die(print_r(sqlsrv_errors(), true));
}

// Veri aktarım sorgusu
$sql = "INSERT INTO [$hedef].[dbo].[Senetler] ([Id], [BelgeNo], [TakipNo], [KesideEden], [KesideTarihi], [KesideYeri], [VergiDairesi], [VergiNumarasi], [Adres])
SELECT [Id], [BelgeNo], [TakipNo], [KesideEden], [KesideTarihi], [KesideYeri], [VergiDairesi], [VergiNumarasi], [Adres]
FROM [$kaynak].[dbo].[Senetler]";

$stmt = sqlsrv_query($conn1, $sql);

if ($stmt === false) {
    die(print_r(sqlsrv_errors(), true));
}

// IDENTITY_INSERT ayarını kapat
$identityOff = "SET IDENTITY_INSERT [$hedef].[dbo].[Senetler] OFF";
$stmt = sqlsrv_query($conn1, $identityOff);

if ($stmt === false) {
    die(print_r(sqlsrv_errors(), true));
}





?>

	
	
</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> Senet Aktarı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 class="box-content">
                    <table class="table table-striped table-bordered responsive">
                        <thead>
                        <tr>
                      
                          <div class="alert alert-success">
                    <button type="button" class="success" data-dismiss="success">&times;</button>
                    <strong>Senet Aktarım Başarılı Lütfen Kontrol Ediniz</strong>
                </div>
                        
                    
                        </tr>
                        </thead>
						




        
                      
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!--/span-->
<?php } ?>
<?php   require('footer.php'); ?>