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.143.237.203
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/task_review.php |
<?php
include("sys_session.php");
include("sys_connect.php");
include("sys_mainphp.php");
$load_data = $_POST['load_data'];
$resp_mesg = "";
$resp_stat = "";
$resp_file = "";
if ($load_data == 'grid_data') {
$grid_type = $_POST['grid_type'];
$work_stat = $_POST['work_stat'];
$work_find = $_POST['work_find'];
if (!(isset($_POST['page_numb']))) {
$page_numb = 1;
} else {
$page_numb = intval($_POST['page_numb']);
}
$page_limt = ($_POST["page_limt"] <> "" && is_numeric($_POST["page_limt"])) ? intval($_POST["page_limt"]) : 10;
if (strtolower($grid_type) == "inbox") {
$grid_query = "select * from dailywork where femplwork='$empl_id' and fworkstat like '%$work_stat%' and fworktitl like '%$work_find%' and ifnull(fdeleted,'F')='F' order by fworkdate desc, fworkcode desc";
} elseif (strtolower($grid_type) == "outbox") {
$grid_query = "select * from dailywork where femplassn='$empl_id' and fworkstat like '%$work_stat%' and fworktitl like '%$work_find%' and ifnull(fdeleted,'F')='F' order by fworkdate desc, fworkcode desc";
} else {
$grid_query = "select * from dailywork where (femplwork='$empl_id' or femplassn='$empl_id') and fworkstat like '%$work_stat%' and fworktitl like '%$work_find%' and ifnull(fdeleted,'F')='F' order by fworkdate desc, fworkcode desc";
}
$myres = mysqli_query($mycon, $grid_query);
$mycnt = mysqli_num_rows($myres);
$last_page = ceil($mycnt / $page_limt);
if ($page_numb < 1) {
$page_numb = 1;
} elseif ($page_numb > $last_page) {
$page_numb = $last_page;
}
if ($last_page == 0) {
$lowr_limt = ($page_numb) * $page_limt;
} else {
$lowr_limt = ($page_numb - 1) * $page_limt;
}
$i = 1;
$mysql = $grid_query . " limit $lowr_limt, $page_limt";
if ($myres = mysqli_query($mycon, $mysql)) {
echo "<table class='table_grid'";
echo "<tr>";
echo "<th> # </th>";
echo "<th> Date</th>";
echo "<th> Work Title </th>";
echo "<th> Status </th>";
echo "<th> Assigned by </th>";
echo "<th> Assigned to </th>";
echo "<th> Action</th>";
echo "</tr>";
while ($row = mysqli_fetch_assoc($myres)) {
$page_link = "<a class='grid_link' href=# onClick=edit_data('$row[fworkcode]')>Edit</a> | ";
$page_link .= "<a class='grid_link' href=# onClick=dele_data('$row[fworkcode]')>Delete</a>";
$work_empl = get_empl_name($row['femplwork']);
$assn_empl = get_empl_name($row['femplassn']);
echo "<tr id=$row[fworkcode]>";
echo "<td width=4% align=center>$i</td>";
echo "<td width=10% align=center>" . date('d/m/Y', strtotime($row['fworkdate'])) . "</td>";
echo "<td width=25% align=left>$row[fworktitl]</td>";
echo "<td width=15% align=center>$row[fworkstat]</td>";
echo "<td width=15% align=center>$assn_empl</td>";
echo "<td width=15% align=center>$work_empl</td>";
echo "<td width=10% align=center>$page_link</td>";
echo "</tr>";
$i++;
}
//NAVIGATION
echo "<tr>";
echo "<th align='center' colspan='9'>";
echo "<div style='width:80%;float:left;text-align:left;'>Pages: ";
if (($page_numb - 1) > 0) {
echo "<a href='javascript:void(0);' onclick='load_grid_data($page_limt,1);'> First</a>";
echo "<a href='javascript:void(0);' onclick='load_grid_data($page_limt,$page_numb-1);'> Previous</a>";
}
for ($i = 1; $i <= $last_page; $i++) {
if ($i == $page_numb) {
echo "<a href='javascript:void(0);' class='selected'> $i</a>";
} else {
echo "<a href='javascript:void(0);' onclick='load_grid_data($page_limt,$i);'> $i</a>";
}
}
if (($page_numb + 1) <= $last_page) {
echo "<a href='javascript:void(0);' onclick='load_grid_data($page_limt,$page_numb+1);'> Next</a>";
}
if (($page_numb) != $last_page) {
echo "<a href='javascript:void(0);' onclick='load_grid_data($page_limt,$last_page);'> Last</a>";
}
echo "</div>";
echo "<div style='width:20%;float:right; text-align:right;'>Rows / Page - ";
echo "<select onChange='load_page_limt(this.value);' style='width:50px;'>";
?>
<option value="13" <?php if ($_POST["page_limt"] == 13) {
echo ' selected="selected"';
} ?>>13</option>
<option value="20" <?php if ($_POST["page_limt"] == 20) {
echo ' selected="selected"';
} ?>>20</option>
<option value="40" <?php if ($_POST["page_limt"] == 40) {
echo ' selected="selected"';
} ?>>40</option>
<option value="50" <?php if ($_POST["page_limt"] == 50) {
echo ' selected="selected"';
} ?>>50</option>
<option value="100" <?php if ($_POST["page_limt"] == 100) {
echo ' selected="selected"';
} ?>>100</option>
<?php
echo "</select>";
echo "</th>";
echo "</tr>";
echo "</table>";
//NAVIGATION ENDS
}
}
if ($load_data == 'dele_data') {
$dele_code = $_POST['dele_code'];
$mysql = "update dailywork set fdeleted='T' where fworkcode='$dele_code'";
$myres = mysqli_query($mycon, $mysql);
}
if ($load_data == 'empl_assn') {
if ($type_id == 'ADMIN') {
$mysql = "select * from masempl where fusertype in ('CHIEF','ADMIN') and ifnull(femplstat,'F')='T' order by femplname";
} elseif ($type_id == 'CHIEF') {
$mysql = "select * from masempl where fusertype in ('CHIEF','ADMIN') and ifnull(femplstat,'F')='T' order by femplname";
} else {
$mysql = "select * from masempl where fdeptcode='$dept_id' and fusertype in ('CHIEF','SUPER') and ifnull(femplstat,'F')='T' order by femplname";
}
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) > 1) {
echo "<option value=0>--Select--</option>";
}
while ($row = mysqli_fetch_assoc($myres)) {
echo "<option value='$row[femplcode]'>$row[femplname] [$row[fdeptcode]]</option>";
}
}
if ($load_data == 'empl_work') {
if ($type_id == 'ADMIN') {
$mysql = "select * from masempl where ifnull(femplstat,'F')='T' order by femplname";
} elseif ($type_id == 'CHIEF') {
$mysql = "select * from masempl where fdeptcode in (select fdeptcode from masdept where fdepthead='$empl_id') and ifnull(femplstat,'F')='T' order by femplname";
} else {
$mysql = "select * from masempl where femplcode='$empl_id' and ifnull(femplstat,'F')='T' order by femplname";
}
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) > 1) {
echo "<option value=0>--Select--</option>";
}
while ($row = mysqli_fetch_assoc($myres)) {
echo "<option value='$row[femplcode]'>$row[femplname] [$row[fdeptcode]]</option>";
}
}
if ($load_data == 'disp_data') {
$work_code = $_POST['work_code'];
$mysql = "select * from dailywork where fworkcode='$work_code'";
$myres = mysqli_query($mycon, $mysql);
$rows = array();
while ($r = mysqli_fetch_assoc($myres)) {
$rows = $r;
}
echo json_encode($rows);
}
if ($load_data == 'save_data') {
$page_mode = $_POST['page_mode'];
$work_code = $_POST['work_code'];
$work_date = $_POST['work_date'];
$work_titl = $_POST['work_titl'];
$work_desc = $_POST['work_desc'];
$empl_assn = $_POST['empl_assn'];
$empl_work = $_POST['empl_work'];
$work_stat = $_POST['work_stat'];
$strt_date = $_POST['strt_date'];
$last_date = $_POST['last_date'];
$comp_date = $_POST['comp_date'];
$work_remk = $_POST['work_remk'];
if ($page_mode == "add") {
$updt_time = date("d/m/Y H:i:s");
$mysql = "insert into dailywork (fworkdate, fworktitl, fworkdesc, femplassn, femplwork, fworkremk, fworkstat, fstrtdate, flastdate, fcompdate, fupdtuser, fupdttime) values(str_to_date('$work_date','%d/%m/%Y') , '$work_titl', '$work_desc', '$empl_assn', '$empl_work', '$work_remk', '$work_stat', str_to_date('$strt_date','%d/%m/%Y'), str_to_date('$last_date','%d/%m/%Y'), str_to_date('$comp_date','%d/%m/%Y'), '$user_id',now())";
$myres = mysqli_query($mycon, $mysql);
$resp_stat = "T";
$resp_mesg = "Details inserted!";
//notification
$mysql1 = "select * from masempl where femplcode='$empl_assn'";
$myres1 = mysqli_query($mycon, $mysql1);
while ($row1 = mysqli_fetch_assoc($myres1)) {
$assn_name = $row1['femplname'];
$assn_numb = $row1['femplmobl'];
$assn_mail = $row1['femplmail'];
}
$mysql1 = "select * from masempl where femplcode='$empl_work'";
$myres1 = mysqli_query($mycon, $mysql1);
while ($row1 = mysqli_fetch_assoc($myres1)) {
$work_name = $row1['femplname'];
$work_numb = $row1['femplmobl'];
$work_mail = $row1['femplmail'];
}
//sms note
// $mess_text="Work assignment: ".$work_titl.". Assigned by: ".$assn_name.", Due Date: ".$last_date.", Date: ".$updt_time;
// require("api_sendsms.php");
// if(strlen($send_numb)==10){$resp_stat1=send_sms($send_numb,$mess_text);}
//mail note
require("api_sendmail.php");
$mail_subj = "Work assignment: " . $work_titl . ", Date: " . $updt_time . ", From: " . $assn_name;
$mail_text = "";
$mail_text .= "<div style='background-color:#666666; width:800px; padding:10px;line-height:32px; color:#FFF;font-weight:bold;'>";
$mail_text .= "Assignment Details</div>";
$mail_text .= "<div style='background-color:#EEF5F9; width:800px; padding:10px;line-height:32px;'>";
$mail_text .= "<span style='font-weight:bold;'>Title: </span>" . $work_titl . "<br>";
$mail_text .= "<span style='font-weight:bold;'>Description: </span>" . $work_desc . "<br>";
$mail_text .= "<span style='font-weight:bold;'>Start Date: </span>" . $strt_date . "<br>";
$mail_text .= "<span style='font-weight:bold;'>Due Date: </span>" . $last_date . "<br>";
$mail_text .= "<span style='font-weight:bold;'>Assigned by: </span>" . $assn_name . "<br>";
$mail_text .= "<span style='font-weight:bold;'>Assigned on: </span>" . $updt_time . "<br>";
$mail_text .= "</div>";
$resp_stat = send_mail($work_mail, $assn_mail, $mail_subj, $mail_text);
} else {
$mysql = "update dailywork set fworktitl='$work_titl', fworkdesc='$work_desc', fworkremk='$work_remk', fworkstat='$work_stat', fstrtdate=str_to_date('$strt_date','%d/%m/%Y'), flastdate=str_to_date('$last_date','%d/%m/%Y'), fcompdate=str_to_date('$comp_date','%d/%m/%Y'), fupdtuser='$user_id',fupdttime=now() where fworkcode='$work_code'";
$myres = mysqli_query($mycon, $mysql);
$resp_stat = "T";
$resp_mesg = "Details updated!";
}
echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));
}
?>
|