<!DOCTYPE html>
<html dir="ltr" lang="en">

<?php
include 'partial/head.php';
include 'partial/status.php';
?>

<body>
<!-- ============================================================== -->
<!-- Preloader - style you can find in spinners.css -->
<!-- ============================================================== -->
<div class="preloader">
    <div class="lds-ripple">
        <div class="lds-pos"></div>
        <div class="lds-pos"></div>
    </div>
</div>
<!-- ============================================================== -->
<!-- Main wrapper - style you can find in pages.scss -->
<!-- ============================================================== -->
<div id="main-wrapper" data-theme="light" data-layout="vertical" data-navbarbg="skin6" data-sidebartype="full"
     data-sidebar-position="fixed" data-header-position="fixed" data-boxed-layout="full">
    <!-- ============================================================== -->
    <!-- Topbar header - style you can find in pages.scss -->
    <!-- ============================================================== -->
    <?php
    include 'partial/topbar.php';
    ?>
    <!-- ============================================================== -->
    <!-- End Topbar header -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- Left Sidebar - style you can find in sidebar.scss  -->
    <!-- ============================================================== -->
    <?php
    include 'partial/sidebar.php';
    ?>
    <!-- ============================================================== -->
    <!-- End Left Sidebar - style you can find in sidebar.scss  -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- Page wrapper  -->
    <!-- ============================================================== -->
    <div class="page-wrapper">
        <!-- ============================================================== -->
        <!-- Bread crumb and right sidebar toggle -->
        <!-- ============================================================== -->
        <div class="page-breadcrumb">
            <div class="row">
                <div class="col-7 align-self-center">
                    <h2 class="page-title text-truncate text-dark font-weight-medium mb-1">Class Diary</h2>
                    <div class="d-flex align-items-center">
                        <nav aria-label="breadcrumb">
                            <ol class="breadcrumb m-0 p-0">
                                <li class="breadcrumb-item"><a href="<?= base_url() ?>" class="text-muted">Home</a></li>
                                <li class="breadcrumb-item text-muted active" aria-current="page">Class Diary</li>
                            </ol>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
        <!-- ============================================================== -->
        <!-- End Bread crumb and right sidebar toggle -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Container fluid  -->
        <!-- ============================================================== -->

        <div class="container-fluid">
            <!-- ============================================================== -->
            <!-- Start Page Content -->
            <!-- ============================================================== -->
            <div class="row">
                <div class="col-sm-12 col-md-12 col-lg-12">
                    <div class="card">
                        <div class="card-body">
                            <form id="studentForm" method="post" action="<?= base_url('studentreport/getstudent') ?>">
                                <div class="form-body">
                                    <div class="row">
                                        <div class="col-md-4">
                                            <div class="form-group mb-3">
                                                <label class="form-label">Student</label>
                                                <select class="form-select mr-sm-2" id="student" name="student" required>
                                                    <option value="" selected disabled>Choose</option>
                                                    <?php foreach($students as $item): ?>
                                                        <option value="<?= $item['id'] ?>"><?= $item['first_name'] ?> <?= $item['last_name'] ?></option>
                                                    <?php endforeach; ?>
                                                </select>
                                        </div>
                                    </div>

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

                    <div class="card">
                        <div class="card-body">
                            <div class="row">
                                <div class="col-12 mt-4">
                                    <h4 class="mb-0">Card styles</h4>
                                    <p class="text-muted mt-0 font-12">Cards include various options for customizing their
                                        backgrounds, borders, and color.<code>.card-primary info, warning, danger</code></p>
                                </div>
                                <?php foreach ($classdiaries as $item): ?>
                                    <div class="col-md-12 mb-3">
                                        <div class="card border-dark">
                                            <div class="card-header bg-dark text-white">
                                                <h3 class="mb-0"><span class="badge rounded-pill text-bg-info" style="font-size:100%"><?= esc($item['date']) ?></span></h3>
                                                </h4>
                                                <div class="card-header">
                                                    <h4 class="mb-0 text-white"><?= esc($item['class_name']) ?> (<?= date('h:i A', strtotime($item['started_time'])) ?> - <?= date('h:i A', strtotime($item['ended_time'])) ?>) <span class="badge rounded-pill text-bg-success" style="font-size:100%"><?= esc($item['class_status_name']) ?></span>
                                                    </h4>
                                                </div>
                                                <div class="card-body">
                                                                <div class="table-responsive">
                                                                    <table id="student_table" class="table table-bordered" width="100%">
                                                                        <thead>
                                                                        <th scope="col">Student Name</th>
                                                                        <th scope="col">Attendance</th>
                                                                        <th scope="col">Duration</th>
                                                                        <th scope="col" style="">Comment</th>
                                                                        </thead>
                                                                        <tbody id="student_table_body">
                                                                        <?php foreach($item['students'] as $student): ?>

                                                                            <tr>
                                                                                <td><?= $student['name'] ?></td>
                                                                                <?php
                                                                                    if($student['attendance_status'] = 1){
                                                                                ?>
                                                                                <td><span class="badge rounded-pill text-bg-info" style="font-size:100%">Present</span></td>
                                                                                <?php
                                                                                    }else{
                                                                                ?>
                                                                                        <td><span class="badge rounded-pill text-bg-danger" style="font-size:100%">Absent</span></td>
                                                                                <?php
                                                                                    }
                                                                                ?>
                                                                                <td><?= $student['duration'] ?></td>
                                                                                <td><?= $student['comment'] ?></td>
                                                                                 </tr>

                                                                        <?php endforeach; ?>
                                                                        </tbody>
                                                                    </table>
                                                                </div>
                                                    Lesson : <?= esc($item['lesson_name']) ?> <br>
                                                    Comment : <?= esc($item['comment']) ?>

