AdminCompany.php
4.69 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/AdminBase.php" ;
include $_SERVER[DOCUMENT_ROOT] . "/common/php/LoginUtil.php";
if (! class_exists("AdminCompany")){
class AdminCompany extends AdminBase{
function __construct($req)
{
parent::__construct($req);
}
function getListOfCompany(){
$productCode=$this->req["productCode"];
$sql="
SELECT COUNT(*) AS rn
FROM tblCompany
WHERE productCode='{$productCode}' AND status=1
";
$this->initPage();
$this->rownum=$this->getValue($sql, 'rn');
$this->setPage($this->rownum);
$limit=" LIMIT {$this->startNum}, {$this->endNum} ;";
$sql="
SELECT companyNo, name, provinceCode, address, telephone
FROM tblCompany
WHERE productCode='{$productCode}' AND status=1
ORDER BY regDate DESC
{$limit}
";
$result=$this->getArray($sql);
return $result;
}
function getInfoOfCompany(){
$companyNo=$_REQUEST["companyNo"];
$sql="
SELECT *
FROM tblCompany
WHERE companyNo='{$companyNo}' AND status=1
";
$result=$this->getRow($sql);
//echo json_encode($result);
return $result;
}
function getListOfProvince(){
$sql="
SELECT *
FROM tblZipProvince
ORDER BY provinceNumber ASC
";
$result=$this->getArray($sql);
return $result;
}
function saveCompany(){
$companyType=$this->req["companyType"];
$companyNo=$this->req["companyNo"];
$name=$this->req["name"];
$productCode=$this->req["productCode"];
$provinceCode=$this->req["provinceCode"];
$address=$this->req["address"];
$telephone1=$this->req["telephone1"];
$telephone2=$this->req["telephone2"];
$telephone3=$this->req["telephone3"];
$telephone=$telephone1.$telephone2.$telephone3;
$fax1=$this->req["fax1"];
$fax2=$this->req["fax2"];
$fax3=$this->req["fax3"];
$fax=$fax1.$fax2.$fax3;
$eMail=$this->req["eMail"];
$companyProductList=$this->req["companyProductList"];
$imgResult = $this->inFn_Common_fileSave($_FILES);
$imgPathCompany1 = $imgResult["imgPathCompany1"]["saveURL"] != "" ? $imgResult["imgPathCompany1"]["saveURL"] : $this->req["imgPathCompany1"];
$imgPathCompany2 = $imgResult["imgPathCompany2"]["saveURL"] != "" ? $imgResult["imgPathCompany2"]["saveURL"] : $this->req["imgPathCompany2"];
$imgPathCompany3 = $imgResult["imgPathCompany3"]["saveURL"] != "" ? $imgResult["imgPathCompany3"]["saveURL"] : $this->req["imgPathCompany3"];
$imgPathCompany4 = $imgResult["imgPathCompany4"]["saveURL"] != "" ? $imgResult["imgPathCompany4"]["saveURL"] : $this->req["imgPathCompany4"];
$imgPathCompany5 = $imgResult["imgPathCompany5"]["saveURL"] != "" ? $imgResult["imgPathCompany5"]["saveURL"] : $this->req["imgPathCompany5"];
if($companyNo == ""){
$sql="
insert INTO `tblCompany`
(
`name`,
`imgPathCompany1`,
`imgPathCompany2`,
`imgPathCompany3`,
`imgPathCompany4`,
`imgPathCompany5`,
`provinceCode`,
`productCode`,
`address`,
`telephone`,
`fax`,
`eMail`,
`companyProductList`,
`status`,
`regDate`
)
VALUES
(
'{$name}',
'{$imgPathCompany1}',
'{$imgPathCompany2}',
'{$imgPathCompany3}',
'{$imgPathCompany4}',
'{$imgPathCompany5}',
'{$provinceCode}',
'{$productCode}',
'{$address}',
'{$telephone}',
'{$fax}',
'{$eMail}',
'{$companyProductList}',
1,
NOW()
);
";
$this->update($sql);
return $this->makeResultJson(1, "저장되었습니다");
}
else{
$sql="
UPDATE tblCompany
SET
name='{$name}',
`imgPathCompany1`= '{$imgPathCompany1}',
`imgPathCompany2`= '{$imgPathCompany2}',
`imgPathCompany3`= '{$imgPathCompany3}',
`imgPathCompany4`= '{$imgPathCompany4}',
`imgPathCompany5`= '{$imgPathCompany5}',
provinceCode='{$provinceCode}',
productCode='{$productCode}',
address='{$address}',
telephone='{$telephone}',
fax='{$fax}',
eMail='{$eMail}',
companyProductList='{$companyProductList}'
WHERE companyNo='{$companyNo}'
";
$this->update($sql);
return $this->makeResultJson(1, "수정되었습니다");
}
}
function deleteCompany(){
$noArr = $this->req["no"];
$noStr = implode(',', $noArr);
$sql = "
UPDATE tblCompany
SET status = 0
WHERE `companyNo` IN({$noStr})
";
$this->update($sql);
}
}
}
?>