<?php $this->load->view("includes/head"); ?>

<body class="wide">

    <!-- Header -->
    <?php $this->load->view("includes/header"); ?>
    <!-- END: Header -->

    <!--Start breadcrumb Style1-->
    <!--<section class="breadcrumb-style1">
        <div class="breadcrumb-style1-bg" style="background-image: url(<?php echo base_url() . "public/"; ?>assets/images/breadcrumb/certification.jpg);">
            <div class="breadcrumb-style1-bg__overlay"></div>
        </div>
        <div class="container">
            <div class="inner-content">
                <div class="title">
                    <h2><?php echo $pageName; ?></h2>
                </div>
                <div class="breadcrumb-menu">
                    <ul class="clearfix">
                        <li><a href="<?php echo base_url(); ?>">Home</a></li>
                        <li><span class="icon-next"></span></li>
                        <li class="active"><?php echo $pageName; ?></li>
                    </ul>
                </div>
            </div>
        </div>
    </section> -->
	
	
	
	<!--<div class="page-hd">
	 
		<img src="<?php echo base_url() . "public/"; ?>assets/images/breadcrumb/certification.jpg" alt>
		 
	</div> -->
	
	<div class="page-heading">
	<div class="container ">
	     <div class="row">
		 <div class="col-md-6">
		 <h3 class="sec-title__title text-white"><?php echo $pageName; ?></h3> 
		 </div>
		 <div class="col-md-6">
		   <div class="breadcrumb-menu">
                            <ul class="clearfix">
                                <li><a href="<?php echo base_url(); ?>">Home</a></li>
                                <li><span class="icon-next"></span></li>
                                <li class="active"><?php echo $pageName; ?></li>
                            </ul>
           </div>
		 </div>
		 </div>
	</div>
	</div>
	
	

    <div class="container p-t-40 p-b-40">
	
	<!--<div class="sec-title pb-5  text-center wow fadeInUp" data-wow-duration='300ms'>
      <h3 class="sec-title__title"><?php echo $pageName; ?></h3> 
	 </div> -->

        <div class="  row justify-content-center">

            <?php if ($changeView) { ?>
                <div class="col-md-8" style="border-right: 0px solid #ccc;">

                    <div class="main-contact-form__inner">
                        <?php
                        if (!empty($dataRows)) {
                            foreach ($dataRows as $record) {
                        ?>
                                <table class="table">
                                    <thead>
                                        <tr>
                                            <th class="no-padding">
                                                <div role="alert" class="alert alert-danger"> <strong class="text-light">License Id :</strong></div>
                                            </th>
                                            <th class="no-padding">
                                                <div role="alert" class="alert alert-danger"> <strong class="text-light"><?php echo $record->certification_id; ?></strong></div>
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>Firstname :</td>
                                            <td><?php echo $record->firstname; ?></td>
                                        </tr>
                                        <tr>
                                            <td>Lastname :</td>
                                            <td><?php echo $record->lastname; ?></td>
                                        </tr>
                                        <tr>
                                            <td>Date :</td>
                                            <td><?php echo date("jS M Y", strtotime($record->submitted_date)); ?></td>
                                        </tr>
                                        <tr>
                                            <td>Status :</td>
                                            <td><?php echo $record->cStatus; ?></td>
                                        </tr>
                                    </tbody>
                                </table>
                        <?php
                            }
                        }
                        ?>
                        <div class="button-box text-center">

                            <a class="btn-one back-link  " href="certification">
                                <span class="txt">
                                    Back
                                </span>
                            </a>

                        </div>
                    </div>

                </div>

            <?php } else { ?>
                <div class="col-md-8" style="border-right: 0px solid #ccc;">
                    <form id="_form" action="certification" role="form" method="post">

                        <div class="main-contact-form__inner">

                            <?php $this->load->view('includes/alert-ci'); ?>

                            <?php $this->load->view('includes/alert'); ?>

                            <center>
                                Please enter your first and last name as it appears on your Ontario drivers licence and location where you completed your course. Please allow up to 2 weeks from your last In-car lesson to check the status of your certification.
                            </center>
                            <div class="row form-group"></div>
                            <div class="contact-form row">
                                <div class="row form-group">
                                    <div class="col-md-3"><label for="firstname">First Name *</label></div>
                                    <div class="col-md-9"><input autocomplete="off" type="text" name="firstname" class="form-control p-10 rounded" placeholder="Enter your First Name" id="firstname" value="<?php echo set_value('firstname'); ?>"></div>
                                </div>
                                <div class="row form-group">
                                    <div class="col-md-3"><label for="lastname">Last Name *</label></div>
                                    <div class="col-md-9"><input autocomplete="off" type="text" name="lastname" class="form-control p-10 rounded" placeholder="Enter your Last Name" id="lastname" value="<?php echo set_value('lastname'); ?>"></div>
                                </div>
                                <div class="row form-group">
                                    <div class="col-md-3"><label for="location">Location *</label></div>
                                    <div class="col-md-9">
                                        <div class="select-box">
                                            <select class="form-control p-10 rounded" name="location" id="location">
                                                <?php foreach ($provinces as $province) { ?>
                                                    <option value="<?php echo $province->id; ?>" <?php if (set_value('location') == $province->id) {
                                                                                                        echo 'selected';
                                                                                                    } ?>><?php echo $province->province; ?></option>
                                                <?php } ?>
                                            </select>
                                        </div>
                                    </div>
                                </div>

                                <div class="button-box text-center">

                                    <button class="btn-one  " id="_submit" type="submit" data-loading-text="Please wait...">
                                        <span class="txt">
                                            Check Now
                                        </span>
                                    </button>

                                </div>

                            </div>
                        </div>

                    </form>
                </div>
            <?php } ?>



        </div>

    </div>

    <!-- Footer -->
    <?php $this->load->view("includes/footer"); ?>
    <!-- End: Footer -->

    <?php $this->load->view("includes/scripts"); ?>
    
    <script>
        $(document).ready(function() {
            // Form Validation
            const $form = $('#_form');

            $form.validate({
                ignore: [], // <== very important for hidden select fields (nice-select hides original select)
                rules: {
                    firstname: {
                        required: true,
                        minlength: 2
                    },
                    lastname: {
                        required: true,
                        minlength: 2
                    },
                    location: {
                        required: true
                    }
                },
                messages: {
                    firstname: "Please enter your first name",
                    lastname: "Please enter your last name",
                    location: "Please select a location"
                },
                errorElement: 'div',
                errorPlacement: function(error, element) {
                    error.addClass('invalid-feedback');
                    if (element.is("select")) {
                        error.insertAfter(element.next('.nice-select'));
                    } else {
                        error.insertAfter(element);
                    }
                },
                highlight: function(element) {
                    $(element).addClass('is-invalid');
                },
                unhighlight: function(element) {
                    $(element).removeClass('is-invalid');
                }
            });

            // Fix: trigger validation on nice-select option click
            $(document).on('click', '.nice-select .option', function() {
                const $select = $(this).closest('.nice-select').prev('select');

                // Wait for nice-select to update the original <select> value
                setTimeout(function() {
                    $select.valid(); // re-validate this field
                }, 10);
            });
        });
    </script>

</body>

</html>