<?php require_once('../Connections/oprmConn.php'); ?>



<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 

{

  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;



  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);



  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;    

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}



$maxRows_getTimeSheet = 10;

$pageNum_getTimeSheet = 0;

if (isset($_GET['pageNum_getTimeSheet'])) {

  $pageNum_getTimeSheet = $_GET['pageNum_getTimeSheet'];

}

$startRow_getTimeSheet = $pageNum_getTimeSheet * $maxRows_getTimeSheet;





mysql_select_db($database_oprmConn, $oprmConn);

$query_getPassEx = "SELECT DATEDIFF(weby_profiles.visa_edate,current_date) AS days_left, weby_profiles.full_name, weby_profiles.visa_edate, weby_profiles.visa_number, weby_users.email_address, weby_users.user_id FROM weby_profiles, weby_users where weby_profiles.user_id = weby_users.user_id and weby_users.status = 'A' and weby_users.user_role <> 1 and weby_profiles.status = 'A' having days_left <= 180";

$getPassEx = mysql_query($query_getPassEx, $oprmConn) or die(mysql_error());

$row_getPassEx = mysql_fetch_assoc($getPassEx);

$totalRows_getPassEx = mysql_num_rows($getPassEx);



 







mysql_select_db($database_oprmConn, $oprmConn);

$query_getProj22 = "select email_address FROM weby_users where user_role = 1";

$getProj22 = mysql_query($query_getProj22, $oprmConn) or die(mysql_error());

$row_getProj22 = mysql_fetch_assoc($getProj22);

$totalRows_getProj22 = mysql_num_rows($getProj22);





	$ADMIN_EMAIL = "SS WEB TECHNOLOGIES";
	$ADMIN_EMAIL = $row_getProj22['email_address'];

    $headers = 'MIME-Version: 1.0' . "\r\n";

		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

       

       $headers .= "From: SS WEB TECHNOLOGIES<mailsendinfo@SS WEB TECHNOLOGIES>" . "\r\n" ;

	   //$headers .= "From: Jiwani Consultancy <donotreply@jiwani.vteksolutions.co.uk>" . "\r\n" ;

	

	$subject = "SS WEB TECHNOLOGIES- $row_getPassEx[full_name]: Visa Expiry Alert";

	

	$body = "Hi admin,<br>This is to inform you that $row_getPassEx[full_name] Visa Expiry Status alert. <br>

	<br>

			

	<table width='100%' border='1' cellpadding='5' cellspacing='0'>

	<th height='30' align='left' valign='top' bgcolor='#FFCC99'><strong>User Id

	</strong>

	<td height='30' align='left' valign='top' bgcolor='#FFCC99'><strong>Name</strong></td>

	<td height='30' align='left' valign='top' bgcolor='#FFCC99'><strong>Visa No</strong></td>

	<td height='30' align='left' valign='top' bgcolor='#FFCC99'><strong>Expiry Date</strong></td>

	<td height='30' align='left' valign='top' bgcolor='#FFCC99'><strong>Days Left</strong></td>

	</th>";

	



if($totalRows_getPassEx>0)  do { 



$body = $body."<tr align='left' valign='top'>	

	

	<td height='30'>$row_getPassEx[user_id]</td>

    <td height='30'>$row_getPassEx[full_name]</td>

	<td height='30'>$row_getPassEx[visa_number]</td>

	<td height='30'>$row_getPassEx[visa_edate]</td>

		<td height='30'>$row_getPassEx[days_left]</td>                   

   

     </tr>               

	

	

	

	



	";

	

	

	

	

	

	

	

	 } while ($row_getPassEx = mysql_fetch_assoc($getPassEx));

	 

	 $body = $body."

	</table>

	<br>

	Auto generated e-mail...";



if($totalRows_getPassEx>0){	

mail($ADMIN_EMAIL, $subject, $body, $headers);

}

	

	





  

	   

	   

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Visa Alert</title>

</head>



<body>

</body>

</html>

