<?php 
session_start();
ob_start();
$idauto= $_SESSION['user_idd'];
include('../include/config.php');
if($_SESSION['user_idd']=='' || $_SESSION['user_idd']==null)
{
//header("location:../");  
}
$ye='';
$ta='';
$namba='';
$date = new DateTime("now", new DateTimeZone('Africa/Nairobi') );
$timenow=$date->format('Y-m-d H:i:s');
$timenow2=$date->format('Y-m-d');
$month=$date->format('F');
$year=$date->format('Y');

//$que = mysqli_query($con,"UPDATE Gradpayment SET Grad='PP2' WHERE Year='2023'");
////////////////////////////////////////////////////Dont Delete this
$lastentered = mysqli_query($con,"select * from Fees2 order by id DESC Limit 1");
while($row = $lastentered->fetch_assoc()) 
{
$ye=$row["Year"];
$ta=$row["Term"];
}

$yea=substr($ye, 2,2);
 
if($ta=='Term One')
{
    $namb=$yea.'01';
}else if($ta=='Term Two')
{
   $namb=$yea.'02'; 
}else if($ta=='Term Three')
{
    $namb=$yea.'03';
}

//$que = mysqli_query($con,"UPDATE Fees2 SET AutoNa='$namb' WHERE Year='$ye' AND Term='$ta'");
///////////////////////////////////////////////////////////End


//$querysql = mysqli_query($con,"DELETE FROM payment WHERE Year='2023' AND Month='November'");

$posi='';
$sqll = "select * FROM Staffs where id='$idauto'";
$result = $con->query($sqll);
while($row = $result->fetch_assoc()) 
{
$posi=$row["Position"]; 
}
if($posi=='Teacher')
{
 header("location:Exams.php?page=Home"); 
}


//Working code to udate multiple rows data in one table from another table
//$result = mysqli_query($con,"SELECT * FROM Fees2 where Year='2024' AND Term='Term One' AND Grad='GRADE 6'");
//$num_rows1 = mysqli_num_rows($result);
//{
//$count=htmlentities($num_rows1); 
//}
//for($i=0;$i<$count;$i++)
//{
//$query=mysqli_query($con,"SELECT * FROM Fees2 where Year='2024' AND Term='Term One' AND Grad='GRADE 6'");
//while($row=mysqli_fetch_array($query))
//{
//$tra=$row['TranF'];
//$pid=$row['pid']; 

//$querysql = mysqli_query($con,"UPDATE Fees2 SET TranF='$tra' where Year='2024' AND Term='Term Two' AND pid='$pid'");
//}
//}
  // 
//$sql=mysqli_query($con,"UPDATE prodata SET proid='4' WHERE EntryDate='2024-03-01'");
// $sql=mysqli_query($con,"UPDATE Imprest2 SET Cate='33' where Cate='3'");


if(isset($_POST["submit_file"]))
{
 $file = $_FILES["file"]["tmp_name"];
 $file_open = fopen($file,"r");
 while(($csv = fgetcsv($file_open, 1000, ",")) !== false)
 {
$name = $csv[0];
$adm  = addslashes($csv[1]);
$cont = $csv[2];
$claz = 'BABY CLASS';
  //$disa = $csv[4];
  //$bo = $csv[5];
  //$loc = $csv[6];
 $sql=mysqli_query($con,"INSERT INTO pupils(Names,Claz,Contact,AdmNo) values('$name','$claz','$cont','$adm')");
 }
 }
 
//$query=mysqli_query($con,"INSERT INTO TourPayment(pid,Tid,Amount,Bank,User,Month,Year,Term,RNo,EntryDate,Dat) 
//SELECT Stud,Tuwa,Amount,Bank,User,Month,Year,Tam,Details,Entrydate,Date FROM Otherincome WHERE Otherincome.Cat='8'");


?>
 <html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>BKEC | Accounting System </title>
   <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
  <!-- SweetAlert2 -->
  <link rel="stylesheet" href="../plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css">
  <link rel="stylesheet" href="../plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="../plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <link rel="stylesheet" href="../plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
  <!-- Toastr -->
  <link rel="stylesheet" href="../plugins/toastr/toastr.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  
  <link rel="stylesheet" href="../dist/css/adminlte.min.css">
    <link rel="stylesheet" href="../plugins/icheck-bootstrap/icheck-bootstrap.min.css">
  <link rel="stylesheet" href="../plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
  <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker.css">
  <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  <link rel="shortcut icon" href="../images/logo.ico">
  
 <script	src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="schedule/js/bootstrap.min.js"></script>

  <style>
  
     body{
         font-family:Spectral;
     }
      .bigger{
          font-size:16px;
          font-family:Tahoma;
      }
      .budget{
          font-size:11px;
      }
      
      .budget:hover{
          color:green;
      }
      .divscroll{
          overflow-y: scroll;
      }
      .farmamount
      {
          font-size:18px;
          color:red;
      }
      .requireds
      {
          color:red;
      }
      #tablefarmincome
      {
       font-size:14px;   
      }
      #tablebankdata
      {
          font-size:14px;
      }
      #idmonthincome
      {
          font-size:14px;
          font-family:Robot;
      }
       #tablebusdata
      {
         font-size:12px;
      }
      #tablestaffsss, #incomeanalysis
      {
          font-size:13px;
          font-family:Tahoma;
      }
      
      #tableexpenditure
      {
          font-size:13px;
      }
      
      .incomeperclasstable
      {
          font-size:14px;
      }
      
      .bstaffedit{
          font-size:10px;
      }
      
      .btnstafdelete{
          font-size:10px;
      }
      
      .side{
          box-shadow: 0 0 0 10px #4fc3dc44,
	0 0 50px #4fc3dc, 0 0 100px #4fc3dc;
	border-radius: 5px;
      }
      
      
	 .fc-dayGridMonth-button{
        font-size:10px;
    }
    
    .fc-dayGridWeek-button{
        font-size:10px;
    }
    
    .fc-list-button{
        font-size:10px;
    }
    
    .fc-today-button{
        font-size:10px;
    }
    
    .fc-prev-button{
        font-size:11px;
    }
    
    .fc-next-button{
        font-size:11px;
    }
    #exeimprest
    {
        font-size:12px;
        font-family:Tahoma;
    }
    #tabletour{
        font-family:Spectral;
        font-size:12px;
    }
    .titles{
        font-size:11px;
    }
    .tablesummary tr td{
        border:1px solid #000;
    }
    #tableexams{
        font-size:12px;font-family:Spectral;
    }
    
     #paidby{
        font-size:12px;
    }
      
  </style>
  
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
   
<link rel="stylesheet" href="schedule/fullcalendar/lib/main.min.css">
<script src="schedule/fullcalendar/lib/main.min.js"></script>
</head>
<body class="hold-transition sidebar-mini layout-fixed">
 <div class="wrapper">
     
  <?php
   if(isset($_GET['page']))
    {
     $pg=$_GET['page'];
    if($pg != '' || $pg != 'index.php')
    {
  include('../include/head.php');
  include('../include/sidebar1.php');
    }
    }
  ?>
  <!-- Preloader -->
 <?php
    if(isset($_GET['page']))
    {
    $pg=$_GET['page'];
    if($pg=='Profile')
    {
       include('myprofile.php');
    }
    else
    {
    ?>
    <script>
    window.location.href='../';
    </script>
    <?php
    // header("location:../index.php");
    }
    }
    ?> 
  
 <?php
  include('modals/Modalstaffs.php');
  include('../include/footer.php');
  ?>
  
   <input type="hidden" value="<?php echo $_SESSION['name']; ?>" id="sessionholder" />
  
 <div class="modal" id="modalregstaffs">
        <div class="modal-dialog modal-lg">
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title">Large Modal</h4>
              
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              <p>One fine body&hellip;</p>
            </div>
            <div class="modal-footer justify-content-between">
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              <button type="button" class="btn btn-primary">Save changes</button>
            </div>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>
  
  
  </div>
  
 <script src="../plugins/jquery/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="//plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button)
</script>
<!-- Bootstrap 4 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script src="tinymce/tinymce.min.js"></script>
<!-- ChartJS -->
<script src="../plugins/chart.js/Chart.min.js"></script>
<!-- Sparkline -->
<script src="./plugins/sparklines/sparkline.js"></script>
<!-- JQVMap -->
<script src="../plugins/jqvmap/jquery.vmap.min.js"></script>
<script src="../plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
<!-- jQuery Knob Chart -->
<script src="../plugins/jquery-knob/jquery.knob.min.js"></script>
<!-- daterangepicker -->
<script src="../plugins/moment/moment.min.js"></script>
<script src="../plugins/daterangepicker/daterangepicker.js"></script>
<!-- Tempusdominus Bootstrap 4 -->


