<?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> Cari 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">

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



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

                   
               
                   &nbsp&nbsp&nbsp <button type="submit" class="btn btn-default"> &nbsp&nbsp&nbsp Cari Aktarım Başlat &nbsp&nbsp&nbsp</button>
                </form>

            </div>
        </div>
  
    <!--/span-->
<?php if ($_POST){


$sql_insert = "

SET IDENTITY_INSERT [$hedef].[dbo].[Cariler] ON;
    INSERT INTO [dbo].[Cariler] (
        [Id], [Durum], [AnaHesapId], [Kodu], [Adi], [Unvani], [Yetkili], [DogumTarihi], [Tipi],
        [SubeId], [ParaBirimi], [Aciklama], [MahalleId], [FaturaAdresi], [SevkAdresi], [Telefon1],
        [Telefon2], [Faks], [GSM], [EMail], [WebAdresi], [VergiDairesi], [VergiNumarasi],
        [KrediLimiti], [AcikHesapLimiti], [Opsiyon], [Iskonto], [GecikmeFaizi], [AylikVade],
        [SatisYapilmasin], [TahsilatYapilmasin], [OzelKod1], [OzelKod2], [OzelKod3], [Tarih],
        [OrtalamaDevirTarihi], [ArtiPuan], [OtomasyonDisi], [BorcHesapId], [AlacakHesapId],
        [SatisFiyati], [IsYeri], [OzelKod0], [IlceId], [EFaturaSenaryo], [GiderTipi], [AdresId],
        [UlkeId], [PostaKodu]
    )
    SELECT
        ISNULL([Id], 0),
        ISNULL([Durum], 0),
        ISNULL([AnaHesapId], 0),
        ISNULL([Kodu], ''),
        ISNULL([Adi], ''),
        ISNULL([Unvani], ''),
        ISNULL([Yetkili], ''),
        ISNULL([DogumTarihi], '1900-01-01'),
        ISNULL([Tipi], 0),
        ISNULL([SubeId], 0),
        ISNULL([ParaBirimi], ''),
        ISNULL([Aciklama], ''),
        ISNULL([MahalleId], 0),
        ISNULL([FaturaAdresi], ''),
        ISNULL([SevkAdresi], ''),
        ISNULL([Telefon1], ''),
        ISNULL([Telefon2], ''),
        ISNULL([Faks], ''),
        ISNULL([GSM], ''),
        ISNULL([EMail], ''),
        ISNULL([WebAdresi], ''),
        ISNULL([VergiDairesi], ''),
        ISNULL([VergiNumarasi], ''),
        ISNULL([KrediLimiti], 0),
        ISNULL([AcikHesapLimiti], 0),
        ISNULL([Opsiyon], 0),
        ISNULL([Iskonto], 0),
        ISNULL([GecikmeFaizi], 0),
        ISNULL([AylikVade], 0),
        ISNULL([SatisYapilmasin], 0),
        ISNULL([TahsilatYapilmasin], 0),
        ISNULL([OzelKod1], ''),
        ISNULL([OzelKod2], ''),
        ISNULL([OzelKod3], ''),
        ISNULL([Tarih], '1900-01-01'),
        ISNULL([OrtalamaDevirTarihi], '1900-01-01'),
        ISNULL([ArtiPuan], 0),
        ISNULL([OtomasyonDisi], 0),
        ISNULL([BorcHesapId], 0),
        ISNULL([AlacakHesapId], 0),
        ISNULL([SatisFiyati], 0),
        ISNULL([IsYeri], 0),
        ISNULL([OzelKod0], ''),
        ISNULL([IlceId], 0),
        ISNULL([EFaturaSenaryo], 0),
        ISNULL([GiderTipi], 0),
        ISNULL([AdresId], 0),
        ISNULL([UlkeId], 0),
        ISNULL([PostaKodu], '')
    FROM [$kaynak].[dbo].[Cariler]
	SET IDENTITY_INSERT [$hedef].[dbo].[Cariler] OFF;
";

// Veri aktarımını gerçekleştir
$stmt_insert = sqlsrv_query($conn1, $sql_insert);

if ($stmt_insert === false) {
   die( "Veri aktarım hatası: Veriler Daha Önce Aktarılmış Olabilir   ");
	

}




// Bağlantıları kapat
sqlsrv_close($conn1);



?>

	
	
</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> Cari 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>Cari Aktarım Başarılı Lütfen Kontrol Ediniz</strong>
                </div>
                        
                    
                        </tr>
                        </thead>
						




        
                      
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!--/span-->


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