<?php
require 'includes/session.inc';
require 'includes/SQL_CommonFunctions.inc';
$e = $_POST['employeeid'];
$t = $_POST['type'];
$row = DB_fetch_array(
  DB_query("SELECT rounded_balance FROM leave_register
            WHERE employeeid='$e' AND type='$t'
            ORDER BY leaveid DESC LIMIT 1")
);
echo json_encode(['opening'=> $row ? (float)$row['rounded_balance'] : 0]);
