Current File : /home/inlingua/public_html/faridabad/icentex/admin/backup/sendmail.php
<?php
ob_start();
include("header.php");

?>

<table width="100%">

<tr><td width='100%'>

<?php
//print_r($_SESSION);
// Include the database connection details
require('dbConnection.php');

// Include common functions
require('commonFunc.php');

// Include common functions
require('globalVars.php');

// Include the table handler class
require('dbHandler.class.php');

// Init and connect to database
$dbObject = new dbHandler();
$dbObject->connect();

echo"<b>Sending Mail Please Wait...</b>";
if($_SESSION['insid1'] && !$_SESSION['insid2'])
{

 $query="select * from timesheet where recNo='$_SESSION[insid1]'";
}
elseif ($_SESSION['insid1'] && $_SESSION['insid2'])
{
 $query="select * from timesheet where recNo='$_SESSION[insid1]' || recNo='$_SESSION[insid2]'";
}
$result=mysql_query($query);

require("html2fpdf.php"); 

class PDF extends HTML2FPDF
{
//Page footer
function Footer()
{
	//Position at 1.5 cm from bottom
	$this->SetY(-15);
	//Arial italic 8
	$this->SetFont('Arial','I',8);
	//Page number
	$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
function PrintChapter()
{
	$this->AddPage();
	//$this->Cell(0,10,'Printing line number '.$i,0,1);
}
function SetCol($col)
{
	//Set position at a given column
	$this->col=$col;
	$x=10+$col*65;
	$this->SetLeftMargin($x);
	$this->SetX($x);
}
}

//Instanciation of inherited class
$pdf=new PDF();
$pdf->AliasNbPages();

	
	//$pdf->SetFont('Arial','B',15);
	//$pdf->SetFont('Arial','B',8);
    //$this->SetTextColor(0,0,128);
	//$pdf->setXY(100,32);
 //$pdf->MultiCell(17,5,'Timesheet',1,1);
	//Line break
	//$pdf->Ln();
	
while($num=mysql_fetch_array($result))
{
$fromDate=$num[fromDate];
$toDate=$num[toDate];
$location=$num[location];
$instructorId=$num[instructorId];
$pdf->PrintChapter();
$content1="";
$content1.="<table width='100%' border='0'><tr><td width='70%'>.</td>";
	$content1.="<td align='right'><img src='logo.jpg'></td></tr></table>";
   $pdf->WriteHTML($content1);

$content="";

$content.="<table width='100%'><tr><td align='center' bgcolor='#cccccc'><b>Updated Timesheet</b></td></tr></table>";

$content.="<table width='100%'><tr><td>Please complete this form at the end of fortnight.This form should not contain any surprises.Any work over and above normal hours should be cleared by the relevant authorised person before it takes place.</td></tr></table>";

$content.="<table width='100%'>
<tr><td><b>Location:</b></td><td colspan='3'>".$num[location]."</td></tr>
<tr><td width='10%'><b>Name:</b></td><td width='30%'>".$num[Instname]."</td>
<td width='8%'><b>From:</b></td><td>".$num[fromDate]." to ".$num[toDate]."</td></tr>
</table>";

$content.="<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center' bgcolor='#cccccc'><b>Teaching Hours</b></td></tr></table>";

$content.="<table width='100%' border='1'>
<tr><td width='20%' bgcolor='#cccccc'><b>Dated</b></td><td align='center' bgcolor='#cccccc'><b>ENG</b></td><td align='center' bgcolor='#cccccc'><b>FR</b></td><td align='center' bgcolor='#cccccc'><b>GER</b></td><td align='center' bgcolor='#cccccc'><b>SP</b></td><td align='center' bgcolor='#cccccc'><b>CLUBS</b></td><td align='center' bgcolor='#cccccc'><b>TRAINING</b></td><td align='center' bgcolor='#cccccc'><b>BIZ</b></td><td align='center' bgcolor='#cccccc'><b>OTHERS</b></td><td align='center' bgcolor='#cccccc'><b>ORALS</b></td></tr>";
if($num[date16]=="")
{
$j=15;

}
else
{
$j=16;
}
for($i=1;$i<=$j;$i++)
{
if($num['eng'.$i]=="0.0")
{
$eng="-";
}
else
{
$eng=$num['eng'.$i];
}

if($num['fr'.$i]=="0.0")
{
$fr="-";
}
else
{
$fr=$num['fr'.$i];
}

if($num['ger'.$i]=="0.0")
{
$ger="-";
}
else
{
$ger=$num['ger'.$i];
}

if($num['sp'.$i]=="0.0")
{
$sp="-";
}
else
{
$sp=$num['sp'.$i];
}

if($num['clubs'.$i]=="0.0")
{
$clubs="-";
}
else
{
$clubs=$num['clubs'.$i];
}

if($num['training'.$i]=="0.0")
{
$training="-";
}
else
{
$training=$num['training'.$i];
}

if($num['biz'.$i]=="0.0")
{
$biz="-";
}
else
{
$biz=$num['biz'.$i];
}

if($num['others'.$i]=="0.0")
{
$others="-";
}
else
{
$others=$num['others'.$i];
}

if($num['orals'.$i]=="0.0")
{
$orals="-";
}
else
{
$orals=$num['orals'.$i];
}


$content.="<tr><td>".$num['date'.$i]."</td><td align='center'>".$eng."</td><td align='center' >".$fr."</td><td align='center'>".$ger."</td><td align='center' >".$sp."</td><td align='center'>".$clubs."</td><td align='center'>".$training."</td><td align='center'>".$biz."</td><td align='center'>".$others."</td><td align='center'>".$orals."</td></tr>";
}

$content.="<tr><td bgcolor='#cccccc'><b>No. Of Hours</b></td><td align='center' bgcolor='#cccccc'>".$num[hours1]."</td><td align='center' bgcolor='#cccccc'>".$num[hours2]."</td><td align='center' bgcolor='#cccccc'>".$num[hours3]."</td><td align='center' bgcolor='#cccccc'>".$num[hours4]."</td><td align='center' bgcolor='#cccccc'>".$num[hours5]."</td><td align='center' bgcolor='#cccccc'>".$num[hours6]."</td><td align='center' bgcolor='#cccccc' >".$num[hours7]."</td><td align='center' bgcolor='#cccccc'>".$num[hours8]."</td><td align='center' bgcolor='#cccccc'>".$num[hours9]."</td></tr>";

$content.="<tr><td bgcolor='#cccccc'><b>Rate(Rs/hr)</b></td><td align='center' bgcolor='#cccccc'>".$num[rate1]."</td><td align='center' bgcolor='#cccccc'>".$num[rate2]."</td><td align='center' bgcolor='#cccccc'>".$num[rate3]."</td><td align='center' bgcolor='#cccccc'>".$num[rate4]."</td><td align='center' bgcolor='#cccccc'>".$num[rate5]."</td><td align='center' bgcolor='#cccccc'>".$num[rate6]."</td><td align='center' bgcolor='#cccccc' >".$num[rate7]."</td><td align='center' bgcolor='#cccccc'>".$num[rate8]."</td><td align='center' bgcolor='#cccccc'>".$num[rate9]."</td></tr>";

$content.="<tr><td bgcolor='#cccccc'><b>Sub-total(Rs)</b></td><td align='center' bgcolor='#cccccc'>".$num[subtot1]."</td><td align='center' bgcolor='#cccccc'>".$num[subtot2]."</td><td align='center' bgcolor='#cccccc'>".$num[subtot3]."</td><td align='center' bgcolor='#cccccc'>".$num[subtot4]."</td><td align='center' bgcolor='#cccccc'>".$num[subtot5]."</td><td align='center' bgcolor='#cccccc'>".$num[subtot6]."</td><td align='center' bgcolor='#cccccc' >".$num[subtot7]."</td><td align='center' bgcolor='#cccccc'>".$num[subtot8]."</td><td align='center' bgcolor='#cccccc'>".$num[subtot9]."</td></tr>";

$content.="<tr><td bgcolor='#cccccc'><b>Gross-total(Rs)</b></td><td align='right' bgcolor='#cccccc' colspan='9'>".$num[totalsubtotal]."</td></tr>";

$content.="<tr><td bgcolor='#cccccc'><b>TAX(T.D.S.-".$num[tdsper]."%)</b></td><td align='right' bgcolor='#cccccc' colspan='9'>".$num[tds]."</td></tr>";

$content.="<tr><td bgcolor='#cccccc'><b>TOTAL</b></td><td align='right' bgcolor='#cccccc' colspan='9'>".$num[Final_total]."</td></tr>";


$content.="</table>";

$content.="<table width='100%'><tr><td align='center' bgcolor='#cccccc'><b>Miscellaneous</b></td></tr>";
if($num[miscellaneous]=="")
{
$content.="<tr><td align='center'>NA</td></tr>";
}
else
{
$content.="<tr><td align='center'>".$num[miscellaneous]."</td></tr>";
}
$content.="</table>";


$pdf->WriteHTML($content);
}
$queryuser="select * from timesheet_user where recNo='".$instructorId."'";
$resultuser=mysql_query($queryuser) or die(mysql_error());
$numuser=mysql_fetch_array($resultuser);
$from1=explode("-",$fromDate);
if($j==15)
{
$half="First";
}
else if($j==16)
{
$half="Second";
}

$sid="".$numuser[username]."_".$from1[1]."_".$half."_".$location."";
$pdf->Output("uploads/".$sid.".pdf");
$path="uploads/".$sid.".pdf";
require("../class.phpmailer.php");

$fromdate1=explode("-",$fromDate);
$todate1=explode("-",$toDate);
$fdate1= date("d F Y", mktime(0, 0, 0, $fromdate1[1], $fromdate1[2], $fromdate1[0]));
$tdate1= date("d F Y", mktime(0, 0, 0, $todate1[1], $todate1[2], $todate1[0]));

$message="Hi ".$numuser[name].",<br>";

$message.="The Administartor has modified your submitted timesheet for the period ".$fdate1." to ".$tdate1." for  ".$location.".The modified timesheet is attached herewith.<br>
For details contact accounts/administrator.<br>
Time Sheet Details: <br>Period - From : ".$fdate1." to ".$tdate1." <br> Location:".$location."<br>";

$message.="*In case of any doubt, please contact the Administrator at hrd@inlinguanewdelhi.com for any queries.";

$fromEmail= "hrd@inlinguanewdelhi.com";
$fromName="Timesheet";

$to=$numuser[email];


$subject="Modified TimeSheet-".$fdate1." to ".$tdate1." - ".$location."";




$mail = new PHPMailer();

$domain = "inlinguanewdelhi.com";

