<div class="container mt-5">

    <?php
    if ($this->session->flashdata('alert_success')) {
    ?>
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="true">×</span>
            </button>
            <?php echo $this->session->flashdata('alert_success'); ?>
        </div>
    <?php
    }

    if ($this->session->flashdata('alert_danger')) {
    ?>
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="true">×</span>
            </button>
            <?php echo $this->session->flashdata('alert_danger'); ?>
        </div>
    <?php
    }
    ?>
    <?php  //print_r($personalInfo); exit; 
    ?>
    <div class="card">
        <div class="card-body">
            <div class="d-flex justify-content-between">

                <div class="col-6">
                    <h4 class="header-title mb-3"> Application view</h4>
                </div>
                <div class="col-6" style="text-align: right;">
              
            <img src="<?= isset($personalInfo['image_url']) ? $personalInfo['image_url'] : '' ?>" alt="Candidate Image" class="float-right" style="max-width: 150px;">
   
                </div>


            </div>

            <div class="row col-md-12">
                <div class="col-md-12">
                    <table class="table">
                        <tbody>

                            <tr >
                                <td>Name</td>
                                <td><?= isset($personalInfo) ? $personalInfo['first_name'] . ' ' . $personalInfo['middle_name'] . ' ' . $personalInfo['last_name'] : '' ?></td>
                            </tr>
                            <!-- <tr>
                            <td>Middle Name</td>
                            <td><?= isset($personalInfo) ? $personalInfo['middle_name'] : '' ?></td>
                        </tr> -->
                            <tr>
                                <td>Gender</td>
                                <td><?= isset($personalInfo) ? $personalInfo['gender'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Date Of Birth</td>
                                <td><?= isset($personalInfo) ? $personalInfo['dob'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Course Name</td>
                                <td><?= isset($personalInfo) ? $personalInfo['course_name'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Application Fees</td>
                                <td><?= isset($personalInfo) ? $personalInfo['application_fees'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Address</td>
                                <td><?= isset($personalInfo) ? $personalInfo['communication_address'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Landline (optional)</td>
                                <td><?= isset($personalInfo) ? $personalInfo['landline'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Mobile (With Country Code)</td>
                                <td><?= isset($personalInfo) ? $personalInfo['mobile'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Email</td>
                                <td><?= isset($personalInfo) ? $personalInfo['email'] : '' ?></td>
                            </tr>
                            <td class="b h5">Father Information</td>
                            <td></td>
                            <tr>
                                <td>Father Name / Guardian</td>
                                <td><?= isset($parentInfo) ? $parentInfo['father_name'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Occupation</td>
                                <td><?= isset($parentInfo) ? $parentInfo['father_occupation'] : '' ?></td>
                            </tr>

                            <td class="b h5">Home Information (Father)</td>
                            <td></td>

                            <tr>
                                <td>Address</td>
                                <td><?= isset($parentInfo) ? $parentInfo['father_home_address'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Landline (optional)</td>
                                <td><?= isset($parentInfo) ? $parentInfo['father_home_landline'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Mobile (With Country Code)</td>
                                <td><?= isset($parentInfo) ? $parentInfo['father_home_mobile'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Email</td>
                                <td><?= isset($parentInfo) ? $parentInfo['father_home_email'] : '' ?></td>
                            </tr>
                            <tr>
                                <td class="b h5">Office Information (Father)</td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>Address</td>
                                <td><?= isset($parentInfo) ? $parentInfo['father_office_address'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Landline (optional)</td>
                                <td><?= isset($parentInfo) ? $parentInfo['father_office_landline'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Mobile (With Country Code)</td>
                                <td><?= isset($parentInfo) ? $parentInfo['father_office_mobile'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Email</td>
                                <td><?= isset($parentInfo) ? $parentInfo['father_office_email'] : '' ?></td>
                            </tr>
                            <tr>
                                <td class="b h5">Mother Information</td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>Mother Name</td>
                                <td><?= isset($parentInfo) ? $parentInfo['mother_name'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Occupation</td>
                                <td><?= isset($parentInfo) ? $parentInfo['mother_occupation'] : '' ?></td>
                            </tr>
                            <tr>
                                <td class="b h5">Home Information (Mother)</td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>Address</td>
                                <td><?= isset($parentInfo) ? $parentInfo['mother_home_address'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Landline (optional)</td>
                                <td><?= isset($parentInfo) ? $parentInfo['mother_home_land_line'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Mobile (With Country Code)</td>
                                <td><?= isset($parentInfo) ? $parentInfo['mother_home_mobile'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Email</td>
                                <td><?= isset($parentInfo) ? $parentInfo['mother_home_email'] : '' ?></td>
                            </tr>
                            <tr>
                                <td class="b h5">Office Information (Mother)</td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>Address</td>
                                <td><?= isset($parentInfo) ? $parentInfo['mother_office_address'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Landline (optional)</td>
                                <td><?= isset($parentInfo) ? $parentInfo['mother_office_land_line'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Mobile (With Country Code)</td>
                                <td><?= isset($parentInfo) ? $parentInfo['mother_office_mobile'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Email</td>
                                <td><?= isset($parentInfo) ? $parentInfo['mother_office_email'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Annual family income from all sources (in INR)</td>
                                <td><?= isset($parentInfo) ? $parentInfo['annual_income_rs'] : '' ?></td>
                            </tr>
                            <tr>
                                <td>Amount in words</td>
                                <td><?= isset($parentInfo) ? $parentInfo['annual_income_words'] : '' ?></td>
                            </tr>
                            <?php if ($personalInfo['apply_scholarship'] == 1) { ?>
                                <tr>
                                    <td class="b h5">scholarship</td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>Community Certificate</td>
                                    <td><?= isset($personalInfo) ? 'yes' : '' ?></td>
                                </tr>
                                <tr>
                                    <td>Income Certificate</td>
                                    <!-- <td><a href="<?= isset($personalInfo) ? $personalInfo['income_certificate'] : '' ?>"><i class="ti-eye"></i></a></td> -->
                                    <td><?= isset($personalInfo) ? 'yes' : '' ?></td>
                                </tr>

                </div>
            </div>


        <?php } else { ?>
            <tr>
                <td>scholarship</td>
                <td>No</td>
            </tr>
        <?php } ?>

        <td class="b h5">Education (Start with last College/University attended)</td>
        <td></td>



        <table class="table table-bordered p-3">
            <thead class="thead-dark">
                <tr>
                    <th class="col">Institution</th>
                    <th class="col">Year</th>
                    <th class="col">Subjects</th>
                    <th class="col">Degree</th>
                    <th class="col">Marks / Grade</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($educationWorkInfo as $info) {
                    if ($info->education_institution) {
                ?>
                        <tr>
                            <td><?= $info->education_institution ?></td>
                            <td><?= $info->education_year ?></td>
                            <td><?= $info->education_subject ?></td>
                            <td><?= $info->education_degree ?></td>
                            <td><?= $info->education_marks ?></td>
                        </tr>
                <?php
                    }
                } ?>
            </tbody>
        </table>



        <tr>
            <h4>High School</h4>
            </td>
            </td>
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th class="col-3">School Name</th>
                        <th class="col-2">Year</th>
                        <th class="col-3">Board</th>
                        <th class="col-2">Marks / Grades</th>

                    </tr>
                </thead>
                <tbody>
                    <?php
                    if ($condition) {
                        // Handle the condition if needed
                    } else {
                        foreach ($educationWorkInfo as $info) {
                            if ($info->high_school_name) {
                    ?>
                                <tr>
                                    <td><?= $info->high_school_name ?></td>
                                    <td><?= $info->high_school_year ?></td>
                                    <td><?= $info->educational_boards ?></td>
                                    <td><?= $info->high_school_marks ?></td>
                                </tr>
                    <?php
                            }
                        }
                    }
                    ?>
                </tbody>
            </table>
        </tr>

        <tr>
            <h4>Work experience, if any</h4>

            </td>
            </td>
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th scope="col" class="col-md-2">Organisation</th>
                        <th scope="col" class="col-md-2">Year</th>
                        <th scope="col" class="col-md-2">Title</th>
                        <th scope="col" class="col-md-2">Responsibilities</th>


                    </tr>
                </thead>
                <tbody>
                    <?php {
                        foreach ($educationWorkInfo as $info) {
                            if ($info->worked_organisation) {
                    ?>
                                <tr>
                                    <td><?= $info->worked_organisation ?></td>
                                    <td><?= $info->worked_year ?></td>
                                    <td><?= $info->worked_title ?></td>
                                    <td><?= $info->worked_responsibilities ?></td>
                                </tr>
                    <?php
                            }
                        }
                    }
                    ?>
                </tbody>
            </table>
        </tr>


        <table class="border">
            <tr class="border">
                <td class="col-6">Name three leading media professionals and explain in a sentence or two, why they have impressed you:</td>
                <td class="col-6 d-flex justify-content-end"><?= isset($otherInfo) ? $otherInfo['media_professionals'] : '' ?></td>
            </tr>
            <tr class="border">
                <td class="col-6">Has any of your work been published/broadcast/podcast? If yes, specify:</td>
                <td class="col-6 d-flex justify-content-end"><?= isset($otherInfo) ? $otherInfo['broadcast_podcast'] : '' ?></td>
            </tr>
            <tr class="border">
                <td class="col-6">Tell us in 100 words why you wish to be a journalist and why you think you will be good at it:</td>
                <td class="col-6 d-flex justify-content-end"><?= isset($otherInfo) ? $otherInfo['journalist_reason'] : '' ?></td>
            </tr>
            <tr class="border">
                <td class="col-6">Will you need residential accommodation?</td>
                <td class="col-6 d-flex justify-content-end"><?= isset($accomodation_info) && $accomodation_info['residential_accommodation'] == 1 ? 'Yes' : 'No' ?></td>
            </tr>
            <tr class="border">
                <td class="col-6">Applied under SC/ST quota?</td>
                <td class="col-6 d-flex justify-content-end"><?= isset($accomodation_info) && $accomodation_info['application_fee_checked'] == 1 ? 'Yes' : 'No' ?></td>
            </tr>
            <tr class="border">
                <td class="col-6">Upload community certificate</td>
                <td class="col-6 d-flex justify-content-end">N/A</td>
            </tr>
            <tr class="border">
                <td class="col-6">PAYMENT MODE</td>
                <td class="col-6 d-flex justify-content-end"><?= isset($accomodation_info) && $accomodation_info['payment_mode'] == 0 ? 'Online' : 'Offline' ?></td>
            </tr>
            </tbody>
        </table>

        
        </div>


        <!-- <div class="row col-md-12">
                <div class="col-5">
                    <p class="mg-b-10">Course Name <span class="text-danger"></p>
                    <p class="mg-b-10">Application Fees <span class="text-danger"></p>
                    <p class="mg-b-10">First Name<span class="text-danger"></p>
                    <p class="mg-b-10">Middle Name <span class="text-danger"></p>
                    <p class="mg-b-10">Gender<span class="text-danger"></p>
                    <p class="mg-b-10">Date Of Birth<span class="text-danger"></p>
                    <p class="mg-b-10">Address<span class="text-danger"></p>
                    <p class="mg-b-10">Landline (optional)<span class="text-danger"></p>
                    <p class="mg-b-10">Mobile (With Country Code)<span class="text-danger"></p>
                    <p class="mg-b-10">Email<span class="text-danger"></p>

                    <p class="mg-b-10">Father Name / Guardian<span class="text-danger"></p>
                    <p class="mg-b-10">Occupation<span class="text-danger"></p>
                    <h4>Home Information</h4>
                    <p class="mg-b-10">Address<span class="text-danger"></p>
                    <p class="mg-b-10"> Landline (optional) <span class="text-danger"></p>
                    <p class="mg-b-10"> Mobile (With Country Code) <span class="text-danger"></p>
                    <p class="mg-b-10">Email <span class="text-danger"></p>
                    <h4>Office Information</h4>
                    <p class="mg-b-10"> Address<span class="text-danger"></p>
                    <p class="mg-b-10"> Landline (optional)<span class="text-danger"></p>
                    <p class="mg-b-10"> Mobile (With Country Code)<span class="text-danger"></p>
                    <p class="mg-b-10"> Email<span class="text-danger"></p>
                    <h4>Mother Information</h4>

                    <p class="mg-b-10"> Mother Name<span class="text-danger"></p>
                    <p class="mg-b-10"> Occupation<span class="text-danger"></p>
                    <h4 class="">Home Information</h4>
                    <p class="mg-b-10"> <span class="text-danger"></p>
                    <p class="mg-b-10">Address<span class="text-danger"></p>
                    <p class="mg-b-10"> Landline (optional) <span class="text-danger"></p>
                    <p class="mg-b-10"> Mobile (With Country Code) <span class="text-danger"></p>
                    <p class="mg-b-10">Email <span class="text-danger"></p>
                    <h4>Office Information</h4>
                    <p class="mg-b-10">Address<span class="text-danger"></p>
                    <p class="mg-b-10"> Landline (optional) <span class="text-danger"></p>
                    <p class="mg-b-10"> Mobile (With Country Code) <span class="text-danger"></p>
                    <p class="mg-b-10">Email <span class="text-danger"></p>
                    <p class="mg-b-10">Annual family income from all sources <span class="text-danger"></p>
                    <p class="mg-b-10">In INR<span class="text-danger"></p>
                    <p class="mg-b-10">Amount in words<span class="text-danger"></p>
                    <h4 class="mg-b-10">Do you intend to apply scholarship?<span class="text-danger"></h4>
                    <p class="mg-b-10">Community Certificate<span class="text-danger"></p>
                    <p class="mg-b-10">Income Certificate<span class="text-danger"></p>
                </div>
                <div class="col-5">
                    <p class="mg-b-10"><?= isset($personalInfo) ? $personalInfo['course_name'] : ' ' ?></p>
                    <p class="mg-b-10"><?= isset($personalInfo) ? $personalInfo['application_fees'] : '' ?></p>
                    <p class="mg-b-10"><?= isset($personalInfo) ? $personalInfo['first_name'] : '' ?></p>
                    <p class="mg-b-10"><?= isset($personalInfo) ? $personalInfo['middle_name'] : '' ?></p>
                    <p class="mg-b-10"> <?= isset($personalInfo) ? $personalInfo['last_name'] : '' ?></p>
                    <p class="mg-b-10"> <?= isset($personalInfo) && $personalInfo['gender'] ?></p>
                    <p class="mg-b-10"> <?= isset($personalInfo) ? $personalInfo['dob'] : '' ?></p>
                    <p class="mg-b-10"><?= isset($personalInfo) ? $personalInfo['communication_address'] : '' ?> </p>
                    <P class="mg-b-10"><?= $personalInfo['landline'] ?></P>
                    <P class="mg-b-10"><?= $personalInfo['mobile'] ?></P>
                    <P class="mg-b-10"><?= $personalInfo['email'] ?></P>

                    <P class="mg-b-10"><?= $parentInfo['father_name']  ?></P>
                    <P class="mg-b-10"><?= $parentInfo['father_occupation']   ?></P>
                    <P class="mg-b-10"></p>
                    <P><?= $parentInfo['father_home_address']  ?></P>
                    <P><?= $parentInfo['father_home_landline']  ?></P>
                    <P><?= $parentInfo['father_home_mobile'] ?></P>
                    <P><?= $parentInfo['father_home_email']  ?></P>
                    <div></div>
                    <P><?= $parentInfo['father_office_address']  ?></P>
                    <P><?= $parentInfo['father_office_landline']   ?></P>
                    <P><?= $parentInfo['father_office_mobile']  ?></P>
                    <P><?= $parentInfo['father_office_email']  ?></P>
                    <div></div>
                    <P><?= $parentInfo['mother_name']   ?></P>
                    <P><?= $parentInfo['mother_occupation']   ?></P>
                    <div></div>
                    <P><?= ($parentInfo['addressCheckbox'] == 1) ? $parentInfo['father_home_address'] :  $parentInfo['mother_home_addressss']  ?></P>
                    <P><?= $parentInfo['mother_home_addressss']  ?></P>
                    <P><?= $parentInfo['mother_home_land_line']  ?></P>
                    <P><?= $parentInfo['mother_home_mobile']   ?></P>
                    <P><?= $parentInfo['mother_home_email']     ?></P>
                    <div></div>
                    <P><?= $parentInfo['mother_office_address']  ?></P>
                    <P><?= $parentInfo['mother_office_land_line']    ?></P>

                    <P><?= $parentInfo['mother_office_mobile']  ?></P>
                    <P><?= $parentInfo['mother_office_email']  ?></P>
                    <div></div>
                    <P><?= $parentInfo['annual_income_rs'] ?></P>
                    <P><?= $parentInfo['annual_income_words'] ?></P>
                    <P><?= $personalInfo['apply_scholarship'] ?></P>
                    <P><?= $personalInfo['community_certificate'] ?></P>
                    <P><?= $personalInfo['income_certificate'] ?></P>
                </div>
                <div class="col-2">
                <p>
                        <?php
                        if (!empty($personalInfo['image_url'])) {
                        ?>
                            <img src="<?= $personalInfo['image_url'] ?>" alt="" height="150px" width="150px">
                        <?php
                        } else {
                        ?>

                            <span>No image available</span>
                        <?php
                        }
                        ?>
                    </p>
                </div>
                <div class="col-12 mt-2">
                    <h3>Education (Start with last College/University attended)</h3>
                    <table class="table table-bordered p-3">
                        <thead class="thead-dark">
                            <tr>
                                <th class="col">Institution</th>
                                <th class="col">Year</th>
                                <th class="col">Subjects</th>
                                <th class="col">Degree</th>
                                <th class="col">Marks / Grade</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($educationWorkInfo as $info) {
                                if ($info->education_institution) {
                            ?>
                                    <tr>
                                        <td><?= $info->education_institution ?></td>
                                        <td><?= $info->education_year ?></td>
                                        <td><?= $info->education_subject ?></td>
                                        <td><?= $info->education_degree ?></td>
                                        <td><?= $info->education_marks ?></td>
                                    </tr>
                            <?php
                                }
                            } ?>
                        </tbody>
                    </table>
                </div>
                <div class="col-12 mt-2">
                    <h3>High School</h3>
                    <div class="table-responsive">

                        
                    </div>
                </div>
                <div class="col-12 mt-2">
                    <h3>Other Educational Qualifications</h3>

                    <table class="table table-bordered">
                        <thead>
                            <tr>

                                <th scope="col" class="col-md-2">Institution</th>
                                <th scope="col" class="col-md-2">Year</th>
                                <th scope="col" class="col-md-2">Subject</th>
                                <th scope="col" class="col-md-2">Certificate</th>
                                <th scope="col" class="col-md-2">Award</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php {
                                foreach ($educationWorkInfo as $info) {
                                    if ($info->other_education_institution) {
                            ?>
                                        <tr>

                                            <td><?= $info->other_education_institution ?></td>
                                            <td><?= $info->other_education_year ?></td>
                                            <td><?= $info->other_education_subject ?></td>
                                            <td><?= $info->other_education_certificate ?></td>
                                            <td><?= $info->other_education_award ?></td>
                                        </tr>
                            <?php
                                    }
                                }
                            }
                            ?>
                        </tbody>
                    </table>
                </div>
                <div class="col-6 mt-2">
                    <p class="mg-b-10">Academic distinctions/awards, if any<span class="text-danger"></p>
                    <p class="mg-b-10">Extracurricular interests, hobbies, sports, etc<span class="text-danger"></p>
                </div>
                <div class="col-6 mt-2">
                    <P><?= $personalInfo['academic_awards'] ?></P>
                    <P><?= $personalInfo['extracurricular'] ?></P>
                </div>
                <div class="col-12 mt-2">
                    <h3>Work experience, if any</h3>

                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th scope="col" class="col-md-2">Organisation</th>
                                <th scope="col" class="col-md-2">Year</th>
                                <th scope="col" class="col-md-2">Title</th>
                                <th scope="col" class="col-md-2">Responsibilities</th>


                            </tr>
                        </thead>
                        <tbody>
                            <?php {
                                foreach ($educationWorkInfo as $info) {
                                    if ($info->worked_organisation) {
                            ?>
                                        <tr>
                                            <td><?= $info->worked_organisation ?></td>
                                            <td><?= $info->worked_year ?></td>
                                            <td><?= $info->worked_title ?></td>
                                            <td><?= $info->worked_responsibilities ?></td>
                                        </tr>
                            <?php
                                    }
                                }
                            }
                            ?>
                        </tbody>
                    </table>
                </div>
                <hr>
                <div class="col-6 mt-2">
                    <p class="mg-b-10">Name three leading media professionals and explain in a sentence or two, why they have impressed you:<span class="text-danger"></p>
                    <p class="mg-b-10">Has any of your work been published/broadcast/podcast? If yes, specify:<span class="text-danger"></p>
                    <p class="mg-b-10">Tell us in 100 words why you wish to be a journalist and why you think you will be good at it <span class="text-danger"></p>
                    <p class="mg-b-10">Will you need residential accommodation?<span class="text-danger"></p>
                    <p class="mg-b-10">Applied under SC/ST quota?<span class="text-danger"></p>
                    <p class="mg-b-10">Upload community certificate<span class="text-danger"></p>
                    <p class="mg-b-10">PAYMENT MODE<span class="text-danger"></p>
                </div>
                <div class="col-6 mt-2">
                    <P><?= $otherInfo['media_professionals'] ?></P>
                    <P><?= $otherInfo['broadcast_podcast']  ?></P>
                    <P><?= $otherInfo['journalist_reason'] ?></P>
                    <P><?= $accomodation_info['residential_accommodation'] == 1 ? 'Yes' : 'No' ?></P>
                    <P><?= $accomodation_info['application_fee_checked'] == 1 ? 'Yes' : 'No' ?></P>
                    <P><?= $accomodation_info['payment_mode'] == 0 ? 'Yes' : 'No' ?></P>
                </div>

            </div> -->

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

<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script> -->
<script>
    $(document).ready(function() {
        //start of form1 validation
        var applicationForm = $('form[id="applicationForm1"]');
        $('form[id="applicationForm1"]').validate({
            rules: {
                mobile: {
                    required: true,
                    maxlength: 10
                },
                email: 'required',
                country_code: 'required',
                communication_address: 'required',
                dob: 'required',
                gender: 'required',
                first_name: 'required',
                application_fee: 'required',
                course_id: 'required',
            },
            messages: {
                mobile: {
                    required: 'Mobile number is required',
                    maxlength: 'Maximum 10 digits'
                },
                email: 'Enter a valid email',
                country_code: 'Country Code is required',
                communication_address: 'Address is required',
                dob: 'Date of Birth is required',
                gender: 'Gender is required',
                first_name: 'First Name is required',
                application_fee: 'Application Fees is required',
                course_id: 'Course Name is required',
            },
            errorPlacement: function(label, element) {
                label.addClass('mt-2 text-danger');
                if (element.hasClass('form-select') && element.next('.select2-container').length) {
                    label.insertAfter(element.next('.select2-container'));
                } else {
                    // Use append to insert the error message after the select element
                    label.appendTo(element.parent());
                }
            },
            highlight: function(element, errorClass) {
                $(element).parent().addClass('has-danger small')
                $(element).addClass('form-control form-control-sm-danger')
            },
            unhighlight: function(element) {
                $(element).parent().removeClass('has-danger small')
                $(element).parent().removeClass('form-control form-control-sm-danger')
            },
            submitHandler: function(form) {
                form.submit();
            }
        });
        applicationForm.find(':input').on('input', function() {
            applicationForm.validate().element(this);
        });
        //end of form1 validation
    });







    function getCourse(event) {
        var id = event.target.value;

        if (id) {
            var url = "<?php echo base_url(); ?>ApplicationController/getFees/" + id;
            $.ajax({
                type: 'GET',
                url: url,
                contentType: false,
                processData: false,
                success: function(data) {
                    $('#applicationfee').val(data)
                },
                error: function(data) {
                    console.log(data);
                }
            });
        } else {
            $('#applicationfee').val('')

        }
    }
    document.addEventListener('DOMContentLoaded', function() {
        const form = document.getElementById('stepForm');
        const steps = form.querySelectorAll('.step');
        const prevButtons = form.querySelectorAll('.prev');
        const nextButtons = form.querySelectorAll('.next');
        const submitButton = form.querySelector('.submit');
        const reviewName = document.getElementById('reviewName');
        const reviewEmail = document.getElementById('reviewEmail');

        let currentStep = 1;

        function showStep(step) {
            steps.forEach((stepElement) => {
                stepElement.style.display = 'none';
            });

            steps[step - 1].style.display = 'block';
        }

        function updateReview() {
            const name = form.querySelector('[name="name"]').value;
            const email = form.querySelector('[name="email"]').value;

            reviewName.textContent = name;
            reviewEmail.textContent = email;
        }

        function validateStep(step) {
            // Add your validation logic here
            if (step === 1) {
                const name = form.querySelector('[name="name"]').value;
                return name.trim() !== '';
            } else if (step === 2) {
                const email = form.querySelector('[name="email"]').value;
                return email.trim() !== '';
            }
            return true; // Default to true if no specific validation is needed
        }

        nextButtons.forEach((button) => {
            button.addEventListener('click', function() {
                if (validateStep(currentStep)) {
                    currentStep++;
                    showStep(currentStep);
                    if (currentStep === 3) {
                        updateReview();
                    }
                } else {
                    alert('Please fill in all required fields.');
                }
            });
        });

        prevButtons.forEach((button) => {
            button.addEventListener('click', function() {
                currentStep--;
                showStep(currentStep);
            });
        });

        submitButton.addEventListener('click', function() {
            // Add your final submission logic here
            alert('Form submitted successfully!');
        });

        showStep(currentStep);
    });


    // var hiddenDiv = document.getElementById('hiddenDiv');
    // var addressCheckbox = document.getElementById('addressCheckbox');


    // if (addressCheckbox.checked) {
    //     hiddenDiv.style.display = 'none';
    // }


    $(document).ready(function() {


        //START OF EDIT HIDE AND SHOW
        var addressCheck = '<?= $parentInfo['addressCheckbox'] ?>';
        if (addressCheck == 1) {
            $('.hiddenDiv').hide();

        }

        var certificateDiv = '<?= $personalInfo['apply_scholarship'] ?>';

        if (certificateDiv == 1) {
            $('#s_file').show();
        }


        //END OF EDIT HIDE AND SHOW





        $('#addressCheckbox').change(function() {
            $('.hiddenDiv').toggle(!this.checked);
        });

        $('#scholarship').change(function() {

            if (this.value == 0) {
                $('#s_file').hide();
            } else {
                $('#s_file').show();
            }
        });
    });






    function toggleCardVisibility(event) {
        // alert(event.target.value);
        var card = document.getElementById('myCard');
        var card1 = document.querySelector('.card1');
        card1.style.display = event.target.value == '1' ? 'block' : 'none';
    }

    function togglePaymentDiv(event) {
        var paymentDiv = document.getElementById("paymentDiv");
        if (event.target.value == 1) {
            $('#paymentDiv').html("Online payment can be made using Internet Banking, Credit or Debit Cards.");
        } else if (event.target.value == 0) {
            $('#paymentDiv').html("Payment should be made in the form of Demand Draft in favour of 'Media Development Foundation', payable at Chennai with your reference number, full name, and address written on the back of the DD.");
        }
    }
</script>