-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItemFinish.php
More file actions
76 lines (58 loc) · 1.81 KB
/
Copy pathItemFinish.php
File metadata and controls
76 lines (58 loc) · 1.81 KB
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
<?php
require_once("session.php");
$se=new session();
if(!$SerialNumbers=$se->get_value("SerialNumbers"))
{
echo "-1";
exit();
}
require_once("connect_mysql_class.php");
require_once("mysql_inc.php");
$db=new DB();
$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);
$ItemID=$_POST['ItemID'];
$CustomNumber=$_POST['CustomNumber'];
//取得StoreItemID
$query="SELECT ID FROM ".$SerialNumbers." WHERE State !='DIE'";
$db->query($query);
$temp=$db->fetch_array();
$StoreItemID=$temp['ID'];
//取得CustomID
$query="SELECT custom_id FROM custom_information where store='".$SerialNumbers."' and item='".$StoreItemID."' and number='".$CustomNumber."' and life='0'";
$db->query($query);
$temp=$db->fetch_array();
$CustomID=$temp['custom_id'];
//更新custom_information的item資訊
$query="Select * FROM custom_information where custom_id='".$CustomID."' and store ='".$SerialNumbers."' and life='0'";
$db->query($query);
$temp=$db->fetch_array();
$SelectItem=json_decode($temp['SelectItem']);
for ($i=0;$i<sizeof($SelectItem);$i++)
{
if($SelectItem[$i]->TakenItemID==$ItemID)
{
if($SelectItem[$i]->Life==0){
$SelectItem[$i]->Life=2;
$CheckNum=2;
}
else if($SelectItem[$i]->Life==2){
$SelectItem[$i]->Life=1;
$CheckNum=1;
}
else{}
}
}
$SelectItem=json_encode($SelectItem);
$query="Update custom_information set `SelectItem` ='".$SelectItem."' where store ='".$SerialNumbers."' and custom_id='".$CustomID."' and life='0'";
$db->query($query);
if($CheckNum==1){
//刪除清單裡面的item資訊
$query="Delete FROM Type2".$StoreItemID." where ItemID ='".$ItemID."' and CustomID='".$CustomID."'";
$db->query($query);
}
else{
$query="Update Type2".$StoreItemID." set Life ='2' where ItemID ='".$ItemID."' and CustomID='".$CustomID."'";
$db->query($query);
}
echo $CheckNum;
?>