0xV3NOMx
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.22.27.41


Current Path : /var/www/html/oums/src/
Upload File :
Current File : /var/www/html/oums/src/oums_sms_push.php

<?php
ini_set('display_errors', 'on');
ini_set('memory_limit', '900M');
ini_set('max_execution_time', 0);

date_default_timezone_set("Asia/Calcutta");   //India time (GMT+5:30)

include("sys_connect.php");
$mysql = "select * from sys_control";
$myres = mysqli_query($mycon, $mysql);
$admn_mobl = "";
while ($myrow = mysqli_fetch_assoc($myres)) {
    $admn_mobl = $myrow['fadmnmobl'];
}

$insert_query = "insert ignore into logisys3_comexam.sendsms(funivcode,fregno,fmobileno,fenttype,fsubcode,fmessage,fstatus,fdeleted,fyear,fexamtype,fupdate) ";

//attendance status ab to head
$query =  $insert_query .
    "select '999' as funivcode,'head' as fregno,(select femplmobl from logisys3_oums.masempl where femplcode=fdepthead) as fmobileno,'oums' as fenttype,
    concat(date_format(current_date,'%d/%m/%Y'),'_atab_',e.fdeptcode) as fsubcode,
    concat('Absent Update\n Dear ',(select femplname from logisys3_oums.masempl where femplcode=fdepthead),', Following staff are absent at ',d.fdeptshrt,' [',d.fdeptcode,']',' on ',date_format(current_date,'%d/%m/%Y'),'.\n',group_concat(distinct concat('[',e.femplcode,'] ',femplname) order by femplname separator '\n'),' - Uniclare') as fmessage,
    'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
    from logisys3_oums.masempl e 
    inner join logisys3_oums.masdept d on e.fdeptcode = d.fdeptcode 
    inner join logisys3_oums.attendance a on e.femplcode = a.femplcode and a.fattndate=current_date and fattnstat = 'AB'
    group by e.fdeptcode order by femplname;";
$result = mysqli_query($mycon, $query);

//attendance status cl to head
$query =  $insert_query .
    "select '999' as funivcode,'head' as fregno,(select femplmobl from logisys3_oums.masempl where femplcode=fdepthead) as fmobileno,'oums' as fenttype,
    concat(date_format(current_date,'%d/%m/%Y'),'_atcl_',e.fdeptcode) as fsubcode,
    concat('Leave Update\n Dear ',(select femplname from logisys3_oums.masempl where femplcode=fdepthead),', Following staff are on leave at ',d.fdeptshrt,' [',d.fdeptcode,']',' on ',date_format(current_date,'%d/%m/%Y'),'.\n',group_concat(distinct concat('[',e.femplcode,'] ',femplname) order by femplname separator '\n'),' - Uniclare') as fmessage,
    'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
    from logisys3_oums.masempl e 
    inner join logisys3_oums.masdept d on e.fdeptcode = d.fdeptcode 
    inner join logisys3_oums.attendance a on e.femplcode = a.femplcode and a.fattndate=current_date and fattnstat = 'CL'
    group by e.fdeptcode order by femplname;";
$result = mysqli_query($mycon, $query);

//attendance status ab to user
$query =  $insert_query .
    "select '999' as funivcode,'user' as fregno,femplmobl as fmobileno,'oums' as fenttype,
    concat(date_format(current_date,'%d/%m/%Y'),'_atab_',e.femplcode) as fsubcode,
    concat('Absent Update\n Dear ',femplname,', You have been marked Absent on ',date_format(current_date,'%d/%m/%Y'),' at ',d.fdeptshrt,' [',d.fdeptcode,'] - Uniclare') as message,
    'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now()
    from logisys3_oums.masempl e
    inner join logisys3_oums.masdept d on e.fdeptcode = d.fdeptcode
    inner join logisys3_oums.attendance a on e.femplcode = a.femplcode and a.fattndate=current_date and fattnstat = 'AB'
    where ifnull(femplmobl,'')<>''  
    order by femplname;";
$result = mysqli_query($mycon, $query);

