<?php 
    $homeworkQuery = $this->db->get_where('activity', array('activity_id' => base64_decode($homework_code)))->row(); 
    $time1 = $homeworkQuery->delivery_date; 
    $time2 = $homeworkQuery->end_time; 
    $homework_details = $this->db->get_where('submission', array('homework_code' => base64_decode($homework_code)))->result_array();
?>
    <div class="content-w">
        <div class="conty">
        <?php include 'fancy.php';?>
        <div class="header-spacer"></div>
            <div class="content-i">
                <div class="content-box">
                    <div class="back mb-3">
                        <a class="fs-16" href="<?php echo base_url();?>teacher/subject_dashboard/<?php echo base64_encode($homeworkQuery->class_id.'-'.$homeworkQuery->section_id.'-'.$homeworkQuery->subject_id);?>/"><i class="picons-thin-icon-thin-0131_arrow_back_undo"></i> <span><?php echo getEduAppGTLang('return_to_dashboard');?></span></a>
                    </div>
	                <div class="row">	
	                    <?php if(count($homework_details) > 0):?>
	                    <div class="col-sm-12">
		                    <div class="pipeline white lined-primary">
		                        <div class="pipeline-header">
			                        <h5 class="pipeline-name"><?php echo getEduAppGTLang('deliveries');?></h5>
		                        </div>
    		                    <?php echo form_open(base_url() . 'teacher/homework/review/' . $homework_code, array('enctype' => 'multipart/form-data')); ?>
			                        <div class="table-responsive">
                                        <table class="table table-lightborder">
                                            <thead>
                                                <tr>
                                                    <th><?php echo getEduAppGTLang('student');?></th>
                                                    <th><?php echo getEduAppGTLang('student_comment');?></th>
                        					        <th><?php echo getEduAppGTLang('delivery_status');?></th>
                                                    <th><?php echo getEduAppGTLang('file_response');?></th>
                        					        <th><?php echo getEduAppGTLang('teacher_comment');?></th>
                                                    <th class="w50"><?php echo getEduAppGTLang('mark');?></th>
                                                    <th class="w50"><?php echo getEduAppGTLang('actions');?></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                            <?php 
                                                $time = $time1. " ".$time2;
                  	                            foreach($homework_details as $row):
                                            ?>
                                                <tr>
                                                    <td class="min-w-170">
                                                        <img alt="" src="<?php echo $this->crud->get_image_url('student', $row['student_id']); ?>" width="25px" class="tbl-user"> 
                                                        <?php echo $this->crud->get_name('student' , $row['student_id']); ?>
                                                    </td>
                                                    <td><?php echo $row['student_comment'];?></td>
					                                <td>
					  	                                <?php if($row['date'] > $time):?>
						  	                                <a class="btn nc btn-rounded btn-sm btn-danger text-white"><?php echo getEduAppGTLang('delayed_delivery');?></a>
						                                <?php endif;?>
						                                <?php if($row['date'] <= $time):?>
						  	                                <a class="btn nc btn-rounded btn-sm btn-success text-white"><?php echo getEduAppGTLang('on_time');?></a>
						                                <?php endif;?>
					                                </td> 
                                                    <td>
                      	                                <?php $type = $homeworkQuery->homework_type;?>
                      	                                <?php if($type == 2):?>
                        	                                <a class="btn btn-rounded btn-sm btn-primary text-white"  onclick="showAjaxModal('<?php echo base_url();?>modal/popup/modal_files/<?php echo $row['id'];?>');" href="javascript:void(0);"><i class="os-icon picons-thin-icon-thin-0042_attachment"></i> <?php echo getEduAppGTLang('see_files');?></a>
                                                        <?php endif;?>
                                                        <?php if($type == 1 && $row['file_name'] == ""):?>
                        	                                <a class="btn btn-rounded btn-sm btn-secondary text-white" href="<?php echo base_url();?>teacher/single_homework/<?php echo $row['id'];?>"><i class="os-icon picons-thin-icon-thin-0043_eye_visibility_show_visible"></i> <?php echo getEduAppGTLang('view_response');?></a>
                                                        <?php endif;?>
                                                    </td>
                                                    <td>
                                                        <textarea class="form-control" name="comment[]" rows="1"><?php echo $row['teacher_comment'];?></textarea>
                                                        <input type="hidden" name="answer_id[]" value="<?php echo $row['id'];?>">
                                                    </td>
					                                <td width="7%">
                                                        <input class="form-control" required name="mark[]" type="text" value="<?php echo $row['mark'];?>">
                                                    </td>
                                                    <td width="7%">
                                                        <a class="btn btn-danger btn-sm" href="<?php echo base_url();?>teacher/delete_delivery/<?php echo $row['id'];?>/<?php echo $homework_code;?>" onclick="return confirm('<?php echo getEduAppGTLang('confirm_delete');?>');"><i class="picons-thin-icon-thin-0057_bin_trash_recycle_delete_garbage_full text-white"></i></a>
                                                    </td> 
                                                </tr>
                	                            <?php endforeach;?>
                                            </tbody>
                                        </table>
                                        <div class="form-buttons-w text-right">
                                            <button class="btn btn-rounded btn-success" type="submit"> <?php echo getEduAppGTLang('apply');?></button>
                                        </div>
                                    <?php echo form_close();?>
                                </div>
		                    </div>
		                </div>  
		                <?php else:?>
		                <div class="col-sm-12 text-center bg-white">
		                    <br><br><br><br>
		                    <svg class="align-sub mb-3 mt-5" xmlns="http://www.w3.org/2000/svg" width="85" height="85" viewBox="0 0 36 36"><path fill="#000000" d="M9 17.41V27h9.59l-2-2H11v-5.59z" class="clr-i-outline clr-i-outline-path-1"></path><path fill="currentColor" d="M34.87 32.29L32 29.38V32H4v-4.15h2v-1.6H4V19.6h2V18H4v-6.4h2V10H4V4.41l15.94 15.85v-2.82L3.71 1.29A1 1 0 0 0 2 2v31a1 1 0 0 0 1 1h31.16a1 1 0 0 0 .71-1.71" class="clr-i-outline clr-i-outline-path-2"></path><path fill="currentColor" d="M24 30h4a2 2 0 0 0 2-2V8.7l-2.3-4.23a2 2 0 0 0-1.76-1a2 2 0 0 0-1.76 1.08L22 8.72V28a2 2 0 0 0 2 2m0-20.8l1.94-3.77L28 9.21V24h-4Zm0 16.43h4v2.44h-4Z" class="clr-i-outline clr-i-outline-path-3"></path><path fill="none" d="M0 0h36v36H0z"></path></svg>
		                    <h4 class="mb-5"><?php echo getEduAppGTLang('no_submissions_yet');?></h4>
		                    <br><br><br><br>
		                </div>
		                <?php endif;?>
	                </div>
                </div>
            </div>
        </div>
    </div>