 <?php
 ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once"labClass.php";
$con=new labClass();
$sdate = $_POST['sdate'];
$chkp= $con->getOthersourceEntrymoneyR($sdate); 
?>
 <div class="container mt-3" style="margin-top:2px;">

 <div  class="mt-4 p-5 bg-white text-dark rounded" >
  <h6>Register money from other source here:</h6> 
     <sub id="dis"></sub>
    <div class="row">
    <div class="col">
       <div class="form-floating mb-3 mt-3"> 
        <h6>Description:</h6>
        <select class="form-select" onchange="var dn = $('#dn').val(); if(dn=='Other'){$('#descrip').show();}else{$('#descrip').hide();}" style="width:100%;" id="dn" name="dn" onchange="getDriver();"> <option value="">Select</option> <?php $cp= $con->getDreveva();  if ($cp->rowCount()>0) { $c=$cp->fetchAll(); foreach ($c as $key => $r) { ?> <option value="<?php echo $r['descrip'];?>"><?php echo $r['descrip'];?></option> <?php } }?>
         <option value="Other">Other</option>
         </select>
      <input type="text" style="display:none;width:100%; height:40px; border-radius:12px; border-color:white;" id="descrip" placeholder="Description:" name="descrip" required>
        
    </div>
     <sup class="text-danger" id="in"> </sup>
</div>
 <div class="col">
       <div class="form-floating mb-3 mt-3"> 
        <h6>Amount:</h6>
      <input type="number" style="width:100%; height:40px; border-radius:12px; border-color:white;" id="tPrice" placeholder="Amount:" name="tPrice" required>
       
     <sup class="text-danger" id="q"> </sup>
    </div>
  </div>
<div class="col-sm justify-content-center">

  <div class="form-floating mb-3 mt-3"> 
  <button type="submit" id="submit" value="Submit" name="submit" class="btn btn-primary" style="height:60px;" onclick="saveData()">Submit</button>

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

</div>
 </div>
   <small><h6>Other source entry report:</h6></small>
  <table class="table"><tr>
      <td style="width:30%;"> Select driver here: <select class="form-select" style="width:100%;" id="acN" name="acN" onchange="getDriver();"> <option value="">Select</option> <?php $cp= $con->getDreveva();  if ($cp->rowCount()>0) { $c=$cp->fetchAll(); foreach ($c as $key => $r) { ?> <option value="<?php echo $r['descrip'];?>"><?php echo $r['descrip'];?></option> <?php } }?> </select></td> 
  <td style="width:30%;">Sort by date range: <input type="date" style="width:200px;" class="form-control" id="dat1" name="dat1"  value="<?php echo Date("Y-m-d");?>" >
  </td>
  <td>and: 
          <input type="date" style="width:100%;" class="form-control" id="dat2" name="dat2" value="<?php echo Date("Y-m-d");?>">
  </td><td style="width:30%;">  
  <button type="submit" class="btn btn-primary" style="width:40%; height:40px;" onclick="var sdate=$('#sdate').val(); var dat1=$('#dat1').val(); var dat2=$('#dat2').val();  $.post('othersourcemoneyentryRBdt.php',{sdate:sdate,dat1:dat1,dat2:dat2},function(data){$('#dispR').html(data).show();});">Generate</button>
 </td>  
 
 </tr>
 </table>  
<div id="dispR">
   <?php
  require_once "othersourcemoneyentryR.php";
  ?>
  
</div>
  <button type="submit" class="btn btn-primary" style="width:30%; height:40px;" onclick="printPageArea();">Print</button>
 <script>
 

 
function saveData(){ 
var ecc=0; 
var descrip =document.getElementById('dn').value;
if(descrip=='Other'){
  var descrip =document.getElementById('descrip').value;  
}
$.trim(descrip);
var user =document.getElementById('user').value; 
$.trim(user);
var submit =document.getElementById('submit').value;
var tprice =document.getElementById('tPrice').value; 
var sdate =document.getElementById('sdate').value; 
var vN =/[\(A-Za-z)]/g; 

var nV =/[a-z\s]/i;
  var j=0,k=0, g=0,i=0;
//FIRST NAME VALIDATION
 
  
if(tprice==""){ 

         ecc++;
             document.getElementById('q').innerHTML="Amount is required!..";
 

               }
else{

document.getElementById('q').innerHTML="";
    }
     
if(descrip==""){ 

         ecc++;
             document.getElementById('in').innerHTML="Description is required!..";
 

               }
else{

document.getElementById('in').innerHTML="";
    }
  
    if(ecc==0)
    { 
        $.post("othersourcemoneypro.php",
          {submit:submit,user:user,descrip:descrip,tprice:tprice,sdate:sdate},
          function(data){
      $('#dis').html(data).show();

    });
    }
  document.getElementById('descrip').value='';
  document.getElementById('tPrice').value='';
} 
 function printPageArea(){
    var printContent = document.getElementById('co').innerHTML;
    var originalContent = document.body.innerHTML;
    document.body.innerHTML = printContent;
    window.print();
    document.body.innerHTML = originalContent;
}
 function getDriver(){ 
     var dr=$('#acN').val(); var sdate=$('#sdate').val(); alert(acN); $('#dpl').empty(); $.post('othersourceonlyonedr.php',{dr:dr,sdate:sdate},function(data){ $('#dpl').html(data);}); //$('#acN').hide();
     }
</script>