<!--                                                    <h3 class="card-title text-white">Comment</h3>-->
<!--                                                    <p class="card-text">--><?php //= esc($item['comment']) ?><!--</p>-->
<!--                                                    <a href="javascript:void(0)" class="btn btn-primary">Go somewhere</a>-->
                                                </div>
                                            </div>

                                        </div>
                                    </div>

                                <?php endforeach; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- ============================================================== -->
    <!-- End Page wrapper  -->
    <!-- ============================================================== -->
</div>
<!-- ============================================================== -->
<!-- End Wrapper -->
<!-- ============================================================== -->
<!-- End Wrapper -->
<!-- ============================================================== -->
<!-- All Jquery -->
<!-- ============================================================== -->

<!--  update modal -->
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog"
     aria-labelledby="myLargeModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myLargeModalLabel">Update Class</h4>
                <button type="button" class="btn-close" data-bs-dismiss="modal"
                        aria-hidden="true"></button>
            </div>
            <div class="modal-body">
                <form method="post" action="<?= base_url('class/update') ?>">
                    <div class="form-body">
                        <div class="row">
                            <?php
                            include 'partial/alerts.php';
                            ?>
                            <div class="col-md-4">
                                <!-- hidden id to update -->
                                <input type="hidden" class="form-control" placeholder="" id="updid" name="updid">
                                <div class="form-group mb-4">
                                    <label class="form-label">Grade</label>
                                    <select class="form-select mr-sm-2" id="updgrade_id" name="updgrade_id" required>
                                        <option value="" disabled selected>Choose</option>
<!--                                        --><?php //foreach($grades as $item): ?>
<!--                                            <option value="--><?php //= $item['id'] ?><!--">--><?php //= $item['name'] ?><!--</option>-->
<!--                                        --><?php //endforeach; ?>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group mb-4">
                                    <label class="form-label">Class Type</label>
                                    <select class="form-select mr-sm-2" id="updclass_type_id" name="updclass_type_id" required>
                                        <option value="" disabled selected>Choose</option>
<!--                                        --><?php //foreach($classtypes as $item): ?>
<!--                                            <option value="--><?php //= $item['id'] ?><!--">--><?php //= $item['name'] ?><!--</option>-->
<!--                                        --><?php //endforeach; ?>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group mb-4">
                                    <label class="form-label">Payment Type</label>
                                    <select class="form-select mr-sm-2" id="updpayment_type_id" name="updpayment_type_id" required>
                                        <option value="" disabled selected>Choose</option>
