31 include_once
'./payment/classes/class.ilPaymentVendors.php';
32 include_once
'./payment/classes/class.ilPaymentTrustees.php';
57 $this->admin_view = $a_admin_view;
58 $this->user_id = $a_user_id;
70 return $this->booking_id = $a_booking_id;
78 $this->transaction = $a_transaction;
82 return $this->transaction;
86 $this->pobject_id = $a_pobject_id;
90 return $this->pobject_id;
94 $this->customer_id = $a_customer_id;
98 return $this->customer_id;
102 $this->vendor_id = $a_vendor_id;
106 return $this->vendor_id;
110 $this->pay_method = $a_pay_method;
114 return $this->pay_method;
118 $this->order_date = $a_order_date;
122 return $this->order_date;
126 $this->duration = $a_duration;
130 return $this->duration;
134 $this->price = $a_price;
142 $this->discount = $a_discount;
146 return $this->discount;
150 $this->payed = $a_payed;
158 $this->access = $a_access;
166 $this->voucher = $a_voucher;
170 return $this->voucher;
174 $this->transaction_extern = $a_transaction_extern;
178 return $this->transaction_extern;
183 $query = sprintf(
"INSERT INTO payment_statistic VALUES('',".
184 "'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
199 $this->db->query($query);
201 return $this->db->getLastInsertId();
208 $query =
"UPDATE payment_statistic ".
211 "WHERE booking_id = '".$this->getBookingId().
"'";
212 $this->db->query($query);
223 $query =
"DELETE FROM payment_statistic ".
224 "WHERE booking_id = '".$this->getBookingId().
"'";
226 $this->db->query($query);
235 $query =
'SELECT * FROM payment_statistic as ps, payment_objects as po '.
236 "WHERE ps.pobject_id = po.pobject_id ".
237 "AND customer_id = '".$a_usr_id.
"' ".
238 "ORDER BY order_date DESC";
240 $res = $this->db->query($query);
243 $booking[$row->booking_id][
'booking_id'] = $row->booking_id;
244 $booking[$row->booking_id][
'transaction'] = $row->transaction;
245 $booking[$row->booking_id][
'pobject_id'] = $row->pobject_id;
246 $booking[$row->booking_id][
'customer_id'] = $row->customer_id;
247 $booking[$row->booking_id][
'order_date'] = $row->order_date;
248 $booking[$row->booking_id][
'duration'] = $row->duration;
249 $booking[$row->booking_id][
'price'] = $row->price;
250 $booking[$row->booking_id][
'discount'] = $row->discount;
251 $booking[$row->booking_id][
'payed'] = $row->payed;
252 $booking[$row->booking_id][
'access'] = $row->access;
253 $booking[$row->booking_id][
'ref_id'] = $row->ref_id;
254 $booking[$row->booking_id][
'status'] = $row->status;
255 $booking[$row->booking_id][
'pay_method'] = $row->pay_method;
256 $booking[$row->booking_id][
'vendor_id'] = $row->vendor_id;
257 $booking[$row->booking_id][
'b_vendor_id'] = $row->b_vendor_id;
258 $booking[$row->booking_id][
'b_pay_method'] = $row->b_pay_method;
259 $booking[$row->booking_id][
'voucher'] = $row->voucher;
260 $booking[$row->booking_id][
'transaction_extern'] = $row->transaction_extern;
262 return $booking ? $booking : array();
267 return $this->bookings ? $this->bookings : array();
272 $query =
'SELECT * FROM payment_statistic as ps, payment_objects as po '.
273 "WHERE ps.pobject_id = po.pobject_id ".
274 "AND booking_id = '".$a_booking_id.
"'";
276 $res = $this->db->query($query);
279 $booking[
'booking_id'] = $row->booking_id;
280 $booking[
'transaction'] = $row->transaction;
281 $booking[
'pobject_id'] = $row->pobject_id;
282 $booking[
'customer_id'] = $row->customer_id;
283 $booking[
'order_date'] = $row->order_date;
284 $booking[
'duration'] = $row->duration;
285 $booking[
'price'] = $row->price;
286 $booking[
'discount'] = $row->discount;
287 $booking[
'payed'] = $row->payed;
288 $booking[
'access'] = $row->access;
289 $booking[
'ref_id'] = $row->ref_id;
290 $booking[
'status'] = $row->status;
291 $booking[
'pay_method'] = $row->pay_method;
292 $booking[
'vendor_id'] = $row->vendor_id;
293 $booking[
'b_vendor_id'] = $row->b_vendor_id;
294 $booking[
'b_pay_method'] = $row->b_pay_method;
295 $booking[
'voucher'] = $row->voucher;
296 $booking[
'transaction_extern'] = $row->transaction_extern;
298 return $booking ? $booking : array();
307 $query =
"SELECT COUNT(booking_id) AS bid FROM payment_statistic ".
308 "WHERE b_vendor_id = '".$a_vendor_id.
"'";
310 $res = $ilDB->query($query);
322 $query =
"SELECT COUNT(booking_id) AS bid FROM payment_statistic ".
323 "WHERE customer_id = '".$a_vendor_id.
"'";
325 $res = $ilDB->query($query);
336 $query =
"SELECT COUNT(booking_id) AS bid FROM payment_statistic ".
337 "WHERE pobject_id = '".$a_pobject_id.
"'";
339 $res = $ilDB->query($query);
351 $usr_id = $a_user_id ? $a_user_id : $ilias->account->getId();
353 $query =
"SELECT * FROM payment_statistic ".
354 "WHERE pobject_id = '".$a_pobject_id.
"' ".
355 "AND customer_id = '".$usr_id.
"' ".
359 $res = $ilDB->query($query);
362 $orderDateYear = date(
"Y", $row->order_date);
363 $orderDateMonth = date(
"m", $row->order_date);
364 $orderDateDay = date(
"d", $row->order_date);
365 $orderDateHour = date(
"H", $row->order_date);
366 $orderDateMinute = date(
"i", $row->order_date);
367 $orderDateSecond = date(
"s", $row->order_date);
368 if (($orderDateMonth + $row->duration) > 12)
370 $years = floor(($orderDateMonth + $row->duration) / 12);
371 $months = ($orderDateMonth + $row->duration) - (12 * $years);
372 $orderDateYear += $years;
373 $orderDateMonth = $months;
377 $orderDateMonth += $row->duration;
379 $startDate = date(
"Y-m-d H:i:s", $row->order_date);
380 $endDate = date(
"Y-m-d H:i:s", mktime($orderDateHour, $orderDateMinute, $orderDateSecond, $orderDateMonth, $orderDateDay, $orderDateYear));
381 if (date(
"Y-m-d H:i:s") >= $startDate &&
382 date(
"Y-m-d H:i:s") <= $endDate)
394 $usr_id = $a_user_id ? $a_user_id : $ilias->account->getId();
396 $query =
"SELECT * FROM payment_statistic ".
397 "WHERE pobject_id = '".$a_pobject_id.
"' ".
398 "AND customer_id = '".$usr_id.
"' ".
402 $res = $ilDB->query($query);
405 $orderDateYear = date(
"Y", $row->order_date);
406 $orderDateMonth = date(
"m", $row->order_date);
407 $orderDateDay = date(
"d", $row->order_date);
408 $orderDateHour = date(
"H", $row->order_date);
409 $orderDateMinute = date(
"i", $row->order_date);
410 $orderDateSecond = date(
"s", $row->order_date);
411 if (($orderDateMonth + $row->duration) > 12)
413 $years = floor(($orderDateMonth + $row->duration) / 12);
414 $months = ($orderDateMonth + $row->duration) - (12 * $years);
415 $orderDateYear += $years;
416 $orderDateMonth = $months;
420 $orderDateMonth += $row->duration;
422 $startDate = date(
"Y-m-d H:i:s", $row->order_date);
423 $endDate = date(
"Y-m-d H:i:s", mktime($orderDateHour, $orderDateMinute, $orderDateSecond, $orderDateMonth, $orderDateDay, $orderDateYear));
424 if (date(
"Y-m-d H:i:s") >= $startDate &&
425 date(
"Y-m-d H:i:s") <= $endDate)
428 "activation_start" => $row->order_date,
429 "activation_end" => mktime($orderDateHour, $orderDateMinute, $orderDateSecond, $orderDateMonth, $orderDateDay, $orderDateYear)
442 $query =
"SELECT COUNT(booking_id) AS bid FROM payment_statistic ".
443 "WHERE pay_method = '1'";
445 $res = $ilDB->query($query);
453 $query =
"SELECT COUNT(booking_id) AS bid FROM payment_statistic ".
454 "WHERE pay_method = '2'";
456 $res = $ilDB->query($query);
464 $query =
"SELECT COUNT(booking_id) AS bid FROM payment_statistic ".
465 "WHERE pay_method = '3'";
467 $res = $ilDB->query($query);
483 $query =
'SELECT * FROM payment_statistic as ps, payment_objects as po';
486 $query .=
', usr_data as ud';
488 $query .=
" WHERE ps.pobject_id = po.pobject_id ";
490 if ($_SESSION[
"pay_statistics"][
"transaction_value"] !=
"")
492 if ($_SESSION[
"pay_statistics"][
"transaction_type"] == 0)
494 $query .=
"AND transaction_extern LIKE '" . $_SESSION[
"pay_statistics"][
"transaction_value"] .
"%' ";
496 else if ($_SESSION[
"pay_statistics"][
"transaction_type"] == 1)
498 $query .=
"AND transaction_extern LIKE '%" . $_SESSION[
"pay_statistics"][
"transaction_value"] .
"' ";
501 if ($_SESSION[
"pay_statistics"][
"customer"] !=
"")
503 $query .=
"AND ud.login LIKE '%" . $_SESSION[
"pay_statistics"][
"customer"] .
"%' " .
504 "AND ud.usr_id = ps.customer_id ";
506 if ($_SESSION[
"pay_statistics"][
"from"][
"day"] !=
"" &&
507 $_SESSION[
"pay_statistics"][
"from"][
"month"] !=
"" &&
508 $_SESSION[
"pay_statistics"][
"from"][
"year"] !=
"")
510 $from = mktime(0, 0, 0, $_SESSION[
"pay_statistics"][
"from"][
"month"],
511 $_SESSION[
"pay_statistics"][
"from"][
"day"], $_SESSION[
"pay_statistics"][
"from"][
"year"]);
512 $query .=
"AND order_date >= '" . $from .
"' ";
514 if ($_SESSION[
"pay_statistics"][
"til"][
"day"] !=
"" &&
515 $_SESSION[
"pay_statistics"][
"til"][
"month"] !=
"" &&
516 $_SESSION[
"pay_statistics"][
"til"][
"year"] !=
"")
518 $til = mktime(23, 59, 59, $_SESSION[
"pay_statistics"][
"til"][
"month"],
519 $_SESSION[
"pay_statistics"][
"til"][
"day"], $_SESSION[
"pay_statistics"][
"til"][
"year"]);
520 $query .=
"AND order_date <= '" . $til .
"' ";
522 if ($_SESSION[
"pay_statistics"][
"payed"] ==
"0" ||
523 $_SESSION[
"pay_statistics"][
"payed"] ==
"1")
525 $query .=
"AND payed = '" . $_SESSION[
"pay_statistics"][
"payed"] .
"' ";
527 if ($_SESSION[
"pay_statistics"][
"access"] ==
"0" ||
528 $_SESSION[
"pay_statistics"][
"access"] ==
"1")
530 $query .=
"AND access = '" . $_SESSION[
"pay_statistics"][
"access"] .
"' ";
532 if ($_SESSION[
"pay_statistics"][
"pay_method"] ==
"1" ||
533 $_SESSION[
"pay_statistics"][
"pay_method"] ==
"2" ||
534 $_SESSION[
"pay_statistics"][
"pay_method"] ==
"3")
536 $query .=
"AND b_pay_method = '" . $_SESSION[
"pay_statistics"][
"pay_method"] .
"' ";
539 if(!$this->admin_view)
542 if (is_array($vendors) &&
545 $in =
'ps.b_vendor_id IN (';
546 $in .= implode(
',',$vendors);
549 $query .=
"AND ".$in.
" ";
554 if($_SESSION[
'pay_statistics'][
'vendor'])
556 $query .=
"AND ud.login LIKE '%" . $_SESSION[
"pay_statistics"][
"vendor"] .
"%' " .
557 "AND ud.usr_id = ps.b_vendor_id ";
560 $query .=
"ORDER BY order_date DESC";
562 $res = $this->db->query($query);
565 $this->bookings[$row->booking_id][
'booking_id'] = $row->booking_id;
566 $this->bookings[$row->booking_id][
'transaction'] = $row->transaction;
567 $this->bookings[$row->booking_id][
'pobject_id'] = $row->pobject_id;
568 $this->bookings[$row->booking_id][
'customer_id'] = $row->customer_id;
569 $this->bookings[$row->booking_id][
'order_date'] = $row->order_date;
570 $this->bookings[$row->booking_id][
'duration'] = $row->duration;
571 $this->bookings[$row->booking_id][
'price'] = $row->price;
572 $this->bookings[$row->booking_id][
'discount'] = $row->discount;
573 $this->bookings[$row->booking_id][
'payed'] = $row->payed;
574 $this->bookings[$row->booking_id][
'access'] = $row->access;
575 $this->bookings[$row->booking_id][
'ref_id'] = $row->ref_id;
576 $this->bookings[$row->booking_id][
'status'] = $row->status;
577 $this->bookings[$row->booking_id][
'pay_method'] = $row->pay_method;
578 $this->bookings[$row->booking_id][
'vendor_id'] = $row->vendor_id;
579 $this->bookings[$row->booking_id][
'b_vendor_id'] = $row->b_vendor_id;
580 $this->bookings[$row->booking_id][
'b_pay_method'] = $row->b_pay_method;
581 $this->bookings[$row->booking_id][
'voucher'] = $row->voucher;
582 $this->bookings[$row->booking_id][
'transaction_extern'] = $row->transaction_extern;
600 #vendors = array_merge($vendors,$v);
604 return $vendors ? $vendors : array();