/var/www/(Del)eizo.hkosl.com/global/hkwarranty/check_serial_number.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
    
require_once ("../webadmin/configure.php");

    
$series_code $_GET["series_code"];
    
$model_code $_GET["model_code"];
    
//$region = $_GET["region"];
    
$region "HK";
    
$serial_number $_GET["serial_number"];
    
$langcode $_SESSION["langcode"];
    
//var_dump($_GET);

    //check if this serial number exist
    
$sql "select * from serial_number sn, model model, series series where sn.series_code = series.series_code and sn.model_code = model.model_code and sn.series_code = ? and sn.model_code = ? and sn.serial_number = ? and sn.deleted = ? and sn.region = ? and model.region = ? and series.region = ? group by sn.serial_number_id ";

    if (!(
$sth $dbh->prepare($sql))) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    if (!
$sth->execute(array($series_code$model_code$serial_number"0"$region$region$region))) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    
//check if this serial number used
    
$sql3 "select * from customer_warranty where serial_number = ? and deleted = ? and (region = ? or region = ?)";
    if (!(
$sth3 $dbh->prepare($sql3))) {
        throw new 
Exception('[' $sth3->errorCode() . ']: ' print_r($sth3->errorInfo()));
    }

    if (!
$sth3->execute(array($serial_number"0""HK""MO"))) {
        throw new 
Exception('[' $sth3->errorCode() . ']: ' print_r($sth3->errorInfo()));
    }

    if(
$sth->rowCount() > && $sth3->rowCount() <= 0){ //if serial number exist and not used before
        
echo "1";
    }else if(
$sth->rowCount() > && $sth3->rowCount() > 0){ //if serial number exist and used before
        
echo "2";
    }else if(
$sth->rowCount() <= 0){ //if serial number not exist
        
echo "0";
    }else{}

?>