<script>

    (function ($) {
        "use strict";

        $('tbody').sortable({
            cursor: "move",
            update: function (event, ui) {
                let ids = $(this).sortable('toArray', {attribute: 'data-item'});
                if (ids.length > 0) {
                    let data = {
                        '_token': '<?php echo e(csrf_token()); ?>',
                        'ids': ids,
                    }
                    $.post("<?php echo e(route('changePlanPosition')); ?>", data, function (data) {

                    });
                }
            }
        });


        $(document).on('click', '.changePopular', function () {
            let id = $(this).data('id');
            let status = $(this).data('status');

            let data = {
                '_token': '<?php echo e(csrf_token()); ?>',
                'status': status,
                'id': id,
            }
            $.post("<?php echo e(route('changePlanPopular')); ?>", data, function (data) {

            });

        });
        $(document).on('click', '.editplan', function () {

            let plan = $(this).data('item');
            $('#planId').val(plan.id);
            $('#editTitle').val(plan.title);
            $('#category_id_edit').val(plan.category_id);
            $('#editPrice').val(plan.price);
            $('#editAbout').val(plan.about);
            $('#editBtnTxt').val(plan.btn_txt);
            $('#editDays').val(plan.days);
            $('#category_id_edit').niceSelect('update');
            $('input[name="is_recurring"][value="' + plan.is_recurring + '"]').prop('checked', true);
            $("#editplan").modal('show');

        });


        $(document).on('click', '.deleteplan', function () {
            let id = $(this).data('id');
            $('#planDeleteId').val(id);
            $("#deleteplan").modal('show');
        });


        $(document).on('click', '#add_plan_btn', function () {
            $('#addTitle').val('');
            $('#addPrice').val('');
            $('#addAbout').val('');
            $('#addDays').val('');
            $('#addBtn').val('');
        });

    })(jQuery);
</script>


<?php if($errors->any()): ?>
    <script>
        (function ($) {
            "use strict";
            <?php if(Session::has('type')): ?>
            <?php if(Session::get('type')=="store"): ?>
            $('#add_plan').modal('show');
            <?php else: ?>
            $('#editplan').modal('show');
            <?php endif; ?>
            <?php endif; ?>
        })(jQuery);
    </script>
<?php endif; ?>
<script type="application/javascript">
    (function ($) {
        "use strict";

        dataTableOptions = updateColumnExportOption(dataTableOptions, [1, 2, 3, 4, 5, 6]);

        $('#lms_table').DataTable(dataTableOptions);
    })(jQuery);

</script>
<?php /**PATH /home/minialms/card.minialms.com/Modules/Subscription/Resources/views/plan/script.blade.php ENDPATH**/ ?>