<?php $__env->startSection('title', 'নতুন নোটিশ তৈরি'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <div class="row mb-4">
        <div class="col-md-12">
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="<?php echo e(route('notices.index')); ?>">নোটিশ</a></li>
                    <li class="breadcrumb-item active">নতুন নোটিশ</li>
                </ol>
            </nav>
            <h2 class="mb-0">নতুন নোটিশ তৈরি</h2>
        </div>
    </div>

    <div class="card">
        <div class="card-body">
            <form action="<?php echo e(route('notices.store')); ?>" method="POST" enctype="multipart/form-data" id="noticeForm">
                <?php echo csrf_field(); ?>
                
                <div class="row">
                    <div class="col-md-8">
                        <!-- বেসিক তথ্য -->
                        <div class="card mb-4">
                            <div class="card-header">
                                <h5 class="mb-0">বেসিক তথ্য</h5>
                            </div>
                            <div class="card-body">
                                <div class="mb-3">
                                    <label for="title" class="form-label">শিরোনাম <span class="text-danger">*</span></label>
                                    <input type="text" class="form-control <?php $__errorArgs = ['title'];
$__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); ?>" 
                                           id="title" name="title" value="<?php echo e(old('title')); ?>" required>
                                    <?php $__errorArgs = ['title'];
$__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 class="mb-3">
                                    <label for="content" class="form-label">বিস্তারিত <span class="text-danger">*</span></label>
                                    <textarea class="form-control <?php $__errorArgs = ['content'];
$__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); ?>" 
                                              id="content" name="content" rows="10" required><?php echo e(old('content')); ?></textarea>
                                    <?php $__errorArgs = ['content'];
$__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>

                        <!-- ফাইল সংযুক্তি -->
                        <div class="card mb-4">
                            <div class="card-header">
                                <h5 class="mb-0">ফাইল সংযুক্তি</h5>
                            </div>
                            <div class="card-body">
                                <div class="mb-3">
                                    <label for="attachment" class="form-label">ফাইল আপলোড</label>
                                    <input type="file" class="form-control <?php $__errorArgs = ['attachment'];
$__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); ?>" 
                                           id="attachment" name="attachment" accept=".jpg,.jpeg,.png,.pdf,.doc,.docx">
                                    <small class="text-muted">সাপোর্টেড ফরম্যাট: JPG, PNG, PDF, DOC, DOCX | সর্বোচ্চ সাইজ: 5MB</small>
                                    <?php $__errorArgs = ['attachment'];
$__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>
                    </div>

                    <div class="col-md-4">
                        <!-- সেটিংস -->
                        <div class="card mb-4">
                            <div class="card-header">
                                <h5 class="mb-0">সেটিংস</h5>
                            </div>
                            <div class="card-body">
                                <div class="mb-3">
                                    <label for="notice_type" class="form-label">নোটিশ টাইপ <span class="text-danger">*</span></label>
                                    <select class="form-control <?php $__errorArgs = ['notice_type'];
$__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); ?>" 
                                            id="notice_type" name="notice_type" required>
                                        <option value="">সিলেক্ট করুন</option>
                                        <option value="general" <?php echo e(old('notice_type') == 'general' ? 'selected' : ''); ?>>সাধারণ নোটিশ</option>
                                        <option value="meeting" <?php echo e(old('notice_type') == 'meeting' ? 'selected' : ''); ?>>মিটিং নোটিশ</option>
                                        <option value="event" <?php echo e(old('notice_type') == 'event' ? 'selected' : ''); ?>>ইভেন্ট নোটিশ</option>
                                        <option value="payment" <?php echo e(old('notice_type') == 'payment' ? 'selected' : ''); ?>>পেমেন্ট নোটিশ</option>
                                    </select>
                                    <?php $__errorArgs = ['notice_type'];
$__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 class="mb-3">
                                    <label for="target_audience" class="form-label">টার্গেট অডিয়েন্স <span class="text-danger">*</span></label>
                                    <select class="form-control <?php $__errorArgs = ['target_audience'];
$__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); ?>" 
                                            id="target_audience" name="target_audience" required>
                                        <option value="">সিলেক্ট করুন</option>
                                        <option value="all" <?php echo e(old('target_audience') == 'all' ? 'selected' : ''); ?>>সবাই</option>
                                        <option value="members" <?php echo e(old('target_audience') == 'members' ? 'selected' : ''); ?>>শুধু সদস্যরা</option>
                                        <option value="committee" <?php echo e(old('target_audience') == 'committee' ? 'selected' : ''); ?>>শুধু কমিটি</option>
                                        <option value="specific" <?php echo e(old('target_audience') == 'specific' ? 'selected' : ''); ?>>নির্দিষ্ট সদস্য</option>
                                    </select>
                                    <?php $__errorArgs = ['target_audience'];
$__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 class="mb-3" id="specific_members_section" style="display: none;">
                                    <label for="specific_members" class="form-label">নির্দিষ্ট সদস্য নির্বাচন <span class="text-danger">*</span></label>
                                    <select class="form-control select2 <?php $__errorArgs = ['specific_members'];
$__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); ?>" 
                                            id="specific_members" name="specific_members[]" multiple>
                                        <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($user->id); ?>" 
                                                <?php echo e(in_array($user->id, old('specific_members', [])) ? 'selected' : ''); ?>>
                                                <?php echo e($user->name); ?> (<?php echo e($user->email); ?>)
                                            </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['specific_members'];
