140 lines
4.5 KiB
PHP
140 lines
4.5 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/auth/auth.php');
|
|
include('includes/functions.php');
|
|
include('access.php');
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
?>
|
|
<?php
|
|
|
|
// Connect to mysqli database
|
|
$page = 1; // The current page
|
|
$sortname = 'id'; // Sort column
|
|
$sortorder = 'asc'; // Sort order
|
|
$qtype = ''; // Search column
|
|
$query = ''; // Search string
|
|
// Get posted data
|
|
if (isset($_POST['page'])) {
|
|
$page = mysqli_real_escape_string($conn, $_POST['page']);
|
|
}
|
|
if (isset($_POST['sortname'])) {
|
|
$sortname = mysqli_real_escape_string($conn, $_POST['sortname']);
|
|
}
|
|
if (isset($_POST['sortorder'])) {
|
|
$sortorder = mysqli_real_escape_string($conn, $_POST['sortorder']);
|
|
}
|
|
if (isset($_POST['qtype'])) {
|
|
$qtype = mysqli_real_escape_string($conn, $_POST['qtype']);
|
|
}
|
|
if (isset($_POST['query'])) {
|
|
$query = mysqli_real_escape_string($conn, $_POST['query']);
|
|
}
|
|
if (isset($_POST['rp'])) {
|
|
$rp = mysqli_real_escape_string($conn, $_POST['rp']);
|
|
}
|
|
// Setup sort and search SQL using posted data
|
|
$sortSql = "order by $sortname $sortorder";
|
|
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%$query%')" : '';
|
|
// Get total count of records
|
|
//echo $searchSql;
|
|
if ($searchSql != '') {
|
|
|
|
if ($qtype == 'item') {
|
|
|
|
$searchSql = " inner join tbl_items b on a.item_id=b.item_id where b.item_name like upper('%$query%') ";
|
|
|
|
// due_date between str_to_date('".$date_from."','%d/%m/%Y') and str_to_date('".$date_to."','%d/%m/%Y')
|
|
|
|
}
|
|
if ($qtype == 'batch') {
|
|
|
|
$searchSql = " and a.batch='$query' ";
|
|
|
|
// due_date between str_to_date('".$date_from."','%d/%m/%Y') and str_to_date('".$date_to."','%d/%m/%Y')
|
|
|
|
}
|
|
if ($qtype == 'expiry_date') {
|
|
|
|
$searchSql = " and a.expiry=str_to_date('" . $query . "','%d/%m/%Y') ";
|
|
|
|
// due_date between str_to_date('".$date_from."','%d/%m/%Y') and str_to_date('".$date_to."','%d/%m/%Y')
|
|
|
|
}
|
|
}
|
|
|
|
$sql = "select count(*) from cleanup_item_stock a where a.cleanup_qty>0 and ohc_type_id='" . $_SESSION['current_ohcttype'] . "' $searchSql ";
|
|
//$sql=$sql.$searchSql;
|
|
//echo $sql;
|
|
$result = mysqli_query($conn, $sql);
|
|
//echo $result;
|
|
$row = mysqli_fetch_array($result);
|
|
$total = $row[0];
|
|
if (!isset($rp)) {
|
|
$rp = 10;
|
|
}
|
|
// Setup paging SQL
|
|
//$rp=1;
|
|
$pageStart = ($page - 1) * $rp;
|
|
$limitSql = "limit $pageStart, $rp";
|
|
// Return JSON data
|
|
$data = array();
|
|
$data['page'] = $page;
|
|
$data['total'] = $total;
|
|
$data['rows'] = array();
|
|
$sql_expiry_items = "select * from cleanup_item_stock a where a.cleanup_qty>0 and ohc_type_id='" . $_SESSION['current_ohcttype'] . "' $searchSql order by a.expiry_date desc";
|
|
|
|
//echo $sql1;
|
|
//echo $results;
|
|
//echo mysqli_error($conn$results);
|
|
$count = ($page - 1) * $rp + 1;
|
|
//echo $sql_ailment;
|
|
//echo $access_level;
|
|
|
|
|
|
$results_expiry_items = mysqli_query($conn, $sql_expiry_items);
|
|
|
|
|
|
$view_link = "";
|
|
$edit_link = "";
|
|
$delete_link = "";
|
|
$links = "";
|
|
/*if($access_level=='R' ||$access_level=='W' || $access_level=='E' )
|
|
{
|
|
//echo "shubham";
|
|
$view_link="<a href=\"#\"class=\"green\" onclick=\"open_procurement('".$id."','V');\"><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
|
|
}
|
|
|
|
if($access_level=='W' || $access_level=='E' )
|
|
{
|
|
$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_procurement('".$id."','E');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
|
}
|
|
if($access_level=='E' )
|
|
{
|
|
$delete_link="<a href=\"#\" class=\"blue\" onclick=\"delete_procurement('".$id."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
|
}*/
|
|
|
|
|
|
while ($row_expiry_items = mysqli_fetch_assoc($results_expiry_items)) {
|
|
|
|
$id = $row_expiry_items['id'];
|
|
|
|
$item_desc = getTableFieldValue('tbl_items', 'item_name', 'item_id', $row_expiry_items['item_id']);
|
|
$item_qty = $row_expiry_items['cleanup_qty'];
|
|
$item_batch = $row_expiry_items['batch_no'];
|
|
$item_expiry_date = date_format(date_create($row_expiry_items['expiry_date']), "M-Y ");
|
|
if ($access_level == 'W' || $access_level == 'E') {
|
|
//$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_Expiry('".$id."','E');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
|
}
|
|
|
|
|
|
$space = " ";
|
|
$links = $space . $edit_link;
|
|
|
|
|
|
$data['rows'][] = array(
|
|
'id' => $row_expiry_items['id'],
|
|
'cell' => array($count++, $item_desc, $item_qty, $item_batch, $item_expiry_date, $links)
|
|
);
|
|
}
|
|
echo json_encode($data);
|
|
?>
|