<script src="../plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Summernote -->
<script src="../plugins/summernote/summernote-bs4.min.js"></script>
<!-- overlayScrollbars -->
<script src="../plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.js"></script>
<!-- AdminLTE for demo purposes -->
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="../dist/js/pages/dashboard.js"></script>

 <script src="scripts/jquery-2excel.js"></script>

<!--Data tables -->
<script src="../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="../plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<script src="tinymce/tinymce.min.js"></script>


<script>
$(document).ready(function() {
$('#btn-down-data').on('click', function(e)
{
    $("#tablebankdata").table2excel({
    exclude: ".leavethiss",
    name: "Data",
    filename: "Overall performance",
});
});
});
</script>



<script>
$(document).ready(function() {
$('#btnenroll').on('click', function(e)
{
    $("#tableenrollmentt").table2excel({
    exclude: ".leavethis",
    name: "Data",
    filename: "Classes Enrollment",
});
});
});
</script>



<script>
$(document).ready(function() {
$('#down').on('click', function(e)
{
    $("#tsummary").table2excel({
    exclude: ".leavethis",
    name: "Data",
    filename: "Overall performance",
});
});
});
</script>

<script>
  $(function () {
    $("#tableenrollmentt").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": true,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divenrollmentt .col-md-6:eq(0)');
  });
</script>


<script>
  $(function () {
    $("#staffemails").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": true,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divincomeanysis .col-md-6:eq(0)');
  });
</script>
<script>
  $(function () {
    $("#incomeanalysis").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": true,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divincomeanysis .col-md-6:eq(0)');
  });
</script>


<script>
  $(function () {
    $("#tableexpen").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#table-r .col-md-6:eq(0)');
  });
</script>

<script>
  $(function () {
    $("#divactivity").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": true,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divtableact .col-md-6:eq(0)');
  });
</script>

<script>
  $(function (){
    $("#tablestaffsss").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": true,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divstaffss .col-md-6:eq(0)');
  });
</script>

<script>
  $(function (){
    $("#tablact").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": true,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divstaffss .col-md-6:eq(0)');
  });
</script>

<script>
  $(function () {
    $("#exeimprest").DataTable({
      "responsive": false, "lengthChange": true, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divimp .col-md-6:eq(0)');
    
    $('#').DataTable({
      "paging": true,
      "lengthChange": true,
      "searching": true,
      "ordering": true,
      "info": true,
      "autoWidth": true,
      "responsive": true,
    });
  });
</script>



<script>
  $(function () {
    $("#tablact").DataTable({
      "responsive": true, "lengthChange": true, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divtableact .col-md-6:eq(0)');
    
    $('#tablebusdat').DataTable({
      "paging": true,
      "lengthChange": true,
      "searching": true,
      "ordering": true,
      "info": true,
      "autoWidth": true,
      "responsive": true,
    });
  });
</script>

 <script>
  $(function () {
    $("#tableactivity").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('# .col-md-6:eq(0)');
    $('#tableactivity').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "responsive": true,
    });
  });
</script>

<script>
  $(function () {
    $("#tablebusdata").DataTable({
      "responsive": false, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divbus .col-md-6:eq(0)');
    
    $('#tablebusdat').DataTable({
      "paging": true,
      "lengthChange": true,
      "searching": true,
      "ordering": true,
      "info": true,
      "autoWidth": true,
      "responsive": true,
    });
  });
</script>

<script>
  $(function () {
    $("#tabletour").DataTable({
      "responsive": false, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divbus .col-md-6:eq(0)');
  });
</script>

<script>
  $(function () {
    $("#tablefarmincome").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divbus .col-md-6:eq(0)');
  });
</script>

<script>
  $(function () {
    $("#tablemails").DataTable({
      "responsive": false, "lengthChange": false, "autoWidth": false,
      "buttons": ["csv"]
    }).buttons().container().appendTo('#divbus .col-md-6:eq(0)');
  });
</script>

<script>
  $(function () {
    $("#tabledatacash").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#tabproject .col-md-6:eq(0)');
  });
</script>

 <script>
        $(document).ready(function () 
        {
        $('#filtersasa').on('click', function()
        {
        var mon1 = document.getElementById('monn1').value;
        var mon2 = document.getElementById('monn2').value;
        if(mon1=='' || mon2=='')
        {
         alert('You must select both dates');
        }else
        {
         window.location.href="index.php?page=Expenses&d1="+mon1+"&d2="+mon2;
        }
        });
        });
</script>

<script>
        $(document).ready(function () 
        {
        $('#incomecateg').on('change', function()
        {
        var pid=this.value;
        if(pid !='')
        {
         
         window.location.href="linkincomecate.php?id="+pid;  
         // $.ajax({
         // url:"getincomecategory.php",
         //  method:"POST",
          // data:{id:pid},
          // dataType:"json",
          /// success:function(data)
           //{
           // $('#source').val(data.Item);
          // }
         // });  
            
            
         //document.getElementById('source').value=pid; 
         
         
        }else
        {
          document.getElementById('source').value='';
        }
        });
        });
</script>

<script>
$(document).ready(function (e) 
{
$("#addincomess").click(function()
{ 
$('#modalothericome').modal('show'); 
});
});
</script>


 <script>
        $(document).ready(function () {
            $("#linkdown").click(function (e) {
                e.preventDefault();
                window.location.href 
                    = "../files/application.docx";
            });
        });
</script>

<script>
    $(document).ready(function() 
     {
     $("body").on("click", ".dele", function(){  
     var currentRow = $(this).closest("tr");
     var id = currentRow.find(".gradataid").val();
     let text = "Are you sure you want to remove this payment?";
     if (confirm(text) == true) 
     { 
      $.ajax({
           url:"removegrad.php",
           method:"POST",
           data:{gid:id},
           success:function(data)
           {
            if(data=='success')
            {
            alert('Graduation data successfully deleted');
            setInterval(function ()
            {
             window.location.href="index.php?page=Graduation";
            }, 1000);   
            }else
            {
            alert(data);
            setInterval(function ()
            {
          //  window.location.href="index.php?page=Other_Earning";
            }, 2000);    
            }
           }
          });
     }
       });   
    });
  </script>

<script>
    $(document).ready(function() 
     {
     $("body").on("click", ".deletegraddata", function(){  
     var currentRow = $(this).closest("tr");
     var id = currentRow.find(".gid").val();
     let text = "Are you sure you want to remove this data?";
     if (confirm(text) == true) 
     { 
      $.ajax({
           url:"removegrad.php",
           method:"POST",
           data:{id:id},
           success:function(data)
           {
            if(data=='success')
            {
            alert('Graduation data successfully deleted');
            setInterval(function ()
            {
             window.location.href="index.php?page=Graduations";
            }, 1000);   
            }else
            {
            alert(data);
            setInterval(function ()
            {
          //  window.location.href="index.php?page=Other_Earning";
            }, 2000);    
            }
           }
          });
     }
       });   
    });
  </script>


 <script>
        $(document).ready(function () 
        {
         $('#selectAll').click(function(e){
        var table= $(e.target).closest('table');
        $('td input:checkbox',table).prop('checked',this.checked);
         }); 
        }); 
         
        
        $(document).ready(function () 
        {
        $("body").on("click", "#subemail", function(){ 
        var sub=document.getElementById('subj').value;
        var mess=document.getElementById('mainmess').value;
        //var rece=document.getElementById('receivers').value;
        var sess=document.getElementById('txtsession').value;
        var rece='';
        
        $('.row-select input:checked').each(function() {
        var id;
        id = $(this).closest('tr').find('.staffsid').val();
          $.ajax({
              
           url:"saveemails.php",
           method:"POST",
           data:{id:id,sub:sub,mess:mess,rece:rece,sess:sess},
           success:function(data)
           {
            if(data=='success')
            {
            $('#feedbackemails').html('Emails sent successfully').css('color', 'green');
            
            setInterval(function ()
            {
              window.location.href="index.php?page=Emails"  
              //$('#feedbackemails').html('').css('color', 'green');
            }, 2000);   
            }else
            {
             $('#feedbackemails').html(data).css('color', 'red');    
                
            //alert(data);
            //setInterval(function ()
            //{
          //  window.location.href="index.php?page=Other_Earning";
           // }, 2000);    
            }
           }
          });
        
        
        });
     
        });
        });
</script>


 <!--Remove system user --> 
<script>
    $(document).ready(function() 
     {
     $("body").on("click", ".empremove", function(){  
     var currentRow = $(this).closest("tr");
     var id = currentRow.find(".useridholding").val();
     let text = "Are you sure you want to remove this data?";
     if (confirm(text) == true) 
     { 
      $.ajax({
           url:"removeuser.php",
           method:"POST",
           data:{id:id},
           success:function(data)
           {
            if(data=='success')
            {
            alert('Staff successfully removed as a user');
            setInterval(function ()
            {
             window.location.href="index.php?page=users";
            }, 1000);   
            }else
            {
            alert(data);
            setInterval(function ()
            {
          //  window.location.href="index.php?page=Other_Earning";
            }, 2000);    
            }
           }
          });
     }
       });   
    });
  </script>

<script>
$(document).ready(function (e) 
{
$("#savebudgett").submit(function()
{ 

 var pe=document.getElementById('periodd').value;
 var item=document.getElementById('itemmm').value;
 var yr=document.getElementById('selectyear').value;
 var bgt=document.getElementById('budgetamt').value;
 
});
});
</script>


<script>
       $(document).ready(function() 
       {
        $("#btnsavegraduation").click(function()
        {
        var tou = document.getElementById('txttour').value;
        var dat = document.getElementById('txtdate').value; 
        var amt = document.getElementById('txtamount').value; 
        var bnk = document.getElementById('txtbank').value;
        var rno = document.getElementById('txtreceipt').value;
        var pid = document.getElementById('stuidd').value;
        var trm = document.getElementById('txtterm').value;
        
        
         if(tou=='' || pid==''  || dat=='' || amt=='' || trm=='')
         {
            $('#otherincomemsg').html("Fill all the mandatory fields").css('color', 'red');
            setInterval(function ()
            {
            $('#otherincomemsg').html("").css('color', 'red');
            }, 2000);    
         }else
         {
           $.ajax({
           url:"savegraduation.php",
           method:"POST",
           data:{tid:tou,dat:dat,amt:amt,bnk:bnk,rno:rno,pid:pid,trm:trm},
           success:function(data)
           {
            if(data=='success')
            {
                $('#otherincomemsg').html("Successfully saved").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Graduation";
                }, 2000);   
            }else
            {
             $('#otherincomemsg').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#otherincomemsg').html("").css('color', 'red');
            
                }, 2000);    
            }
           }
          });
    }
    });
       }); 
  </script>



<script>
$(document).ready(function(){ 
$("#closemymodal").click(function()
{ 
('#modalstaffsedit').modal('hide');
});
});
</script>


 <script>
        $(document).ready(function () 
        {
        $('#btnfilters').on('click', function()
        {
        var pe = document.getElementById('perio').value;
        var yr = document.getElementById('yeah').value;
        if(pe=='' || yr=='')
        {
         alert('You must select both Yeah and Period');
        }else
        {
         window.location.href="filterreportperiod.php?period="+pe+"&year="+yr;
        }
        });
        });
</script>


 <script>
        $(document).ready(function () 
        {
        $('#selectcategory').on('change', function()
        {
        var tu=this.value;
        window.location.href="index.php?page=Staffs&Cat="+tu;
        });
        });
</script>

<script>
        $(document).ready(function () 
        {
        $('#txtgrads').on('change', function()
        {
        var tu=this.value;
    
        window.location.href="index.php?page=Graduation&Select="+tu;
        });
        });
</script>

 <script>
        $(document).ready(function () 
        {
        $('#txttoursclass').on('change', function()
        {
         var cla=this.value;
         var tu=document.getElementById('txttours').value;
         
         if(tu=='')
         {
             alert('You must select Tour-name first');
             this.value='';
         }else
         {
           window.location.href="index.php?page=Tour_Payment&Tour="+tu+"&claz="+cla;
         }
        });
        });
</script>

<script>
$(document).ready(function (e) 
{
 $("body").on("click", ".deletetourpayment", function()
 { 
    var currentRow=$(this).closest("tr"); 
    var id = currentRow.find(".toidd").val();  
    let text = "Are you sure you want to delete this entry?";
     
  if (confirm(text) == true)
  {
       $.ajax({
      url:"savetouramt.php",
       method:"POST",
       data:{did:id},
       success:function(data)
       {
        if(data=='success')
        {
        $('#otherincomemsg').html('Record deleted successfully').css('color', 'red'); 
        setInterval(function ()
        {
        window.location.href='index.php?page=Tour_Payment';
        }, 3000);
        }
        else
        {
        $('#otherincomemsg').html(data).css('color', 'red'); 
        
        setInterval(function ()
        {
        $('#otherincomemsg').html('').css('color', 'red');
        }, 2000);
        } 
       }
       });
 }
      
 });
  });
</script>


<script>
       $(document).ready(function() 
       {
        $("#submitgraddata").click(function()
        {
        var tit = document.getElementById('gtit').value;
        var dat = document.getElementById('gdate').value; 
        var clas = document.getElementById('gclaz').value; 
        var tdes = document.getElementById('gdes').value;
        var fee = document.getElementById('gfee').value;
         if(tit=='' || dat=='')
         {
            $('#otherincomemsg').html("Fill all the mandatory fields").css('color', 'red');
            
            setInterval(function ()
            {
            $('#otherincomemsg').html("").css('color', 'red');
            }, 2000);    
         }else
         {
           $.ajax({
           url:"savegraduationdata.php",
           method:"POST",
           data:{tit:tit,dat:dat,clas:clas,tdes:tdes,fee:fee},
           success:function(data)
           {
            if(data=='success')
            {
                $('#otherincomemsg').html("Successfully saved").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Graduations";
                }, 2000);   
            }else
            {
             $('#otherincomemsg').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#otherincomemsg').html("").css('color', 'red');
            
                }, 2000);    
            }
           }
          });
    }
    });
       }); 
  </script>


