

<?php $__env->startSection('content'); ?>
<div class="bg-gray-100 min-h-full p-4">
    <div class="bg-white p-4 shadow-sm border border-gray-200">
        
        <form action="<?php echo e(route('employees.update', $employee->id)); ?>" method="POST" enctype="multipart/form-data" id="empForm">
            <?php echo csrf_field(); ?>
            <?php echo method_field('PUT'); ?>
            
            <div class="bg-[#ff9800] text-white px-3 py-1.5 font-bold text-sm flex items-center shadow-sm mb-4">
                <i class="fa-solid fa-pen-to-square mr-2"></i> Add/Edit Employee Details
            </div>
            
            <div class="flex flex-col md:flex-row gap-6 mb-6">
                <!-- Left: Photo -->
                <div class="w-full md:w-48 flex flex-col items-center">
                    <div class="w-32 h-32 border border-gray-300 bg-gray-50 flex items-center justify-center overflow-hidden mb-2 relative group">
                        <?php if($employee->photo): ?>
                            <img src="<?php echo e(asset('storage/' . $employee->photo)); ?>" class="w-full h-full object-cover">
                        <?php else: ?>
                            <i class="fa-solid fa-user text-6xl text-blue-500"></i>
                        <?php endif; ?>
                        <input type="file" name="photo" class="absolute inset-0 w-full h-full opacity-0 cursor-pointer" accept="image/*">
                    </div>
                    <div class="text-[10px] text-gray-500 text-center leading-tight">
                        <i class="fa-solid fa-trash text-[#ff9800] mb-1"></i><br>
                        (Photo Size 400 X 400) Photo Size less then 20KB
                    </div>
                </div>

                <!-- Right: Personal Details -->
                <div class="flex-1">
                    <h3 class="text-[#3f51b5] font-bold text-sm border-b pb-1 mb-3">Personal Details</h3>
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Employee Name*</label>
                            <input type="text" name="name" value="<?php echo e(old('name', $employee->name)); ?>" required class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Father/Husband Name</label>
                            <input type="text" name="father_husband_name" value="<?php echo e(old('father_husband_name', $employee->father_husband_name)); ?>" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Employee Code *</label>
                            <input type="text" name="employee_code" value="<?php echo e(old('employee_code', $employee->employee_code)); ?>" required class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Enroll No.* (Eight Digit Only)</label>
                            <input type="text" name="enroll_no" value="<?php echo e(old('enroll_no', $employee->enroll_no)); ?>" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none bg-gray-50">
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">proximity Card No.</label>
                            <input type="text" name="proximity_card_no" value="<?php echo e(old('proximity_card_no', $employee->proximity_card_no)); ?>" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Date of Birth</label>
                            <input type="date" name="dob" value="<?php echo e(old('dob', $employee->dob)); ?>" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none text-gray-500">
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Address</label>
                            <textarea name="address" rows="2" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none"><?php echo e(old('address', $employee->address)); ?></textarea>
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Email Address</label>
                            <input type="email" name="email" value="<?php echo e(old('email', $employee->email)); ?>" required class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Mobile No.</label>
                            <input type="text" name="mobile_no" value="<?php echo e(old('mobile_no', $employee->mobile_no)); ?>" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                        </div>
                    </div>
                </div>
            </div>

            <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
                <!-- Company Details -->
                <div>
                    <h3 class="text-[#3f51b5] font-bold text-sm border-b pb-1 mb-3">Company Details</h3>
                    <div class="space-y-4">
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Company Name*</label>
                            <select disabled class="w-full border border-gray-300 px-2 py-1 text-xs bg-gray-100">
                                <option><?php echo e(\App\Models\Company::where('user_id', session('active_company_id'))->first()->company_name ?? 'N/A'); ?></option>
                            </select>
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Branch Name*</label>
                            <select name="branch_id" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                                <option value="">Select Branch</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($employee->branch_id == $branch->id ? 'selected' : ''); ?>><?php echo e($branch->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                    </div>
                </div>

                <!-- Employee Details -->
                <div class="col-span-2">
                    <h3 class="text-[#3f51b5] font-bold text-sm border-b pb-1 mb-3">Employee Details</h3>
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Dept. Name*</label>
                            <select name="department_id" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                                <option value="">Select Department</option>
                                <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dept): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($dept->id); ?>" <?php echo e($employee->department_id == $dept->id ? 'selected' : ''); ?>><?php echo e($dept->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Designation *</label>
                            <select name="designation_id" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                                <option value="">Select Designation</option>
                                <?php $__currentLoopData = $designations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $desig): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($desig->id); ?>" <?php echo e($employee->designation_id == $desig->id ? 'selected' : ''); ?>><?php echo e($desig->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Office Time Policy*</label>
                            <select name="policy_id" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                                <option value="">Select Policy</option>
                                <?php $__currentLoopData = $policies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $policy): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($policy->id); ?>" <?php echo e($employee->policy_id == $policy->id ? 'selected' : ''); ?>><?php echo e($policy->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Date Of Joining*</label>
                            <input type="date" name="date_of_joining" value="<?php echo e(old('date_of_joining', $employee->date_of_joining)); ?>" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none text-gray-500">
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Shift Start Date*</label>
                            <input type="date" name="shift_start_date" value="<?php echo e(old('shift_start_date', $employee->shift_start_date)); ?>" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none text-gray-500">
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Resignation Date</label>
                            <input type="date" name="resignation_date" value="<?php echo e(old('resignation_date', $employee->resignation_date)); ?>" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none text-gray-500">
                        </div>
                    </div>
                </div>
            </div>

            <!-- Shift Details -->
            <div class="mb-6">
                <h3 class="text-[#3f51b5] font-bold text-sm border-b pb-1 mb-3 flex items-center justify-between">
                    Shift Details
                    <label class="flex items-center space-x-1 cursor-pointer">
                        <input type="checkbox" name="allow_notifications" value="1" <?php echo e($employee->allow_notifications ? 'checked' : ''); ?> class="h-3 w-3">
                        <span class="text-xs font-bold text-gray-800">Allow Notifications</span>
                    </label>
                </h3>
                <div class="flex flex-col md:flex-row gap-6">
                    <div class="flex-1 grid grid-cols-1 md:grid-cols-3 gap-4">
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Shift Type*</label>
                            <select name="shift_type" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                                <option value="Fixed" <?php echo e(old('shift_type', $employee->shift_type) == 'Fixed' ? 'selected' : ''); ?>>Fixed</option>
                                <option value="Rotational" <?php echo e(old('shift_type', $employee->shift_type) == 'Rotational' ? 'selected' : ''); ?>>Rotational</option>
                            </select>
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Shift Name*</label>
                            <select name="shift_id" required class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                                <option value="">Select Shift</option>
                                <?php $__currentLoopData = $shifts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $shift): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($shift->id); ?>" <?php echo e(old('shift_id', $employee->shift_id) == $shift->id ? 'selected' : ''); ?>><?php echo e($shift->name); ?> (<?php echo e($shift->shift_code); ?>)</option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Half Day Shift</label>
                            <select name="half_day_shift" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                                <option value="None" <?php echo e(old('half_day_shift', $employee->half_day_shift) == 'None' ? 'selected' : ''); ?>>None</option>
                                <?php $__currentLoopData = $shifts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $shift): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($shift->id); ?>" <?php echo e(old('half_day_shift', $employee->half_day_shift) == $shift->id ? 'selected' : ''); ?>><?php echo e($shift->name); ?> (<?php echo e($shift->shift_code); ?>)</option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        
                        <div class="col-span-3">
                            <label class="block text-[11px] font-bold text-gray-800 mb-1 flex items-center bg-[#ff9800] text-white px-2 py-1 mt-2 w-max rounded-sm">Second Weekly Off Days</label>
                            <div class="flex space-x-6 p-2 bg-gray-50 border border-gray-200 mt-1">
                                <?php 
                                    $days = is_array(old('second_wo_days', $employee->second_wo_days)) 
                                            ? old('second_wo_days', $employee->second_wo_days) 
                                            : []; 
                                ?>
                                <?php $__currentLoopData = ['I', 'II', 'III', 'IV', 'V']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $day): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <label class="flex items-center space-x-1 cursor-pointer">
                                    <input type="checkbox" name="second_wo_days[]" value="<?php echo e($day); ?>" <?php echo e(in_array($day, $days) ? 'checked' : ''); ?> class="h-3 w-3">
                                    <span class="text-[10px] font-bold text-gray-600"><?php echo e($day); ?></span>
                                </label>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                        </div>

                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">First Weekly Off*</label>
                            <select name="first_weekly_off" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                                <?php $__currentLoopData = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'None', 'All Weeks']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $day): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($day); ?>" <?php echo e(old('first_weekly_off', $employee->first_weekly_off) == $day ? 'selected' : ''); ?>><?php echo e($day); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Second Weekly Off</label>
                            <select name="second_weekly_off" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                                <?php $__currentLoopData = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'None', 'All Weeks']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $day): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($day); ?>" <?php echo e(old('second_weekly_off', $employee->second_weekly_off) == $day ? 'selected' : ''); ?>><?php echo e($day); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div>
                            <label class="block text-[11px] font-bold text-gray-800 mb-1">Second WO Type</label>
                            <select name="second_wo_type" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                                <option value="None" <?php echo e(old('second_wo_type', $employee->second_wo_type) == 'None' ? 'selected' : ''); ?>>None</option>
                                <option value="Half" <?php echo e(old('second_wo_type', $employee->second_wo_type) == 'Half' ? 'selected' : ''); ?>>Half</option>
                                <option value="Full" <?php echo e(old('second_wo_type', $employee->second_wo_type) == 'Full' ? 'selected' : ''); ?>>Full</option>
                            </select>
                        </div>
                    </div>
                    
                    <div class="w-48">
                        <div>
                            <label class="block text-[11px] font-bold text-[#ff9800] mb-1">Extra Allowances for Tour</label>
                            <input type="text" name="extra_allowances_for_tour" value="<?php echo e(old('extra_allowances_for_tour', $employee->extra_allowances_for_tour)); ?>" class="w-32 border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                        </div>
                        <div class="mt-4 border border-gray-300 p-2 h-32 overflow-y-auto">
                            <?php $autoShifts = is_array($employee->is_auto_shift) ? $employee->is_auto_shift : []; ?>
                            <label class="flex items-center space-x-1 cursor-pointer">
                                <input type="checkbox" name="is_auto_shift[]" value="GEN" <?php echo e(in_array('GEN', $autoShifts) ? 'checked' : ''); ?> class="h-3 w-3">
                                <span class="text-[10px] font-bold text-[#ff9800]">Is Auto Shift</span>
                            </label>
                            <div class="text-[10px] text-gray-600 pl-4">GEN</div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Access Control Setting -->
            <div class="mb-6">
                <h3 class="text-[#ff9800] font-bold text-sm border-b pb-1 mb-3">
                    Access Control Setting <span class="text-[10px] font-normal text-[#ff9800]">(Note WeekTime Zone 2,3,4 Only For access controller 2 Door And 4 Door)</span>
                </h3>
                <div class="grid grid-cols-1 md:grid-cols-6 gap-4">
                    <?php for($i=1; $i<=8; $i++): ?>
                    <div>
                        <label class="block text-[11px] font-bold text-gray-800 mb-1">Week Time Zone <?php echo e($i); ?><?php echo e($i == 1 ? '*' : ''); ?></label>
                        <select name="week_time_zone_<?php echo e($i); ?>" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none">
                            <?php for($z=0; $z<=10; $z++): ?>
                                <option value="<?php echo e($z); ?>" <?php echo e(old('week_time_zone_'.$i, $employee->{'week_time_zone_'.$i} ?? ($i==1 ? '1' : '0')) == $z ? 'selected' : ''); ?>><?php echo e($z); ?></option>
                            <?php endfor; ?>
                        </select>
                    </div>
                    <?php endfor; ?>
                    <div>
                        <label class="block text-[11px] font-bold text-gray-800 mb-1">Validity Start*</label>
                        <input type="date" name="validity_start" value="<?php echo e(old('validity_start', $employee->validity_start)); ?>" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none text-gray-500">
                    </div>
                    <div>
                        <label class="block text-[11px] font-bold text-gray-800 mb-1">Validity End*</label>
                        <input type="date" name="validity_end" value="<?php echo e(old('validity_end', $employee->validity_end)); ?>" class="w-full border border-gray-300 px-2 py-1 text-xs focus:border-[#ff9800] focus:outline-none text-gray-500">
                    </div>
                </div>
            </div>

            <!-- Form Action Buttons -->
            <div class="mt-8 text-center space-x-2 pb-4">
                <button type="submit" class="bg-[#4caf50] hover:bg-[#43a047] text-white px-6 py-2 rounded shadow text-sm font-semibold transition">Update</button>
                <button type="button" class="bg-[#3f51b5] hover:bg-[#3949ab] text-white px-6 py-2 rounded shadow text-sm font-semibold transition opacity-80" onclick="alert('Device sync not yet connected.');">Update & Send Device</button>
                <a href="<?php echo e(route('employees.index')); ?>" class="bg-[#f44336] hover:bg-[#e53935] text-white px-6 py-2 rounded shadow text-sm font-semibold inline-block transition">Cancel</a>
            </div>
            
        </form>
    </div>
</div>
<?php $__env->stopSection(); ?>

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