<?php
    $layout = auth()->user()->role === 'super_admin' ? 'layouts.admin' : 'layouts.app';
?>



<?php $__env->startSection('title', 'Register New Grievance'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid px-4 py-3">
    <!-- Header -->
    <div class="dashboard-header">
        <div class="container-fluid">
            <div class="row align-items-center dashboard-header-content">
                <div class="col-lg-6">
                    <h1 class="dashboard-title">
                        <i class="fas fa-tachometer-alt" style="color: var(--dhis2-blue-primary);"></i>
                        Register New Grievance
                    </h1>
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="javascript:history.back()">Back</a></li>
                            <li class="breadcrumb-item"><a href="<?php echo e(route('component1.dashboard')); ?>">Component 1 Dashboard</a></li>
                            <li class="breadcrumb-item active">Grievances</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="container py-4">
    <div class="row justify-content-center">
        <div class="col-lg-10">
            <h3 class="text-success mb-4 text-center fw-bold">Register New Grievance</h3>

            <div class="card border-secondary border-2 shadow-lg rounded-3">
                <div class="card-body p-4 p-md-5">
                    <?php if($errors->any()): ?>
                        <div class="alert alert-danger">
                            <ul class="mb-0">
                                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li><?php echo e($error); ?></li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        </div>
                    <?php endif; ?>

                    <form method="POST" action="<?php echo e(route('grievances.store')); ?>">
                        <?php echo csrf_field(); ?>

                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label for="complainant_name" class="form-label">Name of Complainant</label>
                                <input type="text" name="complainant_name" id="complainant_name" class="form-control <?php $__errorArgs = ['complainant_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('complainant_name')); ?>">
                                <?php $__errorArgs = ['complainant_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 class="col-md-6 mb-3">
                                <label for="gender" class="form-label">Gender</label>
                                <select name="gender" id="gender" class="form-control <?php $__errorArgs = ['gender'];
$__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); ?>">
                                    <option value="">Select Gender</option>
                                    <option value="Male" <?php echo e(old('gender') == 'Male' ? 'selected' : ''); ?>>Male</option>
                                    <option value="Female" <?php echo e(old('gender') == 'Female' ? 'selected' : ''); ?>>Female</option>
                                </select>
                                <?php $__errorArgs = ['gender'];
$__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-4 mb-3">
                                <label for="state_aa" class="form-label">State & AA</label>
                                <select name="state_aa" id="state_aa" class="form-control <?php $__errorArgs = ['state_aa'];
$__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); ?>">
                                    <option value="">Select State</option>
                                    <?php $__currentLoopData = ['CES', 'EES', 'WES', 'Jonglei', 'Unity', 'Upper Nile', 'Lakes', 'Warrap', 'WBGS', 'NBGS', 'Pibor', 'Abyei', 'Ruweng']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $state): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($state); ?>" <?php echo e(old('state_aa') == $state ? 'selected' : ''); ?>><?php echo e($state); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                                <?php $__errorArgs = ['state_aa'];
$__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-4 mb-3">
                                <label for="county" class="form-label">County</label>
                                <input type="text" name="county" id="county" class="form-control <?php $__errorArgs = ['county'];
$__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('county')); ?>">
                                <?php $__errorArgs = ['county'];
$__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-4 mb-3">
                                <label for="payam" class="form-label">Payam</label>
                                <input type="text" name="payam" id="payam" class="form-control <?php $__errorArgs = ['payam'];
$__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('payam')); ?>">
                                <?php $__errorArgs = ['payam'];
