<!DOCTYPE html>
<html>

<head>
    <?php echo $__env->make('partials.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('partials.head-css', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('partials.title-meta', ['title' => 'Bulletins'], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <link rel="stylesheet" href="<?php echo e(asset('assets/libs/twitter-bootstrap-wizard/prettify.css')); ?>">

    <!-- Select2 CSS -->
    <link href="<?php echo e(asset('assets/libs/select2/css/select2.min.css')); ?>" rel="stylesheet" type="text/css" />

    <!-- Dropzone CSS -->
    <link href="<?php echo e(asset('assets/libs/dropzone/min/dropzone.min.css')); ?>" rel="stylesheet" type="text/css" />
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>


</head>

<style>
    .card-body {
        padding: 6.25rem 1.25rem !important;
    }

    .mb-2 {
        margin-top: -92px;
    }

    .user-sidebar {
        background-color: #f14e4e !important;
    }

    .page-title-box {
        background-color: #f14e4e !important;
    }
</style>

<body>

    <div id="layout-wrapper">

        <?php echo $__env->make('partials.menu', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

        <!-- ============================================================== -->
        <!-- Start right Content here -->
        <!-- ============================================================== -->
        <div class="main-content">

            <div class="page-content">

                <?php echo $__env->make('partials.page-title', ['pagetitle' => 'Form', 'subtitle' => 'Codissia', 'title' => 'Edit Bulletins'], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>


                <div class="container-fluid">

                    <div class="page-content-wrapper">

                        <div class="row">
                            <div class="col-lg-12">
                                <div class="card">
                                    <div class="card-body">

                                        <div id="addproduct-nav-pills-wizard" class="twitter-bs-wizard">
                                            <div>
                                                <div>
                                                    <h4 class="header-title">Edit Bulletins</h4>
                                                    <p class="card-title-desc">Modify the information below</p>

                                                    <form action="<?php echo e(route('bulletin.store')); ?>" method="POST" enctype="multipart/form-data">
                                                        <?php echo csrf_field(); ?>

                                                        <!-- Hidden ID Field -->
                                                        <input type="hidden" name="id" value="<?php echo e($bulletin->id ?? ''); ?>">

                                                        <div class="row">
                                                            <!-- Name Field -->
                                                            <div class="col-sm-3">
                                                                <div class="mb-3">
                                                                    <label class="form-label" for="name">Name<span class="text-danger"></span></label>
                                                                    <input type="text" id="name" name="name" class="form-control <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                                                        value="<?php echo e(old('name', $bulletin->name ?? '')); ?>" placeholder="Enter name">
                                                                    <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                                    <div class="invalid-feedback">
                                                                        <?php echo e($message); ?>

                                                                    </div>
                                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                                </div>
                                                            </div>

                                                            <!-- Day Field -->
                                                            <div class="col-sm-3">
                                                                <div class="mb-3">
                                                                    <label class="form-label" for="day">Day<span class="text-danger"> *</span></label>
                                                                    <input type="number" id="date" name="date" class="form-control <?php $__errorArgs = ['date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                                                        value="<?php echo e(old('date', $bulletin->date ?? '')); ?>" placeholder="Enter the date" min="1" max="31">
                                                                    <?php $__errorArgs = ['date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                                    <div class="invalid-feedback">
                                                                        <?php echo e($message); ?>

                                                                    </div>
                                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                                </div>
                                                            </div>

                                                            <!-- Month Field -->
                                                            <div class="col-sm-3">
                                                                <div class="mb-3">
                                                                    <label class="form-label" for="month">Month<span class="text-danger"> *</span></label>
                                                                    <select id="month" name="month" class="form-control <?php $__errorArgs = ['month'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                                                                        <?php $__currentLoopData = range(1, 12); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $m): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                        <option value="<?php echo e($m); ?>" <?php echo e(old('month', $bulletin->month ?? '') == $m ? 'selected' : ''); ?>>
                                                                            <?php echo e(date('F', mktime(0, 0, 0, $m, 10))); ?>

                                                                        </option>
                                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                    </select>
                                                                    <?php $__errorArgs = ['month'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                                    <div class="invalid-feedback">
                                                                        <?php echo e($message); ?>

                                                                    </div>
                                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                                </div>
                                                            </div>

                                                            <!-- Year Field -->
                                                            <div class="col-sm-3">
                                                                <div class="mb-3">
                                                                    <label class="form-label" for="year">Year<span class="text-danger"> *</span></label>
                                                                    <input type="number" id="year" name="year" class="form-control <?php $__errorArgs = ['year'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                                                        value="<?php echo e(old('year', $bulletin->year ?? date('Y'))); ?>" placeholder="Enter year" min="1900" max="<?php echo e(date('Y')); ?>">
                                                                    <?php $__errorArgs = ['year'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                                    <div class="invalid-feedback">
                                                                        <?php echo e($message); ?>

                                                                    </div>
                                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                                </div>
                                                            </div>



                                                            <!-- Image Field -->
                                                            <div class="col-sm-3">
                                                                <div class="mb-3">
                                                                    <label class="form-label" for="image">Image<span class="text-danger"> *</span></label>
                                                                    <input type="file" class="form-control" id="image" name="image" accept="image/*">
                                                                    <?php if(isset($bulletin->image)): ?>
                                                                    <p>Current Image: <img src="<?php echo e(asset($bulletin->image)); ?>" alt="Banner Image" height="50"></p>
                                                                    <?php endif; ?>
                                                                    <?php $__errorArgs = ['image'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                                    <div class="invalid-feedback">
                                                                        <?php echo e($message); ?>

                                                                    </div>
                                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <!-- Submit Button -->
                                                        <ul class="pager wizard twitter-bs-wizard-pager-link">
                                                            <li class="float-end">
                                                                <button type="submit" class="btn btn-primary" style="background-color: red; border-color: red;">
                                                                    Save Changes <i class="mdi mdi-arrow-right ms-1"></i>
                                                                </button>
                                                            </li>
                                                        </ul>
                                                    </form>



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

                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- end row -->

                    </div>


                </div> <!-- container-fluid -->
            </div>
            <!-- End Page-content -->



            <?php echo $__env->make('partials.footer', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

        </div>
        <!-- end main content-->

    </div>
    <!-- End Page-content -->



    </div>
    <?php echo $__env->make('partials.vendor-scripts', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('partials.right-sidebar', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <script>
        $("form").on("submit", function(e) {
            e.preventDefault();

            var formData = new FormData(this);

            // Clear previous error messages
            $("form .invalid-feedback").remove();
            $("form .is-invalid").removeClass("is-invalid");

            $.ajax({
                url: $(this).attr('action'),
                type: 'POST',
                data: formData,
                processData: false,
                contentType: false,
                success: function(response) {
                    console.log(response);
                    if (response.redirect_url) {
                        window.location.href = response.redirect_url;
                    } else {
                        alert('Form submitted successfully!');
                    }
                },
                error: function(xhr) {
                    if (xhr.status === 422) {
                        // Parse validation errors
                        var errors = xhr.responseJSON.errors;
                        for (var field in errors) {
                            var input = $(`[name="${field}"]`);
                            var errorMessage = `<div class="invalid-feedback">${errors[field][0]}</div>`;
                            input.addClass("is-invalid");
                            input.after(errorMessage);
                        }
                    } else {
                        console.error('Error:', xhr.responseText);
                        alert('An unexpected error occurred.');
                    }
                }
            });
        });

        $(".save-button").click(function() {
            $("form").submit();
        });
    </script>



    <script src="<?php echo e(asset('assets/libs/twitter-bootstrap-wizard/jquery.bootstrap.wizard.min.js')); ?>"></script>

    <!-- Prettify JS -->
    <script src="<?php echo e(asset('assets/libs/twitter-bootstrap-wizard/prettify.js')); ?>"></script>

    <!-- Select2 Plugin JS -->
    <script src="<?php echo e(asset('assets/libs/select2/js/select2.min.js')); ?>"></script>

    <!-- Dropzone Plugin JS -->
    <script src="<?php echo e(asset('assets/libs/dropzone/min/dropzone.min.js')); ?>"></script>

    <!-- Init JS -->
    <script src="<?php echo e(asset('assets/js/pages/ecommerce-add-product.init.js')); ?>"></script>

    <!-- App JS -->
    <script src="<?php echo e(asset('assets/js/app.js')); ?>"></script>

</body>

</html><?php /**PATH C:\xampp\htdocs\codissa\resources\views/layouts/bulletin/edit.blade.php ENDPATH**/ ?>