<?php
session_start();
// ============
include("../../asset/theme/css/myfunc.php");
include("../../php_crud/my_class.php");
$obj=new my_class();
// ============

extract($_GET);

$medium_id;
$today = date("Y-m-d");

?>

<style type="text/css">
	.input-append, .input-prepend {
		margin-bottom: 0px !important;
	}
	.table td {
		padding: 3px !important;
	}
	
</style>
<script src="module/detention/js/view_and_edit_detention_topics.js" type="text/javascript"></script>

<?php
$det_in = $obj->Details_By_Cond("_int_institute_setup_vw","section_id='$section_id'");


$tch_id = $obj->Details_By_Cond("_r_class_routine","_section_id='$section_id' AND _teacher_type='CT' AND _teacher_id!='0' GROUP BY _teacher_type");
$teacher_id =  $tch_id['_teacher_id'];

$tch_det = $obj->Details_By_Cond("_pf_emp_personal_info","_id='$teacher_id'");
?>

<div class="row-fluid">
<legend>
	Daily Class Wise detention Sheet for (<?php echo 'Class: '.$det_in['class'].', Department: '.$det_in['department'].', Student Type: '.$det_in['student_type'].', Section: '.$det_in['section']; ?>).
</legend>



<!-- ==================================== -->
<form class="form-vertical" id="attendance_sheet">

<div class="row-fluid">
	<input type="hidden" id="module_id" name="module_id" value="<?php echo $module_id;?>"/>  
    <input type="hidden" name="medium_id" id="medium_id" value="<?php echo $medium_id; ?>">
    <input type="hidden" name="medium_name" id="medium_name" value="<?php echo $medium_name; ?>">
	<input type="hidden" name="section_id" id="section_id" value="<?php echo $section_id; ?>">
    <input type="hidden" name="shipt_name" id="shipt_name" value="<?php echo $shipt_name; ?>">	
     <input type="hidden" name="shift_id" id="shift_id" value="<?php  echo $shift_id; ?>">
   
    			
	
	<table class="table table-striped table-bordered table-hover">
		<thead>
			<tr>
                <th>Sl</th>
                <th>Student ID</th>
                <th>Name</th>
                <th>Roll</th>
                <th style="text-align: center;">Send</th>
                <th style="text-align: center;">Detention Topics</th>
                <th>Contact No</th>
             </tr>   
             <tr>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
                <th style="text-align: center;"><label></label> <input type="checkbox" id="check_all" ><span class="lbl"> Check All</span> </th>
                <th style="text-align: center;">  <textarea style="width:370px;height:20px; padding: 4px;" onkeyup="deft_val(this.value)" class="input-small" placeholder="Detention For" > </textarea>
                <th></th>
             </tr>   
		</thead>
		<tbody>
			<?php
			$i=0;
			foreach($obj->View_Student_List("sc._id='$section_id' AND pf_std._status='A' ORDER BY _section_roll ASC") as $value){
			extract($value);
			$i++;	
			 $student_id = $value['_id'] ;
			 $where_con = '_section_id='.$section_id.' AND _std_id='.$student_id.' AND DATE(_entry_date)="'.$today.'"';
			 
			 $for_topics = $obj->Details_By_Cond("_detention_daily_by_class",$where_con);
			 
			$checked = '';
			$topics = '';
			$checked_value = '0';
			if(!empty($for_topics)){
				
				$checked_value = $for_topics['_detention_message_status'];
				if($checked_value==1){
						$checked = 'checked';
					}
				$topics = $for_topics['_detention_topics'];
				$common_topics = $for_topics['_detention_common_topics'];
				
				}
				
				
				
			?>	
			<tr>
				<td class="td_pad">
					<input type="hidden" name="std_id_<?php echo $i; ?>" value="<?php echo $value['_id']; ?>">
					<?php echo $i; ?>
				</td>
				<td class="td_pad"><?php echo $value['_uniq_id']; ?></td>
				<td class="td_pad"><?php echo $value['_full_name']; if(!empty($value['_nick_name'])){echo ' ('.$value['_nick_name'].')'; } ?></td>
				<td class="td_pad"><?php echo $value['_section_roll']; ?></td>
				<td class="td_pad" style="text-align: center;"><label></label><input type="checkbox" id="home_status_<?php echo $i; ?>" name="home_status_<?php echo $i; ?>" class="checked_home_topics" value="<?php echo $checked_value; ?>"   <?php echo $checked ; ?> /><span class="lbl"></span></td>
				
				<td class="td_pad" style="text-align: center;"><!--<input  type="text"  style="width:370px;" value="<?php echo $topics; ?>" placeholder="<?php echo $topics; ?>" />-->
                <textarea style="width:370px;height:20px; padding: 4px;" name="topics_<?php echo $i; ?>" id="topics_<?php echo $i; ?>" class="topics_specific input-small"  placeholder="Detention For"   ><?php echo $topics; ?> </textarea>
                    <div class="topics-bottom" style="width:100%;">  
                    	<div class="span6 topics-count">
                        	   Characther:<span class="char-length" style="margin-right:20px"> </span> 
                               Message:<span class="message-number"> </span>
                         </div>
                    </div>
                </td>
				<td class="td_pad"><?php echo $value['_contact_mobile']; ?></td>
			</tr>	
			<?php
			}
			$total_row = $obj->View_Student_List_rows("sc._id='$section_id' AND pf_std._status='A'");
			?>
			<tr>
				<input type="hidden" name="total_row" value="<?php echo $total_row; ?>">
			</tr>
		</tbody>	

	</table>