$__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-4 mb-3">
                                <label for="project_beneficiary" class="form-label">Project Beneficiary</label>
                                <select name="project_beneficiary" id="project_beneficiary" class="form-control">
                                    <option value="">Select</option>
                                    <option value="N/A">N/A</option>
                                    <option value="Direct">Direct</option>
                                    <option value="Indirect">Indirect</option>
                                </select>
                            </div>

                            <div class="col-md-4 mb-3">
                                <label for="direct_type" class="form-label">Direct Type</label>
                                <select name="direct_type" id="direct_type" class="form-control">
                                    <option value="">Select</option>
                                    <option value="VSLA Member">VSLA Member</option>
                                    <option value="Community Leader">Community Leader</option>
                                    <option value="Project Staff">Project Staff</option>
                                    <option value="Contractor">Contractor</option>
                                    <option value="Others">Others</option>
                                </select>
                            </div>

                            <div class="col-md-4 mb-3">
                                <label for="report_date" class="form-label">Date of Report</label>
                                <input type="date" name="report_date" class="form-control <?php $__errorArgs = ['report_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); ?>">
                            </div>
                        </div>

                        <hr>

                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label for="grievance_type" class="form-label">Type of Grievances</label>
                                <select name="grievance_type" class="form-control">
                                    <option value="">Select Type</option>
                                    <option value="WEOF Application">WEOF Application</option>
                                    <option value="Grants issue">Grants issue</option>
                                    <option value="GBV/SEA">GBV/SEA</option>
                                    <option value="Fraud">Fraud</option>
                                    <option value="Land Issue">Land Issue</option>
                                </select>
                            </div>

                            <div class="col-md-6 mb-3">
                                <label for="complaint_channel" class="form-label">Channel of Complaints</label>
                                <select name="complaint_channel" class="form-control">
                                    <option value="">Select Channel</option>
                                    <option value="Written Petition">Written Petition</option>
                                    <option value="Text Message">Text Message</option>
                                    <option value="GRM hotlines">GRM hotlines</option>
                                </select>
                            </div>
                        </div>

                        <hr>

                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label>Actions of GRM Committee</label>
                                <div class="form-check">
                                    <input type="checkbox" name="grm_actions_resolved_closed" value="1" class="form-check-input">
                                    <label class="form-check-label">Resolved & Closed</label>
                                </div>
                                <div class="form-check">
                                    <input type="checkbox" name="notification_decisions_outcome" value="1" class="form-check-input">
                                    <label class="form-check-label">Notification - Decisions Outcome</label>
                                </div>
                            </div>

                            <div class="col-md-6 mb-3">
                                <label for="status" class="form-label">Overall Status</label>
                                <select name="status" class="form-control">
                                    <option value="Open">Open</option>
                                    <option value="Closed">Closed</option>
                                    <option value="Referred">Referred</option>
                                </select>
                            </div>
                        </div>

                        <?php if(request('component') == 1): ?>
                        <div class="row bg-light p-3 border rounded mb-3">
                            <div class="col-md-4">
                                <label>Link to Group (Optional)</label>
                                <select name="group_id" class="form-control">
                                    <option value="">None</option>
                                    <?php $__currentLoopData = App\Models\C1Group::all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $group): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($group->id); ?>"><?php echo e($group->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-md-4">
                                <label>Link to Member (Optional)</label>
                                <select name="member_id" class="form-control">
                                    <option value="">None</option>
                                    <?php $__currentLoopData = App\Models\C1Member::all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $member): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($member->id); ?>"><?php echo e($member->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                        </div>
                        <?php endif; ?>

                        <div class="mt-4">
                            <button type="submit" class="btn btn-primary px-5">Submit Complaint</button>
                        </div>                        
                    </form>
                    <script>
                        document.getElementById('project_beneficiary').addEventListener('change', function() {
                        var directGroup = document.getElementById('direct_type_group');
                        var indirectGroup = document.getElementById('indirect_type_group');
                        directGroup.style.display = 'none';
                        indirectGroup.style.display = 'none';
                        if (this.value === 'Direct') {
                        directGroup.style.display = 'block';
                        } else if (this.value === 'Indirect') {
                        indirectGroup.style.display = 'block';
                        }
                        });
                        
                        // Trigger on load for old values
                        document.getElementById('project_beneficiary').dispatchEvent(new Event('change'));
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make($layout, array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\wamp64\www\sswseepcomponents\resources\views/grievances/create.blade.php ENDPATH**/ ?>