<?php
include('../headertop.php');
include('../db.php');
//include('../datepicker.php');

$disp = '';
$pagetitle = 'Email Expense Receipt';
date_default_timezone_set('Asia/Kolkata');

if(empty($_REQUEST['id']))
{
echo 'Select an expense transaction first to email receipt';
exit;
}

$project = 1;
$id = $_REQUEST['id'];



$q = "select * from expenses where id='$id'";
$res = mysqli_query($dbcon,$q) or die(mysqli_error($dbcon));
if(mysqli_num_rows($res)<1)
{
$disp .= 'No such expense transaction found. Please re-check and try again!';
include('../template.php');
exit;
}

$row = mysqli_fetch_array($res);
$datedisp = date("d-m-Y", strtotime($row['date']));

$q2 = "select * from work_type where id='".$row['work_type']."'";
$res2 = mysqli_query($dbcon,$q2) or die(mysqli_error($dbcon));
$row2 = mysqli_fetch_array($res2);

$to = 'azeemquraishi@yahoo.com, info@goodhandsconsultants.com';
$sub = 'Banjara Office Construction Receipt';
$msg = 'Amount: '.$row['amount'].', 
		Date: '.$datedisp.', 
		Work: '.$row2['work_type'].', 
		Payment Method: '.$row['payment_method'].', 
		Payment Details: '.$row['payment_details'].',
		Receipt: http://mcschool.in/office/banjara/'.$row['rcptphoto'];
$headers = "From: info@mcschool.in";
		
if(mail($to,$sub,$msg, $headers))
echo 'Receipt Mailed';
else
echo 'Mail failure. Please try again';
		


