Advertisement
Muharik

server_processing_xml.php

Feb 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.58 KB | None | 0 0
  1. <?php
  2.     require_once "../../../library/adodb5/adodb.inc.php";
  3.     require_once '../../../config/config.php';
  4.     require_once '../../../function/function.php';
  5.     require_once '../../session_login.php';
  6.  
  7.     //require_once '../session_group.php';
  8.     date_default_timezone_set("Asia/Jakarta");
  9.     $current_date = date('Y-m-d');
  10.  
  11.     ini_set('memory_limit','-1');
  12.     error_reporting(0);
  13.  
  14.  
  15.     $aColumns = array('ACCTNO','ACTYPE','SNAME', 'CFNA2','CFNA5','CFSSCD','CFSSNO','CFCLAS');
  16.     $aColumns_sorting = array('ACCTNO','ACTYPE','SNAME', 'CFNA2','CFNA5','CFSSCD','CFSSNO','ACCTNO');
  17.  
  18.     /* Indexed column (used for fast and accurate table cardinality) */
  19.     $sIndexColumn = "ACCTNO";
  20.  
  21.     /*
  22.      * Ordering
  23.      */
  24.     if ( isset( $_GET['iSortCol_0'] ) )
  25.     {
  26.         $sOrder = "ORDER BY  ";
  27.         for ( $i=0 ; $i<intval( $_GET['iSortingCols'] ) ; $i++ )
  28.         {
  29.             if ( $_GET[ 'bSortable_'.intval($_GET['iSortCol_'.$i]) ] == "true" )
  30.             {
  31.                 $sOrder .= $aColumns_sorting[ intval( $_GET['iSortCol_'.$i] ) ]."
  32.                    ".($_GET['sSortDir_'.$i]==='asc' ? 'asc' : 'desc').", ";
  33.             }
  34.         }
  35.  
  36.         $sOrder = substr_replace( $sOrder, "", -2 );
  37.         if ( $sOrder == "ORDER BY" )
  38.         {
  39.             $sOrder = "";
  40.         }
  41.     }
  42.  
  43.    
  44.  
  45. /* Filtering */
  46.     $sWhere = "";
  47.     if ( isset($_GET['sSearch']) && $_GET['sSearch'] != "" ) {
  48.         $sWhere = "WHERE (";
  49.         for ( $i=0 ; $i<count($aColumns) ; $i++ ) {
  50.             $sWhere .= $aColumns[$i]." LIKE '%".addslashes( $_GET['sSearch'] )."%' OR ";
  51.         }
  52.         $sWhere = substr_replace( $sWhere, "", -3 );
  53.         $sWhere .= ')';
  54.     }
  55.     /* Individual column filtering */
  56.     for ( $i=0 ; $i<count($aColumns) ; $i++ ) {
  57.         if ( isset($_GET['bSearchable_'.$i]) && $_GET['bSearchable_'.$i] == "true" && $_GET['sSearch_'.$i] != '' )  {
  58.             if ( $sWhere == "" ) {
  59.                 $sWhere = "WHERE ";
  60.             } else {
  61.                 $sWhere .= " AND ";
  62.             }
  63.             $sWhere .= $aColumns[$i]." LIKE '%".addslashes($_GET['sSearch_'.$i])."%' ";
  64.         }
  65.     }
  66.        
  67.     /* Paging */
  68.     $top = (isset($_GET['iDisplayStart']))?((int)$_GET['iDisplayStart']):0 ;
  69.     $limit = (isset($_GET['iDisplayLength']))?((int)$_GET['iDisplayLength'] ):10;
  70.     $sQuery = "SELECT TOP $limit "." * "."
  71.        FROM PPATK3
  72.        $sWhere ".(($sWhere=="")?" WHERE ":" AND ")." $sIndexColumn NOT IN
  73.        (
  74.            SELECT $sIndexColumn FROM
  75.            (
  76.                SELECT TOP $top "." * "."
  77.                FROM PPATK3
  78.                $sWhere
  79.                $sOrder
  80.            )
  81.            as [virtTable]
  82.        )
  83.        $sOrder";
  84.  
  85.     //$db->SetFetchMode(ADODB_FETCH_ASSOC);
  86.     $rResult  = $db->Execute($sQuery);
  87.     $sQueryCnt = "SELECT count ($sIndexColumn) as jml FROM PPATK3 $sWhere ";
  88.  
  89.     $rResultTotal  = $db->Execute($sQueryCnt);
  90.    
  91.  
  92.     $iFilteredTotal = $rResultTotal->fields["jml"];;
  93.    
  94.    
  95.     $sQuery = " SELECT count ($sIndexColumn) as jml2  FROM PPATK3  ";
  96.     $rResultTotal2  = $db->Execute($sQuery);
  97.     $iTotal = $rResultTotal2->RecordCount();
  98.    
  99.     $output = array(
  100.         "sEcho" => intval($_GET['sEcho']),
  101.         "iTotalRecords" => $iTotal,
  102.         "iTotalDisplayRecords" => $iFilteredTotal,
  103.         "aaData" => array()
  104.     );
  105.  
  106.  
  107.     /*
  108.      * Output
  109.      */
  110.     $output = array(
  111.         "sEcho" => intval($_GET['sEcho']),
  112.         "iTotalRecords" => $iTotal,
  113.         "iTotalDisplayRecords" => $iFilteredTotal,
  114.         "aaData" => array()
  115.     );
  116.  
  117.    
  118.  
  119.  
  120.  
  121. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement