<?php $__env->startSection('content'); ?>
<div class="flex justify-between items-center mb-6">
    <h2 class="text-2xl font-bold text-gold">إنشاء دورة رواتب جديدة</h2>
    <a href="<?php echo e(route('admin.payrolls.index')); ?>" class="px-4 py-2 bg-gray-800 text-gray-300 rounded-lg">عودة</a>
</div>

<div class="max-w-xl bg-black/20 border border-gray-800 rounded-2xl p-8">
    <form action="<?php echo e(route('admin.payrolls.store')); ?>" method="POST" id="payrollForm">
        <?php echo csrf_field(); ?>
        
        <div class="space-y-6">
            <div>
                <label class="block text-sm text-gray-400 mb-2">الفرع</label>
                <select name="branch_id" required class="w-full bg-black border-gray-800 rounded-lg px-4 py-2.5 text-white focus:border-gold outline-none">
                    <option value="">اختر الفرع</option>
                    <?php $__currentLoopData = $branches; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $branch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($branch->id); ?>"><?php echo e($branch->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <?php $__errorArgs = ['branch_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <span class="text-red-500 text-xs"><?php echo e($message); ?></span> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
            </div>

            <div class="grid grid-cols-2 gap-4">
                <div>
                    <label class="block text-sm text-gray-400 mb-2">السنة</label>
                    <select id="select_year" class="w-full bg-black border-gray-800 rounded-lg px-4 py-2.5 text-white focus:border-gold outline-none">
                        <?php for($y = 2025; $y <= 2050; $y++): ?>
                            <option value="<?php echo e($y); ?>" <?php echo e($y == date('Y') ? 'selected' : ''); ?>><?php echo e($y); ?></option>
                        <?php endfor; ?>
                    </select>
                </div>
                <div>
                    <label class="block text-sm text-gray-400 mb-2">الشهر</label>
                    <select id="select_month" class="w-full bg-black border-gray-800 rounded-lg px-4 py-2.5 text-white focus:border-gold outline-none">
                        <?php
                            $months = [
                                '01' => 'يناير', '02' => 'فبراير', '03' => 'مارس', '04' => 'أبريل',
                                '05' => 'مايو', '06' => 'يونيو', '07' => 'يوليو', '08' => 'أغسطس',
                                '09' => 'سبتمبر', '10' => 'أكتوبر', '11' => 'نوفمبر', '12' => 'ديسمبر'
                            ];
                        ?>
                        <?php $__currentLoopData = $months; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $num => $name): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($num); ?>" <?php echo e($num == date('m') ? 'selected' : ''); ?>><?php echo e($num); ?> - <?php echo e($name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>

            <!-- Hidden field to store combined YYYY-MM -->
            <input type="hidden" name="month" id="combined_month">

            <p class="text-[10px] text-gray-500 mt-1">سيتم جلب جميع الموظفين النشطين في هذا الفرع تلقائياً.</p>
            <?php $__errorArgs = ['month'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <span class="text-red-500 text-xs"><?php echo e($message); ?></span> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>

            <button type="submit" class="btn-gold w-full py-3 mt-4 font-bold">إنشاء الدورة</button>
        </div>
    </form>
</div>

<script>
    document.getElementById('payrollForm').addEventListener('submit', function(e) {
        const year = document.getElementById('select_year').value;
        const month = document.getElementById('select_month').value;
        document.getElementById('combined_month').value = `${year}-${month}`;
    });
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\tq cars\resources\views/admin/payrolls/create.blade.php ENDPATH**/ ?>