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

$pageName=basename($_SERVER['PHP_SELF']);

    
     $m->where("page_name", $pageName);
     $video = $m->get("eduportal_modules_pages_detail");


   $sessionIDs;
 
  if($_GET["session"]!=NULL ){

      $sessionIDs= $_GET["session"];
    }
    else{
      $sessionIDs= $_SESSION['current_session'];
    }

$section=$_REQUEST['section'];
$class=$_REQUEST['class_id'];
$branchId=$_SESSION['branch'];

/*$orderBy;

if (!isset($_REQUEST['orderBy'])) {

  $orderBy='asc';

} else {

$orderBy=$_REQUEST['orderBy'];

}*/

if($_REQUEST['CodeCell']=="FamilyCode"){

       $m->where("status", '0');
       $m->where("branch_id", $_SESSION['branch']);
       $m->where("family_code", $_REQUEST['code']);
   
       $param = array('student_id','ref_no','first_name','last_name','cell_no','class_id','section_id','family_code','candidate_roll_no');
       $WorkAssignListVal = $m->get("edu_student_details",null,$param);

      } else {

       $m->where("status", '0');
       $m->where("branch_id", $_SESSION['branch']);
       $m->where("cell_no", $_REQUEST['code']);

       $param = array('student_id','ref_no','first_name','last_name','cell_no','class_id','section_id','family_code','candidate_roll_no');
       $WorkAssignListVal = $m->get("edu_student_details",null,$param);

      }

 
     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Update Family Data | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
   
  </head>
<script type="text/javascript">
  
function getCodeCell(id){

  //alert(id);

            if (window.XMLHttpRequest) {

              // code for IE7+, Firefox, Chrome, Opera, Safari

              xmlhttp=new XMLHttpRequest();

            } else { // code for IE6, IE5

              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

            }

            xmlhttp.onreadystatechange=function() {

              if (xmlhttp.readyState==4 && xmlhttp.status==200) {

                document.getElementById("txt_section").innerHTML=xmlhttp.responseText;
                // alert(xmlhttp.responseText);

              }

            }

            xmlhttp.open("GET","get_codecell_dropdown.php?CodeCell="+id,true);

            xmlhttp.send();




          }



          function total_received(id) {


      var netTotal=document.getElementsByName("feerec[]");

      var net=0;

      for(i=0;i<netTotal.length;i++){

  if(netTotal[i]!="" || netTotal[i]!=null){
    
  
   net= parseInt(net)+ parseInt(netTotal[i].value);
   
  }
   
}//ending loop

if(net!=null || net!="" ){
  //alert(net);
  document.getElementById("totaltotal").value=net; 
 }
        
        
      }



      function totalAmountDivide(TAM) {

     
     var tStd=document.getElementById("totalStd").value;          

     var netTotal=document.getElementsByName("feerec[]");

     var dividAmt=0;

      for(i=0;i<netTotal.length;i++){    
 
   var dividAmt=parseInt(TAM)/parseInt(tStd); 
   
    //alert(dividAmt);

     netTotal[i].value=dividAmt;
   
}//ending loop

     
  }

</script>

<style type="text/css">
    .center {
  margin-left: auto;
  margin-right: auto;
}
  </style>

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
          <div class="right_col" role="main">
          <div class="" style="background-color: white;">
           
<section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

   

 <div class="" style="margin-top:10px;">
      <form  action="edit_family_data.php" enctype="multipart/form-data" method="get">
        <div class="panel panel-default">
          <div class="panel-heading"><span style="float:right;margin-top: -7px;">

          <input type="hidden" value="<?php echo session_id().session_id().session_id().session_id().session_id(); ?>" name="session" />
         

          </span>
          <div class="panel-body">
          
            <div class="col-md-12" id="" >

             <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Search By Code/Cell</label>
 

                  <select name="CodeCell" id="CodeCell" data-placeholder="Select" class="chosen-multi-select inputfield form-control">
                                       
                          <option <?php if($_REQUEST['CodeCell']=="FamilyCode"){echo "Selected";} ?> value="FamilyCode">Family Code</option>
                          <option <?php if($_REQUEST['CodeCell']=="Cell"){echo "Selected";} ?> value="Cell">Cell</option>
                           

                </select> 
                </div>
              </div>
              
              
              <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Code/Cell</label>                   

                    <input type="text" name="code" value="<?php echo $_REQUEST['code'];?>" class="form-control" placeholder="Search Code / Cell" >

                  
                </div>
              </div> 

      
           <div class="col-md-1" style="padding:2px;" >
                <div class="form-group ">
                   <input type="hidden" name="addaccountAdmin" value="1">
                <button type="submit" class="btn btn-primary" style="margin-top: 28px;">Search</button>
                </div>
          </div>

             
            </div>
            <div class="clearfix"></div>
          </div>
        </div>
      </form>

