<?php $__env->startSection('title', 'List'); ?>

<?php $__env->startSection('content'); ?>
<style>
/* Style for the active state */
.btn-toggle.active {
    background-color: #2196f3;
    /* Set to the desired green color */
    color: white;
    /* Set to the desired text color */
    border-color: green;
    /* Set to the desired border color */
}

/* Style for the inactive state */
.btn-toggle:not(.active) {
    background-color: red;
    /* Set to the desired red color */
    color: white;
    /* Set to the desired text color */
    border-color: red;
    /* Set to the desired border color */
}

.badge {
    font-size: 1rem;
    font-style: normal;
    font-weight: 400;
    font-family: "IBM Plex Sans", sans-serif;
    line-height: 1.5;
}
</style>
<style type="text/css">
.dialog-background {
    background: none repeat scroll 0 0 rgba(244, 244, 244, 0.5);
    height: 100%;
    left: 0;
    margin: 0;
    padding: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 100;
}

.dialog-loading-wrapper {
    background: none repeat scroll 0 0 rgba(244, 244, 244, 0.5);
    border: 0 none;
    height: 100px;
    left: 50%;
    margin-left: -50px;
    margin-top: -50px;
    position: fixed;
    top: 50%;
    width: 100px;
    z-index: 9999999;
}
</style>
<style>
.file-upload-box {
    border: 2px dashed #19a7ce;
    border-radius: 8px;
    background: #f9f9f9;
    text-align: center;
    padding: 40px 20px;
    cursor: pointer;
    position: relative;
    transition: 0.3s ease-in-out;
    width:100%;
}

.file-upload-box:hover {
    background: #eefbff;
    border-color: #0d6efd;
}

.file-upload-box input[type="file"] {
    display: none;
}

.file-upload-box .upload-icon {
    font-size: 40px;
    color: #0d6efd;
    margin-bottom: 10px;
}

.file-upload-box p {
    margin: 0;
    color: #555;
}

.file-upload-box small {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #777;
}
</style>
<!-- Main content -->

