31 include_once
'./payment/classes/class.ilPaymentVendors.php';
32 include_once
'./payment/classes/class.ilPaymentTrustees.php';
64 $this->admin_view = $a_admin_view;
65 $this->user_id = $a_user_id;
77 return $this->booking_id = $a_booking_id;
85 $this->transaction = $a_transaction;
89 return $this->transaction;
93 $this->pobject_id = $a_pobject_id;
97 return $this->pobject_id;
101 $this->customer_id = $a_customer_id;
105 return $this->customer_id;
109 $this->vendor_id = $a_vendor_id;
113 return $this->vendor_id;
117 $this->pay_method = $a_pay_method;
125 $this->order_date = $a_order_date;
129 return $this->order_date;
133 $this->duration = $a_duration;
137 return $this->duration;
141 if($a_unlimited_duration ==
'' || null) $a_unlimited_duration = 0;
142 $this->unlimited_duration = $a_unlimited_duration;
147 return $this->unlimited_duration;
152 $this->price = $a_price;
160 if($a_discount == null) $a_discount = 0;
161 $this->discount = $a_discount;
165 if($this->discount == null) $this->discount = 0;
166 return $this->discount;
170 $this->payed = $a_payed;
178 $this->access = $a_access;
186 $this->voucher = $a_voucher;
194 $this->transaction_extern = $a_transaction_extern;
198 return $this->transaction_extern;
207 $street = $a_street.
' '.$a_house_nr;
216 $this->po_box = $a_po_box;
225 $this->zipcode = $a_zipcode;
233 $this->city = $a_city;
242 $this->country = $a_country;
247 $this->vat_unit = $a_vat_unit;
252 return $this->vat_unit;
256 $this->vat_rate = $a_vat_rate;
260 return $this->vat_rate;
264 $this->object_title = $a_object_title;
268 return $this->object_title;
273 $next_id = $this->db->nextId(
'payment_statistic');
275 $statement = $this->db->manipulateF(
'
276 INSERT INTO payment_statistic
302 ( %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',
356 $statement = $this->db->manipulateF(
'
357 UPDATE payment_statistic
360 WHERE booking_id = %s',
361 array(
'integer',
'integer',
'integer'),
373 $statement = $this->db->manipulateF(
'
374 DELETE FROM payment_statistic WHERE booking_id = %s',
387 $res = $this->db->queryf(
'
388 SELECT * from payment_statistic ps, payment_objects po
389 WHERE ps.pobject_id = po.pobject_id
391 ORDER BY order_date DESC',
396 while(
$row = $this->db->fetchObject(
$res))
398 $booking[
$row->booking_id][
'booking_id'] =
$row->booking_id;
399 $booking[
$row->booking_id][
'transaction'] =
$row->transaction;
400 $booking[
$row->booking_id][
'pobject_id'] =
$row->pobject_id;
401 $booking[
$row->booking_id][
'customer_id'] =
$row->customer_id;
402 $booking[
$row->booking_id][
'order_date'] =
$row->order_date;
403 $booking[
$row->booking_id][
'duration'] =
$row->duration;
404 $booking[
$row->booking_id][
'price'] =
$row->price;
405 $booking[
$row->booking_id][
'discount'] =
$row->discount;
406 $booking[
$row->booking_id][
'payed'] =
$row->payed;
407 $booking[
$row->booking_id][
'access'] =
$row->access_granted;
408 $booking[
$row->booking_id][
'ref_id'] =
$row->ref_id;
409 $booking[
$row->booking_id][
'status'] =
$row->status;
410 $booking[
$row->booking_id][
'pay_method'] =
$row->pay_method;
411 $booking[
$row->booking_id][
'vendor_id'] =
$row->vendor_id;
412 $booking[
$row->booking_id][
'b_vendor_id'] =
$row->b_vendor_id;
413 $booking[
$row->booking_id][
'b_pay_method'] =
$row->b_pay_method;
414 $booking[
$row->booking_id][
'voucher'] =
$row->voucher;
415 $booking[
$row->booking_id][
'transaction_extern'] =
$row->transaction_extern;
416 $booking[
$row->booking_id][
'street'] =
$row->street;
417 $booking[
$row->booking_id][
'po_box'] =
$row->po_box;
418 $booking[
$row->booking_id][
'zipcode'] =
$row->zipcode;
419 $booking[
$row->booking_id][
'city'] =
$row->city;
420 $booking[
$row->booking_id][
'country'] =
$row->country;
421 $booking[
$row->booking_id][
'vat_rate'] =
$row->vat_rate;
422 $booking[
$row->booking_id][
'vat_unit'] =
$row->vat_unit;
423 $booking[
$row->booking_id][
'object_title'] =
$row->object_title;
426 return $booking ? $booking : array();
431 return $this->bookings ? $this->bookings : array();
436 $res = $this->db->queryf(
'
437 SELECT * FROM payment_statistic ps, payment_objects po
438 WHERE ps.pobject_id = po.pobject_id
439 AND booking_id = %s',
441 array($a_booking_id));
443 while(
$row = $this->db->fetchObject(
$res))
445 $booking[
'booking_id'] =
$row->booking_id;
446 $booking[
'transaction'] =
$row->transaction;
447 $booking[
'pobject_id'] =
$row->pobject_id;
448 $booking[
'customer_id'] =
$row->customer_id;
449 $booking[
'order_date'] =
$row->order_date;
450 $booking[
'duration'] =
$row->duration;
451 $booking[
'vat_rate'] =
$row->vat_rate;
452 $booking[
'vat_unit'] =
$row->vat_unit;
453 $booking[
'object_title'] =
$row->object_title;
455 $booking[
'price'] =
$row->price;
456 $booking[
'discount'] =
$row->discount;
457 $booking[
'payed'] =
$row->payed;
458 $booking[
'access'] =
$row->access_granted;
459 $booking[
'ref_id'] =
$row->ref_id;
460 $booking[
'status'] =
$row->status;
461 $booking[
'pay_method'] =
$row->pay_method;
462 $booking[
'vendor_id'] =
$row->vendor_id;
463 $booking[
'b_vendor_id'] =
$row->b_vendor_id;
464 $booking[
'b_pay_method'] =
$row->b_pay_method;
465 $booking[
'voucher'] =
$row->voucher;
466 $booking[
'transaction_extern'] =
$row->transaction_extern;
467 $booking[
'street'] =
$row->street;
468 $booking[
'po_box'] =
$row->po_box;
469 $booking[
'zipcode'] =
$row->zipcode;
470 $booking[
'city'] =
$row->city;
471 $booking[
'country'] =
$row->country;
473 return $booking ? $booking : array();
481 $res = $ilDB->queryf(
482 'SELECT COUNT(booking_id) bid FROM payment_statistic
483 WHERE b_vendor_id = %s',
485 array($a_vendor_id));
487 while(
$row = $ilDB->fetchAssoc(
$res))
498 $res = $ilDB->queryf(
'
499 SELECT COUNT(booking_id) bid FROM payment_statistic
500 WHERE customer_id = %s',
502 array($a_vendor_id));
504 while(
$row = $ilDB->fetchObject(
$res))
515 $res = $ilDB->queryf(
'
516 SELECT COUNT(booking_id) bid FROM payment_statistic
517 WHERE pobject_id = %s',
519 array($a_pobject_id));
521 while(
$row = $ilDB->fetchObject(
$res))
530 global
$ilDB, $ilias;
532 $usr_id = $a_user_id ? $a_user_id : $ilias->account->getId();
534 $res = $ilDB->queryf(
'
535 SELECT * FROM payment_statistic
536 WHERE pobject_id = %s
539 AND access_granted = %s',
540 array(
'integer',
'integer',
'integer',
'integer'),
541 array($a_pobject_id,
$usr_id,
'1',
'1'));
543 while(
$row = $ilDB->fetchObject(
$res))
545 $orderDateYear = date(
"Y",
$row->order_date);
546 $orderDateMonth = date(
"m",
$row->order_date);
547 $orderDateDay = date(
"d",
$row->order_date);
548 $orderDateHour = date(
"H",
$row->order_date);
549 $orderDateMinute = date(
"i",
$row->order_date);
550 $orderDateSecond = date(
"s",
$row->order_date);
552 if(
$row->duration != 0)
554 if (($orderDateMonth +
$row->duration) > 12)
556 $years = floor(($orderDateMonth +
$row->duration) / 12);
557 $months = ($orderDateMonth +
$row->duration) - (12 * $years);
558 $orderDateYear += $years;
559 $orderDateMonth = $months;
563 $orderDateMonth +=
$row->duration;
565 $startDate = date(
"Y-m-d H:i:s",
$row->order_date);
566 $endDate = date(
"Y-m-d H:i:s", mktime($orderDateHour, $orderDateMinute, $orderDateSecond, $orderDateMonth, $orderDateDay, $orderDateYear));
567 if (date(
"Y-m-d H:i:s") >= $startDate &&
568 date(
"Y-m-d H:i:s") <= $endDate)
582 $usr_id = $a_user_id ? $a_user_id : $ilias->account->getId();
584 $res = $this->db->queryf(
'
585 SELECT * FROM payment_statistic
586 WHERE pobject_id = %s
589 AND access_granted = %s',
590 array(
'integer',
'integer',
'integer',
'integer'),
591 array($a_pobject_id,
$usr_id,
'1',
'1'));
593 while(
$row = $this->db->fetchObject(
$res))
595 $orderDateYear = date(
"Y",
$row->order_date);
596 $orderDateMonth = date(
"m",
$row->order_date);
597 $orderDateDay = date(
"d",
$row->order_date);
598 $orderDateHour = date(
"H",
$row->order_date);
599 $orderDateMinute = date(
"i",
$row->order_date);
600 $orderDateSecond = date(
"s",
$row->order_date);
601 if (($orderDateMonth +
$row->duration) > 12)
603 $years = floor(($orderDateMonth +
$row->duration) / 12);
604 $months = ($orderDateMonth +
$row->duration) - (12 * $years);
605 $orderDateYear += $years;
606 $orderDateMonth = $months;
610 $orderDateMonth +=
$row->duration;
612 $startDate = date(
"Y-m-d H:i:s",
$row->order_date);
613 $endDate = date(
"Y-m-d H:i:s", mktime($orderDateHour, $orderDateMinute, $orderDateSecond, $orderDateMonth, $orderDateDay, $orderDateYear));
614 if (date(
"Y-m-d H:i:s") >= $startDate &&
615 date(
"Y-m-d H:i:s") <= $endDate)
618 "activation_start" =>
$row->order_date,
619 "activation_end" => mktime($orderDateHour, $orderDateMinute, $orderDateSecond, $orderDateMonth, $orderDateDay, $orderDateYear)
632 $res = $this->db->queryf (
'
633 SELECT COUNT(booking_id) bid FROM payment_statistc
634 WHERE pay_method = %s',
638 while(
$row = $this->db->fetchObject(
$res))
645 $res = $this->db->queryf (
'
646 SELECT COUNT(booking_id) bid FROM payment_statistc
647 WHERE pay_method = %s',
651 while(
$row = $this->db->fetchObject(
$res))
658 $res = $this->db->queryf (
'
659 SELECT COUNT(booking_id) bid FROM payment_statistc
660 WHERE pay_method = %s',
664 while(
$row = $this->db->fetchObject(
$res))
671 $res = $this->db->queryf (
'
672 SELECT COUNT(booking_id) bid FROM payment_statistc
673 WHERE pay_method = %s',
677 while(
$row = $this->db->fetchObject(
$res))
693 $data_types = array();
695 $query =
'SELECT * FROM payment_statistic ps '
696 .
'INNER JOIN payment_objects po ON po.pobject_id = ps.pobject_id ';
697 if(
$_SESSION[
'pay_statistics'][
'customer'])
699 $query .=
'LEFT JOIN usr_data ud ON ud.usr_id = ps.customer_id ';
701 if(
$_SESSION[
'pay_statistics'][
'vendor'] && $this->admin_view)
703 $query .=
'LEFT JOIN usr_data udv ON udv.usr_id = ps.b_vendor_id ';
706 if (
$_SESSION[
'pay_statistics'][
'transaction_value'] !=
'')
708 if (
$_SESSION[
'pay_statistics'][
'transaction_type'] == 0)
710 $query .=
"AND transaction_extern LIKE %s ";
711 array_push(
$data,
$_SESSION[
'pay_statistics'][
'transaction_value'].
'%');
712 array_push($data_types,
'text');
714 else if (
$_SESSION[
'pay_statistics'][
'transaction_type'] == 1)
716 $query .=
"AND transaction_extern LIKE %s ";
717 array_push(
$data,
'%'.
$_SESSION[
'pay_statistics'][
'transaction_value']);
718 array_push($data_types,
'text');
721 if (
$_SESSION[
'pay_statistics'][
'customer'] !=
'')
723 $query .=
"AND ud.login LIKE %s ";
724 array_push(
$data,
'%'.
$_SESSION[
'pay_statistics'][
'customer'].
'%');
725 array_push($data_types,
'text');
727 if (
$_SESSION[
'pay_statistics'][
'from'][
'day'] !=
'' &&
728 $_SESSION[
'pay_statistics'][
'from'][
'month'] !=
'' &&
729 $_SESSION[
'pay_statistics'][
'from'][
'year'] !=
'')
731 $from = mktime(0, 0, 0,
$_SESSION[
'pay_statistics'][
'from'][
'month'],
732 $_SESSION[
'pay_statistics'][
'from'][
'day'],
$_SESSION[
'pay_statistics'][
'from'][
'year']);
733 $query .=
'AND order_date >= %s ';
734 array_push(
$data, $from);
735 array_push($data_types,
'integer');
737 if (
$_SESSION[
'pay_statistics'][
'til'][
'day'] !=
'' &&
738 $_SESSION[
'pay_statistics'][
'til'][
'month'] !=
'' &&
739 $_SESSION[
'pay_statistics'][
'til'][
'year'] !=
'')
741 $til = mktime(23, 59, 59,
$_SESSION[
'pay_statistics'][
'til'][
'month'],
742 $_SESSION[
'pay_statistics'][
'til'][
'day'],
$_SESSION[
'pay_statistics'][
'til'][
'year']);
743 $query .=
'AND order_date <= %s ';
744 array_push(
$data, $til);
745 array_push($data_types,
'integer');
747 if (
$_SESSION[
'pay_statistics'][
'payed'] ==
'0' ||
748 $_SESSION[
'pay_statistics'][
'payed'] ==
'1')
750 $query .=
'AND payed = %s ';
752 array_push($data_types,
'integer');
754 if (
$_SESSION[
'pay_statistics'][
'access'] ==
'0' ||
755 $_SESSION[
'pay_statistics'][
'access'] ==
'1')
757 $query .=
'AND access_granted = %s ';
759 array_push($data_types,
'integer');
761 if (
$_SESSION[
'pay_statistics'][
'pay_method'] ==
'1' ||
762 $_SESSION[
'pay_statistics'][
'pay_method'] ==
'2' ||
763 $_SESSION[
'pay_statistics'][
'pay_method'] ==
'3')
765 $query .=
'AND b_pay_method = %s ';
767 array_push($data_types,
'integer');
770 if(!$this->admin_view)
774 if (is_array($vendors) &&
777 $query .=
' AND '.$this->db->in(
'ps.b_vendor_id', $vendors,
false,
'integer').
' ';
782 if(
$_SESSION[
'pay_statistics'][
'vendor'])
784 $query .=
'AND udv.login LIKE %s ';
787 array_push($data_types,
'text');
790 $query .=
'ORDER BY order_date DESC';
792 $cnt_data = count(
$data);
793 $cnt_data_types = count($data_types);
795 if($cnt_data == 0 || $cnt_data_types == 0)
805 while(
$row = $this->db->fetchObject(
$res))
807 $this->bookings[
$row->booking_id][
'booking_id'] =
$row->booking_id;
808 $this->bookings[
$row->booking_id][
'transaction'] =
$row->transaction;
809 $this->bookings[
$row->booking_id][
'pobject_id'] =
$row->pobject_id;
810 $this->bookings[
$row->booking_id][
'customer_id'] =
$row->customer_id;
811 $this->bookings[
$row->booking_id][
'order_date'] =
$row->order_date;
812 $this->bookings[
$row->booking_id][
'duration'] =
$row->duration;
813 $this->bookings[
$row->booking_id][
'price'] =
$row->price;
814 $this->bookings[
$row->booking_id][
'discount'] =
$row->discount;
815 $this->bookings[
$row->booking_id][
'payed'] =
$row->payed;
816 $this->bookings[
$row->booking_id][
'access'] =
$row->access_granted;
817 $this->bookings[
$row->booking_id][
'ref_id'] =
$row->ref_id;
818 $this->bookings[
$row->booking_id][
'status'] =
$row->status;
819 $this->bookings[
$row->booking_id][
'pay_method'] =
$row->pay_method;
820 $this->bookings[
$row->booking_id][
'vendor_id'] =
$row->vendor_id;
821 $this->bookings[
$row->booking_id][
'b_vendor_id'] =
$row->b_vendor_id;
822 $this->bookings[
$row->booking_id][
'b_pay_method'] =
$row->b_pay_method;
823 $this->bookings[
$row->booking_id][
'voucher'] =
$row->voucher;
824 $this->bookings[
$row->booking_id][
'transaction_extern'] =
$row->transaction_extern;
825 $this->bookings[
$row->booking_id][
'street'] =
$row->street;
826 $this->bookings[
$row->booking_id][
'po_box'] =
$row->po_box;
827 $this->bookings[
$row->booking_id][
'zipcode'] =
$row->zipcode;
828 $this->bookings[
$row->booking_id][
'city'] =
$row->city;
829 $this->bookings[
$row->booking_id][
'country'] =
$row->country;
849 return $vendors ? $vendors : array();
857 $query =
'SELECT * FROM payment_statistic as ps, payment_objects as po
858 WHERE ps.pobject_id = po.pobject_id
860 AND transaction = %s';
863 $res = $ilDB->queryF(
$query, array(
'integer',
'text'), array($a_user_id, $a_transaction_nr));
864 while(
$row = $ilDB->fetchObject(
$res))
885 $bookings[$i][
'transaction_extern'] =
$row->transaction_extern;
905 $query =
'SELECT * FROM payment_statistic
906 WHERE customer_id = %s
908 ORDER BY order_date DESC';
910 $res = $ilDB->queryF(
$query, array(
'integer'), array($a_user_id));
911 while(
$row = $ilDB->fetchObject(
$res))
913 $booking[
$row->booking_id][
'booking_id'] =
$row->booking_id;
914 $booking[
$row->booking_id][
'transaction'] =
$row->transaction;
915 $booking[
$row->booking_id][
'pobject_id'] =
$row->pobject_id;
916 $booking[
$row->booking_id][
'customer_id'] =
$row->customer_id;
917 $booking[
$row->booking_id][
'order_date'] =
$row->order_date;
918 $booking[
$row->booking_id][
'duration'] =
$row->duration;
919 $booking[
$row->booking_id][
'duration_from'] =
$row->duration_from;
920 $booking[
$row->booking_id][
'duration_until'] =
$row->duration_until;
921 $booking[
$row->booking_id][
'price'] =
$row->price;
922 $booking[
$row->booking_id][
'discount'] =
$row->discount;
923 $booking[
$row->booking_id][
'payed'] =
$row->payed;
924 $booking[
$row->booking_id][
'access'] =
$row->access;
925 $booking[
$row->booking_id][
'ref_id'] =
$row->ref_id;
926 $booking[
$row->booking_id][
'status'] =
$row->status;
927 $booking[
$row->booking_id][
'pay_method'] =
$row->pay_method;
928 $booking[
$row->booking_id][
'vendor_id'] =
$row->vendor_id;
929 $booking[
$row->booking_id][
'b_vendor_id'] =
$row->b_vendor_id;
930 $booking[
$row->booking_id][
'b_pay_method'] =
$row->b_pay_method;
931 $booking[
$row->booking_id][
'voucher'] =
$row->voucher;
932 $booking[
$row->booking_id][
'transaction_extern'] =
$row->transaction_extern;
933 $booking[
$row->booking_id][
'price_type'] =
$row->price_type;
934 $booking[
$row->booking_id][
'street'] =
$row->street;
935 $booking[
$row->booking_id][
'po_box'] =
$row->po_box;
936 $booking[
$row->booking_id][
'zipcode'] =
$row->zipcode;
937 $booking[
$row->booking_id][
'city'] =
$row->city;
938 $booking[
$row->booking_id][
'country'] =
$row->country;
939 $booking[
$row->booking_id][
'vat_rate'] =
$row->vat_rate;
940 $booking[
$row->booking_id][
'vat_unit'] =
$row->vat_unit;
941 $booking[
$row->booking_id][
'object_title'] =
$row->object_title;
943 return $booking ? $booking : array();
950 $res = $ilDB->queryF(
'
951 SELECT * FROM payment_statistic WHERE b_pay_method = %s', array(
'integer'), array(
$pay_method));
954 while(
$row = $ilDB->fetchObject(
$res))
956 $booking[$i][
'booking_id'] =
$row->booking_id;
957 $booking[$i][
'pay_method'] =
$row->b_pay_method;
960 return $booking ? $booking : array();
968 UPDATE payment_statistic
974 WHERE b_pay_method = %s',