<?php
function insertData($class, $db)
{
if(empty($class))
return;

$sections = $_POST['sections'][$class];
if( count($sections) > 0 ) {

foreach( $sections as $section){

$newExam = array(
"section" => $section,
"class" => $class,
"teacher_id"=>$_GET['teacher'],
"school_id"=>$_SESSION["admin"]["school_id"],
"session"=>$_SESSION["admin"]["session"]
);
$db->delete("Homework_role","where section = '$section' and class='$class'");
$db->insertAry("Homework_role",$newExam);
}
} else {

$newExam = array(
"section" => '',
"class" => $class,
"teacher_id"=>$_GET['teacher'],
"school_id"=>$_SESSION["admin"]["school_id"],
"session"=>$_SESSION["admin"]["session"]
);

$db->delete("Homework_role","where section = '$section' and class='$class'");
$db->insertAry("Homework_role",$newExam);

}

}

if($_POST){

if(is_array($_POST["classes"]) && count($_POST["classes"])>0){
    
$teacher_ex=$db->getVal("select id  from Homework_role where teacher_id='".$_GET['teacher']."' and session='".$_SESSION["admin"]["session"]."'   ");
		
	if($teacher_ex){	
		$db->delete("Homework_role","where teacher_id='".$_GET['teacher']."'");
	}
foreach($_POST["classes"] as $class){
insertData($class, $db);
}

}

}
?>

<style>.top-bar-minimize{display:none;}
thead, tfoot {display: table-header-group;}
.top-bar+.well,.accordion .accordion-heading+.accordion-body{display: inline-block !important;width: 100% !important;overflow: inherit !important;} 
</style>
<?php
$pgMod="teacher_report";
$pgAct="view";
if(isset($_GET['action']) && trim($_GET['action'])!='')
$pgAct=strtolower($_GET['action']);

if(isset($_SESSION['msg']) && $_SESSION['msg']!="")
{
?>
<div class="alert alert-success">
 <a class="close" data-dismiss="alert">×</a>
 <i class="icon icon-thumbs-up-alt"></i> <b></b><?php echo $_SESSION['msg'] ?></i>
</div>
<?php
unset($_SESSION["msg"]);
}
if(is_array($alert_err) && count($alert_err)>0)
{
?>
<div class="alert alert-error">
 <a class="close" data-dismiss="alert">×</a>
 <i class="icon icon-warning-sign"></i> <b></b> <?php echo $alert_err[0] ?></i>
</div>
<?php
}
?>
    <!--<form method="get" action="">-->
    <input type="hidden" name="src" value="Notice" />
    <input type="hidden" name="page_id" value="<?php echo $pgMod; ?>" />
<div class="row-fluid">
            <div class="span12">
            <div class="top-bar">
<h3><i class="icon-cog"></i>Teachers Report</h3>
<div>
<button type="button" onclick="printDiv('printDiv2')" class="btn btn-primary " style="float:right !important; margin-top:5px ">Print</button>
</div>
</div>
<div class="well no-padding"  id="printDiv2">
<div class="controls controls-row">

<div class="tab">
    <button class="tablinks" onclick="openRole(event, 'attendance')" id="defaultOpen" style="border-right:solid 1px #999;border-bottom:solid 1px #999;">Attendance Report</button>
    <button class="tablinks" onclick="openRole(event, 'homework')" style="border-right:solid 1px #999;border-bottom:solid 1px #999;">Homework Report</button>
    <button class="tablinks" onclick="openRole(event, 'classteacher')" style="border-right:solid 1px #999;border-bottom:solid 1px #999;">Class Teacher</button>
    <button class="tablinks" onclick="openRole(event, 'subjectteacher')" style="border-right:solid 1px #999;border-bottom:solid 1px #999;">Subject Teacher</button>
    <button class="tablinks" onclick="openRole(event, 'teacherwisehw')" style="border-right:solid 1px #999;border-bottom:solid 1px #999;">HW Teacher Wise</button>
    <button class="tablinks" onclick="openRole(event, 'classwisehw')" style="border-right:solid 1px #999;border-bottom:solid 1px #999;">HW Class Wise</button>
    <button class="tablinks" onclick="openRole(event, 'cbseexam')" style="border-right:solid 1px #999;border-bottom:solid 1px #999;">CBSE Exam</button>
    <button class="tablinks" onclick="openRole(event, 'boardexam')" style="border-right:solid 1px #999;border-bottom:solid 1px #999;">Board Exam</button>
    <button class="tablinks" onclick="openRole(event, 'examreport')" style="border-right:solid 1px #999;border-bottom:solid 1px #999;">Objective Exam Result</button>
    <button class="tablinks" onclick="openRole(event, 'subjectivereport')" style="border-right:solid 1px #999;border-bottom:solid 1px #999;">Subjective Exam Result</button>
</div>