<script>
       $(document).ready(function() 
       {
        $("#submittourdata").click(function()
        {
        var tit = document.getElementById('tourtit').value;
        var dat = document.getElementById('tourdate').value; 
        var dat2 = document.getElementById('tourdate2').value; 
        var tdes = document.getElementById('tourdesc').value;
     
         if(tit=='' || dat=='')
         {
            $('#otherincomemsg').html("Fill all the mandatory fields").css('color', 'red');
            
            setInterval(function ()
            {
            $('#otherincomemsg').html("").css('color', 'red');
            }, 2000);    
         }else
         {
           $.ajax({
           url:"savetourdata.php",
           method:"POST",
           data:{tit:tit,dat:dat,dat2:dat2,tdes:tdes},
           success:function(data)
           {
            if(data=='success')
            {
                $('#otherincomemsg').html("Successfully saved").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Tours";
                }, 2000);   
            }else
            {
             $('#otherincomemsg').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#otherincomemsg').html("").css('color', 'red');
            
                }, 2000);    
            }
           }
          });
    }
    });
       }); 
  </script>


<script>
       $(document).ready(function() 
       {
        $("#btnsavetouramt").click(function()
        {
        var tou = document.getElementById('txttour').value;
        var dat = document.getElementById('txtdate').value; 
        var amt = document.getElementById('txtamount').value; 
        var bnk = document.getElementById('txtbank').value;
        var rno = document.getElementById('txtreceipt').value;
        var pid = document.getElementById('stuidd').value;
        var trm = document.getElementById('txtterm').value;
        
         if(tou=='' || pid==''  || dat=='' || amt=='' || trm=='')
         {
            $('#otherincomemsg').html("Fill all the mandatory fields").css('color', 'red');
            
            setInterval(function ()
            {
            $('#otherincomemsg').html("").css('color', 'red');
            }, 2000);    
         }else
         {
           $.ajax({
           url:"savetouramt.php",
           method:"POST",
           data:{tid:tou,dat:dat,amt:amt,bnk:bnk,rno:rno,pid:pid,trm:trm},
           success:function(data)
           {
            if(data=='success')
            {
                $('#otherincomemsg').html("Successfully saved").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Tour_Payment";
                }, 2000);   
            }else
            {
             $('#otherincomemsg').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#otherincomemsg').html("").css('color', 'red');
            
                }, 2000);    
            }
           }
          });
    }
    });
       }); 
  </script>


<script>
       $(document).ready(function() 
       {
        $("#btnfilterpayable").click(function()
        {
        var cat = document.getElementById('TCat').value; 
        var yr = document.getElementById('Tyr').value; 
        var trm = document.getElementById('Ttrm').value;
       /// var grd = document.getElementById('Tgrad').value;
      
        var grd='';
         if(cat=='' || yr==''  || trm=='')
         {
            $('#labelcatmsg').html("Select all the fields kindly").css('color', 'red');
            
            setInterval(function ()
            {
            $('#labelcatmsg').html("").css('color', 'red');
            }, 2000);    
         }else
         {
           window.location.href="filtercat.php?Cat="+cat+"& Yr="+yr+"& Trm="+trm+"& Grd="+grd;  
        }
    });
       }); 
  </script>


<script>
$(document).ready(function (e) 
{
 $("body").on("click", ".expedelete", function()
 { 
    var currentRow=$(this).closest("tr"); 
    var id = currentRow.find(".expecountholder").val();  
    let text = "Are you sure you want to delete this Imprest record?";
     
  if (confirm(text) == true)
  {
  
       $.ajax({
      url:"managexpenses.php",
       method:"POST",
       data:{id:id},
       success:function(data)
       {
        if(data=='success')
        {
        $('#dellabel').html('Record deleted successfully').css('color', 'red'); 
        setInterval(function ()
        {
        window.location.href='index.php?page=Expenses';
        }, 3000);
        }
        else
        {
        $('#dellabel').html(data).css('color', 'red'); 
        
        setInterval(function ()
        {
        $('#dellabel').html('').css('color', 'red');
        }, 2000);
        } 
       }
       });
 }
      
 });
  });
