<?php
$sid=$this->uri->segment('3');
?>
<style>
    .w-50{
        float:left;
        padding:0px 10px;
    }
    .w-100{
        
        padding:0px 10px;
    }
</style>
<div class="container-fluid mt-3 mb-3 bg-white">
    <div class="row">
        <div class="col-sm-12 pt-3 pb-3">
            
            
            <form method="post" class="form-outer">
                <div class="w-100">
                        
                <div class="w-100 main-heading">Add Student Review</div><hr>
                <?php
                if($success){
                ?>
                <div class="alert alert-success"><?php echo $success; ?></div>
                <?php
                }
                
                if($error){
                ?>
                <div class="alert alert-danger"><?php echo $error; ?></div>
                <?php
                }
                ?>
                <div class="form-group w-50">
                    <label>Review Type</label>
                    <input type="hidden" name="sid" value="<?php echo $sid; ?>">
                    <select class="form-control" name="review_type" required>
                        <option value="">--- Select Review Type ---</option>
                        <option value="Good">Good</option>
                        <option value="Not Good">Not Good</option>
                        
                    </select>
                </div>
                
                <div class="form-group w-50">
                    <label>Date</label>
                    <input type="date" name="review_date" value="<?php echo date('Y-m-d'); ?>" class="form-control" required>
                    
                </div>
                
                <div class="form-group w-100">
                    <label>Student Review</label>
                    <textarea name="student_review" class="form-control" placeholder="Remark"></textarea>
                </div>
                
                <div class="form-group w-100">
                    <button class="btn btn-success" name="add_student_review" type="submit">Submit</button>
                </div>
                            </div>
            </form>
            
            <div class="table-responsive mt-3 mb-3">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th class="sl_no">Sl.No.</th>
                            <th>Remark Type</th>
                            <th>Date</th>
                            <th>Remark</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
                        $i=0;
                        $table="student_reviews";
                        $get_student_reviews=$this->WelcomeModel->get_student_data($sid,$table);
                        if($get_student_reviews){
                            foreach($get_student_reviews as $review){
                                $i=$i + 1;
                                $remark_bg="";
                                if($review['review_type'] == "Good"){
                                    $remark_bg="bg-success";    
                                }else if($review['review_type'] == "Not Good"){
                                    $remark_bg="bg-danger";
                                }
                        ?>
                        
                        
                        <tr class="<?php echo $remark_bg; ?> text-white">
                            <td><?php echo $i; ?></td>
                            <td><?php echo $review['review_type']; ?></td>
                            <td><?php echo date("d-M-Y",strtotime($review['review_date'])); ?></td>
                            <td><?php echo $review['student_review']; ?></td>
                        </tr>
                        <?php
                            }
                        }
                        ?>
                    </tbody>
                </table>
            </div>
            
            

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