<body id="page-top">

    <!-- Sidebar -->
    <?php $this->load->view('restricted/layout/sidebar_admin'); ?>
    <!-- Sidebar -->

    <div id="content-wrapper" class="d-flex flex-column">
        <div id="content">

            <!-- NavBar -->
            <?php $this->load->view('restricted/layout/navbar'); ?>
            <!-- Navbar -->

            <!-- Container Fluid-->
            <div class="container-fluid" id="container-wrapper">
                <div class="d-sm-flex align-items-center justify-content-between mb-4">
                    <h1 class="h3 mb-0 text-purple"><?php echo $title; ?></h1>
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="./">Home</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo $title; ?></li>
                    </ol>
                </div>


                <div class="row mb-3">
                    <!-- Pending Requests Card Example -->
                    <div class="col-sm-8 col-18" style="margin: 0 auto;">
                        <div class="card mb-4">
                            <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
                                <h6 class="m-0 font-weight-bold text-primary">Progresso das revisões</h6>
                            </div>
                            <div class="card-body">

                            <div class="table-responsive">
                                <table class="table align-items-center table-flush table-hover" id="dataTableHover">
                                    <thead class="thead-light">
                                        <tr>
                                            <th>Livro</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php foreach ($books as $book) : ?>
                                            <?php $chapters_book = $this->core_model->get_all('chapters', array('book_id' => $book->id)); ?>
                                        <tr>
                                            <td>
                                                <div class="mb-3">
                                                    <div class="small text-gray-600"><?php echo $book->title; ?></div>
                                                    <div class="progress" style="height: 12px;">
                                                        <?php $chapters_approved = count($this->core_model->get_all('chapters', array('book_id' => $book->id, 'status' => 'approved'))); ?>
                                                        <?php if ($chapters_approved != 0 or $chapters_approved != NULL) : ?>
                                                            <?php $chapters_approved = intval($chapters_approved / count($chapters_book) * 100);?>
                                                        <?php endif; ?>
                                                        <div class="progress-bar bg-info" role="progressbar" style="width: <?php echo $chapters_approved; ?>%" aria-valuemin="0" aria-valuemax=""><?php echo $chapters_approved; ?>%</div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <?php endforeach; ?>

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

                                <!-- <?php foreach ($books as $book) : ?>
                                    <?php $chapters_book = $this->core_model->get_all('chapters', array('book_id' => $book->id)); ?>
                                    <div class="mb-3">
                                        <div class="small text-gray-600"><?php echo $book->title; ?></div>
                                        <div class="progress" style="height: 12px;">
                                            <?php $chapters_approved = count($this->core_model->get_all('chapters', array('book_id' => $book->id, 'status' => 'approved'))); ?>
                                            <?php if ($chapters_approved != 0 or $chapters_approved != NULL) : ?>
                                                <?php $chapters_approved = intval($chapters_approved / count($chapters_book) * 100); ?>
                                            <?php endif; ?>
                                            <div class="progress-bar bg-info" role="progressbar" style="width: <?php echo $chapters_approved; ?>%" aria-valuemin="0" aria-valuemax=""></div>
                                        </div>
                                    </div>
                                <?php endforeach; ?> -->
                            </div>
                        </div>
                    </div>

                </div>
                <!--/Row-->

                <!-- Modal Logout -->
                <?php $this->load->view('restricted/layout/modal_logout'); ?>
                <!-- /Modal -->

            </div>
            <!--- /Container Fluid-->
        </div><!-- /Content -->