</script>



<script>
$(document).ready(function (e) 
{
$("#modalimprestitems").submit(function()
{ 
 $('#expefeedback').html('').css('color', 'red'); 
 var tit=document.getElementById('itemu').value;

if(tit=='')
{
$('#expefeedback').html("You MUST enter expenses item").css('color', 'red');
  setInterval(function ()
    {
      $('#expefeedback').html('').css('color', 'red');
    }, 2500);
}else{
    $.ajax({
    url:"managexpenses.php",
    method:"POST",
    data:{tit:tit},
    success:function(data)
    {
        
    if(data=='success')
    {
     $('#expefeedback').html('Item saved successfully').css('color', 'green'); 
      setInterval(function ()
    {
      $('#expefeedback').html('').css('color', 'red');
     window.location.href='index.php?page=Expenses';
    }, 3000);
    }
    else
    {
    $('#expefeedback').html(data).css('color', 'red'); 
    
     setInterval(function ()
    {
      $('#expefeedback').html('').css('color', 'red');
    }, 2000);
    }
      },
     error: function() 
      {
      $('#expefeedback').html(e).css('color', 'red');
      }          
    });
}
});
});
   </script>

<script>
$(document).ready(function (e) 
{
$("#addimpitems").click(function()
{ 
$('#modalimprestitems').modal('show'); 
});
});
</script>
  
  
 <script>
$(document).ready(function (e) 
{
$("#savebudge").click(function()
{ 
 var pe=document.getElementById('perioholder').innerHTML;
 var item=document.getElementById('labelitemm').innerHTML;
 var id=document.getElementById('itemuid').value;
 //var yr=document.getElementById('selectyear').value;
 var bgt=document.getElementById('budgeta').value;
 
 if(bgt=='')
{
  $('#budgetlabeel').html("Fill all entry fields").css('color', 'red');
  setInterval(function ()
    {
      $('#budgetlabeel').html('').css('color', 'red');
    }, 2500);
}else{
    $.ajax({
   url:"savebudgetedamount.php",
    method:"POST",
    data:{pe:pe,item:item,id:id,bgt:bgt},
    success:function(data)
    {
    if(data=='success')
    {
     $('#budgetlabeel').html('Amount successfully saved').css('color', 'green'); 
      setInterval(function ()
    {
      $('#budgetlabeel').html('').css('color', 'red');
     window.location.href='index.php?page=Income-Expenses';
    }, 3000);
    }
    else
    {
    $('#budgetlabeel').html(data).css('color', 'red'); 
    
     setInterval(function ()
    {
      $('#budgetlabeel').html('').css('color', 'red');
    }, 2000);
    }
      },
     error: function() 
      {
      $('#budgetlabeel').html(e).css('color', 'red');
      }          
    });
}


});
  });
 </script>

<script>
       $(document).ready(function() 
       {
        $("#btnuserdataupdate").click(function()
        {
        var id = document.getElementById('useridholderedit').value;
        var lev = document.getElementById('emplevel').value; 
        var aces = document.getElementById('systemacess').value; 

         if(lev=='' || aces==''  )
         {
            $('#mesage').html("All fields must be filled").css('color', 'red');
            
            setInterval(function ()
            {
            $('#mesage').html("").css('color', 'red');
            }, 3500);  
         }else
         {  
         $.ajax({
           url:"updateusersacessdata.php",
           method:"POST",
           data:{id:id,lev:lev,aces:aces},
           success:function(data)
           {    
            if(data=='success')
            {
                $('#mesage').html("Update successful").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=users";
                }, 2000);   
            }else
            {
             $('#mesage').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#mesage').html("").css('color', 'red');
            
                }, 2000);    
            }
           } 
           });
         }
    });
       }); 
  </script>


 <script>
    $(document).ready(function() 
     {
     $("body").on("click", ".deleteotherincome", function(){  
     var currentRow = $(this).closest("tr");
     var id = currentRow.find(".otid").val();
     
     let text = "Are you sure you want to remove this data?";
     if (confirm(text) == true) 
     { 
      $.ajax({
           url:"removeotherincome.php",
           method:"POST",
           data:{id:id},
           success:function(data)
           {
            if(data=='success')
            {
            alert('Record successfully deleted');
            setInterval(function ()
            {
            window.location.href="index.php?page=Other_Earning";
            }, 1000);   
            }else
            {
            alert(data);
            setInterval(function ()
            {
            window.location.href="index.php?page=Other_Earning";
            }, 2000);    
            }
           }
          });
     }
       });   
    });
  </script>


<script>
$(document).ready(function (e) 
{
 $("body").on("click", ".inckamdelete", function()
 { 
    var currentRow=$(this).closest("tr"); 
    var countt = currentRow.find(".incomecountholder").val();  
    let text = "Are you sure you want to delete this income category?";
     
  if (confirm(text) == true)
  {
       $.ajax({
      url:"managexpenses.php",
       method:"POST",
       data:{countt:countt},
       success:function(data)
       {
        if(data=='success')
        {
        $('#incomefeedbackk').html('Record deleted successfully').css('color', 'red'); 
        setInterval(function ()
        {
        window.location.href='index.php?page=Other_Earning';
        }, 3000);
        }
        else
        {
        $('#incomefeedbackk').html(data).css('color', 'red'); 
        
        setInterval(function ()
        {
        $('#incomefeedbackk').html('').css('color', 'red');
        }, 2000);
        } 
       }
       });
 }
      
 });
  });
</script>


<script>
       $(document).ready(function() 
       {
        $("#btnsaveincomecategory").click(function()
        {
        var item = document.getElementById('incomeinput').value;
        var cost= document.getElementById('incomecost').value;
         if(item=='')
         {
            $('#incomefeedbackk').html("Fill all the mandatory fields").css('color', 'red');
            
            setInterval(function ()
            {
            $('#incomefeedbackk').html("").css('color', 'red');
            }, 3500);  
         }else
         { 
         $.ajax({
          url:"saveincomecate.php",
           method:"POST",
           data:{item:item,cost:cost},
           success:function(data)
           {    
            if(data=='success')
            {
                $('#incomefeedbackk').html("Details saved successfully").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Other_Earning";
                }, 2000);   
            }else
            {
             $('#incomefeedbackk').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#incomefeedbackk').html("").css('color', 'red');
            
                }, 2000);    
            }
           } 
           });
         }
    });
       }); 
  </script>





<script>
       $(document).ready(function() 
       {
        $("#btnsaveincomess").click(function()
        {
        var item = document.getElementById('sourcee').value;
        var dat = document.getElementById('otdatee').value; 
        var amount = document.getElementById('otamountt').value; 
        var mod = document.getElementById('otmodee').value;
        var bnk = document.getElementById('otbankk').value;
        var des = document.getElementById('otdescc').value;
        var inf = document.getElementById('otinfoo').value;
        
        var stu = document.getElementById('paidbyy').value;
        var cat = document.getElementById('incomecatii').value;
        var id = document.getElementById('otherincomeidholder').value;  
          
         if(item=='' || dat==''  || amount=='' || mod=='' )
         {
            $('#otherincomemsgg').html("Fill all the mandatory fields").css('color', 'red');
            
            setInterval(function ()
            {
            $('#otherincomemsgg').html("").css('color', 'red');
            }, 3500);  
         }else
         {  
         $.ajax({
           url:"saveotherincome.php",
           method:"POST",
           data:{item:item,dat:dat,amt:amount,mod:mod,bnk:bnk,des:des,inf:inf,idother:id,stu:stu,cat:cat},
           success:function(data)
           {    
            if(data=='success')
            {
                $('#otherincomemsgg').html("Details saved successfully").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Other_Earning";
                }, 2000);   
            }else
            {
             $('#otherincomemsgg').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#otherincomemsgg').html("").css('color', 'red');
            
                }, 2000);    
            }
           } 
           });
         }
    });
       }); 
  </script>
  
  
  <script>
 $(document).ready(function (e) 
{
 $("body").on("click", ".budget", function(){ 
    var currentRow = $(this).closest("tr");
    var id = currentRow.find(".textwithid").val();
    var item = currentRow.find(".cola1").html();
    var jul = currentRow.find(".cola2").html();
    var aug = currentRow.find(".cola3").html();
    var sep = currentRow.find(".cola4").html();
    
    var pe = document.getElementById('periodic').value;
    $('#labelitemm').html(item).css('color', 'red');
    $('#perioholder').html(pe).css('color', 'white');
    document.getElementById('itemuid').value=id;
    
    $.ajax({
          url:"getbudgetamount.php",
           method:"POST",
           data:{pe:pe,id:id},
           dataType:"json",
           success:function(data)
           {
            $('#budgeta').val(data.Amount);
           }
          });
    //c
   $('#modalbudgeted').modal('show');  
 });   
}); 
  </script>
  
  <script>
 $(document).ready(function (e) 
{
 $("body").on("click", ".closee", function(){ 
   $('#modalbudgeted').modal('hide');  
 });   
}); 
  </script>
  
 

  <script>
 $(document).ready(function (e) 
{
    $("body").on("click", ".otheredit", function(){  
         var currentRow = $(this).closest("tr");
         var id = currentRow.find(".otid").val();
         document.getElementById('otherincomeidholder').value=id;
 
          $.ajax({
          url:"getotherincome.php",
           method:"POST",
           data:{id:id},
           dataType:"json",
           success:function(data)
           {
             $('#sourcee').val(data.Particular);
             $('#otdatee').val(data.Date);
             $('#otamountt').val(data.Amount);
             $('#otmodee').val(data.Paymode);
             $('#otbankk').val(data.Bank);
             $('#otdescc').val(data.Details);
             $('#otinfoo').html(data.Description);
             $('#paidbyy').val(data.Stud);
             $('#incomecatii').val(data.Cat);
           }
          });
         $('#modalotherincome').modal('show'); 
    });
});
    </script>

