<style>
    table.dataTable tfoot th {
        font-weight: 600 !important;
    }
       .form-group .bootstrap-select > .dropdown-toggle {
    padding: 9px 9px !important;
    font-size: 12px !important;
    border: 1px solid #c8c8c8 !important;
    background: #fff !important;
}
.course_grade_setup_table th,.course_grade_setup_table td {
    border: 0;
    font-size: 16px;
    padding: 10px;
}

.course_grade_setup_table {
    border: 0;
}

.course_grade_setup_table th {
    font-weight: 600;
    font-size: 17px;
    color: #888787;
        border-bottom: 1px solid #ddd;
}

.course_grade_setup_table th {
    text-align: center;
}

.course_grade_setup_table th:nth-child(1),.course_grade_setup_table td:nth-child(1) {
    text-align: left;
    width: 15%;
}
</style>
<div class="wraper responsive-width">

    <main class="long-tbl-main" id="main">
        <!-- admin template section -->
        <div class="admin_tempblock">
            <div class="admin_tempsec">
                <div class="admin_sec">

                    <div class="subsec_sec" style="display:block">
                        <div class="subject_lsec dashboard_graph report_sec_graph">
                       
                            <div class="report_sec_cover">
                                <div class="report_sec_left">
                                
                                </div>                               
                               
                                <div class="subject_lhead">Course Grade Setup</div>
                                
                                <form action="<?= base_url(); ?>admin/course-grade-setup" method="POST" id='courseGradeSetupForm'>                       
                                
                                <?php if(!empty($this->session->flashdata('success'))) { ?>
                                <div class="alert alert-success">
                                    <a href="#" class="close" data-dismiss="alert">&times;</a>
                                    <strong>Success!</strong> <?php echo $this->session->flashdata('success'); ?>
                                </div>
                                <?php } unset($_SESSION['success']); ?>

                                <div class="row" >
                                	<div class="col-md-12">                                		                               		
	                                	<table style='width:100%' border='1' class="course_grade_setup_table">
	                                		<tr>
	                                			<th width='25%'>Course Name</th>
	                                			<th width='25%'>
                                                    <input type="checkbox" id='the_main_grade' onclick='check_uncheck("the_main_grade")'> Grade
                                                </th>	                                			
	                                			<th width='25%'>
                                                    <input type="checkbox" id='the_main_division' onclick='check_uncheck("the_main_division")'> Percentage
                                                </th>
	                                			<th width='25%'>
                                                    <input type="checkbox" id='the_main_all' onclick='check_uncheck("the_main_all")'> All
                                                </th>	                                			
	                                		</tr>
	                                		
	                                		<?php
	                                		if(isset($theResult) && !empty($theResult))
	                                		{
	                                			foreach($theResult as $k=>$res)
	                                			{
	                                				
	                                				if($res['setup']=='Grade')
	                                					$theRowSelect = 'Grade';
                                                    else if($res['setup']=='Percentage')
                                                        $theRowSelect = 'Percentage';
                                                    else if($res['setup']=='All')
                                                        $theRowSelect = 'All';
                                                    else
                                                        $theRowSelect = '';
	                                		?>
                                            <tr>
                                                <!--onclick='abcd("g", <?php echo $res["id"];?>)'-->
                                                <td><?php echo $res['course_name'];?></td>
                                                <td>
                                                    <input type="radio" name="<?php echo $res['id'];?>" id="<?php echo 'g_'.$res['id'];?>" class='the_grades' value='Grade' <?php if($theRowSelect == 'Grade'){?> checked <?php } ?> >
                                                </td>
                                                <td>
                                                    <input type="radio" name="<?php echo $res['id'];?>" id="<?php echo 'p_'.$res['id'];?>" class='the_division' value='Percentage' <?php if($theRowSelect == 'Percentage'){?> checked <?php } ?> >
                                                </td>
                                                <td>
                                                    <input type="radio" name="<?php echo $res['id'];?>" id="<?php echo 'a_'.$res['id'];?>" class='the_all' value='All' <?php if($theRowSelect == 'All'){?> checked <?php } ?> >
                                                </td>
                                            </tr>	                                		
	                                		<?php
	                                			}
	                                		}
	                                		?>

                                            <tr>
                                                <td colspan="4">
                                                    <button type='submit' name='update_data' style="font-size: 14px;padding: 6px 10px; " class="subject_addbtn download_idcards" >
                                                    Update
                                                    </button>
                                                    &nbsp; &nbsp;
                                                    <a href="<?php echo base_url() ?>admin/course-grade-setup">
                                                    <input type="button" style="font-size: 14px;padding: 6px 10px; " class="subject_addbtn download_idcards" value="Reset">
                                                    </a>
                                                </td>
                                            </tr>
	                                	</table>                                		
                                	</div>
                                </div>                           
                                </form>
                                <!-- tab added -->


                                <!-- new divs added -->
                                <!--<div class="tab-content">
                                    <div class="applicnts-list-wrap ">
                                        <div class=" ">
                                            
                                        </div>
                                    </div>
                                </div>-->
                            </div>
                        </div>

                    </div>
                </div>

            </div>
            <!-- admin template section end -->
    </main>
    <!--End right-top side-->

</div>

<script type="text/javascript">

function check_uncheck(theFlag)
{
    if(theFlag=='the_main_grade')
    {
        if($('#the_main_grade').prop('checked'))
        {
            $('.the_grades').each(function(){
                $(this).prop('checked', true);                
            });

            $("#the_main_division").attr('disabled', true);
            $("#the_main_all").attr('disabled', true);       
        }
        else
        {
            $('.the_grades').each(function(){
                $(this).prop('checked', false);                
            });

            $("#the_main_division").attr('disabled', false);
            $("#the_main_all").attr('disabled', false);
        }       
    }
    else if(theFlag=='the_main_division')
    {
        if($('#the_main_division').prop('checked'))
        {
            $('.the_division').each(function(){
                $(this).prop('checked', true);                
            });

            $("#the_main_grade").attr('disabled', true);
            $("#the_main_all").attr('disabled', true);       
        }
        else
        {
            $('.the_division').each(function(){
                $(this).prop('checked', false);                
            });

            $("#the_main_grade").attr('disabled', false);
            $("#the_main_all").attr('disabled', false);
        }       
    }
    else if(theFlag=='the_main_all')
    {
        if($('#the_main_all').prop('checked'))
        {
            $('.the_all').each(function(){
                $(this).prop('checked', true);                
            });

            $("#the_main_grade").attr('disabled', true);
            $("#the_main_division").attr('disabled', true);       
        }
        else
        {
            $('.the_all').each(function(){
                $(this).prop('checked', false);                
            });

            $("#the_main_grade").attr('disabled', false);
            $("#the_main_division").attr('disabled', false);
        }       
    }
}


$('input[type=radio]').click(function(){
    if(this.previous) {
        this.checked = false;
    }
    this.previous = this.checked;
});

/*function abcd(flag, idVal)
{
    //alert(flag+' = '+idVal);

    //alert( $('#'+flag+'_'+idVal).attr('previousValue') );

    //$('#'+flag+'_'+idVal).toggle();
    if($('#'+flag+'_'+idVal).prop('checked'))
        $('#'+flag+'_'+idVal).prop('checked', false);
    else
        $('#'+flag+'_'+idVal).prop('checked', true);
}*/

</script>


</body>

</html>