//attendance status cl to user
$query =  $insert_query .
    "select '999' as funivcode,'user' as fregno,femplmobl as fmobileno,'oums' as fenttype,
    concat(date_format(current_date,'%d/%m/%Y'),'_atcl_',e.femplcode) as fsubcode,
    concat('Leave Update\n Dear ',femplname,', You have been marked CL on ',date_format(current_date,'%d/%m/%Y'),' at ',d.fdeptshrt,' [',d.fdeptcode,'] - Uniclare') as message,
    'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now()
    from logisys3_oums.masempl e
    inner join logisys3_oums.masdept d on e.fdeptcode = d.fdeptcode
    inner join logisys3_oums.attendance a on e.femplcode = a.femplcode and a.fattndate=current_date and fattnstat = 'CL'
    where ifnull(femplmobl,'')<>''  
    order by femplname;";
$result = mysqli_query($mycon, $query);

// attendance entry pending to admin
// $query =  $insert_query .
//     "select '999' as funivcode,'admn' as fregno,'$admn_mobl' as fmobileno,'oums' as fenttype,
//     concat(date_format(current_date,'%d/%m/%Y'),'_attn_999') as fsubcode,
//     concat('Dear Admin, Attendance is pending on ',date_format(current_date,'%d/%m/%Y'),' at ',group_concat(distinct d.fdeptshrt,' [',d.fdeptcode,']' order by d.fdeptshrt separator ', '), ') as fmessage, 
//     'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
//     from logisys3_oums.masdept d
//     left join logisys3_oums.attendance  a on d.fdeptcode=a.fdeptcode and a.fattndate=current_date 
//     left join logisys3_oums.masholiday h on d.fdeptcode=h.fdeptcode and h.fholidate=current_date and h.fdeleted<>'T'
//     left join logisys3_oums.masempl    e1 on d.fdeptcode=e1.fdeptcode and femplstat='T' 
//     left join logisys3_oums.masempl    e2 on d.fdepthead=e2.femplcode 
//     where fdeptstat='T' and d.fattnenbl='T' 
//     and a.fdeptcode is null and h.fdeptcode is null and e1.fdeptcode is not null and dayname(current_date)<>'Sunday';";
// if ($admn_mobl != '') {
//     $result = mysqli_query($mycon, $query);
// }

// attendance entry pending to head
// $query =  $insert_query .
//     "select '999' as funivcode,'head' as fregno,f.femplmobl,'oums' as fenttype,
// concat(date_format(current_date,'%d/%m/%Y'),'_attn_',f.fdeptcode) as fsubcode,
// concat('Dear ',f.femplname,', Attendance is pending on ',date_format(current_date,'%d/%m/%Y'),' at ',group_concat(distinct d.fdeptshrt,' [',d.fdeptcode,']' order by d.fdeptshrt separator ', '),') as fmessage, 
// 'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
// from logisys3_oums.masdept d
// left join logisys3_oums.attendance  a on d.fdeptcode=a.fdeptcode and a.fattndate=current_date 
// left join logisys3_oums.masholiday h on d.fdeptcode=h.fdeptcode and h.fholidate=current_date and h.fdeleted<>'T'
// left join logisys3_oums.masempl    e on d.fdeptcode=e.fdeptcode and femplstat='t' 
// left join logisys3_oums.masempl    f on d.fdepthead=f.femplcode 
// where fdeptstat='T' and d.fattnenbl='T' 
// and a.fdeptcode is null and h.fdeptcode is null and e.fdeptcode is not null and dayname(current_date)<>'Sunday'
// group by f.femplcode;";
// $result = mysqli_query($mycon, $query);
//end of attedance alerts


//work entry alerts
//work entry pending alert to admin
// $query =  $insert_query .
//     "select '999' as funivcode,'admn' as fregno,'$admn_mobl' as fmobileno,'oums' as fenttype,
//     concat(date_format(subdate(current_date,1),'%d/%m/%Y'),'_work_999') as fsubcode,
//     concat('Dear Admin, Work entry is pending on ',date_format(subdate(current_date,1),'%d/%m/%Y'),' by\n',group_concat(dept_empl order by dept_empl separator '\n')) as fmessage,
//     'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
//     from 
//     (select concat('(',d.fdeptshrt,' -> ',group_concat(distinct concat('[',e.femplcode,'] ',femplname) order by femplname separator ', '),')') as dept_empl
//     from logisys3_oums.masempl e 
//     inner join logisys3_oums.masdept d on e.fdeptcode = d.fdeptcode
//     inner join logisys3_oums.attendance a on e.femplcode = a.femplcode and a.fattndate=subdate(current_date,1) 
//     where femplstat='T' and fworkentr='T' and e.fdeleted<>'T' 
//     and e.femplcode not in (select femplcode from logisys3_oums.workentry where fworkdate=subdate(current_date,1)) 
//     and fattnstat like 'p%' group by e.fdeptcode order by e.fdeptcode,femplname) w;";
// if ($admn_mobl != '') {
//     $result = mysqli_query($mycon, $query);
// }

