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.226.96.202
<?php
function uploadSMSFile($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$tmpid = $aobj_context->mobj_data["tmpid"];
$key = $aobj_context->mobj_data["key"];
$varno = $aobj_context->mobj_data["varno"];
$updtype = $aobj_context->mobj_data["updtype"];
for ($i=0; $i < $varno; $i++) {
$no = $i+1;
${"var$no"} = $aobj_context->mobj_data["var_$no"];
}
$file = $_FILES['file'];
$date = date("Ymdhis");
$filename = $date.$file['name'];
$filedata = $file['tmp_name'];
if(move_uploaded_file($filedata, 'uploads/'.$filename)){
$file = $aobj_context->main_src.'uploads/'.$filename;
if(!file_exists($file)){
$data = "Upload failure. Upload file does not exist";
echo $aobj_context->mobj_output->ToJSONEnvelope($data, -1, "failure");
return;
}else{
$cnd = "";
if($updtype == "msg"){
$cnd = ", fmessage text";
}
$query1 = "drop table if exists tmpsendsms";
$result1 = $aobj_context->pobj_db->Execute($query1);
$query2 = "create table tmpsendsms(
fmobileno varchar(10) primary key $cnd)";
$result2 = $aobj_context->pobj_db->Execute($query2);
$csvFile = $file;
$handle = fopen($csvFile, "r");
if ($handle === false) {
die("Error opening file");
}
$columns = $updtype == "mob" ? 'fmobileno' : 'fmobileno, fmessage';
$i=0;
while (($data = fgetcsv($handle)) !== false) {
$arr = "{$data[0]}', '{$data[1]}";
$explode = explode(",", $arr);
$values = $updtype == "mob" ? "VALUES ('{$data[0]}')" : "VALUES('{$data[0]}', '{$data[1]}')";
if($i != 0){
if($data[0] != ""){
$sql = "INSERT INTO tmpsendsms ($columns) $values";
$result = $aobj_context->pobj_db->Execute($sql);
}
}
$i++;
}
if($result){
$tmpQuery = "select ftemplate from adm_smstemplate where ftempid='{$tmpid}'";
$tmpres = $aobj_context->pobj_db->GetRow($tmpQuery);
$pattern = $tmpres['ftemplate'];
for ($i=0; $i < $varno; $i++) {
$no = $i+1;
$new_string = str_replace("{#var$no#}", ${"var$no"}, $pattern);
$pattern = $new_string;
}
$enttype = 'UPD'.$univcode.date("Ymdhi");
$sms = $updtype == "mob" ? "'{$pattern}'" : "fmessage";
$query = "insert ignore into adm_sendsms(funivcode, fregno, fmobileno, fenttype,
fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate, fmsgtype, fusertype, ftmpid, fkey)
select '{$univcode}', fmobileno, fmobileno, '{$enttype}', '{$enttype}', $sms, 'F', 'F', '2020', '2', NOW(), 'G', '900', '{$tmpid}', '{$key}'
from tmpsendsms";
// var_dump($query);die();
$results = $aobj_context->pobj_db->Execute($query);
if($results){
unlink($file);
$data = "Upload success";
echo $aobj_context->mobj_output->ToJSONEnvelope($data, 0, "success");
return;
}else{
$data = "Upload failure. Error while loading excel data to database";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
return;
}
}else{
$data = "Upload failure. Error while loading excel data to database";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
return;
}
}
}
}
function getSMSData($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$qury = "select funivcode, fenttype, fmessage, sum(if(fstatus='T',1,0)) as fsent, sum(if(fstatus='F',1,0)) as ffpend,
count(fmobileno) as ftotal, date_format(fupdate,'%d/%m/%Y') as pushdate, fyear, fexamtype, fusertype,
if(date_format(fupdate, '%Y-%m-%d') > date_format(date_sub(now(), interval 3 DAY), '%Y-%m-%d'), 'T', 'F') as curdate
from adm_sendsms where funivcode = '{$univcode}' and fmsgtype = 'G'
group by funivcode, fenttype
order by fupdate desc";
$result = $aobj_context->pobj_db->GetAll($qury);
if($result){
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
} else {
$arr['msg'] = 'No Deatils Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function deleteSMSData($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$univ = $aobj_context->mobj_data["univ"];
$usertype = $aobj_context->mobj_data["usertype"];
$enttype = $aobj_context->mobj_data["enttype"];
$query = "delete from adm_sendsms
where funivcode = '{$univ}' and fusertype = '{$usertype}'
and fenttype = '{$enttype}' and fstatus = 'F' ";
$result = $aobj_context->pobj_db->Execute($query);
if($result){
$rows = $aobj_context->pobj_db->affected_rows();
$arr['msg'] = "{$rows} Records deleted.";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
} else {
$arr['msg'] = 'No Deatils Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function getSmsTemplate($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$query = "select concat(ftempid, ' - ', fkey, ' - ', fvarno)as value,
ifnull(fenttype, '') as text, ifnull(ftemplate, '')as ftemplate
from adm_smstemplate
where ifnull(fdeleted, '') <> 'T';";
$result = $aobj_context->pobj_db->GetAll($query);
if($result){
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
} else {
$arr['msg'] = 'Template Not Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function resendSMS($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$univ = $aobj_context->mobj_data["univ"];
$usertype = $aobj_context->mobj_data["usertype"];
$enttype = $aobj_context->mobj_data["enttype"];
$entcnd = 'UPD'.$univcode.date("Ymdhi");
$query = "insert ignore into adm_sendsms(funivcode, fregno, fmobileno, fenttype,
fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate, fmsgtype, fusertype, ftmpid, fkey)
select funivcode, fregno, fmobileno, '{$entcnd}',
'{$entcnd}', fmessage, 'F', fdeleted, fyear, fexamtype,now(), fmsgtype, fusertype, ftmpid, fkey
from adm_sendsms where fenttype = '{$enttype}'
and funivcode = '{$univcode}'";
$result = $aobj_context->pobj_db->Execute($query);
if($result){
$rows = $aobj_context->pobj_db->affected_rows();
$arr['msg'] = "{$rows} Records Created.";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
} else {
$arr['msg'] = 'No Deatils Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
?>
|