Current File : /home/inlingua/www/dwarka/icentex/admin_fd/ingl_course.approval.php |
<?php
// Copyright, Infocity Hosting. Created on: 22-03-2019
// Include header
include "header_fd.php";
session_start();
date_default_timezone_set('Asia/Calcutta');
// 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();
require("../class.phpmailer.php");
$mail_type=="S";
?>
<h3>Approval Course</h3>
<div id="contentnew">
<a href="ingl_course.main.php">Add New Course</a>
<br>
<?php
if(isset($_POST['Submit'])&& ($_POST['Submit']=="Approve") )
{
$sqlQuery = "update ingl_course set instructor='".$_POST['instructor']."', approved='1',approved_by='".$_SESSION['username']."' where recNo='".$_REQUEST['recNo']."' ";
mysqli_query($conn,$sqlQuery);
echo $succFailMesg = "<b style='font-size:16px;color:red;'>Course Approved successfully !!!</b><br>";
}
if(isset($_POST['Submit'])&& ($_POST['Submit']=="Reassign"))
{
$sqlQuerys = "update ingl_course set approved='1',instructor='".$_POST['instructor']."', old_instructor_dc=doneclass,old_instructor=instructor,doneclass=0
where recNo='".$_REQUEST['recNo']."' ";
mysqli_query($conn,$sqlQuerys);
echo $succFailMesg = "<b style='font-size:16px;color:red;'>Course instructor Changed Successfully !!!</b><br>";
}
function Certificate_d($conn,$courseId,$level)
{
if($level=="1A" || $level=="1B" || $level=="1B+"|| $level=="E1S2" || $level=="E1S2+")
{
$cert="certificate_1.php";
$tab="level_1";
}
elseif($level=="2A" || $level=="2B" || $level=="2A+" || $level=="2B+" || $level=="E2-S2" || $level=="E2-S2+"|| $level=="E2-S1"|| $level=="E2-S1+")
{
$cert="certificate_2.php";
$tab="level_2";
}
elseif($level=="3A" || $level=="3B" || $level=="E3-S1" || $level=="E3-S2")
{
$cert="certificate_3.php";
$tab="level_3";
}
elseif($level=="4")
{
$cert="certificate_4.php";
$tab="level_4";
}
elseif($level=="5")
{
$cert="certificate_5.php";
$tab="level_5";
}
elseif($level=="Private")
{
$cert="certificate_Private.php";
$tab="level_private";
}
else
{
$cert="#";
}
$queryC="select count(recNo) as tot from ".$tab." where courseId='".$courseId."'";
$resultC=mysqli_query($conn,$queryC);
$countT=mysqli_fetch_array($resultC);
if($countT['tot']>0)
{
$link="<a href='".$cert."?courseId=".$courseId."' target='_blank'><font size='1'>Download Certificate(".$countT['tot'].")</font></a>";
}
else
{
$link="<font size='1'>Not Generated Yet</font>";
}
return $link;
}
///////////////////////////////////////////////////
function certificate_L($conn,$courseId)
{
$queryS="select count(recNo) as tot from ingl_student where courseId='".$courseId."'";
$resultS=mysqli_query($conn,$queryS);
$countS=mysqli_fetch_array($resultS);
if($countS[tot]>0)
{
$link="<a href='welcome_note_all.php?courseId=".$courseId."' target='_blank'><font size='1'>Download Letter(".$countS[tot].")</font></a>";
}
else
{
$link="<font size='1'>No Student Yet</font>";
}
return $link;
}
?>
<script language="javascript">
<!--
function validate(form)
{ if (form.instructor.value=="")
{ alert("instructor cannot be blank. Please Select it.");
form.instructor.focus(); return false;
}
}
</script>
<script type="text/javascript" src="js/instr.js"></script>
<? isset($_REQUEST['up'])?$action=$_REQUEST['up']:$action='Approve';
$recno=$_REQUEST["recNo"];
$query_view="select * from ingl_course where recNo='".$recno."'";
$resultsview=mysqli_query($conn,$query_view);
$dbObject_veiw=mysqli_fetch_assoc($resultsview);
$queryins="select name,email from timesheet_user where recNo='".$dbObject_veiw['instructor']."' ";
$resinss=mysqli_query($conn,$queryins);
$instructor=mysqli_fetch_assoc($resinss);
$querycls="select * from ingl_class where id='".$dbObject_veiw['class_id']."' ";
$rescls=mysqli_query($conn,$querycls);
$class=mysqli_fetch_assoc($rescls);
$query="select * from ingl_course where recNo='".$_REQUEST["recNo"]."'";
$res2=mysqli_query($conn,$query);
$nums=mysqli_fetch_assoc($res2);
$cid=explode(' ',$nums['courseid']);
$query2="select * from ingl_student where courseId='".$_REQUEST["recNo"]."' ";
$res3=mysqli_query($conn,$query2);
$totalstd_rows=mysqli_num_rows($res3);
$message='<table border="1" class="pa-nor" width="70%" cellpadding="3" cellspacing="0">
<tr valign="top"><td width="25%">Course ID</td>
<td width="75%">'.$dbObject_veiw["courseid"].' '.'</td></tr>
<tr valign="top"><td>Name of Instructor</td><td>'.$instructor["name"].' '.'</td></tr>
<tr valign="top"><td>Name Of PIE</td><td>'.$dbObject_veiw["name_pie"].' '.'</td></tr>
<tr valign="top"><td>Language</td><td>'.$dbObject_veiw["language"].' '.'</td></tr>
<tr valign="top"><td>Level</td><td>'.$dbObject_veiw["level"].' '.'</td></tr>
<tr valign="top"><td>Start Date</td><td>'.$dbObject_veiw["startdate"].' '.'</td></tr>
<tr valign="top"><td>End Date</td><td>'.$dbObject_veiw["enddate"].' '.'</td></tr>
<tr valign="top"><td>Mid. End Date</td><td>'.$dbObject_veiw["mid_enddate"].' '.'</td></tr>
<tr valign="top"><td>Course Days</td><td>'.$dbObject_veiw["courseday"].' '.'</td></tr>';
if($dbObject_veiw["fw_feedback"]!='')
{
$message.='<tr valign="top"><td>First week feedback</td><td style="color:red;">'.$dbObject_veiw["fw_feedback"].' '.'</td></tr>';
}
if($dbObject_veiw["selectedDate"]!='')
{
$message.='<tr valign="top"><td>Cancelled Classes</td><td style="color:red;">'.$dbObject_veiw["selectedDate"].' '.'</td></tr>
';
}
if($dbObject_veiw["description"]!='')
{
$message.='<tr valign="top"><td>Remarks</td><td style="color:red;">'.$dbObject_veiw["description"].' '.'</td></tr>
';
}
$message.='<tr valign="top"><td>Timings</td><td>'.$dbObject_veiw["start_hour"].':'. $dbObject_veiw["start_minute"].' To '.$dbObject_veiw["end_hour"].':'. $dbObject_veiw["end_minute"].'</td></tr>';
$message.='<tr valign="top"><td>Branch</td><td>'.$dbObject_veiw["branch"].' '.'</td></tr>
<tr valign="top"><td>Class Room</td><td>'.$class["c_name"].' '.'</td></tr>
<tr valign="top"><td>No. Of Student</td><td>'.$totalstd_rows.' '.'</td></tr>
</table>';
echo $message;
?>
<div id="student_display_id"></div>
<table width="70%" border="0">
<form action="ingl_course.approval.php" method="POST" onsubmit="return validate(this)">
<input type="hidden" name="recNo" value="<? echo $_REQUEST['recNo']; ?>" />
<tr>
<td><b>Select Instructor Name</b>
<?php $query='select recNo, name from timesheet_user where usertype="user" and status="Active" order by name';
$res=mysqli_query($conn,$query);
if(mysqli_num_rows($res)>0)
{
echo "<select name='instructor' id='instructor' onchange='displaystudent(this.value)'>";
echo"<option value=''>All</option>";
while($rsult=mysqli_fetch_array($res))
{
echo"<option value='".$rsult['recNo']."'" ;
if($_REQUEST['recNo']==$rsult['recNo']) echo "selected";
echo">".$rsult['name']."</option>";
}
echo"</select>";
}
?></td>
<td><input class="submit1" type="submit" name="Submit" value="<?=$action; ?>" /></td>
</tr>
</form>
</table>
<br>
<?php
// Records selection sql
if(isset($_POST['Submit'])&& ($_POST['Submit']=="Reassign"))
{
$messages="<p>Hi!</p>";
$messages.="The following course has been Reassigned:</br><br>";
$messages.=$message;
$messages.="<p>Regards,</p>";
$messages.="Teaching Service"."</br>";
$tomail_array=array();
if($totalstd_rows>0)
{
while($rsult=mysqli_fetch_array($res3))
{
//send sms student and mail to instructor
$student = str_replace(" ","%20",$rsult['studentName']);
$cource=str_replace(" ","%20",$nums['courseid']."/".$nums['level']);
$stime = date("g:i a", strtotime($nums['start_hour'].':'.$nums['start_minute']));
$etime = date("g:i a", strtotime($nums['end_hour'].':'.$nums['end_minute']));
$sms = "Dear%20".$student."%20Your%20inlingua%20course%20".$cource."%20has%20been%20Reassigned%20as%20follows%20Start%20Date%20".$nums['startdate']."%20End%20Date%20".$nums['enddate'].",%20Day:%20".$nums['day']."%20Timing%20".str_replace(" ","%20",$stime)."%20to%20".str_replace(" ","%20",$etime)."%20.You%20are%20requested%20to%20report%2015%20mins%20before%20the%20class%20time%20on%20the%20first%20day.%20Regards%20inlingua%20".$nums['branch'].".";//
//echo $sms;//exit;
$sms=str_replace(" ","%20",$sms);
$dbObject->send_sms(trim($rsult['mobile']),$sms);
// array_push($tomail_array,$rsult['email']);
}
}
$query_ins="select name,email from timesheet_user where recNo='".$_POST['instructor']."' ";
$res_ins=mysqli_query($conn,$query_ins);
$sedRec=mysqli_fetch_assoc($res_ins);
$query_class="select * from ingl_class where id='".$nums['class_id']."' ";
$res_class=mysqli_query($conn,$query_class);
$Rec_class=mysqli_fetch_assoc($res_class);
$email=$sedRec['email'];
$query_ins="select email,location from timesheet_location where location ='".$nums['branch']."'";
$res_ins=mysqli_query($conn,$query_ins);
$rsults=mysqli_fetch_assoc($res_ins);
array_push($tomail_array,$rsults['email']);
array_push($tomail_array,"purvi@inlinguanewdelhi.com");
array_push($tomailarrays,"bd1@inlinguanewdelhi.com");
array_push($tomail_array,$email);
//echo $message; //exit;
$subject="The following course has been Reassigned.".$nums["courseid"].' '.$nums["level"];
$fromEmail= "dwarka@inlinguanewdelhi.in";
$fromName="inlingua Admin ".$_SESSION['name1'];
//$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 = 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);
//comment
if(!$mail->Send())
{
echo "Message could not be sent on mailid: <font color='red'>'".$toAddress."'";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
}
if(isset($_POST['Submit'])&& ($_POST['Submit']=="Approve"))
{
$messages="<p>Hi!</p>";
$messages.="The following course has been Confirmed:</br><br>";
$messages.=$message;
$messages.="<p>Regards,</p>";
$messages.="Teaching Service"."</br>";
$tomail_array=array();
if($totalstd_rows>0)
{
while($rsult=mysqli_fetch_array($res3))
{
//send sms student and mail to instructor
$student = str_replace(" ","%20",$rsult['studentName']);
$cource=str_replace(" ","%20",$nums['courseid']."/".$nums['level']);
$stime = date("g:i a", strtotime($nums['start_hour'].':'.$nums['start_minute']));
$etime = date("g:i a", strtotime($nums['end_hour'].':'.$nums['end_minute']));
$sms = "Dear%20".$student."%20Your%20inlingua%20course%20".$cource."%20has%20been%20confirmed%20as%20follows%20Start%20Date%20".$nums['startdate']."%20End%20Date%20".$nums['enddate'].",%20Day:%20".$nums['day']."%20Timing%20".str_replace(" ","%20",$stime)."%20to%20".str_replace(" ","%20",$etime)."%20.You%20are%20requested%20to%20report%2015%20mins%20before%20the%20class%20time%20on%20the%20first%20day.%20Regards%20inlingua%20".$nums['branch'].".";//
//echo $sms;//exit;
$sms=str_replace(" ","%20",$sms);
//comment
$dbObject->send_sms(trim($rsult['mobile']),$sms);
// array_push($tomail_array,$rsult['email']);
}
}
$query_ins="select name,email from timesheet_user where recNo='".$_POST['instructor']."' ";
$res_ins=mysqli_query($conn,$query_ins);
$sedRec=mysqli_fetch_assoc($res_ins);
$query_class="select * from ingl_class where id='".$nums['class_id']."' ";
$res_class=mysqli_query($conn,$query_class);
$Rec_class=mysqli_fetch_assoc($res_class);
/*
$message="Hi<br>The following course has been confirmed"."(".$nums['branch'].") :<br><br>";
$message.="Course Information Sheet <br>";
$message.="Instructors Name: ".$sedRec['name'].'<br>';
$message.="Course ID: ".$nums['courseid'].'<br>';
$message.="Level: ".$nums['level'].'<br>';
$message.="Days: ".$nums['courseday'].'<br>';
$message.="Timings: ".$nums['start_hour'].':'.$nums['start_minute'].'-'.$nums['end_hour'].':'.$nums['end_minute'].'<br>';
$message.="PIE: ". $nums['name_pie'].'<br>';
$message.="Class Room: ". $Rec_class['c_name'].'<br>';
$message.="Start date: ". date("d-m-Y", strtotime($nums["startdate"])).'<br>';
$message.="First week feedback: ". "N/A".'<br>';
$message.="End of course: ". date("d-m-Y", strtotime($nums["enddate"])).'<br><br>';
$message.="Regards,".'<br>';
$message.=$_SESSION['name1'];
*/
$email=$sedRec['email'];
$query_ins="select email,location from timesheet_location where location ='".$nums['branch']."'";
$res_ins=mysqli_query($conn,$query_ins);
$rsults=mysqli_fetch_assoc($res_ins);
array_push($tomail_array,$rsults['email']);
array_push($tomail_array,"purvi@inlinguanewdelhi.com");
array_push($tomailarrays,"bd1@inlinguanewdelhi.com");
array_push($tomail_array,$email);
//echo $message; //exit;
$subject="The following course has been Approved: ".$nums["courseid"].' '.$nums["level"];
$fromEmail= "dwarka@inlinguanewdelhi.in";
$fromName="inlingua Admin ".$_SESSION['name1'];
//$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 = 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 !=''){
$mail->AddAddress(trim($toAddress),"");
}
}
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = $subject;
$mail->Body = $messages;
//$mail->AddReplyTo("umraovikas@gmail.com","");
//$mail->AddAttachment($path);
//comment
if(!$mail->Send())
{
echo "Message could not be sent on mailid: <font color='red'>'".$toAddress."'";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
}
?>
</div>
<?php
// Include footer
include "footer_fd.php";
//echo $sqlqureynew;
$dbObject->CloseConnection();
?>