</div>

<!-- ========================== -->

<div class="row-fluid">	
	<div class="span5"><b>Class Teacher name:</b> <?php echo $tch_det['_full_name']; if(!empty($tch_det['_nick_name'])){ echo ' ('.$tch_det['_nick_name'].')';} ?></div>

	<div class="span3"><b>Mobile No:</b> <?php echo $tch_det['_contact_mobile_no']; ?></div>
</div>

<!-- ========================= -->
<?php 
$table_name=" _detention_daily_status_class";
$where_cond='_section_id = '.$section_id.' && DATE(_entry_date) = "'.$today.'" ';
$com=$obj->Details_By_Cond($table_name,$where_cond);

?>

<input name="detention_status_id" type="hidden" id="detention_status_id" value="<?php echo $com['_id']; ?>" />
<div class="row-fluid">	

	<div class="span3">Detention Time
		<div class="controls">
			<div class="input-append bootstrap-timepicker">
				<input name="home_work_time" type="text" class="input-small timepicker1" value="<?php echo $com['_detention_time']; ?>" />
				<span class="add-on">
					<i class="icon-time"></i>
				</span>
			</div>
		</div>
	</div>

	<div class="span3">Comments
		<div class="controls">
			<input name="remarks" class="input-large" type="text" value="<?php echo $com['_detention_comments']; ?>" placeholder="Comments">
		</div>
	</div>
    <div class="span3">Common Topics :
		<div class="controls">
			<textarea name="_detention_common_topics" id="_detention_common_topics" class="input-large" rows="3" placeholder=""><?php echo $common_topics; ?></textarea>
		</div>
	</div>
    
</div>


<!-- =========================== -->

<div class="row-fluid">									
	<div class="span12">			
		<div class="control-group">
			<label class="control-label" for="form-field-1">&nbsp;</label>

			<div class="controls">
				<?php if($total_row){ ?>
				<button class="btn btn-small btn-success" type="button" id="btn_edit_save">
					<i class="icon-ok bigger-100"></i>Save
				</button>
				<?php
				}
				else{
				?>
				<button class="btn btn-small btn-success" type="button" id="btn_edit_save">
					<i class="icon-ok bigger-100"></i>Save
				</button>
				<?php } ?>

				<!--&nbsp; &nbsp; &nbsp;
				<button class="btn btn-small btn-danger" type="reset" id="btn_reset">
					
					Back
				</button>-->
			</div>
		</div>
	</div>
	
</div>


</form>