<!--                                        --><?php //foreach($paymenttypes as $item): ?>
<!--                                            <option value="--><?php //= $item['id'] ?><!--">--><?php //= $item['name'] ?><!--</option>-->
<!--                                        --><?php //endforeach; ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group mb-3">
                                    <label class="form-label">Class Code</label>
                                    <input type="text" class="form-control" placeholder="" id="updcode" name="updcode" required>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group mb-3">
                                    <label class="form-label">Class Name</label>
                                    <input type="text" class="form-control" placeholder="" id="updname" name="updname" required>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group mb-3">
                                    <label class="form-label">Description</label>
                                    <input type="text" class="form-control" placeholder="" id="upddescription" name="upddescription">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group mb-3">
                                    <label class="form-label">Class Day</label>
                                    <select class="form-select mr-sm-2" id="updclass_day" name="updclass_day" required>
                                        <option value="Monday">Monday</option>
                                        <option value="Tuesday">Tuesday</option>
                                        <option value="Wednesday">Wednesday</option>
                                        <option value="Thursday">Thursday</option>
                                        <option value="Friday">Friday</option>
                                        <option value="Saturday">Saturday</option>
                                        <option value="Sunday">Sunday</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group mb-3">
                                    <label class="form-label">Start Time</label>
                                    <input type="time" class="form-control" placeholder="" id="updstart_time" name="updstart_time" required>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group mb-3">
                                    <label class="form-label">End Time</label>
                                    <input type="time" class="form-control" placeholder="" id="updend_time" name="updend_time" required>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group mb-3">
                                    <label class="form-label">Started Date</label>
                                    <input type="date" class="form-control" placeholder="" id="updstarted_date" name="updstarted_date" required>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group mb-3">
                                    <label class="form-label">Fee</label>
                                    <input type="number" class="form-control" placeholder="" id="updfee" name="updfee" required>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group mb-3">
                                    <label class="form-label">Students</label>
                                    <select class="form-select mr-sm-2" id="updstudent_id" name="updstudent_id[]" required multiple>
<!--                                        --><?php //foreach($students as $item): ?>
<!--                                            <option value="--><?php //= $item['id'] ?><!--">--><?php //= $item['first_name'] ?><!-- --><?php //= $item['last_name'] ?><!--</option>-->
<!--                                        --><?php //endforeach; ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group mb-4">
                                    <label class="form-label">Status</label>
                                    <select class="form-select mr-sm-2" id="updstatus" name="updstatus" required>
                                        <option value="1">Active</option>
                                        <option value="2">Inactive</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-8">
                                <button type="submit" class="btn btn-primary btn-rounded" style="width:130px;"><i class="fas fa-check"></i>
                                    Update</button>
                                <button data-bs-dismiss="modal" aria-hidden="true" type="button" class="btn btn-danger btn-rounded" style="width:130px;"><i class="fas fa-window-close"></i>
                                    Cancel</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!--  delete modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog"
     aria-labelledby="deleteModal" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="deleteModal">Delete Class</h4>
                <button type="button" class="btn-close" data-bs-dismiss="modal"
                        aria-hidden="true"></button>
            </div>
            <div class="modal-body">
                <form method="post" action="<?= base_url('class/delete') ?>">
                    <div class="form-body">
                        <div class="row">
                            <!-- hidden id to update -->
                            <input type="hidden" class="form-control" placeholder="" id="delid" name="delid">
                            <label class="form-label">Are you sure to delete this item?</label>
                        </div>
                        <div class="row">
                            <div class="col-md-8">
                                <button type="submit" class="btn btn-danger btn-rounded" style="width:130px;"><i class="fas fa-trash"></i>
                                    Delete</button>
                                <button data-bs-dismiss="modal" aria-hidden="true" type="button" class="btn btn-info btn-rounded" style="width:130px;"><i class="fas fa-window-close"></i>
                                    Cancel</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


</body>

<?php
include 'partial/footer.php';
?>


<script>
    var base_url = "<?= base_url() ?>";
</script>

<script src="<?= base_url('dist/js/custom_v1.js') ?>"></script>
<script src="<?= base_url('dist/js/classDiaryReport.js') ?>"></script>

</html>