$__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 class="row mb-3">
                                    <div class="col-md-6">
                                        <label for="publish_date" class="form-label">প্রকাশের তারিখ</label>
                                        <input type="date" class="form-control <?php $__errorArgs = ['publish_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); ?>" 
                                               id="publish_date" name="publish_date" value="<?php echo e(old('publish_date')); ?>">
                                        <?php $__errorArgs = ['publish_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 class="col-md-6">
                                        <label for="expiry_date" class="form-label">মেয়াদ শেষের তারিখ</label>
                                        <input type="date" class="form-control <?php $__errorArgs = ['expiry_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); ?>" 
                                               id="expiry_date" name="expiry_date" value="<?php echo e(old('expiry_date')); ?>">
                                        <?php $__errorArgs = ['expiry_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>

                                <div class="mb-3">
                                    <label for="status" class="form-label">স্ট্যাটাস <span class="text-danger">*</span></label>
                                    <select class="form-control <?php $__errorArgs = ['status'];
$__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); ?>" 
                                            id="status" name="status" required>
                                        <option value="draft" <?php echo e(old('status') == 'draft' ? 'selected' : ''); ?>>খসড়া</option>
                                        <option value="published" <?php echo e(old('status') == 'published' ? 'selected' : ''); ?>>প্রকাশিত</option>
                                    </select>
                                    <?php $__errorArgs = ['status'];
$__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 class="mb-3">
                                    <label for="priority" class="form-label">অগ্রাধিকার</label>
                                    <select class="form-control <?php $__errorArgs = ['priority'];
$__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); ?>" 
                                            id="priority" name="priority">
                                        <option value="medium" <?php echo e(old('priority') == 'medium' ? 'selected' : ''); ?>>সাধারণ</option>
                                        <option value="low" <?php echo e(old('priority') == 'low' ? 'selected' : ''); ?>>নিম্ন</option>
                                        <option value="high" <?php echo e(old('priority') == 'high' ? 'selected' : ''); ?>>উচ্চ</option>
                                        <option value="urgent" <?php echo e(old('priority') == 'urgent' ? 'selected' : ''); ?>>জরুরি</option>
                                    </select>
                                    <?php $__errorArgs = ['priority'];
$__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 class="mb-3">
                                    <div class="form-check">
                                        <input type="checkbox" class="form-check-input" 
                                               id="is_important" name="is_important" value="1"
                                               <?php echo e(old('is_important') ? 'checked' : ''); ?>>
                                        <label class="form-check-label" for="is_important">
                                            <i class="fas fa-exclamation-triangle text-danger"></i> গুরুত্বপূর্ণ নোটিশ
                                        </label>
                                    </div>

                                    <div class="form-check">
                                        <input type="checkbox" class="form-check-input" 
                                               id="send_notification" name="send_notification" value="1"
                                               <?php echo e(old('send_notification') ? 'checked' : ''); ?>>
                                        <label class="form-check-label" for="send_notification">
                                            <i class="fas fa-bell text-warning"></i> নোটিফিকেশন পাঠান
                                        </label>
                                    </div>

                                    <div class="form-check">
                                        <input type="checkbox" class="form-check-input" 
                                               id="pin_to_top" name="pin_to_top" value="1"
                                               <?php echo e(old('pin_to_top') ? 'checked' : ''); ?>>
                                        <label class="form-check-label" for="pin_to_top">
                                            <i class="fas fa-thumbtack text-primary"></i> পিন করে রাখুন
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- সাবমিট বাটন -->
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary btn-lg">
                                <i class="fas fa-save"></i> নোটিশ সংরক্ষণ করুন
                            </button>
                            <a href="<?php echo e(route('notices.index')); ?>" class="btn btn-secondary">
                                <i class="fas fa-times"></i> বাতিল করুন
                            </a>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('styles'); ?>
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<style>
.select2-container--default .select2-selection--multiple {
    min-height: 38px;
    border: 1px solid #ced4da;
}
.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #80bdff;
}
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startPush('scripts'); ?>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script>
$(document).ready(function() {
    // Select2 ইনিশিয়ালাইজ
    $('#specific_members').select2({
        placeholder: 'সদস্য নির্বাচন করুন',
        allowClear: true,
        width: '100%'
    });

    // টার্গেট অডিয়েন্স পরিবর্তন
    $('#target_audience').change(function() {
        if ($(this).val() === 'specific') {
            $('#specific_members_section').show();
            $('#specific_members').prop('required', true);
        } else {
            $('#specific_members_section').hide();
            $('#specific_members').prop('required', false);
        }
    });

    // তারিখ ভ্যালিডেশন
    $('#publish_date, #expiry_date').change(function() {
        var publishDate = $('#publish_date').val();
        var expiryDate = $('#expiry_date').val();
        
        if (publishDate && expiryDate) {
            if (new Date(expiryDate) <= new Date(publishDate)) {
                alert('মেয়াদ শেষের তারিখ প্রকাশের তারিখের পরে হতে হবে');
                $('#expiry_date').val('');
            }
        }
    });

    // পুরাতন ভ্যালু সেট করা
    <?php if(old('target_audience') == 'specific'): ?>
        $('#specific_members_section').show();
        $('#specific_members').prop('required', true);
    <?php endif; ?>
});
</script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/naowarin/somoti.naowarinternational.my.id/resources/views/notices/create.blade.php ENDPATH**/ ?>