/var/www/enzatesting.onesolution.hk/EURO FORBIDDEN TO TOUCH/ajax_json_product_detailEUR.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php 
$formid
=$_REQUEST['formid'];
require_once 
"inc/configure.php";

if (!
function_exists('json_encode')) {
    function 
json_encode($data) {
        
//echo "JD";
        
switch ($type gettype($data)) {
            case 
'NULL':
                return 
'null';
            case 
'boolean':
                return (
$data 'true' 'false');
            case 
'integer':
            case 
'double':
            case 
'float':
                
//return $data;
                
return '"' addslashes($data) . '"';
            case 
'string':
                return 
'"' addslashes($data) . '"';
            case 
'object':
                
$data get_object_vars($data);
            case 
'array':
                
$output_index_count 0;
                
$output_indexed = array();
                
$output_associative = array();
                foreach (
$data as $key => $value) {
                    
$output_indexed[] = json_encode($value);
                    
$output_associative[] = json_encode($key) . ':' json_encode($value);
                    if (
$output_index_count !== NULL && $output_index_count++ !== $key) {
                        
$output_index_count NULL;
                    }
                }
                if (
$output_index_count !== NULL) {
                    return 
'[' implode(','$output_indexed) . ']';
                } else {
                    return 
'{' implode(','$output_associative) . '}';
                }
            default:
                return 
''// Not supported
        
}
    }
}


$refid=(int)$_REQUEST['refid'];
$custcode $_REQUEST['custcode'];

$output=0;
if(
$refid){

    
$sql "SELECT * from inv_product where refid = :refid";        
    
$sth $dbh->prepare($sql);
    
$sth->execute( array(':refid'=>$refid) );
//echo $sth->getSQL( array(':refid'=>$refid) ).HTML_EOL;
    
if($row $sth->fetch(PDO::FETCH_ASSOC) ){
        
//check bom and route are ready
        
$row['readyOrder'] = 1;
        
$bomcost getProductBOMCost($refid);
        
$routecost getProductRouteCost($refid);
        
        if(
$bomcost<=0){ //missing BOM
            
$row['readyOrder'] = 0;
            
$row['msg_out'] = MISSING.WS.BOM;
        }elseif(
$routecost<=0){ //Missing Route
            
$row['readyOrder'] = 0;
            
$row['msg_out'] = MISSING.WS.ROUTE;
        }
        
        
$output++;
         
//var_dump($row); 
        
if(havePermission("DCr")){ //DC-------------------------------
            
$row['unitcost'] = numf($bomcost $routecost);
            
$row['factorycost'] = numf($row['unitcost'] * $system_var['FMU']);
        } else{
            
$row['unitcost'] = 0;
            
$row['factorycost'] = 0;    
        }        
        
//DC --------------------------------------------------------
        
        
if(havePermission("DPr")){ //DP-------------------------------
            
$row['unitprice'] = numf($row['unitprice']);
            
$row['sellingprice'] = numfgetproductSellingPrice($row['refid']) );
            
$row['sellingprice_usd'] = numf(USD_CNY::getUSDAmount($row['uom_cy'],$row['sellingprice']));
            
$row['sellingprice_usd'] = numf(USD_EUR::getUSDAmount($row['uom_cy'],$row['sellingprice']));
            
$row['sellingprice_cny'] =  numf(USD_CNY::getCNYAmount($row['uom_cy'],$row['sellingprice']));
            
$row['sellingprice_eur'] =  numf(USD_EUR::getEURAmount($row['uom_cy'],$row['sellingprice']));
            
$row['price'] = numf($row['price']);        
        } else{
            
$row['unitprice'] = 0;
            
$row['sellingprice'] = 0;
            
$row['sellingprice_usd'] = 0;
            
$row['sellingprice_cny'] = 0;
            
$row['sellingprice_eur'] = 0;
            
$row['price'] = 0;    
        }        
        
//DP--------------------------------------------------------
        
        
$row['weight'] = numf($row['weight']);
        
        
$customer getDB_master_customer($custcode);
        
$row['custcode'] = $custcode;
        
$row['lang'] = $customer['lang'];
        if(!empty(
$customer['lang'])){
            
$row['name_'] = $row'name_'.strtolower($customer['lang']) ];
        }else{
            
$row['name_'] = $row['name_en'];    
        }

        
//echo "p==".$row['unitprice'] ;
        
print json_encode($row);
    }    
    unset(
$sth);
    
}

if(
$output==0){
    print 
json_encode("ERROR");    //return something to the client
}
//http://localhost/enza/ajax_json_product_detail.php?formid=Order&refid=387
?>