function searchresultloggb($username,$TANDA,$dataType)
{
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$order = isset($_POST['order']) ? $_POST['order'] : 'DESC';
$sort = isset($_POST['sort']) ? $_POST['sort'] : 'Logging_ID';
$xls = isset($_POST['xls']) ? $_POST['xls'] : false;
//$START=$_POST['START'].' 00:00:01';
//$FINISIH=$_POST['FINISH'].' 23:59:59';
$START=$_POST['START'];
$FINISIH=$_POST['FINISH'];
$startRow =($page - 1) * $rows + 0;
$endRow = 10;
$sqlResult ="Select TOP ".$endRow."*
from tb_m_logging a
inner join tb_m_usrlgn b
on a.m_UsrLgn_ID=b.UsrLgn_ID
inner join tb_m_action c
on a.m_Action_ID=c.Action_ID
WHERE";
$sqlCount = "SELECT count(*)
from tb_m_logging a
inner join tb_m_usrlgn b
on a.m_UsrLgn_ID=b.UsrLgn_ID
inner join tb_m_action c
on a.m_Action_ID=c.Action_ID
where ";
// $start = $_POST['START'];
// $finish = $_POST['FINISH'];
$sqlString = '';
$sqlString = $sqlString . " Logging_ID IS NOT NULL ";
$sqlString = $sqlString . " and Reff_ID='$dataType' ";
$sqlStringa = $sqlString . " and Logging_ID NOT IN
(
Select TOP ".$startRow." Logging_ID
from tb_m_logging a
inner join tb_m_usrlgn b
on a.m_UsrLgn_ID=b.UsrLgn_ID
inner join tb_m_action c
on a.m_Action_ID=c.Action_ID
) ";
$startRow = ($page - 1) * $rows + 0;
$endRow = ($startRow + $rows) - 1;
$sort = ($sort == "Logging_ID") ? "Logging_ID" : $sort;
$sqlCount = $sqlCount . " " . $sqlString ;
//$sqlString = $sqlString." AND rownum<=".$endRow;
$sqlResult = $sqlResult . $sqlStringa . " ORDER BY " . $sort . " " . $order;
//echo($sqlResult);exit;
if ($xls) {
$sqlResult = $sqlResult ;
//echo($sqlResult);exit();
} else {
$sqlResult = "" . $sqlResult ;
}
//$sqlResult = "SELECT * FROM (".$sqlResult.") WHERE ".$startRow."<=row_number";
//echo($sqlCount);
/* $conn = oci_connect($this->db->username, $this->db->password, $this->db->
hostname);*/
//$conn = oci_connect("ttm", "ngacumak", "172.16.4.4/CDM02");
//get Total Records
$sqlc = mssql_query($sqlCount);
$rowo = mssql_fetch_row($sqlc);
$result['total'] = $rowo[0];
// oci_free_statement($sqlCount);
//echo $sqlResult;
//exit();
//Get Data
$query = mssql_query($sqlResult);
// oci_execute($query);
$items = array();
while ($row =mssql_fetch_object($query)) {
array_push($items, $row);
}
$result['rows'] = $items;
//oci_free_statement($sqlResult);
// oci_close($conn);
return json_encode($result);
}
Tidak ada komentar:
Posting Komentar