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 : 52.15.173.197
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/documents.php |
<?php
include("sys_session.php");
include("sys_mainphp.php");
include("sys_connect.php");
$load_data = $_POST['load_data'];
$resp_mesg = "";
$resp_stat = "";
$resp_file = "";
if ($load_data == 'grid_data') {
require("sys_grid_data.php");
$i = 1;
if ($type_id == "ADMIN") {
$grid_sele = "select concat(dp.fdeptcode,'-',fdeptshrt) as ldeptname, fdocscode,date_format(fdocsdate,'%d/%m/%Y') as ldocsdate,fdocsdesc,hd.fdeptcode from documents hd
inner join masdept dp on hd.fdeptcode = dp.fdeptcode
where hd.fdeptcode like '%$_POST[dept_code]%' and ifnull(fdocsdesc,'') like '%$_POST[docs_find]%' and ifnull(hd.fdeleted,'F')<>'T'
order by hd.fdocsdate,hd.fdocsdesc";
} else {
$grid_sele = "select concat(dp.fdeptcode,'-',fdeptshrt) as ldeptname, fdocscode,date_format(fdocsdate,'%d/%m/%Y') as ldocsdate,fdocsdesc,hd.fdeptcode from documents hd
inner join masdept dp on hd.fdeptcode = dp.fdeptcode
inner join masdept_user du on hd.fdeptcode = du.fdeptcode and du.fusercode='$user_id'
where hd.fdeptcode like '%$_POST[dept_code]%' and ifnull(fdocsdesc,'') like '%$_POST[docs_find]%' and ifnull(hd.fdeleted,'F')<>'T'
order by hd.fdocsdate,hd.fdocsdesc";
}
$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='5%'> # </th>";
echo "<th width='10%'> Client </th>";
echo "<th width='10%'> Date </th>";
echo "<th width='60%'> Description </th>";
echo "<th width='15%'> 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[fdocscode]')>Edit</a>";
$page_link .= " <a class='btn btn-danger btn-sm' href=# onClick=dele_data('$myrow[fdocscode]')>Delete</a>";
echo "<tr>";
echo "<td align='center'>$i</td>";
echo "<td align='center'>$myrow[ldeptname]</td>";
echo "<td align='center'>$myrow[ldocsdate]</td>";
echo "<td align='left'>$myrow[fdocsdesc]</td>";
echo "<td align='left'> $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') {
echo $mysql = "delete from documents where fdocscode='$_POST[dele_code]'";
$myres = mysqli_query($mycon, $mysql);
}
if ($load_data == 'disp_data') {
$mysql = "select * from documents where fdocscode='$_POST[disp_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'];
$docs_desc = str_replace("'", "`", $_POST['docs_desc']);
if ($page_mode == "add") {
$mysql = "insert into documents (fdeptcode,fdocsdate,fdocsdesc,fupdtuser,fupdttime,fdeleted) values(
'$_POST[dept_code]',str_to_date('$_POST[docs_date]','%d/%m/%Y') ,'$_POST[docs_desc]','$user_id',now(),'F')";
$myres = mysqli_query($mycon, $mysql);
$resp_mesg = "docsday added!";
} else {
$mysql = "update documents set fdeptcode='$_POST[dept_code]',
fdocsdate=str_to_date('$_POST[docs_date]','%d/%m/%Y'), fdocsdesc='$_POST[docs_desc]',
fupdtuser='$user_id',fupdttime=now() where fdocscode='$_POST[docs_code]'";
$myres = mysqli_query($mycon, $mysql);
$resp_mesg = "Details updated!";
}
echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));
}
|