ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjPaymentSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
19 require_once './classes/class.ilObjectGUI.php';
20 include_once 'Services/Payment/classes/class.ilShopVatsList.php';
21 include_once './payment/classes/class.ilPaymentPrices.php';
22 
23 
25 {
26  var $user_obj = null;
27  var $pobject = null;
28 
29  var $section;
31 
36  function ilObjPaymentSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
37  {
38  global $ilias;
39 
40  $this->user_obj =& $ilias->account;
41 
42  include_once './payment/classes/class.ilPaymentObject.php';
43 
44  $this->pobject =& new ilPaymentObject($this->user_obj);
45 
46 
47  $this->type = 'pays';
48  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
49 
50  $this->SECTION_GENERAL = 1;
51  $this->SECTION_PAYPAL = 2;
52  $this->SECTION_EPAY = 12;
53  $this->SETTINGS = 3;
54  $this->OTHERS = 0;
55  $this->STATISTIC = 4;
56  $this->VENDORS = 5;
57  $this->PAY_METHODS = 6;
58  $this->OBJECTS = 7;
59  $this->SECTION_BMF = 8;
60  $this->TOPICS = 9;
61  $this->VATS = 10;
62  $this->SECTION_VATS = 11;
63  $this->SECTION_ERP = 13;
64 
65  $this->lng->loadLanguageModule('payment');
66  }
67 
68  function &executeCommand()
69  {
70  $next_class = $this->ctrl->getNextClass($this);
71  $cmd = $this->ctrl->getCmd();
72  $this->prepareOutput();
73 
74  switch($next_class)
75  {
76  case 'ilpermissiongui':
77  include_once('Services/AccessControl/classes/class.ilPermissionGUI.php');
78  $perm_gui =& new ilPermissionGUI($this);
79  $ret =& $this->ctrl->forwardCommand($perm_gui);
80  break;
81 
82  case 'ilpageobjectgui':
83  $this->prepareOutput();
84  $ret = $this->forwardToPageObject();
85  if($ret != '')
86  {
87  $this->tpl->setContent($ret);
88  }
89  break;
90 
91  case 'ilshoptopicsgui':
92  include_once 'Services/Payment/classes/class.ilShopTopicsGUI.php';
93  $topics_gui = new ilShopTopicsGUI($this);
94  $ret = $this->ctrl->forwardCommand($topics_gui);
95  break;
96 
97  default:
98  if ($cmd == '' || $cmd == 'view')
99  {
100  $cmd = 'generalSettings';
101  }
102 
103  switch ($cmd)
104  {
105  case 'vendors' :
106  case 'searchUser' :
107  case 'search' :
108  case 'performSearch' :
109  case 'addVendor' :
110  case 'exportVendors' :
111  case 'performDeleteVendors' :
112  case 'cancelDeleteVendors' :
113  case 'performEditVendor' : $this->__setSection($this->OTHERS);
114  $this->__setMainSection($this->STATISTIC);
115  $this->tabs_gui->setTabActive('vendors');
116  break;
117  case 'statistic' :
118  case 'editStatistic' :
119  case 'updateStatistic' :
120  case 'deleteStatistic' :
121  case 'performDelete' :
122  case 'resetFilter' :
123  case 'exportVendors' :
124  case 'addCustomer' :
125  case 'saveCustomer' :
126  case 'showObjectSelector' :
127  case 'searchUserSP' :
128  case 'performSearchSP' : $this->__setSection($this->OTHERS);
129  $this->__setMainSection($this->STATISTIC);
130  //$this->tabs_gui->setTabActive('statistic');
131  $this->tabs_gui->setTabActive('bookings');
132  break;
133  case 'updateObjectDetails' :
134  case 'deleteObject' :
135  case 'performObjectDelete' :
136  case 'objects' :
137  case 'editPrices' :
138  case 'addPrice' :
139  case 'editObject' :
140  case 'resetObjectFilter' :
141  include_once './payment/classes/class.ilPaymentObject.php';
142  include_once './payment/classes/class.ilPaymentBookings.php';
143  $this->__setSection($this->OTHERS);
144  $this->__setMainSection($this->OBJECTS);
145  $this->tabs_gui->setTabActive('objects');
146  break;
147  case 'saveGeneralSettings' :
148  case 'generalSettings' : $this->__setSection($this->SECTION_GENERAL);
149  $this->__setMainSection($this->SETTINGS);
150  $this->tabs_gui->setTabActive('settings');
151  break;
152  case 'saveBmfSettings' :
153  case 'bmfSettings' : $this->__setSection($this->SECTION_BMF);
154  $this->__setMainSection($this->SETTINGS);
155  $this->tabs_gui->setTabActive('settings');
156  break;
157  case 'savePaypalSettings' :
158  case 'paypalSettings' : $this->__setSection($this->SECTION_PAYPAL);
159  $this->__setMainSection($this->SETTINGS);
160  $this->tabs_gui->setTabActive('settings');
161  break;
162  case 'saveEPaySettings' :
163  case 'epaySettings' : $this->__setSection($this->SECTION_EPAY);
164  $this->__setMainSection($this->SETTINGS);
165  $this->tabs_gui->setTabActive('settings');
166  break;
167  case 'savePayMethods' : $this->__setSection($this->OTHERS);
168  $this->__setMainSection($this->PAY_METHODS);
169  $this->tabs_gui->setTabActive('pay_methods');
170  break;
171  case 'gateway' : if ($_POST['action'] == 'editVendorObject' ||
172  $_POST['action'] == 'deleteVendorsObject')
173  {
174  $this->__setSection($this->OTHERS);
175  $this->__setMainSection($this->STATISTIC);
176  $this->tabs_gui->setTabActive('vendors');
177  }
178  break;
179 
180 
181  case 'deleteVat' :
182  case 'newVat':
183  case 'insertVat':
184 
185  case 'updateVat':
186  case 'performDeleteVat':
187  case 'confirmDeleteVat':
188  case 'createVat':
189  case 'saveVat':
190  case 'editVat':
191  case 'vats' :
192  $this->__setSection($this->OTHERS);
193  $this->__setMainSection($this->VATS);
194  $this->tabs_gui->setTabActive('vats');
195  break;
196  case 'saveERPsettings' :
197  case 'delERPpreview':
198  case 'testERPsettings' :
199  case 'erpSettings' : $this->__setSection($this->SECTION_ERP);
200  $this->__setMainSection($this->SETTINGS);
201  $this->tabs_gui->setTabActive('settings');
202  break;
203 
204  default : $this->__setSection($this->OTHERS);
205  $this->__setMainSection($this->OTHERS);
206  break;
207  }
208  $cmd .= 'Object';
209 
210  $this->__buildSettingsButtons();
211 
212  $this->$cmd();
213 
214  break;
215  }
216  return true;
217  }
218 
219  public function forwardToPageObject()
220  {
221  global $ilTabs;
222 
223  if(!(int)$_GET['pobject_id'])
224  {
225  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
226  return $this->showObjects();
227  }
228  $this->ctrl->setParameter($this, 'pobject_id', (int)$_GET['pobject_id']);
229  $this->__initPaymentObject((int)$_GET['pobject_id']);
230 
231  $this->lng->loadLanguageModule('content');
232 
233  $ilTabs->clearTargets();
234  $ilTabs->clearSubTabs();
235  $ilTabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'editObject'));
236 
237  // page objec
238  include_once 'Services/COPage/classes/class.ilPageObject.php';
239  include_once 'Services/COPage/classes/class.ilPageObjectGUI.php';
240  include_once('./Services/Style/classes/class.ilObjStyleSheet.php');
241 
242  $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
243 
244  if(!ilPageObject::_exists('shop', $this->pobject->getPobjectId()))
245  {
246  // doesn't exist -> create new one
247  $new_page_object = new ilPageObject('shop');
248  $new_page_object->setParentId(0);
249  $new_page_object->setId($this->pobject->getPobjectId());
250  $new_page_object->createFromXML();
251  }
252 
253  $this->ctrl->setReturnByClass('ilpageobjectgui', 'edit');
254 
255  $page_gui = new ilPageObjectGUI('shop', $this->pobject->getPobjectId());
256  $this->ctrl->setParameter($page_gui, 'pobject_id', (int)$_GET['pobject_id']);
257  $page_gui->setIntLinkHelpDefault('StructureObject', $this->pobject->getPobjectId());
258  $page_gui->setTemplateTargetVar('ADM_CONTENT');
259  $page_gui->setLinkXML('');
260  $page_gui->setFileDownloadLink($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'downloadFile'));
261  $page_gui->setFullscreenLink($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'displayMediaFullscreen'));
262  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'download_paragraph'));
263  $page_gui->setPresentationTitle('');
264  $page_gui->setTemplateOutput(false);
265  $page_gui->setHeader('');
266  $page_gui->setEnabledRepositoryObjects(false);
267  $page_gui->setEnabledFileLists(true);
268  $page_gui->setEnabledMaps(true);
269  $page_gui->setEnabledPCTabs(true);
270 
271  return $this->ctrl->forwardCommand($page_gui);
272  }
273 
275  {
276  global $rbacsystem;
277 
278  // MINIMUM ACCESS LEVEL = 'read'
279  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
280  {
281  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
282  }
283 
284  include_once './payment/classes/class.ilBMFSettings.php';
285 
286  $this->error = '';
287 
288  $bmfSetObj = ilBMFSettings::getInstance();
289 
290  $bmfSetObj->setClientId(ilUtil::stripSlashes($_POST['mandantNr']));
291  $bmfSetObj->setBewirtschafterNr(ilUtil::stripSlashes($_POST['bewirtschafterNr']));
292  $bmfSetObj->setHaushaltsstelle(ilUtil::stripSlashes($_POST['haushaltsstelle']));
293  $bmfSetObj->setObjectId(ilUtil::stripSlashes($_POST['objektNr']));
294  $bmfSetObj->setKennzeichenMahnverfahren(ilUtil::stripSlashes($_POST['kennzeichenMahnverfahren']));
295  $bmfSetObj->setWaehrungsKennzeichen(ilUtil::stripSlashes($_POST['waehrungskennzeichen']));
296  $bmfSetObj->setEpaymentServer(ilUtil::stripSlashes($_POST['ePaymentServer']));
297  $bmfSetObj->setClientCertificate(ilUtil::stripSlashes($_POST['clientCertificate']));
298  $bmfSetObj->setCaCertificate(ilUtil::stripSlashes($_POST['caCertificate']));
299  $bmfSetObj->setTimeout(ilUtil::stripSlashes($_POST['timeOut']));
300 
301  if ($_POST['mandantNr'] == '' ||
302  $_POST['bewirtschafterNr'] == '' ||
303  $_POST['haushaltsstelle'] == '' ||
304  $_POST['objektNr'] == '' ||
305  $_POST['kennzeichenMahnverfahren'] == '' ||
306  $_POST['waehrungskennzeichen'] == '' ||
307  $_POST['ePaymentServer'] == '' ||
308  $_POST['clientCertificate'] == '' ||
309  $_POST['caCertificate'] == '' ||
310  $_POST['timeOut'] == '')
311  {
312  $this->error = $this->lng->txt('pays_bmf_settings_not_valid');
313  ilUtil::sendFailure($this->error);
314  $this->bmfSettingsObject();
315  return;
316  }
317 
318  $bmfSetObj->save();
319 
320  $this->bmfSettingsObject();
321 
322  ilUtil::sendSuccess($this->lng->txt('pays_updated_bmf_settings'));
323 
324  return true;
325  }
326 
327  function bmfSettingsObject()
328  {
329  global $rbacsystem;
330 
331  // MINIMUM ACCESS LEVEL = 'read'
332  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
333  {
334  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
335  }
336  include_once './payment/classes/class.ilBMFSettings.php';
337  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
338 
339  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.pays_bmf_settings.html','payment');
340 
341  $bmfSetObj = ilBMFSettings::getInstance();
342 
343  $form = new ilPropertyFormGUI();
344  $form->setFormAction($this->ctrl->getFormAction($this, 'saveBmfSettings'));
345  $form->setTitle($this->lng->txt('pays_bmf_settings'));
346 
347  $form->addCommandButton('saveBmfSettings',$this->lng->txt('save'));
348 
349  $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_client_id'), 'mandantNr');
350  $formItem->setValue($bmfSetObj->getClientId());
351  $form->addItem($formItem);
352 
353  $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_bewirtschafter_nr'), 'bewirtschafterNr');
354  $formItem->setValue($bmfSetObj->getBewirtschafterNr());
355  $form->addItem($formItem);
356 
357  $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_haushaltsstelle'), 'haushaltsstelle');
358  $formItem->setValue($bmfSetObj->getHaushaltsstelle());
359  $form->addItem($formItem);
360 
361  $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_object_id'), 'objektNr');
362  $formItem->setValue($bmfSetObj->getObjectId());
363  $form->addItem($formItem);
364 
365  $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_kennzeichen_mahnverfahren'), 'kennzeichenMahnverfahren');
366  $formItem->setValue($bmfSetObj->getKennzeichenMahnverfahren());
367  $form->addItem($formItem);
368 
369  $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_waehrungskennzeichen'), 'waehrungskennzeichen');
370  $formItem->setValue($bmfSetObj->getWaehrungsKennzeichen());
371  $form->addItem($formItem);
372 
373  $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_epayment_server'), 'ePaymentServer');
374  $formItem->setValue($bmfSetObj->getEpaymentServer());
375  $form->addItem($formItem);
376 
377  $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_client_certificate'), 'clientCertificate');
378  $formItem->setValue($bmfSetObj->getClientCertificate());
379  $form->addItem($formItem);
380 
381  $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_ca_certificate'), 'caCertificate');
382  $formItem->setValue($bmfSetObj->getCaCertificate());
383  $form->addItem($formItem);
384 
385  $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_timeout'), 'timeOut');
386  $formItem->setValue($bmfSetObj->getTimeOut());
387  $form->addItem($formItem);
388 
389  $this->tpl->setVariable('BMF_SETTINGS',$form->getHTML());
390  }
391 
393  {
394  if(!$_GET['pobject_id'])
395  {
396  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
397 
398  $this->objectObjects();
399  return true;
400  }
401 
402  $this->__initPaymentObject((int) $_GET['pobject_id']);
403  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
404 
405  // read old settings
406  $old_pay_method = $this->pobject->getPayMethod();
407  $old_status = $this->pobject->getStatus();
408  $old_vat_id = $this->pobject->getVatId();
409 
410  // check status changed from not_buyable
411  if($old_status == $this->pobject->STATUS_NOT_BUYABLE and
412  (int) $_POST['status'] != $old_status)
413  {
414  // check pay_method edited
415  switch((int) $_POST['pay_method'])
416  {
417  case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
418  ilUtil::sendInfo($this->lng->txt('paya_select_pay_method_first'));
419  $this->editObjectObject();
420 
421  return false;
422 
423  case $this->pobject->PAY_METHOD_BILL:
424  include_once './payment/classes/class.ilPaymentBillVendor.php';
425 
426  $bill_vendor =& new ilPaymentBillVendor((int) $_GET['pobject_id']);
427  if(!$bill_vendor->validate())
428  {
429  ilUtil::sendInfo($this->lng->txt('paya_select_pay_method_first'));
430  $this->editObjectObject();
431 
432  return false;
433  }
434  break;
435 
436  default:
437  ;
438  }
439  // check minimum one price
440  include_once './payment/classes/class.ilPaymentPrices.php';
441 
442  $prices_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
443  if(!count($prices_obj->getPrices()))
444  {
445  ilUtil::sendInfo($this->lng->txt('paya_edit_prices_first'));
446  $this->editObjectObject();
447 
448  return false;
449  }
450  }
451 
452 
453  $this->pobject->setStatus((int) $_POST['status']);
454  $this->pobject->setVendorId((int) $_POST['vendor']);
455  $this->pobject->setPayMethod((int) $_POST['pay_method']);
456  $this->pobject->setTopicId((int) $_POST['topic_id']);
457  $this->pobject->setVatId((int) $_POST['vat_id']);
458 
459  $this->pobject->update();
460 
461  ilUtil::sendInfo($this->lng->txt('paya_details_updated'));
462  $this->editObjectObject();
463 
464  return true;
465  }
466 
467  function editPricesObject($a_show_delete = false)
468  {
469  if($a_show_delete == false) unset($_SESSION['price_ids']);
470 
471  include_once './payment/classes/class.ilPaymentPrices.php';
472  include_once './payment/classes/class.ilPaymentCurrency.php';
473  include_once './Services/Table/classes/class.ilTableGUI.php';
474  include_once './payment/classes/class.ilGeneralSettings.php';
475 
476  $genSet = new ilGeneralSettings();
477 
478  $_SESSION['price_ids'] = $_SESSION['price_ids'] ? $_SESSION['price_ids'] : array();
479 
480  if(!$_GET['pobject_id'])
481  {
482  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
483 
484  $this->objectsObject();
485  return true;
486  }
487  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
488 
489 
490  $this->__showButton('objects',$this->lng->txt('back'));
491  $this->__showButton('editObject',$this->lng->txt('paya_edit_details'));
492  $this->__showButton('editPrices',$this->lng->txt('paya_edit_prices'));
493 
494  $this->__initPaymentObject((int) $_GET['pobject_id']);
495 
496  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_edit_prices.html','payment');
497 
498  $price_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
499  $prices = $price_obj->getPrices();
500 
501  // No prices created
502  if(!count($prices))
503  {
504  ilUtil::sendInfo($this->lng->txt('paya_no_price_available'));
505 
506  $this->tpl->setCurrentBlock('price_info');
507  $this->tpl->setVariable('CONFIRM_FORMACTION',$this->ctrl->getFormAction($this));
508  $this->tpl->setVariable('CONFIRM_CMD','addPrice');
509  $this->tpl->setVariable('TXT_CONFIRM',$this->lng->txt('paya_add_price'));
510  $this->tpl->parseCurrentBlock();
511 
512  return true;
513  }
514  // Show confirm delete
515  if($a_show_delete)
516  {
517  ilUtil::sendInfo($this->lng->txt('paya_sure_delete_selected_prices'));
518 
519  $this->tpl->setCurrentBlock('cancel');
520  $this->tpl->setVariable('CANCEL_CMD','editPrices');
521  $this->tpl->setVariable('TXT_CANCEL',$this->lng->txt('cancel'));
522  $this->tpl->parseCurrentBlock();
523 
524  $this->tpl->setCurrentBlock('price_info');
525  $this->tpl->setVariable('CONFIRM_FORMACTION',$this->ctrl->getFormAction($this));
526  $this->tpl->setVariable('CONFIRM_CMD','performDeletePrice');
527  $this->tpl->setVariable('TXT_CONFIRM',$this->lng->txt('paya_delete_price'));
528  $this->tpl->parseCurrentBlock();
529 
530  }
531 
532  // Fill table cells
533  $tpl =& new ilTemplate('tpl.table.html',true,true);
534 
535  // set table header
536  $tpl->setCurrentBlock('tbl_form_header');
537 
538  $tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
539  $tpl->parseCurrentBlock();
540 
541  $counter = 0;
542  foreach($prices as $price)
543  {
544  $currency = ilPaymentCurrency::_getCurrency($price['currency']);
545  if($a_show_delete == true )
546  {
547  $this->ctrl->setParameter($this, 'show_delete', 'true');
548 
549  if(in_array($price['price_id'],$_SESSION['price_ids']))
550  {
551 
552  $data[$counter]['price_id'] = '';
553  $data[$counter]['duration'] =$price['duration'] ;
554  $data[$counter]['month'] = $this->lng->txt('paya_months');
555 
556  $data[$counter]['unlimited_duration'] = ilUtil::formCheckBox($price['unlimited_duration'] ? 1 : 0,
557  'duration_ids[]', (int)$price['price_id']);
558 
559  $data[$counter]['price'] = ilFormat::_getLocalMoneyFormat($price['price']);
560  $data[$counter]['currency_unit'] = $genSet->get('currency_unit');
561  }
562  }
563  else
564  {
565  $data[$counter]['price_id'] = ilUtil::formCheckBox(in_array($price['price_id'],$_SESSION['price_ids']) ? 1 : 0,
566  'price_ids[]', $price['price_id']);
567 
568  $data[$counter]['duration'] = ilUtil::formInput('prices['.$price['price_id'].'][duration]',$price['duration']);
569  $data[$counter]['month'] = $this->lng->txt('paya_months');
570 
571  $data[$counter]['unlimited_duration'] = ilUtil::formCheckBox($price['unlimited_duration'] ? 1 : 0,
572  'duration_ids[]', (int)$price['price_id']);
573 
574  $data[$counter]['price'] = ilUtil::formInput('prices['.$price['price_id'].'][price]', ilFormat::_getLocalMoneyFormat($price['price']));
575  $data[$counter]['currency_unit'] = $genSet->get('currency_unit');
576  }
577  ++$counter;
578  }
579  $this->__editPricesTable($data);
580 
581  return true;
582  }
583 
584  function __editPricesTable($a_result_set)
585  {
586  $tpl =& new ilTemplate('tpl.table.html',true,true);
587 
588  $parmeter = $this->ctrl->getParameterArray($this, 'show_delete');
589 
590  if(!$parmeter['show_delete'])
591  {
592  // SET FOOTER
593  $tpl->setCurrentBlock("tbl_action_btn");
594  $tpl->setVariable("BTN_NAME","deletePrice");
595  $tpl->setVariable("BTN_VALUE",$this->lng->txt("paya_delete_price"));
596  $tpl->parseCurrentBlock();
597 
598  $tpl->setCurrentBlock("plain_buttons");
599  $tpl->setVariable("PBTN_NAME","addPrice");
600  $tpl->setVariable("PBTN_VALUE",$this->lng->txt("paya_add_price"));
601  $tpl->parseCurrentBlock();
602 
603  $tpl->setCurrentBlock("plain_buttons");
604  $tpl->setVariable("PBTN_NAME","updatePrice");
605  $tpl->setVariable("PBTN_VALUE",$this->lng->txt("paya_update_price"));
606  $tpl->parseCurrentBlock();
607 
608  $tpl->setCurrentBlock("tbl_action_row");
609  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
610  $tpl->setVariable("COLUMN_COUNTS",6);
611  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
612  $tpl->parseCurrentBlock();
613  }
614  $tbl = new ilTableGUI();
615  $tbl->setTemplate($tpl);
616 
617  // SET FORMAACTION
618  $tpl->setCurrentBlock("tbl_form_header");
619  $this->ctrl->setParameter($this, 'cmd', 'editprices');
620 
621  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
622  $tpl->parseCurrentBlock();
623 
624  $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
625  if(is_object($tmp_obj))
626  {
627  $tbl->setTitle($tmp_obj->getTitle(),
628  'icon_'.$tmp_obj->getType().'_b.gif',
629  $this->lng->txt('objs_'.$tmp_obj->getType()));
630  }
631  else
632  {
633  $tbl->setTitle($this->lng->txt('object_not_found'));
634  }
635  $tbl->setHeaderNames(array( '',
636  $this->lng->txt("duration"),
637  '',
638  $this->lng->txt("unlimited_duration"),
639  $this->lng->txt("price_a"),
640  ''),
641  '');
642  $header_params = $this->ctrl->getParameterArray($this,'');
643  $tbl->setHeaderVars(array( "price_id",
644  "duration",
645  "month",
646  "unlimited_duration",
647  "price",
648  "currency_unit",
649  "options"),$header_params);
650  $tbl->setColumnWidth(array('5%', "10%","10%","15%","15%","50%"));
651 
652  $offset = $_GET["offset"];
653  if($_GET["sort_by"] == NULL) $order = 'duration';
654  else $order = $_GET["sort_by"];
655  $direction = $_GET["sort_order"];
656 
657  $tbl->setOrderColumn($order);
658  $tbl->setOrderDirection($direction);
659  $tbl->setOffset($offset);
660  $tbl->setLimit($_GET["limit"]);
661  $tbl->setMaxCount(count($a_result_set));
662  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
663  $tbl->setData($a_result_set);
664 
665  $tbl->render();
666 
667  $this->tpl->setVariable("PRICES_TABLE",$tbl->tpl->get());
668 
669  return true;
670 
671  }
672 
673  function addPriceObject()
674  {
675  if(!$_GET['pobject_id'])
676  {
677  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
678 
679  $this->showObjects();
680  return true;
681  }
682 
683  include_once './payment/classes/class.ilGeneralSettings.php';
684 
685  $genSet = new ilGeneralSettings();
686 
687  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
688 
689  $this->__initPaymentObject((int) $_GET['pobject_id']);
690 
691  $this->__showButton('editObject',$this->lng->txt('paya_edit_details'));
692  $this->__showButton('editPrices',$this->lng->txt('paya_edit_prices'));
693 
694  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_add_price.html','payment');
695 
696  $this->tpl->setVariable('ADD_FORMACTION',$this->ctrl->getFormAction($this));
697 
698  $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
699  if(is_object($tmp_obj))
700  {
701  $tmp_object['title'] = $tmp_obj->getTitle();
702  $tmp_object['type'] = $tmp_obj->getType();
703  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$tmp_object['type'].'_b.gif'));
704  $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_'.$tmp_object['type']));
705  }
706  else
707  {
708  $tmp_object['title'] = $this->lng->txt('object_not_found');
709  $tmp_object['type'] = '';
710  }
711 
712 
713  $this->tpl->setVariable('TITLE', $tmp_object['title']);
714  $this->tpl->setVariable('DESCRIPTION',$this->lng->txt('paya_add_price_title'));
715 
716  // TODO show curency selector
717 # $this->tpl->setVariable('TXT_PRICE_A',$this->lng->txt('currency_euro'));
718 # $this->tpl->setVariable('TXT_PRICE_B',$this->lng->txt('currency_cent'));
719  $this->tpl->setVariable('TXT_PRICE_A',$genSet->get('currency_unit'));
720 
721  $this->tpl->setVariable('MONTH',$this->lng->txt('paya_months'));
722  $this->tpl->setVariable('TXT_DURATION',$this->lng->txt('duration'));
723  $this->tpl->setVariable('TXT_UNLIMITED_DURATION',$this->lng->txt('unlimited_duration'));
724  $this->tpl->setVariable('TXT_PRICE',$this->lng->txt('price_a'));
725  $this->tpl->setVariable('CANCEL',$this->lng->txt('cancel'));
726  $this->tpl->setVariable('ADD',$this->lng->txt('paya_add_price'));
727 
728  $this->tpl->setVariable('DURATION',$_POST['duration']);
729  $this->tpl->setVariable('UNLIMITED_DURATION',$_POST['unlimited_duration']);
730 
731  $this->tpl->setVariable('PRICE',$_POST['price']);
732 
733  return true;
734  }
735 
737  {
738  if(!$_GET['pobject_id'])
739  {
740  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
741 
742  $this->objectsObject();
743  return true;
744  }
745 
746  include_once './payment/classes/class.ilPaymentPrices.php';
747  include_once './payment/classes/class.ilPaymentCurrency.php';
748 
750 
751  $prices =& new ilPaymentPrices((int) $_GET['pobject_id']);
752 
753  $prices->setUnlimitedDuration((int)$_POST['unlimited_duration']);
754 
755  if($_POST['unlimited_duration'] == '1')
756  {
757  $prices->setUnlimitedDuration(1);
758  }
759 
760  $prices->setDuration($_POST['duration']);
761  $prices->setPrice($_POST['price']);
762  $prices->setCurrency($currency[1]['currency_id']);
763 
764  if(!$prices->validate())
765  {
766  ilUtil::sendInfo($this->lng->txt('paya_price_not_valid'));
767  $this->addPriceObject();
768 
769  return true;
770  }
771  $prices->add();
772 
773  ilUtil::sendInfo($this->lng->txt('paya_added_new_price'));
774  $this->editPricesObject();
775 
776  return true;
777  }
778 
780  {
781  if(!$_GET['pobject_id'])
782  {
783  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
784 
785  $this->objectsObject();
786  return true;
787  }
788 
789  if(!count($_SESSION['price_ids']))
790  {
791  ilUtil::sendInfo($this->lng->txt('paya_no_prices_selected'));
792 
793  $this->editPricesObject();
794  return true;
795  }
796  include_once './payment/classes/class.ilPaymentPrices.php';
797 
798  $prices =& new ilPaymentPrices((int) $_GET['pobject_id']);
799 
800  foreach($_SESSION['price_ids'] as $price_id)
801  {
802  if($prices->delete($price_id))
803  ilUtil::sendInfo($this->lng->txt('paya_deleted_selected_prices'));
804 
805  }
806 
807  // check if it was last price otherwise set status to 'not_buyable'
808  if(!count($prices->getPrices()))
809  {
810  $this->__initPaymentObject((int) $_GET['pobject_id']);
811 
812  $this->pobject->setStatus($this->pobject->STATUS_NOT_BUYABLE);
813  $this->pobject->update();
814 
815  ilUtil::sendInfo($this->lng->txt('paya_deleted_last_price'));
816  }
817  unset($prices);
818  unset($_SESSION['price_ids']);
819 
820  return $this->editPricesObject();
821  }
822 
823  function deletePriceObject()
824  {
825  if(!$_GET['pobject_id'])
826  {
827  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
828 
829  $this->objectsObject();
830  return true;
831  }
832 
833  if(!count($_POST['price_ids']))
834  {
835  ilUtil::sendInfo($this->lng->txt('paya_no_prices_selected'));
836 
837  $this->editPricesObject();
838  return true;
839  }
840  $_SESSION['price_ids'] = $_POST['price_ids'];
841 
842  $this->editPricesObject(true);
843  return true;
844  }
845 
846  function updatePriceObject()
847  {
848  include_once './payment/classes/class.ilPaymentPrices.php';
849 
850  if(!$_GET['pobject_id'])
851  {
852  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
853 
854  $this->objectsObject();
855  return true;
856  }
857  $po =& new ilPaymentPrices((int) $_GET['pobject_id']);
858 
859  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
860 
861  // validate
862  foreach($_POST['prices'] as $price_id => $price)
863  {
864 
865  $old_price = $po->getPrice($price_id);
866 
867  $po->setDuration($price['duration']);
868 
869  $po->setPrice($price['price']);
870 
871  $po->setCurrency($old_price['currency']);
872 
873  if(!$po->validate())
874  {
875  $error = true;
876  }
877  }
878  if($error)
879  {
880  ilUtil::sendInfo($this->lng->txt('paya_insert_only_numbers'));
881 
882  $this->editPricesObject();
883  return false;
884  }
885 
886 
887  foreach($_POST['prices'] as $price_id => $price)
888  {
889  $old_price = $po->getPrice($price_id);
890 
891  if(isset($_POST['duration_ids']))
892  {
893 
894  $search = in_array((string)$price_id, $_POST['duration_ids']);
895 
896  //$po->setUnlimitedDuration($price['unlimited_duration']); //$_POST['duration_ids'] != NULL &&
897  if($_POST['duration_ids'] == NULL)
898  {
899  $po->setUnlimitedDuration(0);
900  $po->setDuration($price['duration']);
901 
902  }
903 
904  else if( $search = in_array((string)$price_id, $_POST['duration_ids']))
905  {
906  $po->setUnlimitedDuration(1);
907  $po->setDuration(0);
908  }
909  else
910  {
911  $po->setUnlimitedDuration(0);
912  }
913  }
914 
915  $po->setDuration($price['duration']);
916  $po->setPrice($price['price']);
917  $po->setCurrency($old_price['currency']);
918 
919  $po->update($price_id);
920  }
921  ilUtil::sendSuccess($this->lng->txt('paya_updated_prices'));
922  $this->editPricesObject();
923 
924  return true;
925  }
926 
927  function editObjectObject($a_show_confirm = false)
928  {
929 
930  if(!isset($_GET['pobject_id']))
931  {
932  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
933  $this->objectsObject();
934 
935  return true;
936  }
937 
938  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
939 
940  $this->__showButton('objects',$this->lng->txt('back'));
941  $this->__showButton('editObject',$this->lng->txt('paya_edit_details'));
942  $this->__showButton('editPrices',$this->lng->txt('paya_edit_prices'));
943  $this->tpl->setCurrentBlock('btn_cell');
944  $this->tpl->setVariable('BTN_LINK', $this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'edit'));
945  $this->tpl->setVariable('BTN_TXT', $this->lng->txt('pay_edit_abstract'));
946  $this->tpl->parseCurrentBlock();
947 
948  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_edit_objects.html','payment');
949 
950  $this->__initPaymentObject((int) $_GET['pobject_id']);
951 
952  if($a_show_confirm)
953  {
954  $this->tpl->setCurrentBlock('confirm_delete');
955  $this->tpl->setVariable('CONFIRM_FORMACTION',$this->ctrl->getFormAction($this));
956  $this->tpl->setVariable('TXT_CANCEL',$this->lng->txt('cancel'));
957  $this->tpl->setVariable('CONFIRM_CMD','performObjectDelete');
958  $this->tpl->setVariable('TXT_CONFIRM',$this->lng->txt('confirm'));
959  $this->tpl->parseCurrentBlock();
960  }
961 
962  $this->tpl->setVariable("DETAILS_FORMACTION",$this->ctrl->getFormAction($this));
963 
964 
965  $tmp_obj = ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
966 
967  if(is_object($tmp_obj))
968  {
969  $tmp_object['type'] = $tmp_obj->getType();
970  $tmp_object['title'] = $tmp_obj->getTitle();
971  $tmp_object['description'] = $tmp_obj->getDescription();
972  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$tmp_object['type'].'_b.gif'));
973  $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_'.$tmp_object['type']));
974  }
975  else
976  {
977  $tmp_object['type'] = '';
978  $tmp_object['title'] = $this->lng->txt('object_not_found');
979  $tmp_object['description'] = $this->lng->txt('object_not_found');
980  }
981 
982 
983  $this->tpl->setVariable('TITLE',$tmp_object['title']);
984  $this->tpl->setVariable('DESCRIPTION',$tmp_object['description']);
985  $this->tpl->setVariable('TXT_PATH',$this->lng->txt('path'));
986  $this->tpl->setVariable('PATH',$this->__getHTMLPath($this->pobject->getRefId()));
987  $this->tpl->setVariable('TXT_VENDOR',$this->lng->txt('paya_vendor'));
988  $this->tpl->setVariable('VENDOR',$this->__showVendorSelector($this->pobject->getVendorId()));
989  $this->tpl->setVariable('TXT_COUNT_PURCHASER',$this->lng->txt('paya_count_purchaser'));
990  $this->tpl->setVariable('COUNT_PURCHASER',ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']));
991  $this->tpl->setVariable('TXT_STATUS',$this->lng->txt('status'));
992  $this->tpl->setVariable('STATUS',$this->__showStatusSelector());
993  $this->tpl->setVariable('TXT_PAY_METHOD',$this->lng->txt('paya_pay_method'));
994  $this->tpl->setVariable('PAY_METHOD',$this->__showPayMethodSelector());
995 
996  // topics
997  include_once 'Services/Payment/classes/class.ilShopTopics.php';
998  ilShopTopics::_getInstance()->read();
999  if (is_array($topics = ilShopTopics::_getInstance()->getTopics()) && count($topics))
1000  {
1001  $selectable_topics = array();
1002  $selectable_topics[''] = $this->lng->txt('please_choose');
1003  foreach ($topics as $topic)
1004  {
1005  $selectable_topics[$topic->getId()] = $topic->getTitle();
1006  }
1007 
1008  $this->tpl->setVariable('TXT_TOPIC', $this->lng->txt('topic'));
1009  $this->tpl->setVariable('TOPICS', ilUtil::formSelect(array($this->pobject->getTopicId()), 'topic_id', $selectable_topics, false, true));
1010  }
1011 
1012  // vats
1013  $oShopVatsList = new ilShopVatsList();
1014  $oShopVatsList->read();
1015 
1016  $selectable_vats = array();
1017  $selectable_vats[-1] = '----';
1018  if($oShopVatsList->hasItems())
1019  {
1020  foreach($oShopVatsList as $oVAT)
1021  {
1022  $selectable_vats[$oVAT->getId()] = ilShopUtils::_formatVAT($oVAT->getRate()).' -> '.$oVAT->getTitle();
1023  }
1024  }
1025 
1026  try
1027  {
1028  $oVAT = new ilShopVats((int)$this->pobject->getVatId());
1029  $this->tpl->setVariable('VAT', ilUtil::formSelect($oVAT->getId(), 'vat_id', $selectable_vats, false, true));
1030  }
1031  catch(ilShopException $e)
1032  {
1033  $this->tpl->setVariable('VAT', ilUtil::formSelect(-1, 'vat_id', $selectable_vats, false, true));
1034  }
1035  $this->tpl->setVariable('TXT_VAT', $this->lng->txt('vats'));
1036 
1037  $this->tpl->setVariable('INPUT_CMD','updateObjectDetails');
1038  $this->tpl->setVariable('INPUT_VALUE',$this->lng->txt('save'));
1039 
1040  $this->tpl->setVariable('DELETE_CMD','deleteObject');
1041  $this->tpl->setVariable('DELETE_VALUE',$this->lng->txt('delete'));
1042 
1043  }
1044 
1046  {
1047  include_once './payment/classes/class.ilPaymentBookings.php';
1048 
1049  if(!$_GET['pobject_id'])
1050  {
1051  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
1052 
1053  $this->editObjectObject();
1054  return true;
1055  }
1056  if(ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']))
1057  {
1058  ilUtil::sendInfo($this->lng->txt('paya_bookings_available'));
1059  $this->editObjectObject();
1060 
1061  return false;
1062  }
1063  else
1064  {
1065  ilUtil::sendQuestion($this->lng->txt('paya_sure_delete_object'));
1066  $this->editObjectObject(true);
1067 
1068  return true;
1069  }
1070  }
1071 
1073  {
1074  include_once './payment/classes/class.ilPaymentPrices.php';
1075  include_once './payment/classes/class.ilPaymentBillVendor.php';
1076 
1077  if(!$_GET['pobject_id'])
1078  {
1079  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
1080 
1081  $this->objectsObject();
1082  return true;
1083  }
1084  $this->__initPaymentObject((int) $_GET['pobject_id']);
1085 
1086  // delete object data
1087  $this->pobject->delete();
1088 
1089  // delete payment prices
1090  $price_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
1091  $price_obj->deleteAllPrices();
1092  unset($price_obj);
1093 
1094  $bv =& new ilPaymentBillVendor((int) $_GET['pobject_id']);
1095  $bv->delete();
1096  unset($bv);
1097 
1098  // delete bill vendor data if exists
1099  ilUtil::sendInfo($this->lng->txt('paya_deleted_object'));
1100 
1101  $this->objectsObject();
1102 
1103  return true;
1104  }
1105 
1106  function __getHTMLPath($a_ref_id)
1107  {
1108  global $tree;
1109 
1110  $path = $tree->getPathFull($a_ref_id);
1111  unset($path[0]);
1112 
1113  if($path)
1114  {
1115  foreach($path as $data)
1116  {
1117  $html .= $data['title'].' > ';
1118  }
1119  return substr($html,0,-2);
1120  }
1121  else
1122  {
1123  global $lng;
1124  return $lng->txt('object_not_found');
1125  }
1126  }
1127 
1128  function __showVendorSelector($a_selected = 0)
1129  {
1130  include_once './payment/classes/class.ilPaymentVendors.php';
1131 
1132  $vendors = array();
1133 
1134  $vendor_obj = new ilPaymentVendors();
1135  $all_vendors = $vendor_obj->getVendors();
1136  if (is_array($all_vendors))
1137  {
1138  foreach ($all_vendors as $vendor)
1139  {
1140  $vendors[] = $vendor['vendor_id'];
1141  }
1142  }
1143 
1144  foreach($vendors as $vendor)
1145  {
1146  $tmp_obj =& ilObjectFactory::getInstanceByObjId($vendor,false);
1147 
1148  $action[$vendor] = $tmp_obj->getFullname().' ['.$tmp_obj->getLogin().']';
1149  }
1150 
1151  return ilUtil::formSelect($a_selected,'vendor',$action,false,true);
1152  }
1153 
1155  {
1156  $action = array();
1157  $action[$this->pobject->STATUS_NOT_BUYABLE] = $this->lng->txt('paya_not_buyable');
1158  $action[$this->pobject->STATUS_BUYABLE] = $this->lng->txt('paya_buyable');
1159  $action[$this->pobject->STATUS_EXPIRES] = $this->lng->txt('paya_expires');
1160 
1161  return ilUtil::formSelect($this->pobject->getStatus(),'status',$action,false,true);
1162  }
1163 
1165  {
1166  include_once './payment/classes/class.ilPayMethods.php';
1167 
1168  $action = array();
1169 
1170  $action[$this->pobject->PAY_METHOD_NOT_SPECIFIED] = $this->lng->txt('paya_pay_method_not_specified');
1171  if(ilPayMethods::_enabled('pm_bill'))
1172  {
1173  $action[$this->pobject->PAY_METHOD_BILL] = $this->lng->txt('pays_bill');
1174  }
1175  if(ilPayMethods::_enabled('pm_bmf'))
1176  {
1177  $action[$this->pobject->PAY_METHOD_BMF] = $this->lng->txt('pays_bmf');
1178  }
1179  if(ilPayMethods::_enabled('pm_paypal'))
1180  {
1181  $action[$this->pobject->PAY_METHOD_PAYPAL] = $this->lng->txt('pays_paypal');
1182  }
1183  if(ilPayMethods::_enabled('pm_epay'))
1184  {
1185  $action[$this->pobject->PAY_METHOD_EPAY] = $this->lng->txt('pays_epay');
1186  }
1187 
1188  return ilUtil::formSelect($this->pobject->getPayMethod(),'pay_method',$action,false,true);
1189  }
1190 
1192  {
1193  unset($_SESSION['pay_statistics']);
1194  unset($_POST['title_type']);
1195  unset($_POST['title_value']);
1196  unset($_POST['vendor']);
1197  unset($_POST['pay_method']);
1198 
1199  ilUtil::sendInfo($this->lng->txt('paya_filter_reseted'));
1200 
1201  return $this->objectsObject();
1202  }
1203 
1204  function objectsObject()
1205  {
1206  global $rbacsystem;
1207 
1208  // MINIMUM ACCESS LEVEL = 'read'
1209  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
1210  {
1211  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
1212  }
1213 
1214  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_objects.html','payment');
1215 
1216  if ($_POST['updateView'] == 1)
1217  {
1218  $_SESSION['pay_objects']['title_type'] = $_POST['title_type'];
1219  $_SESSION['pay_objects']['title_value'] = $_POST['title_value'];
1220  $_SESSION['pay_objects']['pay_method'] = $_POST['pay_method'];
1221  $_SESSION['pay_objects']['vendor'] = $_POST['vendor'];
1222  }
1223 
1224  $this->__initPaymentObject();
1225  $this->lng->loadLanguageModule('search');
1226  $this->tpl->setVariable('TXT_FILTER',$this->lng->txt('pay_filter'));
1227  $this->tpl->setVariable('FORM_ACTION',$this->ctrl->getFormAction($this));
1228  $this->tpl->setVariable('TXT_TITLE',$this->lng->txt('title'));
1229  $this->tpl->setVariable('TXT_AND',$this->lng->txt('search_all_words'));
1230  $this->tpl->setVariable('TXT_OR',$this->lng->txt('search_any_word'));
1231  $this->tpl->setVariable('TXT_BILL',$this->lng->txt('pays_bill'));
1232  $this->tpl->setVariable('TXT_BMF',$this->lng->txt('pays_bmf'));
1233  $this->tpl->setVariable('TXT_PAYPAL',$this->lng->txt('pays_paypal'));
1234  $this->tpl->setVariable('TXT_VENDOR',$this->lng->txt('paya_vendor'));
1235  $this->tpl->setVariable('TXT_PAYMENT',$this->lng->txt('payment_system'));
1236  $this->tpl->setVariable('TXT_UPDATE_VIEW',$this->lng->txt('pay_update_view'));
1237  $this->tpl->setVariable('TXT_RESET_FILTER',$this->lng->txt('pay_reset_filter'));
1238 
1239  $this->tpl->setVariable(($_SESSION['pay_objects']['title_type'] != '' ? strtoupper($_SESSION['pay_objects']['title_type']) : 'OR') . '_CHECKED', ' checked');
1240  $this->tpl->setVariable('TITLE_VALUE', ilUtil::prepareFormOutput($_SESSION['pay_objects']['title_value'], true));
1241  $this->tpl->setVariable('PAYMENT_' . $_SESSION['pay_objects']['pay_method'], ' selected');
1242  $this->tpl->setVariable('VENDOR', ilUtil::prepareFormOutput($_SESSION['pay_objects']['vendor'], true));
1243 
1244  if(!count($objects = ilPaymentObject::_getAllObjectsData()))
1245  {
1246  ilUtil::sendInfo($this->lng->txt('paya_no_objects_assigned'));
1247 
1248  return true;
1249  }
1250 
1251  $counter = 0;
1252  foreach($objects as $data)
1253  {
1254  $tmp_obj =& ilObjectFactory::getInstanceByRefId($data['ref_id'], false);
1255  if($tmp_obj)
1256  {
1257  $f_result[$counter][] = $tmp_obj->getTitle();
1258  }
1259  else
1260  {
1261  $f_result[$counter][] = $this->lng->txt('object_not_found');
1262  }
1263 
1264  switch($data['status'])
1265  {
1266  case $this->pobject->STATUS_BUYABLE:
1267  $f_result[$counter][] = $this->lng->txt('paya_buyable');
1268  break;
1269 
1270  case $this->pobject->STATUS_NOT_BUYABLE:
1271  $f_result[$counter][] = $this->lng->txt('paya_not_buyable');
1272  break;
1273 
1274  case $this->pobject->STATUS_EXPIRES:
1275  $f_result[$counter][] = $this->lng->txt('paya_expires');
1276  break;
1277  }
1278  switch($data['pay_method'])
1279  {
1280  case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
1281  $f_result[$counter][] = $this->lng->txt('paya_pay_method_not_specified');
1282  break;
1283 
1284  case $this->pobject->PAY_METHOD_BILL:
1285  $f_result[$counter][] = $this->lng->txt('pays_bill');
1286  break;
1287 
1288  case $this->pobject->PAY_METHOD_BMF:
1289  $f_result[$counter][] = $this->lng->txt('pays_bmf');
1290  break;
1291 
1292  case $this->pobject->PAY_METHOD_PAYPAL:
1293  $f_result[$counter][] = $this->lng->txt('pays_paypal');
1294  break;
1295  }
1296 
1297  if($data['vat_id'] <= 0)
1298  {
1299 
1300  $vat_rate = $this->lng->txt('payment_vat_has_to_be_defined_by_administration_short');
1301  }
1302  else
1303  {
1304  try
1305  {
1306  $oVAT = new ilShopVats((int)$data['vat_id']);
1307  $vat_rate = ilShopUtils::_formatVAT((float)$oVAT->getRate());
1308  }
1309  catch(ilShopException $e)
1310  {
1311  $vat_rate = $this->lng->txt('payment_vat_has_to_be_defined_by_administration_short');
1312  }
1313  }
1314 
1315  $f_result[$counter][] = $vat_rate;
1316 
1317 // $tmp_user =& ilObjectFactory::getInstanceByObjId($data['vendor_id']);
1318 // $f_result[$counter][] = $tmp_user->getFullname().' ['.$tmp_user->getLogin().']';
1319  if($data['vendor_id'] == 0)
1320  {
1321  $f_result[$counter][] = $this->lng->txt('no_vendor_selected');
1322  }
1323  else
1324  {
1325  $tmp_user = ilObjectFactory::getInstanceByObjId($data['vendor_id'], false);
1326  if(is_object($tmp_user))
1327  {
1328  $f_result[$counter][] = $tmp_user->getFullname().' ['.$tmp_user->getLogin().']';
1329  }
1330  else
1331  {
1332  $f_result[$counter][] = $this->lng->txt('no_vendor_selected');
1333  }
1334  }
1335 
1336  // Get number of purchasers
1337 
1338  $f_result[$counter][] = ilPaymentBookings::_getCountBookingsByObject($data['pobject_id']);
1339 
1340 
1341  // edit link
1342  $this->ctrl->setParameter($this,'pobject_id',$data['pobject_id']);
1343  $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editObject")."\">".$this->lng->txt("edit")."</a></div>";
1344 
1345  $f_result[$counter][] = $link_change;
1346  unset($tmp_user);
1347  unset($tmp_obj);
1348 
1349  ++$counter;
1350  }
1351 
1352  $this->__showObjectsTable($f_result);
1353 
1354  return true;
1355  }
1356 
1357  function __showObjectsTable($a_result_set)
1358  {
1359  $tbl =& $this->initTableGUI();
1360  $tpl =& $tbl->getTemplateObject();
1361 
1362  // SET FORMAACTION
1363  $tpl->setCurrentBlock('tbl_form_header');
1364 
1365  $this->ctrl->setParameter($this, 'cmd', 'objects');
1366 
1367  $tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this));
1368  $tpl->parseCurrentBlock();
1369 
1370 
1371 
1372  $tbl->setTitle($this->lng->txt('objects'),'icon_pays.gif',$this->lng->txt('objects'));
1373  $tbl->setHeaderNames(array($this->lng->txt('title'),
1374  $this->lng->txt('status'),
1375  $this->lng->txt('paya_pay_method'),
1376  $this->lng->txt("vat_rate"),
1377  $this->lng->txt('paya_vendor'),
1378  $this->lng->txt('paya_count_purchaser'),
1379  ''));
1380  $header_params = $this->ctrl->getParameterArray($this,'');
1381 
1382 
1383  $tbl->setHeaderVars(array('title',
1384  'status',
1385  'pay_method',
1386  'vat_rate',
1387  'vendor',
1388  'purchasers',
1389  'options'),$header_params);
1390  /*
1391  array("cmd" => "",
1392  "cmdClass" => "ilpaymentobjectgui",
1393  "cmdNode" => $_GET["cmdNode"]));
1394  */
1395  $tbl->setColumnWidth(array("15%","15%","15%","20%","20%"));
1396 
1397 # $this->setTableGUIBasicData($tbl,$a_result_set);
1398 
1399  $offset = $_GET['offset'];
1400  $order = $_GET['sort_by'];
1401  $direction = $_GET['sort_order'] ? $_GET['sort_order'] : 'desc';
1402 
1403  $tbl->setOrderColumn($order,'order_date');
1404  $tbl->setOrderDirection($direction);
1405  $tbl->setOffset($offset);
1406  $tbl->setLimit($_GET['limit']);
1407  $tbl->setMaxCount(count($a_result_set));
1408  $tbl->setFooter('tblfooter',$this->lng->txt('previous'),$this->lng->txt('next'));
1409  $tbl->setData($a_result_set);
1410 
1411  $tbl->render();
1412 
1413  $this->tpl->setVariable('OBJECTS_TABLE',$tbl->tpl->get());
1414 
1415 
1416  return true;
1417  }
1418 
1419  function __initPaymentObject($a_pobject_id = 0)
1420  {
1421  include_once './payment/classes/class.ilPaymentObject.php';
1422 
1423  $this->pobject =& new ilPaymentObject($this->user_obj,$a_pobject_id);
1424 
1425  return true;
1426  }
1427 
1428  function gatewayObject()
1429  {
1430  switch($_POST['action'])
1431  {
1432  case 'deleteVendorsObject':
1433  $this->deleteVendors();
1434  break;
1435 
1436  case 'editVendorObject':
1437  $this->editVendor();
1438  break;
1439 
1440  case 'performEditVendorObject':
1441  $this->performEditVendorObject();
1442  break;
1443 
1444  default:
1445  $this->vendorsObject();
1446  break;
1447  }
1448  return true;
1449  }
1450 
1452  {
1453  unset($_SESSION['pay_statistics']);
1454  unset($_POST['transaction_type']);
1455  unset($_POST['transaction_value']);
1456  unset($_POST['from']['day']);
1457  unset($_POST['from']['month']);
1458  unset($_POST['from']['year']);
1459  unset($_POST['til']['day']);
1460  unset($_POST['til']['month']);
1461  unset($_POST['til']['year']);
1462  unset($_POST['payed']);
1463  unset($_POST['access']);
1464  unset($_POST['customer']);
1465  unset($_POST['pay_method']);
1466  unset($_POST['updateView']);
1467  ilUtil::sendInfo($this->lng->txt('paya_filter_reseted'));
1468 
1469  return $this->statisticObject();
1470  }
1471 
1472  function statisticObject()
1473  {
1474  global $rbacsystem;
1475 
1476  // MINIMUM ACCESS LEVEL = 'read'
1477  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
1478  {
1479  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
1480  }
1481 
1482  $this->__showButton('showObjectSelector',$this->lng->txt('paya_add_customer'));
1483 
1484  if ($_POST['updateView'] == 1)
1485  {
1486  $_SESSION['pay_statistics']['updateView'] = true;
1487  $_SESSION['pay_statistics']['transaction_type'] = $_POST['transaction_type'];
1488  $_SESSION['pay_statistics']['transaction_value'] = $_POST['transaction_value'];
1489  $_SESSION['pay_statistics']['from']['day'] = $_POST['from']['day'];
1490  $_SESSION['pay_statistics']['from']['month'] = $_POST['from']['month'];
1491  $_SESSION['pay_statistics']['from']['year'] = $_POST['from']['year'];
1492  $_SESSION['pay_statistics']['til']['day'] = $_POST['til']['day'];
1493  $_SESSION['pay_statistics']['til']['month'] = $_POST['til']['month'];
1494  $_SESSION['pay_statistics']['til']['year'] = $_POST['til']['year'];
1495  $_SESSION['pay_statistics']['payed'] = $_POST['payed'];
1496  $_SESSION['pay_statistics']['access'] = $_POST['access'];
1497  $_SESSION['pay_statistics']['pay_method'] = $_POST['pay_method'];
1498  $_SESSION['pay_statistics']['customer'] = $_POST['customer'];
1499  $_SESSION['pay_statistics']['vendor'] = $_POST['vendor'];
1500  }
1501 
1502  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_statistic.html','payment');
1503 
1504  $this->tpl->setVariable('TXT_FILTER',$this->lng->txt('pay_filter'));
1505  $this->tpl->setVariable('FORM_ACTION',$this->ctrl->getFormAction($this));
1506  $this->tpl->setVariable('TXT_TRANSACTION',$this->lng->txt('paya_transaction'));
1507  $this->tpl->setVariable('TXT_STARTING',$this->lng->txt('pay_starting'));
1508  $this->tpl->setVariable('TXT_ENDING',$this->lng->txt('pay_ending'));
1509  $this->tpl->setVariable('TXT_PAYED',$this->lng->txt('paya_payed'));
1510  $this->tpl->setVariable('TXT_ALL',$this->lng->txt('pay_all'));
1511  $this->tpl->setVariable('TXT_YES',$this->lng->txt('yes'));
1512  $this->tpl->setVariable('TXT_NO',$this->lng->txt('no'));
1513  $this->tpl->setVariable('TXT_BILL',$this->lng->txt('pays_bill'));
1514  $this->tpl->setVariable('TXT_BMF',$this->lng->txt('pays_bmf'));
1515  $this->tpl->setVariable('TXT_PAYPAL',$this->lng->txt('pays_paypal'));
1516  $this->tpl->setVariable('TXT_EPAY',$this->lng->txt('pays_epay'));
1517  $this->tpl->setVariable('TXT_PAYMENT',$this->lng->txt('payment_system'));
1518  $this->tpl->setVariable('TXT_CUSTOMER',$this->lng->txt('paya_customer'));
1519  $this->tpl->setVariable('TXT_VENDOR',$this->lng->txt('paya_vendor'));
1520  $this->tpl->setVariable('TXT_ACCESS',$this->lng->txt('paya_access'));
1521  $this->tpl->setVariable('TXT_ORDER_DATE_FROM',$this->lng->txt('pay_order_date_from'));
1522  $this->tpl->setVariable('TXT_ORDER_DATE_TIL',$this->lng->txt('pay_order_date_til'));
1523  $this->tpl->setVariable('TXT_UPDATE_VIEW',$this->lng->txt('pay_update_view'));
1524  $this->tpl->setVariable('TXT_RESET_FILTER',$this->lng->txt('pay_reset_filter'));
1525 
1526  $this->tpl->setVariable('TRANSACTION_TYPE_' . $_SESSION['pay_statistics']['transaction_type'], ' selected');
1527  $this->tpl->setVariable('TRANSACTION_VALUE', ilUtil::prepareFormOutput($_SESSION['pay_statistics']['transaction_value'], true));
1528  $this->tpl->setVariable('PAYED_' . $_SESSION['pay_statistics']['payed'], ' selected');
1529  $this->tpl->setVariable('ACCESS_' . $_SESSION['pay_statistics']['access'], ' selected');
1530  $this->tpl->setVariable('PAYMENT_' . $_SESSION['pay_statistics']['pay_method'], ' selected');
1531  $this->tpl->setVariable('CUSTOMER', ilUtil::prepareFormOutput($_SESSION['pay_statistics']['customer'], true));
1532  $this->tpl->setVariable('VENDOR', ilUtil::prepareFormOutput($_SESSION['pay_statistics']['vendor'], true));
1533 
1534  for ($i = 1; $i <= 31; $i++)
1535  {
1536  $this->tpl->setCurrentBlock('loop_from_day');
1537  $this->tpl->setVariable('LOOP_FROM_DAY', $i < 10 ? '0' . $i : $i);
1538  if ($_SESSION['pay_statistics']['from']['day'] == $i)
1539  {
1540  $this->tpl->setVariable('LOOP_FROM_DAY_SELECTED', ' selected');
1541  }
1542  $this->tpl->parseCurrentBlock('loop_from_day');
1543  $this->tpl->setCurrentBlock('loop_til_day');
1544  $this->tpl->setVariable('LOOP_TIL_DAY', $i < 10 ? '0' . $i : $i);
1545  if ($_SESSION['pay_statistics']['til']['day'] == $i)
1546  {
1547  $this->tpl->setVariable('LOOP_TIL_DAY_SELECTED', ' selected');
1548  }
1549  $this->tpl->parseCurrentBlock('loop_til_day');
1550  }
1551  for ($i = 1; $i <= 12; $i++)
1552  {
1553  $this->tpl->setCurrentBlock('loop_from_month');
1554  $this->tpl->setVariable('LOOP_FROM_MONTH', $i < 10 ? '0' . $i : $i);
1555  if ($_SESSION['pay_statistics']['from']['month'] == $i)
1556  {
1557  $this->tpl->setVariable('LOOP_FROM_MONTH_SELECTED', ' selected');
1558  }
1559  $this->tpl->parseCurrentBlock('loop_from_month');
1560  $this->tpl->setCurrentBlock('loop_til_month');
1561  $this->tpl->setVariable('LOOP_TIL_MONTH', $i < 10 ? '0' . $i : $i);
1562  if ($_SESSION['pay_statistics']['til']['month'] == $i)
1563  {
1564  $this->tpl->setVariable('LOOP_TIL_MONTH_SELECTED', ' selected');
1565  }
1566  $this->tpl->parseCurrentBlock('loop_til_month');
1567  }
1568  for ($i = 2004; $i <= date('Y'); $i++)
1569  {
1570  $this->tpl->setCurrentBlock('loop_from_year');
1571  $this->tpl->setVariable('LOOP_FROM_YEAR', $i);
1572  if ($_SESSION['pay_statistics']['from']['year'] == $i)
1573  {
1574  $this->tpl->setVariable('LOOP_FROM_YEAR_SELECTED', ' selected');
1575  }
1576  $this->tpl->parseCurrentBlock('loop_from_year');
1577  $this->tpl->setCurrentBlock('loop_til_year');
1578  $this->tpl->setVariable('LOOP_TIL_YEAR', $i);
1579  if ($_SESSION['pay_statistics']['til']['year'] == $i)
1580  {
1581  $this->tpl->setVariable('LOOP_TIL_YEAR_SELECTED', ' selected');
1582  }
1583  $this->tpl->parseCurrentBlock('loop_til_year');
1584  }
1585 
1586  if(!$_SESSION['pay_statistics']['updateView'])
1587  {
1588  $this->tpl->setVariable('FILTER_MESSAGE', $this->lng->txt('statistics_filter_advice'));
1589  return true;
1590  }
1591 
1592  $this->__initBookingObject();
1593 
1594  if(!count($bookings = $this->booking_obj->getBookings()))
1595  {
1596  ilUtil::sendInfo($this->lng->txt('paya_no_bookings'));
1597 
1598  return true;
1599  }
1600 # else
1601 # {
1602 # $this->__showButton('exportVendors',$this->lng->txt('excel_export'));
1603 # }
1604  $img_change = "<img src=\"".ilUtil::getImagePath("edit.gif")."\" alt=\"".
1605  $this->lng->txt("edit")."\" title=\"".$this->lng->txt("edit").
1606  "\" border=\"0\" vspace=\"0\"/>";
1607 
1608  include_once 'Services/User/classes/class.ilObjUser.php';
1609  $object_title_cache = array();
1610  $user_title_cache = array();
1611 
1612  $counter = 0;
1613  foreach($bookings as $booking)
1614  {
1615  if(array_key_exists($booking['ref_id'], $object_title_cache))
1616  {
1617  $tmp_obj = $object_title_cache[$booking['ref_id']];
1618  }
1619  else
1620  {
1621  $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($booking['ref_id']));
1622  $object_title_cache[$booking['ref_id']] = $tmp_obj;
1623  }
1624  if(array_key_exists($booking['b_vendor_id'], $user_title_cache))
1625  {
1626  $tmp_vendor = $user_title_cache[$booking['b_vendor_id']];
1627  }
1628  else
1629  {
1630  $tmp_vendor = ilObjUser::_lookupLogin($booking['b_vendor_id']);
1631  $user_title_cache[$booking['b_vendor_id']] = $tmp_vendor;
1632  }
1633  if(array_key_exists($booking['customer_id'], $user_title_cache))
1634  {
1635  $tmp_purchaser = $user_title_cache[$booking['customer_id']];
1636  }
1637  else
1638  {
1639  $tmp_purchaser = ilObjUser::_lookupLogin($booking['customer_id']);
1640  $tmp_purchaser_name = ilObjUser::_lookupName($booking['customer_id']);
1641  $tmp_purchaser_email = ilObjUser::_lookupEmail($booking['customer_id']);
1642  $user_title_cache[$booking['customer_id']] = $tmp_purchaser;
1643  }
1644 
1645  $transaction = $booking['transaction_extern'];
1646  switch ($booking['b_pay_method'])
1647  {
1648  case $this->pobject->PAY_METHOD_BILL :
1649  $transaction .= $booking['transaction']."<br> (" . $this->lng->txt("pays_bill") . ")";
1650  break;
1651  case $this->pobject->PAY_METHOD_BMF :
1652  $transaction .= $booking['transaction']." (" . $this->lng->txt("pays_bmf") . ")";
1653  break;
1654  case $this->pobject->PAY_METHOD_PAYPAL :
1655  $transaction .= $booking['transaction']." (" . $this->lng->txt("pays_paypal") . ")";
1656  break;
1657  }
1658  $f_result[$counter][] = $transaction;
1659  $f_result[$counter][] = ($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted'));
1660  $f_result[$counter][] = ($tmp_vendor != '' ? '['.$tmp_vendor.']' : $this->lng->txt('user_deleted'));
1661  $f_result[$counter][] = ($tmp_purchaser != '' ?
1662  $tmp_purchaser_name['firstname'].' '.$tmp_purchaser_name['lastname']. ' ['.$tmp_purchaser.']<br>'
1663  .$tmp_purchaser_email
1664  : $this->lng->txt('user_deleted'));
1665  $f_result[$counter][] = date("Y-m-d H:i:s", $booking['order_date']);
1666  //$f_result[$counter][] = $booking['duration'];
1667 
1668  if($booking['duration'] != 0)
1669  {
1670  $f_result[$counter][] = $booking['duration'].' '.$this->lng->txt('paya_months');
1671 
1672  }
1673  else
1674  {
1675  //$f_result[$counter][] = ilFormat::formatDate($booking['duration_from'],'date') .' - '. ilFormat::formatDate($booking['duration_until'],'date') ;
1676  $f_result[$counter][] = $this->lng->txt("unlimited_duration");
1677  }
1678 
1679 
1680  $f_result[$counter][] = $booking['price'];
1681  $f_result[$counter][] = ($booking['discount'] != '' ? $booking['discount'] : '&nbsp;');
1682 
1683  $payed_access = $booking['payed'] ?
1684  $this->lng->txt('yes') :
1685  $this->lng->txt('no');
1686 
1687  $payed_access .= '/';
1688  $payed_access .= $booking['access'] ?
1689  $this->lng->txt('yes') :
1690  $this->lng->txt('no');
1691 
1692  $f_result[$counter][] = $payed_access;
1693 
1694  $this->ctrl->setParameter($this,"booking_id",$booking['booking_id']);
1695 # $link_change = "<a href=\"".$this->ctrl->getLinkTarget($this,"editStatistic")."\"> ".
1696 # $img_change."</a>";
1697  $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editStatistic")."\">".$this->lng->txt("edit")."</a></div>";
1698 
1699  $f_result[$counter][] = $link_change;
1700 
1701  unset($tmp_obj);
1702  unset($tmp_vendor);
1703  unset($tmp_purchaser);
1704 
1705  ++$counter;
1706  }
1707  return $this->__showStatisticTable($f_result);
1708  }
1709 
1710  function editStatisticObject($a_show_confirm_delete = false)
1711  {
1712  if(!isset($_GET['booking_id']))
1713  {
1714  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
1715  $this->showStatistics();
1716 
1717 
1718  return true;
1719  }
1720 
1721  $this->__showButton('statistic',$this->lng->txt('back'));
1722 
1723  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_edit_statistic.html','payment');
1724  $this->ctrl->setParameter($this,'booking_id',(int) $_GET['booking_id']);
1725 
1726  // confirm delete
1727  if($a_show_confirm_delete)
1728  {
1729  $this->tpl->setCurrentBlock('confirm_delete');
1730  $this->tpl->setVariable('CONFIRM_FORMACTION',$this->ctrl->getFormAction($this));
1731  $this->tpl->setVariable('TXT_CANCEL',$this->lng->txt('cancel'));
1732  $this->tpl->setVariable('CONFIRM_CMD','performDelete');
1733  $this->tpl->setVariable('TXT_CONFIRM',$this->lng->txt('confirm'));
1734  $this->tpl->parseCurrentBlock();
1735  }
1736 
1737 
1738  $this->__initBookingObject();
1739  $bookings = $this->booking_obj->getBookings();
1740  $booking = $bookings[(int) $_GET['booking_id']];
1741 
1742  // get customer_obj
1743  $tmp_user = ilObjectFactory::getInstanceByObjId($booking['customer_id'], false);
1744 
1745  $this->tpl->setVariable('STAT_FORMACTION',$this->ctrl->getFormAction($this));
1746  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_usr.gif'));
1747  $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_usr'));
1748  if(is_object($tmp_user))
1749  {
1750  $this->tpl->setVariable('TITLE', $tmp_user->getFullname().' ['.$tmp_user->getLogin().']');
1751  }
1752  else
1753  {
1754  $this->tpl->setVariable('TITLE', $this->lng->txt('user_deleted'));
1755  }
1756 
1757  // TXT
1758  $pObj = new ilPaymentObject($this->user_obj, $booking['pobject_id']);
1759  $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($pObj->getRefId()));
1760 
1761  $this->tpl->setVariable('TXT_OBJECT',$this->lng->txt('title'));
1762  $this->tpl->setVariable('OBJECT', ($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted')));
1763 
1764  $this->tpl->setVariable('TXT_TRANSACTION',$this->lng->txt('paya_transaction'));
1765  $this->tpl->setVariable('TXT_VENDOR',$this->lng->txt('paya_vendor'));
1766  $this->tpl->setVariable('TXT_PAY_METHOD',$this->lng->txt('paya_pay_method'));
1767  $this->tpl->setVariable('TXT_ORDER_DATE',$this->lng->txt('paya_order_date'));
1768  $this->tpl->setVariable('TXT_DURATION',$this->lng->txt('duration'));
1769  $this->tpl->setVariable('TXT_PRICE',$this->lng->txt('price_a'));
1770  $this->tpl->setVariable('TXT_PAYED',$this->lng->txt('paya_payed'));
1771  $this->tpl->setVariable('TXT_ACCESS',$this->lng->txt('paya_access'));
1772 
1773  $this->tpl->setVariable("TRANSACTION",$booking['transaction']);
1774 
1775  $tmp_vendor = ilObjectFactory::getInstanceByObjId($booking['b_vendor_id'], false);
1776  if(is_object($tmp_vendor))
1777  {
1778  $this->tpl->setVariable('VENDOR', $tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']');
1779  }
1780  else
1781  {
1782  $this->tpl->setVariable('VENDOR', $this->lng->txt('user_deleted'));
1783  }
1784 
1785  switch($booking['b_pay_method'])
1786  {
1787  case $this->pobject->PAY_METHOD_BILL:
1788  $this->tpl->setVariable('PAY_METHOD',$this->lng->txt('pays_bill'));
1789  break;
1790 
1791  case $this->pobject->PAY_METHOD_BMF:
1792  $this->tpl->setVariable('PAY_METHOD',$this->lng->txt('pays_bmf'));
1793  break;
1794 
1795  case $this->pobject->PAY_METHOD_PAYPAL:
1796  $this->tpl->setVariable('PAY_METHOD',$this->lng->txt('pays_paypal'));
1797  break;
1798 
1799  default:
1800  $this->tpl->setVariable('PAY_METHOD',$this->lng->txt('paya_pay_method_not_specified'));
1801  break;
1802  }
1803  $this->tpl->setVariable('ORDER_DATE',date('Y m d H:i:s',$booking['order_date']));
1804  // $this->tpl->setVariable('DURATION',$booking['duration'].' '.$this->lng->txt('paya_months'));
1805  if($booking['duration'] != 0)
1806  {
1807  $this->tpl->setVariable("DURATION",$booking['duration'].' '.$this->lng->txt('paya_months'));
1808  }
1809  else
1810  {
1811  $this->tpl->setVariable("DURATION",$this->lng->txt("unlimited_duration"));
1812 
1813  }
1814 
1815  $this->tpl->setVariable('PRICE',$booking['price']);
1816 
1817  $yes_no = array(0 => $this->lng->txt('no'),1 => $this->lng->txt('yes'));
1818 
1819  $this->tpl->setVariable('PAYED',ilUtil::formSelect((int) $booking['payed'],'payed',$yes_no,false,true));
1820  $this->tpl->setVariable('ACCESS',ilUtil::formSelect((int) $booking['access'],'access',$yes_no,false,true));
1821 
1822  // buttons
1823  $this->tpl->setVariable('INPUT_CMD','updateStatistic');
1824  $this->tpl->setVariable('INPUT_VALUE',$this->lng->txt('save'));
1825 
1826  $this->tpl->setVariable('DELETE_CMD','deleteStatistic');
1827  $this->tpl->setVariable('DELETE_VALUE',$this->lng->txt('delete'));
1828  $this->tpl->parseCurrentBlock();
1829 
1830  // show CUSTOMER_DATA if isset -> setting: save_user_address
1831  include_once './payment/classes/class.ilPayMethods.php';
1832 
1833  switch($booking['b_pay_method'])
1834  {
1835  case $this->pobject->PAY_METHOD_BILL:
1836  $save_user_adr_bill = (int) ilPayMethods::_enabled('save_user_adr_bill') ? $this->showCustomerTable() : 0;
1837  break;
1838 
1839  case $this->pobject->PAY_METHOD_BMF:
1840  $save_user_adr_bmf = (int) ilPayMethods::_enabled('save_user_adr_bmf') ? $this->showCustomerTable() : 0;
1841  break;
1842 
1843  case $this->pobject->PAY_METHOD_PAYPAL:
1844  $save_user_adr_paypal =(int) ilPayMethods::_enabled('save_user_adr_paypal') ? $this->showCustomerTable() : 0;
1845  break;
1846 
1847  case $this->pobject->PAY_METHOD_EPAY:
1848  $save_user_adr_epay =(int) ilPayMethods::_enabled('save_user_adr_epay') ? $this->showCustomerTable() : 0;
1849 
1850  default:
1851  break;
1852  }
1853 
1854  }
1856  {
1857  if(!isset($_GET['booking_id']))
1858  {
1859  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
1860  $this->statisticObject();
1861 
1862  return true;
1863  }
1864  $this->__initBookingObject();
1865 
1866  $this->booking_obj->setBookingId((int) $_GET['booking_id']);
1867  $this->booking_obj->setAccess((int) $_POST['access']);
1868  $this->booking_obj->setPayed((int) $_POST['payed']);
1869 
1870  if($this->booking_obj->update())
1871  {
1872  ilUtil::sendSuccess($this->lng->txt('paya_updated_booking'));
1873 
1874  $this->statisticObject();
1875  return true;
1876  }
1877  else
1878  {
1879  ilUtil::sendInfo($this->lng->txt('paya_error_update_booking'));
1880 
1881  $this->statisticObject();
1882 
1883  return true;
1884  }
1885  }
1886 
1888  {
1889  if(!isset($_GET['booking_id']))
1890  {
1891  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
1892  $this->statisticObject();
1893 
1894  return true;
1895  }
1896  ilUtil::sendQuestion($this->lng->txt('paya_sure_delete_stat'));
1897 
1898  $this->editStatisticObject(true);
1899 
1900  return true;
1901  }
1903  {
1904  if(!isset($_GET['booking_id']))
1905  {
1906  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
1907  $this->statisticObject();
1908 
1909  return true;
1910  }
1911 
1912  $this->__initBookingObject();
1913  $this->booking_obj->setBookingId((int) $_GET['booking_id']);
1914  if(!$this->booking_obj->delete())
1915  {
1916  die('Error deleting booking');
1917  }
1918  ilUtil::sendInfo($this->lng->txt('pay_deleted_booking'));
1919 
1920  $this->statisticObject();
1921 
1922  return true;
1923  }
1924 
1925  function getAdminTabs(&$tabs_gui)
1926  {
1927  $this->getTabs($tabs_gui);
1928  }
1929 
1935  function getTabs(&$tabs_gui)
1936  {
1937  global $rbacsystem;
1938 
1939  if ($rbacsystem->checkAccess('visible,read',$this->object->getRefId()))
1940  {
1941  $tabs_gui->addTarget('settings',
1942  $this->ctrl->getLinkTarget($this, 'generalSettings'), array('generalSettings','', 'view'), '', '');
1943 
1944  $tabs_gui->addTarget('bookings',
1945  $this->ctrl->getLinkTarget($this, 'statistic'), 'statistic', '', '');
1946 
1947  $tabs_gui->addTarget('objects',
1948  $this->ctrl->getLinkTarget($this, 'objects'), 'objects', '', '');
1949 
1950  $tabs_gui->addTarget('vendors',
1951  $this->ctrl->getLinkTarget($this, 'vendors'), 'vendors', '', '');
1952 
1953  $tabs_gui->addTarget('pay_methods',
1954  $this->ctrl->getLinkTarget($this, 'payMethods'), 'payMethods', '', '');
1955 
1956  $tabs_gui->addTarget('topics',
1957  $this->ctrl->getLinkTargetByClass('ilshoptopicsgui', ''), 'payment_topics', '', '');
1958 
1959  $tabs_gui->addTarget('vats',
1960  $this->ctrl->getLinkTarget($this, 'vats'), 'vats', '', '');
1961  }
1962 
1963  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
1964  {
1965  $tabs_gui->addTarget('perm_settings',
1966  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), 'perm'), array('perm','info','owner'), 'ilpermissiongui');
1967  }
1968  }
1969 
1970  function generalSettingsObject($a_show_confirm = false)
1971  {
1972  global $rbacsystem;
1973 
1974  // MINIMUM ACCESS LEVEL = 'read'
1975  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
1976  {
1977  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
1978  }
1979 
1980  include_once './payment/classes/class.ilGeneralSettings.php';
1981 
1982  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.pays_general_settings.html','payment');
1983 
1984  $genSet = new ilGeneralSettings();
1985  $genSetData = $genSet->getAll();
1986 
1987  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1988 
1989  $form = new ilPropertyFormGUI();
1990  $form->setFormAction($this->ctrl->getFormAction($this, 'saveGeneralSettings'));
1991  $form->setTitle($this->lng->txt('pays_general_settings'));
1992 
1993  $form->addCommandButton('saveGeneralSettings',$this->lng->txt('save'));
1994 
1995  // enable webshop
1996  $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_enable_shop'), 'shop_enabled');
1997  $formItem->setChecked((int)$genSetData['shop_enabled']);
1998  $formItem->setInfo($this->lng->txt('pay_enable_shop_info'));
1999  $form->addItem($formItem);
2000 
2001  $formItem = new ilTextInputGUI($this->lng->txt('pays_currency_unit'), 'currency_unit');
2002  $formItem->setSize(5);
2003  $formItem->setValue($this->error != '' && isset($_POST['currency_unit'])
2004  ? ilUtil::prepareFormOutput($_POST['currency_unit'],true)
2005  : ilUtil::prepareFormOutput($genSetData['currency_unit'],true));
2006  $formItem->setRequired(true);
2007  $form->addItem($formItem);
2008 
2009  $formItem = new ilTextInputGUI($this->lng->txt('pays_currency_subunit'), 'currency_subunit');
2010  $formItem->setSize(5);
2011  $formItem->setRequired(true);
2012  $formItem->setValue($this->error != '' && isset($_POST['currency_subunit'])
2013  ? ilUtil::prepareFormOutput($_POST['currency_subunit'],true)
2014  : ilUtil::prepareFormOutput($genSetData['currency_subunit'],true));
2015  $form->addItem($formItem);
2016 
2017  $formItem = new ilTextAreaInputGUI($this->lng->txt('pays_address'), 'address');
2018  $formItem->setRows(7);
2019  $formItem->setCols(35);
2020  $formItem->setRequired(true);
2021  $formItem->setValue($this->error != '' && isset($_POST['address'])
2022  ? ilUtil::prepareFormOutput($_POST['address'],true)
2023  : ilUtil::prepareFormOutput($genSetData['address'],true));
2024  $form->addItem($formItem);
2025 
2026  $formItem = new ilTextAreaInputGUI($this->lng->txt('pays_bank_data'), 'bank_data');
2027  $formItem->setRows(7);
2028  $formItem->setCols(35);
2029  $formItem->setRequired(true);
2030  $formItem->setValue($this->error != '' && isset($_POST['bank_data'])
2031  ? ilUtil::prepareFormOutput($_POST['bank_data'],true)
2032  : ilUtil::prepareFormOutput($genSetData['bank_data'],true));
2033  $form->addItem($formItem);
2034 
2035  $formItem = new ilTextAreaInputGUI($this->lng->txt('pays_add_info'), 'add_info');
2036  $formItem->setRows(7);
2037  $formItem->setCols(35);
2038  $formItem->setValue($this->error != '' && isset($_POST['add_info'])
2039  ? ilUtil::prepareFormOutput($_POST['add_info'],true)
2040  : ilUtil::prepareFormOutput($genSetData['add_info'],true));
2041  $form->addItem($formItem);
2042 /*
2043  $formItem = new ilTextInputGUI($this->lng->txt('pays_vat_rate'), 'vat_rate');
2044  $formItem->setSize(5);
2045  $formItem->setValue($this->error != "" && isset($_POST['vat_rate'])
2046  ? ilUtil::prepareFormOutput($_POST['vat_rate'],true)
2047  : ilUtil::prepareFormOutput($genSetData['vat_rate'],true));
2048  $form->addItem($formItem);
2049 */
2050  $formItem = new ilTextInputGUI($this->lng->txt('pays_pdf_path'), 'pdf_path');
2051  $formItem->setValue($this->error != "" && isset($_POST['pdf_path'])
2052  ? ilUtil::prepareFormOutput($_POST['pdf_path'],true)
2053  : ilUtil::prepareFormOutput($genSetData['pdf_path'],true));
2054  $formItem->setRequired(true);
2055  $form->addItem($formItem);
2056 
2057 
2058  // default sorting type
2059  $formItem = new ilSelectInputGUI($this->lng->txt('pay_topics_default_sorting_type'), 'topics_sorting_type');
2060  $formItem->setValue($genSetData['topics_sorting_type']);
2061  $options = array(
2062  1 => $this->lng->txt('pay_topics_sort_by_title'),
2063  2 => $this->lng->txt('pay_topics_sort_by_date'),
2064  3 => $this->lng->txt('pay_topics_sort_manually')
2065  );
2066  $formItem->setOptions($options);
2067  $form->addItem($formItem);
2068 
2069  // default sorting direction
2070  $formItem = new ilSelectInputGUI($this->lng->txt('pay_topics_default_sorting_direction'), 'topics_sorting_direction');
2071  $formItem->setValue($genSetData['topics_sorting_direction']);
2072  $options = array(
2073  'asc' => $this->lng->txt('sort_asc'),
2074  'desc' => $this->lng->txt('sort_desc'),
2075  );
2076  $formItem->setOptions($options);
2077  $form->addItem($formItem);
2078 
2079  // custom sorting
2080  $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_topics_allow_custom_sorting'), 'topics_allow_custom_sorting');
2081  $formItem->setChecked((int)$genSetData['topics_allow_custom_sorting']);
2082  $formItem->setInfo($this->lng->txt('pay_topics_allow_custom_sorting_info'));
2083  $form->addItem($formItem);
2084 
2085  // max hits
2086  $formItem = new ilSelectInputGUI($this->lng->txt('pay_max_hits'), 'max_hits');
2087  $formItem->setValue($genSetData['max_hits']);
2088  $options = array();
2089  for($i = 10; $i <= 100; $i += 10)
2090  {
2091  $options[$i] = $i;
2092  }
2093  $formItem->setOptions($options);
2094  $formItem->setInfo($this->lng->txt('pay_max_hits_info'));
2095  $form->addItem($formItem);
2096 
2097  // hide advanced search
2098  $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_hide_advanced_search'), 'hide_advanced_search');
2099  $formItem->setChecked((int)$genSetData['hide_advanced_search']);
2100  $formItem->setInfo($this->lng->txt('pay_hide_advanced_search_info'));
2101  $form->addItem($formItem);
2102 
2103  // hide shop news
2104  $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_hide_news'), 'hide_news');
2105  $formItem->setChecked((int)$genSetData['hide_news']);
2106  $formItem->setInfo($this->lng->txt('pay_hide_news_info'));
2107  $form->addItem($formItem);
2108 
2109 
2110 
2111  // Hide filtering
2112  $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_hide_filtering'), 'hide_filtering');
2113  $formItem->setChecked((int)$genSetData['hide_filtering']);
2114  $formItem->setInfo($this->lng->txt('pay_hide_filtering_info'));
2115  $form->addItem($formItem);
2116 
2117  // Hide coupons
2118  $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_hide_coupons'), 'hide_coupons');
2119  $formItem->setChecked((int)$genSetData['hide_coupons']);
2120  $formItem->setInfo($this->lng->txt('pay_hide_coupons'));
2121  $form->addItem($formItem);
2122 
2123 
2124 
2125 
2126  $this->tpl->setVariable('GENERAL_SETTINGS',$form->getHTML());
2127  }
2128 
2130  {
2131  global $rbacsystem;
2132 
2133  // MINIMUM ACCESS LEVEL = 'read'
2134  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2135  {
2136  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
2137  }
2138 
2139  include_once './payment/classes/class.ilGeneralSettings.php';
2140 
2141  $genSet = new ilGeneralSettings();
2142 
2143  if ($_POST['currency_unit'] == '' ||
2144  $_POST['currency_subunit'] == '' ||
2145  $_POST['address'] == '' ||
2146  $_POST['bank_data'] == '' ||
2147  $_POST['pdf_path'] == '')
2148  {
2149  $this->error = $this->lng->txt('pays_general_settings_not_valid');
2150  ilUtil::sendFailure($this->error);
2151  $this->generalSettingsObject();
2152  return;
2153  }
2154 
2155  $genSet->clearAll();
2156 
2157 
2158  /*$values = array(
2159  'currency_unit' => $_POST['currency_unit']),
2160  'currency_subunit' => $_POST['currency_subunit']),
2161  'address' => $_POST['address']),
2162  'bank_data' => $_POST['bank_data']),
2163  'add_info' => $_POST['add_info']),
2164  'pdf_path' => $_POST['pdf_path']),
2165  'topics_allow_custom_sorting' => $_POST['topics_allow_custom_sorting']),
2166  'topics_sorting_type' => $_POST['topics_sorting_type']),
2167  'topics_sorting_direction' => $_POST['topics_sorting_direction']),
2168  'max_hits' => $_POST['max_hits']),
2169  'shop_enabled' => $_POST['shop_enabled']),
2170  'hide_advanced_search' => $_POST['hide_advanced_search']),
2171  'hide_filtering' => $_POST['hide_filtering']),
2172  'hide_coupons' => $_POST['hide_coupons']),
2173  'hide_news' => $_POST['hide_news'])
2174  );*/
2175  $values = array(
2176  'currency_unit',
2177  'currency_subunit',
2178  'address',
2179  'bank_data',
2180  'add_info',
2181  'pdf_path',
2182  'topics_allow_custom_sorting',
2183  'topics_sorting_type',
2184  'topics_sorting_direction',
2185  'max_hits',
2186  'shop_enabled',
2187  'hide_advanced_search',
2188  'hide_filtering',
2189  'hide_coupons',
2190  'hide_news'
2191  );
2192 
2193  foreach ($values as $value) $values[$value] = ilUtil::stripSlashes($_POST[$value]);
2194 
2195 
2196  $genSet->setAll($values);
2197  $this->generalSettingsObject();
2198 
2199  ilUtil::sendSuccess($this->lng->txt('pays_updated_general_settings'));
2200 
2201  return true;
2202  }
2203 
2204 
2205 
2209  function epaySettingsObject($a_show_confirm = false)
2210  {
2211  global $rbacsystem;
2212 
2213  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2214  {
2215  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
2216  }
2217 
2218  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
2219  include_once './payment/classes/class.ilEPaySettings.php';
2220 
2221  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.pays_epay_settings.html','payment');
2222 
2223  $ePayObj = ilEPaySettings::getInstance();
2224 
2225  $ep = $ePayObj->getAll();
2226 
2227  $form = new ilPropertyFormGUI();
2228  $form->setFormAction($this->ctrl->getFormAction($this, 'saveEPaySettings'));
2229  $form->setTitle($this->lng->txt('pays_epay_settings'));
2230 
2231  $form->addCommandButton('saveEPaySettings',$this->lng->txt('save'));
2232 
2233  $fields = array (
2234  array('pays_epay_server_host', 'server_host', true, null),
2235  array('pays_epay_server_path', 'server_path', true, null),
2236  array('pays_epay_merchant_number', 'merchant_number', true, null),
2237  array('pays_epay_auth_token', 'auth_token', true, 'pays_epay_auth_token_info'),
2238  array('pays_epay_auth_email', 'auth_email', true, 'pays_epay_auth_email_info')
2239  );
2240 
2241  foreach ($fields as $f)
2242  {
2243  $fi = new ilTextInputGUI($this->lng->txt($f[0]), $f[1]);
2244  $fi->setValue($ep[$f[1]]);
2245  $fi->setRequired($f[2]);
2246  if ($f[3] != null ) $fi->setInfo($this->lng->txt($f[3]));
2247  if ($f[1] == 'auth_token') $fi->setInputType('password');
2248  $form->addItem($fi);
2249  }
2250 
2251  $formItem = new ilCheckboxInputGUI($this->lng->txt('pays_epay_instant_capture'), 'instant_capture');
2252  $formItem->setChecked($ep['instant_capture'] == 1);
2253  $formItem->setInfo($this->lng->txt('pays_epay_instant_capture_info'));
2254  $form->addItem($formItem);
2255 
2256  $this->tpl->setVariable('EPAY_INFO', $this->lng->txt('pays_epay_info'));
2257  $this->tpl->setVariable('EPAY_SETTINGS',$form->getHTML());
2258  }
2259 
2261  {
2262  include_once './payment/classes/class.ilEPaySettings.php';
2263  global $rbacsystem;
2264  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2265  {
2266  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
2267  }
2268 
2269  $epSet = ilEPaySettings::getInstance();
2270 
2271  $arr = ilUtil::stripSlashesArray( array ($_POST['server_host'], $_POST['server_path'], $_POST['merchant_number'],
2272  $_POST['auth_token'], $_POST['auth_email']));
2273  $arr['instant_capture'] = isset($_POST['instant_capture']) ? 1 : 0;
2274 
2275  $epSet->setAll($arr);
2276 
2277  if (!$epSet->valid())
2278  {
2279  $this->error = $this->lng->txt('pays_epay_settings_not_valid');
2280  ilUtil::sendFailure($this->error);
2281  $this->epaySettingsObject();
2282  return;
2283  }
2284 
2285  $epSet->save();
2286  ilUtil::sendSuccess($this->lng->txt('pays_updated_epay_settings'));
2287 
2288  $this->epaySettingsObject();
2289  return true;
2290  }
2291 
2292 
2293 
2298  private function getERPform_eco(&$op, $erps_id = 0)
2299  {
2300  $erp = new ilERP_eco();
2301  $erp->loadSettings($erps_id);
2302  $set = $erp->getSettings(0);
2303 
2304  $fields = array(
2305  array("pays_eco_agreement", "agreement", 10),
2306  array("username", "username", 16),
2307  array("password", "password", 16),
2308  array("pays_eco_product_number", "product", 6),
2309  array("pays_eco_payment_terms", "terms", 6),
2310  array("pays_eco_layout", "layout", 6),
2311  array("pays_eco_cur_handle_code", "code", 3)
2312  );
2313 
2314  foreach ($fields as $f)
2315  {
2316  $txt = new ilTextInputGUI($this->lng->txt($f[0]), $f[1]);
2317  $txt->setMaxLength($f[2]);
2318  $txt->setValue($set[$f[1]]);
2319  if ($f[0] == 'password') $txt->setInputType('password');
2320  $op->addSubItem($txt);
2321  }
2322 
2323  }
2324 
2325  private function getERPform_none(&$op, $erps_id = 0)
2326  {
2327 
2328  }
2329 
2330 
2335  private function getERPform()
2336  {
2337  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
2338  require_once './Services/Payment/classes/class.ilERP_eco.php';
2339 
2340  global $ilias;
2341 
2342  $systems = ilERP::getAllERPs();
2343  $active = ilERP::getActive();
2344  global $ilias;
2345 
2346  $frm = new ilPropertyFormGUI();
2347 
2348 
2349  $frm->setFormAction($this->ctrl->getFormAction($this, 'saveEEPsettings'));
2350  $frm->setTitle($this->lng->txt('pays_erp_settings'));
2351 
2352  if (ilERP::preview_exists())
2353  {
2354  $preview_link = "<br/><a href='". ilERP::getPreviewUrl() ."' target='_blank'>" . $this->lng->txt('pays_erp_invoice_preview') . "</a>";
2355  $frm->addCommandButton('delERPpreview', $this->lng->txt('pays_erp_invoice_delpreview') );
2356  }
2357 
2358  $frm->addCommandButton('saveERPsettings',$this->lng->txt('save'));
2359  $frm->addCommandButton('testERPsettings',$this->lng->txt('test'));
2360 
2361  $savepdf = new ilCheckboxInputGUI($this->lng->txt('pays_erp_invoice_copies'), 'save_copy');
2362  $chk = new ilCheckboxInputGUI($this->lng->txt('enable_ean'), 'use_ean');
2363 
2364  $savepdf->setDisabled( $active['erp_id'] == ERP_NONE);
2365  $chk->setDisabled( $active['erp_id'] == ERP_NONE);
2366 
2367  $rdo = new ilRadioGroupInputGUI($this->lng->txt("pays_erp_system"), "erp_id");
2368  $rdo->setInfo("The ERP is currently in development");
2369 
2370  $rdo->setValue($active['erp_id']);
2371 
2372  foreach ($systems as $system)
2373  {
2374  $desc = $system['description'];
2375  $desc .= empty($system['url']) ? '' : ' <a href="'.$system['url'].'" target="_blank">' . $this->lng->txt("additional_info") ."</a>";
2376 
2377  $op = new ilRadioOption($system['name'], $system['erp_id'], $desc);
2378 
2379  $function = "getERPform_" . $system['erp_short'];
2380  $this->$function(&$op, $active['erps_id']);
2381 
2382 
2383 
2384  $rdo->addOption($op);
2385  }
2386  $frm->addItem($rdo);
2387 
2388  $savepdf->setChecked( $active['save_copy'] );
2389  $chk->setChecked( $active['use_ean']);
2390 
2391  $save_msg = $this->lng->txt('pays_erp_invoice_copies_info') .' ' .ilERP::getSaveDirectory();
2392 
2393  if (!is_writable( ilERP::getSaveDirectory() )) $save_msg .= "<br/><b>" . $this->lng->txt('pays_erp_invoice_nowrite') . "</b>";
2394  $save_msg .= $preview_link;
2395 
2396  $savepdf->setInfo($save_msg);
2397 
2398  $frm->addItem($savepdf);
2399 
2400 
2401 
2402  $chk->setInfo($this->lng->txt('enable_ean_info'));
2403  $frm->addItem($chk);
2404 
2405  return $frm;
2406  }
2407 
2408 
2409 
2415  private function getERPObject($system)
2416  {
2417  require_once './Services/Payment/classes/class.ilERP.php';
2418  switch ($system)
2419  {
2420  case ERP_NONE:
2421  require_once './Services/Payment/classes/class.ilERP_none.php';
2422  $instance = new ilERP_none();
2423  break;
2424  case ERP_ECONOMIC:
2425  require_once './Services/Payment/classes/class.ilERP_eco.php';
2426  $instance = new ilERP_eco();
2427  break;
2428  default:
2429  throw new ilERPException("System " . $system . " is invalid.");
2430  break;
2431  }
2432  return $instance;
2433  }
2434 
2435 
2436 
2437  private function getERParray()
2438  {
2439  $a = array();
2440  foreach ($_POST as $a_post => $a_value) if ($a_post != 'cmd') $a[$a_post] = ilUtil::stripSlashes($a_value);
2441  $a['use_ean'] = (isset($_POST['use_ean'])) ? 1 : 0;
2442  $a['save_copy'] = (isset($_POST['save_copy'])) ? 1 : 0;
2443  return $a;
2444  }
2445 
2446  private function delERPpreviewObject()
2447  {
2448  require_once './Services/Payment/classes/class.ilERP.php';
2450  ilUtil::sendInfo($this->lng->txt('pays_erp_invoice_deleted'));
2451  $this->erpSettingsObject();
2452  }
2453 
2454  private function testERPSettingsObject()
2455  {
2456  global $rbacsystem;
2457  global $ilUser;
2458  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2459  {
2460  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'),$this->ilias->error_obj->MESSAGE);
2461  }
2462  try
2463  {
2464  $this->saveERPsettingsObject();
2465  $active = ilERP::getActive();
2466  assert ($active['erp_id'] == (int) $_POST['erp_id']);
2467 
2468  $cls = "ilERPDebtor_" . $active['erp_short'] ;
2469  require_once './Services/Payment/classes/class.' . $cls . ".php";
2470 
2471  if ($active['erp_id']== ERP_NONE) ilUtil::sendInfo($this->lng->txt('saved_successfully'));
2472  else
2473  {
2474 
2475  $deb = new $cls();
2476  $nr = rand(1030,1040);
2477  if ($deb->getDebtorByNumber($nr))
2478  {
2479  $good .= $this->lng->txt('pays_erp_tst_existing');
2480  }
2481  else
2482  {
2483  $deb->setTestValues();
2484  $deb->createDebtor($nr);
2485 
2486  $good = $this->lng->txt('pays_erp_tst_new');
2487 
2488  }
2489  $good .= " " . $nr . ", " . $deb->getName() . " ";
2490 
2491  $amount = rand(10,1000);
2492  $pcs = rand(1,10);
2493  $good .= $this->lng->txt('pays_erp_tst_billed') . " " . $pcs . " x " . $amount .
2494  "<br/>" . $this->lng->txt('total') . " " . number_format( $pcs*$amount, 2, ',','.');
2495 
2496  $deb->createInvoice();
2497  $deb->createInvoiceLine( 0, $this->lng->txt('pays_erp_tst_product'), $pcs, $amount);
2498  $deb->createInvoiceLine( 0, "www.ilias.dk", 1, 1);
2499  $v = $deb->bookInvoice();
2500  $good .= ", # " . $deb->getInvoiceNumber();
2501 
2502  $attach = $deb->getInvoicePDF($v);
2503 
2504  $deb->saveInvoice($attach, true);
2505  $deb->sendInvoice($this->lng->txt('pay_order_paid_subject'), $deb->getName() . ",\n" . $this->lng->txt('pays_erp_invoice_attached'), $ilUser->getEmail(), $attach, "faktura");
2506 
2507  $good .= "<br/>" . $ilUser->getEmail() . " => " . $this->lng->txt('mail_sent');
2508  ilUtil::sendInfo($good);
2509  }
2510  }
2511  catch (ilERPException $e)
2512  {
2513  ilUtil::sendInfo($good);
2514  ilUtil::sendFailure($e->getMessage());
2515  }
2516  $this->erpSettingsObject();
2517 
2518  }
2519 
2520 
2521 
2522 
2526  private function checkForERPerror(&$instance)
2527  {
2528  $message ="";
2529 
2530  if (!$instance->looksValid()) $message = str_replace('%s', $instance->getName, $this->lng->txt('pays_erp_bad_settings'));
2531  else
2532  {
2533  try
2534  {
2535  $instance->connect();
2536  ilUtil::sendInfo(str_replace('%s', $instance->getName(), $this->lng->txt("pays_erp_connection_established")));
2537  }
2538  catch (ilERPException $e)
2539  {
2540  ilUtil::sendFailure($e->getMessage());
2541  }
2542  }
2543  }
2544 
2545 
2546 
2550  private function saveERPsettingsObject()
2551  {
2552  global $rbacsystem;
2553  if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
2554  {
2555  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'),$this->ilias->error_obj->MESSAGE);
2556  }
2557 
2558  $settings = $this->getERParray();
2559  $system = (int) $_POST['erp_id'];
2560  $instance = $this->getERPObject($system);
2561  $instance->setSettings($settings);
2562 
2563  switch ($system)
2564  {
2565  case ERP_NONE:
2566  break;
2567  case ERP_ECONOMIC:
2568  $this->checkForERPerror($instance);
2569  break;
2570  }
2571 
2572  $instance->setActive($system);
2573  $instance->saveSettings($settings);
2574  ilUtil::sendSuccess(str_replace('%s', $instance->getName(), $this->lng->txt('pays_erp_updated_settings')));
2575  $this->erpSettingsObject();
2576  return true;
2577 
2578  }
2579 
2584  function erpSettingsObject($a_show_confirm = false)
2585  {
2586  global $rbacsystem;
2587  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2588  {
2589  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
2590  }
2591  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.pays_erp_settings.html','payment');
2592 
2593  $form = $this->getERPform();
2594 
2595  $this->tpl->setVariable('ERP_INFO', $this->lng->txt('pays_erp_info'));
2596  $this->tpl->setVariable('ERP_SETTINGS',$form->getHTML());
2597  }
2598 
2599 
2600 
2601 
2602 
2603 
2604  function paypalSettingsObject($a_show_confirm = false)
2605  {
2606  global $rbacsystem;
2607 
2608  // MINIMUM ACCESS LEVEL = 'read'
2609  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2610  {
2611  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
2612  }
2613 
2614  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
2615  include_once './payment/classes/class.ilPaypalSettings.php';
2616 
2617  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.pays_paypal_settings.html','payment');
2618 
2619  $ppSet = ilPaypalSettings::getInstance();
2620 
2621  $form = new ilPropertyFormGUI();
2622  $form->setFormAction($this->ctrl->getFormAction($this, 'savePaypalSettings'));
2623  $form->setTitle($this->lng->txt('pays_paypal_settings'));
2624 
2625  $form->addCommandButton('savePaypalSettings',$this->lng->txt('save'));
2626 
2627  $formItem = new ilTextInputGUI($this->lng->txt('pays_server_host'), 'server_host');
2628  $formItem->setValue($ppSet->getServerHost());
2629  $form->addItem($formItem);
2630 
2631  $formItem = new ilTextInputGUI($this->lng->txt('pays_server_path'), 'server_path');
2632  $formItem->setValue($ppSet->getServerPath());
2633  $form->addItem($formItem);
2634 
2635  $formItem = new ilTextInputGUI($this->lng->txt('pays_email_vendor'), 'vendor');
2636  $formItem->setValue($ppSet->getVendor());
2637  $form->addItem($formItem);
2638 
2639  $formItem = new ilTextInputGUI($this->lng->txt('pays_auth_token'), 'auth_token');
2640  $formItem->setValue($ppSet->getAuthToken());
2641  $form->addItem($formItem);
2642 
2643  $formItem = new ilTextInputGUI($this->lng->txt('pays_page_style'), 'page_style');
2644  $formItem->setValue($ppSet->getPageStyle());
2645  $form->addItem($formItem);
2646 
2647  $this->tpl->setVariable('PAYPAL_SETTINGS',$form->getHTML());
2648  }
2649 
2651  {
2652  include_once './payment/classes/class.ilPaypalSettings.php';
2653 
2654  global $rbacsystem;
2655 
2656  // MINIMUM ACCESS LEVEL = 'read'
2657  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2658  {
2659  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
2660  }
2661 
2662  $ppSet = ilPaypalSettings::getInstance();
2663 
2664  $ppSet->setServerHost(ilUtil::stripSlashes($_POST['server_host']));
2665  $ppSet->setServerPath(ilUtil::stripSlashes($_POST['server_path']));
2666  $ppSet->setVendor(ilUtil::stripSlashes($_POST['vendor']));
2667  $ppSet->setAuthToken(ilUtil::stripSlashes($_POST['auth_token']));
2668  $ppSet->setPageStyle(ilUtil::stripSlashes($_POST['page_style']));
2669  $ppSet->setSsl(ilUtil::stripSlashes($_POST['ssl']));
2670 
2671  if ($_POST['server_host'] == '' ||
2672  $_POST['server_path'] == '' ||
2673  $_POST['vendor'] == '' ||
2674  $_POST['auth_token'] == '')
2675  {
2676  $this->error = $this->lng->txt('pays_paypal_settings_not_valid');
2677  ilUtil::sendFailure($this->error);
2678  $this->paypalSettingsObject();
2679  return;
2680  }
2681 
2682  $ppSet->save();
2683 
2684  $this->paypalSettingsObject();
2685 
2686  ilUtil::sendSuccess($this->lng->txt('pays_updated_paypal_settings'));
2687 
2688  return true;
2689  }
2690 
2691  function vendorsObject($a_show_confirm = false)
2692  {
2693  include_once './payment/classes/class.ilPaymentBookings.php';
2694 
2695  global $rbacsystem;
2696 
2697  // MINIMUM ACCESS LEVEL = 'read'
2698  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2699  {
2700  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
2701  }
2702 
2703  $_SESSION['pays_vendor'] = is_array($_SESSION['pays_vendor']) ? $_SESSION['pays_vendor'] : array();
2704 
2705 
2706  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.pays_vendors.html','payment');
2707 
2708  $this->__showButton('searchUser',$this->lng->txt('search_user'));
2709 
2710  $this->object->initPaymentVendorsObject();
2711  if(!count($vendors = $this->object->payment_vendors_obj->getVendors()))
2712  {
2713  ilUtil::sendInfo($this->lng->txt('pay_no_vendors_created'));
2714  }
2715 # else
2716 # {
2717 # $this->__showButton('exportVendors',$this->lng->txt('excel_export'));
2718 # }
2719 
2720 
2721 
2722  if($a_show_confirm)
2723  {
2724  $this->tpl->setCurrentBlock('confirm_delete');
2725  $this->tpl->setVariable('CONFIRM_FORMACTION',$this->ctrl->getFormAction($this));
2726  $this->tpl->setVariable('TXT_CANCEL',$this->lng->txt('cancel'));
2727  $this->tpl->setVariable('CONFIRM_CMD','performDeleteVendors');
2728  $this->tpl->setVariable('TXT_CONFIRM',$this->lng->txt('delete'));
2729  $this->tpl->parseCurrentBlock();
2730  }
2731 
2732  $counter = 0;
2733  $f_result = array();
2734  foreach($vendors as $vendor)
2735  {
2736  // GET USER OBJ
2737  if($tmp_obj = ilObjectFactory::getInstanceByObjId($vendor['vendor_id'],false))
2738  {
2739  $f_result[$counter][] = ilUtil::formCheckbox(in_array($vendor['vendor_id'],$_SESSION['pays_vendor']) ? 1 : 0,
2740  "vendor[]",
2741  $vendor['vendor_id']);
2742  $f_result[$counter][] = $tmp_obj->getLogin();
2743  $f_result[$counter][] = $vendor['cost_center'];
2744  $f_result[$counter][] = ilPaymentBookings::_getCountBookingsByVendor($vendor['vendor_id']);
2745 
2746  unset($tmp_obj);
2747  ++$counter;
2748  }
2749  } // END VENDORS TABLE
2750  $this->__showVendorsTable($f_result);
2751 
2752  return true;
2753  }
2754 
2756  {
2757  include_once './payment/classes/class.ilPaymentExcelWriterAdapter.php';
2758 
2759 //$_ENV['TMPDIR'] = '/home/nkrzywon/public_html/ilias310/extern';
2760  $pewa =& new ilPaymentExcelWriterAdapter('payment_vendors.xls');
2761 
2762  // add/fill worksheet
2763  $this->addVendorWorksheet($pewa);
2764  $this->addStatisticWorksheet($pewa);
2765 
2766  // HEADER SENT
2767 
2768  $workbook =& $pewa->getWorkbook();
2769  @$workbook->close();
2770  }
2771 
2772  function addStatisticWorksheet(&$pewa)
2773  {
2774  include_once './Services/Excel/classes/class.ilExcelUtils.php';
2775  include_once './payment/classes/class.ilPaymentVendors.php';
2776 
2777  $this->__initBookingObject();
2778 
2779  $workbook =& $pewa->getWorkbook();
2780  $worksheet =& $workbook->addWorksheet(utf8_decode($this->lng->txt('bookings')));
2781 
2782  $worksheet->mergeCells(0,0,0,3);
2783  $worksheet->setColumn(0,0,16);
2784  $worksheet->setColumn(0,1,32);
2785  $worksheet->setColumn(0,2,32);
2786  $worksheet->setColumn(0,3,16);
2787  $worksheet->setColumn(0,4,16);
2788  $worksheet->setColumn(0,5,16);
2789  $worksheet->setColumn(0,6,24);
2790  $worksheet->setColumn(0,7,8);
2791  $worksheet->setColumn(0,8,12);
2792  $worksheet->setColumn(0,9,16);
2793 
2794  //$title = $this->lng->txt('paya_statistic');
2795  $title = $this->lng->txt('bookings');
2796  $title .= ' '.$this->lng->txt('as_of').' ';
2797  $title .= strftime('%Y-%m-%d %R',time());
2798 
2799  $worksheet->writeString(0,0,$title,$pewa->getFormatTitle());
2800 
2801  $worksheet->writeString(1,0,ilExcelUtils::_convert_text($this->lng->txt('payment_system')),$pewa->getFormatHeader());
2802  $worksheet->writeString(1,1,ilExcelUtils::_convert_text($this->lng->txt('paya_transaction')),$pewa->getFormatHeader());
2803  $worksheet->writeString(1,2,ilExcelUtils::_convert_text($this->lng->txt('title')),$pewa->getFormatHeader());
2804  $worksheet->writeString(1,3,ilExcelUtils::_convert_text($this->lng->txt('paya_vendor')),$pewa->getFormatHeader());
2805  $worksheet->writeString(1,4,ilExcelUtils::_convert_text($this->lng->txt('pays_cost_center')),$pewa->getFormatHeader());
2806  $worksheet->writeString(1,5,ilExcelUtils::_convert_text($this->lng->txt('paya_customer')),$pewa->getFormatHeader());
2807  $worksheet->writeString(1,6,ilExcelUtils::_convert_text($this->lng->txt('email')),$pewa->getFormatHeader());
2808  $worksheet->writeString(1,7,ilExcelUtils::_convert_text($this->lng->txt('paya_order_date')),$pewa->getFormatHeader());
2809  $worksheet->writeString(1,8,ilExcelUtils::_convert_text($this->lng->txt('duration')),$pewa->getFormatHeader());
2810  $worksheet->writeString(1,9,ilExcelUtils::_convert_text($this->lng->txt('price_a')),$pewa->getFormatHeader());
2811  $worksheet->writeString(1,10,ilExcelUtils::_convert_text($this->lng->txt('paya_payed_access')),$pewa->getFormatHeader());
2812 
2813  $worksheet->writeString(1,11,ilExcelUtils::_convert_text($this->lng->txt('street')),$pewa->getFormatHeader());
2814  $worksheet->writeString(1,12,ilExcelUtils::_convert_text($this->lng->txt('pay_bmf_po_box')),$pewa->getFormatHeader());
2815  $worksheet->writeString(1,13,ilExcelUtils::_convert_text($this->lng->txt('zipcode')),$pewa->getFormatHeader());
2816  $worksheet->writeString(1,14,ilExcelUtils::_convert_text($this->lng->txt('city')),$pewa->getFormatHeader());
2817  $worksheet->writeString(1,15,ilExcelUtils::_convert_text($this->lng->txt('country')),$pewa->getFormatHeader());
2818 
2819  if(!count($bookings = $this->booking_obj->getBookings()))
2820  {
2821  return false;
2822  }
2823 
2824  include_once 'Services/User/classes/class.ilObjUser.php';
2825  $object_title_cache = array();
2826  $user_title_cache = array();
2827 
2828  $counter = 2;
2829  foreach($bookings as $booking)
2830  {
2831  if(array_key_exists($booking['ref_id'], $object_title_cache))
2832  {
2833  $tmp_obj = $object_title_cache[$booking['ref_id']];
2834  }
2835  else
2836  {
2837  $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($booking['ref_id']));
2838  $object_title_cache[$booking['ref_id']] = $tmp_obj;
2839  }
2840  if(array_key_exists($booking['b_vendor_id'], $user_title_cache))
2841  {
2842  $tmp_vendor = $user_title_cache[$booking['b_vendor_id']];
2843  }
2844  else
2845  {
2846  $tmp_vendor = ilObjUser::_lookupLogin($booking['b_vendor_id']);
2847  $user_title_cache[$booking['b_vendor_id']] = $tmp_vendor;
2848  }
2849  if(array_key_exists($booking['customer_id'], $user_title_cache))
2850  {
2851  $tmp_purchaser = $user_title_cache[$booking['customer_id']];
2852  }
2853  else
2854  {
2855  $tmp_purchaser_name = ilObjUser::_lookupName($booking['customer_id']);
2856  $tmp_purchaser_login = ilObjUser::_lookupLogin($booking['customer_id']);
2857  $tmp_purchaser_email = ilObjUser::_lookupEmail($booking['customer_id']);
2858  $tmp_purchaser = ''.$tmp_purchaser_name['firstname'].' '.$tmp_purchaser_name['lastname'].' ['.$tmp_purchaser_login.']';
2859  $user_title_cache[$booking['customer_id']] = $tmp_purchaser;
2860  }
2861 
2862  switch ($booking['b_pay_method'])
2863  {
2864  case $this->pobject->PAY_METHOD_BILL :
2865  $pay_method = $this->lng->txt('pays_bill');
2866  break;
2867  case $this->pobject->PAY_METHOD_BMF :
2868  $pay_method = $this->lng->txt('pays_bmf');
2869  break;
2870  case $this->pobject->PAY_METHOD_PAYPAL :
2871  $pay_method = $this->lng->txt('pays_paypal');
2872  break;
2873  }
2874  $worksheet->writeString($counter,0,ilExcelUtils::_convert_text($pay_method));
2875  $worksheet->writeString($counter,1,ilExcelUtils::_convert_text($booking['transaction']));
2876  $worksheet->writeString($counter,2,ilExcelUtils::_convert_text(($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted'))));
2877  $worksheet->writeString($counter,3,ilExcelUtils::_convert_text(($tmp_vendor != '' ? $tmp_vendor : $this->lng->txt('user_deleted'))));
2878  $worksheet->writeString($counter,4,ilExcelUtils::_convert_text(ilPaymentVendors::_getCostCenter($booking['b_vendor_id'])));
2879  $worksheet->writeString($counter,5,ilExcelUtils::_convert_text(($tmp_purchaser != '' ? $tmp_purchaser : $this->lng->txt('user_deleted'))));
2880  $worksheet->writeString($counter,6,ilExcelUtils::_convert_text($tmp_purchaser_email));
2881  $worksheet->writeString($counter,7,strftime('%Y-%m-%d %R',$booking['order_date']));
2882  $worksheet->writeString($counter,8,$booking['duration']);
2883  $worksheet->writeString($counter,9,ilExcelUtils::_convert_text($booking['price']));
2884 
2885  $payed_access = $booking['payed'] ?
2886  $this->lng->txt('yes') :
2887  $this->lng->txt('no');
2888 
2889  $payed_access .= '/';
2890  $payed_access .= $booking['access'] ?
2891  $this->lng->txt('yes') :
2892  $this->lng->txt('no');
2893 
2894  $worksheet->writeString($counter,10,$payed_access);
2895 
2896  $worksheet->writeString($counter,11,ilExcelUtils::_convert_text($booking['street']));
2897  $worksheet->writeString($counter,12,ilExcelUtils::_convert_text($booking['po_box']));
2898  $worksheet->writeString($counter,13,ilExcelUtils::_convert_text($booking['zipcode']));
2899  $worksheet->writeString($counter,14,ilExcelUtils::_convert_text($booking['city']));
2900  $worksheet->writeString($counter,15,ilExcelUtils::_convert_text($booking['country']));
2901 
2902  unset($tmp_obj);
2903  unset($tmp_vendor);
2904  unset($tmp_purchaser);
2905 
2906  ++$counter;
2907  }
2908  }
2909 
2910  function addVendorWorksheet(&$pewa)
2911  {
2912  include_once './Services/Excel/classes/class.ilExcelUtils.php';
2913 
2914  $this->object->initPaymentVendorsObject();
2915 
2916  $workbook =& $pewa->getWorkbook();
2917  $worksheet =& $workbook->addWorksheet(ilExcelUtils::_convert_text($this->lng->txt('pays_vendor')));
2918 
2919  // SHOW HEADER
2920  $worksheet->mergeCells(0,0,0,2);
2921  $worksheet->setColumn(1,0,32);
2922  $worksheet->setColumn(1,1,32);
2923  $worksheet->setColumn(1,2,32);
2924 
2925  $title = $this->lng->txt('bookings');
2926  $title .= ' '.$this->lng->txt('as_of').' ';
2927  $title .= strftime('%Y-%m-%d %R',time());
2928 
2929  $worksheet->writeString(0,0,$title,$pewa->getFormatTitle());
2930 
2931  $worksheet->writeString(1,0,ilExcelUtils::_convert_text($this->lng->txt('login')),$pewa->getFormatHeader());
2932  $worksheet->writeString(1,1,ilExcelUtils::_convert_text($this->lng->txt('fullname')),$pewa->getFormatHeader());
2933  $worksheet->writeString(1,2,ilExcelUtils::_convert_text($this->lng->txt('pays_cost_center')),$pewa->getFormatHeader());
2934 
2935  if(!count($vendors = $this->object->payment_vendors_obj->getVendors()))
2936  {
2937  return false;
2938  }
2939 
2940  $counter = 2;
2941  foreach($vendors as $vendor)
2942  {
2943  // GET USER OBJ
2944  if($tmp_obj = ilObjectFactory::getInstanceByObjId($vendor['vendor_id'],false))
2945  {
2946  $worksheet->writeString($counter,0,ilExcelUtils::_convert_text($tmp_obj->getLogin()));
2947  $worksheet->writeString($counter,1,ilExcelUtils::_convert_text($tmp_obj->getFullname()));
2948  $worksheet->writeString($counter,2,ilExcelUtils::_convert_text($vendor['cost_center']));
2949  }
2950  unset($tmp_obj);
2951  ++$counter;
2952  }
2953  }
2954 
2955  function payMethodsObject($askForDeletingAddresses = array(),$oConfirmationGUI = '')
2956  {
2957 
2958  include_once './payment/classes/class.ilPayMethods.php';
2959  include_once 'Services/Table/classes/class.ilTable2GUI.php';
2960  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
2961 
2962  global $rbacsystem, $ilCtrl;
2963 
2964  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.pays_pay_methods.html','payment');
2965 
2966  // MINIMUM ACCESS LEVEL = 'read'
2967  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2968  {
2969  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
2970  }
2971 
2972  if(count($askForDeletingAddresses))
2973  {
2974 
2975  $oConfirmationGUI = new ilConfirmationGUI();
2976 
2977  // set confirm/cancel commands
2978  $oConfirmationGUI->setFormAction($ilCtrl->getFormAction($this, "deleteAddressesForPaymethods"));
2979  $oConfirmationGUI->setHeaderText($this->lng->txt("info_delete_sure"));
2980  $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "paymethods");
2981  $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "deleteAddressesForPaymethods");
2982 
2983  foreach($askForDeletingAddresses as $pm)
2984  {
2985  $oConfirmationGUI->addHiddenItem('pm[]',$pm);
2986 
2987  if($pm == 'bill') $oConfirmationGUI->additem('paymethod','bill', $this->lng->txt('delete_addresses_bill'));
2988  if($pm == 'bmf') $oConfirmationGUI->additem('paymethod','bmf', $this->lng->txt('delete_addresses_bmf'));
2989  if($pm == 'paypal')$oConfirmationGUI->additem('paymethod','paypal', $this->lng->txt('delete_addresses_paypal'));
2990  if($pm == 'epay')$oConfirmationGUI->additem('paymethod','epay', $this->lng->txt('delete_addresses_epay'));
2991  }
2992 
2993  $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHtml());
2994  return true;
2995  }
2996 
2997  $tbl = new ilTable2GUI($this, 'paymethods');
2998  $tbl->setId('pay_methods_tbl');
2999  $tbl->setFormAction($this->ctrl->getFormAction($this), 'savePayMethods');
3000 
3001  $result = array();
3002 
3003  $counter = 0;
3004  $result[$counter][] = $this->lng->txt('pays_online');
3005  $result[$counter][] = $this->lng->txt('pays_bill');
3006  $result[$counter][] = ilUtil::formCheckbox((int) ilPayMethods::_enabled('pm_bill') ? 1 : 0,'pm_bill',1);
3007  $result[$counter][] = ilUtil::formCheckbox((int) ilPayMethods::_enabled('save_user_adr_bill') ? 1 : 0,'save_user_adr_bill',1);
3008  $this->ctrl->clearParameters($this);
3009  $counter++;
3010 
3011  $result[$counter][] = $this->lng->txt('pays_online');
3012  $result[$counter][] = $this->lng->txt('pays_bmf');
3013  $result[$counter][] = ilUtil::formCheckbox((int) ilPayMethods::_enabled('pm_bmf') ? 1 : 0,'pm_bmf',1);
3014  $result[$counter][] = ilUtil::formCheckbox((int) ilPayMethods::_enabled('save_user_adr_bmf') ? 1 : 0,'save_user_adr_bmf',1);
3015  $this->ctrl->clearParameters($this);
3016  $counter++;
3017 
3018  $result[$counter][]= $this->lng->txt('pays_online');
3019  $result[$counter][] = $this->lng->txt('pays_paypal');
3020  $result[$counter][] = ilUtil::formCheckbox((int) ilPayMethods::_enabled('pm_paypal') ? 1 : 0,'pm_paypal',1);
3021  $result[$counter][] = ilUtil::formCheckbox((int) ilPayMethods::_enabled('save_user_adr_paypal') ? 1 : 0,'save_user_adr_paypal',1);
3022  $this->ctrl->clearParameters($this);
3023  $counter++;
3024 
3025  $result[$counter][] = $this->lng->txt('pays_online');
3026  $result[$counter][] = $this->lng->txt('pays_epay');
3027  $result[$counter][] = ilUtil::formCheckbox((int) ilPayMethods::_enabled('pm_epay') ? 1 : 0,'pm_epay',1);
3028  $result[$counter][] = ilUtil::formCheckbox((int) ilPayMethods::_enabled('save_user_adr_epay') ? 1 : 0,'save_user_adr_epay',1);
3029  $this->ctrl->clearParameters($this);
3030 
3031  $tbl =& $this->__initTableGUI();
3032  $tpl =& $tbl->getTemplateObject();
3033 
3034  // SET FORMAACTION
3035  $tpl->setCurrentBlock('tbl_form_header');
3036 
3037  $tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this), 'savePayMethods');
3038 
3039  $tpl->parseCurrentBlock();
3040 
3041  $tbl->setTitle($this->lng->txt('pays_pay_methods'),'icon_pays.gif',$this->lng->txt('bookings'));
3042  $tbl->setHeaderNames(array($this->lng->txt('pays_online'),
3043  $this->lng->txt('paya_pay_method'),
3044  $this->lng->txt('enabled'),
3045  $this->lng->txt('save_customer_address')));
3046 
3047  $tbl->setHeaderVars(array('online',
3048  'pm',
3049  'enabled',
3050  'adr_check'),
3051  $this->ctrl->getParameterArray($this,'paymethods',false));
3052 
3053 
3054  $offset = $_GET['offset'];
3055 
3056  $tbl->disable('sort');
3057  $tbl->disable('linkbar');
3058  $tbl->setOffset($offset);
3059  $tbl->setLimit($_GET['limit']);
3060  $tbl->setMaxCount(count($result));
3061  $tbl->setFooter('tblfooter',$this->lng->txt('previous'),$this->lng->txt('next'));
3062  $tbl->setData($result);
3063 
3064  $tpl->setVariable('COLUMN_COUNTS',5);
3065  $tpl->setCurrentBlock('plain_buttons');
3066  $tpl->setVariable('PBTN_NAME','savePayMethods');
3067  $tpl->setVariable('PBTN_VALUE',$this->lng->txt('save'));
3068  $tpl->parseCurrentBlock();
3069  $tbl->render();
3070 
3071  $this->tpl->setVariable('PAYMETHODS',$tbl->tpl->get());
3072  return true;
3073 
3074 
3075  }
3076 
3078  {
3079  include_once './payment/classes/class.ilPayMethods.php';
3080  include_once './payment/classes/class.ilPaymentObject.php';
3081 
3082  global $rbacsystem;
3083 
3084  // MINIMUM ACCESS LEVEL = 'read'
3085  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
3086  {
3087  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
3088  }
3089 
3090  // check current payings
3091  if(ilPayMethods::_enabled('pm_bill') and !$_POST['pm_bill'])
3092  {
3094  {
3095  ilUtil::sendInfo($this->lng->txt('pays_objects_bill_exist'));
3096  $this->payMethodsObject();
3097 
3098  return false;
3099  }
3100  }
3101 
3102  if(ilPayMethods::_enabled('pm_bmf') and !$_POST['pm_bmf'])
3103  {
3105  {
3106  ilUtil::sendInfo($this->lng->txt('pays_objects_bmf_exist'));
3107  $this->payMethodsObject();
3108 
3109  return false;
3110  }
3111  }
3112 
3113  if(ilPayMethods::_enabled('pm_paypal') and !$_POST['pm_paypal'])
3114  {
3116  {
3117  ilUtil::sendInfo($this->lng->txt('pays_objects_paypal_exist'));
3118  $this->payMethodsObject();
3119 
3120  return false;
3121  }
3122  }
3123 
3124  if(ilPayMethods::_enabled('pm_epay') and !$_POST['pm_epay'])
3125  {
3127  {
3128  ilUtil::sendInfo($this->lng->txt('pays_objects_epay_exist'));
3129  $this->payMethodsObject();
3130 
3131  return false;
3132  }
3133  }
3134 
3136  if(isset($_POST['pm_bill']))
3137  {
3138  ilPayMethods::_enable('pm_bill');
3139  }
3140  if(isset($_POST['pm_bmf']))
3141  {
3142  ilPayMethods::_enable('pm_bmf');
3143  }
3144  if(isset($_POST['pm_paypal']))
3145  {
3146  ilPayMethods::_enable('pm_paypal');
3147  }
3148  if(isset($_POST['pm_epay']))
3149  {
3150  ilPayMethods::_enable('pm_epay');
3151  }
3152 
3153 
3154  // check: (enable/disable) save billing address of users for selected paymethod
3155 
3156  //get old values before saving new settings
3157  $save_user_adr_bill = ilPayMethods::_enabled('save_user_adr_bill');
3158  $save_user_adr_bmf = ilPayMethods::_enabled('save_user_adr_bmf');
3159  $save_user_adr_paypal = ilPayMethods::_enabled('save_user_adr_paypal');
3160  $save_user_adr_epay = ilPayMethods::_enabled('save_user_adr_epay');
3161 
3162  $askForDeletingAddresses = array();
3163 
3164  if(isset($_POST['save_user_adr_bill']))
3165  {
3166  ilPayMethods::_enable('save_user_adr_bill');
3167  }
3168  else if($save_user_adr_bill == true && $_POST['save_user_adr_bill'] == false)
3169  {
3170  //confirmation: sure delete all user address for this paymethod?
3171  $askForDeletingAddresses[] = 'bill';
3172 
3173  }
3174  if(isset($_POST['save_user_adr_bmf']))
3175  {
3176  ilPayMethods::_enable('save_user_adr_bmf');
3177  }
3178  else if($save_user_adr_bmf == true && $_POST['save_user_adr_bmf'] == false)
3179  {
3180  //confirmation: sure delete all user address for this paymethod?
3181  $askForDeletingAddresses[] = 'bmf';
3182 
3183  }
3184  if(isset($_POST['save_user_adr_paypal']))
3185  {
3186  ilPayMethods::_enable('save_user_adr_paypal');
3187  }
3188  else if($save_user_adr_paypal == true && $_POST['save_user_adr_paypal'] == false)
3189  {
3190  //confirmation: sure delete all user address for this paymethod?
3191  $askForDeletingAddresses[] = 'paypal';
3192  }
3193  if(isset($_POST['save_user_adr_epay']))
3194  {
3195  ilPayMethods::_enable('save_user_adr_epay');
3196  }
3197  else if($save_user_adr_epay == true && $_POST['save_user_adr_epay'] == false)
3198  {
3199  //confirmation: sure delete all user address for this paymethod?
3200  $askForDeletingAddresses[] = 'epay';
3201  }
3202 
3203  $this->payMethodsObject($askForDeletingAddresses,$oConfirmationGUI);
3204 
3205  ilUtil::sendSuccess($this->lng->txt('pays_updated_pay_method'));
3206 
3207  return true;
3208  }
3209 
3211  {
3212  unset($_SESSION['pays_vendor']);
3213  $this->vendorsObject();
3214 
3215  return true;
3216  }
3217 
3218  function deleteVendors()
3219  {
3220  include_once './payment/classes/class.ilPaymentBookings.php';
3221 
3222  if(!count($_POST['vendor']))
3223  {
3224  ilUtil::sendFailure($this->lng->txt('pays_no_vendor_selected'));
3225  $this->vendorsObject();
3226 
3227  return true;
3228  }
3229  // CHECK BOOKINGS
3230  foreach($_POST['vendor'] as $vendor)
3231  {
3233  {
3234  ilUtil::sendInfo($this->lng->txt('pays_active_bookings'));
3235  $this->vendorsObject();
3236 
3237  return true;
3238  }
3239  }
3240 
3241  $_SESSION['pays_vendor'] = $_POST['vendor'];
3242  ilUtil::sendQuestion($this->lng->txt('pays_sure_delete_selected_vendors'));
3243  $this->vendorsObject(true);
3244 
3245  return true;
3246  }
3248  {
3249  include_once './payment/classes/class.ilPaymentTrustees.php';
3250 
3251  global $rbacsystem;
3252 
3253  // MINIMUM ACCESS LEVEL = 'read'
3254  if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
3255  {
3256  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'),$this->ilias->error_obj->MESSAGE);
3257  }
3258 
3259  $this->object->initPaymentVendorsObject();
3260 
3261  foreach($_SESSION['pays_vendor'] as $vendor)
3262  {
3263  $this->object->payment_vendors_obj->delete($vendor);
3265  }
3266 
3267  ilUtil::sendInfo($this->lng->txt('pays_deleted_number_vendors').' '.count($_SESSION['pays_vendor']));
3268  unset($_SESSION['pays_vendor']);
3269 
3270  $this->vendorsObject();
3271 
3272  return true;
3273  }
3274 
3275  function editVendor()
3276  {
3277  global $rbacsystem;
3278 
3279  // MINIMUM ACCESS LEVEL = 'read'
3280  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
3281  {
3282  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
3283  }
3284 
3285  if(!count($_POST['vendor']))
3286  {
3287  ilUtil::sendInfo($this->lng->txt('pays_no_vendor_selected'));
3288  $this->vendorsObject();
3289 
3290  return true;
3291  }
3292  if(count($_POST['vendor']) > 1)
3293  {
3294  ilUtil::sendInfo($this->lng->txt('pays_too_many_vendors_selected'));
3295  $this->vendorsObject();
3296 
3297  return true;
3298  }
3299 
3300  $_SESSION['pays_vendor'] = $_POST['vendor'][0];
3301 
3302  $this->object->initPaymentVendorsObject();
3303 
3304  if (!is_array($this->object->payment_vendors_obj->vendors[$_SESSION['pays_vendor']]))
3305  {
3306  $this->vendorsObject();
3307 
3308  return true;
3309  }
3310 
3311  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pays_vendor.html','payment');
3312 
3313  $this->tpl->setVariable('VENDOR_FORMACTION',$this->ctrl->getFormAction($this));
3314 
3315  // set table header
3316  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_usr.gif'));
3317  $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_usr'));
3318  $this->tpl->setVariable('TITLE',$this->lng->txt('pays_vendor'));
3319 
3320  // set plain text variables
3321  $this->tpl->setVariable('TXT_VENDOR',$this->lng->txt('pays_vendor'));
3322  $this->tpl->setVariable('TXT_COST_CENTER',$this->lng->txt('pays_cost_center'));
3323 
3324  $this->tpl->setVariable('INPUT_VALUE',ucfirst($this->lng->txt('save')));
3325 
3326  // fill defaults
3327 
3328  $this->tpl->setVariable('VENDOR',
3329  ilObjUser::getLoginByUserId($this->object->payment_vendors_obj->vendors[$_SESSION['pays_vendor']]['vendor_id']), true);
3330  $this->tpl->setVariable('COST_CENTER',
3331  $this->error != '' && isset($_POST['cost_center'])
3332  ? ilUtil::prepareFormOutput($_POST['cost_center'],true)
3333  : ilUtil::prepareFormOutput($this->object->payment_vendors_obj->vendors[$_SESSION['pays_vendor']]['cost_center'],true));
3334 
3335  // Button
3336  $this->tpl->addBlockfile('BUTTONS', 'buttons', 'tpl.buttons.html');
3337  $this->tpl->setCurrentBlock('btn_cell');
3338  $this->tpl->setVariable('BTN_LINK', $this->ctrl->getLinkTarget($this, 'vendors'));
3339  $this->tpl->setVariable('BTN_TXT', $this->lng->txt('pay_bmf_back'));
3340  $this->tpl->parseCurrentBlock('btn_cell');
3341 
3342  }
3344  {
3345  global $rbacsystem;
3346 
3347  // MINIMUM ACCESS LEVEL = 'read'
3348  if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
3349  {
3350  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'),$this->ilias->error_obj->MESSAGE);
3351  }
3352 
3353  if(!count($_SESSION['pays_vendor']))
3354  {
3355  ilUtil::sendInfo($this->lng->txt('pays_no_vendor_selected'));
3356  $this->vendorsObject();
3357 
3358  return true;
3359  }
3360  if(count($_SESSION['pays_vendor']) > 1)
3361  {
3362  ilUtil::sendInfo($this->lng->txt('pays_too_many_vendors_selected'));
3363  $this->vendorsObject();
3364 
3365  return true;
3366  }
3367 
3368  $this->object->initPaymentVendorsObject();
3369 
3370  if (!is_array($this->object->payment_vendors_obj->vendors[$_SESSION['pays_vendor']]))
3371  {
3372  $this->vendorsObject();
3373 
3374  return true;
3375  }
3376 
3377  if ($_POST['cost_center'] == '')
3378  {
3379  $this->error = $this->lng->txt('pays_cost_center_not_valid');
3380  ilUtil::sendFailure($this->error);
3381  $_POST['vendor'] = array($_SESSION['pays_vendor']);
3382  $this->editVendor();
3383  return;
3384  }
3385 
3386  $this->object->initPaymentVendorsObject();
3387  $this->object->payment_vendors_obj->update($_SESSION['pays_vendor'], $_POST['cost_center']);
3388 
3389  unset($_SESSION['pays_vendor']);
3390 
3391  $this->vendorsObject();
3392 
3393  return true;
3394  }
3395 
3397  {
3398  global $rbacsystem, $tree;
3399 
3400  // MINIMUM ACCESS LEVEL = 'read'
3401  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
3402  {
3403  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
3404  }
3405 
3406  include_once './payment/classes/class.ilPaymentObjectSelector.php';
3407 
3408  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.paya_object_selector.html','payment');
3409  //$this->__showButton('statistic',$this->lng->txt('back'));
3410  $this->__showButton('statistic',$this->lng->txt('back'));
3411 
3412 
3413  ilUtil::sendInfo($this->lng->txt('paya_select_object_to_sell'));
3414 
3415  $exp = new ilPaymentObjectSelector($this->ctrl->getLinkTarget($this,'showObjectSelector'), strtolower(get_class($this)));
3416  $exp->setExpand($_GET['paya_link_expand'] ? $_GET['paya_link_expand'] : $tree->readRootId());
3417  $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showObjectSelector'));
3418 
3419  $exp->setOutput(0);
3420 
3421  $this->tpl->setVariable('EXPLORER',$exp->getOutput());
3422 
3423  return true;
3424  }
3425 
3426  function searchUserObject()
3427  {
3428  global $rbacsystem;
3429 
3430  // MINIMUM ACCESS LEVEL = 'read'
3431  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
3432  {
3433  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
3434  }
3435 
3436  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.pays_user_search.html','payment');
3437  $this->__showButton('vendors',$this->lng->txt('back'));
3438 
3439  $this->lng->loadLanguageModule('search');
3440 
3441  $this->tpl->setVariable('F_ACTION',$this->ctrl->getFormAction($this));
3442  $this->tpl->setVariable('SEARCH_ASSIGN_USR',$this->lng->txt('crs_search_members'));
3443  $this->tpl->setVariable('SEARCH_SEARCH_TERM',$this->lng->txt('search_search_term'));
3444  $this->tpl->setVariable('SEARCH_VALUE',$_SESSION['pays_search_str'] ? $_SESSION['pays_search_str'] : '');
3445  $this->tpl->setVariable('BTN2_VALUE',$this->lng->txt('cancel'));
3446  $this->tpl->setVariable('BTN1_VALUE',$this->lng->txt('search'));
3447 
3448  return true;
3449  }
3450 
3451  function searchObject()
3452  {
3453  global $rbacsystem,$tree;
3454 
3455  if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
3456  {
3457  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilias->error_obj->MESSAGE);
3458  }
3459 
3460  $_SESSION['pays_search_str'] = $_POST['search_str'] = $_POST['search_str'] ? $_POST['search_str'] : $_SESSION['pays_search_str'];
3461 
3462  if(!isset($_POST['search_str']))
3463  {
3464  ilUtil::sendInfo($this->lng->txt('crs_search_enter_search_string'));
3465  $this->searchUserObject();
3466 
3467  return false;
3468  }
3469  if(!count($result = $this->__search(ilUtil::stripSlashes($_POST['search_str']))))
3470  {
3471  ilUtil::sendInfo($this->lng->txt('crs_no_results_found'));
3472  $this->searchUserObject();
3473 
3474  return false;
3475  }
3476 
3477  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.pays_usr_selection.html','payment');
3478  $this->__showButton('searchUser',$this->lng->txt('crs_new_search'));
3479 
3480  $counter = 0;
3481  $f_result = array();
3482  foreach($result as $user)
3483  {
3484  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user['id'],false))
3485  {
3486  continue;
3487  }
3488  $f_result[$counter][] = ilUtil::formCheckbox(0,'user[]',$user['id']);
3489  $f_result[$counter][] = $tmp_obj->getLogin();
3490  $f_result[$counter][] = $tmp_obj->getLastname();
3491  $f_result[$counter][] = $tmp_obj->getFirstname();
3492 
3493  unset($tmp_obj);
3494  ++$counter;
3495  }
3496  $this->__showSearchUserTable($f_result);
3497 
3498  return true;
3499  }
3500  function addVendorObject()
3501  {
3502  global $rbacsystem;
3503 
3504  // MINIMUM ACCESS LEVEL = 'administrate'
3505  if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
3506  {
3507  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'),$this->ilias->error_obj->MESSAGE);
3508  }
3509  if(!$_POST['vendor_login'])
3510  {
3511  ilUtil::sendFailure($this->lng->txt('pays_no_username_given'));
3512  $this->vendorsObject();
3513 
3514  return true;
3515  }
3517  {
3518  ilUtil::sendFailure($this->lng->txt('pays_no_valid_username_given'));
3519  $this->vendorsObject();
3520 
3521  return true;
3522  }
3523 
3524  $this->object->initPaymentVendorsObject();
3525 
3526  if($this->object->payment_vendors_obj->isAssigned($usr_id))
3527  {
3528  ilUtil::sendFailure($this->lng->txt('pays_user_already_assigned'));
3529  $this->vendorsObject();
3530 
3531  return true;
3532  }
3533  $this->object->payment_vendors_obj->add($usr_id);
3534 
3535  ilUtil::sendSuccess($this->lng->txt('pays_added_vendor'));
3536  $this->vendorsObject();
3537 
3538  return true;
3539  }
3540 
3541  function addUserObject()
3542  {
3543  global $rbacsystem;
3544 
3545  // MINIMUM ACCESS LEVEL = 'administrate'
3546  if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
3547  {
3548  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'),$this->ilias->error_obj->MESSAGE);
3549  }
3550 
3551  $this->lng->loadLanguageModule('crs');
3552  if(!is_array($_POST['user']))
3553  {
3554  ilUtil::sendFailure($this->lng->txt('crs_no_users_selected'));
3555  $this->searchObject();
3556 
3557  return false;
3558  }
3559 
3560  $this->object->initPaymentVendorsObject();
3561 
3562  $already_assigned = $assigned = 0;
3563  foreach($_POST['user'] as $usr_id)
3564  {
3565  if($this->object->payment_vendors_obj->isAssigned($usr_id))
3566  {
3567  ++$already_assigned;
3568 
3569  continue;
3570  }
3571  $this->object->payment_vendors_obj->add($usr_id);
3572  ++$assigned;
3573 
3574  // TODO: SEND NOTIFICATION
3575  }
3576  $message = '';
3577  if($assigned)
3578  {
3579  $message .= $this->lng->txt('pays_assigned_vendors').' '.$assigned;
3580  }
3581  if($already_assigned)
3582  {
3583  $message .= '<br />'.$this->lng->txt('pays_already_assigned_vendors').' '.$already_assigned;
3584  }
3585 
3586  ilUtil::sendInfo($message);
3587  $this->vendorsObject();
3588 
3589  return true;
3590  }
3591 
3592 
3594  {
3595  if(!isset($_GET['sell_id']))
3596  {
3597  ilUtil::sendFailiure($this->lng->txt('paya_no_booking_id_given'));
3598  $this->showObjectSelectorObject();
3599 
3600  return false;
3601  }
3602 
3603  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.paya_user_search.html','payment');
3604  $this->__showButton('showObjectSelector',$this->lng->txt('back'));
3605 
3606  $this->lng->loadLanguageModule('search');
3607 
3608  $this->ctrl->setParameter($this, 'sell_id', $_GET['sell_id']);
3609  $this->tpl->setVariable('F_ACTION',$this->ctrl->getFormAction($this));
3610  $this->tpl->setVariable('SEARCH_ASSIGN_USR',$this->lng->txt('search_user'));
3611  $this->tpl->setVariable('SEARCH_SEARCH_TERM',$this->lng->txt('search_search_term'));
3612  $this->tpl->setVariable('SEARCH_VALUE',$_SESSION['paya_search_str_user_sp'] ? $_SESSION['paya_search_str_user_sp'] : '');
3613  $this->tpl->setVariable('BTN2_VALUE',$this->lng->txt('cancel'));
3614  $this->tpl->setVariable('BTN1_VALUE',$this->lng->txt('search'));
3615  $this->tpl->setVariable('SEARCH','performSearchSP');
3616  // $this->tpl->setVariable('CANCEL','statistic');
3617  $this->tpl->setVariable('CANCEL','bookings');
3618 
3619  return true;
3620  }
3621 
3623  {
3624  // SAVE it to allow sort in tables
3625  $_SESSION['paya_search_str_user_sp'] = $_POST['search_str'] = $_POST['search_str'] ? $_POST['search_str'] : $_SESSION['paya_search_str_user_sp'];
3626 
3627  if(!trim($_POST['search_str']))
3628  {
3629  ilUtil::sendFailure($this->lng->txt('search_no_search_term'));
3630  $this->statistics();
3631 
3632  return false;
3633  }
3634  if(!count($result = $this->__search(ilUtil::stripSlashes($_POST['search_str']))))
3635  {
3636  ilUtil::sendInfo($this->lng->txt('search_no_match'));
3637  $this->searchUserSPObject();
3638 
3639  return false;
3640  }
3641 
3642  if(!isset($_GET['sell_id']))
3643  {
3644  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
3645  $this->showObjectSelectorObject();
3646 
3647  return false;
3648  }
3649 
3650  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.paya_usr_selection.html','payment');
3651  $this->ctrl->setParameter($this, 'sell_id', $_GET['sell_id']);
3652  $this->__showButton('searchUserSP',$this->lng->txt('back'));
3653 
3654  $counter = 0;
3655  $f_result = array();
3656  foreach($result as $user)
3657  {
3658  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user['id'],false))
3659  {
3660  continue;
3661  }
3662  $f_result[$counter][] = ilUtil::formRadiobutton(0,'user_id',$user['id']);
3663  $f_result[$counter][] = $tmp_obj->getLogin();
3664  $f_result[$counter][] = $tmp_obj->getFirstname();
3665  $f_result[$counter][] = $tmp_obj->getLastname();
3666 
3667  unset($tmp_obj);
3668  ++$counter;
3669  }
3670  $this->__showSearchUserSPTable($f_result);
3671  }
3672 
3674  {
3675  if ($_POST['sell_id'] != '') $_GET['sell_id'] = $_POST['sell_id'];
3676  if ($_GET['user_id'] != '') $_POST['user_id'] = $_GET['user_id'];
3677 
3678  if(!isset($_GET['sell_id']))
3679  {
3680  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
3681  $this->showObjectSelectorObject();
3682 
3683  return true;
3684  }
3685 
3686  if(!isset($_POST['user_id']))
3687  {
3688  ilUtil::sendInfo($this->lng->txt('paya_no_user_id_given'));
3689  $this->searchUserSPObject();
3690 
3691  return true;
3692  }
3693 
3694  $this->ctrl->setParameter($this, 'sell_id', $_GET['sell_id']);
3695  $this->__showButton('searchUserSP',$this->lng->txt('back'));
3696 
3697  $this->ctrl->setParameter($this, 'user_id', $_POST['user_id']);
3698 
3699  $pObjectId = ilPaymentObject::_lookupPobjectId($_GET['sell_id']);
3700  $obj =& new ilPaymentObject($this->user_obj, $pObjectId);
3701 
3702  // get obj
3703  $tmp_obj =& ilObjectFactory::getInstanceByRefId($_GET['sell_id'], false);
3704  if($tmp_obj)
3705  {
3706  $tmp_object['title'] = $tmp_obj->getTitle();
3707  }
3708  else
3709  {
3710  $tmp_object['title'] = $this->lng->txt('object_not_found');
3711  }
3712  // get customer_obj
3713  $tmp_user =& ilObjectFactory::getInstanceByObjId($_POST['user_id']);
3714  // get vendor_obj
3715  $tmp_vendor =& ilObjectFactory::getInstanceByObjId($obj->getVendorId());
3716 
3717  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_add_customer.html','payment');
3718 
3719  $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
3720 
3721  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_usr.gif'));
3722  $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_usr'));
3723  $this->tpl->setVariable('TITLE',$tmp_user->getFullname().' ['.$tmp_user->getLogin().']');
3724 
3725  // TXT
3726  $this->tpl->setVariable('TXT_TRANSACTION',$this->lng->txt('paya_transaction'));
3727  $this->tpl->setVariable('TRANSACTION',ilUtil::prepareFormOutput($_POST['transaction'], true));
3728 
3729  $this->tpl->setVariable('TXT_OB JECT',$this->lng->txt('title'));
3730  $this->tpl->setVariable('OBJECT', $tmp_object['title']);
3731 
3732  $this->tpl->setVariable('TXT_VENDOR',$this->lng->txt('paya_vendor'));
3733  $this->tpl->setVariable('VENDOR',$tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']');
3734 
3735  $this->tpl->setVariable('TXT_PAY_METHOD',$this->lng->txt('paya_pay_method'));
3736  $this->tpl->setVariable('TXT_PAY_METHOD_BILL',$this->lng->txt('pays_bill'));
3737  $this->tpl->setVariable('TXT_PAY_METHOD_BMF',$this->lng->txt('pays_bmf'));
3738  $this->tpl->setVariable('TXT_PAY_METHOD_PAYPAL',$this->lng->txt('pays_paypal'));
3739  $this->tpl->setVariable('PAY_METHOD_'.$_POST['pay_method'], ' selected');
3740 
3741  $this->tpl->setVariable('TXT_ORDER_DATE',$this->lng->txt('paya_order_date'));
3742  $this->tpl->setVariable('ORDER_DATE',ilDatePresentation::formatDate(new ilDateTime(time(),IL_CAL_UNIX)));
3743 
3744  $this->tpl->setVariable('TXT_DURATION',$this->lng->txt('duration'));
3745  include_once './payment/classes/class.ilPaymentPrices.php';
3746  $prices_obj =& new ilPaymentPrices($pObjectId);
3747  if (is_array($prices = $prices_obj->getPrices()))
3748  {
3749  foreach($prices as $price)
3750  {
3751  $this->tpl->setCurrentBlock('duration_loop');
3752  if ($_POST['duration'] == $price['price_id']) $this->tpl->setVariable('DURATION_LOOP_SELECTED', ' selected');
3753  $this->tpl->setVariable('DURATION_LOOP_ID', $price['price_id']);
3754  $this->tpl->setVariable('DURATION_LOOP_NAME', $price['duration'].' '.$this->lng->txt('paya_months').', '.ilPaymentPrices::_getPriceString($price['price_id']));
3755  $this->tpl->parseCurrentBlock();
3756  }
3757  }
3758 
3759  $this->tpl->setVariable('TXT_PAYED',$this->lng->txt('paya_payed'));
3760  if ($_POST['payed'] == 1) $this->tpl->setVariable('PAYED_1', ' selected');
3761  $this->tpl->setVariable('TXT_ACCESS',$this->lng->txt('paya_access'));
3762  if ($_POST['access'] == 1) $this->tpl->setVariable('ACCESS_1', ' selected');
3763 
3764  $this->tpl->setVariable('TXT_NO',$this->lng->txt('no'));
3765  $this->tpl->setVariable('TXT_YES',$this->lng->txt('yes'));
3766  $this->tpl->setVariable('TXT_SAVE',$this->lng->txt('save'));
3767  $this->tpl->setVariable('TXT_CANCEL',$this->lng->txt('cancel'));
3768  //$this->tpl->setVariable('STATISTICS','statistic');
3769  $this->tpl->setVariable('STATISTICS','bookings');
3770 
3771  }
3772 
3774  {
3775  global $ilias, $ilUser,$ilObjDataCache;
3776 
3777  if(!isset($_GET['sell_id']))
3778  {
3779  ilUtil::sendInfo($this->lng->txt('paya_error_no_object_id_given'));
3780  $this->showObjectSelectorObject();
3781 
3782  return true;
3783  }
3784 
3785  if(!isset($_GET['user_id']))
3786  {
3787  ilUtil::sendInfo($this->lng->txt('paya_error_no_user_id_given'));
3788  $this->searchUserSPObject();
3789 
3790  return true;
3791  }
3792 
3793  if ($_POST['pay_method'] == '' ||
3794  $_POST['duration'] == '')
3795  {
3796  ilUtil::sendInfo($this->lng->txt('paya_error_mandatory_fields'));
3797  $this->addCustomerObject();
3798 
3799  return true;
3800  }
3801 
3802  $pObjectId = ilPaymentObject::_lookupPobjectId($_GET['sell_id']);
3803  $obj =& new ilPaymentObject($this->user_obj, $pObjectId);
3804 
3805  $this->__initBookingObject();
3806 
3807  $inst_id_time = $ilias->getSetting('inst_id').'_'.$this->user_obj->getId().'_'.substr((string) time(),-3);
3808  $transaction = $inst_id_time.substr(md5(uniqid(rand(), true)), 0, 4);
3809  $this->booking_obj->setTransaction($transaction);
3810  $this->booking_obj->setTransactionExtern($_POST['transaction']);
3811  $this->booking_obj->setPobjectId($pObjectId);
3812  $this->booking_obj->setCustomerId($_GET['user_id']);
3813  $this->booking_obj->setVendorId($obj->getVendorId());
3814  $this->booking_obj->setPayMethod((int) $_POST['pay_method']);
3815  $this->booking_obj->setOrderDate(time());
3816  include_once './payment/classes/class.ilPaymentPrices.php';
3817  $price = ilPaymentPrices::_getPrice($_POST['duration']);
3818  $this->booking_obj->setDuration($price['duration']);
3819  $this->booking_obj->setPrice(ilPaymentPrices::_getPriceString($_POST['duration']));
3820  $this->booking_obj->setAccess((int) $_POST['access']);
3821  $this->booking_obj->setPayed((int) $_POST['payed']);
3822  $this->booking_obj->setVoucher('');
3823  $obj_id = $ilObjDataCache->lookupObjId($obj->getRefId());
3824  $obj_type = $ilObjDataCache->lookupType($obj_id);
3825  $obj_title = $ilObjDataCache->lookupTitle($obj_id);
3826 
3827  include_once 'Services/Payment/classes/class.ilShopVatsList.php';
3828  $oVAT = new ilShopVats((int)$obj->getVatId());
3829  $obj_vat_rate = $oVAT->getRate();
3830  $obj_vat_unit = $obj->getVat($this->booking_obj->getPrice());
3831 
3832  $this->booking_obj->setObjectTitle($obj_title);
3833  $this->booking_obj->setVatRate($obj_vat_rate);
3834  $this->booking_obj->setVatUnit($obj_vat_unit);
3835 
3836  include_once './payment/classes/class.ilPayMethods.php';
3837  $save_user_adr_bill = (int) ilPayMethods::_enabled('save_user_adr_bill') ? 1 : 0;
3838  $save_user_adr_bmf = (int) ilPayMethods::_enabled('save_user_adr_bmf') ? 1 : 0;
3839  $save_user_adr_paypal =(int) ilPayMethods::_enabled('save_user_adr_paypal') ? 1 : 0;
3840  $save_user_adr_epay =(int) ilPayMethods::_enabled('save_user_adr_epay') ? 1 : 0;
3841 
3842  if($save_user_adr_bill == 1 || $save_user_adr_bmf == 1
3843  || $save_user_adr_paypal == 1 || $save_user_adr_epay == 1)
3844  {
3845  global $ilObjUser;
3846  $user_id[] = $_GET["user_id"];
3847 
3848  $cust_obj = ilObjUser::_readUsersProfileData($user_id);
3849 
3850  $this->booking_obj->setStreet($cust_obj[$_GET["user_id"]]['street'],'');
3851 
3852  $this->booking_obj->setZipcode($cust_obj[$_GET["user_id"]]['zipcode']);
3853  $this->booking_obj->setCity($cust_obj[$_GET["user_id"]]['city']);
3854  $this->booking_obj->setCountry($cust_obj[$_GET["user_id"]]['country']);
3855  }
3856 
3857  if($this->booking_obj->add())
3858  {
3859  ilUtil::sendInfo($this->lng->txt('paya_customer_added_successfully'));
3860  $this->statisticObject();
3861  }
3862  else
3863  {
3864  ilUtil::sendInfo($this->lng->txt('paya_error_adding_customer'));
3865  $this->addCustomerObject();
3866  }
3867 
3868  return true;
3869  }
3870 
3871  // PRIVATE
3872  function __setSection($a_section)
3873  {
3874  $this->section = $a_section;
3875  }
3876  function __getSection()
3877  {
3878  return $this->section;
3879  }
3880  function __setMainSection($a_section)
3881  {
3882  $this->mainSection = $a_section;
3883  }
3884  function __getMainSection()
3885  {
3886  return $this->mainSection;
3887  }
3888 
3889  private function __buildSettingsButtons()
3890  {
3891  if($this->__getMainSection() == $this->SETTINGS)
3892  {
3893  $this->tabs_gui->addSubTabTarget('pays_general',
3894  $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'generalSettings'),
3895  '',
3896  '',
3897  '',
3898  $this->__getSection() == $this->SECTION_GENERAL ? true : false);
3899  $this->tabs_gui->addSubTabTarget('pays_bmf',
3900  $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'bmfSettings'),
3901  '',
3902  '',
3903  '',
3904  $this->__getSection() == $this->SECTION_BMF ? true : false);
3905  $this->tabs_gui->addSubTabTarget('pays_paypal',
3906  $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'paypalSettings'),
3907  '',
3908  '',
3909  '',
3910  $this->__getSection() == $this->SECTION_PAYPAL ? true : false);
3911 
3912  $this->tabs_gui->addSubTabTarget('pays_epay',
3913  $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'epaySettings'),
3914  '',
3915  '',
3916  '',
3917  $this->__getSection() == $this->SECTION_EPAY ? true : false);
3918  $this->tabs_gui->addSubTabTarget('pays_erp',
3919  $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'erpSettings'),
3920  '',
3921  '',
3922  '',
3923  $this->__getSection() == $this->SECTION_ERP ? true : false);
3924  }
3925  }
3926 
3927  public function showCustomerTable()
3928  {
3929  if(!isset($_GET['booking_id']))
3930  {
3931  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
3932  $this->showStatistics();
3933 
3934  return true;
3935  }
3936 
3937  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_edit_statistic.html','payment');
3938  $this->ctrl->setParameter($this,'booking_id',(int) $_GET['booking_id']);
3939  $this->tpl->setCurrentBlock('CUSTOMER_DATA');
3940 
3941  $this->__initBookingObject();
3942  $bookings = $this->booking_obj->getBookings();
3943 
3944  $booking = $bookings[(int) $_GET['booking_id']];
3945 
3946  // get customer_obj
3947  $tmp_user = ilObjectFactory::getInstanceByObjId($booking['customer_id'], false);
3948 
3949  $this->tpl->setVariable('TYPE_IMG_2',ilUtil::getImagePath('icon_usr.gif'));
3950  $this->tpl->setVariable('ALT_IMG_2',$this->lng->txt('obj_usr'));
3951  if(is_object($tmp_user))
3952  {
3953  $this->tpl->setVariable('TITLE_2', $tmp_user->getFullname().' ['.$tmp_user->getLogin().']');
3954  }
3955  else
3956  {
3957  $this->tpl->setVariable('TITLE_2', $this->lng->txt('user_deleted'));
3958  }
3959 
3960  // TXT
3961  $pObj = new ilPaymentObject($this->user_obj, $booking['pobject_id']);
3962 
3963  $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($pObj->getRefId()));
3964 
3965  $this->tpl->setVariable('TXT_OBJECT',$this->lng->txt('title'));
3966  $this->tpl->setVariable('OBJECT', ($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted')));
3967 
3968  $this->tpl->setVariable('TXT_EMAIL',$this->lng->txt('email'));
3969  $this->tpl->setVariable('TXT_STREET',$this->lng->txt('street'));
3970  $this->tpl->setVariable('TXT_PO_BOX',$this->lng->txt('pay_bmf_po_box'));
3971  $this->tpl->setVariable('TXT_ZIPCODE',$this->lng->txt('zipcode'));
3972  $this->tpl->setVariable('TXT_CITY',$this->lng->txt('city'));
3973  $this->tpl->setVariable('TXT_COUNTRY',$this->lng->txt('country'));
3974 
3975  $email = (!isset($tmp_user)) ? $this->lng->txt('user_deleted') : $tmp_user->getEmail();
3976  $this->tpl->setVariable('EMAIL',$email);
3977  $this->tpl->setVariable('STREET',$booking['street']);
3978  $this->tpl->setVariable('PO_BOX',$booking['po_box']);
3979  $this->tpl->setVariable('ZIPCODE',$booking['zipcode']);
3980  $this->tpl->setVariable('CITY',$booking['city']);
3981  $this->tpl->setVariable('COUNTRY',$booking['country']);
3982 
3983  $this->tpl->parseCurrentBlock();
3984  }
3985 
3986  function __showStatisticTable($a_result_set)
3987  {
3988  $tbl =& $this->__initTableGUI();
3989  $tpl =& $tbl->getTemplateObject();
3990 
3991  // SET FORMAACTION
3992  $tpl->setCurrentBlock('tbl_form_header');
3993 
3994  $tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
3995  $tpl->parseCurrentBlock();
3996 
3997 
3998  // $tbl->setTitle($this->lng->txt('paya_statistic'),'icon_pays.gif',$this->lng->txt('paya_statistic'));
3999  $tbl->setTitle($this->lng->txt('bookings'),'icon_pays.gif',$this->lng->txt('bookings'));
4000  $tbl->setHeaderNames(array($this->lng->txt('paya_transaction'),
4001  $this->lng->txt('title'),
4002  $this->lng->txt('paya_vendor'),
4003  $this->lng->txt('paya_customer'),
4004  $this->lng->txt('paya_order_date'),
4005  $this->lng->txt('duration'),
4006  $this->lng->txt('price_a'),
4007  $this->lng->txt('paya_coupons_coupons'),
4008  $this->lng->txt('paya_payed_access'),
4009  ''));
4010 
4011  $tbl->setHeaderVars(array('transaction',
4012  'title',
4013  'vendor',
4014  'customer',
4015  'order_date',
4016  'duration',
4017  'price',
4018  'discount',
4019  'payed_access',
4020  'options'),
4021  $this->ctrl->getParameterArray($this,'statistic',false));
4022 
4023 
4024  $offset = $_GET['offset'];
4025  $order = $_GET['sort_by'];
4026  $direction = $_GET['sort_order'] ? $_GET['sort_order'] : 'desc';
4027 
4028  $tbl->setOrderColumn($order,'order_date');
4029  $tbl->setOrderDirection($direction);
4030  $tbl->setOffset($offset);
4031  $tbl->setLimit($_GET['limit']);
4032  $tbl->setMaxCount(count($a_result_set));
4033  $tbl->setFooter('tblfooter',$this->lng->txt('previous'),$this->lng->txt('next'));
4034  $tbl->setData($a_result_set);
4035 
4036  $tpl->setVariable('COLUMN_COUNTS',10);
4037  $tpl->setCurrentBlock('plain_buttons');
4038  $tpl->setVariable('PBTN_NAME','exportVendors');
4039  $tpl->setVariable('PBTN_VALUE',$this->lng->txt('excel_export'));
4040  $tpl->parseCurrentBlock();
4041  $tbl->render();
4042 
4043  $this->tpl->setVariable('STATISTIC_TABLE',$tbl->tpl->get());
4044 
4045  return true;
4046  }
4047 
4049  {
4050  include_once './payment/classes/class.ilPaymentBookings.php';
4051 
4052  $this->booking_obj =& new ilPaymentBookings($this->user_obj->getId(),true);
4053  }
4054 
4055  function __showVendorsTable($a_result_set)
4056  {
4057  $actions = array(
4058  'editVendorObject' => $this->lng->txt('pays_edit_vendor'),
4059  'deleteVendorsObject' => $this->lng->txt('pays_delete_vendor')
4060  );
4061 
4062  $tbl =& $this->__initTableGUI();
4063  $tpl =& $tbl->getTemplateObject();
4064 
4065  // SET FORMAACTION
4066  $tpl->setCurrentBlock('tbl_form_header');
4067 
4068  $tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
4069  $tpl->parseCurrentBlock();
4070 
4071  $tpl->setCurrentBlock('tbl_action_row');
4072 
4073  $tpl->setCurrentBlock('input_text');
4074  $tpl->setVariable('PB_TXT_NAME','vendor_login');
4075  $tpl->parseCurrentBlock();
4076 
4077  $tpl->setCurrentBlock('plain_button');
4078  $tpl->setVariable('PBTN_NAME','addVendor');
4079  $tpl->setVariable('PBTN_VALUE',$this->lng->txt('pays_add_vendor'));
4080  $tpl->parseCurrentBlock();
4081  $tpl->setCurrentBlock('plain_buttons');
4082  $tpl->parseCurrentBlock();
4083 
4084  $tpl->setVariable('COLUMN_COUNTS',4);
4085 
4086  $tpl->setVariable('IMG_ARROW', ilUtil::getImagePath('arrow_downright.gif'));
4087 
4088  $tpl->setCurrentBlock('tbl_action_select');
4089  $tpl->setVariable('SELECT_ACTION',ilUtil::formSelect(1,'action',$actions,false,true));
4090  $tpl->setVariable('BTN_NAME','gateway');
4091  $tpl->setVariable('BTN_VALUE',$this->lng->txt('execute'));
4092  $tpl->parseCurrentBlock();
4093  $tpl->setCurrentBlock('tbl_action_row');
4094  $tpl->setVariable('TPLPATH',$this->tpl->tplPath);
4095  $tpl->parseCurrentBlock();
4096 
4097  $tbl->setTitle($this->lng->txt('vendors'),'icon_usr.gif',$this->lng->txt('vendors'));
4098  $tbl->setHeaderNames(array('',
4099  $this->lng->txt('pays_vendor'),
4100  $this->lng->txt('pays_cost_center'),
4101  $this->lng->txt('pays_number_bookings')));
4102  $tbl->setHeaderVars(array('',
4103  'login',
4104  'cost_center',
4105  'bookings'),
4106  array('ref_id' => $this->object->getRefId(),
4107  'cmd' => 'vendors',
4108  'update_members' => 1,
4109  'baseClass' => 'ilAdministrationGUI',
4110  'cmdClass' => 'ilobjpaymentsettingsgui',
4111  'cmdNode' => $_GET['cmdNode']));
4112 # $tbl->setColumnWidth(array('4%','48%','25%','24%'));
4113 
4114  $tpl->setVariable('COLUMN_COUNTS',9);
4115  $tpl->setCurrentBlock('plain_buttons');
4116  $tpl->setVariable('PBTN_NAME','exportVendors');
4117  $tpl->setVariable('PBTN_VALUE',$this->lng->txt('excel_export'));
4118  $tpl->parseCurrentBlock();
4119 
4120  $this->__setTableGUIBasicData($tbl,$a_result_set);
4121  $tbl->render();
4122 
4123  $this->tpl->setVariable('VENDOR_TABLE',$tbl->tpl->get());
4124 
4125  return true;
4126  }
4127 
4128 
4129  function __showSearchUserTable($a_result_set,$a_cmd = 'search')
4130  {
4131  $tbl =& $this->__initTableGUI();
4132  $tpl =& $tbl->getTemplateObject();
4133 
4134 
4135  // SET FORMACTION
4136  $tpl->setCurrentBlock('tbl_form_header');
4137  $tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
4138  $tpl->parseCurrentBlock();
4139 
4140  $tpl->setCurrentBlock('tbl_action_btn');
4141  $tpl->setVariable('BTN_NAME','addUser');
4142  $tpl->setVariable('BTN_VALUE',$this->lng->txt('add'));
4143  $tpl->parseCurrentBlock();
4144 
4145  $tpl->setCurrentBlock('tbl_action_btn');
4146  $tpl->setVariable('BTN_NAME','vendors');
4147  $tpl->setVariable('BTN_VALUE',$this->lng->txt('cancel'));
4148  $tpl->parseCurrentBlock();
4149 
4150  $tpl->setCurrentBlock('tbl_action_row');
4151  $tpl->setVariable('COLUMN_COUNTS',5);
4152  $tpl->setVariable('IMG_ARROW',ilUtil::getImagePath('arrow_downright.gif'));
4153  $tpl->parseCurrentBlock();
4154 
4155  $tbl->setTitle($this->lng->txt('pays_header_select_vendor'),'icon_usr.gif',$this->lng->txt('pays_header_select_vendor'));
4156  $tbl->setHeaderNames(array('',
4157  $this->lng->txt('login'),
4158  $this->lng->txt('firstname'),
4159  $this->lng->txt('lastname')));
4160  $tbl->setHeaderVars(array('',
4161  'login',
4162  'firstname',
4163  'lastname'),
4164  array('ref_id' => $this->object->getRefId(),
4165  'cmd' => $a_cmd,
4166  'cmdClass' => 'ilobjpaymentsettingsgui',
4167  'cmdNode' => $_GET['cmdNode']));
4168 
4169  $tbl->setColumnWidth(array('3%','32%','32%','32%'));
4170 
4171  $this->__setTableGUIBasicData($tbl,$a_result_set);
4172  $tbl->render();
4173 
4174  $this->tpl->setVariable('SEARCH_RESULT_TABLE',$tbl->tpl->get());
4175 
4176  return true;
4177  }
4178 
4179  function __showButton($a_cmd,$a_text,$a_target = '')
4180  {
4181  $this->tpl->addBlockfile('BUTTONS', 'buttons', 'tpl.buttons.html');
4182 
4183  // display button
4184  $this->tpl->setCurrentBlock('btn_cell');
4185  $this->tpl->setVariable('BTN_LINK',$this->ctrl->getLinkTarget($this,$a_cmd));
4186  $this->tpl->setVariable('BTN_TXT',$a_text);
4187  if($a_target)
4188  {
4189  $this->tpl->setVariable('BTN_TARGET',$a_target);
4190  }
4191 
4192  $this->tpl->parseCurrentBlock();
4193  }
4194 
4195  function &__initTableGUI()
4196  {
4197  include_once './Services/Table/classes/class.ilTableGUI.php';
4198 
4199  return new ilTableGUI(0,false);
4200  }
4201 
4202  function __setTableGUIBasicData(&$tbl,&$result_set,$from = '')
4203  {
4204  $offset = $_GET['offset'];
4205  $order = $_GET['sort_by'];
4206  $direction = $_GET['sort_order'];
4207 
4208  $tbl->setOrderColumn($order);
4209  $tbl->setOrderDirection($direction);
4210  $tbl->setOffset($offset);
4211  $tbl->setLimit($_GET['limit']);
4212  $tbl->setMaxCount(count($result_set));
4213  $tbl->setFooter('tblfooter',$this->lng->txt('previous'),$this->lng->txt('next'));
4214  $tbl->setData($result_set);
4215  }
4216 
4217  function __search($a_search_string)
4218  {
4219  include_once('./classes/class.ilSearch.php');
4220 
4221  $this->lng->loadLanguageModule('content');
4222 
4223  $search =& new ilSearch($_SESSION['AccountId']);
4224  $search->setPerformUpdate(false);
4225  $search->setSearchString(ilUtil::stripSlashes($a_search_string));
4226  $search->setCombination('and');
4227  $search->setSearchFor(array(0 => 'usr'));
4228  $search->setSearchType('new');
4229 
4230  if($search->validate($message))
4231  {
4232  $search->performSearch();
4233  }
4234  else
4235  {
4236  ilUtil::sendInfo($message,true);
4237  $this->ctrl->redirect($this,'searchUser');
4238  }
4239  return $search->getResultByType('usr');
4240  }
4241 
4242  function __searchSP($a_search_string)
4243  {
4244  include_once('./classes/class.ilSearch.php');
4245 
4246  $this->lng->loadLanguageModule('content');
4247 
4248  $search =& new ilSearch($this->user_obj->getId());
4249  $search->setPerformUpdate(false);
4250  $search->setSearchString(ilUtil::stripSlashes($a_search_string));
4251  $search->setCombination('and');
4252  $search->setSearchFor(array(0 => 'usr'));
4253  $search->setSearchType('new');
4254 
4255  if($search->validate($message))
4256  {
4257  $search->performSearchSPObject();
4258  }
4259  else
4260  {
4261  ilUtil::sendInfo($message,true);
4262  $this->ctrl->redirect($this,'searchUserSP');
4263  }
4264  return $search->getResultByType('usr');
4265  }
4266  function __showSearchUserSPTable($a_result_set)
4267  {
4268  $tbl =& $this->initTableGUI();
4269  $tpl =& $tbl->getTemplateObject();
4270 
4271 
4272  // SET FORMACTION
4273  $tpl->setCurrentBlock('tbl_form_header');
4274  $this->ctrl->setParameter($this, 'sell_id', $_GET['sell_id']);
4275  $tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
4276  $tpl->parseCurrentBlock();
4277 
4278  $tpl->setCurrentBlock('tbl_action_btn');
4279  $tpl->setVariable('BTN_NAME','addCustomer');
4280  $tpl->setVariable('BTN_VALUE',$this->lng->txt('add'));
4281  $tpl->parseCurrentBlock();
4282 
4283  $tpl->setCurrentBlock('tbl_action_btn');
4284  $tpl->setVariable('BTN_NAME','statistic');
4285  $tpl->setVariable('BTN_VALUE',$this->lng->txt('cancel'));
4286  $tpl->parseCurrentBlock();
4287 
4288  $tpl->setCurrentBlock('tbl_action_row');
4289  $tpl->setVariable('COLUMN_COUNTS',5);
4290  $tpl->setVariable('IMG_ARROW',ilUtil::getImagePath('arrow_downright.gif'));
4291  $tpl->parseCurrentBlock();
4292 
4293  $tbl->setTitle($this->lng->txt('users'),'icon_usr.gif',$this->lng->txt('crs_header_edit_members'));
4294  $tbl->setHeaderNames(array('',
4295  $this->lng->txt('login'),
4296  $this->lng->txt('firstname'),
4297  $this->lng->txt('lastname')));
4298  $this->ctrl->setParameter($this, 'cmd', 'addCustomer');
4299  $header_params = $this->ctrl->getParameterArray($this,'');
4300  $tbl->setHeaderVars(array('',
4301  'login',
4302  'firstname',
4303  'lastname'), $header_params);
4304  /*
4305  array('cmd' => 'performSearch',
4306  'cmdClass' => 'ilpaymentstatisticgui',
4307  'cmdNode' => $_GET['cmdNode']));
4308  */
4309 
4310  $tbl->setColumnWidth(array('3%','32%','32%','32%'));
4311 
4312  $this->setTableGUIBasicData($tbl,$a_result_set);
4313  $tbl->render();
4314 
4315  $this->tpl->setVariable('SEARCH_RESULT_TABLE',$tbl->tpl->get());
4316 
4317  return true;
4318  }
4319 
4320  function &initTableGUI()
4321  {
4322  include_once './Services/Table/classes/class.ilTableGUI.php';
4323 
4324  return new ilTableGUI(0,false);
4325  }
4326  function setTableGUIBasicData(&$tbl,&$result_set,$a_default_order_column = '')
4327  {
4328 
4329  $offset = $_GET['offset'];
4330  $order = $_GET['sort_by'];
4331  $direction = $_GET['sort_order'];
4332 
4333  $tbl->setOrderColumn($order,$a_default_order_column);
4334  $tbl->setOrderDirection($direction);
4335  $tbl->setOffset($offset);
4336  $tbl->setLimit($_GET['limit']);
4337  $tbl->setMaxCount(count($result_set));
4338  $tbl->setFooter('tblfooter',$this->lng->txt('previous'),$this->lng->txt('next'));
4339  $tbl->setData($result_set);
4340  }
4341 
4342  public function vatsObject()
4343  {
4344  global $ilAccess;
4345 
4346  if(!$ilAccess->checkAccess('read', '', $this->object->getRefId()))
4347  {
4348  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilias->error_obj->MESSAGE);
4349  }
4350 
4351  include_once 'Services/Table/classes/class.ilTable2GUI.php';
4352  $tbl = new ilTable2GUI($this, 'vats');
4353  $tbl->setId('pay_vats_tbl');
4354  $tbl->setFormAction($this->ctrl->getFormAction($this), 'createVat');
4355  $tbl->setTitle($this->lng->txt('payment_tax_rates'));
4356  $tbl->setRowTemplate('tpl.shop_vats_list_row.html', 'Services/Payment');
4357 
4358  $tbl->setDefaultOrderField('title');
4359 
4360  $result = array();
4361 
4362  $tbl->addColumn('', 'check', '1%');
4363  $tbl->addColumn($this->lng->txt('vat_title'), 'vat_title', '33%');
4364  $tbl->addColumn($this->lng->txt('vat_rate'), 'vat_rate', '33%');
4365  $tbl->addColumn('', 'commands', '33%');
4366 
4367  $oShopVatsList = new ilShopVatsList();
4368  $oShopVatsList->read();
4369 
4370  $result = array();
4371 
4372  if($oShopVatsList->hasItems())
4373  {
4374  $tbl->enable('select_all');
4375  $tbl->setSelectAllCheckbox('vat_id');
4376 
4377  $counter = 0;
4378  foreach($oShopVatsList as $oVAT)
4379  {
4380  $result[$counter]['check'] = ilUtil::formCheckbox(0, 'vat_id[]', $oVAT->getId());
4381  $result[$counter]['vat_title'] = $oVAT->getTitle();
4382  $result[$counter]['vat_rate'] = ilShopUtils::_formatVAT((float)$oVAT->getRate());
4383  $this->ctrl->setParameter($this, 'vat_id', $oVAT->getId());
4384  $result[$counter]['edit_text'] = $this->lng->txt('edit');
4385  $result[$counter]['edit_url'] = $this->ctrl->getLinkTarget($this, 'editVat');
4386  $result[$counter]['delete_text'] = $this->lng->txt('delete');
4387  $result[$counter]['delete_url'] = $this->ctrl->getLinkTarget($this, 'confirmDeleteVat');
4388  $this->ctrl->clearParameters($this);
4389  ++$counter;
4390  }
4391 
4392  $tbl->addMultiCommand('confirmDeleteVat', $this->lng->txt('delete'));
4393  }
4394  else
4395  {
4396  $tbl->disable('header');
4397  $tbl->disable('footer');
4398 
4399  $tbl->setNoEntriesText($this->lng->txt('paya_no_vats_assigned'));
4400  }
4401 
4402  $tbl->setData($result);
4403 
4404  $tbl->addCommandButton('createVat', $this->lng->txt('paya_insert_vats'));
4405 
4406  $this->tpl->setContent($tbl->getHTML());
4407 
4408  return true;
4409  }
4410 
4411  public function confirmDeleteVatObject()
4412  {
4413  if((int)$_GET['vat_id'] && !isset($_POST['vat_id']))
4414  {
4415  $_POST['vat_id'][] = $_GET['vat_id'];
4416  }
4417 
4418  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
4419  $c_gui = new ilConfirmationGUI();
4420  $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDeleteVat'));
4421  $c_gui->setHeaderText($this->lng->txt('paya_sure_delete_vats'));
4422  $c_gui->setCancel($this->lng->txt('cancel'), 'vats');
4423  $c_gui->setConfirm($this->lng->txt('confirm'), 'performDeleteVat');
4424 
4425  $counter = 0;
4426  foreach((array)$_POST['vat_id'] as $vat_id)
4427  {
4428  try
4429  {
4430  $oVAT = new ilShopVats((int)$vat_id);
4431  $c_gui->addItem('vat_id[]', $oVAT->getId(), $oVAT->getTitle());
4432  ++$counter;
4433  }
4434  catch(ilShopException $e)
4435  {
4436  ilUtil::sendInfo($e->getMessage());
4437  return $this->vatsObject();
4438  }
4439  }
4440 
4441  if($counter)
4442  {
4443  return $this->tpl->setContent($c_gui->getHTML());
4444  }
4445  else
4446  {
4447  return $this->vatsObject();
4448  }
4449  }
4450 
4451  public function performDeleteVatObject()
4452  {
4453  if(!is_array($_POST['vat_id']))
4454  {
4455  return $this->vatsObject();
4456  }
4457 
4458  foreach($_POST['vat_id'] as $vat_id)
4459  {
4460  try
4461  {
4462  $oVAT = new ilShopVats((int)$vat_id);
4463  $oVAT->delete();
4464 
4465  }
4466  catch(ilShopException $e)
4467  {
4468  ilUtil::sendInfo($e->getMessage());
4469  return $this->vatsObject();
4470  }
4471  }
4472 
4473  ilUtil::sendSuccess($this->lng->txt('payment_vat_deleted_successfully'));
4474  return $this->vatsObject();
4475  }
4476  public function createVatObject()
4477  {
4478  $this->initVatForm('create');
4479  $this->tpl->setContent($this->form->getHtml());
4480  }
4481 
4482  public function editVatObject()
4483  {
4484  $this->initVatForm('edit');
4485  $this->fillVATDataIntoVATForm();
4486  $this->tpl->setContent($this->form->getHtml());
4487  }
4488 
4489  private function initVatForm($a_type = 'create')
4490  {
4491  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
4492 
4493  $this->form = new ilPropertyFormGUI();
4494  if($a_type == 'edit')
4495  {
4496  $this->ctrl->setParameter($this, 'vat_id', $_GET['vat_id']);
4497  $this->form->setFormAction($this->ctrl->getFormAction($this, 'updateVat'));
4498  $this->form->setTitle($this->lng->txt('payment_edit_vat'));
4499  }
4500  else
4501  {
4502  $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveVat'));
4503  $this->form->setTitle($this->lng->txt('payment_add_vat'));
4504  }
4505 
4506  $oTitle = new ilTextInputGUI($this->lng->txt('title'), 'vat_title');
4507  $oTitle->setMaxLength(255);
4508  $oTitle->setSize(40);
4509  $oTitle->setRequired(true);
4510  $oTitle->setInfo($this->lng->txt('payment_vat_title_info'));
4511  $this->form->addItem($oTitle);
4512 
4513  $oRate = new ilTextInputGUI($this->lng->txt('vat_rate'), 'vat_rate');
4514  $oRate->setMaxLength(5);
4515  $oRate->setSize(5);
4516  $oRate->setRequired(true);
4517  $oRate->setInfo($this->lng->txt('payment_vat_rate_info'));
4518  $this->form->addItem($oRate);
4519 
4520  if($a_type == 'edit')
4521  {
4522  $this->form->addCommandButton('updateVat', $this->lng->txt('save'));
4523  }
4524  else
4525  {
4526  $this->form->addCommandButton('saveVat', $this->lng->txt('save'));
4527  }
4528 
4529  $this->form->addCommandButton('vats', $this->lng->txt('cancel'));
4530  }
4531 
4532 
4533 
4534  private function fillVATDataIntoVATForm()
4535  {
4536  $oVAT = new ilShopVats((int)$_GET['vat_id']);
4537  $this->form->setValuesByArray(array(
4538  'vat_title' => $oVAT->getTitle(),
4539  'vat_rate' => $oVAT->getRate()
4540  ));
4541  }
4542 
4543  public function updateVatObject()
4544  {
4545  $this->initVatForm('edit');
4546  if(!$this->form->checkInput())
4547  {
4548  $this->form->setValuesByPost();
4549  return $this->tpl->setContent($this->form->getHtml());
4550  }
4551 
4552  if(!ilShopUtils::_checkVATRate($this->form->getInput('vat_rate')))
4553  {
4554  $this->form->getItemByPostVar('vat_rate')->setAlert($this->lng->txt('payment_vat_input_invalid'));
4555  $this->form->setValuesByPost();
4556  return $this->tpl->setContent($this->form->getHtml());
4557  }
4558 
4559  try
4560  {
4561  $oVAT = new ilShopVats((int)$_GET['vat_id']);
4562  $oVAT->setTitle($this->form->getInput('vat_title'));
4563  $oVAT->setRate((float)str_replace(',', '.', $this->form->getInput('vat_rate')));
4564  $oVAT->update();
4565  }
4566  catch(ilShopException $e)
4567  {
4568  ilUtil::sendInfo($e->getMessage());
4569  $this->form->setValuesByPost();
4570  return $this->tpl->setContent($this->form->getHtml());
4571  }
4572 
4573  ilUtil::sendInfo($this->lng->txt('saved_successfully'));
4574  return $this->vatsObject();
4575  }
4576 
4577  public function saveVatObject()
4578  {
4579  $this->initVatForm('create');
4580  if(!$this->form->checkInput())
4581  {
4582  $this->form->setValuesByPost();
4583  return $this->tpl->setContent($this->form->getHtml());
4584  }
4585 
4586  if(!ilShopUtils::_checkVATRate($this->form->getInput('vat_rate')))
4587  {
4588  $this->form->getItemByPostVar('vat_rate')->setAlert($this->lng->txt('payment_vat_input_invalid'));
4589  $this->form->setValuesByPost();
4590  return $this->tpl->setContent($this->form->getHtml());
4591  }
4592 
4593  try
4594  {
4595  $oVAT = new ilShopVats();
4596  $oVAT->setTitle($this->form->getInput('vat_title'));
4597  $oVAT->setRate((float)str_replace(',', '.', $this->form->getInput('vat_rate')));
4598  $oVAT->save();
4599  }
4600  catch(ilShopException $e)
4601  {
4602  ilUtil::sendInfo($e->getMessage());
4603  $this->form->setValuesByPost();
4604  return $this->tpl->setContent($this->form->getHtml());
4605 
4606  }
4607 
4608  ilUtil::sendInfo($this->lng->txt('saved'));
4609  return $this->vatsObject();
4610 
4611  }
4612 
4614  {
4615  // delete addresses here
4616 
4617  include_once './payment/classes/class.ilPaymentBookings.php';
4618  include_once './payment/classes/class.ilPayMethods.php';
4619 
4620  $this->__initBookingObject();
4621 
4622  foreach($_POST['pm'] as $pm)
4623  {
4624 
4625  switch($pm)
4626  {
4627  case 'bill':
4628  $pay_method = 1;
4629  ilPayMethods::_disable('save_user_adr_bill');
4630  break;
4631 
4632  case 'bmf':
4633  $pay_method = 2;
4634  ilPayMethods::_disable('save_user_adr_bmf');
4635  break;
4636 
4637  case 'paypal':
4638  $pay_method = 3;
4639  ilPayMethods::_disable('save_user_adr_paypal');
4640  break;
4641 
4642  case 'epay':
4643  $pay_method = 4;
4644  ilPayMethods::_disable('save_user_adr_epay');
4645  break;
4646 
4647  default:
4648  $pay_method = -1;
4649  }
4650 
4651  //$get_bookings = $this->booking_obj->getBookingsByPaymethod($pay_method);
4652 
4653  $del_bookings = $this->booking_obj->deleteAddressesByPaymethod((int)$pay_method);
4654  }
4655  return $this->payMethodsObject();
4656  }
4657 } // END class.ilObjPaymentSettingsGUI
4658 ?>