<?php   
    $query = $this->db->get_where('submission', array('id' => $delivery_id, 'student_id' => $this->session->userdata('login_user_id')));
    $homework_code = $query->row()->homework_code;
    $dformat = $this->crud->getInfo('date_format');
    $running_year = $this->crud->getInfo('running_year');
    $current_homework = $this->db->get_where('activity' , array('activity_id' => $homework_code))->result_array();
    foreach ($current_homework as $row):
?>
    <link href="<?php echo base_url();?>public/uploads/fonts/font-fileuploader.css" rel="stylesheet">
    <link href="<?php echo base_url();?>public/uploads/fonts/script.css" media="all" rel="stylesheet">
    <div class="content-w">
        <div class="conty">
        <?php include 'fancy.php';?>
        <div class="header-spacer"></div>
	        <div class="os-tabs-w menu-shad">
		        <div class="os-tabs-controls">
		            <ul class="navs navs-tabs upper">
			            <li class="navs-item">
			                <a class="navs-links active" href="javascript:void(0);"><i class="os-icon picons-thin-icon-thin-0014_notebook_paper_todo"></i><span><?php echo getEduAppGTLang('homework_details');?></span></a>
			            </li>
		            </ul>
		        </div>
	        </div>
            <div class="content-i">
                <div class="content-box">
	                <div class="back backbutton">		
	                    <a href="<?php echo base_url();?>student/homeworkroom/<?php echo base64_encode($homework_code);?>/"><i class="picons-thin-icon-thin-0131_arrow_back_undo"></i></a>	
	                </div>
	                <div class="row">
	                    <div class="col-sm-8">
		                    <div class="pipeline white lined-primary shadow">
		                        <div class="pipeline-header">
			                        <h5 class="pipeline-name"><?php echo $row['title'];?></h5>
			                        <div class="pipeline-header-numbers">
			                            <div class="pipeline-count">
				                            <i class="os-icon picons-thin-icon-thin-0024_calendar_month_day_planner_events"></i> <?php echo date($dformat,strtotime($row['delivery_date']));?> <br>
				                            <i class="os-icon picons-thin-icon-thin-0025_alarm_clock_ringer_time_morning"></i> <?php echo date('h:i A',strtotime($row['end_time']));?>
			                            </div>
			                        </div>
    		                    </div>
    			                <p><?php echo html_entity_decode($row['description']);?></p>
    			                <?php if($row['file'] != ""):?>
    			                <div class="b-t padded-v-big">
    				                <?php echo getEduAppGTLang('file');?>: <br><a class="text-white btn btn-rounded btn-sm btn-primary" href="<?php echo base_url() . 'student/downloadHomework/' . $row['activity_id']; ?>"><i class="os-icon picons-thin-icon-thin-0042_attachment"></i> <?php echo $row['real_name'];?></a>
    			                </div>
			                <?php endif;?>
			                <?php if($row['homework_type'] != 1):?>
    			                <div class="b-t padded-v-big">
    			                    <?php echo form_open(base_url() . 'student/delivery/update_file/'.$delivery_id.'/'.$homework_code , array('enctype' => 'multipart/form-data'));?>
    				                    <div class="form-group">
    					                    <label><?php echo getEduAppGTLang('upload_files');?>:</label><br>
    					                    <input type="file" name="files">
    				                    </div>
    				                    <input type="hidden" name="class_id" value="<?php echo $row['class_id'];?>">
    				                    <input type="hidden" name="section_id" value="<?php echo $row['section_id'];?>">
    			                        <input type="hidden" name="subject_id" value="<?php echo $row['subject_id'];?>">
    			                        <div class="row">
    			                            <div class="col-sm-12">
                                                <textarea class="form-control full-width" placeholder="<?php echo getEduAppGTLang('send_teacher_comment');?>" name="comment" rows="5"><?php echo $query->row()->student_comment;?></textarea>
                                                <button type="submit" class="btn btn-success pull-right text-white"><?php echo getEduAppGTLang('send');?></button>
    				                        </div>
    				                    </div>
    			                    <?php echo form_close();?>
    			                </div>
			                <?php endif;?>
			                <?php if($row['homework_type'] == 1):?>
			                    <div class="alert alert-info" role="alert"><?php echo getEduAppGTLang('no_required');?></div>
			                    <?php echo form_open(base_url() . 'student/delivery/update_text/'.$delivery_id.'/'.$homework_code);?>
			                        <div class="b-t padded-v-big">
			                            <textarea cols="80" id="ckeditor1" required="" name="reply" rows="10"><?php echo $query->row()->homework_reply;?></textarea>
			                            <input type="hidden" name="class_id" value="<?php echo $row['class_id'];?>"> 
			                            <input type="hidden" name="section_id" value="<?php echo $row['section_id'];?>">
			                            <input type="hidden" name="subject_id" value="<?php echo $row['subject_id'];?>">
			                            <br>
			                            <div class="row">
			                                <div class="col-sm-12">
                                                <textarea class="full-width form-control" placeholder="<?php echo getEduAppGTLang('send_teacher_comment');?>" name="comment" rows="5"><?php echo $query->row()->student_comment;?></textarea>
                                                <button type="submit" class="btn btn-success pull-right text-white" href="javascript:void(0);"><?php echo getEduAppGTLang('send');?></button>
				                            </div>
				                        </div>
			                        </div>
			                    <?php echo form_close();?>
			                    <?php endif;?>
		                    </div>
		                </div>
	                    <div class="col-sm-4">
		                    <div class="pipeline white lined-secondary">
		                        <div class="pipeline-header">
			                        <h5 class="pipeline-name"><?php echo getEduAppGTLang('information');?></h5>
		                        </div>
		                        <div class="table-responsive">
		                            <table class="table table-lightbor table-lightfont">
			                            <tr>
				                            <th><b><?php echo getEduAppGTLang('subject');?></b>:</th>
				                            <td><?php echo $this->crud->get_type_name_by_id('subject',$row['subject_id']);?></td>
                        			    </tr>
			                            <tr>
				                            <th><b><?php echo getEduAppGTLang('class');?></b>:</th>
				                            <td><?php echo $this->crud->get_type_name_by_id('class',$row['class_id']);?></td>
			                            </tr>
			                            <tr>
				                            <th><b><?php echo getEduAppGTLang('section');?></b>:</th>
				                            <td><?php echo $this->crud->get_type_name_by_id('section',$row['section_id']);?></td>
			                            </tr>
			                            <tr>
				                            <th><b><?php echo getEduAppGTLang('limit_date');?></b>:</th>
				                            <td><?php echo getEduAppGTLang('allowed_deliveries');?> <?php echo date($dformat,strtotime($row['delivery_date']));?> <?php echo date('h:i A',strtotime($row['end_time']));?>.</td>
			                            </tr>
			                            <tr>
				                            <th><b><?php echo getEduAppGTLang('status');?></b>:</th>
				                            <td>
				 	                            <?php if($query->num_rows() <= 0):?>
				  		                        <a class="btn nc btn-rounded btn-sm btn-danger text-white"><?php echo getEduAppGTLang('no_delivered');?></a>
					                            <?php endif;?>
					                            <?php if($query->num_rows() > 0):?>
				  		                        <a class="btn nc btn-rounded btn-sm btn-success text-white"><?php echo getEduAppGTLang('submitted_for_review');?></a>
					                            <?php endif;?>
				                            </td>
			                            </tr>
			                            <tr>
				                            <th><b><?php echo getEduAppGTLang('mark');?></b>:</th>
				                            <td>
				                            <?php if($query->num_rows() <= 0):?>
				                                <a class="btn btn-rounded btn-sm btn-danger text-white"><?php echo getEduAppGTLang('unrated');?></a>
				                            <?php endif;?>
				                            <?php if($query->num_rows() > 0):?>
				                                <a class="btn btn-rounded btn-sm btn-primary text-white"><?php $mark =$this->db->get_where('submission', array('homework_code' => $homework_code, 'student_id' => $this->session->userdata('login_user_id')))->row()->mark; if($mark > 0) echo $mark; else echo getEduAppGTLang('waiting_mark');?></a>
				                            <?php endif;?>
				                            </td>
			                            </tr>
			                            <tr>
				                            <th><b><?php echo getEduAppGTLang('teacher_comment');?></b>:</th>
				                            <td>
				                                <?php if($query->num_rows() > 0):?>
				                                <?php echo $this->db->get_where('submission', array('homework_code' => $homework_code, 'student_id' => $this->session->userdata('login_user_id')))->row()->teacher_comment;?>
				                                <?php endif;?>
				                            </td>
			                            </tr>
		                            </table>
		                        </div>
		                    </div>
	                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="<?php echo base_url();?>public/uploads/jquery.fileuploader.min.js"></script>
    <script src="<?php echo base_url();?>public/style/js/student_panel.js"></script>
<?php endforeach;?>