<div id="attendance" class="tabcontent">
  <h5 style="font-size:21px;">Attendance Role Assigned Teachers List</h5>
  <button class="btn btn-danger" onclick="exportTableToExcel('attRole', 'Attendance Report')" style="float:right;margin-top:5px;margin-left:10px;">Excel</button>
    <table class="table" id="attRole" border="1">
        <tr>
            <th>S.No.</th>
            <th>Teacher Name</th>
            <th>Mobile</th>
            <th>Designation</th>
            <th>Assigned Class & Section</th>
            <th>Photo</th>
        </tr>
        <?php $i=0;
            $staff = $db->getRows("select * from staff where session='".$_SESSION["admin"]["session"]."' and status=1 order by name");
            foreach($staff as $teacher){
                $i++;
                echo "<tr>
                <td>$i</td>
                <td>$teacher[name]</td>
                <td>$teacher[mobile]</td>
                <td>$teacher[designation]</td>
                <td>";
                $roles = $db->getRows("select * from Attandence_role where session='".$_SESSION["admin"]["session"]."' and teacher_id=$teacher[idno] and school_id=1 order by section ASC ");
                foreach($roles as $role){
                    echo "$role[class] - $role[section]<br>";
                }
                echo "</td> <td>";
                if($teacher[photo]!=""){
                    echo "
                        <img src='../media/photo/$teacher[photo]' style='width:80px;'/>                   
                    ";
                }
                echo "</td> 
                </tr>";
            }
        ?>
    </table>
</div>

<div id="homework" class="tabcontent">
  <h5 style="font-size:21px;">Homework Role Assigned Teachers List</h5>
    <button class="btn btn-danger" onclick="exportTableToExcel('hwRole', 'Homework Report')" style="float:right;margin-top:5px;margin-left:10px;">Excel</button>
  <table class="table" id="hwRole" border="1">
        <tr>
            <th>S.No.</th>
            <th>Teacher Name</th>
            <th>Mobile</th>
            <th>Designation</th>
            <th>Assigned Class & Section</th>
            <th>Photo</th>
        </tr>
        <?php $i=0;
            $staff = $db->getRows("select * from staff where session='".$_SESSION["admin"]["session"]."' and status=1 order by name");
            foreach($staff as $teacher){
                $i++;
                echo "<tr>
                    <td>$i</td>
                    <td>$teacher[name]</td>
                    <td>$teacher[mobile]</td>
                <td>$teacher[designation]</td>
                    <td>";

                $roles = $db->getRows("select * from Homework_role where session='".$_SESSION["admin"]["session"]."' and teacher_id=$teacher[idno] and school_id=1 order by section ASC ");

                foreach($roles as $role){
                    echo "$role[class] - $role[section]<br>";
                }
                echo "</td> <td>";
                if($teacher[photo]!=""){
                    echo "
                        <img src='../media/photo/$teacher[photo]' style='width:80px;'/>                   
                    ";
                }
                echo "</td> 
                </tr>";

            }

        ?>
    </table>
</div>


<div id="classteacher" class="tabcontent">
  <h5 style="font-size:21px;">Class Teachers List</h5>
  
  <form id="classTeacherForm" class="login-form" method="post">
      <input type="hidden" name="classteacher" />

      <div style="display:inline-block;"><span>Select Class</span><br>
      <select name="class" id="class">
      <option value="">--Select Class--</option>
      <?php $allClasses = $db->getRows("select * from class where school_id=1 and added_by=1 and status=1");
            foreach($allClasses as $class){
                echo "<option value='$class[class]'>$class[class]</option>";
                }
            ?>
        </select>
      </div>
      <div style="display:inline-block;"><span>Select Section</span><br>
      <select name="section" id="section">
      <option value="">--Select Section--</option>
      <?php $allSection = $db->getRows("select * from section where school_id=1 and added_by=1 order by name ASC");
            foreach($allSection as $section){
                echo "<option value='$section[name]'>$section[name]</option>";
                }
            ?>
        </select>
      </div>
      
      <div style="display:inline-block;">
      <input type="submit" id="submit" name="classteacher" value="Search" class="btn btn-primary" style="background:#ff0066;color:white;border-radius:10px;padding:5px 10px;font-size:16px;box-shadow:0px 0px 5px #999;margin-left:20px;" />
      </div>
    </form>
    
    <div id="classteacherlist"></div>
  
  <!--<table class="table">-->
  <!--      <tr>-->
            <!--<th>S.No.</th>-->
            <!--<th>Teacher Name</th>-->
            <!--<th>Mobile</th>-->
            <!--<th>Designation</th>-->
            <!--<th>Assigned Class & Section</th>-->
            <!--<th>Photo</th>-->
  <!--      </tr>-->
        <?php /*
        $i=0;
            $staff = $db->getRows("select * from staff where session='".$_SESSION["admin"]["session"]."' and status=1 order by name");
            foreach($staff as $teacher){
                $i++;
                echo "<tr>
                    <td>$i</td>
                    <td>$teacher[name]</td>
                    <td>$teacher[mobile]</td>
                    <td>$teacher[designation]</td>
                    <td>";

                $roles = $db->getRows("select * from assign_teacher where session='".$_SESSION["admin"]["session"]."' and teacher_id=$teacher[idno] and school_id=1 and is_class_teacher=1 order by section ASC ");

                foreach($roles as $role){
                    echo "$role[class] - $role[section]<br>";
                }
                echo "</td>
                    <td><img src='../media/photo/$teacher[photo]' style='width:80px;'/></td>
                </tr>";
            }
*/        ?>
    <!--</table>-->
