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

 $branch=$_SESSION['branch'];
    
     $session1;
      if($_REQUEST['session']!=NULL){

       $session1=$_REQUEST['session'];
     }else {
       $session1=$_SESSION['current_session'];
     }

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

       $m->where("status", '0');
       $m->where("branch_id", $_SESSION['branch']);
       $m->where("student_id", $_REQUEST['student']);
       $WorkAssignListVal = $m->get("edu_student_details");

      }
     // print_r($WorkAssignListVal)

      $m->where("student_id", $WorkAssignListVal[0]['student_id']);
      /*$m->where("class_id", $WorkAssignListVal[0]['class_id']);*/
      $m->where("session_id", $_SESSION['current_session']);
      $m->where("branch_id", $_SESSION['branch']);
      $details2 = $m->get("eduportal_student_fee_structure");
 
      

  // settings month details

    $default;
    
    if($_GET["month"]!=NULL ){
      $default= $_GET["month"];
    }
    else{
      $default= date("m");
    }
  
      $m->where("Month_Id", $default);
      $month_name=$m->get("eduportal_month_config");

       $date;
    
    if($_GET["date"]!=NULL ){
      $date= $_GET["date"];
    }
    else{
      $date= date("Y-m-d");
    }
 
     ?>

<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Add Revenue | EduPortal</title>
    <?php include('RootMe/css_links.php');?>

<style>

.thStyle{background-color:gray;color:white;}

tr th {padding:1.5%;border:1px solid white;}
tr td {padding:1%;}

@media only screen and (max-width: 768px) {

/* For mobile phones: */
.popup_style{margin-top:20%;}

}
</style>   
  </head>
  
<script>
function showResult1(str) {
  if (str.length==0) { 
    document.getElementById("livesearch1").innerHTML="";
    document.getElementById("livesearch1").style.border="0px";
    return;
  }
  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 (this.readyState==4 && this.status==200) {
      document.getElementById("livesearch1").innerHTML=this.responseText;
      document.getElementById("livesearch1").style.border="1px solid #A5ACB2";
      //alert(this.responseText);
    }
  }
  xmlhttp.open("GET","live_search_revenue.php?q="+str,true);
  xmlhttp.send();
}
</script>

<script type="text/javascript">

function HideDate(str){
  
  if(str=="1"){
    
    document.getElementById("studentName").style.display="block";
    document.getElementById("col3").style.display="block";
   
  }
  else {
    
    document.getElementById("studentName").style.display="none";
    document.getElementById("col3").style.display="none";
   
   
  }
}

</script>


 <!-- jQuery -->
    <script src="js/ajax_functions.js"></script>  
  <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;">
      
        <div class="panel panel-default">
             <div class="panel-heading" id="std_section">
      

                 
          



<div class="panel-body">

<div class="container">
  <div class="row">

   <div class="col-md-11" style="background-color: white;">

      <!-- Nav tabs -->
      <div class="card">
             

                <!-- Tab panes -->
                <div class="tab-content">





<div >
<form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe1.php" method="post" enctype="multipart/form-data">

  <?php if(!isset($_GET['id'])){?> 
  
       <input type="hidden" name="action" value="AddRevenue" />
       <input type="hidden" name="student" value="<?php echo $_REQUEST['student'];?>" />
       <input type="hidden" name="class_id" value="<?php echo $WorkAssignListVal[0]['class_id'];?>" />
 <?php } else { ?>

        <input type="hidden" name="action" value="Update_RevenueBill" />
        <input type="hidden" name="id"  value="<?php echo $_GET['id'];?>">

<?php } ?>
   



<h3 style="text-align:left;margin-top:2%;margin-left:1.3%;"> Add Income / Revenue </h3>

        <div class="row">


                  <div class="col-md-2 col-xs-6" style="padding: 8px;">

                     <div class="form-group ">

                        <label class="required">Choose option</label>
                            <select name="stdOther" id="stdOther" onChange="HideDate(this.value);" class="form-control"  required>

                                   <option value="">Select</option>
                                   <option <?php if($_REQUEST['paid']=="Cash"){echo "Selected";} ?> value="1">Student</option>
                                   <option <?php if($_REQUEST['paid']=="Check"){echo "Selected";} ?> value="0">Other's</option>
                               
                            </select>
                        </div>


                </div>


                <div class="col-md-4 col-xs-6" id="studentName" style="padding: 8px;margin-top: 24px;<?php if(isset($_REQUEST['studentName']) && $_REQUEST['stdOther']=='1') { echo 'display:block;';}else {echo 'display:none;';} ?>">

                <select name="student" id="student" data-placeholder="Select" class="chosen-multi-select inputfield form-control" >
                    <option value="">Select Student</option>

                    <?php

                    $session123=$_SESSION['current_session'];
                    $branch123=$_SESSION['branch'];

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

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

                    foreach($WorkAssignList as $WorkAssignListVal)

                    { ?>
                      
                       <option value="<?php echo $WorkAssignListVal['student_id']; ?>"><?php echo $WorkAssignListVal['first_name']." | ".$WorkAssignListVal['last_name']." | ".$WorkAssignListVal['cell_no']." | ".$WorkAssignListVal['candidate_roll_no']." | ".$WorkAssignListVal['ref_no']." | ".$WorkAssignListVal['family_code']; ?></option>

                            <?php
                    } ?>

                </select>
               </div>

               
               
                   <div class="col-md-2 col-xs-6" style="padding: 8px;">

                     <div class="form-group ">

                        <label class="required">Paid By</label>
                            <select name="paidBy" id="paidBy" class="form-control"  required>

                                   <option value="">Select</option>
                                   <option <?php if($_REQUEST['paid']=="Cash"){echo "Selected";} ?> value="Cash">Cash</option>
                                   <option <?php if($_REQUEST['paid']=="Check"){echo "Selected";} ?> value="Check">Check</option>
                               
                            </select>
                        </div>


                </div> 

               <div class="col-md-2 col-xs-6" style="padding: 8px;">
               <div class="form-group ">

                  <label class="required"> Paid Date</label>
                      <input name="paidDate" id="paidDate" value="<?php echo $date;?>" type="date" class="form-control"  required>      
                  </div>
              </div>

              <div class="col-md-2 col-xs-6" style="padding: 8px;margin-top: 22px;">
             
              <input  class="add-row btn btn-success" name="pronam" type="button" value="Add Row" />
           

              </div>

               

      </div>  <!-- ending row-->     

        <div class="row">
              
    <table id="mytable" class="table table-striped table-bordered"style="background-color: white;" >
                      <thead>
                        <tr>

                           
                            <th width="30%">  Revenue Head  </th>
                            <th width="20%">   Amount  </th>
                            <th width="50%">   Remarks  </th>
                                   
                          </tr>
                      </thead>
                       <tbody>
     
