Current File : /home/inlingua/www/dwarka/icentex/admin/delet.timesheet.php |
<?php
session_start();
ob_start();
// 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');
// Setup table name, configuration and data entry form
$tableName = "timesheet";
$tableConf = $tableName . ".conf.php";
// Init and connect to database
$dbObject = new dbHandler();
$dbObject->setTableName($tableName);
$dbObject->setDbFieldList($dbFieldList);
$dbObject->setKeyFieldName("recNo");
$dbObject->connect();
// Retrieve parameters from request
//$dbObject->getDbFieldsFromRequest();
// Records selection sql
$query="select * from timesheet where recNo='".$_REQUEST[id]."'";
$res=mysqli_query($conn,$query);
$result_array=mysqli_fetch_array($res);
$queryU="select recNo,email,startingHours from timesheet_user where recNo='".$result_array[instructorId]."'";
$resultU=mysqli_query($conn,$queryU);
$numU=mysqli_fetch_array($resultU);
$startinghours=$numU[startingHours];
$queryT="select (sum(hours1) + sum(hours2) + sum(hours3) + sum(hours4) + sum(hours5) + sum(hours7) + sum(hours8) + sum(hours9)) as totalhrs from timesheet where count_send <='".$result_array[count_send]."' && instructorId='".$numU[recNo]."' && status_send=1 && approve_status=1 && modify_status!='1' && modify_status!='3'";
$resultT=mysqli_query($conn,$queryT) or die(mysql_error($conn));
$numT=mysqli_fetch_array($resultT);
$totalHours1=$startinghours+$numT[totalhrs];
/*if($totalHours1 >=1500)
{
$query_f="select * from timesheet where recNo='".$_REQUEST[id]."'";
}
else
{
$query_f="select * from timesheet where recNo='".$_REQUEST[id]."'";
$query_f="select * from timesheet where fromDate >='".$result_array[fromDate]."' && instructorId ='".$result_array[instructorId]."' and status_send ='1' and approve_status='1' && modify_status!='1' && modify_status!='3' order by fromDate Asc";
}*/
$query_f="select * from timesheet where recNo='".$_REQUEST[id]."'";
$res_f=mysqli_query($conn,$query_f);
$_SESSION['delstatus']='';
while($result_fetch=mysqli_fetch_array($res_f))
{
if($result_fetch[recNo]==$result_array[recNo])
{
$msg="Due to some problem , timesheet dated from".$result_fetch[fromDate]." to ".$result_fetch[toDate]." is cancelled by the administrator . Please resend it.";
$_SESSION['delstatus'] .="* Timesheet from ".$result_fetch[fromDate]." to ".$result_fetch[toDate]." is cancelled <br>";
$message1.="* Due to some problem your timesheet from ".$result_fetch[fromDate]." to ".$result_fetch[toDate]." is cancelled .Please contact administrator and resend it.<br>";
}
else
{
$msg="The timesheet dated from".$result_fetch[fromDate]." to ".$result_fetch[toDate]." is after problemed timesheet dated from".$result_array[fromDate]." to ".$result_array[toDate]."so cancelled" ;
$_SESSION['delstatus'] .="* Timesheet from ".$result_fetch[fromDate]." to ".$result_fetch[toDate]." is cancelled";
$message1.="* Due to some problem your timesheet from ".$result_fetch[fromDate]." to ".$result_fetch[toDate]." is cancelled .Please contact administrator and resend it.<br>";
}
$dbObject->setDbField("approve_status",'0');
$dbObject->setDbField("msg",$msg);
$dbObject->Update("recNo",$result_fetch[recNo]);
}
$message="Dear ".$result_array[Instname].", <br><br>";
$message.=$message1;
$message.="<br><br>";
$message.="-Administrator<br><br>Inlingua New Delhi";
require("../class.phpmailer.php");
$fromEmail= "hrd@inlinguanewdelhi.com";
$fromName="Timesheet Admin-Inlingua";
$to=$numU[email];
$subject="Timesheet Cancelled";
$mail = new PHPMailer();
$mail->IsMail();
$mail->From = $fromEmail;
$mail->FromName = $fromName;
$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.archive.php");
// Print navigation bar
?>