ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPaymentBookings.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
31 include_once './payment/classes/class.ilPaymentVendors.php';
32 include_once './payment/classes/class.ilPaymentTrustees.php';
33 
35 {
36  /*
37  * id of vendor, admin or trustee
38  */
39  var $user_id = null;
40  var $db = null;
41 
42  var $bookings = array();
43 
44  var $booking_id = null;
45  var $payed = null;
46  var $access = null;
47  var $voucher = null;
48  var $street = null;
49  var $house_nr = null;
50  var $po_box = null;
51  var $zipcode = null;
52  var $city = null;
53  var $country = null;
54 
55  var $admin_view = false;
56 
57  /*
58  * admin_view = true reads all statistic data (only_used in administration)
59  */
60  function ilPaymentBookings($a_user_id = '',$a_admin_view = false)
61  {
62  global $ilDB;
63 
64  $this->admin_view = $a_admin_view;
65  $this->user_id = $a_user_id;
66  $this->db =& $ilDB;
67 
68  if($a_user_id)
69  {
70  $this->__read();
71  }
72  }
73 
74  // SET GET
75  function setBookingId($a_booking_id)
76  {
77  return $this->booking_id = $a_booking_id;
78  }
79  function getBookingId()
80  {
81  return $this->booking_id;
82  }
83  function setTransaction($a_transaction)
84  {
85  $this->transaction = $a_transaction;
86  }
87  function getTransaction()
88  {
89  return $this->transaction;
90  }
91  function setPobjectId($a_pobject_id)
92  {
93  $this->pobject_id = $a_pobject_id;
94  }
95  function getPobjectId()
96  {
97  return $this->pobject_id;
98  }
99  function setCustomerId($a_customer_id)
100  {
101  $this->customer_id = $a_customer_id;
102  }
103  function getCustomerId()
104  {
105  return $this->customer_id;
106  }
107  function setVendorId($a_vendor_id)
108  {
109  $this->vendor_id = $a_vendor_id;
110  }
111  function getVendorId()
112  {
113  return $this->vendor_id;
114  }
115  function setPayMethod($a_pay_method)
116  {
117  $this->pay_method = $a_pay_method;
118  }
119  function getPayMethod()
120  {
121  return $this->pay_method;
122  }
123  function setOrderDate($a_order_date)
124  {
125  $this->order_date = $a_order_date;
126  }
127  function getOrderDate()
128  {
129  return $this->order_date;
130  }
131  function setDuration($a_duration)
132  {
133  $this->duration = $a_duration;
134  }
135  function getDuration()
136  {
137  return $this->duration;
138  }
139  function setUnlimitedDuration($a_unlimited_duration)
140  {
141  if($a_unlimited_duration == '' || null) $a_unlimited_duration = 0;
142  $this->unlimited_duration = $a_unlimited_duration;
143  }
144 
146  {
147  return $this->unlimited_duration;
148  }
149 
150  function setPrice($a_price)
151  {
152  $this->price = $a_price;
153  }
154  function getPrice()
155  {
156  return $this->price;
157  }
158  function setDiscount($a_discount)
159  {
160  if($a_discount == null) $a_discount = 0;
161  $this->discount = $a_discount;
162  }
163  function getDiscount()
164  {
165  if($this->discount == null) $this->discount = 0;
166  return $this->discount;
167  }
168  function setPayed($a_payed)
169  {
170  $this->payed = $a_payed;
171  }
172  function getPayedStatus()
173  {
174  return $this->payed;
175  }
176  function setAccess($a_access)
177  {
178  $this->access = $a_access;
179  }
180  function getAccessStatus()
181  {
182  return $this->access;
183  }
184  function setVoucher($a_voucher)
185  {
186  $this->voucher = $a_voucher;
187  }
188  function getVoucher()
189  {
190  return $this->voucher;
191  }
192  function setTransactionExtern($a_transaction_extern)
193  {
194  $this->transaction_extern = $a_transaction_extern;
195  }
197  {
198  return $this->transaction_extern;
199  }
200 
201  function getStreet()
202  {
203  return $this->street;
204  }
205  function setStreet($a_street, $a_house_nr)
206  {
207  $street = $a_street.' '.$a_house_nr;
208  $this->street = $street;
209  }
210  function getPoBox()
211  {
212  return $this->po_box;
213  }
214  function setPoBox($a_po_box)
215  {
216  $this->po_box = $a_po_box;
217  }
218 
219  function getZipcode()
220  {
221  return $this->zipcode;
222  }
223  function setZipcode($a_zipcode)
224  {
225  $this->zipcode = $a_zipcode;
226  }
227  function getCity()
228  {
229  return $this->city;
230  }
231  function setCity($a_city)
232  {
233  $this->city = $a_city;
234  }
235 
236  function getCountry()
237  {
238  return $this->country;
239  }
240  function setCountry($a_country)
241  {
242  $this->country = $a_country;
243  }
244  function setVatUnit($a_vat_unit)
245  {
246 
247  $this->vat_unit = $a_vat_unit;
248  }
249  function getVatUnit()
250  {
251 
252  return $this->vat_unit;
253  }
254  function setVatRate($a_vat_rate)
255  {
256  $this->vat_rate = $a_vat_rate;
257  }
258  function getVatRate()
259  {
260  return $this->vat_rate;
261  }
262  function setObjectTitle($a_object_title)
263  {
264  $this->object_title = $a_object_title;
265  }
266  function getObjectTitle()
267  {
268  return $this->object_title;
269  }
270 
271  function add()
272  {
273  $next_id = $this->db->nextId('payment_statistic');
274 
275  $statement = $this->db->manipulateF('
276  INSERT INTO payment_statistic
277  (
278  booking_id,
279  transaction,
280  pobject_id,
281  customer_id,
282  b_vendor_id,
283  b_pay_method,
284  order_date,
285  duration,
286  price,
287  discount,
288  payed,
289  access_granted,
290  voucher,
291  transaction_extern,
292  street,
293  po_box,
294  zipcode,
295  city,
296  country,
297  vat_rate,
298  vat_unit,
299  object_title
300  )
301  VALUES
302  ( %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',
303  array( 'integer',
304  'text',
305  'integer',
306  'integer',
307  'integer',
308  'integer',
309  'integer',
310  'text',
311  'text',
312  'text',
313  'integer',
314  'integer',
315  'text',
316  'text',
317  'text',
318  'text',
319  'text',
320  'text',
321  'text',
322  'float',
323  'float',
324  'text'),
325  array( $next_id,
326  $this->getTransaction(),
327  $this->getPobjectId(),
328  $this->getCustomerId(),
329  $this->getVendorId(),
330  $this->getPayMethod(),
331  $this->getOrderDate(),
332  $this->getDuration(),
333  $this->getPrice(),
334  $this->getDiscount(),
335  $this->getPayedStatus(),
336  $this->getAccessStatus(),
337  $this->getVoucher(),
338  $this->getTransactionExtern(),
339  $this->getStreet(),
340  $this->getPoBox(),
341  $this->getZipcode(),
342  $this->getCity(),
343  $this->getCountry(),
344  $this->getVatRate(),
345  $this->getVatUnit(),
346  $this->getObjectTitle()
347  ));
348 
349  return $next_id;
350  }
351 
352  function update()
353  {
354  if($this->getBookingId())
355  {
356  $statement = $this->db->manipulateF('
357  UPDATE payment_statistic
358  SET payed = %s,
359  access_granted = %s
360  WHERE booking_id = %s',
361  array('integer', 'integer', 'integer'),
362  array((int) $this->getPayedStatus(), (int) $this->getAccessStatus(), $this->getBookingId()));
363 
364  return true;
365  }
366  return false;
367  }
368 
369  function delete()
370  {
371  if($this->getBookingId())
372  {
373  $statement = $this->db->manipulateF('
374  DELETE FROM payment_statistic WHERE booking_id = %s',
375  array('integer'),
376  array((int)$this->getBookingId())
377  );
378 
379  return true;
380  }
381  return false;
382  }
383 
384  function getBookingsOfCustomer($a_usr_id)
385  {
386 
387  $res = $this->db->queryf('
388  SELECT * from payment_statistic ps, payment_objects po
389  WHERE ps.pobject_id = po.pobject_id
390  AND customer_id = %s
391  ORDER BY order_date DESC',
392  array('integer'),
393  array($a_usr_id)
394  );
395 
396  while($row = $this->db->fetchObject($res))
397  {
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;
424  }
425 
426  return $booking ? $booking : array();
427  }
428 
429  function getBookings()
430  {
431  return $this->bookings ? $this->bookings : array();
432  }
433 
434  function getBooking($a_booking_id)
435  {
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',
440  array('integer'),
441  array($a_booking_id));
442 
443  while($row = $this->db->fetchObject($res))
444  {
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;
454 
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;
472  }
473  return $booking ? $booking : array();
474  }
475 
476  // STATIC
477  function _getCountBookingsByVendor($a_vendor_id)
478  {
479  global $ilDB;
480 
481  $res = $ilDB->queryf(
482  'SELECT COUNT(booking_id) bid FROM payment_statistic
483  WHERE b_vendor_id = %s',
484  array('integer'),
485  array($a_vendor_id));
486 
487  while($row = $ilDB->fetchAssoc($res))
488  {
489  return $row['bid'];
490  }
491  return 0;
492  }
493 
494  function _getCountBookingsByCustomer($a_vendor_id)
495  {
496  global $ilDB;
497 
498  $res = $ilDB->queryf('
499  SELECT COUNT(booking_id) bid FROM payment_statistic
500  WHERE customer_id = %s',
501  array('integer'),
502  array($a_vendor_id));
503 
504  while($row = $ilDB->fetchObject($res))
505  {
506  return $row->bid;
507  }
508  return 0;
509  }
510 
511  function _getCountBookingsByObject($a_pobject_id)
512  {
513  global $ilDB;
514 
515  $res = $ilDB->queryf('
516  SELECT COUNT(booking_id) bid FROM payment_statistic
517  WHERE pobject_id = %s',
518  array('integer'),
519  array($a_pobject_id));
520 
521  while($row = $ilDB->fetchObject($res))
522  {
523  return $row->bid;
524  }
525  return 0;
526  }
527 
528  function _hasAccess($a_pobject_id,$a_user_id = 0)
529  {
530  global $ilDB, $ilias;
531 
532  $usr_id = $a_user_id ? $a_user_id : $ilias->account->getId();
533 
534  $res = $ilDB->queryf('
535  SELECT * FROM payment_statistic
536  WHERE pobject_id = %s
537  AND customer_id = %s
538  AND payed = %s
539  AND access_granted = %s',
540  array('integer', 'integer', 'integer', 'integer'),
541  array($a_pobject_id, $usr_id, '1', '1'));
542 
543  while($row = $ilDB->fetchObject($res))
544  {
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);
551 
552  if($row->duration != 0)
553  {
554  if (($orderDateMonth + $row->duration) > 12)
555  {
556  $years = floor(($orderDateMonth + $row->duration) / 12);
557  $months = ($orderDateMonth + $row->duration) - (12 * $years);
558  $orderDateYear += $years;
559  $orderDateMonth = $months;
560  }
561  else
562  {
563  $orderDateMonth += $row->duration;
564  }
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)
569  {
570  return true;
571  }
572  }
573  else return true;
574  }
575  return false;
576  }
577 
578  function _getActivation($a_pobject_id,$a_user_id = 0)
579  {
580  global $ilDB,$ilias;
581 
582  $usr_id = $a_user_id ? $a_user_id : $ilias->account->getId();
583 
584  $res = $this->db->queryf('
585  SELECT * FROM payment_statistic
586  WHERE pobject_id = %s
587  AND customer_id = %s
588  AND payed = %s
589  AND access_granted = %s',
590  array('integer', 'integer', 'integer', 'integer'),
591  array($a_pobject_id, $usr_id, '1', '1'));
592 
593  while($row = $this->db->fetchObject($res))
594  {
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)
602  {
603  $years = floor(($orderDateMonth + $row->duration) / 12);
604  $months = ($orderDateMonth + $row->duration) - (12 * $years);
605  $orderDateYear += $years;
606  $orderDateMonth = $months;
607  }
608  else
609  {
610  $orderDateMonth += $row->duration;
611  }
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)
616  {
617  $activation = array(
618  "activation_start" => $row->order_date,
619  "activation_end" => mktime($orderDateHour, $orderDateMinute, $orderDateSecond, $orderDateMonth, $orderDateDay, $orderDateYear)
620  );
621  return $activation;
622  }
623  }
624  return false;
625  }
626 
628  {
629  switch($a_pm)
630  {
631  case 'pm_bill':
632  $res = $this->db->queryf ('
633  SELECT COUNT(booking_id) bid FROM payment_statistc
634  WHERE pay_method = %s',
635  array('integer'),
636  array('1'));
637 
638  while($row = $this->db->fetchObject($res))
639  {
640  return $row->bid;
641  }
642  return 0;
643 
644  case 'pm_bmf':
645  $res = $this->db->queryf ('
646  SELECT COUNT(booking_id) bid FROM payment_statistc
647  WHERE pay_method = %s',
648  array('integer'),
649  array('2'));
650 
651  while($row = $this->db->fetchObject($res))
652  {
653  return $row->bid;
654  }
655  return 0;
656 
657  case 'pm_paypal':
658  $res = $this->db->queryf ('
659  SELECT COUNT(booking_id) bid FROM payment_statistc
660  WHERE pay_method = %s',
661  array('integer'),
662  array('3'));
663 
664  while($row = $this->db->fetchObject($res))
665  {
666  return $row->bid;
667  }
668  return 0;
669 
670  case 'pm_epay':
671  $res = $this->db->queryf ('
672  SELECT COUNT(booking_id) bid FROM payment_statistc
673  WHERE pay_method = %s',
674  array('integer'),
675  array('4'));
676 
677  while($row = $this->db->fetchObject($res))
678  {
679  return $row->bid;
680  }
681  return 0;
682 
683  default:
684  return 0;
685  }
686  }
687 
688  // PRIVATE
689  function __read()
690  {
691 
692  $data = array();
693  $data_types = array();
694 
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'])
698  {
699  $query .= 'LEFT JOIN usr_data ud ON ud.usr_id = ps.customer_id ';
700  }
701  if($_SESSION['pay_statistics']['vendor'] && $this->admin_view)
702  {
703  $query .= 'LEFT JOIN usr_data udv ON udv.usr_id = ps.b_vendor_id ';
704  }
705  $query .= 'WHERE 1 = 1 ';
706  if ($_SESSION['pay_statistics']['transaction_value'] != '')
707  {
708  if ($_SESSION['pay_statistics']['transaction_type'] == 0)
709  {
710  $query .= "AND transaction_extern LIKE %s ";
711  array_push($data, $_SESSION['pay_statistics']['transaction_value'].'%');
712  array_push($data_types, 'text');
713  }
714  else if ($_SESSION['pay_statistics']['transaction_type'] == 1)
715  {
716  $query .= "AND transaction_extern LIKE %s ";
717  array_push($data, '%'.$_SESSION['pay_statistics']['transaction_value']);
718  array_push($data_types, 'text');
719  }
720  }
721  if ($_SESSION['pay_statistics']['customer'] != '')
722  {
723  $query .= "AND ud.login LIKE %s ";
724  array_push($data, '%'.$_SESSION['pay_statistics']['customer'].'%');
725  array_push($data_types, 'text');
726  }
727  if ($_SESSION['pay_statistics']['from']['day'] != '' &&
728  $_SESSION['pay_statistics']['from']['month'] != '' &&
729  $_SESSION['pay_statistics']['from']['year'] != '')
730  {
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');
736  }
737  if ($_SESSION['pay_statistics']['til']['day'] != '' &&
738  $_SESSION['pay_statistics']['til']['month'] != '' &&
739  $_SESSION['pay_statistics']['til']['year'] != '')
740  {
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');
746  }
747  if ($_SESSION['pay_statistics']['payed'] == '0' ||
748  $_SESSION['pay_statistics']['payed'] == '1')
749  {
750  $query .= 'AND payed = %s ';
751  array_push($data, $_SESSION['pay_statistics']['payed']);
752  array_push($data_types, 'integer');
753  }
754  if ($_SESSION['pay_statistics']['access'] == '0' ||
755  $_SESSION['pay_statistics']['access'] == '1')
756  {
757  $query .= 'AND access_granted = %s ';
758  array_push($data, $_SESSION['pay_statistics']['access']);
759  array_push($data_types, 'integer');
760  }
761  if ($_SESSION['pay_statistics']['pay_method'] == '1' ||
762  $_SESSION['pay_statistics']['pay_method'] == '2' ||
763  $_SESSION['pay_statistics']['pay_method'] == '3')
764  {
765  $query .= 'AND b_pay_method = %s ';
766  array_push($data, $_SESSION['pay_statistics']['pay_method']);
767  array_push($data_types, 'integer');
768  }
769 
770  if(!$this->admin_view)
771  {
772 
773  $vendors = $this->__getVendorIds();
774  if (is_array($vendors) &&
775  count($vendors) > 1)
776  {
777  $query .= ' AND '.$this->db->in('ps.b_vendor_id', $vendors, false, 'integer').' ';
778  }
779  }
780  else
781  {
782  if($_SESSION['pay_statistics']['vendor'])
783  {
784  $query .= 'AND udv.login LIKE %s ';
785 
786  array_push($data, '%'.$_SESSION['pay_statistics']['vendor'].'%');
787  array_push($data_types, 'text');
788  }
789  }
790  $query .= 'ORDER BY order_date DESC';
791 
792  $cnt_data = count($data);
793  $cnt_data_types = count($data_types);
794 
795  if($cnt_data == 0 || $cnt_data_types == 0)
796  {
797  $res = $this->db->query($query);
798 
799  }
800  else
801  {
802  $res= $this->db->queryf($query, $data_types, $data);
803  }
804 
805  while($row = $this->db->fetchObject($res))
806  {
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;
830  }
831  }
832 
833  function __getVendorIds()
834  {
835  if(ilPaymentVendors::_isVendor($this->user_id))
836  {
837  $vendors[] = $this->user_id;
838  }
839  if($vend = ilPaymentTrustees::_getVendorsForObjects($this->user_id))
840  {
841  foreach($vend as $v)
842  {
844  {
845  $vendors[] = $v;
846  }
847  }
848  }
849  return $vendors ? $vendors : array();
850  }
851 
852 
853  public static function __readBillByTransaction($a_user_id, $a_transaction_nr)
854  {
855  global $ilDB;
856 
857  $query = 'SELECT * FROM payment_statistic as ps, payment_objects as po
858  WHERE ps.pobject_id = po.pobject_id
859  AND customer_id = %s
860  AND transaction = %s';
861 
862  $i = 0;
863  $res = $ilDB->queryF($query, array('integer','text'), array($a_user_id, $a_transaction_nr));
864  while($row = $ilDB->fetchObject($res))
865  {
866  $bookings[$i]['booking_id'] = $row->booking_id;
867  $bookings[$i]['transaction'] = $row->transaction;
868  $bookings[$i]['pobject_id'] = $row->pobject_id;
869  $bookings[$i]['customer_id'] = $row->customer_id;
870  $bookings[$i]['order_date'] = $row->order_date;
871  $bookings[$i]['duration'] = $row->duration;
872  $bookings[$i]['duration_from'] = $row->duration_from;
873  $bookings[$i]['duration_until'] = $row->duration_until;
874  $bookings[$i]['price'] = $row->price;
875  $bookings[$i]['discount'] = $row->discount;
876  $bookings[$i]['payed'] = $row->payed;
877  $bookings[$i]['access'] = $row->access;
878  $bookings[$i]['ref_id'] = $row->ref_id;
879  $bookings[$i]['status'] = $row->status;
880  $bookings[$i]['pay_method'] = $row->pay_method;
881  $bookings[$i]['vendor_id'] = $row->vendor_id;
882  $bookings[$i]['b_vendor_id'] = $row->b_vendor_id;
883  $bookings[$i]['b_pay_method'] = $row->b_pay_method;
884  $bookings[$i]['voucher'] = $row->voucher;
885  $bookings[$i]['transaction_extern'] = $row->transaction_extern;
886  $bookings[$i]['price_type'] = $row->price_type;
887  $bookings[$i]['street'] = $row->street;
888  $bookings[$i]['po_box'] = $row->po_box;
889  $bookings[$i]['zipcode'] = $row->zipcode;
890  $bookings[$i]['city'] = $row->city;
891  $bookings[$i]['country'] = $row->country;
892  $bookings[$i]['vat_rate'] = $row->vatrate;
893  $bookings[$i]['vat_unit'] = $row->vat_unit;
894  $bookings[$i]['object_title'] = $row->object_title;
895  $i++;
896  }
897 
898  return $bookings;
899  }
900 
901  function getDistinctTransactions($a_usr_id)
902  {
903  global $ilDB;
904 
905  $query = 'SELECT * FROM payment_statistic
906  WHERE customer_id = %s
907  GROUP BY transaction
908  ORDER BY order_date DESC';
909 
910  $res = $ilDB->queryF($query, array('integer'), array($a_user_id));
911  while($row = $ilDB->fetchObject($res))
912  {
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;
942  }
943  return $booking ? $booking : array();
944  }
945 
947  {
948  global $ilDB;
949 
950  $res = $ilDB->queryF('
951  SELECT * FROM payment_statistic WHERE b_pay_method = %s', array('integer'), array($pay_method));
952  $i = 0;
953 
954  while($row = $ilDB->fetchObject($res))
955  {
956  $booking[$i]['booking_id'] = $row->booking_id;
957  $booking[$i]['pay_method'] = $row->b_pay_method;
958  $i++;
959  }
960  return $booking ? $booking : array();
961  }
962 
964  {
965  global $ilDB;
966 
967  $ilDB->manipulateF('
968  UPDATE payment_statistic
969  SET street = null,
970  po_box = null,
971  city = null,
972  zipcode = null,
973  country = null
974  WHERE b_pay_method = %s',
975  array('integer'),
976  array($pay_method));
977  }
978 
979 
980 }
981 ?>