<script>
    (function ($) {
        "use strict";
        $(document).ready(function () {
            var InputsWrapper = $("tfoot");
            var AddButton = $("#add_plan_btn");
            $('.main-title').on('click', AddButton, function (e) {
                e.preventDefault();
                $('#AddFeatureSection').toggle();
                // $(InputsWrapper).append('');
            });
        });

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

                    });
                }
            }
        });


        $(document).on('click', '.editplan', function () {
            let plan = $(this).data('item');
            $('#planId').val(plan.id);
            $('#editTitle').val(plan.title);
            $('#editOrder').val(plan.order);
            $("#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('');
        });

    })(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; ?>
<?php /**PATH /home/minialms/card.minialms.com/Modules/Subscription/Resources/views/feature/script.blade.php ENDPATH**/ ?>