adminVehicle.php
3.45 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/AdminBase.php" ;
include $_SERVER[DOCUMENT_ROOT] . "/common/php/LoginUtil.php";
if (! class_exists("AdminVehicle")){
class AdminVehicle extends AdminBase{
function __construct($req)
{
parent::__construct($req);
}
function getListOfVehicle(){
$vehicleType=$this->req["vehicleType"];
$sql="
SELECT COUNT(*) AS rn
FROM tblVehicle
WHERE vehicleType='{$vehicleType}' AND status=1
";
$this->initPage();
$this->rownum=$this->getValue($sql, 'rn');
$this->setPage($this->rownum);
$limit=" LIMIT {$this->startNum}, {$this->endNum} ;";
$sql="
SELECT vehicleNo, name
FROM tblVehicle
WHERE vehicleType='{$vehicleType}' AND status=1
ORDER BY regDate DESC
{$limit}
";
$result=$this->getArray($sql);
return $result;
}
function getInfoOfVehicle(){
$vehicleNo=$this->req["vehicleNo"];
$sql="
SELECT *
FROM tblVehicle
WHERE vehicleNo='{$vehicleNo}' AND status=1
";
$result=$this->getRow($sql);
return $result;
}
function saveVehicle(){
$vehicleType=$this->req["vehicleType"];
$vehicleNo=$this->req["vehicleNo"];
$name=$this->req["name"];
$spec=$this->req["spec"];
$videoURL=$this->req["videoURL"];
$imgResult = $this->inFn_Common_fileSave($_FILES);
$imgPathVehicle1 = $imgResult["imgPathVehicle1"]["saveURL"] != "" ? $imgResult["imgPathVehicle1"]["saveURL"] : $this->req["imgPathVehicle1"];
$imgPathVehicle2 = $imgResult["imgPathVehicle2"]["saveURL"] != "" ? $imgResult["imgPathVehicle2"]["saveURL"] : $this->req["imgPathVehicle2"];
$imgPathVehicle3 = $imgResult["imgPathVehicle3"]["saveURL"] != "" ? $imgResult["imgPathVehicle3"]["saveURL"] : $this->req["imgPathVehicle3"];
$imgPathVehicle4 = $imgResult["imgPathVehicle4"]["saveURL"] != "" ? $imgResult["imgPathVehicle4"]["saveURL"] : $this->req["imgPathVehicle4"];
$imgPathVehicle5 = $imgResult["imgPathVehicle5"]["saveURL"] != "" ? $imgResult["imgPathVehicle5"]["saveURL"] : $this->req["imgPathVehicle5"];
if($vehicleNo == ""){
$sql="
INSERT INTO tblVehicle(vehicleType, name, spec, videoURL, status, regDate)
VALUES
(
'{$vehicleType}',
'{$name}',
'{$spec}',
'{$videoURL}',
1,
NOW()
)
";
$this->update($sql);
$lastNo=$this->mysql_insert_id();
$sql="
UPDATE tblVehicle
SET
imgPathVehicle1='{$imgPathVehicle1}',
imgPathVehicle2='{$imgPathVehicle2}',
imgPathVehicle3='{$imgPathVehicle3}',
imgPathVehicle4='{$imgPathVehicle4}',
imgPathVehicle5='{$imgPathVehicle5}'
WHERE vehicleNo='{$lastNo}'
";
$this->update($sql);
return $this->makeResultJson(1, "저장되었습니다");
}
else{
$sql="
UPDATE tblVehicle
SET
name='{$name}',
spec='{$spec}',
videoURL='{$videoURL}',
imgPathVehicle1='{$imgPathVehicle1}',
imgPathVehicle2='{$imgPathVehicle2}',
imgPathVehicle3='{$imgPathVehicle3}',
imgPathVehicle4='{$imgPathVehicle4}',
imgPathVehicle5='{$imgPathVehicle5}'
WHERE vehicleNo='{$vehicleNo}'
";
$this->update($sql);
return $this->makeResultJson(1, "수정되었습니다");
}
}
function deleteVehicle()
{
$noArr = $this->req["no"];
$noStr = implode(',', $noArr);
$sql = "
UPDATE tblVehicle
SET status = 0
WHERE `vehicleNo` IN({$noStr})
";
$this->update($sql);
}
}
}
?>