<?php include('parent/callMe.php');?>

<?php include('Sessioncheck.php');?>

<?php





 $branch=$_SESSION['branch'];

 

 $sql = " select first_name, last_name,candidate_roll_no,ref_no,class_id,section_id,session_id,cell_no,father_cellno,mother_cell,home_number,father_Bnumber from  edu_student_details where status='0' AND branch_id=".$_SESSION['branch'];



if($_REQUEST['class_id']=="All"){

    

    } else {

     $sql .= " AND class_id = '" .$_REQUEST['class_id']. "' ";



    } 



    if($_REQUEST['section']=="All"){

    

    } else {

     $sql .= " AND section_id = '" .$_REQUEST['section']. "' ";



    }

  

   if($_REQUEST['session']!=NULL){

    $sql .= " AND session_id = '" .$_REQUEST['session']. "' ";

  }else {

    $sql .= " AND session_id = '" .$_SESSION['current_session']. "' ";

  }



   if($_REQUEST['orderby']=="class"){
      $sql .= " ORDER BY class_id, CAST(ref_no AS SIGNED) ASC";
    } else {
      $sql .= " ORDER BY CAST(ref_no AS SIGNED) ASC";

    }

  

  //print_r($sql);



  $WorkAssignListings = $m->query($sql);





  $m->where("session_id", $_REQUEST['session']);

  $session=$m->get("edu_session_config");





  // getting branch details



  $m->where("branch_id", $_SESSION['branch']);

  $branch=$m->get("edu_branch_config");



 ?>



<!DOCTYPE HTML>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Print Contact Sheet</title>

<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />

<script type="text/javascript">

// window.print();

</script>

<style type="text/css">



tr th {padding:1%;border-bottom:1px solid gray;border-top:1px solid gray;border-left:1px solid gray;text-align:center;background-color:lightgray;font-size:14px;}

tr td {border-bottom:1px solid gray;border-left:1px solid gray;font-size:16px;}

  

.border{border:1px solid black;}

.center{text-align:center;}

.alignment{padding-left:1%;text-align:left;}







@media print {

    #Header, #Footer { display: none !important; }

}

@media screen

   {

      p.bodyText {font-family:verdana, arial, sans-serif;}

   }



   @media print

   {

      p.bodyText {font-family:georgia, times, serif;}

   }

   @media screen, print

   {

      p.bodyText {font-size:10pt}

   }

   @media print {

  a[href]:after {

    content: none !important;

  }

}

</style>

</head>

<body style="font-size:12px;">

<div style="width:100%; text-align:center; height:80px;float:left;">
<div style="width:20%;font-size:13px;text-align:center;float:left;height:80px;">

<img src="<?php echo DOMAIN;?>Production/img/<?php echo $brid[0]['logo']; ?>" style="height:100px;width:100px;"  />

</div>

<div style="width:60%; float:left;">

         <span style="font-size:25px; text-align:center;font-family:times new roman;font-weight:bold;color: black;">  <?php echo $brid[0]['Branch_Name'];?> </span>

         <br>
         <span style="font-size:14px; text-align:center;color: black;">  <?php echo $brid[0]['Branch_Location']."<br>"." Cell: ".$brid[0]['Owner_no'];?> </span>



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



    <div style="text-align:center;font-size:18px;font-weight:bold;"> Students Contact Report

 </div>


<hr style="width:100%;" />

<div style="width:25%;float:left;font-size:16px;">  <b> Order By:</b> 

<?php if ($_REQUEST['orderby']=="class") {
    echo "Class Wise";
} else {
    echo "Admission Wise"; }?> 

</div>

<br>

   

    <table id="listofstudents" data-page-length='100' class="table table-striped table-bordered" style="width:100%">

          

         <thead>

            <tr style="font-size: 12px;">

                <th width="3%" class=" center"> S.No</th>

                <th width="10%" class="center"> Name</th>

                <th width="10%" class="center"> F.Name</th>

                <th width="10%" class=" center"> Roll No / Adm </th>  

                <th width="10%" class=" center"> Class / Sec</th>

                <th width="10%" class=" center">Reporting Number </th>  

                <th width="10%" class=" center" > Father Contact No  </th>  

                <th width="10%" class=" center" > Father Busi No </th>  

                <th width="10%" class=" center"> Mother Contact No  </th>

                <th width="10%" class=" center"> Home Contact No </th>

                <th width="10%" class=" center"> Whatsapp No </th>  

                

                

                 

            </tr>

        </thead>

        <tbody>

  <?php 

$count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)

      { 



        $m->where("section_id", $WorkAssignListVal['section_id']);

        $section=$m->get("edu_adm_section_detail");

         

        $m->where("class_id", $WorkAssignListVal['class_id']);

        $class=$m->get("edu_class_config");







       if ($_REQUEST['orderby']=="class") {
            $usrCls=$WorkAssignListVal['class_id'];
            $clsUsrName="Class Name: ". getClassName($m, $WorkAssignListVal['class_id']);
        }




            // Check if the class has changed, print the class-wise total, and update the overall total
            if ($currentClass !== $usrCls) {
                
                // Reset the class-wise total for the new class
                
                $classSerialNumber = 1; // Reset the serial number for the new class

                // Print the heading for the new class
                echo "<tr style='background-color:lightblue;'>
                        <td colspan='11' style='text-align:center;'><b> " . $clsUsrName . "</b></td>
                      </tr>";
                $currentClass = $usrCls;
            }
          $totalRecord=$count++;

            // Process the current record, you can display the data as needed
            echo "<tr>
                    <td>" . $classSerialNumber++ . "</td>
                    <td style='padding-left:1%;'>" . $WorkAssignListVal['first_name'] . "</td>
                    <td>" . $WorkAssignListVal['last_name'] . "</td>
                    <td>" . $WorkAssignListVal['candidate_roll_no']." / ".$WorkAssignListVal['ref_no'] . "</td>
                    <td>" . getClassName($m,$WorkAssignListVal['class_id']).'/'.getSectionName($m,$WorkAssignListVal['section_id']) . "</td>
                    <td>" . $WorkAssignListVal['cell_no'] . "</td>
                    <td>" . $WorkAssignListVal['father_cellno'] . "</td>
                    <td>" . $WorkAssignListVal['father_Bnumber'] . "</td>
                    <td>" . $WorkAssignListVal['mother_cell'] . "</td>
                    <td>" . $WorkAssignListVal['home_number'] . "</td>
                    <td>" . $WorkAssignListVal['whatsapp_number'] . "</td>                    
                  </tr>";                  
          
        }

        // Print the total settlement for the last class in the result set

        
                 
                  if ($currentClass !== null) {
            echo "<tr style='background-color:lightgray;'>
                    <td colspan='3' style='text-align:center;'>Total Record: $totalRecord</td>
                    <td colspan='8' style='text-align:center;'></td>                  
                  </tr>";           
        }
      

     ?>
                   

        </tbody>
    

    </table>



</body>

</html>