</div>

<div id="subjectteacher" class="tabcontent">
  <h5 style="font-size:21px;">Subject Teachers List</h5>
    <form id="subjectTeacherForm" class="login-form" method="post">
      <input type="hidden" name="subjectteacher" />

      <div style="display:inline-block;"><span>Select Class</span><br>
      <select name="class" id="class">
      <option value="">--Select Class--</option>
      <?php $allClasses = $db->getRows("select * from class where school_id=1 and added_by=1 and status=1");
            foreach($allClasses as $class){
                echo "<option value='$class[class]'>$class[class]</option>";
                }
            ?>
        </select>
      </div>
      <div style="display:inline-block;"><span>Select Section</span><br>
      <select name="section" id="section">
      <option value="">--Select Section--</option>
      <?php $allSection = $db->getRows("select * from section where school_id=1 and added_by=1 order by name ASC");
            foreach($allSection as $section){
                echo "<option value='$section[name]'>$section[name]</option>";
                }
            ?>
        </select>
      </div>

      <div style="display:inline-block;">
      <input type="submit" id="submit" name="subjectteacher" value="Search" class="btn btn-primary" style="background:#ff0066;color:white;border-radius:10px;padding:5px 10px;font-size:16px;box-shadow:0px 0px 5px #999;margin-left:20px;" />
      </div>
    </form>
    
    <div id="subjectteacherlist"></div>

  <!--<table class="table">-->
  <!--      <tr>-->
  <!--          <th>S.No.</th>-->
  <!--          <th>Teacher Name</th>-->
  <!--          <th>Mobile</th>-->
  <!--          <th>Designation</th>-->
  <!--          <th>Assigned Class & Section</th>-->
  <!--          <th>Photo</th>-->
  <!--      </tr>-->
        <?php /*$i=0;
            $staff = $db->getRows("select * from staff where session='".$_SESSION["admin"]["session"]."' and status=1 order by name");
            foreach($staff as $teacher){
                $i++;
                echo "<tr>
                    <td>$i</td>
                    <td>$teacher[name]</td>
                    <td>$teacher[mobile]</td>
                    <td>$teacher[designation]</td>
                    <td>";

                $roles = $db->getRows("select * from assign_teacher where session='".$_SESSION["admin"]["session"]."' and teacher_id=$teacher[idno] and school_id=1 and is_class_teacher=0 order by section ASC ");

                foreach($roles as $role){
                    echo "$role[class] - $role[section]<br>";
                }
                echo "</td>
                    <td><img src='../media/photo/$teacher[photo]' style='width:80px;'/></td>
                </tr>";
            }
        */?>
    <!--</table>-->
</div>


<div id="teacherwisehw" class="tabcontent">
  <h5 style="font-size:21px;">Teachers List</h5>

    <form id="myForm" class="login-form" method="post">
      <input type="hidden" name="teacherwisehw" />
      <div style="display:inline-block;" ><span>From</span><br>
      <input type="date" name="fromdate" value="<?php echo date('Y-m-d'); ?>" id="fromdate" />
      </div>
      <div style="display:inline-block;"><span>To</span><br>
      <input type="date" name="todate" value="<?php echo date('Y-m-d', strtotime("+1 day")); ?>" id="todate" />
      </div>
      <div style="display:inline-block;"><span>Select Teacher</span><br>
      <select name="teacher_id" id="teacher_id">
      <option value="">--Select Teacher--</option>
      <?php $staff = $db->getRows("select * from staff where session='".$_SESSION["admin"]["session"]."' and status=1 order by name");
            foreach($staff as $teacher){
                echo "<option value='$teacher[idno]'>$teacher[name]</option>";
                }
            ?>
        </select>
      </div>
      <div style="display:inline-block;">
      <input type="submit" id="submit" name="teacherwisehw" value="Search" class="btn btn-primary" style="background:#ff0066;color:white;border-radius:10px;padding:5px 10px;font-size:16px;box-shadow:0px 0px 5px #999;margin-left:20px;" />
   	<input type="button" class="btn btn-danger hidet" onclick="getStudentSMS()" value="SMS" style="float:right;" />
      </div>
    </form>
    
    <div id="teacherslist"></div>

