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