<?php

function insmess(){
    
    print '<script type="text/javascript">';
    print 'alert("RECORD ADDED SUCESSFULLY")';
    PRINT '</script>';
}

function updmess()
{
    print '<script type="text/javascript">';
    print 'alert("RECORDS UPDATED SUCESSFULLY")';
    print '</script>';
}

function browse($var)
{
    print '<script type="text/javascript">';
    print 'alert("'.$var.'")';
    print '</script>';
}

function mydt($var)
{
    mysqli_real_escape_string($conn, $var);
    strtotime($var);
    date('Y-m-d',  strtotime($var));
}


function rsword($number)
{
if (($number < 0) || ($number > 999999999))
{
throw new Exception("Number is out of range");
}
$Gn = floor($number / 100000);  /* Millions (giga) */
$number -= $Gn * 100000;
$kn = floor($number / 1000);     /* Thousands (kilo) */
$number -= $kn * 1000;
$Hn = floor($number / 100);      /* Hundreds (hecto) */
$number -= $Hn * 100;
$Dn = floor($number / 10);       /* Tens (deca) */
$n = $number % 10;               /* Ones */
$res = "";
if ($Gn)
{
$res .= rsword($Gn) . " Lacs";
}
if ($kn)
{
$res .= (empty($res) ? "" : " ") .
rsword($kn) . " Thousand";
}
if ($Hn)
{
$res .= (empty($res) ? " " : " ") .
rsword($Hn) . " Hundred";
}
$ones = array("", "One", "Two", "Three", "Four", "Five", "Six",
"Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen",
"Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen",
"Nineteen");
$tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty",
"Seventy", "Eigthy", "Ninety");
if ($Dn || $n)
{
if (!empty($res))
{
$res .= " and ";
}
if ($Dn < 2)
{
$res .= $ones[$Dn * 10 + $n];
}
else
{
$res .= $tens[$Dn];
if ($n)
{
$res .= "-" . $ones[$n];
}
}
}
if (empty($res))
{
$res = "zero";
}
return $res;
}


function delete($mydb, $table, $delfld, $delvar, $file){
    mysqli_select_db($conn, $mydb);
    

    mysqli_query($conn, "DELETE FROM $table WHERE $delfld='$delvar'") or die(mysqli_error($conn));
    header("refresh: 1; $file");
}

function delmulti($mydb, $table, $delcond,$file){
    mysqli_select_db($conn, $mydb);
    

    mysqli_query($conn, "DELETE FROM $table WHERE $delcond") or die(mysqli_error($conn));
    header("refresh: 1; $file");
}


function monthname($month_int) {
$month_int = (int)$month_int;
$months = array("","January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
return $months[$month_int];
}
?>