</div>

<div id="classwisehw" class="tabcontent">
  <h5 style="font-size:21px;">Teachers List</h5>

    <form id="myForm1" class="login-form" method="post">
      <input type="hidden" name="classwisehw" />
      <div style="display:inline-block;" ><span>From</span><br>
      <input type="date" name="fromdate" value="<?php echo date('Y-m-d'); ?>" id="classfromdate" />
      </div>
      <div style="display:inline-block;"><span>To</span><br>
      <input type="date" name="todate" value="<?php echo date('Y-m-d', strtotime("+1 day")); ?>" id="classtodate" />
      </div>
      <div style="display:inline-block;"><span>Select Class</span><br>
      <select name="class" id="class">
      <option value="">--Select Class--</option>
      <?php $allClasses = $db->getRows("select * from class where school_id=1 and added_by=1 and status=1");
            foreach($allClasses as $class){
                echo "<option value='$class[class]'>$class[class]</option>";
                }
            ?>
        </select>
      </div>
      <div style="display:inline-block;"><span>Select Section</span><br>
      <select name="section" id="section">
      <option value="">--Select Section--</option>
      <?php $allSection = $db->getRows("select * from section where school_id=1 and added_by=1 order by name ASC");
            foreach($allSection as $section){
                echo "<option value='$section[name]'>$section[name]</option>";
                }
            ?>
        </select>
      </div>
      
      <div style="display:inline-block;">
      <input type="submit" id="submit" name="classwisehw" value="Search" class="btn btn-primary" style="background:#ff0066;color:white;border-radius:10px;padding:5px 10px;font-size:16px;box-shadow:0px 0px 5px #999;margin-left:20px;" />
      </div>
    </form>
    
    <div id="classlist"></div>

</div>

<div id="cbseexam" class="tabcontent">
  <h5 style="font-size:21px;">Subject assigned to Teachers</h5>
      <button class="btn btn-danger" onclick="exportTableToExcel('cbseEx', 'CBSE Exam Report')" style="float:right;">Excel</button>
    <table class="table" id="cbseEx" border="1">
        <tr>
            <th>S.No.</th>
            <th>Teacher Name</th>
            <th>Mobile</th>
            <th>Designation</th>
            <th>Class & Section</th>
            <th>Subjects</th>
            <th>Photo</th>
        </tr>
        <?php  $i=0;
            $staff = $db->getRows("select * from staff where session='".$_SESSION["admin"]["session"]."' and status=1 order by name");
            foreach($staff as $teacher){
             $i++;
             echo "<tr>
                <td>$i</td>
                <td>$teacher[name]</td>
                <td>$teacher[mobile]</td>
                <td>$teacher[designation]</td>";

                $teachersubject = $db->getRows("select * from teacher_subject where teacher_id=$teacher[idno] and session='".$_SESSION["admin"]["session"]."' and school_id=1 ");

                $cs="";
                $sub="";
                $arun = array();
                foreach($teachersubject as $ts){
                    $sec=json_decode($ts[section]);
                    $sec = implode(", ",$sec);
                    $classsubject = $db->getRow("select * from subject where id=$ts[cls_sub_id] order by class ASC");
                    $cs .= "$classsubject[class] - $sec<br>";
                    $sub .="$classsubject[subject]<br>"; 
                }

                echo "<td>$cs</td>
                      <td>$sub</td>
                      <td><img src='../media/photo/$teacher[photo]' style='width:80px;'/></td>
                </tr>";
            }
        ?>
    </table>
</div>


<div id="boardexam" class="tabcontent">
  <h5 style="font-size:21px;">Subject assigned to Teachers</h5>
        <button class="btn btn-danger" onclick="exportTableToExcel('boardEx', 'Board Exam Report')" style="float:right;">Excel</button>
    <table class="table" id="boardEx" border="1">
        <tr>
            <th>S.No.</th>
            <th>Teacher Name</th>
            <th>Mobile</th>
            <th>Designation</th>
            <th>Class & Section</th>
            <th>Subjects</th>
            <th>Photo</th>
        </tr>
        <?php  $i=0;
            $staff = $db->getRows("select * from staff where session='".$_SESSION["admin"]["session"]."' and status=1 order by name");
            foreach($staff as $teacher){
             $i++;
             echo "<tr>
                <td>$i</td>
                <td>$teacher[name]</td>
                <td>$teacher[mobile]</td>
                <td>$teacher[designation]</td>";

                $teachersubject = $db->getRows("select * from teacher_subject_mp where teacher_id=$teacher[idno] and session='".$_SESSION["admin"]["session"]."' and school_id=1 ");

                $cs="";
                $sub="";
                foreach($teachersubject as $ts){
                    $sec=json_decode($ts[section]);
                    $sec = implode(", ",$sec);
                    $classsubject = $db->getRow("select * from subject_mp where id=$ts[cls_sub_id] order by class ASC");
                    $cs .= "$classsubject[class] - $sec<br>";
                    $sub .="$classsubject[subject]<br>"; 
                }

                echo "<td>$cs</td>
                      <td>$sub</td>
                      <td><img src='../media/photo/$teacher[photo]' style='width:80px;'/></td>
                </tr>";
            }
        ?>
    </table>
