Current File : /home/inlingua/public_html/icentex/admin_fd/send_emailcou.php |
<?php
session_start();
//print_r($_SESSION);
require('../dbConnection.php');
// Include common functions
require('../commonFunc.php');
// Include common functions
require('../globalVars.php');
require('../dbHandler.class.php');
$dbObject = new dbHandler();
$dbObject->connect();
//ob_start();
//include("header.php");
require_once('../tcpdf/config/lang/eng.php');
require_once('../tcpdf/tcpdf.php');
$level=$_REQUEST['c_level'];
$courseId=$_REQUEST['courseId'];
$student_recNo=$_REQUEST['student_recNo'];
$value=$_REQUEST['language'];
$lang = array("English"=>"14","French"=>"17","German"=>"18","Spanish"=>"19","Hindi"=>"20","IOL"=>"12");
$bcat=$lang[$value];
$course_count="SELECT level FROM ingl_billing_main WHERE `bill_category` ='".$bcat."' and bill_details= '".$level."' ";
$totcourse_id=mysqli_query($conn,$course_count) or die(mysqli_query($conn));
$slevel=mysqli_fetch_array($totcourse_id);
//echo $slevel['level'];
//echo '<br>';
//echo $level;
if($value=='Spanish' || $value=='French' || $value=='German')
{
$slevel['level']='Private';
}
if($level=="Reg-Pre Intermediate Proficiency" || $level=="Reg-Basic Proficiency" || $level=="Reg-Intermediate Proficiency" || $level=="Reg-Pre Advanced Proficiency" || $level=="Reg-Advanced Proficiency")
{
$cert="pre-certificates-single.php?c_level=level_1&student_recNo=".$student_recNo;
$tab="level_1";
$slevel['level']=$level;
}
elseif($slevel['level']=="level_1" )
{
$cert="certificates-single.php?c_level=level_1&student_recNo=".$student_recNo;
$tab="level_1";
}
elseif($slevel['level']=="level_2")
{
$cert="certificates-single.php?c_level=level_2&student_recNo=".$student_recNo;
$tab="level_2";
}
elseif($slevel['level']=="level_3")
{
$cert="certificates-single.php?c_level=level_3&student_recNo=".$student_recNo;
$tab="level_3";
}
elseif($slevel['level']=="level_4")
{
$cert="certificates-single.php?c_level=level_4&student_recNo=".$student_recNo;
$tab="level_4";
}
elseif($slevel['level']=="level_5")
{
$cert="certificates-single.php?c_level=level_5&student_recNo=".$student_recNo;
$tab="level_5";
}
$query="select a.*, s.studentName,s.ref_No,s.course_type from $tab a left join ingl_student s on s.recNo=a.student_recNo where a.courseId='$courseId' and a.student_recNo='$student_recNo'";
$result=mysqli_query($conn,$query);
$num=mysqli_fetch_array($result);
$totalstd_rows=mysqli_num_rows($result);
if($totalstd_rows<=0){
echo "Certificate Not Generated Please contact instructor.";
exit;
}
$queryins="select signature,name from timesheet_user where recNo='".$num['createdBy']."' ";
$resinss=mysqli_query($conn,$queryins);
$instructor=mysqli_fetch_array($resinss);
$sign=$instructor['signature'];
// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {
//Page header
public function Header() {
$img_file = 'https://www.inlinguanewdelhi.in/icentex/certificate-with-signature.jpg';
// full background image
// store current auto-page-break status
$bMargin = $this->getBreakMargin();
$auto_page_break = $this->AutoPageBreak;
$this->SetAutoPageBreak(false, 0);
//$img_file = K_PATH_IMAGES.'image_demo.jpg';
$this->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
// restore auto-page-break status
//$this->SetAutoPageBreak($auto_page_break, $bMargin);
}
}
$certificate='Certificate Of: '.$num['level'].' '.$num['studentName'];
$string=$num['student_recNo'].'-'.$num['courseId'].'-'.$num['level'].'-'.$num['studentName'];
// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle($certificate);
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, '115', PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(0);
// remove default footer
$pdf->setPrintFooter(false);
//set auto page breaks
//$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set font
$pdf->SetFont('times', '', 12);
// ---------------------------------------------------------
//while($num=mysqli_fetch_array($result))
$queryCourse="select courseid,startdate,enddate,mid_enddate,language,level from ingl_course where courseid='".$num['courseId']."'";
$resultCourse=mysqli_query($conn,$queryCourse) or die("Error:There is some ploblem");
$numCourse=mysqli_fetch_array($resultCourse);
if($num['course_type']=='part1'){
$toDate=$numCourse['mid_enddate'];
$fromDate=$numCourse['startdate'];
}
else if($num['course_type']=='part2'){
$fromDate=$numCourse['mid_enddate'];
$toDate=$numCourse['enddate'];
}
else {
$fromDate=$numCourse['startdate'];
$toDate=$numCourse['enddate'];
}
$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]));
$newlevel=explode('-',$numCourse['level']);
if($newlevel[1]=='Basic Proficiency'){
$Basic = array('part1' => 'English 1 Step 1', 'part2' => 'English 1 Step 2', 'complete' => 'Basic proficiency');
$coursetitle=$Basic[$num['course_type']];
}
if($newlevel[1]=='Pre Intermediate Proficiency'){
$PreIntermediate = array('part1' => 'English 1 Step 2', 'part2' => 'English 2 Step 1', 'complete' => 'Pre-Intermediate Proficiency');
$coursetitle=$PreIntermediate[$num['course_type']];
}
if($newlevel[1]=='Pre-Intermediate Proficiency'){
$PreIntermediate = array('part1' => 'English 1 Step 2', 'part2' => 'English 2 Step 1', 'complete' => 'Pre-Intermediate Proficiency');
$coursetitle=$PreIntermediate[$num['course_type']];
}
if($newlevel[1]=='Intermediate Proficiency'){
$IntermediateProficiency = array('part1' => 'English 2 Step 1', 'part2' => 'English 2 Step 2', 'complete' => 'Intermediate Proficiency');
$coursetitle=$IntermediateProficiency[$num['course_type']];
}
if($newlevel[1]=='Pre-Advanced Proficiency'){
$PreAdvanced = array('part1' => 'English 2 Step 2', 'part2' => 'English 3 Step 1', 'complete' => 'Pre-Advanced Proficiency');
$coursetitle=$PreAdvanced[$num['course_type']];
}
if($newlevel[1]=='Advanced proficiency'){
$Advancedproficiency = array('part1' => 'English 3 Step 1', 'part2' => 'English 3 Step 1', 'complete' => 'Advanced proficiency');
$coursetitle=$Advancedproficiency[$num['course_type']];
}
$content="";
$content.='<div style="padding-bottom:10px;">';
$content.='<table border="0" width="100%">';
$content.='<tr><td valign="center" align="center"><em><u>'.$coursetitle.' General English Language Course</u></em></td></tr>';
$content.='<tr><td align="center"><em><u> '.$fdate1.' – '.$tdate1.' </u></em></td></tr><tr><td> </td></tr>';
$content.='<tr><td align="center" width="100%" style="text-align:center;font-size:20;">This is to certify that </td></tr>';
$content.='<tr><td align="center" width="100%" style="text-align:center;font-size:24;font-family: Monotype Corsiva;"><strong>'.ucfirst($num['studentName']).'</strong></td></tr>';
if($num['eligibility']=='Yes')
{
$cer_comment="successfully completed the ".$coursetitle." course on the above dates and can communicate effectively in ".$numCourse['language']." at this level.";
$status='';
$content.='<tr><td align="center" width="100%" style="text-align:center;font-size:20;">'.$cer_comment.'</td></tr>';
}else {
$queryg="select gender from ingl_admission where ref_No='".$num['ref_No']."'";
$resultg=mysqli_query($conn,$queryg) or die("Error:There is some ploblem");
$g=mysqli_fetch_array($resultg);
$g['gender']=='Male';
if($g['gender']=='Male')
{
$gender='he';
}
if($g['gender']=='Female')
{
$gender='she';
}
//$cer_comment="attended the ".$numCourse['level']." course on the above dates. However, ". $gender." is unable to communicate effectively in ".$numCourse['language']." at this level.";
$cer_comment="Attended the ".$coursetitle." course on the above dates.<br>";
$content.='<tr><td align="center" width="100%" style="text-align:center;font-size:20;">'.$cer_comment.'</td></tr>';
}
$content.="<tr><td> </td></tr>";
$content.="<tr><td> </td></tr>";
$content.='<tr><td style="padding:5px;"><table border="0"><tr><td width="25%" ></td><td width="24%" border="2" bgcolor="#FFFF66" align="center" style="height:50px; "><div style=" padding:30px;"><br><b>Overall Grade</b></div ></td><td width="20%"></td><td width="15%" border="2" bgcolor="#FFFF66" align="center" ><div style=" padding:30px;"><br><b >'.nl2br ($num['overall_grade']).'</b></div></td></tr></table></td></tr>';
$content.="<tr><td> </td></tr>";
$content.='<tr><td width="100%" style="text-align:center;font-size:14;"><b>Eligibility for the next level:</b> '.$num['eligibility'].'</td>'.'</tr>';
$content.="<tr><td> </td></tr>";
$content.="<tr><td> </td></tr>";
$content.="<tr><td> </td></tr>";
$content.="<tr><td> </td></tr>";
$content.="<tr><td> </td></tr>";
$content.="<tr><td> </td></tr>";
$content.="<tr><td> </td></tr>";
$content.="<tr><td> </td></tr>";
$content.="<tr><td> </td></tr>";
if($num['eligibility']=='Yes')
{}else {
//$content.="<tr><td> </td></tr>";
}
$content.='</table>';
$url='../signature/'.$sign;
if(file_exists($url) && $sign !='') {
$image='../signature/'.$sign;
$img='<img src="'.$image.'">';
}else {
$img='';
}
$content.='</div>';
$content.='<div>
<table width="100%">
<tr ><td align="center" ></td><td align="center" style="margin-top:30px;">
'.$img.'</td>
<td style="font-weight:bold;margin:20px;text-align:right;"><br/><br/>'.$tdate1.'</td></tr>';
$content.='</table></div>';
//echo $content; exit;
// add a page
// add a page
$pdf->AddPage();
// Print a text
$html = $content;
//echo $html; exit;
$pdf->writeHTML($html, true, false, true, false, '');
$nstring = str_replace(" ", "-", $string).'.pdf';
// add a page
//$pdf->AddPage();
//$path="../../certificate/";
$path ='/home/inlingua/public_html/';
$pdf->Output($path.'certificate/'.$nstring, 'F');
// Print a text
//$html = '<span style="background-color:yellow;color:blue;"> PAGE 2 </span>';
//$pdf->writeHTML($html, true, false, true, false, '');
// ---------------------------------------------------------
//Close and output PDF document
//$pdf->Output($path.$nstring,'F');
//============================================================+
// END OF FILE Meet the experts 31 may to 2nd june
//============================================================+
$filename=$nstring;
require("../class.phpmailer.php");
$query="SELECT cou. * , user.name AS instructor, loc.address, loc.contact FROM ingl_course cou INNER JOIN timesheet_user user ON cou.instructor = user.recNo
INNER JOIN timesheet_location loc ON cou.branch = loc.location where cou.courseid='".$_GET['courseId']."'";
$result=mysqli_query($conn,$query);
if(!$result)
{
echo "Data Not Found For This Cource Please Contect To System Administrator.";
return false;
}
while($row=mysqli_fetch_array($result))
{
$courseid=$row['courseId'];
$startdate=$row['startdate'];
$enddate=$row['enddate'];
$start_time=$row['start_hour'].":".$row['start_minute'];
$end_time=$row['end_hour'].":".$row['end_minute'];
$branch=$row['branch'];
$language=$row['language'];
$level=$row['level'];
$name_pie=$row['name_pie'];
$courseday=$row['courseday'];
$instructor=$row['instructor'];
$address=$row['address'];
$contact=$row['contact'];
}
//echo "Email=> ". $_GET['email']."<br/> Name=> ".$_GET['name']."<br/> CourceId=> ".$_GET['courceid'];
// please change this to your E-Mail address
//$sendTo = "amod@infocityhosting.com";
//$sendTo = "snware@infocityhosting.in" ;
//$sendTo = "mayanka@infocityhosting.in" ;
$sendTo =$_REQUEST['email'];//"mandeep@inlinguanewdelhi.com";//"admin@inlinguanewdelhi.com";//
//$sendTo ="abdullahansari70@gmail.com";//"mandeep@inlinguanewdelhi.com";//"admin@inlinguanewdelhi.com";//
$attendedfile='https://inlinguanewdelhi.in/certificate/'.$filename;
$messages="
<p>Dear <strong>".ucfirst($num['studentName'])."</strong>,</p>
<p>We hope this email finds you well.</p>
<p>We are reaching out to provide an update regarding your recent participation in the English course (Level ) at inlingua New Delhi. Your commitment to learning is commendable, and we appreciate the effort you have invested in your studies.</p>
<p>
Attached to this email, you will find your course certificate with the ID - <strong>".$courseId."</strong>. Please review it at your convenience.</p>
<p>Thank you for your dedication throughout the course. We value your participation and look forward to assisting you further in your language learning journey.</p>
<p>Best regards,<br/>
Inlingua New Delhi. <br/></p>
<p style='margin-bottom:25px;'><a style='font-weight: bold;text-decoration: none;background:#FFE600;padding: 10px;border-radius: 4px;' href='".$attendedfile."'>Download Your Certificate</a><br/></p>
<p style='margin-bottom:25px;'><a style='font-weight: bold;text-decoration: none;background:#FFE600;padding: 10px;border-radius: 4px;' href='https://wa.me/919540050266'>Customer care</a><br/></p>
<p><a style='font-weight: bold;text-decoration: none;background:#FFE600;padding: 10px;border-radius: 4px;' href='https://www.inlinguanewdelhi.com/online-skill-workshop'>Courses under 599/-</a></p>";
$tomail_array=array();
array_push($tomail_array,$sendTo);
//echo $message; //exit;
$subject="Important Update: Course Completion Information.";
$fromEmail= "admin@inlinguanewdelhi.in";
$fromName="inlingua Admin !!!";
//$tomail_array=array($email);
$domain = "inlinguanewdelhi.in";
$smtpHost = "mail.$domain";
$smtpUser = "admin@$domain";
$smtpPassword = "5B&vp7pgm7flABvi";
/*
$domain = "academycentral.in";
$smtpHost = "mail.$domain";
$smtpUser = "support@academycentral.in";
$smtpPassword = "Noida007";
*/
$mail_type=="N";
$mail = new PHPMailer();
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->SetLanguage( 'en', 'phpmailer/language/' );
//$mail->Priority = 1;
}
$mail->From = $fromEmail;
$mail->FromName = $fromName;
foreach ($tomail_array as $toAddress)
{
if($toAddress !=''){
trim($toAddress);
$mail->AddAddress($toAddress, "");
}
}
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = $subject;
$mail->Body = $messages;
//$mail->AddReplyTo("umraovikas@gmail.com","");
//$mail->AddAttachment($path,$filename);
$mail->AddAttachment($path, $filename, $encoding = 'base64', $type = 'application/pdf');
//comment
if(!$mail->Send())
{
echo "Message could not be sent on mailid: <font color='red'>'".$toAddress."'";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}else {
echo "Email sent on Successfully!!!";
}
?>