<?php session_start(); 

        include '../config/database.php';
        include_once "../resources/offering.php";

        // initialize objects
        $offering = new Offering();
        $id = $_SESSION['uid'];

        $offering->user_id = $id;

        $points = $offering->Sum_completionPoints();
        if($points ==""){
        echo "<h4 class='text-center mb-5 text-green-5'>";
        echo _("HM0135");
        echo "</h4>";
        }else{
        echo "<h4 class='text-center mb-5 text-green-5'>";
        echo _("HM0130");
        echo round($points). " "; 
        echo _("HM0131");
        echo "</h4>";
        
        $i=1;
        ?>
        <div class="table-responsive mt-20">
            <table class="table_points w-1/1">
                <colgroup>
                    <col style="width:10%">
                    <col style="width:50%">
                    <col style="width:20%">
                    <col style="width:15%">
                </colgroup>
                <thead class="bg-color-primary">
                    <tr>
                        <th class="text-center"><?php echo _("HM0132"); ?>.</th>
                        <th class="text-center"><?php echo _("HM0114"); ?></th>
                        <th class="text-center"><?php echo _("HM0133"); ?></th>
                        <th class="text-center"><?php echo _("HM0134"); ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    $stmt = $offering->points_course();
                    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                        echo "<tr class='bg-white shadow-1 rounded-8 border-light'>";
                            echo "<td class='text-center'>".$i."</td>";
                            echo "<td >".$row['course_name']."</td>";
                            echo "<td class='text-center'>".date(' d-m-Y', strtotime($row['attended_date']))."</td>";
                            echo "<td class='text-center'>".$row['completion_points']."</td>";
                        echo "</tr>";
                        $i++;
                    }
                    ?>
                </tbody>
            </table>
        </div>    
        <?php } ?>