<?php for ($i=0;$i<1;$i++){ 

// now getting order details to update 

if(isset($_GET['id'])){
  $qry="select * from eduportal_revenue_details where revenue_id =".$_GET['id'];
  $Data = $m->query($qry);

// getting product details 


}

?>    

<?php if (!isset($_GET['id'])) { ?>
  

          
          <tr>

            
            <td id="pro_row">   
            <select name="revenue_head[]" id="revenue_head" class="form-control"  required>

                                      <option value="">Select </option>
                                

                                <?php
                                $m->where("branch_id", $_SESSION['branch']);
                                $WorkAssignList = $m->get("eduportal_revenue_heads");
                                foreach($WorkAssignList as $WorkAssignListVal)
                                { ?>

                                   <option <?php if($Data[0]['revenue_head_id']==$WorkAssignListVal['revenueHead_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['revenueHead_id']; ?>"><?php echo $WorkAssignListVal['revenue_head']; ?></option>


                                        <?php
                                } ?>

                            </select> 
                            
              
              </td>
            

            <td>  <input class="form-control"  value="<?php echo $Data[0]['amount']; ?>" min="0" name="amount[]" 
            id="cotton_pcs<?php echo $i;?>" type="text" />  </td>


            <td>  

             <input class="form-control" name="remarks[]"
             id="remarks<?php echo $i;?>"  value="<?php echo $Data[0]['remarks']; ?>"  type="text" /> 

           

             </td>
            
            
          </tr>

 <?php } else { 


    foreach($Data as $DataRevenue)
      {
?>
                <tr>

            
            <td id="pro_row">   
            <select name="revenue_head[]" id="revenue_head" class="form-control"  required>

                                      <option value="">Select </option>
                                

                                <?php
                                $WorkAssignList = $m->get("eduportal_revenue_heads");
                                foreach($WorkAssignList as $WorkAssignListVal)
                                { ?>

                                   <option <?php if($DataRevenue['revenue_head_id']==$WorkAssignListVal['revenueHead_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['revenueHead_id']; ?>"><?php echo $WorkAssignListVal['revenue_head']; ?></option>


                                        <?php
                                } ?>

                            </select> 
                            
              
              </td>
            

            <td>  <input class="form-control"  value="<?php echo $DataRevenue['amount']; ?>" min="0" name="amount[]" 
            id="cotton_pcs<?php echo $i;?>" type="text" />  </td>


            <td>  

             <input class="form-control" name="remarks[]"
             id="remarks<?php echo $i;?>"  value="<?php echo $DataRevenue['remarks']; ?>"  type="text" /> 

           

             </td>
            
            
          </tr>



<?php  
 } } } ?>    


   </tbody>
                    </table>

                    <input  type="submit"style="font-size:18px; float: right;"  value="Submit" class="btn btn-success">
    </div>   <!--  ending 12 column-->


    </form>
</div>

          

             </table>

</div>


                    </div>
                    



                </div>
      

      </div>

       </div> <!-- col 9 -->
  </div>
</div>  <!-- container -->


    <br><br>

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

            </div>
          </div>
        </div>
        <!-- /page content -->
      
  <?php include('RootMe/js_linksscript.php');?>

    
    <script type="text/javascript">
        $(document).ready(function(){
            $(".add-row").click(function(){
                
                var pro;

                $.ajax({url: "get_revenue_head.php", success: function(result){
                    
                    //alert(result);
                    
                var markup = "<tr><td>"+result+"</td><td><input class='form-control' name='amount[]' id='cotton' type='number' /></td><td><input class='form-control' name='remarks[]' id='qty' type='text' /></td></tr>";
                $("#mytable tbody").append(markup);
              
              
                  }});


              /*  var name = $("#name").val();
                var email = $("#email").val();
              */
              
            });
            
            // Find and remove selected table rows
            $(".delete-row").click(function(){
                $("table tbody").find('input[name="record"]').each(function(){
                  if($(this).is(":checked")){
                        $(this).parents("tr").remove();
                    }
                });
            });
        });    
    </script>


    <!-- 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>