</div>


<div id="examreport" class="tabcontent">
  <h5 style="font-size:21px;">Objective Exam Result</h5>
    <form id="examResultForm" class="login-form" method="post" onsubmit="showresult()">
      <input type="hidden" name="examresult" />
        <table>
            <tr>
                <td>
                    <label class="control-label">Select Class</label>
                    <select name="class" style="width:100%;" onchange="filterSubject(this.value)">
                      <option value="">--Select Class--</option>
                      <?php $allClasses = $db->getRows("select * from class where school_id=1 and added_by=1 and status=1");
                        foreach($allClasses as $class){
                            ?>
                            <option <?php if($class["class"]==$aryForm["class"])echo 'selected';?> value="<?php echo $class['class']; ?>"><?php echo $class['class']; ?></option>
                            <?php
                            }
                        ?>
                    </select>
                </td>
                <td>
                    <label class="control-label">Section</label>
                    <select name="section" style="width:100%;">
                      <option value="">--Select Section--</option>
                      <?php $section = $db->getRows("select * from section ");
                        foreach($section as $sec){
                            ?>
                            <option value="<?php echo $sec['name']; ?>"><?php echo $sec['name']; ?></option>
                            <?php
                            }
                        ?>
                    </select>
                </td>
                <td>
                    <label class="control-label">Subject</label>
                    <div  class="controls" id="parent_subject">

                    <select id="mySelect1" name="parent_subject" style="width:100%;"  onchange="changeSubject()">
                        <option value="">--Select Subject--</option>
                      <?php $allSubjects = $db->getRows("select * from subject_new where class='$aryForm[class]' and session='".$_SESSION["admin"]["session"]."' and type='subject' order by id ASC ");
                            foreach($allSubjects as $sub){
                            ?>
                            <option <?php if($sub["id"]==$aryForm["parent_subject"])echo 'selected';?> value="<?php echo $sub['id']; ?>"><?php echo $sub['subject']; ?></option>
                            <?php
                            }
                        ?>
                    </select>  
                    </div>
                </td>
                <td>
                    <label class="control-label">Sub - Subject</label>
                          <div  class="controls" id="sub_subject">

                    <select name="sub_subject" style="width:100%;" id="subSubjectid" onchange="filterChapter()">
                        <option value="">--Select sub-Subject--</option>
                        <?php $allsubSubjects = $db->getRows("select * from subject_new where parent_subject='".$aryForm["parent_subject"]."' and session='".$_SESSION["admin"]["session"]."' and type='sub_subject'  order by id ASC");
                        foreach($allsubSubjects as $sub){
                            ?>
                            <option <?php if($sub["id"]==$aryForm["sub_subject"])echo 'selected'; ?> value="<?php echo $sub['id']; ?>"><?php echo $sub['subject']; ?></option>
                            <?php
                            }
                        ?>
                    </select>
                    </div>
                </td>
                <td>
                    <label class="control-label">Chapter</label>
                          <div  class="controls" id="chapter_div">

                    <select id="chapter" name="chapter" style="width:100%" onchange="getpaper(this.value)">
                        <option value="">--Select Chapter--</option>
                        <?php $allChapters = $db->getRows("select * from subject_new where sub_subject='".$aryForm["sub_subject"]."' and session='".$_SESSION["admin"]["session"]."' and type='chapter'  order by id ASC ");
                        foreach($allChapters as $chapter){
                            ?>
                            <option <?php if($chapter["id"]==$aryForm["chapter"])echo 'selected'; ?> value="<?php echo $chapter['id']; ?>"><?php echo $chapter['subject']; ?></option>
                            <?php
                            }
                        ?>            
                    </select>
                    </div>
                </td>
                <td>
                    <label class="control-label">Papers</label>
                          <div  class="controls" id="paper_div">

                    <select name="paper" style="width:100%">
                        <option value="">--Select Paper--</option>
                        <?php $allChapters = $db->getRows("select * from subject_new where sub_subject='".$aryForm["sub_subject"]."' and session='".$_SESSION["admin"]["session"]."' and type='chapter'  order by id ASC ");
                        foreach($allChapters as $chapter){
                            ?>
                            <option <?php if($chapter["id"]==$aryForm["chapter"])echo 'selected'; ?> value="<?php echo $chapter['id']; ?>"><?php echo $chapter['subject']; ?></option>
                            <?php
                            }
                        ?>            
                    </select>
                    </div>
                </td>
                <td>
                    <label></label>
                  <input type="submit" id="submit" name="examresult" value="Search" class="btn btn-primary" style="background:#ff0066;color:white;border-radius:10px;padding:5px 10px;font-size:16px;box-shadow:0px 0px 5px #999;margin-left:20px;margin-top:20px;" />
                    <!--<button class="btn" style="margin-top:20px;font-size:15px;padding:3px 8px;" onclick="filterRecord()">Search</button>-->
                </td>
            </tr>
        </table>
        
        </form>
    
    <div id="examresultlist"></div>


  <div class="modal fade" id="myModal" role="dialog" style="width:1000px;margin-left:-500px;">
    <div class="modal-dialog modal-lg" id="mcontent">
    
      <!-- Modal content-->
      <div class="modal-content">

        <div class="modal-body">
          <!--<div id="chartContainer" style="height: 370px; width: 100%;"></div>-->
          <!--<p>Some text in the modal.</p>-->
          <div id="solution"></div>
        </div>
        
      </div>
      
    </div>
  </div>

