<?php include_once('header.php'); ?>
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <title>Fatura Aktarım</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function() {
            $('#startTransfer').on('click', function(e) {
                e.preventDefault();
                var $button = $(this);
                
                // Butonu devre dışı bırak
                $button.prop('disabled', true);
                
                $('#status').text('Lütfen bekleyiniz...');
                $.ajax({
                    type: 'POST',
                    url: 'process.php',
                    data: $('form').serialize(),
                    success: function(response) {
                        $('#status').html(response);
                        // Butonu tekrar etkinleştir
                        $button.prop('disabled', false);
                    },
                    error: function() {
                        $('#status').html('Bir hata oluştu. Lütfen tekrar deneyin.');
                        // Butonu tekrar etkinleştir
                        $button.prop('disabled', false);
                    }
                });
            });
        });
    </script>
</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-edit"></i> Kasa 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="kasa">
                            </div>
                            <input id="startTransfer" value="  &nbsp&nbsp&nbsp Kasa Aktarım Başlat &nbsp&nbsp&nbsp" type="submit" class="btn btn-default">
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <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> Kasa 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>
                                <th>Durum</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>
                                    <div id="status">İşlem başlatılmadı.</div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<?php include_once('footer.php'); ?>