		    $smtpHost = "mail.$domain";

		    $smtpUser = "shrikant@$domain";

		    $smtpPassword = "Noida007";

      if($mail_type=="S")
        {
	$mail->IsSMTP();              // set mailer to use SMTP
        
        }

        if($mail_type=="N")
        {
	$mail->IsMail();
        }
        
        if($mail_type=="S")
        {
	$mail->Host = $smtpHost;  // specify main and backup server
	$mail->SMTPAuth = true;     // turn on SMTP authentication
	$mail->Username = $smtpUser;  // SMTP username
	$mail->Password = $smtpPassword; // SMTP password
        }

$mail->From = $fromEmail;
$mail->FromName = $fromName;
//foreach ($to as $toAddress) 
//{
	 $toAddress;
	$mail->AddAddress($to, "");
//}


$mail->IsHTML(true);               // set email format to HTML
 

$mail->Subject = $subject;
$mail->Body    = $message;
//$mail->AddReplyTo("umraovikas@gmail.com","");
$mail->AddAttachment($path);
		
if(!$mail->Send())
{
    echo "Message could not be sent on mailid: <font color='red'>'".$to."'</font><br>";
	echo "Please check the emailId.<br>";
    //echo "Mailer Error: " . $mail->ErrorInfo;
    //exit;
}

header("Location: timesheet.select.php");

?>


</td></tr>

<tr><td  align="center">  </td></tr>

<tr><td>

</td><td>




</td></tr>

</table>
<?php
include("footer.php");
?>