<div class="content-wrapper" style="min-height: 946px;">
    <section class="content-header">
        <h1>
            <i class="fa fa-map-o"></i> ASSESSMENT SETTINGS<small><?php echo $this->lang->line('student_fee1'); ?></small> </h1>

<div style='color:red;'>			


</div>
			
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <!-- left column -->
            <div class="col-md-12">
                <!-- general form elements -->
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <div >
<?php

	include "application/scripts/get_examlabel.php";
	$get_examlabel_data = get_examlabel();
	
//	echo "<pre>"; print_r($get_examlabel_data); echo "</pre>";
?> 

	<?php
	foreach($classsectionlist as $key=>$value){
	$ca_array = array("ca1","ca2","ca3","ca4","ca5","ca6","ca7","ca8","ca9","get_marks");		
		foreach($classlist as $class_key=>$class_value){
			if($class_value['id'] == $value['class_id']){
				$class_name = $class_value['class'];
			}
		}

		$class_section_key = $value['class_id'] . "_" . $value['section_id'];
		
		$div_id = $value['class_id'] . "_" . $value['section_id'];	
	?>
	
<!--id	int(11) Auto Increment	 
section_id	int(11)	 
class_id	int(11)	 
ca_type	varchar(10)	 
max_mark	varchar(10)	 
label	varchar(100)	 
description	text	 
active	int(1)	 
last_modified	timestamp [CURRENT_TIMESTAMP]	 
created-->
			<!-- separator --><div class="gallery">
		<h4 class="" style="font-weight:;min-height:20px;max-height:20px;"><?php echo $class_name . " " . $value['section']; ?></h4>		
	<div class="pphoto" id='<?php echo $div_id; ?>'>
<table border='1'>
<tr>
	<th>
	Ass.
	</th>
	<th>
	Label
	</th>
	<th>
	Max. Mark
	</th>
	<th>
	Description
	</th>
	<th>
	Active
	</th>
</tr>
<?php

	$asn = 0;
	foreach($ca_array as $keyx => $valuex){
	$asn += 1;	
	if($asn==10){
		$asn_s = "EXAM";	
	}else{
		$asn_s = "CA" . $asn;
	}	
	
	$label_val = "label_" . $valuex;
	$max_val = "max_" . $valuex;
	$description_val = "description_" . $valuex;
	$active_val = "active_" . $valuex;
	
	$$label_val = strtoupper($valuex);
	$$max_val = "";
	$$description_val = "";
	$$active_val = "";
	if($asn==10){
		$$label_val = "EXAM";	
		$$active_val = "1";
	}
	
	if(isset($get_examlabel_data[$class_section_key][$valuex])){
		$$label_val = $get_examlabel_data[$class_section_key][$valuex]['label'];
		$$max_val = $get_examlabel_data[$class_section_key][$valuex]['max_mark'];
		$$description_val = $get_examlabel_data[$class_section_key][$valuex]['description'];
		$$active_val = $get_examlabel_data[$class_section_key][$valuex]['active'];

	}
	
	$label = $$label_val;
	$max = $$max_val;
	$description = $$description_val;
	$active = $$active_val;
	
	if($active == '1'){
		$checked = "checked";
	}else{
		$checked = "";
	}
	
/*	
	if(isset()){
		
	}
*/	
		echo "
		</tr>
			<td>
			" . $asn_s . "
			</td>
			<td>
			<input type='text' id=\"label_". $valuex. "\"  name=\"label_". $valuex. "\" value='$label'>
			</td>
			<td>
			<input type='number' id=\"max_". $valuex. "\"  name=\"max_". $valuex. "\" size='4' style='width:100px;' value='$max'>
			</td>
			<td>
			<input type='text' id=\"description_". $valuex. "\"  name=\"description_". $valuex. "\"  value='$description'>
			</td>
			<td align='center'>
			<input type='checkbox' id=\"active_". $valuex. "\"  name=\"description_". $valuex. "\" value='1' echo $checked >
			</td>
		</tr>
		";
		
	//	var head_address = $('#' + classData + ' #head_address').val();

/*	
				echo "label_". $valuex. ":label_". $valuex. ",<br />
max_". $valuex. ":max_". $valuex. ",<br />
description_". $valuex. ":description_". $valuex. ",<br />
active_". $valuex. ":active_". $valuex. ",<br />
		";
		
		/*
	
/*
			echo "var label_". $valuex. " = $('#' + classData + ' #label_". $valuex. "').val();<br/>
var max_". $valuex. " = $('#' + classData + ' #max_". $valuex. "').val();<br/>
var description_". $valuex. " = $('#' + classData + ' #description_". $valuex. "').val();<br/>
var active_". $valuex. " = $('#' + classData + ' #active_". $valuex. "').val();<br/>
		";
		
		*/
	}

?>

</table>
<input type='button' value='UPDATE' onclick="updateClassInfo('<?php echo $div_id; ?>')">
	</div>

	</div>
	<!-- End Separator -->
	<?php
		
		
	}
	
	?>