<script>
        $(document).ready(function () 
        {
        $('#pupilselect').on('change', function()
        {
        var pid=this.value;
        var yr = document.getElementById('yea').value;
        var trm = document.getElementById('tam').value;
        
        if(pid !='')
        {
        if(trm=='')
        {
         alert('Term should not be empty');
        }else
        {
        window.location.href="index.php?page=Proforma&Year="+yr+"&JHGHJUXXXYYII*hssyjkoqwwhjkwjloonk="+pid+"&Term="+trm;
        }
        }
        });
        });
</script>

<script>
 $(function(){
  $("#stuidd").select2();
 }); 
</script>

<script>
 $(function(){
  $("#paidby").select2();
 }); 
</script>

<script>
 $(function(){
  $("#pupilselect").select2();
 }); 
</script>

<script>
       $(document).ready(function() 
       {
        $("#btnsaveincomes").click(function()
        {
        var item = document.getElementById('source').value;
        var dat = document.getElementById('otdate').value; 
        var amount = document.getElementById('otamount').value; 
        var mod = document.getElementById('otmode').value;
        var bnk = document.getElementById('otbank').value;
        var des = document.getElementById('otdesc').value;
        var info = document.getElementById('otinfo').value;
        
         var stu = document.getElementById('paidby').value;
         var cat = document.getElementById('incomecati').value;
        
         if(item=='' || dat==''  || amount=='' || mod=='' )
         {
            $('#otherincomemsg').html("Fill all the mandatory fields").css('color', 'red');
            
            setInterval(function ()
            {
            $('#otherincomemsg').html("").css('color', 'red');
            }, 2000);    
         }else
         {
           $.ajax({
           url:"saveotherincome.php",
           method:"POST",
           data:{item:item,dat:dat,amt:amount,mod:mod,bnk:bnk,des:des,info:info,stu:stu,cat:cat},
           success:function(data)
           {
            if(data=='success')
            {
                $('#otherincomemsg').html("Details saved successfully").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Other_Earning";
                }, 2000);   
            }else
            {
             $('#otherincomemsg').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#otherincomemsg').html("").css('color', 'red');
            
                }, 2000);    
            }
           }
          });
    }
    });
       }); 
  </script>
  

 <script>
    $(document).ready(function() 
     {
     $("body").on("click", ".btnstafdelete", function(){  
     var currentRow = $(this).closest("tr");
     var id = currentRow.find(".stafidd").val();
     
     let text = "Are you sure you want to remove this employee?";
     if (confirm(text) == true) 
     { 
      $.ajax({
          url:"removestaff.php",
           method:"POST",
           data:{id:id},
           success:function(data)
           {
            if(data=='success')
            {
            alert('Staff data successfully deleted');
            setInterval(function ()
            {
            window.location.href="index.php?page=Staffs";
            }, 1000);   
            }else
            {
            alert(data);
            setInterval(function ()
            {
            window.location.href="index.php?page=Staffs";
            }, 2000);    
            }
           }
          });
     }
       });   
    });
  </script>
  
  <script>
        $(document).ready(function () 
        {
        $('#yearfilterincome').on('change', function()
        {
        var yr=this.value;
        window.location.href="index.php?page=Income&Year="+yr;
        });
        });
</script>

<script>
        $(document).ready(function () 
        {
        $('#yearfilter').on('change', function()
        {
        var yr=this.value;
        window.location.href="index.php?page=Expenditure&Year="+yr;
        });
        });
</script>


<script>
       $(document).ready(function() 
       {
        $("#btnsavefarminput").click(function()
        {
        var item = document.getElementById('farmitem').value;
        var dat = document.getElementById('farmdate').value; 
        var amount = document.getElementById('farmamount').value; 
        var modd = document.getElementById('farmmod').value;
        var bnk = document.getElementById('farmbnk').value;
        var ftd = document.getElementById('ftd').value;
        
         if(item=='' || dat==''  || amount=='' || modd=='' )
         {
            $('#farmmessage').html("Fill all the mandatory fields").css('color', 'red');
            
            setInterval(function ()
            {
            $('#farmmessage').html("").css('color', 'red');
            }, 2000);    
         }else
         {
           $.ajax({
           url:"savefarmincome.php",
           method:"POST",
           data:{item:item,dat:dat,amt:amount,modd:modd,bnk:bnk,ftd:ftd},
           success:function(data)
           {
            if(data=='success')
            {
                $('#farmmessage').html("Successfully updated").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Farm";
                }, 2000);   
            }else
            {
             $('#farmmessage').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#farmmessage').html("").css('color', 'red');
            
                }, 2000);    
            }
           }
          });
    }
    });
       }); 
  </script>
  
  
  <script>
       $(document).ready(function() 
       {
        $("#btnupdatefarminput").click(function()
        {
        var item = document.getElementById('farmitem2').value;
        var dat = document.getElementById('farmdate2').value; 
        var amount = document.getElementById('farmamount2').value; 
        var modd = document.getElementById('farmmod2').value;
        var bnk = document.getElementById('farmbnk2').value;
        var ftd = document.getElementById('ftd2').value;
        var id = document.getElementById('farmidholder2').value;
        
         if(item=='' || dat==''  || amount=='' || modd=='' )
         {
            $('#farmupdatemsg').html("Fill all the mandatory fields").css('color', 'red');
            
            setInterval(function ()
            {
            $('#farmupdatemsg').html("").css('color', 'red');
            }, 2000);    
         }else
         {
           $.ajax({
           url:"savefarmincome.php",
           method:"POST",
           data:{idup:id,item:item,dat:dat,amt:amount,modd:modd,bnk:bnk,ftd:ftd},
           success:function(data)
           {
            if(data=='success')
            {
                $('#farmupdatemsg').html("Successfully updated").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Farm";
                }, 2000);   
            }else
            {
             $('#farmupdatemsg').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#farmupdatemsg').html("").css('color', 'red');
            
                }, 3000);    
            }
           }
          });
    }
    });
       }); 
  </script>
  
  <script>
 $(document).ready(function (e) 
{
    $("body").on("click", ".farmedit", function(){  
         var currentRow = $(this).closest("tr");
         var id = currentRow.find(".faid").val();
         document.getElementById('farmidholder2').value=id;
         
          $.ajax({
          url:"getfarminputdata.php",
           method:"POST",
           data:{id:id},
           dataType:"json",
           success:function(data)
           {
             $('#farmitem2').val(data.Item);
             $('#farmdate2').val(data.Date);
             $('#farmamount2').val(data.Amount);
             $('#farmmod2').val(data.Paymode);
             $('#farmbnk2').val(data.Bank);
             $('#ftd2').val(data.Details);
             $('#farmuzer').html(data.staname);
           }
          });
         $('#farminputmodal').modal('show'); 
    });
});
    </script>
  
  <script>
    $(document).ready(function() 
     {
     $("body").on("click", ".btnfarmdelete", function(){  
     var currentRow = $(this).closest("tr");
     var id = currentRow.find(".faid").val();
     let text = "Are you sure you want to delete this record?";
     if (confirm(text) == true) 
     { 
       $.ajax({
           url:"savefarmincome.php",
           method:"POST",
           data:{idd:id},
           success:function(data)
           {
        
            if(data=='deleted')
            {
            alert('Entry successfully deleted')
            setInterval(function ()
            {
            window.location.href="index.php?page=Farm";
            }, 1000);   
            }else
            {
            alert(data);
            setInterval(function ()
            {
            window.location.href="index.php?page=Farm";
            }, 2000);    
            }
           }
          });
     }
       });   
    });
  </script>
  
  