//work entry pending alert to dept head
$query =  $insert_query .
    "select '999' as funivcode,'head' as fregno,(select femplmobl from logisys3_oums.masempl where femplcode=fdepthead) as fmobileno,'oums' as fenttype,
    concat(date_format(subdate(current_date,1),'%d/%m/%Y'),'_work_',e.fdeptcode) as fsubcode,
    concat('Dear ',(select femplname from logisys3_oums.masempl where femplcode=fdepthead),', Work entry is pending at ',d.fdeptshrt,' [',d.fdeptcode,'] on ',date_format(subdate(current_date,1),'%d/%m/%Y'),' by\n',group_concat(distinct concat('[',e.femplcode,'] ',femplname) order by femplname separator '\n'),' - Uniclare') as fmessage,
    'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
    from logisys3_oums.masempl e 
    inner join logisys3_oums.masdept d on e.fdeptcode = d.fdeptcode 
    inner join logisys3_oums.attendance a on e.femplcode = a.femplcode and a.fattndate=subdate(current_date,1) 
    where e.femplstat='T' and e.fworkentr='T' and e.fdeleted<>'T' and ifnull(e.fupdtabcl,'')<>'T'
    and e.femplcode not in (select femplcode from logisys3_oums.workentry where fworkdate=subdate(current_date,1)) 
    and fattnstat like 'p%' 
    group by e.fdeptcode order by femplname;";
$result = mysqli_query($mycon, $query);

// work entry pending alert to staff
// $query =  $insert_query .
//     "select '999' as funivcode,'user' as fregno,femplmobl as fmobileno,'oums' as fenttype,
//     concat(date_format(subdate(current_date,1),'%d/%m/%Y'),'_work_',e.femplcode) as fsubcode,
//     concat('Dear ',femplname,', Your work entry is pending on ',date_format(subdate(current_date,1),'%d/%m/%Y'),' at ',d.fdeptshrt,' [',d.fdeptcode,'] - Uniclare') as message,
//     'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now()
//     from logisys3_oums.masempl e
//     inner join logisys3_oums.masdept d on e.fdeptcode = d.fdeptcode
//     inner join logisys3_oums.attendance a on e.femplcode = a.femplcode and a.fattndate=subdate(current_date,1) 
//     where femplstat='T' and fworkentr='T' and e.fdeleted<>'T' and ifnull(femplmobl,'')<>'' and ifnull(e.fupdtabcl,'')<>'T'
//     and e.femplcode not in (select femplcode from logisys3_oums.workentry where fworkdate=subdate(current_date,1)) and fattnstat like 'p%' 
//     order by femplname;";
// $result = mysqli_query($mycon, $query);
//end of work entry alerts



//task reminder alerts
//task pending alert to admin
$query =  $insert_query .
    "select '999' as funivcode,'1001' as fregno,'$admn_mobl' as fmobileno,'oums' as fenttype,
    concat(date_format(current_date,'%d/%m/%Y'),'_rm_',ftaskcode) as fsubcode,
    concat('Task Reminder [',ftaskcode,']\nTask name : ',ftaskname,'\nAssigned to : ',e2.femplname,'\nAssigned by : ',e1.femplname,'\nStart date : ',date_format(fstrtdate,'%d/%m/%Y'),'\nDue date : ',date_format(flastdate,'%d/%m/%Y'),'\nDelay : ',datediff(current_date,flastdate),' days - Uniclare') as fmessage,
    'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
    from logisys3_oums.taskreminder t
    inner join logisys3_oums.masempl e1 on t.ftaskasby=e1.femplcode
    inner join logisys3_oums.masempl e2 on t.ftaskasto=e2.femplcode
    where ftaskstat='PENDING' and flastdate<=current_date and ifnull(t.fdeleted,'F')<>'T' and ftaskasby<>ftaskasto;";
if ($admn_mobl != '') {
    $result = mysqli_query($mycon, $query);
}

// task pending alert to assigner
$query =  $insert_query .
    "select '999' as funivcode,ftaskasby as fregno,e1.femplmobl as fmobileno,'oums' as fenttype,
    concat(date_format(current_date,'%d/%m/%Y'),'_rm_',ftaskcode) as fsubcode,
    concat('Task Reminder [',ftaskcode,']\nTask name : ',ftaskname,'\nAssigned to : ',e2.femplname,'\nAssigned by : ',e1.femplname,'\nStart date : ',date_format(fstrtdate,'%d/%m/%Y'),'\nDue date : ',date_format(flastdate,'%d/%m/%Y'),'\nDelay : ',datediff(current_date,flastdate),' days - Uniclare') as fmessage,
    'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
    from logisys3_oums.taskreminder t
    inner join logisys3_oums.masempl e1 on t.ftaskasby=e1.femplcode
    inner join logisys3_oums.masempl e2 on t.ftaskasto=e2.femplcode
    where ftaskstat='PENDING' and flastdate<=current_date and ifnull(t.fdeleted,'F')<>'T';";
$result = mysqli_query($mycon, $query);

// task pending alert to assignee
// concat('Task Reminder [',ftaskcode,']\nTask name : ',ftaskname,'\nTask from : ',e1.femplname,'\nStart date : ',date_format(fstrtdate,'%d/%m/%Y'),'\nDue date : ',date_format(flastdate,'%d/%m/%Y'),'\nDelay : ',datediff(current_date,flastdate),' days - Uniclare') as fmessage,
$query =  $insert_query .
    "select '999' as funivcode,ftaskasto as fregno,e2.femplmobl as fmobileno,'oums' as fenttype,
    concat(date_format(current_date,'%d/%m/%Y'),'_rm_',ftaskcode) as fsubcode,
    concat('Task Reminder [',ftaskcode,']\nTask name : ',ftaskname,'\nAssigned to : ',e2.femplname,'\nAssigned by : ',e1.femplname,'\nStart date : ',date_format(fstrtdate,'%d/%m/%Y'),'\nDue date : ',date_format(flastdate,'%d/%m/%Y'),'\nDelay : ',datediff(current_date,flastdate),' days - Uniclare') as fmessage,
    'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
    from logisys3_oums.taskreminder t
    inner join logisys3_oums.masempl e1 on t.ftaskasby=e1.femplcode
    inner join logisys3_oums.masempl e2 on t.ftaskasto=e2.femplcode
    where ftaskstat='PENDING' and flastdate<=current_date and ifnull(t.fdeleted,'F')<>'T';";
$result = mysqli_query($mycon, $query);

//task reminder 01
$query =  $insert_query .
    "select '999' as funivcode,ftaskasby as fregno,e1.femplmobl as fmobileno,'oums' as fenttype,concat(ftaskcode,'reminder01') as fsubcode,
    concat('Task Reminder 01 [',ftaskcode,'] : ',ftaskname,', To: ',e2.femplname,', Init. date: ',date_format(fstrtdate,'%d/%m/%Y'),', Due date: ',date_format(flastdate,'%d/%m/%Y')) as fmessage,'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
    from logisys3_oums.taskreminder t
    inner join logisys3_oums.masempl e1 on t.ftaskasby=e1.femplcode
    inner join logisys3_oums.masempl e2 on t.ftaskasto=e2.femplcode
    where ftaskstat='PENDING' and fremndat1=current_date and ifnull(fremnsta1,'F')<>'T' and ifnull(t.fdeleted,'F')<>'T' union
    
    select '999' as funivcode,ftaskasto as fregno,e2.femplmobl as fmobileno,'oums' as fenttype,concat(ftaskcode,'reminder01') as fsubcode,
    concat('Task Reminder 01 [',ftaskcode,'] : ',ftaskname,', From: ',e1.femplname,', Init. date: ',date_format(fstrtdate,'%d/%m/%Y'),', Due date: ',date_format(flastdate,'%d/%m/%Y')) as fmessage,'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
    from logisys3_oums.taskreminder t
    inner join logisys3_oums.masempl e1 on t.ftaskasby=e1.femplcode
    inner join logisys3_oums.masempl e2 on t.ftaskasto=e2.femplcode
    where ftaskstat='PENDING' and fremndat1=current_date and ifnull(fremnsta1,'F')<>'T' and ifnull(t.fdeleted,'F')<>'T';";
$result = mysqli_query($mycon, $query);

//task reminder 02
$query =  $insert_query .
    "select '999' as funivcode,ftaskasby as fregno,e1.femplmobl as fmobileno,'oums' as fenttype,concat(ftaskcode,'reminder02') as fsubcode,
    concat('Task Reminder 02 [',ftaskcode,'] : ',ftaskname,', To: ',e2.femplname,', Init. date: ',date_format(fstrtdate,'%d/%m/%Y'),', Due date: ',date_format(flastdate,'%d/%m/%Y')) as fmessage,'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() 
    from logisys3_oums.taskreminder t
    inner join logisys3_oums.masempl e1 on t.ftaskasby=e1.femplcode
    inner join logisys3_oums.masempl e2 on t.ftaskasto=e2.femplcode
    where ftaskstat='PENDING' and fremndat2=current_date and ifnull(fremnsta2,'F')<>'T' and ifnull(t.fdeleted,'F')<>'T' union
    
    select '999' as funivcode,ftaskasto as fregno,e2.femplmobl as fmobileno,'oums' as fenttype,concat(ftaskcode,'reminder02') as fsubcode,
    concat('Task Reminder 02 [',ftaskcode,'] : ',ftaskname,', From: ',e1.femplname,', Init. date: ',date_format(fstrtdate,'%d/%m/%Y'),', Due date: ',date_format(flastdate,'%d/%m/%Y')) as fmessage,'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() from logisys3_oums.taskreminder t
    inner join logisys3_oums.masempl e1 on t.ftaskasby=e1.femplcode
    inner join logisys3_oums.masempl e2 on t.ftaskasto=e2.femplcode
    where ftaskstat='PENDING' and fremndat2=current_date and ifnull(fremnsta2,'F')<>'T';";
$result = mysqli_query($mycon, $query);

//task reminder 03 
$query =  $insert_query .
    "select '999' as funivcode,ftaskasby as fregno,e1.femplmobl as fmobileno,'oums' as fenttype,concat(ftaskcode,'reminder03') as fsubcode,
    concat('Task Reminder 03 [',ftaskcode,'] : ',ftaskname,', To: ',e2.femplname,', Init. date: ',date_format(fstrtdate,'%d/%m/%Y'),', Due date: ',date_format(flastdate,'%d/%m/%Y')) as fmessage,'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() from logisys3_oums.taskreminder t
    inner join logisys3_oums.masempl e1 on t.ftaskasby=e1.femplcode
    inner join logisys3_oums.masempl e2 on t.ftaskasto=e2.femplcode
    where ftaskstat='PENDING' and fremndat3=current_date and ifnull(fremnsta3,'F')<>'T' union

    select '999' as funivcode,ftaskasto as fregno,e2.femplmobl as fmobileno,'oums' as fenttype,concat(ftaskcode,'reminder03') as fsubcode,
    concat('Task Reminder 03 [',ftaskcode,'] : ',ftaskname,', From: ',e1.femplname,', Init. date: ',date_format(fstrtdate,'%d/%m/%Y'),', Due date: ',date_format(flastdate,'%d/%m/%Y')) as fmessage,'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now() from logisys3_oums.taskreminder t
    inner join logisys3_oums.masempl e1 on t.ftaskasby=e1.femplcode
    inner join logisys3_oums.masempl e2 on t.ftaskasto=e2.femplcode
    where ftaskstat='PENDING' and fremndat3=current_date and ifnull(fremnsta3,'F')<>'T';";
$result = mysqli_query($mycon, $query);    //end if task reminder alerts


// birthday wish to logisys user
$query =  $insert_query .
    "select '999' as funivcode,femplcode as fregno,femplmobl as fmobileno,'oums' as fenttype,
    concat(date_format(current_date,'%d/%m/%Y'),'_bday_',femplcode) as fsubcode,
    concat('Dear ',femplname,', Logisys family wishes you a very Happy Birthday and have a Great future ahead! - Uniclare') as message,
    'F' as fstatus,'F' as fdeleted,year(current_date) as fyear,'1',now()
    from logisys3_oums.masempl e 
    left join logisys3_oums.masdept d on e.fdeptcode=d.fdeptcode 
    where date_format(fbrthdate,'%d-%m') = date_format(current_date,'%d-%m') and ifnull(femplmobl,'')<>'' and femplstat='T'
    order by femplname;";
$result = mysqli_query($mycon, $query);

echo "<br/>OUMS SMS alerts pushed!, Updated on:" . date('m/d/Y h:i:s a', time());