This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * $Id: order.php,v 1.42 2007/02/04 15:01:40 malanciault Exp $ |
||
4 | * Module:martin |
||
5 | * Licence: GNU |
||
6 | */ |
||
7 | |||
8 | if (!defined("XOOPS_ROOT_PATH")) { |
||
9 | die("XOOPS root path not defined"); |
||
10 | } |
||
11 | |||
12 | include_once XOOPS_ROOT_PATH . '/modules/martin/include/common.php'; |
||
13 | |||
14 | /** |
||
15 | * Class MartinOrder |
||
16 | */ |
||
17 | class MartinOrder extends XoopsObject |
||
18 | { |
||
19 | public function MartinOrder() |
||
20 | { |
||
21 | $this->initVar("order_id", XOBJ_DTYPE_INT, null, false); |
||
22 | $this->initVar("order_type", XOBJ_DTYPE_INT, null, false); |
||
23 | $this->initVar("order_mode", XOBJ_DTYPE_INT, null, false); |
||
24 | $this->initVar("order_uid", XOBJ_DTYPE_INT, null, false); |
||
25 | $this->initVar("order_pay_method", XOBJ_DTYPE_INT, null, false); |
||
26 | $this->initVar("order_pay", XOBJ_DTYPE_TXTBOX, null, true, 25); |
||
27 | $this->initVar("order_status", XOBJ_DTYPE_INT, null, false); |
||
28 | $this->initVar("order_total_price", XOBJ_DTYPE_INT, null, false); |
||
29 | $this->initVar("order_pay_money", XOBJ_DTYPE_INT, null, false); |
||
30 | $this->initVar("order_coupon", XOBJ_DTYPE_INT, null, false); |
||
31 | $this->initVar("order_sented_coupon", XOBJ_DTYPE_INT, null, false); |
||
32 | $this->initVar("order_real_name", XOBJ_DTYPE_TXTBOX, null, true, 45); |
||
33 | $this->initVar("order_document_type", XOBJ_DTYPE_INT, null, false); |
||
34 | $this->initVar("order_document", XOBJ_DTYPE_TXTBOX, null, true, 255); |
||
35 | $this->initVar("order_telephone", XOBJ_DTYPE_TXTBOX, null, true, 45); |
||
36 | $this->initVar("order_phone", XOBJ_DTYPE_TXTBOX, null, true, 45); |
||
37 | $this->initVar("order_extra_persons", XOBJ_DTYPE_TXTAREA, null, false); |
||
38 | $this->initVar("order_note", XOBJ_DTYPE_TXTAREA, null, false); |
||
39 | $this->initVar("order_status_time", XOBJ_DTYPE_INT, null, false); |
||
40 | $this->initVar("order_submit_time", XOBJ_DTYPE_INT, null, false); |
||
41 | //room |
||
42 | |||
43 | //users |
||
44 | $this->initVar("uname", XOBJ_DTYPE_TXTBOX, null, true, 255); |
||
45 | $this->initVar("email", XOBJ_DTYPE_TXTBOX, null, true, 255); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return mixed |
||
50 | */ |
||
51 | public function order_id() |
||
52 | { |
||
53 | return $this->getVar("order_id"); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @return mixed |
||
58 | */ |
||
59 | public function order_type() |
||
60 | { |
||
61 | return $this->getVar("order_type"); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return mixed |
||
66 | */ |
||
67 | public function order_mode() |
||
68 | { |
||
69 | return $this->getVar("order_mode"); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return mixed |
||
74 | */ |
||
75 | public function order_uid() |
||
76 | { |
||
77 | return $this->getVar("order_uid"); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @return mixed |
||
82 | */ |
||
83 | public function order_pay_method() |
||
84 | { |
||
85 | return $this->getVar("order_pay_method"); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @param string $format |
||
90 | * @return mixed |
||
91 | */ |
||
92 | public function order_pay($format = 'S') |
||
93 | { |
||
94 | return $this->getVar("order_pay", $format); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * @return mixed |
||
99 | */ |
||
100 | public function order_status() |
||
101 | { |
||
102 | return $this->getVar("order_status"); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * @return mixed |
||
107 | */ |
||
108 | public function order_total_price() |
||
109 | { |
||
110 | return $this->getVar("order_total_price"); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * @return mixed |
||
115 | */ |
||
116 | public function order_pay_money() |
||
117 | { |
||
118 | return $this->getVar("order_pay_money"); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * @return mixed |
||
123 | */ |
||
124 | public function order_coupon() |
||
125 | { |
||
126 | return $this->getVar("order_coupon"); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * @return mixed |
||
131 | */ |
||
132 | public function order_sented_coupon() |
||
133 | { |
||
134 | return $this->getVar("order_sented_coupon"); |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * @param string $format |
||
139 | * @return mixed |
||
140 | */ |
||
141 | public function order_real_name($format = 'S') |
||
142 | { |
||
143 | return $this->getVar("order_real_name", $format); |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * @return mixed |
||
148 | */ |
||
149 | public function order_document_type() |
||
150 | { |
||
151 | return $this->getVar("order_document_type"); |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * @param string $format |
||
156 | * @return mixed |
||
157 | */ |
||
158 | public function order_document($format = 'S') |
||
159 | { |
||
160 | return $this->getVar("order_document", $format); |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * @param string $format |
||
165 | * @return mixed |
||
166 | */ |
||
167 | public function order_telephone($format = 'S') |
||
168 | { |
||
169 | return $this->getVar("order_telephone", $format); |
||
170 | } |
||
171 | |||
172 | /** |
||
173 | * @param string $format |
||
174 | * @return mixed |
||
175 | */ |
||
176 | public function order_phone($format = 'S') |
||
177 | { |
||
178 | return $this->getVar("order_phone", $format); |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * @param string $format |
||
183 | * @return mixed |
||
184 | */ |
||
185 | public function order_extra_persons($format = 'S') |
||
186 | { |
||
187 | return unserialize($this->getVar("order_extra_persons", $format)); |
||
188 | } |
||
189 | |||
190 | /** |
||
191 | * @param string $format |
||
192 | * @return mixed |
||
193 | */ |
||
194 | public function order_note($format = 'S') |
||
195 | { |
||
196 | return $this->getVar("order_note", $format); |
||
197 | } |
||
198 | |||
199 | /** |
||
200 | * @return mixed |
||
201 | */ |
||
202 | public function order_status_time() |
||
203 | { |
||
204 | return $this->getVar("order_status_time"); |
||
205 | } |
||
206 | |||
207 | /** |
||
208 | * @return mixed |
||
209 | */ |
||
210 | public function order_submit_time() |
||
211 | { |
||
212 | return $this->getVar("order_submit_time"); |
||
213 | } |
||
214 | |||
215 | //rooms |
||
216 | |||
217 | //users |
||
218 | /** |
||
219 | * @param string $format |
||
220 | * @return mixed |
||
221 | */ |
||
222 | public function uname($format = 'S') |
||
223 | { |
||
224 | return $this->getVar("uname", $format); |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * @param string $format |
||
229 | * @return mixed |
||
230 | */ |
||
231 | public function email($format = 'S') |
||
232 | { |
||
233 | return $this->getVar("email", $format); |
||
234 | } |
||
235 | } |
||
236 | |||
237 | /** |
||
238 | * @method: orderHandler |
||
239 | * @license http://www.blags.org/ |
||
240 | * @created :2010年05月21日 20时40分 |
||
241 | * @copyright 1997-2010 The Martin Group |
||
242 | * @author Martin <[email protected]> |
||
243 | * */ |
||
244 | class MartinOrderHandler extends XoopsObjectHandler |
||
245 | { |
||
246 | /** |
||
247 | * create a new hotel order |
||
248 | * @param bool $isNew flag the new objects as "new"? |
||
249 | * @return object order |
||
250 | */ |
||
251 | public function &create($isNew = true) |
||
252 | { |
||
253 | $order = new MartinOrder(); |
||
254 | if ($isNew) { |
||
255 | $order->setNew(); |
||
256 | } |
||
257 | |||
258 | return $order; |
||
259 | } |
||
260 | |||
261 | /** |
||
262 | * retrieve a hotel order |
||
263 | * |
||
264 | * @param int $id orderid of the order |
||
265 | * @return mixed reference to the {@link order} object, FALSE if failed |
||
266 | */ |
||
267 | public function &get($id) |
||
268 | { |
||
269 | if ((int)($id) <= 0) { |
||
270 | return false; |
||
271 | } |
||
272 | |||
273 | $criteria = new CriteriaCompo(new Criteria('order_id', $id)); |
||
274 | $criteria->setLimit(1); |
||
275 | $obj_array = $this->getObjects('', $criteria); |
||
276 | |||
277 | if (count($obj_array) != 1) { |
||
278 | $obj =& $this->create(); |
||
279 | |||
280 | return $obj; |
||
281 | } |
||
282 | |||
283 | //var_dump($obj_array); |
||
284 | //get order roooms |
||
285 | $obj_array[0]->rooms = $this->GetOrderRooms($id); |
||
286 | $obj_array[0]->qrooms = $this->GetOrderQueryRooms($id); |
||
287 | //not query room |
||
288 | //$obj_array[0]->rooms = empty($obj_array[0]->rooms) ? $this->GetOrderRooms($id) : $obj_array[0]->rooms; |
||
289 | |||
290 | return $obj_array[0]; |
||
291 | } |
||
292 | |||
293 | /** |
||
294 | * @得到列表 |
||
295 | * @license http://www.blags.org/ |
||
296 | * @created :2010年05月23日 14时59分 |
||
297 | * @copyright 1997-2010 The Martin Group |
||
298 | * @author Martin <[email protected]> |
||
299 | * @param $Data |
||
300 | * @param int $limit |
||
301 | * @param int $start |
||
302 | * @param string $sort |
||
303 | * @param string $order |
||
304 | * @param bool $id_as_key |
||
305 | * @return array |
||
306 | */ |
||
307 | View Code Duplication | public function &getOrders($Data, $limit = 0, $start = 0, $sort = 'order_id', $order = 'ASC', $id_as_key = true) |
|
0 ignored issues
–
show
|
|||
308 | { |
||
309 | $criteria = new CriteriaCompo(); |
||
310 | |||
311 | $criteria->setSort($sort); |
||
312 | $criteria->setOrder($order); |
||
313 | |||
314 | $criteria->setStart($start); |
||
315 | $criteria->setLimit($limit); |
||
316 | |||
317 | return $this->getObjects($Data, $criteria, $id_as_key); |
||
318 | } |
||
319 | |||
320 | /** |
||
321 | * insert a new order in the database |
||
322 | * |
||
323 | * @param object $order reference to the {@link order} object |
||
324 | * @param bool $force |
||
325 | * @return bool FALSE if failed, TRUE if already present and unchanged or successful |
||
326 | */ |
||
327 | public function insert(&$order, $force = false) |
||
328 | { |
||
329 | if (strtolower(get_class($order)) !== 'martinorder') { |
||
330 | return false; |
||
331 | } |
||
332 | |||
333 | if (!$order->cleanVars()) { |
||
334 | return false; |
||
335 | } |
||
336 | |||
337 | foreach ($order->cleanVars as $k => $v) { |
||
338 | ${$k} = $v; |
||
339 | } |
||
340 | |||
341 | View Code Duplication | if ($order->isNew()) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
342 | $sql = sprintf("INSERT INTO %s ( |
||
343 | order_type_id, |
||
344 | order_type_name |
||
345 | ) VALUES ( |
||
346 | NULL, |
||
347 | %s |
||
348 | )", $this->db->prefix('martin_hotel_order_type'), $this->db->quoteString($order_type_name)); |
||
0 ignored issues
–
show
The variable
$order_type_name does not exist. Did you forget to declare it?
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug. ![]() |
|||
349 | } else { |
||
350 | $sql = sprintf("UPDATE %s SET |
||
351 | order_type_name = %s |
||
352 | WHERE order_type_id = %u", $this->db->prefix('martin_hotel_order_type'), $this->db->quoteString($order_type_name), $order_type_id); |
||
0 ignored issues
–
show
The variable
$order_type_id does not exist. Did you forget to declare it?
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug. ![]() |
|||
353 | } |
||
354 | //echo $sql;exit; |
||
355 | if (false != $force) { |
||
0 ignored issues
–
show
|
|||
356 | $result = $this->db->queryF($sql); |
||
357 | } else { |
||
358 | $result = $this->db->query($sql); |
||
359 | } |
||
360 | if (!$result) { |
||
361 | $order->setErrors('The query returned an error. ' . $this->db->error()); |
||
362 | |||
363 | return false; |
||
364 | } |
||
365 | |||
366 | return $order_id > 0 ? $order_id : $this->db->getInsertId(); |
||
0 ignored issues
–
show
|
|||
367 | } |
||
368 | |||
369 | /** |
||
370 | * @ update order |
||
371 | * @license http://www.blags.org/ |
||
372 | * @created :2010年06月09日 21时46分 |
||
373 | * @copyright 1997-2010 The Martin Group |
||
374 | * @author Martin <[email protected]> |
||
375 | * @param $OrderObj |
||
376 | * @param $room_id |
||
377 | * @return bool |
||
378 | */ |
||
379 | public function updateOrder(&$OrderObj, $room_id) |
||
380 | { |
||
381 | $sql = 'UPDATE ' . $this->db->prefix("martin_order") . ' set order_status = ' . $OrderObj->order_status() . ' WHERE order_id = ' . $OrderObj->order_id(); |
||
382 | //echo $sql;exit; |
||
383 | //update Status |
||
384 | $result = true; |
||
385 | if (!$this->db->queryF($sql)) { |
||
386 | $result = false; |
||
387 | } |
||
388 | //update room price |
||
389 | |||
390 | if (is_array($room_id)) { |
||
391 | foreach ($room_id as $key => $room_price) { |
||
392 | list($id, $room_date) = explode('-', $key); |
||
393 | $sql = 'UPDATE ' . $this->db->prefix("martin_order_query_room") . ' set room_price = ' . $room_price . ' WHERE order_id = ' . $OrderObj->order_id() . " AND room_id = $id AND room_date = $room_date"; |
||
394 | if (!$this->db->queryF($sql)) { |
||
395 | $result = false; |
||
396 | } |
||
397 | } |
||
398 | } |
||
399 | |||
400 | return $result; |
||
401 | } |
||
402 | |||
403 | /** |
||
404 | * @删除一个城市 |
||
405 | * @method:delete(order_id) |
||
406 | * @license http://www.blags.org/ |
||
407 | * @created :2010年05月21日 20时40分 |
||
408 | * @copyright 1997-2010 The Martin Group |
||
409 | * @author Martin <[email protected]> |
||
410 | * @param object $order |
||
411 | * @param bool $force |
||
412 | * @return bool|void |
||
413 | */ |
||
414 | public function delete(&$order, $force = false) |
||
415 | { |
||
416 | if (strtolower(get_class($order)) !== 'martinorder') { |
||
417 | return false; |
||
418 | } |
||
419 | |||
420 | global $xoopsDB; |
||
421 | //delete order room relation |
||
422 | $sql = "DELETE FROM " . $xoopsDB->prefix("martin_order_room") . " WHERE order_id = " . $order->order_id(); |
||
423 | $xoopsDB->queryF($sql); |
||
424 | //delete order query room relation |
||
425 | $sql = "DELETE FROM " . $xoopsDB->prefix("martin_order_query_room") . " WHERE order_id = " . $order->order_id(); |
||
426 | $xoopsDB->queryF($sql); |
||
427 | //delete order service |
||
428 | $sql = "DELETE FROM " . $xoopsDB->prefix("martin_order_service") . " WHERE order_id = " . $order->order_id(); |
||
429 | $xoopsDB->queryF($sql); |
||
430 | |||
431 | $sql = "DELETE FROM " . $xoopsDB->prefix("martin_order") . " WHERE order_id = " . $order->order_id(); |
||
432 | |||
433 | if (false != $force) { |
||
0 ignored issues
–
show
|
|||
434 | $result = $xoopsDB->queryF($sql); |
||
435 | } else { |
||
436 | $result = $xoopsDB->query($sql); |
||
437 | } |
||
438 | |||
439 | if (!$result) { |
||
440 | return false; |
||
441 | } |
||
442 | |||
443 | return true; |
||
444 | } |
||
445 | |||
446 | /** |
||
447 | * delete hotel cities matching a set of conditions |
||
448 | * |
||
449 | * @param object $criteria {@link CriteriaElement} |
||
0 ignored issues
–
show
Should the type for parameter
$criteria not be object|null ?
This check looks for It makes a suggestion as to what type it considers more descriptive. Most often this is a case of a parameter that can be null in addition to its declared types. ![]() |
|||
450 | * @return bool FALSE if deletion failed |
||
451 | */ |
||
452 | View Code Duplication | public function deleteAll($criteria = null) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
453 | { |
||
454 | $sql = 'DELETE FROM ' . $this->db->prefix('martin_order'); |
||
455 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
||
0 ignored issues
–
show
|
|||
456 | $sql .= ' ' . $criteria->renderWhere(); |
||
457 | } |
||
458 | if (!$result = $this->db->query($sql)) { |
||
459 | return false; |
||
460 | } |
||
461 | |||
462 | return true; |
||
463 | } |
||
464 | |||
465 | /** |
||
466 | * count hotel cities matching a condition |
||
467 | * |
||
468 | * @param $Data |
||
469 | * @return int count of categories |
||
470 | * @internal param object $criteria <a href='psi_element://CriteriaElement'>CriteriaElement</a> to match to match |
||
471 | */ |
||
472 | public function getCount($Data) |
||
473 | { |
||
474 | if (is_array($Data)) { |
||
475 | foreach ($Data as $key => $value) { |
||
476 | ${$key} = (int)($value); |
||
477 | } |
||
478 | } |
||
479 | $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('martin_order') . " WHERE 1 = 1 "; |
||
480 | $sql .= $order_mode > 0 ? "AND order_mode = $order_mode " : " "; |
||
0 ignored issues
–
show
|
|||
481 | $sql .= $order_pay_method > 0 ? "AND order_pay_method = $order_pay_method " : " "; |
||
0 ignored issues
–
show
The variable
$order_pay_method does not exist. Did you forget to declare it?
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug. ![]() |
|||
482 | $sql .= $order_status > 0 ? "AND order_status = $order_status " : " "; |
||
0 ignored issues
–
show
The variable
$order_status does not exist. Did you forget to declare it?
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug. ![]() |
|||
483 | $sql .= $order_type > 0 ? "AND order_type = $order_type " : " "; |
||
0 ignored issues
–
show
|
|||
484 | $sql .= $hotel_id > 0 ? "AND order_id IN ( |
||
0 ignored issues
–
show
|
|||
485 | SELECT order_id FROM " . $this->db->prefix('martin_order_room') . " WHERE room_id IN ( |
||
486 | SELECT room_id FROM " . $this->db->prefix("martin_room") . " WHERE hotel_id = $hotel_id |
||
487 | )) " : " "; |
||
488 | //echo $sql; |
||
489 | $result = $this->db->query($sql); |
||
490 | if (!$result) { |
||
491 | return 0; |
||
492 | } |
||
493 | list($count) = $this->db->fetchRow($result); |
||
494 | |||
495 | return $count; |
||
496 | } |
||
497 | |||
498 | /** |
||
499 | * @得到城市 |
||
500 | * @license http://www.blags.org/ |
||
501 | * @created :2010年05月21日 20时40分 |
||
502 | * @copyright 1997-2010 The Martin Group |
||
503 | * @author Martin <[email protected]> |
||
504 | * @param $Data |
||
505 | * @param null $criteria |
||
506 | * @param bool $id_as_key |
||
507 | * @return array |
||
508 | */ |
||
509 | public function &getObjects($Data, $criteria = null, $id_as_key = false) |
||
510 | { |
||
511 | if (is_array($Data)) { |
||
512 | foreach ($Data as $key => $value) { |
||
513 | ${$key} = (int)($value); |
||
514 | } |
||
515 | } |
||
516 | |||
517 | $ret = array(); |
||
518 | $limit = $start = 0; |
||
519 | $sql = 'SELECT o.*,u.* FROM ' . $this->db->prefix('martin_order') . ' o '; |
||
520 | $sql .= 'LEFT JOIN ' . $this->db->prefix('users') . ' u ON ( o.order_uid = u.uid ) '; |
||
521 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement') && empty($Data)) { |
||
0 ignored issues
–
show
|
|||
522 | $sql .= ' ' . $criteria->renderWhere(); |
||
523 | /*if ($criteria->getSort() != '') { |
||
524 | $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder(); |
||
525 | }*/ |
||
526 | $limit = $criteria->getLimit(); |
||
527 | $start = $criteria->getStart(); |
||
528 | } |
||
529 | $sql .= $Data ? ' WHERE 1 = 1 ' : " "; |
||
530 | $sql .= $order_mode > 0 ? "AND order_mode = $order_mode " : " "; |
||
0 ignored issues
–
show
|
|||
531 | $sql .= $order_pay_method > 0 ? "AND order_pay_method = $order_pay_method " : " "; |
||
0 ignored issues
–
show
The variable
$order_pay_method does not exist. Did you forget to declare it?
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug. ![]() |
|||
532 | $sql .= $order_status > 0 ? "AND order_status = $order_status " : " "; |
||
0 ignored issues
–
show
The variable
$order_status does not exist. Did you forget to declare it?
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug. ![]() |
|||
533 | $sql .= $order_type > 0 ? "AND order_type = $order_type " : " "; |
||
0 ignored issues
–
show
|
|||
534 | $sql .= $hotel_id > 0 ? "AND o.order_id IN ( |
||
0 ignored issues
–
show
|
|||
535 | SELECT order_id FROM " . $this->db->prefix('martin_order_room') . " WHERE room_id IN ( |
||
536 | SELECT room_id FROM " . $this->db->prefix("martin_room") . " WHERE hotel_id = $hotel_id |
||
537 | )) " : " "; |
||
538 | $sql .= " ORDER BY o.order_status ASC , o.order_submit_time DESC "; |
||
539 | //echo $sql;exit; |
||
540 | |||
541 | $result = $this->db->query($sql, $limit, $start); |
||
542 | |||
543 | if (!$result) { |
||
544 | return $ret; |
||
545 | } |
||
546 | |||
547 | $theObjects = array(); |
||
548 | |||
549 | while ($myrow = $this->db->fetchArray($result)) { |
||
550 | $order = new MartinOrder(); |
||
551 | $order->assignVars($myrow); |
||
552 | $theObjects[$myrow['order_id']] =& $order; |
||
553 | //var_dump($order); |
||
554 | unset($order); |
||
555 | } |
||
556 | //var_dump($theObjects); |
||
557 | |||
558 | foreach ($theObjects as $theObject) { |
||
559 | if (!$id_as_key) { |
||
560 | $ret[] =& $theObject; |
||
561 | } else { |
||
562 | $ret[$theObject->order_id()] =& $theObject; |
||
563 | } |
||
564 | unset($theObject); |
||
565 | } |
||
566 | |||
567 | //var_dump($ret); |
||
568 | return $ret; |
||
569 | } |
||
570 | |||
571 | /** |
||
572 | * @get order rooms |
||
573 | * @method: |
||
574 | * @license http://www.blags.org/ |
||
575 | * @created :2010年06月07日 20时25分 |
||
576 | * @copyright 1997-2010 The Martin Group |
||
577 | * @author Martin <[email protected]> |
||
578 | * @param $order_id |
||
579 | * @return array |
||
580 | */ |
||
581 | View Code Duplication | public function GetOrderRooms($order_id) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
582 | { |
||
583 | if (!$order_id) { |
||
584 | return $order_id; |
||
585 | } |
||
586 | global $xoopsDB; |
||
587 | $sql = "SELECT mor.room_id , mor.room_count ,mor.room_date , r.room_name , h.hotel_id , |
||
588 | rp.room_is_today_special,rp.room_price,rp.room_advisory_range_small,rp.room_advisory_range_max , |
||
589 | h.hotel_name,hotel_city_id "; |
||
590 | $sql .= "FROM " . $xoopsDB->prefix("martin_order_room") . " mor "; |
||
591 | |||
592 | $sql .= " LEFT JOIN " . $xoopsDB->prefix("martin_room") . " r ON ( r.room_id = mor.room_id ) "; |
||
593 | $sql .= " LEFT JOIN " . $xoopsDB->prefix("martin_room_price") . " rp ON ( r.room_id = rp.room_id AND mor.room_date = rp.room_date ) "; |
||
594 | $sql .= " LEFT JOIN " . $xoopsDB->prefix("martin_hotel") . " h ON ( r.hotel_id = h.hotel_id ) "; |
||
595 | $sql .= " WHERE 1 = 1 "; |
||
596 | $sql .= $order_id > 0 ? " AND mor.order_id = $order_id " : " "; |
||
597 | $sql .= " Group by mor.room_date order by mor.room_id DESC "; |
||
598 | //echo '<pre>'.$sql;exit; |
||
599 | $result = $xoopsDB->query($sql); |
||
600 | $rows = array(); |
||
601 | while ($row = $xoopsDB->fetchArray($result)) { |
||
602 | $rows[] = $row; |
||
603 | } |
||
604 | |||
605 | return $rows; |
||
606 | } |
||
607 | |||
608 | /** |
||
609 | * @get order query rooms |
||
610 | * @method: |
||
611 | * @license http://www.blags.org/ |
||
612 | * @created :2010年06月07日 20时25分 |
||
613 | * @copyright 1997-2010 The Martin Group |
||
614 | * @author Martin <[email protected]> |
||
615 | * @param $order_id |
||
616 | * @return array |
||
617 | */ |
||
618 | View Code Duplication | public function GetOrderQueryRooms($order_id) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
619 | { |
||
620 | if (!$order_id) { |
||
621 | return $order_id; |
||
622 | } |
||
623 | global $xoopsDB; |
||
624 | $sql = "SELECT mor.room_id , mor.room_count ,mor.room_date , mor.room_price , r.* , |
||
625 | rp.room_is_today_special,rp.room_advisory_range_small,rp.room_advisory_range_max , |
||
626 | h.hotel_name,hotel_city_id "; |
||
627 | $sql .= "FROM " . $xoopsDB->prefix("martin_order_query_room") . " mor "; |
||
628 | |||
629 | $sql .= " LEFT JOIN " . $xoopsDB->prefix("martin_room") . " r ON ( r.room_id = mor.room_id ) "; |
||
630 | $sql .= " LEFT JOIN " . $xoopsDB->prefix("martin_room_price") . " rp ON ( r.room_id = rp.room_id AND mor.room_date = rp.room_date ) "; |
||
631 | $sql .= " LEFT JOIN " . $xoopsDB->prefix("martin_hotel") . " h ON ( r.hotel_id = h.hotel_id ) "; |
||
632 | $sql .= " WHERE 1 = 1 "; |
||
633 | $sql .= $order_id > 0 ? " AND mor.order_id = $order_id " : " "; |
||
634 | $sql .= " Group by mor.room_date order by mor.room_id DESC "; |
||
635 | //echo '<pre>'.$sql;exit; |
||
636 | $result = $xoopsDB->query($sql); |
||
637 | $rows = array(); |
||
638 | while ($row = $xoopsDB->fetchArray($result)) { |
||
639 | $rows[] = $row; |
||
640 | } |
||
641 | |||
642 | return $rows; |
||
643 | } |
||
644 | |||
645 | /** |
||
646 | * @得到类别列表 |
||
647 | * @license http://www.blags.org/ |
||
648 | * @created :2010年05月30日 20时48分 |
||
649 | * @copyright 1997-2010 The Martin Group |
||
650 | * @author Martin <[email protected]> |
||
651 | * */ |
||
652 | View Code Duplication | public function GetList() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
653 | { |
||
654 | $sql = "SELECT * FROM " . $this->db->prefix("martin_order"); |
||
655 | $result = $this->db->query($sql); |
||
656 | $rows = array(); |
||
657 | while ($row = $this->db->fetchArray($result)) { |
||
658 | $rows[$row['order_id']] = $row; |
||
659 | } |
||
660 | |||
661 | return $rows; |
||
662 | } |
||
663 | |||
664 | /** |
||
665 | * @get hotel list |
||
666 | * @license http://www.blags.org/ |
||
667 | * @created :2010年06月10日 21时25分 |
||
668 | * @copyright 1997-2010 The Martin Group |
||
669 | * @author Martin <[email protected]> |
||
670 | * @param $hotel_city_id |
||
671 | * @param $hotel_star |
||
672 | * @return array |
||
673 | */ |
||
674 | public function GetSearchHotelList($hotel_city_id, $hotel_star) |
||
675 | { |
||
676 | global $xoopsDB; |
||
677 | $sql = "select hotel_id ,hotel_name FROM {$xoopsDB->prefix('martin_hotel')} WHERE 1 = 1 "; |
||
678 | $sql .= $hotel_city_id > 0 ? " and hotel_city_id = $hotel_city_id " : " "; |
||
679 | $sql .= $hotel_star > 0 ? " and hotel_star = $hotel_star " : " "; |
||
680 | $result = $xoopsDB->query($sql); |
||
681 | $hotelArr = array(); |
||
682 | while ($row = $xoopsDB->fetchArray($result)) { |
||
683 | $hotelArr[$row['hotel_id']] = $row['hotel_name']; |
||
684 | } |
||
685 | |||
686 | return $hotelArr; |
||
687 | } |
||
688 | } |
||
689 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.