<script>
  $(function () {
    $("#incomeperclasstable").DataTable({
      "responsive": true, "lengthChange": true, "autoWidth": true, "info": true, "ordering": true, "paging": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('.divincome2.col-md-6:eq(0)');
  });
</script>  
  

<script>
  $(function () {
    $("#idmonthincome").DataTable({
      "responsive": false, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divincome .col-md-6:eq(0)');
    
    $('#').DataTable({
      "paging": true,
      "lengthChange": true,
      "searching": true,
      "ordering": true,
      "info": true,
      "autoWidth": true,
      "responsive": true,
    });
  });
</script>

<script>
  $(function () {
    $("#tableexpenditure").DataTable({
      "responsive": false, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#divincome .col-md-6:eq(0)');
   
  });
</script>


<script>
 $(document).ready(function (e) 
{
    $("body").on("click", ".changedata", function(){  
          var currentRow = $(this).closest("tr");
          var id = currentRow.find(".useridholding").val();
          document.getElementById('useridholderedit').value=id;
          $.ajax({
           url:"getuserdata.php",
           method:"POST",
           data:{id:id},
           dataType:"json",
           success:function(data)
           {
            $('#emplevel').val(data.Level);
            $('#systemacess').val(data.Aces);
           }
          });
          $('#modaluseredit').modal('show'); 
    });
  });
</script>

<script>
       $(document).ready(function() 
       {
        $("#updateexpenses").click(function()
        {
        var id = document.getElementById('expeidholder').value;
        var cat = document.getElementById('expecatt').value;
        var expdate = document.getElementById('expedatess').value; 
        var parti = document.getElementById('partiii').value; 
        var amount = document.getElementById('expeamountt').value;
        var mod = document.getElementById('paymodee').value;
        var chequ = document.getElementById('chequedee').value;
        var bank = document.getElementById('bankdebitedd').value;
        var dess = document.getElementById('expemoredetailss').value;
     
         if(cat=='' || expdate=='' || parti=='' || amount=='' || mod=='')
         {
            $('#messs').html("Fill all the mandatory fields").css('color', 'red');
            setInterval(function ()
            {
            $('#messs').html("").css('color', 'red');
            }, 2000);    
         }else
         {
           $.ajax({
           url:"saveexpenses.php",
           method:"POST",
           data:{cat:cat,dat:expdate,parti:parti,amt:amount,mod:mod,chequ:chequ,bank:bank,dess:dess,id:id},
           success:function(data)
           {
            if(data=='success')
            {
                $('#messs').html("Successfully updated").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Expenses";
                }, 2000);   
            }else
            {
             $('#messs').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#messs').html("").css('color', 'red');
            
                }, 2000);    
            }
           }
          });
    }
    });
       }); 
  </script>

<script>
 $(document).ready(function (e) 
{
    $("body").on("click", ".expendit", function(){  
         var currentRow = $(this).closest("tr");
         var id = currentRow.find(".expeinputid").val();
         document.getElementById('expeidholder').value=id;
         
          $.ajax({
          url:"getschoolexpenses.php",
           method:"POST",
           data:{id:id},
           dataType:"json",
           success:function(data)
           {
            $('#expecatt').val(data.Cat);
            $('#expedatess').val(data.ExpDate);
            $('#partiii').val(data.Particular);
            $('#expeamountt').val(data.Amount);
            $('#paymodee').val(data.Mode);
            $('#chequedee').val(data.Details);
            $('#bankdebitedd').val(data.Account);
            $('#expemoredetailss').val(data.Description);
            $('#entdate').html(data.EntryDate);
            $('#adby').html(data.uname);
           }
          });
         $('#modalexpenditure').modal('show'); 
    });
    
    $("body").on("click", ".deleteexpenses", function(){  
     var currentRow = $(this).closest("tr");
     var id = currentRow.find(".expeinputid").val();
     
     let text = "Are you sure you want to delete?";
     if (confirm(text) == true) 
     { 
       $.ajax({
           url:"deleteexpenses.php",
           method:"POST",
           data:{id:id},
           success:function(data)
           {
            if(data=='deleted')
            {
            alert('Item successfully deleted')
            setInterval(function ()
            {
            window.location.href="index.php?page=Expenses";
            }, 1000);   
            }else
            {
            alert(data);
            setInterval(function ()
            {
            window.location.href="index.php?page=Expenses";
            }, 2000);    
            }
           }
          });
     }
         
    });
  });
</script>

<script>
       $(document).ready(function() 
       {
        $("#saveexpenses").click(function()
        { 
        var cat = document.getElementById('expecat').value;
        var expdate = document.getElementById('expedates').value; 
        var parti = document.getElementById('parti').value; 
        var amount = document.getElementById('expeamount').value;
        var mod = document.getElementById('paymode').value;
        var chequ = document.getElementById('chequede').value;
        var bank = document.getElementById('bankdebited').value;
        var dess = document.getElementById('expemoredetails').value;
        
         if(cat=='' || expdate=='' || parti=='' || amount=='' || mod=='')
         {
            $('#mes').html("Fill all the mandatory fields").css('color', 'red');
            setInterval(function ()
            {
            $('#mes').html("").css('color', 'red');
            }, 2000);    
         }else
         {
           $.ajax({
           url:"saveexpenses.php",
           method:"POST",
           data:{cat:cat,dat:expdate,parti:parti,amt:amount,mod:mod,chequ:chequ,bank:bank,dess:dess},
           success:function(data)
           {
            if(data=='success')
            {
                $('#mes').html("Successfully Saved").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Expenses";
                }, 2000);   
            }else
            {
             $('#mes').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#mes').html("").css('color', 'red');
            
                }, 2000);    
            }
           }
          });
    }
    });
       }); 
  </script>


<script>
       $(document).ready(function() 
       {
         $("#btnupdatestaffs").click(function(){ 
 
        var sn = document.getElementById('snamee').value;
        var sid = document.getElementById('sidd').value; 
        var gen = document.getElementById('sgenderr').value; 
        var phone = document.getElementById('scontaa').value;
        var edat = document.getElementById('edatt').value;
        var subs = document.getElementById('subss').value;
        var email = document.getElementById('emaill').value;
        var cat = document.getElementById('cattt').value;
        var sta = document.getElementById('selestatus').value;
        var id = document.getElementById('staffidholderone').value;
        
        var nat = document.getElementById('txtnature').value;
        var nhif = document.getElementById('txtnhif').value;
        var nssf = document.getElementById('txtnssf').value;
        var spno = document.getElementById('spno').value;
        
         if(sn=='' || gen=='' || cat=='' || nat=='')
         {
            $('#feedbackstaffsupdate').html("Fill all the mandatory fields").css('color', 'red');
            setInterval(function ()
            {
            $('#feedbackstaffsupdate').html("").css('color', 'red');
            }, 2000);    
         }else
         {
           $.ajax({
           url:"savestaffs.php",
           method:"POST",
           data:{sn:sn,sid:sid,gen:gen,phone:phone,edat:edat,subs:subs,email:email,cat:cat,id:id,nat:nat,nh:nhif,sta:sta,ns:nssf,spno:spno},
           success:function(data)
           {
            if(data=='success')
            {
                $('#feedbackstaffsupdate').html("Staff's details successfully updated").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Staffs";
                }, 2000);   
            }else
            {
             $('#feedbackstaffsupdate').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#feedbackstaffsupdate').html("").css('color', 'red');
                $('#feedbackstaffsupdate').modal('hide');
                }, 2000);    
            }
           }
          });
    }
            //}
    });
       }); 
  </script>

<script>
$(document).ready(function (e) 
{
$("body").on("click", ".bstaffedit", function()
{  
var currentRow = $(this).closest("tr");
var id = currentRow.find(".stafidd").val();
$('#staffidholderone').val(id);
$.ajax({
           url:"getstaffsdata.php",
           method:"POST",
           data:{id:id},
           dataType:"json",
           success:function(data)
           {
            $('#snamee').val(data.Name);
            $('#sidd').val(data.IDNo);
            $('#emaill').val(data.Email);
            $('#sgenderr').val(data.Gender);
            $('#scontaa').val(data.Phone);
            $('#cattt').val(data.Position);
            $('#edatt').val(data.EmpDate);
            $('#subss').val(data.Subs);
            $('#txtnature').val(data.Nature);
            $('#txtnhif').val(data.NHIF);
            $('#txtnssf').val(data.NSSF);
            $('#selestatus').val(data.Status);
            $('#spno').val(data.PRNo);
           }
          });
 $('#modalstaffsedit').modal('show'); 
});
  });
</script>