<div style='clear:both'></div>						

<div style="display:none;">						
 

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

	
                </div>
                <!-- right column -->
            </div>   <!-- /.row -->
		</div>
    </section><!-- /.content -->
<div id='result_response'>

</div>
<?php

?>

<style>
#dialog {
position:fixed;
top:0px;
left:0px;
width:100%;
height:100%;
background: url('<?php echo base_url()?>/backend/images/fading.png');
display:none;
z-index:100000;
}

#dialog_box {
width:50%;
height:50%;
background:white;
overflow: auto;
position:absolute;
border-radius:10px 10px;
border:4px green dotted;
z-index:100002;
}

#dialog_head{
opacity:1;
}
</style>

<div id="dialog">

<div id="dialog_box">
<h1 style="margin:0px;text-align:center;" id="dialog_head"></h1>
<div id="dialog_body">

</div>
<center><button class='btn btn-primary btn-sm' onclick="close_dialog()">CLOSE</button></center>
</div>

</div>


<script>
function dialog(head,body){
//$("#dialog").slideDown();
$("#dialog").fadeIn();
$("#dialog_head").html(head);
$("#dialog_body").html(body);
//$("#dialog_box").css("width", "200px");
//alert(document.body.getBoundingClientRect().width);
window_width = document.body.getBoundingClientRect().width;
box_width = Math.round(7/10 * window_width);
box_position_x = Math.round(window_width-box_width)/2;


window_height = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;

//window_height = document.body.getBoundingClientRect().height;
box_height = Math.round(9/10 * window_height);
box_position_y = Math.round(window_height-box_height)/2;


if(window_width < 400){box_width = window_width; box_position_x = 0;}
if(window_height < 300){box_height = window_height; box_position_y = 0;}

//$("#dialog").css("display", "");
$("#dialog_box").css("position", "fixed");

$("#dialog_box").css("width", box_width + "px");
$("#dialog_box").css("left", box_position_x + "px");

$("#dialog_box").css("height", box_height + "px");
$("#dialog_box").css("top", box_position_y + "px");


}

function close_dialog(){
$("#dialog").fadeOut();
}
</script>
<script type="text/javascript">
    function getSectionByClass(class_id, section_id) {
        if (class_id != "" && section_id != "") {
            $('#section_id').html("");
            var base_url = '<?php echo base_url() ?>';
            var div_data = '<option value=""><?php echo $this->lang->line('select'); ?></option>';
            $.ajax({
                type: "GET",
                url: base_url + "sections/getByClass",
                data: {'class_id': class_id},
                dataType: "json",
                success: function (data) {
                    $.each(data, function (i, obj)
                    {
                        var sel = "";
                        if (section_id == obj.section_id) {
                            sel = "selected";
                        }
                        div_data += "<option value=" + obj.section_id + " " + sel + ">" + obj.section + "</option>";
                    });
                    $('#section_id').append(div_data);
                }
            });
        }
    }

    $(document).ready(function () {
        $(document).on('change', '#class_id', function (e) {
            $('#section_id').html("");
            var class_id = $(this).val();
            var base_url = '<?php echo base_url() ?>';
            var div_data = '<option value=""><?php echo $this->lang->line('select'); ?></option>';
            $.ajax({
                type: "GET",
                url: base_url + "sections/getByClass",
                data: {'class_id': class_id},
                dataType: "json",
                success: function (data) {
                    $.each(data, function (i, obj)
                    {
                        div_data += "<option value=" + obj.section_id + ">" + obj.section + "</option>";
                    });
                    $('#section_id').append(div_data);
                }
            });
        });
        var class_id = $('#class_id').val();
        var section_id = '<?php echo set_value('section_id') ?>';
        getSectionByClass(class_id, section_id);
        $(document).on('change', '#feecategory_id', function (e) {
            $('#feetype_id').html("");
            var feecategory_id = $(this).val();
            var base_url = '<?php echo base_url() ?>';
            var div_data = '<option value=""><?php echo $this->lang->line('select'); ?></option>';
            $.ajax({
                type: "GET",
                url: base_url + "feemaster/getByFeecategory",
                data: {'feecategory_id': feecategory_id},
                dataType: "json",
                success: function (data) {
                    $.each(data, function (i, obj)
                    {
                        div_data += "<option value=" + obj.id + ">" + obj.type + "</option>";
                    });
                    $('#feetype_id').append(div_data);
                }
            });
        });
    });
    $(document).on('change', '#section_id', function (e) {
        $("form#schedule-form").submit();
    });
