<?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/schedule.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/schedule.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>
	
    <?php
    $newSchedules = $newNextYearSchedule = array();
    foreach ($schedules as $s) {
        $newSchedules[$s->month]["year"] = $s->year;
        $newSchedules[$s->month]["month"] = $s->month;
        $newSchedules[$s->month]["package_id"][] = $s->package_id;
        $newSchedules[$s->month]["date"][] = $s->date;
        $newSchedules[$s->month]["description"][] = $s->description;
        $newSchedules[$s->month]["time"][] = $s->time;
    }

    if (isset($nextYearSchedule) && count($nextYearSchedule) && ((int)date("m") > 9)) {
        foreach ($nextYearSchedule as $s) {
            $newNextYearSchedule[$s->month]["month"] = $s->month;
            $newNextYearSchedule[$s->month]["package_id"][] = $s->package_id;
            $newNextYearSchedule[$s->month]["date"][] = $s->date;
            $newNextYearSchedule[$s->month]["description"][] = $s->description;
            $newNextYearSchedule[$s->month]["time"][] = $s->time;
        }
    }

    if (isset($nextYearSchedule) && count($nextYearSchedule) && ((int)date("m") > 9))
        foreach ($nextYearSchedule as $month) {

            $newyearMonths[$month->month] = $month->month;
        }
    ?>
    <div class="container p-t-40 p-b-40">
<!--<div class="sec-title pb-5 col-md-9  text-start wow fadeInUp" data-wow-duration='300ms'>
      <h3 class="sec-title__title"><?php echo $pageName; ?></h3> 
	 </div> -->
        <div class="col-md-3  ">
            <div class="row form-group">

                <div class="col-md-12 schedule-locations-box-style1">
                    <div class="select-box clearfix">
                        <form action="" method="post" id="_form">
                            <select class="form-control p-10 rounded" name="month" onChange="filterMonth();" id="month">
                                <option value="0">All Months</option>

                                <?php foreach ($months as $month) { ?>
                                    <option value="<?php echo $month->month; ?>_<?php echo $month->year; ?>" <?php if ($this->input->post("month") == $month->month . '_' . $month->year) {
                                        echo " selected ";
                                    } ?>><?php echo date('F', mktime(0, 0, 0, $month->month, 10)) . ' ' . $month->year; ?></option>
                                <?php } ?>
                                <?php if (!empty($newyearMonths) && count($newyearMonths)) {
                                    foreach ($newyearMonths as $month) { ?>
                                        <option value="<?php echo $month; ?>_<?php echo (date("Y") + 1); ?>" <?php if ($this->input->post("month") == $month . '_' . (date("Y") + 1)) {
                                        echo " selected ";
                                    } ?>><?php echo date('F', mktime(0, 0, 0, $month, 10)) . ' ' . (date("Y") + 1); ?></option>
                                <?php }
                                } ?>
                                <!-- end -->
                            </select>
                        </form>
                    </div>
                </div>
            </div>
        </div>
		<div class="clearfix"></div>

        <?php foreach ($newSchedules as $newSchedule) { ?>
            <div data-example-id="contextual-table" class="bs-example">
                <h4 class="schedule-hd mb-0"><i class="fa fa-calendar" aria-hidden="true"></i> <?php echo date('F', mktime(0, 0, 0, $newSchedule["month"], 10)) . ' ' . $newSchedule["year"]; ?></h4>
                <div class="table-responsive">
                    <table class="table currentYear">
                        <thead>
                            <tr>
                                <th class="no-padding" width="30%">
                                    <div role="alert" class="alert alert-danger"> Date</div>
                                </th>
                                <th class="no-padding" width="45%">
                                    <div role="alert" class="alert alert-danger"> Days</div>
                                </th>
                                <th class="no-padding" width="15%">
                                    <div role="alert" class="alert alert-danger"> Time</div>
                                </th>
                                <th class="no-padding" width="10%">
                                    <div role="alert" class="alert alert-danger"> Register</div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            for ($a = 0; $a < count($newSchedule["date"]); $a++) { ?>
                                <tr class="active">
                                    <th scope="row"><?php echo $newSchedule["date"][$a]; ?></th>
                                    <td><?php echo $newSchedule["description"][$a]; ?></td>
                                    <td><?php echo $newSchedule["time"][$a]; ?></td>
                                    <td><a href="<?php echo base_url() . "registration/" . $newSchedule["package_id"][$a]; ?>" class="button small red button-3d rounded no-margin"><span>Register</span></a></td>
                                </tr>

                            <?php } ?>

                        </tbody>
                    </table>
                </div>
            </div>
        <?php } ?>

        <?php
        if (count($newNextYearSchedule) && date("m") >= 9 && $this->input->post("month") == '')
            foreach ($newNextYearSchedule as $newSchedule) { ?>
            <div data-example-id="contextual-table" class="bs-example">
                <h4><i class="fa fa-calendar" aria-hidden="true"></i> <?php echo date('F', mktime(0, 0, 0, $newSchedule["month"], 10)) . ' ' . (date("Y") + 1); ?></h4>
                <div class="table-responsive">
                    <table class="table">
                        <thead>
                            <tr>
                                <th class="no-padding" width="30%">
                                    <div role="alert" class="alert alert-danger"> Date</div>
                                </th>
                                <th class="no-padding" width="45%">
                                    <div role="alert" class="alert alert-danger"> Days</div>
                                </th>
                                <th class="no-padding" width="15%">
                                    <div role="alert" class="alert alert-danger"> Time</div>
                                </th>
                                <th class="no-padding" width="10%">
                                    <div role="alert" class="alert alert-danger"> Register</div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            for ($a = 0; $a < count($newSchedule["date"]); $a++) { ?>
                                <tr class="active">
                                    <th scope="row"><?php echo $newSchedule["date"][$a]; ?></th>
                                    <td><?php echo $newSchedule["description"][$a]; ?></td>
                                    <td><?php echo $newSchedule["time"][$a]; ?></td>
                                    <td><a href="<?php echo base_url() . "registration/" . $newSchedule["package_id"][$a]; ?>" class="button small red button-3d rounded no-margin"><span>Register</span></a></td>
                                </tr>

                            <?php } ?>

                        </tbody>
                    </table>
                </div>
            </div>

        <?php } ?>

        <!--- end changes -->

    </div>

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

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

    <script>
        function filterMonth() {
            $("#_form").submit();
        }
    </script>
</body>

</html>