<script>
$(document).ready(function (e) 
{
$("body").on("click", ".busdelete", function()
{  
var currentRow = $(this).closest("tr");
var id = currentRow.find(".busid").val();

let text = "Are you sure you want to delete this entry?";
  if (confirm(text) == true) {
       $.ajax({
    url:"bussave.php",
    method:"POST",
    data:{idd:id},
    success:function(data)
    {
    if(data=='successful')
    {
        alert('Entry deleted successfully');
       window.location.href="index.php?page=Manage_Bus";
    }
    else
    {
     alert(data);
    }
      },
     error: function() 
      {
      $('#modalmessage1').html(e).css('color', 'red');
      }          
    });
   
  }
});
  });
</script>


<script>
$(document).ready(function (e) 
{
$("#btnbusupdate").click(function()
{
 var bname=document.getElementById('busnoo').value;
 var cost=document.getElementById('hirecostt').value;
 var cont=document.getElementById('recontactt').value;
 var client=document.getElementById('renamee').value;
 var hdate=document.getElementById('hiredatee').value;
 var info=document.getElementById('businfoo').value;
 var hfro=document.getElementById('bfrommm').value;
 var hto=document.getElementById('btooo').value;
 var bk=document.getElementById('busbnkk').value;
 var id=document.getElementById('bushireidholder').value;

 if(bname=='' || cost=='' || cont=='' || hdate=='' || client=='' || hfro=='' )
 {
    $('#bushiremsggg').html('All entry fields must not be empty!').css('color', 'red'); 
    setInterval(function ()
    {
    $('#bushiremsggg').html('').css('color', 'red');
    }, 3000);

 }else
 {
     $.ajax({
        url:"bussave.php",
        method:"POST",
        data:{bid:bname,cost:cost,client:client,dat:hdate,cont:cont,info:info,hfro:hfro,hto:hto,id:id,bk:bk},
        success:function(data)
        {
         var dat=data;
         if(dat=='success')
         {
         $('#bushiremsggg').html('Successfully updated').css('color', 'green'); 
         
         setInterval(function ()
         {
         window.location.href="index.php?page=Manage_Bus";
         }, 2000);
         }else
         {
         $('#bushiremsggg').html(data).css('color', 'red'); 
         
         setInterval(function ()
         {
         window.location.href="index.php?page=Manage_Bus";
         }, 2000);  
         }
        
        }
        });
 }
});
});
</script> 

<script>
 $(document).ready(function (e) 
{
    $("body").on("click", ".busedit", function(){  
         var currentRow = $(this).closest("tr");
         var id = currentRow.find(".busid").val();
         document.getElementById('bushireidholder').value=id;
         
          $.ajax({
           url:"getbusdata.php",
           method:"POST",
           data:{id:id},
           dataType:"json",
           success:function(data)
           {
            $('#busnoo').val(data.busid);
            $('#hiredatee').val(data.Hiredate);
            $('#renamee').val(data.client);
            $('#recontactt').val(data.contact);
            $('#hirecostt').val(data.cost);
            $('#bfrommm').val(data.Hfrom);
            $('#btooo').val(data.Hto);
            $('#businfoo').val(data.Des);
            $('#busbnkk').val(data.Bank);
           }
          });
         $('#modalbusedit').modal('show'); 
    });
  });
</script>


<script>
$(document).ready(function (e) 
{
$("#btnbussaved").click(function()
{
 var bname=document.getElementById('busno').value;
 var cost=document.getElementById('hirecost').value;
 var cont=document.getElementById('recontact').value;
 var client=document.getElementById('rename').value;
 var hdate=document.getElementById('hiredate').value;
 var info=document.getElementById('businfo').value;
 var hfro=document.getElementById('bfromm').value;
 var hto=document.getElementById('btoo').value;
 var bnk=document.getElementById('busbnk').value;
 

 if(bname=='' || cost=='' || cont=='' || hdate=='' || client=='' || hfro=='' )
 {
    $('#bushiremsg').html('All entry fields must not be empty!').css('color', 'red'); 
    setInterval(function ()
    {
    $('#bushiremsg').html('').css('color', 'red');
    }, 3000);

 }else
 {
     $.ajax({
        url:"bussave.php",
        method:"POST",
        data:{bus:bname,cost:cost,client:client,dat:hdate,cont:cont,info:info,hfro:hfro,hto:hto,bk:bnk},
        success:function(data)
        {
         var dat=data;
         if(dat=='success')
         {
         $('#bushiremsg').html('Successfully saved').css('color', 'green'); 
         
         setInterval(function ()
         {
         window.location.href="index.php?page=Manage_Bus";
         }, 2000);
         }else
         {
         $('#bushiremsg').html(data).css('color', 'red'); 
         
         setInterval(function ()
         {
         window.location.href="index.php?page=Manage_Bus";
         }, 2000);  
         }
        
        }
        });
 }
});
});
</script> 

<script>
 $(document).ready(function(){ 
    $("#btnsendmail").click(function()
    { 
        var yesno='';
        var remember = document.getElementById("yessend");
        if (remember.checked)
        {
        yesno='Yes';
        } else {
        yesno='No';
        }
        
        $.ajax({
        url:"emailsendupdate.php",
        method:"POST",
        data:{ans:yesno},
        success:function(data)
        {
        alert(data);
        //$('#updatepassfeedback').html(data).css('color', 'red'); 
        
        // setInterval(function ()
        //{
        // $('#updatepassfeedback').html(data).css('color', 'red');
        // }, 2000);
        
        }
        });
    });
 });
</script>

<script>
  $(document).ready(function(){ 
        $("#btnchangepassword").click(function()
        { 
          $('#updatepassfeedback').html('').css('color', 'red'); 
          $('#updatepassfeedback').html('').css('color', 'green'); 
          var id = document.getElementById('idholder').value;
          var pass = document.getElementById('cpass').value;
          var npass = document.getElementById('newpassword').value;
          var copass = document.getElementById('copass').value;
         
          if(npass == '' || copass == '' || pass == '') 
          {
             $('#updatepassfeedback').html('No entry should be EMPTY!').css('color', 'red'); 
          }else{

           let length = npass.length; 
           if(length < 8)
           {
            $('#updatepassfeedback').html('Password must not be less than 8 characters!').css('color', 'red'); 
           }else{

            if(npass != copass)
           {
           $('#updatepassfeedback').html('New passwords not matching!').css('color', 'red'); 
           }else{
            
                 var ans = confirm('Do you want to change password?');
                if (ans == true) {

                     $.ajax({
                        url:"changepass.php",
                        method:"POST",
                        data:{id:id,npass:npass,pass:pass},
                        success:function(data)
                        {

                          $('#updatepassfeedback').html(data).css('color', 'red'); 
                          
                          if(data=='success')
                          {

                            $('#updatepassfeedback').html('Password change successful').css('color', 'green'); 
                            setInterval(function ()
                            {
                            window.location.href="logout.php";
                            }, 2000);
                          }
                          else if(data=='No match')
                          {
                           $('#updatepassfeedback').html('You have entered wrong current password!').css('color', 'red'); 
                          }else{
                           $('#updatepassfeedback').html(data).css('color', 'red'); 
                          }
                         //window.location.href='Activereport.php?id=data';
                        }
                        });
                }else{
                   
                }
           }
           }
          }
          });
        });
      </script>

<script>
$(document).ready(function (e) 
{
$("#savebanksss").click(function()
{ 

 var name=document.getElementById('inputbnamee').value;
 var aka=document.getElementById('inputactt').value;
 var id=document.getElementById('bankidholder').value;
 var bal=document.getElementById('bnbala').value;
 var bdat=document.getElementById('baladate').value;
 
 $.ajax({
        url:"savebankdata.php",
        method:"POST",
        data:{nam:name,aka:aka,id:id,bal:bal,dat:bdat},
        success:function(data)
        {
         var dat=data;
         if(dat=='success')
         {
         $('#bankmessagee').html('Successfully saved').css('color', 'green'); 
         
         setInterval(function ()
         {
         window.location.href="index.php?page=setup";
         }, 2000);
         }else
         {
         $('#bankmessagee').html(data).css('color', 'red'); 
         
         setInterval(function ()
         {
         window.location.href="index.php?page=setup";
         }, 2000);  
         }
        
        }
        });
 
 
 $('#bankmessagee').html(dat).css('color', 'red'); 
});
});
</script> 

<script>
 $(document).ready(function (e) 
{
    $("body").on("click", ".bankedit", function(){  
           var currentRow = $(this).closest("tr");
           var id = currentRow.find(".bid").val();
           document.getElementById('bankidholder').value=id;
           var bname=currentRow.find("td:eq(1)").text(); 
           var aka=currentRow.find("td:eq(2)").text();
           document.getElementById('inputbnamee').value=bname;
           document.getElementById('inputactt').value=aka;
           
         $.ajax({
          url:"getbankdata.php",
           method:"POST",
           data:{id:id},
           dataType:"json",
           success:function(data)
           {
            $('#bnbala').val(data.Balance);
            $('#baladate').val(data.Dat);
           }
          });
         $('#modaleditbank').modal('show'); 
    });
    });