</script>
<script>
function updateClassInfo(classData){
	
var label_ca1 = $('#' + classData + ' #label_ca1').val();
var label_ca1 = $('#' + classData + ' #label_ca1').val();
var max_ca1 = $('#' + classData + ' #max_ca1').val();
var description_ca1 = $('#' + classData + ' #description_ca1').val();
var active_ca1 = $('#' + classData + ' #active_ca1:checked').val() || 0;
var label_ca2 = $('#' + classData + ' #label_ca2').val();
var max_ca2 = $('#' + classData + ' #max_ca2').val();
var description_ca2 = $('#' + classData + ' #description_ca2').val();
var active_ca2 = $('#' + classData + ' #active_ca2:checked').val() || 0;
var label_ca3 = $('#' + classData + ' #label_ca3').val();
var max_ca3 = $('#' + classData + ' #max_ca3').val();
var description_ca3 = $('#' + classData + ' #description_ca3').val();
var active_ca3 = $('#' + classData + ' #active_ca3:checked').val() || 0;
var label_ca4 = $('#' + classData + ' #label_ca4').val();
var max_ca4 = $('#' + classData + ' #max_ca4').val();
var description_ca4 = $('#' + classData + ' #description_ca4').val();
var active_ca4 = $('#' + classData + ' #active_ca4:checked').val() || 0;
var label_ca5 = $('#' + classData + ' #label_ca5').val();
var max_ca5 = $('#' + classData + ' #max_ca5').val();
var description_ca5 = $('#' + classData + ' #description_ca5').val();
var active_ca5 = $('#' + classData + ' #active_ca5:checked').val() || 0;
var label_ca6 = $('#' + classData + ' #label_ca6').val();
var max_ca6 = $('#' + classData + ' #max_ca6').val();
var description_ca6 = $('#' + classData + ' #description_ca6').val();
var active_ca6 = $('#' + classData + ' #active_ca6:checked').val() || 0;
var label_ca7 = $('#' + classData + ' #label_ca7').val();
var max_ca7 = $('#' + classData + ' #max_ca7').val();
var description_ca7 = $('#' + classData + ' #description_ca7').val();
var active_ca7 = $('#' + classData + ' #active_ca7:checked').val() || 0;
var label_ca8 = $('#' + classData + ' #label_ca8').val();
var max_ca8 = $('#' + classData + ' #max_ca8').val();
var description_ca8 = $('#' + classData + ' #description_ca8').val();
var active_ca8 = $('#' + classData + ' #active_ca8:checked').val() || 0;
var label_ca9 = $('#' + classData + ' #label_ca9').val();
var max_ca9 = $('#' + classData + ' #max_ca9').val();
var description_ca9 = $('#' + classData + ' #description_ca9').val();
var active_ca9 = $('#' + classData + ' #active_ca9:checked').val() || 0;
var label_get_marks = $('#' + classData + ' #label_get_marks').val();
var max_get_marks = $('#' + classData + ' #max_get_marks').val();
var description_get_marks = $('#' + classData + ' #description_get_marks').val();
var active_get_marks = $('#' + classData + ' #active_get_marks:checked').val() || 0;

//alert(description_get_marks);
//alert(head_address);
//alert(teacher_address);
//alert(student_address);
	var update_url = base_url + 'application/scripts/update_examlabel.php';
	  $.post(update_url,{
			class_data:classData,
			label_ca1:label_ca1,
			max_ca1:max_ca1,
			description_ca1:description_ca1,
			active_ca1:active_ca1,
			label_ca2:label_ca2,
			max_ca2:max_ca2,
			description_ca2:description_ca2,
			active_ca2:active_ca2,
			label_ca3:label_ca3,
			max_ca3:max_ca3,
			description_ca3:description_ca3,
			active_ca3:active_ca3,
			label_ca4:label_ca4,
			max_ca4:max_ca4,
			description_ca4:description_ca4,
			active_ca4:active_ca4,
			label_ca5:label_ca5,
			max_ca5:max_ca5,
			description_ca5:description_ca5,
			active_ca5:active_ca5,
			label_ca6:label_ca6,
			max_ca6:max_ca6,
			description_ca6:description_ca6,
			active_ca6:active_ca6,
			label_ca7:label_ca7,
			max_ca7:max_ca7,
			description_ca7:description_ca7,
			active_ca7:active_ca7,
			label_ca8:label_ca8,
			max_ca8:max_ca8,
			description_ca8:description_ca8,
			active_ca8:active_ca8,
			label_ca9:label_ca9,
			max_ca9:max_ca9,
			description_ca9:description_ca9,
			active_ca9:active_ca9,
			label_get_marks:label_get_marks,
			max_get_marks:max_get_marks,
			description_get_marks:description_get_marks,
			active_get_marks:active_get_marks
		  },function(result){
		$("#result_response").html(result);
	  });

}

</script>
<style>
.gallery{
width:500px; 
float:left; 
padding: 5px;
margin: 5px;
border:3px #eeeeee solid;
text-align:center;
box-shadow: 2px 2px 2px grey;
background: ;
}

.gallery .pname{
width:100%; 
position:relative;
text-align:left;
padding-top:5px;
height:150px;
overflow:auto;
}

.gallery .pphoto{
/*height:200px;*/
/*max-height:200px;*/
overflow:hidden;
text-align:left;
background:white;
}

.gallery img {
min-width:100%;
max-width:100%;
padding:0px;
margin:0px;
}
p {display:inline;}

</style>
