<? require_once('functions.php');
$type='BACK OFFICE';
$wage= $_SESSION['wage'];
        $name=$_SESSION['name'];
 $id= $_SESSION['id'];

//echo $name;
Permission($_SESSION['department'],$type);?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US"><head><!-- Created by Artisteer v4.0.0.58475 -->
        <meta charset"utf-8">
        <title>Issue Date</title>
        <!--<meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">-->
        <meta name="HandheldFriendly" content="True"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
        <meta name="HandheldFriendly" content="true" />
        <meta name="MobileOptimized" content="true" />

        <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
        <link rel="stylesheet" href="style.css" media="screen">
        <!--[if lte IE 7]><link rel="stylesheet" href="style.ie7.css" media="screen" /><![endif]-->
        <link rel="stylesheet" href="style.responsive.css" media="all">

<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="data/tables.min.css" />
<script type="text/javascript" src="data/data.min.js"></script>
<script type="text/javascript" src="data/data.bootstrap.min.js"></script>
        <script src="jquery.js"></script>
        <script src="script.js"></script>
        <script src="script.responsive.js"></script>
        <meta name="description" content="NEURO DATA">
        <meta name="keywords" content="EZ-SACCO">
		
<script type="text/javascript" src="datepicker.js"></script>
      
        <link href="datepicker.css" rel="stylesheet" type="text/css" />
		
<script type="text/javascript">
//<![CDATA[

/*
        A "Reservation Date" example using two datePickers
        --------------------------------------------------

        * Functionality

        1. When the page loads:
                - We clear the value of the two inputs (to clear any values cached by the browser)
                - We set an "onchange" event handler on the startDate input to call the setReservationDates function
        2. When a start date is selected
                - We set the low range of the endDate datePicker to be the start date the user has just selected
                - If the endDate input already has a date stipulated and the date falls before the new start date then we clear the input's value

        * Caveats (aren't there always)

        - This demo has been written for dates that have NOT been split across three inputs

*/

function makeTwoChars(inp) {
        return String(inp).length < 2 ? "0" + inp : inp;
}

function initialiseInputs() {
        // Clear any old values from the inputs (that might be cached by the browser after a page reload)
        document.getElementById("sd").value = "";
        document.getElementById("ed").value = "";

        // Add the onchange event handler to the start date input
        datePickerController.addEvent(document.getElementById("sd"), "change", setReservationDates);
}

var initAttempts = 0;

function setReservationDates(e) {
        // Internet Explorer will not have created the datePickers yet so we poll the datePickerController Object using a setTimeout
        // until they become available (a maximum of ten times in case something has gone horribly wrong)

        try {
                var sd = datePickerController.getDatePicker("sd");
                var ed = datePickerController.getDatePicker("ed");
        } catch (err) {
                if(initAttempts++ < 10) setTimeout("setReservationDates()", 50);
                return;
        }

        // Check the value of the input is a date of the correct format
        var dt = datePickerController.dateFormat(this.value, sd.format.charAt(0) == "m");

        // If the input's value cannot be parsed as a valid date then return
        if(dt == 0) return;

        // At this stage we have a valid YYYYMMDD date

        // Grab the value set within the endDate input and parse it using the dateFormat method
        // N.B: The second parameter to the dateFormat function, if TRUE, tells the function to favour the m-d-y date format
        var edv = datePickerController.dateFormat(document.getElementById("ed").value, ed.format.charAt(0) == "m");

        // Set the low range of the second datePicker to be the date parsed from the first
        ed.setRangeLow( dt );
        
        // If theres a value already present within the end date input and it's smaller than the start date
        // then clear the end date value
        if(edv < dt) {
                document.getElementById("ed").value = "";
        }
}

function removeInputEvents() {
        // Remove the onchange event handler set within the function initialiseInputs
        datePickerController.removeEvent(document.getElementById("sd"), "change", setReservationDates);
}

datePickerController.addEvent(window, 'load', initialiseInputs);
datePickerController.addEvent(window, 'unload', removeInputEvents);

//]]>
</script>