</div>


<div id="subjectivereport" class="tabcontent">
  <h5 style="font-size:21px;">Subjective Exam Result</h5>
    <form id="subjectiveResultForm" class="login-form" method="post" onsubmit="showsubjectiveresult()">
      <input type="hidden" name="subjectiveresult" />
        <table>
            <tr>
                <td>
                    <label class="control-label">Select Class</label>
                    <select name="class" style="width:100%;" onchange="filterSubject(this.value)">
                      <option value="">--Select Class--</option>
                      <?php $allClasses = $db->getRows("select * from class where school_id=1 and added_by=1 and status=1");
                        foreach($allClasses as $class){
                            ?>
                            <option <?php if($class["class"]==$aryForm["class"])echo 'selected';?> value="<?php echo $class['class']; ?>"><?php echo $class['class']; ?></option>
                            <?php
                            }
                        ?>
                    </select>
                </td>
                <td>
                    <label class="control-label">Section</label>
                    <select name="section" style="width:100%;">
                      <option value="">--Select Section--</option>
                      <?php $section = $db->getRows("select * from section ");
                        foreach($section as $sec){
                            ?>
                            <option value="<?php echo $sec['name']; ?>"><?php echo $sec['name']; ?></option>
                            <?php
                            }
                        ?>
                    </select>
                </td>
                <td>
                    <label class="control-label">Subject</label>
                    <div  class="controls" id="parent_subject1">

                    <select id="mySelect1" name="parent_subject" style="width:100%;"  onchange="changeSubject()">
                        <option value="">--Select Subject--</option>
                      <?php $allSubjects = $db->getRows("select * from subject_new where class='$aryForm[class]' and session='".$_SESSION["admin"]["session"]."' and type='subject' order by id ASC ");
                            foreach($allSubjects as $sub){
                            ?>
                            <option <?php if($sub["id"]==$aryForm["parent_subject"])echo 'selected';?> value="<?php echo $sub['id']; ?>"><?php echo $sub['subject']; ?></option>
                            <?php
                            }
                        ?>
                    </select>  
                    </div>
                </td>
                <td>
                    <label class="control-label">Sub - Subject</label>
                          <div  class="controls" id="sub_subject1">

                    <select name="sub_subject" style="width:100%;" id="subSubjectid" onchange="filterChapter()">
                        <option value="">--Select sub-Subject--</option>
                        <?php $allsubSubjects = $db->getRows("select * from subject_new where parent_subject='".$aryForm["parent_subject"]."' and session='".$_SESSION["admin"]["session"]."' and type='sub_subject'  order by id ASC");
                        foreach($allsubSubjects as $sub){
                            ?>
                            <option <?php if($sub["id"]==$aryForm["sub_subject"])echo 'selected'; ?> value="<?php echo $sub['id']; ?>"><?php echo $sub['subject']; ?></option>
                            <?php
                            }
                        ?>
                    </select>
                    </div>
                </td>
                <td>
                    <label class="control-label">Chapter</label>
                          <div  class="controls" id="chapter_div1">

                    <select id="chapter" name="chapter" style="width:100%" onchange="getpaper(this.value)">
                        <option value="">--Select Chapter--</option>
                        <?php $allChapters = $db->getRows("select * from subject_new where sub_subject='".$aryForm["sub_subject"]."' and session='".$_SESSION["admin"]["session"]."' and type='chapter'  order by id ASC ");
                        foreach($allChapters as $chapter){
                            ?>
                            <option <?php if($chapter["id"]==$aryForm["chapter"])echo 'selected'; ?> value="<?php echo $chapter['id']; ?>"><?php echo $chapter['subject']; ?></option>
                            <?php
                            }
                        ?>            
                    </select>
                    </div>
                </td>
                <td>
                    <label></label>
                    <input type="submit" id="submit" name="subjectiveresult" value="Search" class="btn btn-primary" style="background:#ff0066;color:white;border-radius:10px;padding:5px 10px;font-size:16px;box-shadow:0px 0px 5px #999;margin-left:20px;margin-top:20px;" />
                </td>
            </tr>
        </table>
        
        </form>

    <div id="subjectiveresultlist"></div>

      <div class="modal fade" id="myModal" role="dialog" style="width:1000px;margin-left:-500px;">
        <div class="modal-dialog modal-lg" id="mcontent">
        
          <!-- Modal content-->
          <div class="modal-content">
    
            <div class="modal-body">
              <!--<div id="chartContainer" style="height: 370px; width: 100%;"></div>-->
              <!--<p>Some text in the modal.</p>-->
              <div id="solution"></div>
            </div>
            
          </div>
          
        </div>
      </div>


