Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Paging */
- $sLimit = "";
- if ( isset( $_POST['iDisplayStart'] ) )
- {
- $sLimit = " LIMIT ".mysql_real_escape_string( $_POST['iDisplayStart'] ).", ".
- mysql_real_escape_string( $_POST['iDisplayLength'] );
- }
- $sOrder ="";
- if ( isset( $_POST['iSortCol_0'] ) )
- {
- $sOrder = "ORDER BY Date, A.Line";
- }
- $sWhere = "";
- // if ( $_POST['sSearch'] != "" )
- if (postVar('sSearch') !="" )
- {
- $sWhere = " WHERE (A.Inspection_datetime LIKE '%".mysql_real_escape_string( $_POST['sSearch'] )."%' OR
- A.Line LIKE '%".mysql_real_escape_string( $_POST['sSearch'] )."%' OR ".
- " A.Model LIKE '%".mysql_real_escape_string( $_POST['sSearch'] )."%' OR ".
- " A.Lot_no LIKE '%".mysql_real_escape_string( $_POST['sSearch'] )."%' OR ".
- " A.Range_sampling LIKE '%".mysql_real_escape_string( $_POST['sSearch'] )."%' OR ".
- // " A.Serial_number LIKE '%".mysql_real_escape_string( $_POST['sSearch'] )."%' OR ".
- " B.name LIKE '%".mysql_real_escape_string( $_POST['sSearch'] )."%') ";
- }
- $sGroupBy = " GROUP BY A.Range_sampling, A.Lot_no ";
- $sQuery = "SELECT DATE(A.Inspection_datetime) AS Date, A.Line, A.Model,
- A.Lot_no,A.Range_sampling,COUNT(A.Serial_number) AS Error,B.name AS PIC
- FROM inspection_report A
- LEFT JOIN Employee B
- ON A.NIK=B.NIK
- WHERE CHAR_LENGTH( A.Range_sampling ) < 17
- AND MONTH(A.Inspection_datetime)=MONTH(CURRENT_DATE)" .$sWhere.$sGroupBy.$sOrder.$sLimit;
- $rResult = mysql_query( $sQuery) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($sql) . '</small>): ' . mysql_error() ); // submit SQL to MySQL and err$
- $sQuery = "SELECT FOUND_ROWS()";
- $rResultFilterTotal = mysql_query( $sQuery) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($sql) . '</small>): ' . mysql_error() ); // submit SQL to My$
- $aResultFilterTotal = mysql_fetch_array($rResultFilterTotal);
- $iFilteredTotal = $aResultFilterTotal[0];
- $sQuery = "SELECT COUNT(Line) FROM inspection_report";
- $rResultTotal = mysql_query( $sQuery) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($sql) . '</small>): ' . mysql_error() ); // submit SQL to MySQL an$
- $aResultTotal = mysql_fetch_array($rResultTotal);
- $iTotal = $aResultTotal[0];
- $sOutput = '{';
- $sOutput .= '"sEcho": '.intval($_POST['sEcho']).','; // '.intval($_POST['sEcho']).', ';
- $sOutput .= '"iTotalRecords": '.$iTotal.', ';
- // $sOutput .= '"iTotalDisplayRecords": '.$iFilteredTotal.', \';
- $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
- $sOutput .= '"aaData": [ ';
- while ( $aRow = mysql_fetch_array( $rResult ) )
- {
- $sOutput .= "[";
- $sOutput .= '"'.addslashes($aRow['Date']).'",';
- $sOutput .= '"'.addslashes($aRow['Line']).'",';
- $sOutput .= '"'.addslashes($aRow['Model']).'",';
- $sOutput .= '"'.addslashes($aRow['Lot_no']).'",';
- $sOutput .= '"'.addslashes($aRow['Range_sampling']).'",';
- $sOutput .= '"'.addslashes($aRow['Error']).'",';
- $sOutput .= '"'.addslashes($aRow['PIC']).'"';
- $sOutput .= "],";
- }
- $sOutput = substr_replace( $sOutput, "", -1 );
- $sOutput .= '] }';
- echo $sOutput;
- function fnColumnToField( $i )
- {
- if ( $i == 0 )
- return "Date";
- else if ( $i == 1 )
- return "Line";
- else if ( $i == 2 )
- return "Model";
- else if ( $i == 3 )
- return "Lot_no";
- else if ( $i == 4 )
- return "Range_sampling";
- else if ( $i == 5 )
- return "Error";
- else if ( $i == 6 )
- return "PIC";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement