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.15.214.238
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/task_reminder.php |
<?php
include("sys_session.php");
include("sys_connect.php");
include("sys_mainphp.php");
include("api_sendsms.php");
$load_data = $_POST['load_data'];
$resp_mesg = "";
$resp_stat = "";
$resp_file = "";
$sms1_sent = "";
$sms2_sent = "";
if ($load_data == 'grid_data') {
require("sys_grid_data.php");
if ($type_id == 'ADMIN') {
$myqry = " ftaskasby like '$_POST[task_asby]' and ftaskasto like '$_POST[task_asto]' ";
} else {
$myqry = " (ftaskasby like '$_POST[task_asby]' and ftaskasto like '$_POST[task_asto]') and (ftaskasby like '$empl_id' or ftaskasto like '$empl_id') ";
}
$i = 1;
$grid_sele = "select ftaskcode,date_format(ftaskdate,'%d/%m/%Y') as ltaskdate, ftaskname, ftaskasby, e1.femplname as fasbyname, ftaskasto, e2.femplname as fastoname, ftaskstat,fcompdate
from taskreminder tk
left join masempl e1 on tk.ftaskasby = e1.femplcode
left join masempl e2 on tk.ftaskasto = e2.femplcode
where ftaskstat like '$_POST[task_stat]' and ftaskname like '%$_POST[task_find]%'
and ". $myqry ."
and ifnull(tk.fdeleted,'F')='F'
order by ftaskdate desc, ftaskcode desc";
$grid_para = grid_limit($grid_sele);
$page_numb = $grid_para[0];
$last_page = $grid_para[1];
$page_limt = $grid_para[2];
$lowr_limt = $grid_para[3];
$mysql = $grid_sele . " limit $lowr_limt, $page_limt";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt > 0) {
echo "<table>";
echo "<thead>";
echo "<tr>";
echo "<th width=4%> # </th>";
echo "<th width=6%> ID </th>";
echo "<th width=8%> Date</th>";
echo "<th width=30%> Reminder Name </th>";
echo "<th width=16%> Reminder from </th>";
echo "<th width=16%> Reminder To </th>";
echo "<th width=8%> Status </th>";
echo "<th width=8%> Completed On </th>";
echo "<th width=10%> Action</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while ($myrow = mysqli_fetch_assoc($myres)) {
$page_link = " <a class='btn btn-success btn-sm' href=# onClick=edit_data('$myrow[ftaskcode]')>Edit</a> ";
// $page_link .= " <a class='btn btn-danger btn-sm' href=# onClick=dele_data('$myrow[ftaskcode]')>Delete</a>";
echo "<tr id=$myrow[ftaskcode]>";
echo "<td align=center> $i</td>";
echo "<td align=center>$myrow[ftaskcode]</td>";
echo "<td align=center>$myrow[ltaskdate]</td>";
echo "<td align=left> $myrow[ftaskname]</td>";
echo "<td align=left> $myrow[fasbyname]</td>";
echo "<td align=left> $myrow[fastoname]</td>";
echo "<td align=center>$myrow[ftaskstat]</td>";
echo "<td align=center>$myrow[fcompdate]</td>";
echo "<td align=center>$page_link</td>";
echo "</tr>";
$i++;
}
echo "</tbody>";
echo "</table>";
include("sys_grid_navbar.php");
} else {
echo "<div class='alert alert-info'>No details found!</div>";
}
}
if ($load_data == 'dele_data') {
$dele_code = $_POST['dele_code'];
$mysql = "update taskreminder set fdeleted='T' where ftaskcode='$dele_code'";
$myres = mysqli_query($mycon, $mysql);
}
if ($load_data == 'empl_list') {
$mysql = "select * from masempl e left join masdept d on e.fdeptcode=d.fdeptcode where fempltype='P' and ifnull(femplstat,'F')='T' and femplcode not in ('1000') and e.fdeptcode not in ('DEP','IHF') order by femplname";
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) > 1) {
echo "<option value=''>--Select--</option>";
}
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<option value='$myrow[femplcode]'>$myrow[femplname] | $myrow[femplcode] | $myrow[fempldesn] | $myrow[fdeptcode] | $myrow[fdeptshrt]</option>";
}
}
if ($load_data == 'sele_empl_copy') {
$mysql = "select em.femplcode,em.femplname,em.fempldesn,em.femplphot,dp.fdeptcode,dp.fdeptshrt from masempl em
inner join masdept dp on em.fdeptcode = dp.fdeptcode
where ifnull(femplstat,'F')='T' and femplname like '%$_POST[sele_find]%' and femplcode not in ('1000','$_POST[task_asby]','$_POST[task_asto]') and em.fdeptcode not in ('DEP','IHF')
order by femplname;";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt > 0) {
echo "<div class='list-group'>";
while ($myrow = mysqli_fetch_assoc($myres)) {
if ($myrow['femplphot'] == '') {
$empl_imge = "img-empl/blank.png";
} else {
$url = dirname($_SERVER['PHP_SELF']) . "../img-empl/" . $myrow['femplphot'];
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($handle);
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if ($httpCode == 404) {
$empl_imge = "img-empl/blank.png";
} else {
$empl_imge = "img-empl/" . $myrow['femplphot'];
}
curl_close($handle);
}
echo "<label class='list-group-item text-left' style='padding:3px 5px;border-radius:0px;font-weight:normal;'>";
echo "<img src='$empl_imge' class='img-rounded' alt='' height='20px' width='20px' style='border:1px solid #ccc;' align='absmiddle'> $myrow[femplname] <div style='float:right;'> $myrow[femplcode] | $myrow[fdeptcode] <a href='#'>Add</a></div>";
echo "</label>";
}
echo "</div>";
}
else{
echo "<div class='alert alert-info'>No details found to add!</div>";
}
}
if ($load_data == 'list_empl_copy') {
$mysql = "select em.femplcode,em.femplname,em.fempldesn,em.femplphot,dp.fdeptcode,dp.fdeptshrt from masempl em
inner join masdept dp on em.fdeptcode = dp.fdeptcode
inner join taskreminder rm on em.femplcode = rm.ftaskcopy and rm.ftaskcode = '$_POST[task_code]'
where ifnull(femplstat,'F')='T' and femplname like '%$_POST[list_find]%' and femplcode not in ('1000','$empl_id') and em.fdeptcode not in ('DEP','IHF')
order by femplname;";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt > 0) {
echo "<div class='list-group'>";
while ($myrow = mysqli_fetch_assoc($myres)) {
if ($myrow['femplphot'] == '') {
$empl_imge = "img-empl/blank.png";
} else {
$url = dirname($_SERVER['PHP_SELF']) . "../img-empl/" . $myrow['femplphot'];
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($handle);
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if ($httpCode == 404) {
$empl_imge = "img-empl/blank.png";
} else {
$empl_imge = "img-empl/" . $myrow['femplphot'];
}
curl_close($handle);
}
echo "<label class='list-group-item text-left' style='padding:3px 5px;border-radius:0px;font-weight:normal;'>";
echo "<img src='$empl_imge' class='img-rounded' alt='' height='20px' width='20px' style='border:1px solid #ccc;' align='absmiddle'> $myrow[femplname] <div style='float:right;'> $myrow[femplcode] | $myrow[fdeptcode] <a href='#'>Remove</a></div>";
echo "</label>";
}
echo "</div>";
}
else{
echo "<div class='alert alert-info'>No details found to remove!</div>";
}
}
if ($load_data == 'disp_data') {
$mysql = "select * from taskreminder where ftaskcode='$_POST[task_code]'";
$myres = mysqli_query($mycon, $mysql);
$myrows = array();
while ($r = mysqli_fetch_assoc($myres)) {
$myrows = $r;
}
echo json_encode($myrows);
}
if ($load_data == 'save_data') {
$page_mode = $_POST['page_mode'];
$task_code = $_POST['task_code'];
$task_name = $_POST['task_name'];
$last_date = $_POST['last_date'];
$task_asby = $_POST['task_asby'];
$task_asto = $_POST['task_asto'];
$task_stat = $_POST['task_stat'];
$strt_date = $_POST['strt_date'];
$last_date = $_POST['last_date'];
$comp_date = $_POST['comp_date'];
$mysql1 = "select * from masempl where femplcode='$task_asto'";
$myres1 = mysqli_query($mycon, $mysql1);
while ($myrow1 = mysqli_fetch_assoc($myres1)) {
$asto_name = $myrow1['femplname'];
$asto_mobl = $myrow1['femplmobl'];
$asto_mail = $myrow1['femplmail'];
}
$mysql1 = "select * from masempl where femplcode='$task_asby'";
$myres1 = mysqli_query($mycon, $mysql1);
while ($myrow1 = mysqli_fetch_assoc($myres1)) {
$asby_name = $myrow1['femplname'];
$asby_mobl = $myrow1['femplmobl'];
$asby_mail = $myrow1['femplmail'];
}
$updt_time = date("d/m/Y H:i:s");
if ($page_mode == "add") {
$mysql = "insert into taskreminder (ftaskdate, ftaskname, ftaskdetl, ftaskasby, ftaskasto, ftaskremk, ftaskstat,
fstrtdate, flastdate, fcompdate,fremndat1,fremndat2,fremndat3,fupdtuser, fupdttime) values(
str_to_date('$_POST[task_date]','%d/%m/%Y') , '$_POST[task_name]', '$_POST[task_detl]',
'$_POST[task_asby]', '$_POST[task_asto]', '$_POST[task_remk]', '$_POST[task_stat]',
str_to_date(if('$_POST[strt_date]'='',null,'$_POST[strt_date]'),'%d/%m/%Y'),
str_to_date(if('$_POST[last_date]'='',null,'$_POST[last_date]'),'%d/%m/%Y'),
str_to_date(if('$_POST[comp_date]'='',null,'$_POST[comp_date]'),'%d/%m/%Y'),
str_to_date(if('$_POST[remn_dat1]'='',null,'$_POST[remn_dat1]'),'%d/%m/%Y'),
str_to_date(if('$_POST[remn_dat2]'='',null,'$_POST[remn_dat2]'),'%d/%m/%Y'),
str_to_date(if('$_POST[remn_dat2]'='',null,'$_POST[remn_dat3]'),'%d/%m/%Y'), '$user_id',now())";
$myres = mysqli_query($mycon, $mysql);
$resp_stat = "T";
$resp_mesg = "Task added!";
$crtd_code = str_pad(mysqli_insert_id($mycon), 6, '0', STR_PAD_LEFT);
set_user_logs($dept_id, $user_id, 'TASK', 'TASK REMINDER CREATED: ' . $crtd_code . ' - ' . $_POST['task_date'] . ', by: ' . $asby_name . ', to: ' . $asto_name);
//sms note
if (strlen($asto_mobl) == 10) {
$asto_mesg = "Task Created [" . $crtd_code . "] " . chr(10) . "Task Name : " . $task_name . chr(10) . "Task From : " . $asby_name . chr(10) . "Start Date : " . $strt_date . chr(10) . "Due Date : " . $last_date . " - Uniclare";
send_sms($asto_mobl, $asto_mesg);
$asto_qry = "insert ignore into logisys3_comexam.sendsms(funivcode,fregno,fmobileno,fenttype,fsubcode,fmessage,fstatus,fdeleted,fyear,fexamtype,fupdate) values('999','$_POST[task_asto]','$asto_mobl','oums',concat(date_format(current_date,'%d/%m/%Y'),'_nt_','$crtd_code'),'$asto_mesg','T','F',year(current_date),'1',now())";
$asto_res = mysqli_query($mycon, $asto_qry);
}
if (strlen($asby_mobl) == 10) {
$asby_mesg = "Task Created [" . $crtd_code . "] " . chr(10) . "Task Name : " . $task_name . chr(10) . "Assigned To : " . $asto_name . chr(10) . "Start Date : " . $strt_date . chr(10) . "Due Date : " . $last_date . " - Uniclare";
send_sms($asby_mobl, $asby_mesg);
$asby_qry = "insert ignore into logisys3_comexam.sendsms(funivcode,fregno,fmobileno,fenttype,fsubcode,fmessage,fstatus,fdeleted,fyear,fexamtype,fupdate) values('999','$_POST[task_asby]','$asby_mobl','oums',concat(date_format(current_date,'%d/%m/%Y'),'_nt_','$crtd_code'),'$asby_mesg','T','F',year(current_date),'1',now())";
$asby_res = mysqli_query($mycon, $asby_qry);
}
} else {
$mysql = "update taskreminder set ftaskname='$_POST[task_name]', ftaskdetl='$_POST[task_detl]', ftaskasto='$_POST[task_asto]',
ftaskremk='$_POST[task_remk]', ftaskstat='$_POST[task_stat]', fstrtdate=str_to_date('$_POST[strt_date]','%d/%m/%Y'),
flastdate=str_to_date('$_POST[last_date]','%d/%m/%Y'), fcompdate=str_to_date('$_POST[comp_date]','%d/%m/%Y'),
fupdtuser='$user_id',fupdttime=now() where ftaskcode='$_POST[task_code]]'";
$myres = mysqli_query($mycon, $mysql);
$resp_stat = "T";
$resp_mesg = "Task details updated!";
set_user_logs($dept_id, $user_id, 'TASK', 'TASK REMINDER UPDATED: ' . $task_code . ' - ' . $_POST['task_date'] . ', by: ' . $asby_name . ', to: ' . $asto_name);
//sms note
if ($task_stat == 'COMPLETED') {
$mysql = "select ftaskcode,datediff(fcompdate,flastdate) as task_dely from taskreminder where ftaskcode='$task_code';";
$myres = mysqli_query($mycon, $mysql);
while ($myrow = mysqli_fetch_assoc($myres)) {
$task_dely = $myrow['task_dely'];
}
if (strlen($asto_mobl) == 10) {
$taskqry = "insert ignore into logisys3_comexam.sendsms(funivcode,fregno,fmobileno,fenttype,fsubcode,fmessage,fstatus,fdeleted,fyear,fexamtype,fupdate)
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 Completed [',ftaskcode,']\nTask name : ',ftaskname,'\nTask From : ',e1.femplname,'\nCompleted On : ',date_format(fcompdate,'%d/%m/%Y'),'\nStart date : ',date_format(fstrtdate,'%d/%m/%Y'),'\nDue date : ',date_format(flastdate,'%d/%m/%Y'),'\nDelay : ',datediff(fcompdate,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='COMPLETED' and ftaskcode='$task_code' and flastdate<=current_date and ifnull(t.fdeleted,'F')<>'T';";
$taskres = mysqli_query($mycon, $taskqry);
$asto_mesg = "Task Completed [" . $task_code . "] " . chr(10) . "Task Name : " . $task_name . chr(10) . "Task From : " . $asby_name . chr(10) . "Completed On : " . $comp_date . chr(10) . "Start Date : " . $strt_date . chr(10) . "Due Date : " . $last_date . chr(10) . "Delay : " . $task_dely . " days - Uniclare";
send_sms($asto_mobl, $asto_mesg);
}
if (strlen($asby_mobl) == 10) {
$taskqry = "insert ignore into logisys3_comexam.sendsms(funivcode,fregno,fmobileno,fenttype,fsubcode,fmessage,fstatus,fdeleted,fyear,fexamtype,fupdate)
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 Completed [',ftaskcode,']\nTask name : ',ftaskname,'\nCompleted By : ',e2.femplname,'\nCompleted On : ',date_format(fcompdate,'%d/%m/%Y'),'\nStart date : ',date_format(fstrtdate,'%d/%m/%Y'),'\nDue date : ',date_format(flastdate,'%d/%m/%Y'),'\nDelay : ',datediff(fcompdate,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='COMPLETED' and ftaskcode='$task_code' and flastdate<=current_date and ifnull(t.fdeleted,'F')<>'T';";
$taskres = mysqli_query($mycon, $taskqry);
$asby_mesg = "Task Completed [" . $task_code . "] " . chr(10) . "Task Name : " . $task_name . chr(10) . "Completed By : " . $asto_name . chr(10) . "Completed On : " . $comp_date . chr(10) . "Start Date : " . $strt_date . chr(10) . "Due Date : " . $last_date . chr(10) . "Delay : " . $task_dely . " days - Uniclare";
send_sms($asby_mobl, $asby_mesg);
}
}
}
echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));
}
|