<!--sa error trapping-->
<script type="text/javascript">
function validateForm()
{
var x=document.forms["amort"]["date"].value;
if (x==null || x=="")
  {
  alert("you must enter the Commencement Date(click the calendar icon)");
  return false;
  }

}
</script>
        <script type="text/javascript">
            function showUser(str)
            {
                if (str == "")
                {
                    document.getElementById("txtHint").innerHTML = "";
                    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 (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                    {
                        document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
                    }
                }
                xmlhttp.open("GET", "./search/contributionsearch.php?q=" + str, true);
                xmlhttp.send();
            }
        </script>
        <script type="text/javascript">
            function showUser(str)
            {
                
                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp = new XMLHttpRequest();
                }
                else
                {// code for IE6, IE5
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange = function()
                {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                    {
                        document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
                    }
                }
                xmlhttp.open("GET", "./search/nsearch.php?q=" + str, true);
                xmlhttp.send();
            }
            function showser(str)
            {
                
                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp = new XMLHttpRequest();
                }
                else
                {// code for IE6, IE5
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange = function()
                {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                    {
                        document.getElementById("txtHin").innerHTML = xmlhttp.responseText;
                    }
                }
                xmlhttp.open("GET", "./search/nsearch.php?q=" + str, true);
                xmlhttp.send();
            }
        </script>    
		
        <!-- SimpleTabs -->
        <script type="text/javascript" src="js/simpletabs_1.3.js"></script>
		<script>
			function zi(){
			f=Number(document.tpc.prev.value);
			h=Number(document.tpc.cur.value);
			
			n=h-f;
  document.tpc.unts.value=n.toFixed(2);			
			}
			</script>
			<script>
			function calc(){
			p=Number(document.tpc.unts.value);
			k=Number(document.tpc.price.value);
			
			l=p*k;
  document.tpc.per.value=l.toFixed(2);			
			}
			</script>
			<script>
			function fin(){
			t=Number(document.tpc.arrear.value);
			o=Number(document.tpc.per.value);
			s=Number(document.tpc.maint.value);
			j=t+o+s;
  document.tpc.amnt.value=j.toFixed(2);			
			}
			</script>
        <style type="text/css" media="screen">
            @import "css/simpletabs.css";
        </style>
    </head>
    <body>
        <div id="art-main">
          
            <nav class="art-nav clearfix">
                <?php
$type='BACK OFFICE';

Permission($_SESSION['department'],$type);

				headermenu($_SESSION['department'],'BACK OFFICE'); ?> 
            </nav>
			<style>
			.button-3 {
  appearance: none;
  background-color: #2ea44f;
  border: 1px solid rgba(27, 31, 35, .15);
  border-radius: 6px;
  box-shadow: rgba(27, 31, 35, .1) 0 1px 0;
  box-sizing: border-box;
  color: #fff;
  cursor: pointer;
  display: inline-block;
  font-family: -apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  padding: 6px 16px;
  position: relative;
  text-align: center;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  vertical-align: middle;
  white-space: nowrap;
  
}

.button-3:focus:not(:focus-visible):not(.focus-visible) {
  box-shadow: none;
  outline: none;
}

.button-3:hover {
  background-color: #2c974b;
}

.button-3:focus {
  box-shadow: rgba(46, 164, 79, .4) 0 0 0 3px;
  outline: none;
}

.button-3:disabled {
  background-color: #94d3a2;
  border-color: rgba(27, 31, 35, .1);
  color: rgba(255, 255, 255, .8);
  cursor: default;
}

.button-3:active {
  background-color: #298e46;
  box-shadow: rgba(20, 70, 32, .2) 0 1px 0 inset;
}
			</style>
			<script type="text/javascript">
let l, d, c,t,m;

function bml() {
  l = Number(document.tpc.amnt.value);
  d = Number(document.tpc.mont.value);

  if (l <= 5000) {
    c = l * 9 * d;
    t=c/100;
    m=t*d;
  } else if (l > 5000 && l <= 15000) {
    c = l * 7 * d;
     t=c/100;
     m=t*d;
  } else if (l > 15000 && l <= 30000) {
    c = l * 4.5 * d;
     t=c/100;
  } else if (l > 30000 && l <= 45000) {
    c = l * 3.5 * d;
     t=c/100;
      m=t*d;
  } else {
    c = l * 3 * d;
     t=c/100;
      m=t*d;
  }

  document.tpc.tpy.value = t.toFixed(2);
   document.tpc.fn.value = m.toFixed(2);
}
</script>
            <div class="art-sheet clearfix">
                <div class="art-layout-wrapper clearfix">
                    <div class="art-content-layout">
                        <div class="art-content-layout-row">
                          
                            <div class="art-layout-cell art-content clearfix">
                                <article class="art-post art-article">
                                    <h2 class="art-postheader"><span class="art-postheadericon"></span></h2>

                                    <!------form start----->
                                 
                                    <div class="art-content-layout">
                                        <div class="art-content-layout-row">
                                            <div class="art-layout-cell" style="width: 100%" >
                                               
                                                                    
					<form action="lon.php" class="row g-3" method="post" name="tpc" id="fr" >
																	<div class="col-md-6"><label class="form-label"><b>Name</b></label>
			<input type="text" class="form-control" name="name" value="<?php echo strtoupper($name); ?>" ></div>
																
                                                    
													<div class="col-md-6"><label class="form-label"><b>Salary</b></label>  
                                           <input type="text"class="form-control" name="salary"value="<?php echo $wage; ?>"   required="required"/></div>
												  <input type="hidden"  name="id"value="<?php echo $id; ?>">
												          	<div class="col-md-6"><label class="form-label"><b>Applied Date</b></label>  
                                           <input type="date" class="form-control" name="date" required/></div>
													<div class="col-md-6"><label class="form-label"><b>Requested Amount</b></label>  
                                           <input type="text" class="form-control" name="amnt"   id="amnt" ></div>
                                           
											<div class="col-md-6"><label class="form-label"><b>Number Of Months</b></label>  
                                           <input type="text" class="form-control" name="mont"  onkeyup="bml()"></div>
                                   
                                           	<div class="col-md-6"><label class="form-label"><b>Amount To Per Month</b></label>  
                                           <input type="text" class="form-control" name="tpy"  id="tpy"></div>
                                           	<div class="col-md-6"><label class="form-label"><b>Final Amount To Pay</b></label>  
                                           <input type="text" class="form-control" name="fn"  id="fn"></div>
											
<div class="two"><button type="submit" name="submit">Record</button>&nbsp;&nbsp;

	<input type="hidden" name="submitted" value="TRUE"/>	
</form>	
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div align="center"> <fieldset style="border-width: 3px;">
<? echo $_SESSION['ERR'];?>
					<legend style="font-family:Bell Gothic,Verdana,Arial"><b>Applied Loan Record</legend>
  <div class="center">
    <table cellpadding="4" cellspacing="0" 
						style="font-family:Bell Gothic,Verdana,Arial" border="1" cellspacing="0" cellpadding="0" style="border-color:#000000;background-color:#cc8022;border-width:thin;">
      <tr>
        
        <td width="10%"><div align="center"><strong>Staff Name</strong></div></td>
		<td width="10%"><div align="center"><strong>Loan Amount </strong></div></td>
	
        
        <td width="10%"><div align="center"><strong>Inception Date</strong></div></td>
		<td width="10%"><div align="center"><strong>Due Date</strong></div></td>
		<td width="10%"><div align="center"><strong>Total Amount</strong></div></td>
		<td width="10%"><strong>Cancel</td>

      </tr>
	  <?php
	  $session= $_SESSION['f'];
   $dbc=mysqli_connect("localhost","gurudumu_bazuu2","@@karishop@@2023!!","gurudumu_pos");
// $f=$_SESSION['MEMBER'];
//echo $session;
$result = mysqli_query($dbc,("SELECT * from lones where sessio='$session'"));

while($row = mysqli_fetch_array($result))
  {
      echo '<tr>';
 
		echo '<td><div align="left">&nbsp;&nbsp;'.$row['name'].'</div></td>';
        echo '<td><div align="center">'.$row['tpy'].'</div></td>';

        echo '<td><div align="center">'.($row['dat']).'</div></td>';
		 echo '<td><div align="center">'.$row['datt'].'</div></td>';
		  //  echo '<td><div align="center">'.$row['tax'].'</div></td>';
        echo '<td><div align="right">';
		$fg=$row['tpy'];
		echo $fg;
		echo '&nbsp;&nbsp;</div></td>';
	
		echo '&nbsp;&nbsp;</div></td>';
		
        echo '<td>';
		echo '<a href=delete_loan.php?id=' . $session .'>Remove</a>';
		echo '</td>';
      echo '</tr>';
	  
	  }
	    echo '<tr>';
     //   echo '<td colspan="3"><b><center>TOTAL</td>';
	
  

		
    //echo '<td><div align="center"><b>'.round($fg).'</div></td>';
	
		echo '&nbsp;&nbsp;</div></td>';
		
      
      echo '</tr>';

mysqli_close($dbc);
?>
    </table>
	</form>
   <form action="loan_note.php" method="post">
	  <table id="header" width="100" border="0" cellpadding="0" cellspacing="0"><tr>
	  <td ><input style="height: 44px; width: 210px; cursor:pointer;" name="submit" type="submit" value="PRINT NOTE"></tr>

 
  
    <br />
	
	<div align="right">
	
  
    <br />
	
	<div align="right">
	</body>


</html>
<table width="100%" height="-5%" cellspacing="0" border="0">
                                    <div class="art-content-layout">
                                        <div class="art-content-layout-row">
                                            <div class="art-layout-cell" style="width: 100%" >
                                            </div>
                                        </div>
                                    </div>

                                </article></div>
                        </div>
                    </div>
                </div><?php footer(); ?>

            </div>
        </div>


    </body></html>