ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPaymentStatisticGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 include_once './Services/Payment/classes/class.ilPaymentObject.php';
14 include_once './Services/Payment/classes/class.ilPayMethods.php';
15 include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
16 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
17 include_once './Services/Payment/classes/class.ilShopTableGUI.php';
18 include_once './Services/Payment/classes/class.ilInvoiceNumberPlaceholdersPropertyGUI.php';
19 
21 {
22  private $pobject = null;
23  public $booking_obj = null;
24 
25  public function __construct($user_obj)
26  {
28 
29  $this->ctrl->saveParameter($this, 'baseClass');
30 
31  $this->user_obj = $user_obj;
32  $this->pobject = new ilPaymentObject($this->user_obj);
33 
34  }
35 
36  protected function prepareOutput()
37  {
38  global $ilTabs;
39 
40  $this->setSection(6);
41 
43 
44  $ilTabs->setTabActive('paya_header');
45  $ilTabs->setSubTabActive('bookings');
46  }
47 
48  public function executeCommand()
49  {
50  $cmd = $this->ctrl->getCmd();
51 
52  switch ($this->ctrl->getNextClass($this))
53  {
54  default:
55  if(!$cmd = $this->ctrl->getCmd())
56  {
57  $cmd = 'showStatistics';
58  }
59  $this->prepareOutput();
60  $this->$cmd();
61  break;
62  }
63  }
64 
65  public function resetFilter()
66  {
67  unset($_SESSION["pay_statistics"]);
68  unset($_POST["transaction_type"]);
69  unset($_POST["transaction_value"]);
70  unset($_POST["from"]["day"]);
71  unset($_POST["from"]["month"]);
72  unset($_POST["from"]["year"]);
73  unset($_POST["til"]["day"]);
74  unset($_POST["til"]["month"]);
75  unset($_POST["til"]["year"]);
76  unset($_POST["payed"]);
77  unset($_POST["access"]);
78  unset($_POST["customer"]);
79  unset($_POST["pay_method"]);
80  unset($_POST["updateView"]);
81  unset($_POST["filter_title_id"]);
82 
83  $this->showStatistics();
84  }
85 
86  public function showStatistics()
87  {
88  global $rbacsystem, $ilToolbar, $ilObjDataCache;
89 
90  // MINIMUM ACCESS LEVEL = 'read'
91  /* if(!$rbacsystem->checkAccess('read', $this->getRefId()))
92  {
93  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
94  }
95  */
96 
97 
98  $ilToolbar->addButton($this->lng->txt('paya_add_customer'), $this->ctrl->getLinkTarget($this, 'showObjectSelector'));
99  if(!$_POST['show_filter'] && $_POST['updateView'] == '1')
100  {
101  $this->resetFilter();
102  }
103  else
104  if ($_POST['updateView'] == 1)
105  {
106  $_SESSION['pay_statistics']['show_filter']= $_POST['show_filter'];
107  $_SESSION['pay_statistics']['updateView'] = true;
108  $_SESSION['pay_statistics']['until_check'] = $_POST['until_check'];
109  $_SESSION['pay_statistics']['from_check'] = $_POST['from_check'];
110  $_SESSION['pay_statistics']['transaction_type'] = isset($_POST['transaction_type']) ? $_POST['transaction_type'] : '' ;
111  $_SESSION['pay_statistics']['transaction_value'] = isset($_POST['transaction_value']) ? $_POST['transaction_value'] : '';
112  $_SESSION['pay_statistics']['filter_title_id'] = (int)$_POST['filter_title_id'];
113 
114  if($_SESSION['pay_statistics']['from_check'] == '1')
115  {
116  $_SESSION['pay_statistics']['from']['date']['d'] = $_POST['from']['date']['d'];
117  $_SESSION['pay_statistics']['from']['date']['m'] = $_POST['from']['date']['m'];
118  $_SESSION['pay_statistics']['from']['date']['y'] = $_POST['from']['date']['y'];
119  }
120  else
121  {
122  $_SESSION['pay_statistics']['from']['date']['d'] = '';
123  $_SESSION['pay_statistics']['from']['date']['m'] = '';
124  $_SESSION['pay_statistics']['from']['date']['y'] = '';
125  }
126 
127  if($_SESSION['pay_statistics']['until_check']== '1')
128  {
129  $_SESSION['pay_statistics']['til']['date']['d'] = $_POST['til']['date']['d'];
130  $_SESSION['pay_statistics']['til']['date']['m'] = $_POST['til']['date']['m'];
131  $_SESSION['pay_statistics']['til']['date']['y'] = $_POST['til']['date']['y'];
132  }
133  else
134  {
135  $_SESSION['pay_statistics']['til']['date']['d'] = '';
136  $_SESSION['pay_statistics']['til']['date']['m'] = '';
137  $_SESSION['pay_statistics']['til']['date']['y'] = '';
138  }
139 
140  $_SESSION['pay_statistics']['payed'] = $_POST['payed'];
141  $_SESSION['pay_statistics']['access'] = $_POST['access'];
142  $_SESSION['pay_statistics']['pay_method'] = $_POST['pay_method'];
143  $_SESSION['pay_statistics']['customer'] = isset ($_POST['customer']) ? $_POST['customer'] : '';
144  $_SESSION['pay_statistics']['vendor'] = isset ($_POST['vendor']) ? $_POST['vendor']: '';
145  }
146 
147  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
148 
149  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
150  // FILTER FORM
151  $filter_form = new ilPropertyFormGUI();
152  $filter_form->setFormAction($this->ctrl->getFormAction($this));
153  $filter_form->setTitle($this->lng->txt('pay_filter'));
154  $filter_form->setId('formular');
155  $filter_form->setTableWidth('100 %');
156 
157 
158  $o_hide_check = new ilCheckBoxInputGUI($this->lng->txt('show_filter'),'show_filter');
159  $o_hide_check->setValue(1);
160  $o_hide_check->setChecked($_SESSION['pay_statistics']['show_filter'] ? 1 : 0);
161 
162  $o_hidden = new ilHiddenInputGUI('updateView');
163  $o_hidden->setValue(1);
164  $o_hidden->setPostVar('updateView');
165  $o_hide_check->addSubItem($o_hidden);
166 
167  $o_transaction_type = new ilSelectInputGUI();
168  $trans_option = array($this->lng->txt('pay_starting'),$this->lng->txt('pay_ending'));
169  $trans_value = array('0','1');
170  $o_transaction_type->setTitle($this->lng->txt('paya_transaction'));
171  $o_transaction_type->setOptions($trans_option);
172  $o_transaction_type->setValue($_SESSION['pay_statistics']['transaction_type']);
173  $o_transaction_type->setPostVar('transaction_type');
174  $o_hide_check->addSubItem($o_transaction_type);
175 
176  $o_transaction_val = new ilTextInputGUI();
177  $o_transaction_val->setValue($_SESSION['pay_statistics']['transaction_value']);
178  $o_transaction_val->setPostVar('transaction_value');
179  $o_hide_check->addSubItem($o_transaction_val);
180 
181  $o_customer = new ilTextInputGUI();
182  $o_customer->setTitle($this->lng->txt('paya_customer'));
183  $o_customer->setValue($_SESSION['pay_statistics']['customer']);
184  $o_customer->setPostVar('customer');
185  $o_hide_check->addSubItem($o_customer);
186 
187  $o_vendor = new ilTextInputGUI();
188  $o_vendor->setTitle($this->lng->txt('paya_vendor'));
189  $o_vendor->setValue($_SESSION['pay_statistics']['vendor']);
190  $o_vendor->setPostVar('vendor');
191  $o_hide_check->addSubItem($o_vendor);
192 
193  $o_from_check = new ilCheckBoxInputGUI($this->lng->txt('pay_order_date_from'),'from_check');
194  $o_from_check->setValue(1);
195  $o_from_check->setChecked($_SESSION['pay_statistics']['from_check'] ? 1 : 0);
196 
197  $o_date_from = new ilDateTimeInputGUI();
198  $o_date_from->setPostVar('from');
199  $_POST['from'] = $_SESSION['pay_statistics']['from'];
200 
201  if($_SESSION['pay_statistics']['from_check'] == '1')
202  {
203  $o_date_from->checkInput();
204  }
205 
206  $o_from_check->addSubItem($o_date_from);
207  $o_hide_check->addSubItem($o_from_check);
208 
209  $o_until_check = new ilCheckBoxInputGUI($this->lng->txt('pay_order_date_til'), 'until_check');
210  $o_until_check->setValue(1);
211  $o_until_check->setChecked($_SESSION['pay_statistics']['until_check'] ? 1 : 0);
212 
213  $o_date_until = new ilDateTimeInputGUI();
214  $o_date_until->setPostVar('til');
215  $_POST['til'] = $_SESSION['pay_statistics']['til'];
216 
217  if($_SESSION['pay_statistics']['until_check'] == '1')
218  {
219  $o_date_until->checkInput();
220  }
221 
222  $o_until_check->addSubItem($o_date_until);
223  $o_hide_check->addSubItem($o_until_check);
224 
225 
226  // title filter
227  $this->__initBookingObject();
228  $title_options['all']=$this->lng->txt('pay_all');
229  $unique_titles = $this->booking_obj->getUniqueTitles();
230 
231  if(is_array($unique_titles) && count($unique_titles))
232  {
233  foreach($unique_titles as $ref_id)
234  {
235  $title_options[$ref_id] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($ref_id));
236  }
237  }
238 
239  $o_object_title = new ilSelectInputGUI();
240  $o_object_title->setTitle($this->lng->txt('title'));
241  $o_object_title->setOptions($title_options);
242  $o_object_title->setValue($_SESSION["pay_statistics"]["filter_title_id"]);
243  $o_object_title->setPostVar('filter_title_id');
244  $o_hide_check->addSubItem($o_object_title);
245 
246  $o_payed = new ilSelectInputGUI();
247  $payed_option = array('all'=>$this->lng->txt('pay_all'),'1'=>$this->lng->txt('yes'),'0'=>$this->lng->txt('no'));
248 
249  $o_payed->setTitle($this->lng->txt('paya_payed'));
250  $o_payed->setOptions($payed_option);
251  $o_payed->setValue($_SESSION['pay_statistics']['payed']);
252  $o_payed->setPostVar('payed');
253 
254  $o_hide_check->addSubItem($o_payed);
255 
256  $o_access = new ilSelectInputGUI();
257  $access_option = array('all'=>$this->lng->txt('pay_all'),'1'=>$this->lng->txt('yes'),'0'=>$this->lng->txt('no'));
258 
259  $o_access->setTitle($this->lng->txt('paya_access'));
260  $o_access->setOptions($access_option);
261  $o_access->setValue($_SESSION['pay_statistics']['access']);
262  $o_access->setPostVar('access');
263  $o_hide_check->addSubItem($o_access);
264 
265  $o_paymethod = new ilSelectInputGUI();
266  $o_paymethod->setTitle($this->lng->txt('payment_system'));
267  $o_paymethod->setOptions(ilPayMethods::getPayMethodsOptions('all'));
268  $o_paymethod->setValue($_SESSION['pay_statistics']['pay_method']);
269  $o_paymethod->setPostVar('pay_method');
270  $o_hide_check->addSubItem($o_paymethod);
271 
272  $filter_form->addCommandButton('showStatistics', $this->lng->txt('pay_update_view'));
273  $filter_form->addCommandButton('resetFilter', $this->lng->txt('pay_reset_filter'));
274 
275  $filter_form->addItem($o_hide_check);
276 
277  $this->tpl->setVariable('FORM', $filter_form->getHTML());
278 
279 
280 // STATISTICS TABLE
281  $this->__initBookingObject();
282 
283  if(!count($bookings = $this->booking_obj->getBookings()))
284  {
285  ilUtil::sendInfo($this->lng->txt('paya_no_bookings'));
286 
287  return true;
288  }
289 # $this->__showButton('excelExport',$this->lng->txt('excel_export'));
290 
291  include_once 'Services/User/classes/class.ilObjUser.php';
292  $object_title_cache = array();
293  $user_title_cache = array();
294 
295  $counter = 0;
296  foreach($bookings as $booking)
297  {
298  if(array_key_exists($booking['ref_id'], $object_title_cache))
299  {
300  $tmp_obj = $object_title_cache[$booking['ref_id']];
301  }
302  else
303  {
304  $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($booking['ref_id']));
305  $object_title_cache[$booking['ref_id']] = $tmp_obj;
306  }
307  if(array_key_exists($booking['b_vendor_id'], $user_title_cache))
308  {
309  $tmp_vendor = $user_title_cache[$booking['b_vendor_id']];
310  }
311  else
312  {
313  $tmp_vendor = ilObjUser::_lookupLogin($booking['b_vendor_id']);
314  $user_title_cache[$booking['b_vendor_id']] = $tmp_vendor;
315  }
316  if(array_key_exists($booking['customer_id'], $user_title_cache))
317  {
318  $tmp_purchaser = $user_title_cache[$booking['customer_id']];
319  }
320  else
321  {
322  $tmp_purchaser = ilObjUser::_lookupLogin($booking['customer_id']);
323  $user_title_cache[$booking['customer_id']] = $tmp_purchaser;
324  }
325 
326  $transaction = $booking['transaction_extern'];
327  $str_paymethod = ilPayMethods::getStringByPaymethod($booking['b_pay_method']);
328  $transaction .= " (" . $str_paymethod . ")";
329 
330  $f_result[$counter]['transaction'] = $transaction;
331  $f_result[$counter]['object_title'] = ($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted'));
332  $f_result[$counter]['vendor'] = ($tmp_vendor != '' ? '['.$tmp_vendor.']' : $this->lng->txt('user_deleted'));
333  $f_result[$counter]['customer'] = ($tmp_purchaser != '' ? '['.$tmp_purchaser.']' : $this->lng->txt('user_deleted'));
334  $f_result[$counter]['order_date'] = ilDatePresentation::formatDate(new ilDateTime($booking['order_date'], IL_CAL_UNIX));
335 
336  if($booking['duration'] == 0)
337  {
338  $booking['duration'] = $this->lng->txt('unlimited_duration');
339  }
340 
341  $f_result[$counter]['duration'] = $booking['duration'];
342  $f_result[$counter]['price'] = ilFormat::_getLocalMoneyFormat($booking['price']).' '.$booking['currency_unit'];
343  $f_result[$counter]['discount'] = $booking['discount'].' '.$booking['currency_unit'];
344 
345  $payed_access = $booking['payed'] ?
346  $this->lng->txt('yes') :
347  $this->lng->txt('no');
348 
349  $payed_access .= '/';
350  $payed_access .= $booking['access_granted'] ?
351  $this->lng->txt('yes') :
352  $this->lng->txt('no');
353 
354  $f_result[$counter]['payed_access'] = $payed_access;
355 
356  $this->ctrl->setParameter($this,"booking_id",$booking['booking_id']);
357  $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editStatistic")."\">".$this->lng->txt("edit")."</a></div>";
358 
359  $f_result[$counter]['edit'] = $link_change;
360 
361  unset($tmp_obj);
362  unset($tmp_vendor);
363  unset($tmp_purchaser);
364 
365  ++$counter;
366  }
367  return $this->__showStatisticTable($f_result);
368  }
369 
370  public function excelExport()
371  {
372  include_once './Services/Payment/classes/class.ilPaymentExcelWriterAdapter.php';
373 
374  $pewa = new ilPaymentExcelWriterAdapter('payment_vendors.xls');
375 
376  // add/fill worksheet
377  $this->addStatisticWorksheet($pewa);
378 
379  // HEADER SENT
380 
381  $workbook = $pewa->getWorkbook();
382  @$workbook->close();
383  }
384 
385  public function addStatisticWorksheet($pewa)
386  {
387  include_once './Services/Payment/classes/class.ilPaymentVendors.php';
388 
389  $this->__initBookingObject();
390 
391  $workbook = $pewa->getWorkbook();
392  $worksheet = $workbook->addWorksheet($this->lng->txt('bookings'));
393 
394  $worksheet->mergeCells(0,0,0,8);
395  $worksheet->setColumn(0,0,16);
396  $worksheet->setColumn(0,1,32);
397  $worksheet->setColumn(0,2,32);
398  $worksheet->setColumn(0,3,16);
399  $worksheet->setColumn(0,4,16);
400  $worksheet->setColumn(0,5,16);
401  $worksheet->setColumn(0,6,24);
402  $worksheet->setColumn(0,7,8);
403  $worksheet->setColumn(0,8,12);
404  $worksheet->setColumn(0,9,16);
405 
406  $title = $this->lng->txt('bookings');
407  $title .= ' '.$this->lng->txt('as_of');
408  $title .= strftime('%Y-%m-%d %R',time());
409 
410  $worksheet->writeString(0,0,$title,$pewa->getFormatTitle());
411 
412  $worksheet->writeString(1,0,$this->lng->txt('payment_system'),$pewa->getFormatHeader());
413  $worksheet->writeString(1,1,$this->lng->txt('paya_transaction'),$pewa->getFormatHeader());
414  $worksheet->writeString(1,2,$this->lng->txt('title'),$pewa->getFormatHeader());
415  $worksheet->writeString(1,3,$this->lng->txt('paya_vendor'),$pewa->getFormatHeader());
416  $worksheet->writeString(1,4,$this->lng->txt('pays_cost_center'),$pewa->getFormatHeader());
417  $worksheet->writeString(1,5,$this->lng->txt('paya_customer'),$pewa->getFormatHeader());
418  $worksheet->writeString(1,6,$this->lng->txt('paya_order_date'),$pewa->getFormatHeader());
419  $worksheet->writeString(1,7,$this->lng->txt('duration'),$pewa->getFormatHeader());
420  $worksheet->writeString(1,8,$this->lng->txt('price_a'),$pewa->getFormatHeader());
421  $worksheet->writeString(1,9,$this->lng->txt('paya_payed_access'),$pewa->getFormatHeader());
422 
423  if(!count($bookings = $this->booking_obj->getBookings()))
424  {
425  return false;
426  }
427 
428  include_once 'Services/User/classes/class.ilObjUser.php';
429  $object_title_cache = array();
430  $user_title_cache = array();
431 
432  $counter = 2;
433  foreach($bookings as $booking)
434  {
435  if(array_key_exists($booking['ref_id'], $object_title_cache))
436  {
437  $tmp_obj = $object_title_cache[$booking['ref_id']];
438  }
439  else
440  {
441  $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($booking['ref_id']));
442  $object_title_cache[$booking['ref_id']] = $tmp_obj;
443  }
444  if(array_key_exists($booking['b_vendor_id'], $user_title_cache))
445  {
446  $tmp_vendor = $user_title_cache[$booking['b_vendor_id']];
447  }
448  else
449  {
450  $tmp_vendor = ilObjUser::_lookupLogin($booking['b_vendor_id']);
451  $user_title_cache[$booking['b_vendor_id']] = $tmp_vendor;
452  }
453  if(array_key_exists($booking['customer_id'], $user_title_cache))
454  {
455  $tmp_purchaser = $user_title_cache[$booking['customer_id']];
456  }
457  else
458  {
459  $tmp_purchaser = ilObjUser::_lookupLogin($booking['customer_id']);
460  $user_title_cache[$booking['customer_id']] = $tmp_purchaser;
461  }
462 
463  $pay_method = ilPayMethods::getStringByPaymethod($booking['b_pay_method']);
464 
465  $worksheet->writeString($counter,0,$pay_method);
466  $worksheet->writeString($counter,1,$booking['transaction_extern']);
467  $worksheet->writeString($counter,2,($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted')));
468  $worksheet->writeString($counter,3,($tmp_vendor != '' ? $tmp_vendor : $this->lng->txt('user_deleted')));
469  $worksheet->writeString($counter,4,ilPaymentVendors::_getCostCenter($booking['b_vendor_id']));
470  $worksheet->writeString($counter,5,($tmp_purchaser != '' ? $tmp_purchaser : $this->lng->txt('user_deleted')));
471  $worksheet->writeString($counter,6,strftime('%Y-%m-%d %R',$booking['order_date']));
472  $worksheet->writeString($counter,7,$booking['duration']);
473  $worksheet->writeString($counter,8,$booking['price']);
474 
475  $payed_access = $booking['payed'] ?
476  $this->lng->txt('yes') :
477  $this->lng->txt('no');
478 
479  $payed_access .= '/';
480  $payed_access .= $booking['access_granted'] ?
481  $this->lng->txt('yes') :
482  $this->lng->txt('no');
483 
484  $worksheet->writeString($counter,9,$payed_access);
485 
486  unset($tmp_obj);
487  unset($tmp_vendor);
488  unset($tmp_purchaser);
489 
490  ++$counter;
491  }
492  }
493 
494  public function editStatistic($a_show_confirm_delete = false)
495  {
496  global $ilToolbar;
497 
498  if(!isset($_GET['booking_id']))
499  {
500  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
501  $this->showStatistics();
502 
503  return true;
504  }
505 
506  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
507  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'showStatistics'));
508 
509  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
510 
511  $this->ctrl->setParameter($this,'booking_id',(int) $_GET['booking_id']);
512  $this->__initBookingObject();
513  $bookings = $this->booking_obj->getBookings();
514  $booking = $bookings[(int) $_GET['booking_id']];
515 
516  // confirm delete
517  if($a_show_confirm_delete)
518  {
519  $pobject_data = ilPaymentObject::_getObjectData($booking['pobject_id']);
520  $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($pobject_data['ref_id']));
521  $type = ilObject::_lookupType(ilObject::_lookupObjId($pobject_data['ref_id']));
522 
523  $oConfirmationGUI = new ilConfirmationGUI();
524 
525  // set confirm/cancel commands
526  $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this,"performDelete"));
527  $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_stat"));
528  $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "editStatistic");
529 
530  if($type == 'crs')
531  {
532  $oConfirmationGUI->addButton($this->lng->txt("confirm"), "performDeleteDeassignCrs");
533  }
534  else
535  $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDelete");
536 
537  $oConfirmationGUI->addItem('booking_id', $_GET['booking_id'], $tmp_obj);
538 
539  $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHTML());
540  return true;
541  }
542 
543 
544  // get customer_obj
545  $tmp_user = ilObjectFactory::getInstanceByObjId($booking['customer_id'], false);
546  $oForm = new ilPropertyFormGUI();
547  $oForm->setFormAction($this->ctrl->getFormAction($this));
548  $oForm->setId('stat_form');
549  $oForm->setTableWidth('50 %');
550  $oForm->setTitleIcon(ilUtil::getImagePath('icon_usr.png'));
551  if(is_object($tmp_user))
552  {
553  $frm_user = $tmp_user->getFullname().' ['.$tmp_user->getLogin().']';
554  }
555  else
556  {
557  $frm_user = $this->lng->txt('user_deleted');
558  }
559  $oForm->setTitle($frm_user);
560 
561  $pObj = new ilPaymentObject($this->user_obj, $booking['pobject_id']);
562  $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($pObj->getRefId()));
563 
564  // object_title
565  $oTitleGUI = new ilNonEditableValueGUI($this->lng->txt('title'));
566  $oTitleGUI->setValue($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted'));
567  $oForm->addItem($oTitleGUI);
568 
569  // transaction
570  $oTransactionGUI = new ilNonEditableValueGUI($this->lng->txt('paya_transaction'));
571  $oTransactionGUI->setValue($booking['transaction']);
572  $oForm->addItem($oTransactionGUI);
573 
574  //vendor
575  $oVendorGUI = new ilNonEditableValueGUI($this->lng->txt('paya_vendor'));
576  $tmp_vendor = ilObjectFactory::getInstanceByObjId($booking['b_vendor_id'], false);
577  if(is_object($tmp_vendor))
578  {
579  $frm_vendor = $tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']';
580  }
581  else
582  {
583  $frm_vendor = $this->lng->txt('user_deleted');
584  }
585  $oVendorGUI->setValue($frm_vendor);
586  $oForm->addItem($oVendorGUI);
587 
588  // paymethod
589  $oPaymethodGUI = new ilNonEditableValueGUI($this->lng->txt('paya_pay_method'));
590  $oPaymethodGUI->setValue(ilPayMethods::getStringByPaymethod($booking['b_pay_method']));
591  $oForm->addItem($oPaymethodGUI);
592 
593  // order_date
594  $oOrderdateGUI = new ilNonEditableValueGUI($this->lng->txt('paya_order_date'));
595  $oOrderdateGUI->setValue(ilDatePresentation::formatDate(new ilDateTime($booking["order_date"],IL_CAL_UNIX)));
596  $oForm->addItem($oOrderdateGUI);
597 
598  // duration
599  $oDurationGUI = new ilNonEditableValueGUI($this->lng->txt('duration'));
600  if(($booking['duration'] == 0) && ($booking['access_enddate'] == NULL))
601  {
602  $frm_duration = $this->lng->txt("unlimited_duration");
603  }
604  else
605  {
606  if($booking['duration'] > 0)
607  {
608  $frm_duration = $booking['duration'].' '.$this->lng->txt('paya_months');
609  }
610  $frm_duration .= ilDatePresentation::formatDate(new ilDate($booking['access_startdate'], IL_CAL_DATETIME))
611  .' - '.ilDatePresentation::formatDate(new ilDate($booking['access_enddate'], IL_CAL_DATETIME));
612  }
613  $oDurationGUI->setValue($frm_duration);
614  $oForm->addItem($oDurationGUI);
615 
616  // price
617  $oPriceGUI = new ilNonEditableValueGUI($this->lng->txt('price_a'));
618  $oPriceGUI->setValue($booking['price'].' '.$booking['currency_unit'] );
619  $oForm->addItem($oPriceGUI);
620 
621  // payed
622  $oPayedGUI = new ilSelectInputGUI();
623  $payed_option = array(0 => $this->lng->txt('no'),1 => $this->lng->txt('yes'));
624 
625  $oPayedGUI->setTitle($this->lng->txt('paya_payed'));
626  $oPayedGUI->setOptions($payed_option);
627  $oPayedGUI->setValue($booking['payed']);
628  $oPayedGUI->setPostVar('payed');
629  $oForm->addItem($oPayedGUI);
630 
631  // access
632  $oAccessGUI = new ilSelectInputGUI();
633  $access_option = array(0 => $this->lng->txt('no'),1 => $this->lng->txt('yes'));
634 
635  $oAccessGUI->setTitle($this->lng->txt('paya_access'));
636  $oAccessGUI->setOptions($access_option);
637  $oAccessGUI->setValue($booking['access_granted']);
638  $oAccessGUI->setPostVar('access');
639  $oForm->addItem($oAccessGUI);
640 
641  $oForm->addCommandButton('updateStatistic',$this->lng->txt('save'));
642  $oForm->addCommandButton('deleteStatistic',$this->lng->txt('delete'));
643 
644  $this->tpl->setVariable('FORM',$oForm->getHTML());
645 
646 
647 
648 /* //Same output as in ilobjpaymentsettingsgui->statistics
649  // show CUSTOMER_DATA if isset -> setting: save_user_address
650  if(ilPayMethods::isCustomerAddressEnabled($booking['b_pay_method']))
651  {
652  $oForm2 = new ilPropertyFormGUI();
653  $oForm2->setId('cust_form');
654  $oForm2->setTableWidth('50 %');
655  $oForm2->setTitle($frm_user);
656 
657  // email
658  $oEmailGUI = new ilNonEditableValueGUI($this->lng->txt('email'));
659  $email = (!isset($tmp_user)) ? $this->lng->txt('user_deleted') : $tmp_user->getEmail();
660  $oEmailGUI->setValue($email);
661  $oForm2->addItem($oEmailGUI);
662 
663  // street
664  $oStreetGUI = new ilNonEditableValueGUI($this->lng->txt('street'));
665  $oStreetGUI->setValue($booking['street']);
666  $oForm2->addItem($oStreetGUI);
667 
668  // pobox
669  $oPoBoxGUI = new ilNonEditableValueGUI($this->lng->txt('pay_bmf_po_box'));
670  $oPoBoxGUI->setValue($booking['po_box']);
671  $oForm2->addItem($oPoBoxGUI);
672 
673  // zipcode
674  $oPoBoxGUI = new ilNonEditableValueGUI($this->lng->txt('zipcode'));
675  $oPoBoxGUI->setValue($booking['zipcode']);
676  $oForm2->addItem($oPoBoxGUI);
677 
678  // city
679  $oCityGUI = new ilNonEditableValueGUI($this->lng->txt('city'));
680  $oCityGUI->setValue($booking['city']);
681  $oForm2->addItem($oCityGUI);
682 
683  // country
684  $oCountryGUI = new ilNonEditableValueGUI($this->lng->txt('country'));
685  $oCountryGUI->setValue($booking['country']);
686  $oForm2->addItem($oCountryGUI);
687  }
688 
689  $this->tpl->setVariable('FORM_2',$oForm2->getHTML());
690 */
691 
692  return true;
693  }
694 
695  public function updateStatistic()
696  {
697  if(!isset($_GET['booking_id']))
698  {
699  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
700  $this->showStatistics();
701 
702  return true;
703  }
704  $this->__initBookingObject();
705 
706  $this->booking_obj->setBookingId((int) $_GET['booking_id']);
707  $this->booking_obj->setAccess((int) $_POST['access']);
708  $this->booking_obj->setPayed((int) $_POST['payed']);
709 
710  if($this->booking_obj->update())
711  {
712  ilUtil::sendInfo($this->lng->txt('paya_updated_booking'));
713 
714  $this->showStatistics();
715  return true;
716  }
717  else
718  {
719  ilUtil::sendInfo($this->lng->txt('paya_error_update_booking'));
720  $this->showStatistics();
721 
722  return true;
723  }
724  }
725 
726  public function deleteStatistic()
727  {
728  if(!isset($_GET['booking_id']))
729  {
730  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
731  $this->showStatistics();
732 
733  return true;
734  }
735 
736  $this->editStatistic(true);
737 
738  return true;
739  }
740 
741  public function performDelete()
742  {
743  if(!isset($_GET['booking_id']))
744  {
745  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
746  $this->showStatistics();
747 
748  return true;
749  }
750 
751  $this->__initBookingObject();
752  $this->booking_obj->setBookingId((int) $_GET['booking_id']);
753  if(!$this->booking_obj->delete())
754  {
755  die('Error deleting booking');
756  }
757  ilUtil::sendInfo($this->lng->txt('pay_deleted_booking'));
758 
759  $this->showStatistics();
760 
761  return true;
762  }
763 
764  public function showObjectSelector()
765  {
766  global $tree, $ilToolbar;
767 
768  include_once './Services/Payment/classes/class.ilPaymentObjectSelector.php';
769 
770  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paya_object_selector.html",'Services/Payment');
771  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'showStatistics'));
772 
773  ilUtil::sendInfo($this->lng->txt("paya_select_object_to_sell"));
774 
775  $exp = new ilPaymentObjectSelector($this->ctrl->getLinkTarget($this,'showObjectSelector'), (string)strtolower(get_class($this)));
776  $exp->setExpand($_GET["paya_link_expand"] ? $_GET["paya_link_expand"] : $tree->readRootId());
777  $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showObjectSelector'));
778 
779  $exp->setOutput(0);
780 
781  $this->tpl->setVariable("EXPLORER",$exp->getOutput());
782 
783  return true;
784  }
785 
786  public function searchUser()
787  {
788  global $ilToolbar;
789 
790  if(!isset($_GET['sell_id']))
791  {
792  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
793  $this->showObjectSelector();
794 
795  return false;
796  }
797 
798  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
799 
800  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'showObjectSelector'));
801 
802  $this->lng->loadLanguageModule('search');
803  $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
804 
805  $form_gui = new ilPropertyFormGUI();
806  $form_gui->setFormAction($this->ctrl->getFormAction($this),'performSearch');
807  $form_gui->setTitle($this->lng->txt('grp_search_members'));
808  $form_gui->setId('search_form');
809 
810  $oTitle = new ilTextInputGUI($this->lng->txt('search_search_term'), 'search_str');
811  $oTitle->setMaxLength(255);
812  $oTitle->setSize(40);
813  $oTitle->setValue($_POST['search_str']);
814  $form_gui->addItem($oTitle);
815 
816  // buttons
817  $form_gui->addCommandButton('performSearch', $this->lng->txt('search'));
818  $form_gui->addCommandButton('showStatistics', $this->lng->txt('cancel'));
819 
820  $this->tpl->setVariable('FORM',$form_gui->getHTML());
821  return true;
822  }
823 
824  public function performSearch()
825  {
826  global $ilToolbar;
827  // SAVE it to allow sort in tables
828  $_SESSION["pays_search_str_user_sp"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["pays_search_str_user_sp"];
829 
830 
831  if(!trim($_POST["search_str"]))
832  {
833  ilUtil::sendInfo($this->lng->txt("search_no_search_term"));
834  $this->showStatistics();
835 
836  return false;
837  }
838  if(!count($result = $this->__search(ilUtil::stripSlashes($_POST["search_str"]))))
839  {
840  ilUtil::sendInfo($this->lng->txt("search_no_match"));
841  $this->searchUser();
842 
843  return false;
844  }
845 
846  if(!isset($_GET['sell_id']))
847  {
848  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
849  $this->showObjectSelector();
850 
851  return false;
852  }
853 
854  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.main_view.html",'Services/Payment');
855  $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
856 
857  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'searchUser'));
858 
859  $counter = 0;
860  $f_result = array();
861  foreach($result as $user)
862  {
863  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user["id"],false))
864  {
865  continue;
866  }
867  // $f_result[$counter]['user_id'] = ilUtil::formRadiobutton(0,"user_id",$user["id"]);
868  $f_result[$counter]['user_id'] = $user["id"];
869  $f_result[$counter]['login'] = $tmp_obj->getLogin();
870  $f_result[$counter]['firstname'] = $tmp_obj->getFirstname();
871  $f_result[$counter]['lastname'] = $tmp_obj->getLastname();
872 
873  unset($tmp_obj);
874  ++$counter;
875  }
876  $this->__showSearchUserTable($f_result);
877  }
878 
879  public function addCustomer()
880  {
881  global $ilToolbar,$ilCtrl;
882 
883  isset($_POST['sell_id']) ? $sell_id = $_POST['sell_id'] : $sell_id = $_GET['sell_id'];
884  isset($_POST['user_id']) ? $user_id = $_POST['user_id'] : $user_id = $_GET['user_id'];
885 
886  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.main_view.html",'Services/Payment');
887  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'searchUser'));
888  $ilCtrl->setParameter($this, "sell_id", $sell_id);
889  $ilCtrl->setParameter($this, "user_id", $user_id);
890 
891  $pObjectId = ilPaymentObject::_lookupPobjectId($sell_id);
892  $obj = new ilPaymentObject($this->user_obj, $pObjectId);
893 
894  // get obj
895  $tmp_obj = ilObjectFactory::getInstanceByRefId($sell_id, false);
896  if($tmp_obj)
897  {
898  $tmp_object['title'] = $tmp_obj->getTitle();
899  }
900  else
901  {
902  $tmp_object['title'] = $this->lng->txt('object_not_found');
903  }
904 
905  // get customer_obj
906  $tmp_user = ilObjectFactory::getInstanceByObjId($user_id);
907  // get vendor_obj
908  $tmp_vendor = ilObjectFactory::getInstanceByObjId($obj->getVendorId());
909 
910  $oForm = new ilPropertyFormGUI();
911  $oForm->setFormAction($ilCtrl->getFormAction($this, 'saveCustomer'));
912 
913  $oForm->setTitle($this->lng->txt($tmp_user->getFullname().' ['.$tmp_user->getLogin().']'));
914 
915  //transaction
916  $oTransaction = new ilTextInputGUI();
917  $oTransaction->setTitle($this->lng->txt('paya_transaction'));
918  $oTransaction->setValue(ilUtil::prepareFormOutput($_POST['transaction'], true));
919  $oTransaction->setPostVar('transaction');
920  $oForm->addItem($oTransaction);
921 
922  //object
923  $oObject = new ilNonEditableValueGUI($this->lng->txt('title'));
924  $oObject->setValue($tmp_obj->getTitle());
925  $oForm->addItem($oObject);
926 
927  //vendor
928  $oVendor = new ilNonEditableValueGUI($this->lng->txt('paya_vendor'));
929  $oVendor->setValue($tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']');
930  $oForm->addItem($oVendor);
931 
932  // pay methods
933  $oPayMethods = new ilSelectInputGUI($this->lng->txt('paya_pay_method'), 'pay_method');
934  $payOptions = ilPayMethods::getPayMethodsOptions(false);
935 
936  $oPayMethods->setOptions($payOptions);
937  $oPayMethods->setValue($_POST['pay_method']);
938  $oPayMethods->setPostVar('pay_method');
939  $oForm->addItem($oPayMethods);
940 
941  //duration
942  $duration_options = array();
943  $price_obj = new ilPaymentPrices($pObjectId);
944 
945  $standard_prices = array();
946  $extension_prices = array();
947  $standard_prices = $price_obj->getPrices();
948  $extension_prices = $price_obj->getExtensionPrices();
949 
950  $prices = array_merge($standard_prices, $extension_prices );
951 
952  if (is_array($prices))
953  {
955  $currency_unit = $genSet->get('currency_unit');
956 
957  foreach($prices as $price)
958  {
959  switch($price['price_type'])
960  {
962  $txt_duration =
963  $price['duration'].' '.$this->lng->txt('paya_months').' -> '.$price['price'].' '. $currency_unit;
964  break;
965 
967  include_once './Services/Calendar/classes/class.ilDatepresentation.php';
968  $txt_duration =
969  ilDatePresentation::formatDate(new ilDate($price['duration_from'], IL_CAL_DATE))
970  .' - '.ilDatePresentation::formatDate(new ilDate($price['duration_until'], IL_CAL_DATE))
971  ." -> ".ilPaymentPrices::_getPriceString($price["price_id"]) .' '.$currency_unit;
972  break;
973 
975  $txt_duration = $this->lng->txt('unlimited_duration').' -> '.$price['price'].' '. $currency_unit;
976  break;
977  }
978  $txt_extension = '';
979  if($price['extension'] == 1)
980  {
981  $txt_extension = ' ('.$this->lng->txt('extension_price').') ';
982  }
983  $duration_options[$price['price_id']] = $txt_duration.''.$txt_extension;
984  }
985  }
986 
987  $oDuration = new ilSelectInputGUI($this->lng->txt('duration'), 'duration');
988  $oDuration->setOptions($duration_options);
989  $oDuration->setValue($_POST['duration']);
990  $oForm->addItem($oDuration);
991 
992  //payed
993  $o_payed = new ilSelectInputGUI();
994  $payed_option = array('1'=>$this->lng->txt('yes'),'0'=>$this->lng->txt('no'));
995 
996  $o_payed->setTitle($this->lng->txt('paya_payed'));
997  $o_payed->setOptions($payed_option);
998  $o_payed->setValue($_POST['payed']);
999  $o_payed->setPostVar('payed');
1000  $oForm->addItem($o_payed);
1001 
1002  $o_access = new ilSelectInputGUI();
1003  $access_option = array('1'=>$this->lng->txt('yes'),'0'=>$this->lng->txt('no'));
1004 
1005  $o_access->setTitle($this->lng->txt('paya_access'));
1006  $o_access->setOptions($access_option);
1007  $o_access->setValue($_POST['access']);
1008  $o_access->setPostVar('access');
1009  $oForm->addItem($o_access);
1010 
1011  $oForm->addCommandButton('saveCustomer',$this->lng->txt('save'));
1012  $oForm->addCommandButton('showStatistics', $this->lng->txt('cancel'));
1013 
1014  $this->tpl->setVariable('FORM', $oForm->getHTML());
1015  }
1016 
1017  public function saveCustomer()
1018  {
1019  global $ilObjDataCache;
1020 
1021 
1022  if(!isset($_GET['sell_id']))
1023  {
1024  ilUtil::sendInfo($this->lng->txt('paya_error_no_object_id_given'));
1025  $this->showObjectSelector();
1026 
1027  return true;
1028  }
1029 
1030  if(!isset($_GET['user_id']))
1031  {
1032  ilUtil::sendInfo($this->lng->txt('paya_error_no_user_id_given'));
1033  $this->searchUser();
1034 
1035  return true;
1036  }
1037 
1038  if ($_POST["pay_method"] == "" ||
1039  $_POST["duration"] == "")
1040  {
1041  ilUtil::sendInfo($this->lng->txt('paya_error_mandatory_fields'));
1042  $this->addCustomer();
1043 
1044  return true;
1045  }
1046 
1047  $pObjectId = ilPaymentObject::_lookupPobjectId($_GET["sell_id"]);
1048  $obj = new ilPaymentObject($this->user_obj, $pObjectId);
1049 
1050  $this->__initBookingObject();
1052 
1053  $this->booking_obj->setTransaction($transaction);
1054  $this->booking_obj->setTransactionExtern($_POST["transaction"]);
1055  $this->booking_obj->setPobjectId($pObjectId);
1056  $this->booking_obj->setCustomerId($_GET["user_id"]);
1057  $this->booking_obj->setVendorId($obj->getVendorId());
1058  $this->booking_obj->setPayMethod((int) $_POST["pay_method"]);
1059  $this->booking_obj->setOrderDate(time());
1060 
1061  $price = ilPaymentPrices::_getPrice($_POST["duration"]);
1062 
1063  $this->booking_obj->setDuration($price["duration"]);
1064  $this->booking_obj->setAccessExtension($price['extension']);
1065 
1066  switch((int)$price['price_type'])
1067  {
1069  $this->booking_obj->setDuration(0);
1070  break;
1071 
1073  $this->booking_obj->setAccessStartdate($price['duration_from']);
1074  $this->booking_obj->setAccessEnddate($price['duration_until']);
1075  $this->booking_obj->setDuration(0);
1076  break;
1077 
1078  default:
1080  $this->booking_obj->setDuration($price["duration"]);
1081  break;
1082  }
1083 
1084  $this->booking_obj->setPriceType($price['price_type']);
1085  $this->booking_obj->setPrice(ilPaymentPrices::_getPriceString($_POST["duration"]));
1086 
1087  $this->booking_obj->setAccess((int) $_POST['access']);
1088  $this->booking_obj->setPayed((int) $_POST['payed']);
1089  $this->booking_obj->setVoucher('');
1090 
1091  $obj_id = $ilObjDataCache->lookupObjId($obj->getRefId());
1092  $obj_type = $ilObjDataCache->lookupType($obj_id);
1093  $obj_title = $ilObjDataCache->lookupTitle($obj_id);
1094 
1095  include_once 'Services/Payment/classes/class.ilShopVatsList.php';
1096  $oVAT = new ilShopVats((int)$obj->getVatId());
1097  $obj_vat_rate = $oVAT->getRate();
1098  $obj_vat_unit = $obj->getVat($this->booking_obj->getPrice());
1099 
1100  $this->booking_obj->setObjectTitle($obj_title);
1101  $this->booking_obj->setVatRate($obj_vat_rate);
1102  $this->booking_obj->setVatUnit($obj_vat_unit);
1103 
1104  include_once './Services/Payment/classes/class.ilPaymentSettings.php';
1105  $genSet = ilPaymentSettings::_getInstance();
1106  $this->booking_obj->setCurrencyUnit( $genSet->get('currency_unit'));
1107 
1108  include_once './Services/Payment/classes/class.ilPayMethods.php';
1109  if(ilPayMethods::_EnabledSaveUserAddress((int) $_POST["pay_method"]) == 1)
1110  {
1111 
1115  global $ilObjUser;
1116  $user_id[] = $_GET["user_id"];
1117 
1118  $cust_obj = ilObjUser::_readUsersProfileData($user_id);
1119 
1120  $this->booking_obj->setStreet($cust_obj[$_GET["user_id"]]['street'],'');
1121 
1122  $this->booking_obj->setZipcode($cust_obj[$_GET["user_id"]]['zipcode']);
1123  $this->booking_obj->setCity($cust_obj[$_GET["user_id"]]['city']);
1124  $this->booking_obj->setCountry($cust_obj[$_GET["user_id"]]['country']);
1125  }
1126 
1127  if($this->booking_obj->add())
1128  {
1129  // add purchased item to desktop
1130  ilShopUtils::_addPurchasedObjToDesktop($obj, $this->booking_obj->getCustomerId());
1131 
1132  // autosubscribe user if purchased object is a course
1133  if($obj_type == 'crs')
1134  {
1135  ilShopUtils::_assignPurchasedCourseMemberRole($obj, $this->booking_obj->getCustomerId());
1136  }
1137 
1138  ilUtil::sendInfo($this->lng->txt('paya_customer_added_successfully'));
1139  $this->showStatistics();
1140  }
1141  else
1142  {
1143  ilUtil::sendInfo($this->lng->txt('paya_error_adding_customer'));
1144  $this->addCustomer();
1145  }
1146 
1147  return true;
1148  }
1149 
1150  // PRIVATE
1151  public function __showStatisticTable($a_result_set)
1152  {
1153  $tbl = new ilShopTableGUI($this);
1154  $tbl->setTitle($this->lng->txt("bookings"));
1155  $tbl->setId('tbl_bookings');
1156  $tbl->setRowTemplate("tpl.shop_statistics_row.html", "Services/Payment");
1157 
1158  $tbl->addColumn($this->lng->txt('paya_transaction'), 'transaction', '10%');
1159  $tbl->addColumn($this->lng->txt('title'), 'object_title', '10%');
1160  $tbl->addColumn($this->lng->txt('paya_vendor'), 'vendor', '10%');
1161  $tbl->addColumn($this->lng->txt('paya_customer'), 'customer', '10%');
1162  $tbl->addColumn($this->lng->txt('paya_order_date'), 'order_date', '10%');
1163  $tbl->addColumn($this->lng->txt('duration'), 'duration', '10%');
1164  $tbl->addColumn($this->lng->txt('price_a'), 'price', '5%');
1165  $tbl->addColumn($this->lng->txt('paya_coupons_coupon'), 'discount', '5%');
1166  $tbl->addColumn($this->lng->txt('paya_payed_access'), 'payed_access', '5%');
1167  $tbl->addColumn($this->lng->txt('edit'), 'edit', '5%');
1168  $tbl->setData($a_result_set);
1169 
1170  $this->tpl->setVariable('TABLE', $tbl->getHTML());
1171 
1172  return true;
1173  }
1174 
1175  public function __initBookingObject()
1176  {
1177  include_once './Services/Payment/classes/class.ilPaymentBookings.php';
1178 
1179  $this->booking_obj = new ilPaymentBookings($this->user_obj->getId());
1180  }
1181 
1182  public function __search($a_search_string)
1183  {
1184  include_once("./Services/Search/classes/class.ilSearch.php");
1185 
1186  $this->lng->loadLanguageModule("content");
1187 
1188  $search = new ilSearch($this->user_obj->getId());
1189  $search->setPerformUpdate(false);
1190  $search->setSearchString(ilUtil::stripSlashes($a_search_string));
1191  $search->setCombination("and");
1192  $search->setSearchFor(array(0 => 'usr'));
1193  $search->setSearchType('new');
1194 
1195  if($search->validate($message))
1196  {
1197  $search->performSearch();
1198  }
1199  else
1200  {
1201  ilUtil::sendInfo($message,true);
1202  $this->ctrl->redirect($this,"searchUser");
1203  }
1204  return $search->getResultByType('usr');
1205  }
1206  public function __showSearchUserTable($a_result_set)
1207  {
1208  $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
1209 
1210  $tbl = new ilShopTableGUI($this);
1211  $tbl->setTitle($this->lng->txt("users"));
1212  $tbl->setId('tbl_users_search');
1213  $tbl->setRowTemplate("tpl.shop_users_row.html", "Services/Payment");
1214  $tbl->addColumn('', 'user_id', '1%', true);
1215  $tbl->addColumn($this->lng->txt('login'), 'login', '10%');
1216  $tbl->addColumn($this->lng->txt('firstname'), 'firstname', '10%');
1217  $tbl->addColumn($this->lng->txt('lastname'), 'lastname', '10%');
1218 
1219  $tbl->addMultiCommand('addCustomer', $this->lng->txt('add'));
1220  $tbl->setData($a_result_set);
1221 
1222  $this->tpl->setVariable('TABLE', $tbl->getHTML());
1223  return true;
1224  }
1225 
1226  public function performDeleteDeassignCrs()
1227  {
1228  include_once './Services/Payment/classes/class.ilShopUtils.php';
1229 
1230  if(!isset($_GET['booking_id']))
1231  {
1232  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
1233  $this->showStatistics();
1234 
1235  return true;
1236  }
1237 
1238  $this->__initBookingObject();
1239  $bookings = $this->booking_obj->getBookings();
1240  $booking = $bookings[(int) $_GET['booking_id']];
1241 
1242  $pobject_data = ilPaymentObject::_getObjectData($booking['pobject_id']);
1243  ilShopUtils::_deassignPurchasedCourseMemberRole($pobject_data['ref_id'], $booking['customer_id']);
1244 
1245  $this->booking_obj->setBookingId((int) $_GET['booking_id']);
1246  if(!$this->booking_obj->delete())
1247  {
1248  die('Error deleting booking');
1249  }
1250  ilUtil::sendInfo($this->lng->txt('pay_deleted_booking'));
1251 
1252  $this->showStatistics();
1253 
1254  return true;
1255  }
1256 }
1257 ?>