@@ -39,7 +39,8 @@ protected function getCustomerOrder($id) {
39
39
usercare.name AS 'Nhân viên chăm sóc',
40
40
tbl_order.total AS 'Đơn giá',
41
41
tbl_order.create_at AS 'Thời gian',
42
- tbl_order.id AS 'id'
42
+ tbl_order.id AS 'id',
43
+ usercare.id AS 'idu'
43
44
FROM
44
45
tbl_user AS usersell
45
46
INNER JOIN tbl_order
@@ -101,4 +102,154 @@ protected function getCustomerOrderDetail($id) {
101
102
102
103
return $ result ;
103
104
}
105
+
106
+ protected function addFeedback ($ user_id , $ customer_id , $ rate , $ feedback ) {
107
+
108
+ $ sql = "INSERT INTO tbl_feedback(user_id, customer_id, rate, feedback) VALUES
109
+ (:user_id, :customer_id, :rate, :feedback) " ;
110
+
111
+ $ pre = $ this ->pdo ->prepare ($ sql );
112
+
113
+ $ pre ->bindParam (':user_id ' , $ user_id );
114
+
115
+ $ pre ->bindParam (':customer_id ' , $ customer_id );
116
+
117
+ $ pre ->bindParam (':rate ' , $ rate );
118
+
119
+ $ pre ->bindParam (':feedback ' , $ feedback );
120
+
121
+ return $ pre ->execute ();
122
+ }
123
+
124
+ protected function getUserInfo ($ id ) {
125
+
126
+ $ sql = "SELECT
127
+ *
128
+ FROM
129
+ tbl_user, tbl_showroom
130
+ WHERE
131
+ tbl_user.showroom_id = tbl_showroom.showroom_id
132
+ AND
133
+ id = :id " ;
134
+
135
+ $ pre = $ this ->pdo ->prepare ($ sql );
136
+
137
+ $ pre ->bindParam (':id ' , $ id );
138
+
139
+ $ pre ->execute ();
140
+
141
+ $ result = $ pre ->fetch (PDO ::FETCH_ASSOC );
142
+
143
+ return $ result ;
144
+ }
145
+
146
+ protected function getUserRate ($ id ) {
147
+
148
+ $ sql = "SELECT
149
+ COUNT(tbl_feedback.user_id) AS 'num',
150
+ ROUND(
151
+ SUM(tbl_feedback.rate) / COUNT(tbl_feedback.user_id),
152
+ 1
153
+ ) AS 'avg'
154
+ FROM
155
+ tbl_feedback
156
+ WHERE
157
+ tbl_feedback.user_id = :id " ;
158
+
159
+ $ pre = $ this ->pdo ->prepare ($ sql );
160
+
161
+ $ pre ->bindParam (':id ' , $ id );
162
+
163
+ $ pre ->execute ();
164
+
165
+ $ result = $ pre ->fetch (PDO ::FETCH_ASSOC );
166
+
167
+ return $ result ;
168
+ }
169
+
170
+ protected function getUserFeedback ($ id , $ row ) {
171
+
172
+ if (isset ($ _GET ['pages ' ])) {
173
+ $ pages = $ _GET ['pages ' ];
174
+ }else {
175
+ $ pages = 1 ;
176
+ }
177
+
178
+ $ from = ($ pages - 1 ) * $ row ;
179
+
180
+ $ sql = "SELECT
181
+ tbl_customer.name,
182
+ tbl_customer.avatar,
183
+ tbl_feedback.rate,
184
+ tbl_feedback.feedback,
185
+ tbl_feedback.create_at as 'time'
186
+ FROM
187
+ tbl_feedback, tbl_customer
188
+ WHERE
189
+ tbl_feedback.customer_id = tbl_customer.id and tbl_feedback.user_id = 2
190
+ ORDER BY
191
+ tbl_feedback.create_at DESC
192
+ LIMIT
193
+ $ from, $ row " ;
194
+
195
+ $ pre = $ this ->pdo ->prepare ($ sql );
196
+
197
+ $ pre ->bindParam (':id ' , $ id );
198
+
199
+ $ pre ->execute ();
200
+
201
+ $ result = array ();
202
+
203
+ while ($ row = $ pre ->fetch (PDO ::FETCH_ASSOC )) {
204
+
205
+ $ result [] = $ row ;
206
+
207
+ }
208
+
209
+ return $ result ;
210
+ }
211
+
212
+ protected function countFeedback ($ user_id ){
213
+
214
+ $ sql = "SELECT COUNT(user_id) as id FROM tbl_feedback WHERE user_id = :user_id " ;
215
+
216
+ $ pre = $ this ->pdo ->prepare ($ sql );
217
+
218
+ $ pre ->bindParam (':user_id ' , $ user_id );
219
+
220
+ $ pre ->execute ();
221
+
222
+ $ result = $ pre ->fetch (PDO ::FETCH_ASSOC );
223
+
224
+ return $ result ['id ' ];
225
+ }
226
+
227
+ protected function checkFeedback ($ order_id ) {
228
+
229
+ $ sql = "SELECT
230
+ *
231
+ FROM
232
+ tbl_feedback, tbl_order
233
+ WHERE
234
+ tbl_feedback.order_id = tbl_order.id
235
+ AND
236
+ order_id = :order_id " ;
237
+
238
+ $ pre = $ this ->pdo ->prepare ($ sql );
239
+
240
+ $ pre ->bindParam (':order_id ' , $ order_id );
241
+
242
+ $ pre ->execute ();
243
+
244
+ $ result = array ();
245
+
246
+ while ($ row = $ pre ->fetch (PDO ::FETCH_ASSOC )) {
247
+
248
+ $ result [] = $ row ;
249
+
250
+ }
251
+
252
+ return $ result ;
253
+ }
254
+
104
255
}
0 commit comments