<div class="content-wrapper" style="min-height: 946px;">
    <section class="content-header">
        <h1>
            <i class="fa fa-map-o"></i> CLASS LABELS<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_classlabel.php";
	$get_classlabel_data = get_classlabel();
	
	//echo "<pre>"; print_r($get_classlabel_data); echo "</pre>";
?> 

	<?php
	foreach($classsectionlist as $key=>$value){
		
		foreach($classlist as $class_key=>$class_value){
			if($class_value['id'] == $value['class_id']){
				$class_name = $class_value['class'];
			}
		}
		$head_address = "";
		$teacher_address = "";
		$student_address= "";
		$class_section_key = $value['class_id'] . "_" . $value['section_id'];
		if(array_key_exists($class_section_key, $get_classlabel_data)){
		$head_address = $get_classlabel_data[$class_section_key]['head_address'];
		$teacher_address = $get_classlabel_data[$class_section_key]['teacher_address'];
		$student_address = $get_classlabel_data[$class_section_key]['student_address'];	
		}
		
		$div_id = $value['class_id'] . "_" . $value['section_id'];	
	?>
			<!-- separator --><div class="gallery">
	<div class="pphoto" id='<?php echo $div_id; ?>'>
Head of School Label:<br />
<input name="head_address" id='head_address'  value="<?php echo $head_address;?>" /><br />
Teacher Label:<br />
<input name="teacher_address" id='teacher_address' value="<?php echo $teacher_address;?>" /><br />
Student Label:<br />
<input name="student_address" id='student_address'  value="<?php echo $student_address;?>" /><br />
<input type='button' value='UPDATE' onclick="updateClassInfo('<?php echo $div_id; ?>')">
	</div>
	<h4 class="" style="font-weight:;min-height:20px;max-height:20px;"><?php echo $class_name . " " . $value['section']; ?></h4>
	</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){
//alert(classData);	
var head_address = $('#' + classData + ' #head_address').val();
var teacher_address = $('#' + classData + ' #teacher_address').val();
var student_address = $('#' + classData + ' #student_address').val();
//alert(head_address);
//alert(teacher_address);
//alert(student_address);
	var update_url = base_url + 'application/scripts/update_classlabel.php';
	  $.post(update_url,{
		  class_data:classData,
		  head_address:head_address,
		  teacher_address:teacher_address,
		 student_address:student_address
		  },function(result){
		$("#result_response").html(result);
	  });

}

</script>
<style>
.gallery{
width:200px; 
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>