</script>

<script>
$(document).ready(function (e) 
{
$("#savebanks").click(function()
{ 
$('#compmsg').html('').css('color', 'red'); 
 var name=document.getElementById('inputbname').value;
 var act=document.getElementById('inputact').value;
 
 
if(name=='' || act=='')
{
$('#bankmessage').html("All Bank details must be entered").css('color', 'red');
  setInterval(function ()
    {
      $('#bankmessage').html('.').css('color', 'white');

    }, 2500);

}else{

    $.ajax({
    url:"savebankdata.php",
    method:"POST",
    data:{name:name,act:act},
    success:function(data)
    {
    if(data=='success')
    {
     $('#bankmessage').html('New Bank details added').css('color', 'green'); 

      setInterval(function ()
    {
      $('#bankmessage').html('').css('color', 'red');
       window.location.href='index.php?page=setup';
    }, 2000);
    }
    else
    {
    $('#bankmessage').html(data).css('color', 'red'); 
    
     setInterval(function ()
    {
      $('#bankmessage').html('').css('color', 'red');
    }, 2000);
    }
      },
     error: function() 
      {
      $('#bankmessage').html(e).css('color', 'red');
      }          
    });
}
});

});
   </script>

 <script>
      $(document).ready(function(){ 
        makechart();
	function makechart()
	{
		$.ajax({
			url:"getchart.php",
			method:"POST",
			data:{action:'fetch'},
			dataType:"JSON",
			success:function(data)
			{
				var claz = [];
				var total = [];
				var color = [];

				for(var count = 0; count < data.length; count++)
				{
				claz.push(data[count].claz);
				total.push(data[count].total);
				color.push(data[count].color);
				}

				var chart_data = {
					labels:claz,
					datasets:[
						{  
							label:'Pupils',
							backgroundColor:color,
							color:'#fff',
							data:total
						}
					]
				};

				var options = {
					responsive:true,
					scales:{
						yAxes:[{
							ticks:{
								min:0
							}
						}]
					}
				};

				var group_chart1 = $('#pie_chart');

				var graph1 = new Chart(group_chart1, {
					type:"pie",
					data:chart_data
				});
			
			}
		})
	}
        });
</script>

 <script>
       $(document).ready(function(){ 
          $("#btnsend").click(function()
          {
          var em=document.getElementById('app_opt').value; 
          $.ajax({
          url:"sendmail.php",
           method:"POST",
           data:{em:em},//
           success:function(data)
           {
             if(data=='success')
             {
               $('#rolesmsg').html("Email successfully sent").css('color', 'green');   
                 
             setInterval(function () 
            {
            $('#rolesmsg').html("").css('color', 'green'); 
            }, 3000);
             }else
             {
             $('#rolesmsg').html(data).css('color', 'green');  
             }
           }
          });
        });
        }); 
</script>


<script>
$(document).ready(function (e) 
{
$("#saveschoolinfo").click(function()
{ 
$('#compmsg').html('').css('color', 'red'); 
 var name=document.getElementById('cname').value;
 var loc=document.getElementById('location').value;
 var add=document.getElementById('address').value;
 var con=document.getElementById('contact').value;
 var em=document.getElementById('email').value;
 var mi=document.getElementById('mission').value;
 var vi=document.getElementById('vision').value;
 
if(name=='' || add=='' || con=='' || em=='')
{
$('#orgasavemsg').html("Fill all the fields labelled '*' ").css('color', 'red');
  setInterval(function ()
    {
      $('#orgasavemsg').html('').css('color', 'red');

    }, 2500);

}else{

    $.ajax({
    url:"companydata.php",
    method:"POST",
    data:{name:name,loc:loc,add:add,con:con,em:em,mi:mi,vi:vi},
    success:function(data)
    {
    if(data=='success')
    {
     $('#orgasavemsg').html('Submitted successfully').css('color', 'green'); 

      setInterval(function ()
    {
      $('#orgasavemsg').html('').css('color', 'red');
       window.location.href='index.php?page=setup';
    }, 2000);
    }
    else
    {
    $('#orgasavemsg').html(data).css('color', 'red'); 
    
     setInterval(function ()
    {
      $('#orgasavemsg').html('').css('color', 'red');
    }, 2000);
    }
      },
     error: function() 
      {
      $('#orgasavemsg').html(e).css('color', 'red');
      }          
    });
}
});

});
   </script>


<script>
$(document).ready(function () 
{
$("#adduserbtn").click(function()
{ 
var id=document.getElementById('employee').value;
var lev=document.getElementById('posi').value; 

if(id=='' || lev=='')
{
$('#useraddlabel').html('Fill all the required entries!').css('color', 'red'); 
}else{

$.ajax({
url:"saveuser.php",
method:"POST",
data:{id:id,lev:lev},
success:function(data)
{
var resp=data;
if(resp=='saved')
{
$('#useraddlabel').html("User Successfully added").css('color', 'green');
setInterval(function ()
{
window.location.href="index.php?page=users";
}, 2000);   
}else
{
$('#useraddlabel').html(data).css('color', 'red');
//$('#savefeedbackmodal').modal('show'); 
setInterval(function ()
{
$('#useraddlabel').html("").css('color', 'red');
$('#useraddlabel').modal('hide');
}, 2000);    
}

}
});
}
});

});
</script>



<script>
    $(document).ready(function() 
    {
    $("#seemodal1").click(function(){
      
      $('#modalregstaffs').modal('show'); 
    });
    });
         
</script>         

<script>
       $(document).ready(function() 
       {
         $("#savesataffs").click(function(){ 
        var sn = document.getElementById('sname').value;
        var sid = document.getElementById('sid').value; 
        var gen = document.getElementById('sgender').value; 
        var phone = document.getElementById('sconta').value;
        var edat = document.getElementById('edat').value;
        var subs = document.getElementById('subs').value;
        var email = document.getElementById('email').value;
        var cat = document.getElementById('cat').value;
        var nat = document.getElementById('txtnaturee').value;
        var nhif = document.getElementById('txtnhiff').value;
        var nssf = document.getElementById('txtnssff').value;
        
         if(sn=='' || gen=='' || cat=='' || nat=='')
         {
            $('#feedback1').html("Fill all the mandatory fields").css('color', 'red');
            setInterval(function ()
            {
            $('#feedback1').html("").css('color', 'red');
            }, 2000);    
         }else
         {
         // var result = confirm("Are you sure you want to DELETE this employee PERMANENTLY ?");
          //if (result == true) {
           $.ajax({
           url:"savestaffs.php",
           method:"POST",
           data:{sn:sn,sid:sid,gen:gen,phone:phone,edat:edat,subs:subs,email:email,cat:cat,nat:nat,nh:nhif,ns:nssf},
           success:function(data)
           {
            if(data=='success')
            {
                $('#feedback1').html("New staff has been Successfully added").css('color', 'green');
                setInterval(function ()
                {
                window.location.href="index.php?page=Staffs";
                }, 2000);   
            }else
            {
             $('#feedback1').html(data).css('color', 'red');
                //$('#savefeedbackmodal').modal('show'); 
                setInterval(function ()
                {
                $('#feedback1').html("").css('color', 'red');
                $('#feedback1').modal('hide');
                }, 2000);    
            }
           }
          });
    }
            //}
    });
       }); 
  </script>
  
<?php 
require_once('../include/db_connect.php');
$schedules = $conn->query("SELECT * FROM `schedule_list`");
$sched_res = [];
foreach($schedules->fetch_all(MYSQLI_ASSOC) as $row){
$row['sdate'] = date("F d, Y h:i A",strtotime($row['start_datetime']));
$row['edate'] = date("F d, Y h:i A",strtotime($row['end_datetime']));
$sched_res[$row['id']] = $row;
}
?>
<?php 
if(isset($conn)) $conn->close();
?>

<script src="schedule/js/script.js"></script>

  <script>
 $(document).ready(function (e) 
 {
    setInterval(function ()
    {
      var session = document.getElementById('sessionholder').value;
      if(session=='' || session==null)
      {
        window.location.href='../';
      }
    }, 500);
 });
  </script>  
  
<script>
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>
   
<?php 
require_once('schedule/db-connect.php');

$schedules = $conn->query("SELECT * FROM schedule_list");
$sched_res = [];
foreach($schedules->fetch_all(MYSQLI_ASSOC) as $row)
{
$row['sdate'] = date("F d, Y h:i A",strtotime($row['start_datetime']));
$row['edate'] = date("F d, Y h:i A",strtotime($row['end_datetime']));
$sched_res[$row['id']] = $row;
}
?>
<?php 
if(isset($conn)) $conn->close();
?>

<script>
    var scheds = $.parseJSON('<?= json_encode($sched_res) ?>')
</script>
<script src="schedule/js/scriptt.js"></script>
   </body>
</html>
