Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.14.249.102
<?php
//include 'database.php';
ini_set('memory_limit','900M');
ini_set('max_execution_time',0);
$servername = "97.74.228.93";
$username = "logisys3_logu";
$password = "Logisys@2106";
include("sendGridMail.php");
/*$servername = "server";
$username = 'root';
$password = "";*/
$conn = new mysqli($servername,$username,$password);
if(!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$commondb = "logisys3_comexam";
$sql = "select fdbname, funivcode from {$commondb}.dbname where ifnull(fdeleted,'') <> 'T'";
$result = mysqli_query($conn,$sql);
$result1 = 0;
if($result)
{
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
$db = $row['fdbname'];
$univcode = $row['funivcode'];
//Room Allotment
$enttype = "RA";
$sql1 = "insert ignore into {$commondb}.sendsms(funivcode, fregno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate,fexamdate)
select distinct '{$univcode}', x.fregno, 'RA', y.fqpcode ,
concat('Dear Student, you have been alloted to room no. : ',
if(ifnull(z.froomname,'') = '',
ifnull(x.FHALLNO,''),ifnull(z.froomname,'')), ' for the QP Code ',
concat(y.fqpcode,' - ',y.fsubname),' on ',
date_format(y.fdoe,'%d/%m/%Y'),' (',w.FDESCPN,').',' All the best.') as fmessage,
'F', 'F', x.fyear, x.fexamtype,now(),d.fexamdate
from {$db}.canddet x inner join {$db}.subject y
on x.fdegree = y.fdegree and x.fexamno = y.fexamno and x.fsubcode = y.fsubcode
inner join {$db}.degree d on x.fdegree = d.fdegree and x.fexamno = d.fexamno
left join {$db}.masroom z on x.fcollcode = z.fcollcode and x.FHALLNO = z.froomno
left join {$db}.reason w on y.FSESSION = w.FREASONCD
where ifnull(x.fpresent,'') = 'p' and ifnull(x.fpassmth,'') = ''
and x.fyear = '2018' and x.fexamtype = '1'
and date_format(now(),'%Y-%m-%d') = date_format(y.fdoe,'%Y-%m-%d')
and ifnull(y.FSESSION,'') like 'N%' and ifnull(x.fhallno,'') <> ''";
$result1 = mysqli_query($conn, $sql1);
//echo "Insert {$univcode} {$enttype} {$result1}";
}
$sql1 = "update {$commondb}.sendsms x, {$commondb}.masuser y set x.fmobileno = y.fmobileno
where x.funivcode = y.funivcode and x.fregno = y.fregno and ifnull(x.fmobileno,'') = ''";
$result1 = mysqli_query($conn, $sql1);
if($result1)
{
$query = "select s.funivcode, d.funivname, s.fenttype,count(fmobileno) as pushcount,date_format(left(fupdate,10),'%d.%m.%Y') as pushdate
from {$commondb}.sendsms s
inner join {$commondb}.dbname d
on s.funivcode = d.funivcode
where ifnull(fmobileno,'') <> ''
and ifnull(fstatus,'') = 'F'
and left(fupdate,10) = date_format(now(),'%Y-%m-%d')
group by s.funivcode,s.fenttype";
$result = mysqli_query($conn, $query);
$count = mysqli_num_rows($result);
if($count > 0)
{
$table = '<table cellspacing="1" cellpadding="2" border="0" align="center" bgcolor="#505151">
<thead>
<tr bgcolor="#e1eaea">
<th>Sl.<br> No.</th>
<th>University <br>Code</th>
<th>University Name</th>
<th>Event <br> Type</th>
<th>Count</th>
<th>Date</th>
</tr>
</thead>';
$i = 1;
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
//var_dump($row);
$table .= "<tr bgcolor='#ffffff' >";
$table .= "<td><center>".$i."</center></td>";
$table .= "<td><center>".$row['funivcode']."</center></td>";
$table .= "<td>".$row['funivname']."</td>";
$table .= "<td><center>".$row['fenttype']."</center></td>";
$table .= "<td align='right'>".$row['pushcount']."</td>";
$table .= "<td><center>".$row['pushdate']."</center></td>";
$table .= "</tr>";
//$sum +=$row['pushcount'];
$i++;
}
$table.="</table>";
$emails = ['prashanth.k@logisys.org','arun.v@logisys.org', 'mohan.s@logisys.org'];
$subject = "OASIS AFTERNOON SMS DATA UPLOAD STATISTICS( ".$_SERVER['REMOTE_ADDR'].")";
for($i=0;$i< count($emails); $i++)
{
$emailid = $emails[$i];
$resp = sendGridMail($emailid,$subject,$table);
echo $resp;
}
}
//echo $table;
//$arr = "Updated Successfully";
//echo json_encode($arr);
}else
{
$arr = "Updation Failed";
//echo json_encode($arr);
}
}
?>
|