<?php
$title = 'TỐ CÁO LỪA ĐẢO - ' . $DVR->site('site_ten');
$body['header'] = '';
$body['footer'] = '';
require_once __DIR__ . '/../../../core/is_user.php';
require_once __DIR__ . '/header.php';
require_once __DIR__ . '/nav.php';
//CheckLogin();
?>

<link rel="stylesheet" href="<?=BASE_URL('public/theme/');?>assets/default/css/dropzone.css">
<script src="<?=BASE_URL('public/theme/');?>assets/default/js/dropzone.js"></script>
<style>
    #dropzone_files {
        border: none;
    }
    .section-form_item .form-theme_item__upload {
        border: 1px #d9d9d9 solid !important;
        border-radius: 5px;
        display: block;
        width: 100%;
        padding: 0.983838em;
        word-break: normal;
        line-height: inherit;
        background-color: white;
        -webkit-transition: all 0.2s ease-out;
        transition: all 0.2s ease-out;
        margin-top: 20px;
        margin-bottom: 10px;
    }
</style>
<div id="main" class="main">
    <div class="section-gap section-report">
        <form method="post" class="form-theme" id="reportForm" enctype="multipart/form-data">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-12">
                        <div class="section-heading">
                            <div class="title">
                                THÔNG TIN KẺ LỪA ĐẢO
                            </div>
                            <div class="line"></div>
                        </div>
                    </div>
                    <div class="col-md-10 col-lg-8">
                        <div class="row row-col-10">
                              <div class="col-md-6 col-12">
                                <div class="form-theme_item">
                                    <input type="text" value="" class="form-theme_item__input"
                                           name="hoten" required>
                                    <label class="form-theme_item__label" for="">
                                        Họ Và Tên - Website ( ghi cả https:// ) <span class="font-weight-bold text-danger">*</span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-6 col-12">
                                <div class="form-theme_item">
                                    <input type="number" value="" class="form-theme_item__input"
                                           name="sdt" required>
                                    <label class="form-theme_item__label" for="">
                                        Số Điện Thoại <span class="font-weight-bold text-danger">*</span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-6 col-12">
                                <div class="form-theme_item">
                                     <select name="nganhang" class="form-theme_item__select" id="">
                                         <option value="">--- Ngân Hàng  ---</option>
                                                                                                                                    <?php foreach ($DVR->get_list("SELECT * FROM `api_logo`") as $bank) {?>
                                            <option value="<?=$bank['shortName'];?>"><?=$bank['name'];?></option>
                                        <?php } ?>             </select>
                                    <label class="form-theme_item__label" for="">
                                        Ngân Hàng <span class="font-weight-bold text-danger">*</span>
                                    </label>
                                      <div class="form-theme_item__caret">
                                        <i class="fas fa-caret-down"></i>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6 col-12">
                                <div class="form-theme_item">
                                    <input type="text" class="form-theme_item__input" name="stk" required>
                                    <label class="form-theme_item__label" for="">
                                        Số Tài Khoản <span class="font-weight-bold text-danger">*</span>
                                    </label>
                                </div>
                            </div>
                               <div class="col-md-6 col-12">
                                <div class="form-theme_item">
                                    <input type="text" value="" class="form-theme_item__input" name="money" id="money" required>
                                    <label class="form-theme_item__label" for="">
                                        Số Tiền Scam <span class="font-weight-bold text-danger">*</span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-6 col-12">
                                <div class="form-theme_item">
                                    <select name="loai" class="form-theme_item__select" id="">
                                        <option value="">--- Định Danh Scam ---</option>
                                                                                                                                    <option value="scam">SCAMER</option>
                                                                                            <option value="web">WEBSITE</option>                               </select>
                                    <label class="form-theme_item__label" for="">
                                        Danh mục
                                    </label>
                                    <div class="form-theme_item__caret">
                                        <i class="fas fa-caret-down"></i>
                                    </div>
                                </div>
                            </div>
                             <div class="col-md-6 col-12">
                                <div class="form-theme_item">
                                    <input type="text" value="" class="form-theme_item__input"
                                           name="linkfb" required>
                                    <label class="form-theme_item__label" for="">
                                        Link Fb <span class="font-weight-bold text-danger">*</span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-12">
                                <div class="section-form_item">
                                    <div class="form-theme_item__upload">
                                        <div class="form-theme_item__upload-images">
                                            <div id="dropzone_files" class="dropzone dz-clickable">
                                                <div class="dz-message needsclick">
                                                    <i class="fas fa-file-image text-danger"></i>
                                                    <i class="fas fa-file-image text-primary"></i>
                                                    <i class="far fa-file-image text-success"></i>
                                                    <i class="fas fa-file-image text-secondary"></i>
                                                    <p style="font-size: 13px;">Kéo hoặc click vào đây để upload</p>
                                                </div>
                                            </div>
                                            <ul id="file-upload-list" class="list-unstyled"></ul>
                                        </div>
                                        <div class="form-theme_item__upload-desc">
                                            <i class="far fa-images"></i>
                                            Upload Bill chuyển tiền &amp; ảnh đoạn chát lừa đảo.
                                        </div>
                                    </div>
                                </div>
                            </div>
                             <div class="col-12 py-0">
                                <div class="form-theme_item">
                                    <div class="form-theme_item__desc px-1 text-muted">
                                        
                                    </div>
                                </div>
                            </div>
                            <div class="col-12">
                                <div class="form-theme_item">
                                     <textarea class="form-theme_item__input"
                                               name="lydo" rows="4"></textarea>
                                    <label class="form-theme_item__label" for="" required>
                                        Nội Dung Tố Cáo <span class="font-weight-bold text-danger">*</span>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-12">
                        <div class="section-heading">
                            <div class="title">
                                THÔNG TIN CỦA BẠN
                            </div>
                            <div class="line"></div>
                        </div>
                    </div>
                    <div class="col-md-10 col-lg-8">
                        <div class="row row-col-10">
                                    <div class="col-md-6 col-12 py-md-0">
                                <div class="form-theme_item">
                                    <input type="text" class="form-theme_item__input"
                                           name="hotennp" required>
                                    <label class="form-theme_item__label" for="">
                                        Họ & Tên <span class="font-weight-bold text-danger">*</span>
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-6 col-12 py-md-0">
                                <div class="form-theme_item">
                                    <input type="text" class="form-theme_item__input" name="sdtnp" required>
                                    <label class="form-theme_item__label" for="">
                                        SĐT Liên Hệ Hoặc Zalo <span class="font-weight-bold text-danger">*</span>
                                    </label>
                      <div class="form-theme_item__desc p-1 pb-0 text-muted">Đơn Tố Cáo Sẽ Không Được Duyệt Nếu Như Zalo Ảo
                                    </div>
                                </div>
                            </div>
                                 <div class="col-12"> <div class="form-theme_item"> <input type="text" value="" class="form-theme_item__input" name="link_report"> <label class="form-theme_item__label" for=""> Link phốt trên group (nếu có) </label> <div class="form-theme_item__desc p-1 pb-0 text-muted"> Có thể bỏ trống. </div> </div>
                                 </div> 
                            <div class="col-12 mt-4">
                                <div class="form-theme_item text-center">
                                    <button id="submitReport" type="submit" name="submit" class="btn-theme btn-theme_primary">
                                        GỬI DUYỆT
                                        <span></span>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"></script>
<script>
    Dropzone.autoDiscover = false;

    var myDropzone = new Dropzone("#dropzone_files", {
        url: "/ajaxs/client/to-cao.php",
        acceptedFiles: ".jpg,.png,.jfif",
        autoProcessQueue: false,
        paramName: "file",
        maxFilesize: 5,
        addRemoveLinks: true,
        dictDefaultMessage: "Kéo hoặc click vào đây để upload",
        dictRemoveFile: "Xóa Ảnh"
        
    });

    $("#submitReport").on("click", function() {
        $('#submitReport').html('<i class="fa fa-spinner fa-spin"></i> Đang xử lý...').prop(
            'disabled',
            true);

        var formData = new FormData(document.getElementById('reportForm'));
        
        // Thêm các tệp từ Dropzone vào formData
        myDropzone.files.forEach(function(file) {
            formData.append('file[]', file);
        });

        $.ajax({
            url: "/ajaxs/client/to-cao.php",
            type: "POST",
            dataType: "json",
            data: formData,
            processData: false,
            contentType: false,
            
            success: function(res) {
                if (res.status == 'success') {
                   showMessage(res.msg, "success");
                      setTimeout(function() {
                     location.reload(); }, 2000);
                } else {
                     showMessage(res.msg, res.status);
                }
                $('#submitReport').html('GỬI DUYỆT').prop('disabled',
                    false);
            },
            error: function(xhr, status, error) {
                Swal.fire({
                    icon: 'error',
                    title: 'Lỗi',
                    text: 'Có lỗi xảy ra khi gửi đơn tố cáo. Vui lòng thử lại!'
                });
            }
        });
    });
</script>

<?php require_once __DIR__ . '/footer.php'; ?>
