/var/www/enzatesting.onesolution.hk/01_20240711_full_backup/master_modify.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
<?php require_once "inc/configure.php";

$id                 = (int) filter_var($_REQUEST['id'], FILTER_SANITIZE_NUMBER_INT);
$typeid             filter_var($_REQUEST['typeid'], FILTER_SANITIZE_STRING);

//(int)$_REQUEST['productID'];
//vdump($_REQUEST);
if( $_REQUEST['action']=="master_modifyform" && !empty($id) ){
    

    
$codedesc             filter_var($_REQUEST['codedesc'], FILTER_SANITIZE_STRING);    
    
$ccodedesc             filter_var($_REQUEST['ccodedesc'], FILTER_SANITIZE_STRING);    
    
$deleted             filter_var($_REQUEST['deleted'], FILTER_SANITIZE_STRING);
    
$deleted            = empty($deleted)?'0':'1';
    
$lastupby            filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);

    
// check existance of itemno before insert    
    
$sql "SELECT count(*) as count from master_type_code 
            where typeid=:typeid and codeid=:codeid and id<>:id"
;
    
$sth $dbh->prepare($sql);
    
$sth->execute( array(':typeid'=> $typeid,
                            
':codeid'=> $codeid,
                            
':id'=> $id) );
    
$row $sth->fetch(); 
    if( 
$row['count']>){
        
$msg="Master Type already existed";
        
header("Location: master_addform.php?typeid=$typeid&error=$msg");
        exit;    
    }
    unset(
$sth);
    
    
//add stone
    
$sql "UPDATE master_type_code SET 
                codedesc_en = :codedesc,
                codedesc_sc = :ccodedesc,
                deleted = :deleted,
                lastupby = :lastupby, 
                lastupdate = GETDATE()
            WHERE id=:id"
;
                
    
$sth $dbh->prepare($sql);
    
$q$sth->execute( array(':id' => $id
                            
':codedesc' => $codedesc
                            
':ccodedesc' => $ccodedesc,
                            
':deleted' => $deleted,
                            
':lastupby' => $lastupby) );
    
pdo_showerror($sth$q);
/*echo $sth->getSQL( array(':id' => $id, 
                            ':codedesc' => $codedesc, 
                            ':ccodedesc' => $ccodedesc,
                            ':lastupby' => $lastupby) ) . HTML_EOL;*/
        
    //exit;                
    
header("Location: master_index.php?typeid=$typeid&msg=Saved."); 
    print 
"Saved.";
    exit;
    
    
}
print 
"Invalid Request";