<section class="content">

    <div class="row">




        <div class="col-12">
            <div class="box">

                <div class="box-body">
                    <h4 class="box-title text-info mb-0"><i class="fa fa-user fa-sx"></i> List</h4>
                    <a id="openListForm" type="submit" style="float:right"
                        class="waves-effect waves-light btn btn-rounded btn-primary btn-bitbucket btn-sm mb-5"><i
                            class="fa fa-plus"></i>Add List</a>
                    <hr class="my-15">
                    <div class="table-responsive">
                        <table id="list" class="table mt-0 table-hover no-wrap" data-page-size="10">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>List Name</th>
                                    <th>Campaign Name</th>
                                    <th>Total Leads</th>
                                    <th>Dialing Column</th>
                                    <th>Created Date</th>
                                    <th>Status</th>
                                    <th>Action</th>

                                </tr>
                            </thead>
                            <tbody>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="delete" tabindex="-1" aria-labelledby="deleteLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="myModalLabel">Confirm Delete</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>

                    <div class="modal-body">
                        <p>You are about to delete <b><i class="title"></i></b>list.</p>
                        <p>Do you want to proceed?</p>
                        <input type="hidden" class="form-control" name="list_id" value="" id="list_id">
                        <input type="hidden" class="form-control" name="camid" value="" id="camid">
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Close</button>
                        <button type="submit" name="submit" class="btn btn-danger btn-sm deleteListData">Delete</button>
                    </div>

                </div>
            </div>
        </div>
        <!-- <div class="modal fade" id="listModal" tabindex="-1" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="dialog-background" id="loadingmodal" style="display: none;">
                        <div class="dialog-loading-wrapper">
                            <img src="<?php echo e(asset('assets/images/lp.gif')); ?>">
                        </div>
                    </div>
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="add-edit"></h5>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                        </div>
                        <form method="post" action="" enctype="multipart/form-data"id="listForm">
                            <?php echo csrf_field(); ?>
                            <div class="modal-body">
                                <div class="form-group">
                                    <label for="inputEmail3" class="form-label">Title </label>
                                    <div class="input-group mb-3">
                                        <span class="input-group-text"><i class="ti-user"></i></span>

                                        <input type="text" class="form-control closed" required name="title"
                                            id="title" placeholder="Please enter name">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputEmail3" class="form-label">Duplicate Check</label>
                                    <div class="input-group mb-3">
                                        <div class="c-inputs-stacked ">
                                            <input name="duplicate_check" type="radio" id="caller_id_yes" value="1"
                                                checked />
                                            <label for="caller_id_yes">Yes</label>
                                            <input name="duplicate_check" type="radio" id="caller_id_no" value="0">
                                            <label for="caller_id_no">No</label>

                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="list_file" class="form-label">Select List you want to upload</label>
                                        <div class="input-group mb-3">
                                            <span class="input-group-text"><i class="ti-user"></i></span>

                                            <input type="file" class="form-control" id="list_file" name="list_file"
                                                value="" required placeholder="Select file">

                                        </div>
                                        <div class="form-group">
                                            <div class="form-group <?php $__errorArgs = ['list_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> has-error <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                                                <label class="form-label">Campaign</label>
                                                <div class="input-group mb-3">
                                                    <span
                                                        class="input-group-text <?php $__errorArgs = ['list_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> text-danger border-danger <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"><i
                                                            class="ti-list"></i></span>
                                                    <select class="form-select" name="campaign" autocomplete="off"
                                                        data-placeholder="Select Campaign" placeholder="Select Campaign"
                                                        required>
                                                        <option value="">Select Campaign</option>
                                                        <?php foreach ($campaign_list as $key=>$value){
                                                        if(!empty($value->title) &($value->status==1)){
                                                        ?>
                                                        <option value="<?php echo $value->id; ?>"><?php echo $value->title; ?></option>
                                                        <?php } }?>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-secondary "
                                            data-bs-dismiss="modal">Close</button>
                                        <button type="submit" name="submit" class="btn btn-info btn-ok">Save</button>
                                    </div>
                        </form>
                    </div>
                </div>

            </div> -->
        <div class="modal custom-modal fade" id="listModal" tabindex="-1" aria-labelledby="myModalLabel"
            aria-hidden="true">
            <div class="modal-dialog custom-top-modal1">
                <div class="modal-content" style="border-radius: 1rem; padding: 0;">
                    <div class="modal-header">
                        <h5 class="modal-title" id="add-edit"></h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <!-- Loader Background -->
                    <div class="dialog-background" id="loadingmodal" style="display: none;">
                        <div class="dialog-loading-wrapper">
                            <img src="<?php echo e(asset('assets/images/lp.gif')); ?>">
                        </div>
                    </div>

                    <hr class="mx-4" style="border-top: 1.5px solid #aaa; margin-top: 0; margin-bottom: 1rem;">

                    <div class="modal-body px-4 pt-0 pb-4">
                        <form method="post" action="" enctype="multipart/form-data" id="listForm">
                            <?php echo csrf_field(); ?>

                            <div class="form-group mb-3">
                                <label for="title" class="form-label">Title</label>
                                <div class="input-group">
                                    <span class="input-group-text"><i class="ti-user"></i></span>
                                    <input type="text" class="form-control closed" required name="title" id="title"
                                        placeholder="Please enter name">
                                </div>
                            </div>
<div class="form-group mb-3">
    <!-- <label class="form-label">Duplicate Check</label> -->
    <div class="form-check " style="padding-left:0">
        <input class="form-check-input" type="checkbox" id="duplicate_check" name="duplicate_check" value="1" checked>
        <label class="form-check-label" for="duplicate_check">Enable Duplicate Check</label>
    </div>
</div>
    <div class="form-group mb-3 <?php $__errorArgs = ['list_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> has-error <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                                <label class="form-label">Dialing Column</label>
                                <div class="input-group">
                                    <span
                                        class="input-group-text <?php $__errorArgs = ['list_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> text-danger border-danger <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"><i
                                            class="ti-list"></i></span>
                                    <select class="form-select" name="is_dialing" autocomplete="off"
                                        data-placeholder="Select" placeholder="Select" required>
                                        <option value="">Select</option>
                                            <option value="1">Yes</option>
                                        <option value="0">No</option>

                                    </select>
                                </div>
                            </div>
                            <!-- <div class="form-group mb-3">
                                <label class="form-label">Duplicate Check</label>
                                <div class="input-group">
                                    <div class="c-inputs-stacked">
                                        <input name="duplicate_check" type="radio" id="caller_id_yes" value="1"
                                            checked />
                                        <label for="caller_id_yes">Yes</label>
                                        <input name="duplicate_check" type="radio" id="caller_id_no" value="0">
                                        <label for="caller_id_no">No</label>
                                    </div>
                                </div>
                            </div> -->
                          <div class="form-group mb-3">
                                    <label class="form-label">Upload File</label>
                                    <div>
                                        <!-- Hidden File Input -->
                                        <input type="file" class="form-control d-none" id="list_file" name="list_file"
                                            required accept=".xlsx,.xls,.csv" />

                                        <!-- Custom Upload Box -->
                                        <label class="file-upload-box" for="list_file">
                                            <div class="upload-icon">
                                                <i class="ti ti-cloud-upload"></i>
                                            </div>
                                            <p>
                                                Drag & drop your file here or
                                                <span class="text-primary">choose file</span>
                                            </p>
                                            <small>Supported formats: XLSX, XLS, CSV | Max size: 5MB</small>
                                        </label>

                                        <!-- Selected File Name -->
                                        <div id="file-name" style="margin-top:8px; font-size:14px; color:#333;"></div>
                                    </div>
                                </div>
                            <!-- <div class="form-group mb-3">
                                <label for="list_file" class="form-label">Select List you want to upload</label>
                                <div class="input-group">
                                    <span class="input-group-text"><i class="ti-user"></i></span>
                                    <input type="file" class="form-control" id="list_file" name="list_file" required
                                        placeholder="Select file">
                                </div>
                            </div> -->

                            <div class="form-group mb-3 <?php $__errorArgs = ['list_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> has-error <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                                <label class="form-label">Campaign</label>
                                <div class="input-group">
                                    <span
                                        class="input-group-text <?php $__errorArgs = ['list_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> text-danger border-danger <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"><i
                                            class="ti-list"></i></span>
                                    <select class="js-example-basic-single select2" name="campaign" autocomplete="off"
                                        data-placeholder="Select Campaign" placeholder="Select Campaign" required>
                                        <option value="">Select Campaign</option>
                                        <?php foreach ($campaign_list as $key=>$value){
                                    if(!empty($value->title) &($value->status==1)){
                                ?>
                                        <option value="<?php echo $value->id; ?>"><?php echo $value->title; ?></option>
                                        <?php } }?>
                                    </select>
                                </div>
                            </div>

                            <!-- Footer Buttons -->
                            <div class="d-flex gap-3 pt-2 mt-4">
                                <button type="button" class="btn btn-light " data-bs-dismiss="modal"
                                    style="border-radius: 0.6rem;width:50%;">
                                    Close
                                </button>
                                <button type="submit" name="submit" class="btn btn-primary "
                                    style="border-radius: 0.6rem;width:50%">
                                    Save
                                </button>
                            </div>

                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <!-- /.row -->

</section>
<!-- /.content -->




<script src="https://code.jquery.com/jquery-3.7.0.js" integrity="sha256-JlqSTELeR4TLqP0OG9dxM7yDPqX1ox/HfgiSLBj8+kM="
    crossorigin="anonymous"></script>
