<?php
date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 


include ("dbset.php");

$con = mysql_connect("localhost",$dbu,$dbp);
if (!$con)
  {
  die('Could not connect to database: ' . mysql_error());
  }
   
mysql_select_db($dbs, $con);

function execsql($qry){
	$result = mysql_query($qry);
	return $result;
}


$today = date("Y-m-d");

$check_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($today)) . " -60 day"));


$table_name = "ftw_quotations";
$update_query = "UPDATE $table_name SET status = 'unsuccessful' WHERE status = 'quoted' AND quotation_date < '".$check_date."' ";
execsql($update_query);

	
$email_address = 'tocotex-management@bwcustomized.com';
$subject = 'Tlhomeso Francistown quotations reset';
$message = 'Quotations older then 60 days set to unsuccessful on:'.date("d-m-Y, H:i", strtotime($entry_date)).'.';
include ('alert_to_email.php');

	


?>