</div>

        </div>
        <br>
</div>
<!-- / Forms: Content -->
</div>
    </div>
    <!--</form>-->
 



<script>
function openRole(evt, roleName) {
  var i, tabcontent, tablinks;
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
  }
  tablinks = document.getElementsByClassName("tablinks");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].className = tablinks[i].className.replace(" active", "");
  }
  document.getElementById(roleName).style.display = "block";
  evt.currentTarget.className += " active";
}

// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>

<style>
body {font-family: Arial;}

/* Style the tab */
.tab {
  overflow: hidden;
  border: 1px solid #ccc;
  background-color: #f1f1f1;
}

/* Style the buttons inside the tab */
.tab button {
  background-color: inherit;
  float: left;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 14px 6px;
  transition: 0.3s;
  font-size: 18px;
  width:25%;
  font-weight:bold;
}

/* Change background color of buttons on hover */
.tab button:hover {
  background-color: #ddd;
}

/* Create an active/current tablink class */
.tab button.active {
  background-color: crimson;
  color:white;
}

/* Style the tab content */
.tabcontent {
  display: none;
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-top: none;
}
</style>

<style type="text/css">
@media print {
    #myPrntbtn {
        display :  none;
    }
}

@media screen {
   #myPrntbtn1 {
        display: none;
    }
}
</style>

<script type="text/javascript">
	$(document).ready(function(e) {
		var oTable = $('.table').dataTable( {
			"bPaginate": false,
			"bLengthChange": false,
			"bFilter": true,
			"bSort": true,
			"bInfo": true,
			"bAutoWidth": false
		});
	});
	
	</script>
	
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

<script>
$(document).ready(function(){
    $(function(){
       $("#myForm").submit(function(event){
           event.preventDefault();

           var fromdate = document.getElementById('fromdate').value;
           var todate = document.getElementById('todate').value;
           var teacher = document.getElementById('teacher_id').value;

          if(fromdate == ""){
              alert('Please select From date');
              return;
          }
          if(todate == ""){
              alert('Please select To date');
              return;
          }
          if(fromdate > todate){
              alert('From date should be less than To date');
              return;
          }

           $.ajax({
               method: 'POST',
               url: 'Notice/ajax.php',
               data : $('#myForm').serialize(),
               success: function( response ){
                   document.getElementById('teacherslist').innerHTML = response;
               },
               error: function(xhr, desc, err){
                   alert(err);
               }
           });
       });

    });

    $(function(){
        $("#myForm1").submit(function(event){
           event.preventDefault();

           var fromdate = document.getElementById('classfromdate').value;
           var todate = document.getElementById('classtodate').value;
           var classes = document.getElementById('class').value;

          if(fromdate == ""){
              alert('Please select From date');
              return;
          }
          if(todate == ""){
              alert('Please select To date');
              return;
          }
          if(fromdate > todate){
              alert('From date should be less than To date');
              return;
          }

           $.ajax({
               method: 'POST',
               url: 'Notice/ajax.php',
               data : $('#myForm1').serialize(),
               success: function( response ){
                   document.getElementById('classlist').innerHTML = response;
               },
               error: function(xhr, desc, err){
                   alert(err);
               }
           });

       });

    });
    
    
    
    $(function(){
        $("#classTeacherForm").submit(function(event){
           event.preventDefault();

           $.ajax({
               method: 'POST',
               url: 'Notice/ajax.php',
               data : $('#classTeacherForm').serialize(),
               success: function( response ){
                   document.getElementById('classteacherlist').innerHTML = response;
               },
               error: function(xhr, desc, err){
                   alert(err);
               }
           });

       });

    });
    
    $(function(){
        $("#subjectTeacherForm").submit(function(event){
           event.preventDefault();

           $.ajax({
               method: 'POST',
               url: 'Notice/ajax.php',
               data : $('#subjectTeacherForm').serialize(),
               success: function( response ){
                   document.getElementById('subjectteacherlist').innerHTML = response;
               },
               error: function(xhr, desc, err){
                   alert(err);
               }
           });

       });

    });

});