<script>
const fileInput = document.getElementById("list_file");
const fileName = document.getElementById("file-name");

fileInput.addEventListener("change", function() {
    if (this.files.length > 0) {
        fileName.textContent = "Selected file: " + this.files[0].name;
    } else {
        fileName.textContent = "";
    }
});
</script>

<script>
$("#openListForm").click(function() {
    $("#listModal").modal('show');
    $("#name").val('');
    $("#status").val('1');
    $("#id").val('');
    $("#add-edit").html('Add List');
});
$("#listForm").submit(function() {
    $('#loadingmodal').show();
});
// $(".deleteList").click(function() {
//     var delete_id = $(this).data('id');
//     var camid = $(this).data('camid');

//     //alert(camid);

//     $("#delete").modal('show');
//     $("#list_id").val(delete_id);
//     $("#camid").val(camid);


// });
$(document).on('click', '.deleteList', function() {
    var delete_id = $(this).data('id');
    var camid = $(this).data('camid');

    $("#delete").modal('show');
    $("#list_id").val(delete_id);
    $("#camid").val(camid);
});

$(document).on("click", ".deleteListData", function() {
    var list_id = $('#list_id').val();
    var camid = $('#camid').val();

    //alert(group_id);
    var el = this;
    $.ajax({
        url: 'deleteListData/' + list_id + '/' + camid,
        type: 'get',
        success: function(response) {
            toastr.success('List deleted successfully');
            $("#delete").modal('hide');

            window.location.reload(1);
        }
    });
    //   window.location.reload(1);

});
</script>


<script>
$(function() {
    $("#list").on("click", ".btn-toggle", function() {
        var status = $(this).hasClass('active') ? 1 : 0;
        var listid = $(this).data('listid');

        $.ajax({
            type: "GET",
            dataType: "json",
            url: '/updateListStatus/' + listid + '/' + status,
            success: function(data) {
                if (data.status == 'true') {
                    toastr.success(data.message);
                } else {
                    toastr.error(data.message);
                }

                console.log(data.success);
                window.location.reload(1);
            }
        });
    });
});
</script>


<script>
$(document).ready(function() {
    $('#list').DataTable({
        processing: true,
        serverSide: false,
        ajax: "<?php echo e(url('list')); ?>",
        columns: [{
                data: 'DT_RowIndex',
                name: 'DT_RowIndex',
                orderable: false,
                searchable: false
            },
            {
                data: 'campaign',
                name: 'List Name',
                searchable: true

            },

            {
                data: 'campaign_Name',
                name: 'Campaign Name',
                searchable: true

            },

            {
                data: 'total_leads',
                name: 'Total Leads',
                searchable: true

            },
              {
                data: 'is_dialing',
                name: 'Is Dialing',
                searchable: true

            },

            {
                data: 'updated_at',
                name: 'Created Date',
                searchable: true

            },

            {
                data: 'status',
                name: 'status',
                orderable: false,
                searchable: false
            },
            {
                data: 'action',
                name: 'action',
                orderable: false,
                searchable: false
            }
        ],
language: {
    processing: `
        <span style="display:flex; align-items:center; justify-content:center; gap:8px;">
            <img src="https://i.gifer.com/ZZ5H.gif"
                 alt="Loading..." style="width:20px; height:20px;">
            Processing...
        </span>
    `
}

    });
});
</script>


<script>
$(document).ready(function() {
   
    function initializeSelect2() {
        $('.js-example-basic-single.select2').select2({
            width: '90%',
            dropdownParent: $('#listModal') 
        });
    }

   
    $('#listModal').on('shown.bs.modal', function() {
        initializeSelect2(); 
    });


    if ($('#listModal').hasClass('show')) {
        initializeSelect2();
    }
});
</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/leadmine/leadmine_pro/resources/views/lists/lists.blade.php ENDPATH**/ ?>