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 : 18.222.98.91
<?php
include("database.php");
include("sendsmsbulk.php");
include("sendGridMail.php");
include("credits.php");
ini_set('memory_limit','900M');
ini_set('max_execution_time',0);
$query1 = "SET SESSION group_concat_max_len=10000000";
$result1 = mysqli_query($conn,$query1);
$query = "select funivcode, group_concat(concat('91', fmobileno)) as mobilenos,
fenttype, fmessage,fexamdate
from sendsms
where fmobileno is not null
and fstatus = 'F'
and funivcode <> '038'
group by funivcode, fmessage";
$result = mysqli_query($conn,$query);
$count = mysqli_num_rows($result);
$username = 'logisyhttp';
$password = 'Logis986';
$from = 'UNISOL';
$category = 'bulk';
if($count >0)
{
while($row = mysqli_fetch_assoc($result))
{
$rgBigArr = explode(',', $row['mobilenos']);
$rgSmallArr = array_chunk($rgBigArr,90);
$text = $row['fmessage'];
foreach($rgSmallArr as $key => $value)
{
$strTo = implode(',', $value);
$response = sendsmaapibulk($username,$password,$from,$strTo,$text,$category);
$rgExpAmp = explode('&', $response);
array_walk($rgExpAmp, function($val,$key) use(&$final){
list($key, $value) = explode('=', $val);
$final[$key] = $value;
});
$errorcode = explode(',', $final['errorcode']);
$mobnos = explode(',', $final['seqno']);
$rgInsert = array();
$rgTrimedMobs = array();
for($i = 0; $i < count($mobnos);$i++)
{
$rgInsert[] = "('".$row['funivcode']."','".substr($mobnos[$i],2,11)."','".$errorcode[$i]."','".$final['guid']."','".$row['fenttype']."', DATE_FORMAT(NOW(),'%Y-%m-%d'), DATE_FORMAT(NOW(),'%T'),'".$row['fexamdate']."')";
$rgTrimedMobs[$i] = substr($mobnos[$i],2,11);
}
$strInsertQuery = "insert into smslog(funivcode, fmobileno, freasoncode, fguid, fenttype, fackdate, facktime, fexamdate) values".implode(',',$rgInsert);
$result1 = mysqli_query($conn,$strInsertQuery);
$srtImplodedMobs = implode("','",$rgTrimedMobs);
$strUpdateQuery = "update sendsms set fstatus = 'T' where fenttype = '{$row['fenttype']}' and fmobileno in ('{$srtImplodedMobs}')";
$result2 = mysqli_query($conn,$strUpdateQuery);
}
//echo "Sms Sent.";
}
$strLogSumQuery = "select date_format(x.fackdate, '%d/%m/%Y') as DATE,
x.funivcode as UNIVERSITY_CODE, y.funivname as FUNIVNAME,y.FSTAFFMOBILENO AS sumbob,
x.fenttype as EVENT_TYPE, 'AD' as event, count(x.fmobileno) as SMS_COUNT,
CONCAT('Message : ',x.fenttype, '; SMS Sent Count : ',COUNT(x.fmobileno),
'; Exam : ',ifnull(x.fexamdate,'APRIL / MAY 2018'), '; Client : ',y.funivcode,' - ',y.funivname,'.') AS message
from smslog x
inner join dbname y
on x.funivcode = y.funivcode
where fackdate = date_format(now(), '%Y-%m-%d')
and freasoncode = 0
and facktime >= DATE_SUB(now(), interval 1 hour)
group by x.fackdate, y.funivcode, x.fenttype";
$result3 = mysqli_query($conn, $strLogSumQuery);
$strHtmlMail = '<html><body>';
$strHtmlMail .= '<table cellspacing="1" cellpadding="2" border="0" align="center" bgcolor="#505151">';
$strHtmlMail .= "<thead>
<tr bgcolor='#e1eaea'>
<th>DATE</th>
<th>UNIVERSITY CODE</th>
<th>UNIVERSITY NAME</th>
<th>EVENT TYPE</th>
<th>SMS COUNT</th>
</tr>
</thead>";
while($row = mysqli_fetch_assoc($result3))
{
/* $strTo = $row['sumbob'];
$text = $row['message'];
$response = sendsmaapibulk($username,$password,$from,$strTo,$text,$category);
$rgExpAmp = explode('&', $response);
array_walk($rgExpAmp, function($val,$key) use(&$final){
list($key, $value) = explode('=', $val);
$final[$key] = $value;
});
$errorcode = explode(',', $final['errorcode']);
$mobnos = explode(',', $final['seqno']);
$rgInsert = array();
$rgTrimedMobs = array();
for($i = 0; $i < count($mobnos);$i++)
{
$rgInsert[] = "('".substr($mobnos[$i],2,11)."','".$errorcode[$i]."','".$final['guid']."','".$row['event']."', DATE_FORMAT(NOW(),'%Y-%m-%d'), DATE_FORMAT(NOW(),'%T'))";
$rgTrimedMobs[$i] = substr($mobnos[$i],2,11);
}
$strInsertQuery = "insert into smslog(fmobileno, freasoncode, fguid, fenttype, fackdate, facktime) values".implode(',',$rgInsert);
$result1 = mysqli_query($conn,$strInsertQuery); */
$strHtmlMail .= "<tr bgcolor='#ffffff'><td><center>".$row['DATE']."</center></td><td><center>".$row['UNIVERSITY_CODE']."</center></td><td>".$row['FUNIVNAME']."</td>";
$strHtmlMail .= "<td><center>".$row['EVENT_TYPE']."</center></td><td align='right'>".$row['SMS_COUNT']."</td></tr>";
}
$strHtmlMail .= '</table></body></html>';
$query = "update dbname set fsmslog = null, fuserlog = null";
$result1 = mysqli_query($conn,$query);
$query = "update dbname a, smslogsummain b set a.fsmslog = b.fsmslog
where a.funivcode = b.funivcode";
$result1 = mysqli_query($conn,$query);
$query = "update dbname a, userlogsum b set a.fuserlog = b.fvisitcnt
where a.funivcode = b.funivcode";
$result1 = mysqli_query($conn,$query);
$query = "select FSTAFFMOBILENO AS sumbob,group_concat(concat(upper(ffolder), ' Visit : ',ifnull(fuserlog,''), ' ', ifnull(fsmslog,'')) separator ', ') as message
from dbname where ifnull(fuserlog,'') <> '' or ifnull(fsmslog,'') <> ''";
$result1 = mysqli_query($conn,$query);
$smsRemain = smsCreditDetails();
while($row = mysqli_fetch_assoc($result1))
{
$strTo = $row['sumbob'];
$text = $row['message'];
$text .= ", Remaining SMS : ".$smsRemain;
$response = sendsmaapibulk($username,$password,$from,$strTo,$text,$category);
$rgExpAmp = explode('&', $response);
array_walk($rgExpAmp, function($val,$key) use(&$final){
list($key, $value) = explode('=', $val);
$final[$key] = $value;
});
$errorcode = explode(',', $final['errorcode']);
$mobnos = explode(',', $final['seqno']);
$rgInsert = array();
$rgTrimedMobs = array();
for($i = 0; $i < count($mobnos);$i++)
{
$rgInsert[] = "('".substr($mobnos[$i],2,11)."','".$errorcode[$i]."','".$final['guid']."','".$row['event']."', DATE_FORMAT(NOW(),'%Y-%m-%d'), DATE_FORMAT(NOW(),'%T'))";
$rgTrimedMobs[$i] = substr($mobnos[$i],2,11);
}
$strInsertQuery = "insert into smslog(fmobileno, freasoncode, fguid, fenttype, fackdate, facktime) values".implode(',',$rgInsert);
$result1 = mysqli_query($conn,$strInsertQuery);
}
$subject = "SMS Sent Status Report";
$emails = ['prashanth.k@logisys.org','arun.v@logisys.org','hnagaraj@hotmail.com', 'mohan.s@logisys.org', 'hnramesh@logisys.org'];
for($i=0;$i< count($emails); $i++)
{
$emailid = $emails[$i];
$resp = sendGridMail($emailid,$subject,$strHtmlMail);
}
echo $strHtmlMail;
}
?>
|