function getStudentSMS(){

   	var todate = $("#todate").val();
   	var fromdate = $("#fromdate").val();
   	var teacher_id = $("#teacher_id").val();

$.post( "Notice/ajax.php", { type: "attendance_message" ,todate: todate,fromdate: fromdate, teacher_id: teacher_id } , function( data ) {
		alert(data);
	});

	}
	 
	
function filterSubject(cls){

    $.post( "Notice/ajax.php", { type: "filter_subject" ,classname: cls } , function( data ) {
 
        document.getElementById("parent_subject").innerHTML = data;
        document.getElementById("parent_subject1").innerHTML = data;
	});

}

function changeSubject(subject){
    // var subject = document.getElementById("mySelect1").value;
    $.post( "Notice/ajax.php", { type: "filterSubSubject" ,subject: subject } , function( data ) {
        document.getElementById("sub_subject").innerHTML = data;
        document.getElementById("sub_subject1").innerHTML = data;
        // alert(data);
	});
}

function filterChapter(subject){
        // var subject = document.getElementById("subSubjectid").value;
//    alert(subject);
    $.post( "Notice/ajax.php", { type: "filterChapter" ,subject: subject } , function( data ) {
        document.getElementById("chapter_div").innerHTML = data;
        document.getElementById("chapter_div1").innerHTML = data;
	});
	
}

function getpaper(chapter_id){
    // alert(chapter_id);
    $.post( "Notice/ajax.php", { type: "getPaper" ,chapter: chapter_id } , function( data ) {
        document.getElementById("paper_div").innerHTML = data;
	});
	
}

    function showresult(){
           event.preventDefault();

           $.ajax({
               method: 'POST',
               url: 'Notice/ajax.php',
               data : $('#examResultForm').serialize(),
               success: function( response ){
                   document.getElementById('examresultlist').innerHTML = response;
               },
               error: function(xhr, desc, err){
                   alert(err);
               }
           });

    };
    
    function showsubjectiveresult(){
           event.preventDefault();

           $.ajax({
               method: 'POST',
               url: 'Notice/ajax.php',
               data : $('#subjectiveResultForm').serialize(),
               success: function( response ){
                   document.getElementById('subjectiveresultlist').innerHTML = response;
               },
               error: function(xhr, desc, err){
                   alert(err);
               }
           });

    }
   
	function viewSolution(pid, uid, c, w, s){
        document.cookie = "correct = " + c;
        document.cookie = "wrong = " + w;
        document.cookie = "skipped = " + s;
        	   // showpiechart(c, w, s);
        $.post( "Notice/ajax.php", { type: "viewSolution" ,pid: pid, uid:uid } , function( data ) {
            document.getElementById("solution").innerHTML = data;
    	});
    jQuery.noConflict();	
    	$("#myModal").modal('show');
    	 
	}

function showpiechart(c,w,s){

    <?php
        $dataPoints = array(
    	array("label"=>"Skipped", "y"=>$_COOKIE[skipped]),
    	array("label"=>"Wrong", "y"=>$_COOKIE[wrong]),
    	array("label"=>"Correct", "y"=>$_COOKIE[correct]),
    );
    ?>
var chart = new CanvasJS.Chart("chartContainer", {
	animationEnabled: true,
	title: {
		text: ""
	},
	subtitles: [{
		text: ""
	}],
	data: [{
		type: "pie",
		yValueFormatString: "#,##0\"\"",
		indexLabel: "{label} ({y})",
		dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
	}]
});
chart.render();
$(".canvasjs-chart-credit").hide();

 arun();   
}

function arun(){
    // alert('delete cookie.');
        document.cookie = "correct=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
    document.cookie = "wrong=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
    document.cookie = "skipped=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
}	

function deleteattemptpaper(pid){
    $.post( "Notice/ajax.php", { type: "delete_attempt_paper" ,pid: pid } , function( data ) {
            showresult();
	    });
}
	
	    function exportTableToExcel(tableID, filename = '',e){
    
    // var tableType = document.getElementById('tblData').getAttribute("data-tblname");

    var downloadLink;
    var dataType = 'application/vnd.ms-excel';
    var tableSelect = document.getElementById(tableID);
    var tableHTML = tableSelect.outerHTML.replace(/ /g, '%20');

    // Specify file name
    filename = filename?filename+'.xls':'excel_data.xls';
    
    // Create download link element
    downloadLink = document.createElement("a");
    
    document.body.appendChild(downloadLink);
    
    if(navigator.msSaveOrOpenBlob){
        var blob = new Blob(['\ufeff', tableHTML], {
            type: dataType
        });
        navigator.msSaveOrOpenBlob( blob, filename);
    }else{
        // Create a link to the file
        downloadLink.href = 'data:' + dataType + ', ' + tableHTML;
    
        // Setting the file name
        downloadLink.download = filename;
        
        //triggering the function
        downloadLink.click();
    }
    e.preventDefault();
}	
</script>

<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>