<?php  if(isset($_SESSION['submitfamilyFee'])){?>

<div class="alert alert-success" id="msg">
 <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
  <strong>Success!</strong> Fee (<?php echo $_REQUEST['TfeeRec'] ;?>) successfully submitted...
</div>
<?php  unset($_SESSION['submitfamilyFee']); }?>


      <div class="center nameHeadingWidth" style="width: 100%;text-align: center;">
<?php if($_GET['code']!=NULL){ ?>

<h4  class="nameHeadingFont"> Father Name: &nbsp; <?php echo $WorkAssignListVal[0]['last_name']." | Family Code: ".$_REQUEST['code'];?> </h4>

<?php } else { ?>



       <div style="color:black;font-size:18px;" class="alert alert-warning alert-dismissible">
          <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
           <strong>Alert !</strong> Please search Family Code / Cell Number to view fee details!!!
        </div>


<?php } ?>

</div>
      <div class="clearfix"></div>
    </div>
    <br>

     <?php if (isset($_REQUEST['CodeCell'])) { ?>

      <form action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post" enctype="multipart/form-data" class="form-horizontal form-label-left" >

    <input type="hidden" name="action" value="UpdateFamilyData"/>
    <input type="hidden" name="code" value="<?php echo $_REQUEST['code']; ?>">
    <input type="hidden" name="CodeCell" value="<?php echo $_REQUEST['CodeCell']; ?>">
    <input type="hidden" name="branchID" value="<?php echo $_SESSION['branch']; ?>">
    <input type="hidden" name="sessionIDss" value="<?php echo $_SESSION['current_session']; ?>">
    
    <table width="100%"  class="responsive">  


    <tr>

 <th class="thStyle" style="padding:6px 5px;"> Student Name  </th>
 <th class="thStyle" style="padding:6px 5px;"> Father Name  </th>
 <th class="thStyle" style="padding:6px 5px;"> Class/Sec  </th>
 <th class="thStyle" style="padding:6px 5px;"> Cell Number  </th>
 <th class="thStyle" style="padding:6px 5px;"> Family Code  </th>
 <th class="thStyle" style="padding:6px 5px;"> Monthly Fee </th>
 <th class="thStyle" style="padding:6px 5px;"> Transport Fee </th>
 <th class="thStyle" style="padding:6px 5px;"> <?php if ($brid[0]['misc_title']!=NULL){echo $brid[0]['misc_title'];}else {echo 'Misc Fee';} ?> </th>
 <th class="thStyle" style="padding:6px 5px;"> Discount </th>
 <th class="thStyle" style="padding:6px 5px;"> Discount Reasons </th>

  </tr>


    <?php 
/*$count=1;*/

$branch_id=$_SESSION['branch'];
$family_code=$_REQUEST['code'];
$sessionIDs=$_SESSION['current_session'];
$month=date("m");

 
if($_REQUEST['CodeCell']=="FamilyCode"){

  $sql="SELECT student_id, first_name, last_name, cell_no, class_id, candidate_roll_no, section_id, session_id, family_code FROM edu_student_details WHERE family_code='$family_code' and branch_id='$branch_id' and status='0' /*and session_id='$sessionIDs'*/ ";

  } else {

    $sql="SELECT student_id, first_name, last_name, cell_no, class_id, candidate_roll_no, section_id, session_id, family_code FROM edu_student_details WHERE cell_no='$family_code' and branch_id='$branch_id' and status='0' /*and session_id='$sessionIDs'*/ ";
  }
//print_r($sql);


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

 foreach($WorkAssignListings as $WorkAssignListVal)
      { 

        $studendtID=$WorkAssignListVal['student_id'];

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

          $param = array('std_tution_fee','std_misc_fee','std_transport_fee','discount','discount_reason');
       $fees = $m->get("eduportal_student_fee_structure",null,$param);

//echo $WorkAssignListVal['student_id'];
          //print_r($fees);
         $show_fee=0;
         $misc_fee=0;

        if(count($fees)>0){
         
         $show_fee=$fees[0]['std_tution_fee'];
         $misc_fee=$fees[0]['std_misc_fee'];
         
        }else {

         $m->where("class_id", $WorkAssignListVal['class_id']);
         $fees1=$m->get("eduportal_class_fee_details");

          $param = array('tution_fee','misc_fee');
          $fees = $m->get("eduportal_class_fee_details",null,$param);

         $show_fee=$fees1[0]['tution_fee'];
         $misc_fee=$fees1[0]['misc_fee'];


        }


        ?>
      <input type="hidden" name="stdID[]" value="<?php echo $WorkAssignListVal['student_id'];?>">
    
      
      
    
      <tr style="padding:10px;">  

         <td>
          <input type="text" name="first_name[]" value="<?php echo $WorkAssignListVal['first_name'];?>" style="width: 98%;margin-bottom: 3px;"></td>

         <td>
          <input type="text" name="last_name[]" value="<?php echo $WorkAssignListVal['last_name'];?>" style="width: 98%;"></td>

          <td> <input type="text" name="ClassSection" value="<?php echo getClassName($m,$WorkAssignListVal['class_id']);?> / <?php echo getSectionName($m,$WorkAssignListVal['section_id']);?>" style="width: 98%;" readonly></td>

         <td>
          <input type="text" name="cell_no[]" value="<?php echo $WorkAssignListVal['cell_no'];?>"></td>
         <td>
          <input type="text" name="family_code[]" value="<?php echo $WorkAssignListVal['family_code'];?>" style="width: 65px;"></td>

          <td>
          <input type="text" name="tutionfee[]" value="<?php echo $show_fee;?>" style="width: 65px;"></td>

          <td>
          <input type="text" name="transportfee[]" value="<?php echo $fees[0]['std_transport_fee'];?>" style="width: 65px;"></td>

          <td>
          <input type="text" name="misc_fee[]" value="<?php echo $misc_fee;?>" style="width: 65px;"></td>

          <td>
          <input type="text" name="discount[]" value="<?php echo $fees[0]['discount'];?>" style="width: 65px;"></td>

          <td>
          <input type="text" name="discount_reason[]" value="<?php echo $fees[0]['discount_reason'];?>" style=""></td>
                 
        <!--  <td><?php echo getClassName($m,$WorkAssignListVal['class_id']);?></td>         
         <td><?php echo getMonthName($m,$familyfees[0]['month_id'])?></td> -->

          

                 
      </tr>




<?php 


 }  ?>


</table>
<br>
<button id="send" type="submit" style="float: right;" class="btn btn-success" >Update Records</button>
</form>


<?php  } ?>
<br><br>
  

  </div>
  <div class="clearfix"></div>
</section>            
    

           
          </div>
        </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
  
   <!-- jQuery -->
    <script src="js/ajax_functions.js"></script>  
    
  <?php include('RootMe/js_linksscript.php');?>


    <!-- searchable dropdown -->
    
    <link href="autosearch_select/select2.css" rel="stylesheet">
    <link href="autosearch_select/select2-default.css" rel="stylesheet">
    <script src="autosearch_select/select2.min.js"></script>
    
   <script>
    $(function() {
    $('.chosen-select').select2( { width:'100%', maximumSelectionSize: 1 } );
    $(document).ready(function() {
    $(".chosen-multi-select").select2( { width:'100%', } ); }); }); function slideout(){ setTimeout(function(){
    $(".alert-success").fadeOut("slow", function () { });
    $(".alert-danger").fadeOut("slow", function () { }); }, 4000);}
    </script>

  </body>
</html>
