ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjPaymentSettingsGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
19require_once './Services/Object/classes/class.ilObjectGUI.php';
20include_once './Services/Payment/classes/class.ilShopVatsList.php';
21include_once './Services/Payment/classes/class.ilPaymentPrices.php';
22include_once './Services/Payment/classes/class.ilPaymentObject.php';
23include_once './Services/Payment/classes/class.ilFileDataShop.php';
24include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
25include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
26include_once './Services/Payment/classes/class.ilPaymentBookings.php';
27include_once './Services/Payment/classes/class.ilPaymentSettings.php';
28include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
29include_once './Services/Payment/classes/class.ilShopTableGUI.php';
30include_once './Services/Payment/classes/class.ilInvoiceNumberPlaceholdersPropertyGUI.php';
31include_once './Services/Payment/classes/class.ilUserDefinedInvoiceNumber.php';
32include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
33include_once './Services/Payment/classes/class.ilPaymentObjectSelector.php';
34
36{
37 const CONDITIONS_EDITOR_PAGE_ID = 99999997;
38
41 public $user_obj = null;
42
44 public $pobject = null;
48 public $genSetData = null;
49
51
52 public $error = false;
54 public $booking_obj = null;
55 public $form = null;
56
57 public $ilErr = null;
61 public $vendors_obj = null;
62
66 public $ctrl = null;
67
71 public $tabs_gui = null;
72
77 public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
78 {
79 global $ilErr, $ilUser;
80
81 $this->user_obj = $ilUser;
82 $this->ilErr = $ilErr;
83
84 $this->pobject = new ilPaymentObject($this->user_obj);
85
86 $this->genSetData = ilPaymentSettings::_getInstance();
87 $this->vendors_obj = ilPaymentVendors::getInstance();
88
89 $this->type = 'pays';
90 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
91
92 $this->lng->loadLanguageModule('payment');
93 }
94
95 public function checkShopActivationObject()
96 {
97// check general settings
98 $check = $this->genSetData->get('currency_unit');
99 if($check == null)
100 {
101 ilUtil::sendInfo($this->lng->txt('please_enter_currency'));
102 return $this->generalSettingsObject();
103 }
104
105 $check = $this->genSetData->get('address');
106 if($check == null)
107 {
108 ilUtil::sendInfo($this->lng->txt('please_enter_address'));
109 return $this->generalSettingsObject();
110 }
111
112 $check = $this->genSetData->get('bank_data');
113 if($check == null)
114 {
115 ilUtil::sendInfo($this->lng->txt('please_enter_bank_data'));
116 return $this->generalSettingsObject();
117 }
118
119 $check = $this->genSetData->get('pdf_path');
120 if($check == null)
121 {
122 ilUtil::sendInfo($this->lng->txt('please_enter_pdf_path'));
123 return $this->generalSettingsObject();
124 }
125
126// check paymethods
127 $pm_array = ilPaymethods::_getActivePaymethods();
128
129 if(count($pm_array) == 0)
130 {
131 ilUtil::sendInfo($this->lng->txt('please_activate_one_paymethod'));
132 $this->payMethodsObject();
133 return false;
134 }
135
136 foreach($pm_array as $paymethod)
137 {
138 switch($paymethod['pm_title'])
139 {
140 case 'bmf':
141 $check = unserialize($this->genSetData->get('bmf'));
142 if ($check['mandantNr'] == '' ||
143 $check['bewirtschafterNr'] == '' ||
144 $check['haushaltsstelle'] == '' ||
145 $check['objektNr'] == '' ||
146 $check['kennzeichenMahnverfahren'] == '' ||
147 $check['waehrungskennzeichen'] == '' ||
148 $check['ePaymentServer'] == '' ||
149 $check['clientCertificate'] == '' ||
150 $check['caCertificate'] == '' ||
151 $check['timeOut'] == '')
152 {
153 ilUtil::sendInfo($this->lng->txt('please_enter_bmf_data'));
154 $this->bmfSettingsObject();
155 return false;
156
157 }
158 break;
159 case 'paypal':
160 $check = unserialize($this->genSetData->get('paypal'));
161 if ($check['server_host'] == '' ||
162 $check['server_path'] == '' ||
163 $check['vendor'] == '' ||
164 $check['auth_token'] == '')
165 {
166 ilUtil::sendInfo($this->lng->txt('please_enter_paypal_data'));
167 $this->paypalSettingsObject();
168 return false;
169 }
170 break;
171 case 'epay':
172 case 'erp':
173 break;
174 }
175 }
176// check vats
177 include_once './Services/Payment/classes/class.ilShopVats.php';
178 $check= ilShopVats::_readAllVats();
179 if(count($check) == 0)
180 {
181 ilUtil::sendInfo($this->lng->txt('please_enter_vats'));
182 $this->vatsObject();
183 return false;
184 }
185// check vendors
186 $vendors = $this->vendors_obj->getVendors();
187
188 if(count($vendors) == 0)
189 {
190 ilUtil::sendInfo($this->lng->txt('please_create_vendor'));
191 $this->vendorsObject();
192 return false;
193 }
194
195// everything ok
196 ilUtil::sendInfo($this->lng->txt('shop_activation_ok'));
197 $this->generalSettingsObject();
198 return true;
199
200 }
201
202 public function executeCommand()
203 {
204 $next_class = $this->ctrl->getNextClass($this);
205 $cmd = $this->ctrl->getCmd();
206 $this->prepareOutput();
207
208/*
209 * shop activation guide
210 */
211
216 global $ilToolbar;
217 $ilToolbar->addButton($this->lng->txt('check_shop_activation'),$this->ctrl->getLinkTarget($this,'checkShopActivation'));
218
219 $this->getTabs($this->tabs_gui);
220
221 switch($next_class)
222 {
223 case 'ilrepositorysearchgui':
224 include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
225 $rep_search =& new ilRepositorySearchGUI();
226
227 $rep_search->setCallback($this,
228 'addVendorObject', array()
229 );
230
231 $this->ctrl->setReturn($this,'vendors');
232 $ret =& $this->ctrl->forwardCommand($rep_search);
233 break;
234
235 case 'ilpermissiongui':
236 include_once('Services/AccessControl/classes/class.ilPermissionGUI.php');
237 $perm_gui = new ilPermissionGUI($this);
238 $ret = $this->ctrl->forwardCommand($perm_gui);
239 break;
240
241 case 'ilshoppagegui':
242 if($cmd == 'TermsConditions')
243 {
244 $ret = $this->forwardToDocumentsPageObject(self::CONDITIONS_EDITOR_PAGE_ID);
245 $this->prepareOutput();
246 }
247 else
248 {
249 $ret = $this->forwardToPageObject();
250 }
251 if($ret != '')
252 {
253 $this->tpl->setContent($ret);
254 }
255 break;
256
257 case 'ilshoptopicsgui':
258 include_once './Services/Payment/classes/class.ilShopTopicsGUI.php';
259
260 $topics_gui = new ilShopTopicsGUI($this);
261 $ret = $this->ctrl->forwardCommand($topics_gui);
262 $this->getSubTabs('topics', $cmd);
263 break;
264
265 default:
266 if ($cmd == '' || $cmd == 'view')
267 {
268 $cmd = 'generalSettings';
269 }
270 switch ($cmd)
271 {
272 // only needed for subtabs
273 case 'saveGeneralSettings' :
274 case 'generalSettings' :
275 $this->tabs_gui->setTabActive('settings');
276 $this->getSubTabs('settings', 'generalSettings');
277 break;
278 case 'payMethods':
279 case 'savePayMethods':
280 $this->tabs_gui->setTabActive('pay_methods');
281 $this->getSubTabs('payMethods', 'payMethods');
282 break;
283 case 'saveBmfSettings' :
284 case 'bmfSettings' : $this->tabs_gui->setTabActive('pay_methods');
285 $this->getSubTabs('payMethods', 'bmfSettings');
286 break;
287 case 'savePaypalSettings' :
288 case 'paypalSettings' :
289 $this->tabs_gui->setTabActive('pay_methods');
290 $this->getSubTabs('payMethods', 'paypalSettings');
291 break;
292 case 'deleteVat' :
293 case 'newVat':
294 case 'insertVat':
295
296 case 'updateVat':
297 case 'performDeleteVat':
298 case 'confirmDeleteVat':
299 case 'createVat':
300 case 'saveVat':
301 case 'editVat':
302 case 'vats' : $this->tabs_gui->setTabActive('vats');
303 break;
304
305
306#TODO: CURRENCY not finished yet
307 case 'addCurrency':
308 case 'currencies':
309 # case 'performDeleteCurrency':
310 case 'updateCurrency':
311 # if($_POST['action'] == 'editCurrency' || $_POST['action'] == 'deleteCurrency')
312 # $cmd = $_POST['action'];
313 $this->tabs_gui->setTabActive('currencies');
314 break;
315
316 case 'StatutoryRegulations':
317 case 'saveStatutoryRegulations':
318 $this->active_sub_tab = 'statutory_regulations';
319 $this->tabs_gui->setTabActive('documents');
320 $this->getSubTabs('documents', 'statutory_regulations');
321 break;
322 case 'TermsConditions':
323 case 'documents':
324 $this->active_sub_tab = 'terms_conditions';
325 $this->tabs_gui->setTabActive('documents');
326 $this->getSubTabs('documents', 'terms_conditions');
327
328 $cmd = 'TermsConditions';
329 break;
330 case 'BillingMail':
331 case 'saveBillingMail':
332 $this->active_sub_tab = 'billing_mail';
333 $this->tabs_gui->setTabActive('documents');
334 $this->getSubTabs('documents', 'billing_mail');
335
336 # $cmd = 'BillingMail';
337 break;
338 case 'InvoiceNumber':
339 case 'saveInvoiceNumber':
340 $this->active_sub_tab = 'invoice_number';
341 $this->tabs_gui->setTabActive('documents');
342 $this->getSubTabs('documents', 'invoice_number');
343
344 #$cmd = 'InvoiceNumber';
345 break;
346 case 'checkShopActivation':
347 break;
348 }
349 $cmd .= 'Object';
350
351 $this->$cmd();
352
353 break;
354 }
355 return true;
356 }
357
358 public function forwardToPageObject()
359 {
363 global $ilTabs;
364
365 if(isset($_GET['pobject_id']) && $_GET['pobject_id'] > 0)
366 {
367 $this->ctrl->setParameter($this, 'pobject_id', (int)$_GET['pobject_id']);
368 $this->__initPaymentObject((int)$_GET['pobject_id']);
369 $this->lng->loadLanguageModule('content');
370
371 $ilTabs->clearTargets();
372 $ilTabs->clearSubTabs();
373 $ilTabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'editDetails'));
374
375 include_once 'Services/Payment/classes/class.ilShopPage.php';
376 include_once 'Services/Payment/classes/class.ilShopPageGUI.php';
377 include_once('./Services/Style/classes/class.ilObjStyleSheet.php');
378
379 $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
380
381 if(!ilShopPage::_exists('shop', (int)$this->pobject->getPobjectId()))
382 {
383 // doesn't exist -> create new one
384 $new_page_object = new ilShopPage();
385 $new_page_object->setParentId(0);
386 $new_page_object->setId($this->pobject->getPobjectId());
387 $new_page_object->createFromXML();
388 }
389
390 $this->ctrl->setReturnByClass('ilshoppagegui', 'edit');
391
392 if(!(int)$_GET['pobject_id'])
393 {
394 ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
395 return $this->objectsObject();
396 }
397 $this->ctrl->setParameter($this, 'pobject_id', (int)$_GET['pobject_id']);
398 $this->__initPaymentObject((int)$_GET['pobject_id']);
399
400 $page_gui = new ilShopPageGUI((int)$this->pobject->getPobjectId());
401 $this->ctrl->setParameter($page_gui, 'pobject_id', (int)$_GET['pobject_id']);
402 }
403 else
404 {
409 global $lng, $ilCtrl;
410
411 $ilTabs->clearTargets();
412 $ilTabs->setBackTarget($lng->txt('back'), $this->ctrl->getLinkTarget($this), '_top');
413
414 // page object
415 include_once 'Services/Payment/classes/class.ilShopPage.php';
416 include_once 'Services/Payment/classes/class.ilShopPageGUI.php';
417
418 $lng->loadLanguageModule('content');
419
420 include_once('./Services/Style/classes/class.ilObjStyleSheet.php');
421 $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
422
423 if(!ilShopPage::_exists('shop', self::CONDITIONS_EDITOR_PAGE_ID))
424 {
425 // doesn't exist -> create new one
426 $new_page_object = new ilShopPage();
427 $new_page_object->setParentId(0);
428 $new_page_object->setId(self::CONDITIONS_EDITOR_PAGE_ID);
429 $new_page_object->createFromXML();
430 }
431
432 $this->ctrl->setReturnByClass('ilshoppagegui', 'edit');
433
434 $page_gui = new ilShopPageGUI(self::CONDITIONS_EDITOR_PAGE_ID);
435 }
436
437 return $this->ctrl->forwardCommand($page_gui);
438 }
439
440 public function saveBmfSettingsObject()
441 {
445 global $rbacsystem;
446
447 // MINIMUM ACCESS LEVEL = 'read'
448 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
449 {
450 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
451 }
452
453 include_once './Services/Payment/classes/class.ilBMFSettings.php';
454
455 $this->error = '';
459 $bmfSetObj = ilBMFSettings::getInstance();
460
461 $bmfSetObj->setClientId(ilUtil::stripSlashes($_POST['mandantNr']));
462 $bmfSetObj->setBewirtschafterNr(ilUtil::stripSlashes($_POST['bewirtschafterNr']));
463 $bmfSetObj->setHaushaltsstelle(ilUtil::stripSlashes($_POST['haushaltsstelle']));
464 $bmfSetObj->setObjectId(ilUtil::stripSlashes($_POST['objektNr']));
465 $bmfSetObj->setKennzeichenMahnverfahren(ilUtil::stripSlashes($_POST['kennzeichenMahnverfahren']));
466 $bmfSetObj->setWaehrungsKennzeichen(ilUtil::stripSlashes($_POST['waehrungskennzeichen']));
467 $bmfSetObj->setEpaymentServer(ilUtil::stripSlashes($_POST['ePaymentServer']));
468 $bmfSetObj->setClientCertificate(ilUtil::stripSlashes($_POST['clientCertificate']));
469 $bmfSetObj->setCaCertificate(ilUtil::stripSlashes($_POST['caCertificate']));
470 $bmfSetObj->setTimeout(ilUtil::stripSlashes($_POST['timeOut']));
471
472 if ($_POST['mandantNr'] == '' ||
473 $_POST['bewirtschafterNr'] == '' ||
474 $_POST['haushaltsstelle'] == '' ||
475 $_POST['objektNr'] == '' ||
476 $_POST['kennzeichenMahnverfahren'] == '' ||
477 $_POST['waehrungskennzeichen'] == '' ||
478 $_POST['ePaymentServer'] == '' ||
479 $_POST['clientCertificate'] == '' ||
480 $_POST['caCertificate'] == '' ||
481 $_POST['timeOut'] == '')
482 {
483 $this->error = $this->lng->txt('pays_bmf_settings_not_valid');
485 $this->bmfSettingsObject();
486 return true;
487 }
488
489 $bmfSetObj->save();
490
491 $this->bmfSettingsObject();
492
493 ilUtil::sendSuccess($this->lng->txt('pays_updated_bmf_settings'));
494
495 return true;
496 }
497
498 public function bmfSettingsObject()
499 {
503 global $rbacsystem;
504
505 // MINIMUM ACCESS LEVEL = 'read'
506 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
507 {
508 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
509 }
510 include_once './Services/Payment/classes/class.ilBMFSettings.php';
511
512
513 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html','Services/Payment');
514
518 $bmfSetObj = ilBMFSettings::getInstance();
519
520 $form = new ilPropertyFormGUI();
521 $form->setFormAction($this->ctrl->getFormAction($this, 'saveBmfSettings'));
522 $form->setTitle($this->lng->txt('pays_bmf_settings'));
523
524 $form->addCommandButton('saveBmfSettings',$this->lng->txt('save'));
525
526 $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_client_id'), 'mandantNr');
527 $formItem->setValue($bmfSetObj->getClientId());
528 $form->addItem($formItem);
529
530 $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_bewirtschafter_nr'), 'bewirtschafterNr');
531 $formItem->setValue($bmfSetObj->getBewirtschafterNr());
532 $form->addItem($formItem);
533
534 $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_haushaltsstelle'), 'haushaltsstelle');
535 $formItem->setValue($bmfSetObj->getHaushaltsstelle());
536 $form->addItem($formItem);
537
538 $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_object_id'), 'objektNr');
539 $formItem->setValue($bmfSetObj->getObjectId());
540 $form->addItem($formItem);
541
542 $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_kennzeichen_mahnverfahren'), 'kennzeichenMahnverfahren');
543 $formItem->setValue($bmfSetObj->getKennzeichenMahnverfahren());
544 $form->addItem($formItem);
545
546 $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_waehrungskennzeichen'), 'waehrungskennzeichen');
547 $formItem->setValue($bmfSetObj->getWaehrungsKennzeichen());
548 $form->addItem($formItem);
549
550 $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_epayment_server'), 'ePaymentServer');
551 $formItem->setValue($bmfSetObj->getEpaymentServer());
552 $form->addItem($formItem);
553
554 $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_client_certificate'), 'clientCertificate');
555 $formItem->setValue($bmfSetObj->getClientCertificate());
556 $form->addItem($formItem);
557
558 $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_ca_certificate'), 'caCertificate');
559 $formItem->setValue($bmfSetObj->getCaCertificate());
560 $form->addItem($formItem);
561
562 $formItem = new ilTextInputGUI($this->lng->txt('pays_bmf_timeout'), 'timeOut');
563 $formItem->setValue($bmfSetObj->getTimeOut());
564 $form->addItem($formItem);
565
566 $this->tpl->setVariable('FORM',$form->getHTML());
567 return true;
568 }
569
570
571 public function updateDetailsObject()
572 {
573 if(!$_GET['pobject_id'])
574 {
575 ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
576
577 $this->objectObjects();
578 return true;
579 }
580
581 $this->__initPaymentObject((int) $_GET['pobject_id']);
582 $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
583
584 // read old settings
585 $old_status = $this->pobject->getStatus();
586
587 // check status changed from not_buyable
588 if($old_status == $this->pobject->STATUS_NOT_BUYABLE and
589 (int) $_POST['status'] != $old_status)
590 {
591 // check pay_method edited
592 switch((int) $_POST['pay_method'])
593 {
594 case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
595 ilUtil::sendInfo($this->lng->txt('paya_select_pay_method_first'));
596 $this->editDetailsObject();
597
598 return false;
599 default:
600 ;
601 }
602 // check minimum one price
603 $prices_obj = new ilPaymentPrices((int) $_GET['pobject_id']);
604 $standard_prices = array();
605 $standard_prices = $prices_obj->getPrices();
606
607 if(!count($standard_prices))
608 {
609 ilUtil::sendInfo($this->lng->txt('paya_edit_prices_first'));
610 $this->editDetailsObject();
611
612 return false;
613 }
614 }
615
616 $this->pobject->setStatus((int) $_POST['status']);
617 $this->pobject->setVendorId((int) $_POST['vendor']);
618 $this->pobject->setPayMethod((int) $_POST['pay_method']);
619 $this->pobject->setTopicId((int) $_POST['topic_id']);
620 $this->pobject->setVatId((int) $_POST['vat_id']);
621
622 $this->pobject->update();
623
624 ilUtil::sendInfo($this->lng->txt('paya_details_updated'));
625 $this->editDetailsObject();
626
627 return true;
628 }
629
630 public function editPricesObject($a_show_delete = false)
631 {
635 global $ilToolbar;
636
637 if($a_show_delete == false) unset($_SESSION['price_ids']);
638
639 $_SESSION['price_ids'] = $_SESSION['price_ids'] ? $_SESSION['price_ids'] : array();
640
641 if(!$_GET['pobject_id'])
642 {
643 ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
644
645 $this->objectsObject();
646 return true;
647 }
648 $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
649
650 $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'objects'));
651 $ilToolbar->addButton($this->lng->txt('paya_edit_details'), $this->ctrl->getLinkTarget($this, 'editDetails'));
652 $ilToolbar->addButton($this->lng->txt('paya_edit_prices'), $this->ctrl->getLinkTarget($this, 'editPrices'));
653 $ilToolbar->addButton($this->lng->txt('pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array('ilshoppagegui'), 'edit'));
654
655 $this->__initPaymentObject((int) $_GET['pobject_id']);
656
657 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
658
659 $price_obj = new ilPaymentPrices((int) $_GET['pobject_id']);
660 $standard_prices = array();
661 $extension_prices = array();
662 $standard_prices = $price_obj->getPrices();
663 $extension_prices = $price_obj->getExtensionPrices();
664
665 $prices = array_merge($standard_prices, $extension_prices );
666
667
668 // No prices created
669 if(!count($prices))
670 {
671 ilUtil::sendInfo($this->lng->txt('paya_no_price_available'));
672 $ilToolbar->addButton($this->lng->txt('paya_add_price'), $this->ctrl->getLinkTarget($this, 'addPrice'));
673
674 return true;
675 }
676 // Show confirm delete
677 if($a_show_delete)
678 {
679 $oConfirmationGUI = new ilConfirmationGUI();
680
681 // set confirm/cancel commands
682 $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this,"performDeletePrice"));
683 $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_selected_prices"));
684 $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "editPrices");
685 $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDeletePrice");
686
687 foreach($prices as $price)
688 {
689 $delete_row = '';
690 $tmp_price = '';
691
692 if(in_array($price['price_id'],$_SESSION['price_ids']))
693 {
694 switch($price['price_type'])
695 {
697 include_once './Services/Calendar/classes/class.ilDatePresentation.php';
698 $tmp_price = ilDatePresentation::formatDate(new ilDate($price['duration_from'], IL_CAL_DATE))
699 .' - '.ilDatePresentation::formatDate(new ilDate($price['duration_until'], IL_CAL_DATE));
700 break;
701
703 $tmp_price = $price['duration'].' '.$this->lng->txt('paya_months');
704 break;
705
707 $tmp_price = $this->lng->txt('unlimited_duration');
708 break;
709 }
710
711 $delete_row .= ''.$tmp_price.' -> '.
712 ilFormat::_getLocalMoneyFormat($price['price']).' '.
713 $this->genSetData->get('currency_unit');
714
715 $oConfirmationGUI->addItem('',$delete_row, $delete_row);
716 }
717 }
718
719 $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHTML());
720
721 return true;
722 }
723
724 // Fill table cells
728 $tpl = new ilTemplate('tpl.table.html',true,true);
729
730 // set table header
731 $tpl->setCurrentBlock('tbl_form_header');
732
733 $tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
734 $tpl->parseCurrentBlock();
735
736 $counter = 0;
737 $data = array();
738 foreach($prices as $price)
739 {
740 $data[$counter]['price_id'] = ilUtil::formCheckBox(in_array($price['price_id'],$_SESSION['price_ids']) ? 1 : 0,
741 'price_ids[]', $price['price_id']);
742
743 switch($price['price_type'])
744 {
746 $data[$counter]['duration'] = $price['duration'].' '.$this->lng->txt('paya_months');
747 break;
749
750 $data[$counter]['duration'] = ilDatePresentation::formatDate(new ilDate($price['duration_from'], IL_CAL_DATE))
751 .' - '.ilDatePresentation::formatDate(new ilDate($price['duration_until'],IL_CAL_DATE));
752 break;
754 $data[$counter]['duration'] = $this->lng->txt('unlimited_duration');
755 break;
756 }
757 $data[$counter]['price'] = ilFormat::_getLocalMoneyFormat($price['price']);
758 $data[$counter]['currency_unit'] = $this->genSetData->get('currency_unit');
759 $data[$counter]['extension'] = ilUtil::formCheckBox($price['extension'] ? 1 : 0,
760 'extension_ids[]', (int)$price['price_id'], true);
761
762 $this->ctrl->setParameter($this,"price_id",$price['price_id']);
763 $data[$counter]['edit'] =
764 "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editPrice")."\">".$this->lng->txt("edit")."</a></div>";
765
766 ++$counter;
767 }
768 $this->__editPricesTable($data);
769
770 return true;
771 }
772
773 private function __editPricesTable($a_result_set)
774 {
775 $this->ctrl->setParameter($this, 'cmd', 'editprices');
776 $tbl = new ilShopTableGUI($this);
777
778 $tmp_obj = ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
779 if($tmp_obj)
780 {
781 $tbl->setTitle($tmp_obj->getTitle());
782 }
783 else
784 {
785 $tbl->setTitle($this->lng->txt('object_not_found'));
786 }
787
788 $tbl->setId('tbl_bookings');
789 $tbl->setRowTemplate("tpl.shop_prices_row.html", "Services/Payment");
790
791 $tbl->addColumn(' ', 'price_id', '5%');
792 $tbl->addColumn($this->lng->txt('duration'), 'duration', '40%');
793 $tbl->addColumn($this->lng->txt('price_a'), 'price', '1%');
794 $tbl->addColumn($this->lng->txt('currency'), 'currency_unit', '10%');
795 $tbl->addColumn($this->lng->txt('extension_price'), 'extension', '10%');
796 $tbl->addColumn('', 'edit', '30%' );
797
798 $tbl->setSelectAllCheckbox('price_id');
799 $tbl->addCommandButton('addPrice',$this->lng->txt('paya_add_price'));
800
801 $tbl->addMultiCommand("deletePrice", $this->lng->txt("paya_delete_price"));
802 $tbl->fillFooter();
803
804 $tbl->setData($a_result_set);
805
806 $this->tpl->setVariable('TABLE', $tbl->getHTML());
807
808 return true;
809 }
810
811 public function addPriceObject()
812 {
816 global $ilToolbar;
817
818 if(!$_GET['pobject_id'])
819 {
820 ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
821
822 $this->objectsObject();
823 return true;
824 }
829
830 $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
831
832 $this->__initPaymentObject((int) $_GET['pobject_id']);
833
834 $ilToolbar->addButton($this->lng->txt('paya_edit_details'), $this->ctrl->getLinkTarget($this, 'editDetails'));
835 $ilToolbar->addButton($this->lng->txt('paya_edit_prices'), $this->ctrl->getLinkTarget($this, 'editPrices'));
836 $ilToolbar->addButton($this->lng->txt('pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array('ilshoppagegui'), 'edit'));
837
838 $tmp_obj = ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
839 if(is_object($tmp_obj))
840 {
841 $tmp_object['title'] = $tmp_obj->getTitle();
842 }
843 else
844 {
845 $tmp_object['title'] = $this->lng->txt('object_not_found');
846 }
847 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
848
849 $form = new ilPropertyFormGUI();
850 $form->setFormAction($this->ctrl->getFormAction($this));
851 $form->setTitle($this->lng->txt('paya_add_price_title'));
852
853 // object_title
854 $oTitle = new ilNonEditableValueGUI($this->lng->txt('title'));
855
856 $oTitle->setValue($tmp_object['title']);
857 $form->addItem($oTitle);
858
859 //price_type
860
861 $radio_group = new ilRadioGroupInputGUI('','price_type');
862 $radio_group->setTitle($this->lng->txt('duration'));
863 $radio_group->setRequired(true);
864 $radio_group->setValue($_POST['price_type']);
865 $radio_group->setPostVar('price_type');
866
867 $radio_option_1 = new ilRadioOption($this->lng->txt('duration_month'), 'duration_month');
868
869 // duration month
870 $oDuration = new ilNumberInputGUI();
871 $oDuration->setTitle($this->lng->txt('paya_months'));
872 $oDuration->setSize('30%');
873 $oDuration->setValue($_POST['duration_month']);
874 $oDuration->setPostVar('duration_month');
875 $radio_option_1->addSubItem($oDuration);
876
877 $radio_group->addOption($radio_option_1);
878
879 $radio_option_3 = new ilRadioOption($this->lng->txt('duration_date'), 'duration_date');
880
881 // duration_date from
882 $o_date_from = new ilDateTimeInputGUI();
883 $o_date_from->setTitle($this->lng->txt('cal_from'));
884 $o_date_from->setPostVar('duration_date_from');
885 $radio_option_3->addSubItem($o_date_from);
886
887 // duration_date until
888 $o_date_until = new ilDateTimeInputGUI();
889 $o_date_until->setTitle($this->lng->txt('cal_until'));
890 $o_date_until->setPostVar('duration_date_until');
891 $radio_option_3->addSubItem($o_date_until);
892
893 $radio_group->addOption($radio_option_3);
894
895 $radio_option_2 = new ilRadioOption($this->lng->txt('unlimited_duration'), 'unlimited_duration');
896 $radio_group->addOption($radio_option_2);
897
898 $form->addItem($radio_group);
899
900 // description
901 $oDescription = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
902 $oDescription->setRows(4);
903 $oDescription->setCols(35);
904 $oDescription->setValue($_POST['description']);
905 $form->addItem($oDescription);
906
907 // price
908 $oPrice = new ilNumberInputGUI();
909 $oPrice->setTitle($this->lng->txt('price_a'));
910 $oPrice->setValue($_POST['price']);
911 $oPrice->setPostVar('price');
912 $oPrice->setRequired(true);
913 $oPrice->allowDecimals(true);
914 $form->addItem($oPrice);
915
916 // currency
917 // TODO show curency selector
918
919#TODO: CURRENCY not finished yet
920/* $objCurrency = new ilPaymentCurrency();
921 $currencies = $objCurrency->_getAvailableCurrencies();
922
923 foreach($currencies as $currency)
924 {
925 $currency_options[$currency['currency_id']] = $currency['unit'];
926 }
927
928
929 $oCurrency = new ilSelectInputGUI($this->lng->txt('currency'), 'currency_id');
930 $oCurrency->setOptions($currency_options);
931
932 $oCurrency->setValue($_SESSION['pay_objects']['currency_value']);
933 $oCurrency->setPostVar('currency_id');
934 /**/
935 $currency_options = $genSet->get('currency_unit');
936 $oCurrency = new ilNonEditableValueGUI($this->lng->txt('currency'));
937 $oCurrency->setValue($currency_options);
938 $form->addItem($oCurrency);
939
940
941 //extension
942 $oExtension = new ilCheckboxInputGUI($this->lng->txt('extension_price'), 'extension');
943 $oExtension->setChecked((int)$_POST['extension']);
944
945 $form->addItem($oExtension);
946
947 $form->addCommandButton('performAddPrice',$this->lng->txt('paya_add_price'));
948 $form->addCommandButton('editPrices', $this->lng->txt('cancel'));
949 $this->tpl->setVariable('FORM',$form->getHTML());
950
951 return true;
952 }
953
954 public function performAddPriceObject()
955 {
956 $po = new ilPaymentPrices((int)$_GET['pobject_id']);
957
958 switch($_POST['price_type'])
959 {
960 case 'unlimited_duration':
962 $po->setDuration(0);
963 $po->setDurationFrom(NULL);
964 $po->setDurationUntil(NULL);
965 $po->setUnlimitedDuration(1);
966
967 break;
968
969 case 'duration_date':
970
972 $po->setDuration(NULL);
973 $po->setDurationFrom(ilUtil::stripSlashes(
974 $_POST['duration_date_from']['date']['y'].'-'.
975 $_POST['duration_date_from']['date']['m'].'-'.
976 $_POST['duration_date_from']['date']['d']));
977 $po->setDurationUntil(ilUtil::stripSlashes(
978 $_POST['duration_date_until']['date']['y'].'-'.
979 $_POST['duration_date_until']['date']['m'].'-'.
980 $_POST['duration_date_until']['date']['d']));
981 break;
982
983 default:
984 case 'duration_month':
986 $po->setDuration($_POST['duration_month']);
987 $po->setDurationFrom(NULL);
988 $po->setDurationUntil(NULL);
989 break;
990 }
991
992 $po->setDescription($_POST['description'] ? ilUtil::stripSlashes($_POST['description']) : NULL);
993 $po->setPrice(ilUtil::stripSlashes($_POST['price']));
994// $po->setCurrency($currency[1]['currency_id']);
995
996 if($_POST['extension_price'])
997 {
998 $po->setExtension(1);
999 }
1000 else
1001 {
1002 $po->setExtension(0);
1003 }
1004
1005 try
1006 {
1007 $po->validate();
1008 $po->add();
1009 ilUtil::sendInfo($this->lng->txt('paya_added_new_price'));
1010 return $this->editPricesObject();
1011 }
1012 catch(ilShopException $e)
1013 {
1014 ilUtil::sendInfo($e->getMessage());
1015 return $this->addPriceObject();
1016 }
1017 }
1018
1020 {
1021 if(!$_GET['pobject_id'])
1022 {
1023 ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
1024
1025 $this->objectsObject();
1026 return true;
1027 }
1028
1029 if(!count($_SESSION['price_ids']))
1030 {
1031 ilUtil::sendInfo($this->lng->txt('paya_no_prices_selected'));
1032
1033 $this->editPriceObject();
1034 return true;
1035 }
1036
1037 $prices = new ilPaymentPrices((int) $_GET['pobject_id']);
1038
1039 foreach($_SESSION['price_ids'] as $price_id)
1040 {
1041 if($prices->delete($price_id))
1042 ilUtil::sendInfo($this->lng->txt('paya_deleted_selected_prices'));
1043
1044 }
1045
1046 // check if it was last price otherwise set status to 'not_buyable'
1047 if(!count($prices->getPrices()))
1048 {
1049 $this->__initPaymentObject((int) $_GET['pobject_id']);
1050
1051 $this->pobject->setStatus($this->pobject->STATUS_NOT_BUYABLE);
1052 $this->pobject->update();
1053
1054 ilUtil::sendInfo($this->lng->txt('paya_deleted_last_price'));
1055 }
1056 unset($prices);
1057 unset($_SESSION['price_ids']);
1058
1059 return $this->editPricesObject();
1060 }
1061
1062 public function deletePriceObject()
1063 {
1064 if(!$_GET['pobject_id'])
1065 {
1066 ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
1067
1068 $this->objectsObject();
1069 return true;
1070 }
1071
1072 if(!count($_POST['price_ids']))
1073 {
1074 ilUtil::sendInfo($this->lng->txt('paya_no_prices_selected'));
1075
1076 $this->editPricesObject();
1077 return true;
1078 }
1079 $_SESSION['price_ids'] = $_POST['price_ids'];
1080
1081 $this->editPricesObject(true);
1082 return true;
1083 }
1084
1085 public function updatePriceObject()
1086 {
1087 if(!$_GET['pobject_id'] && !$_POST['pobject_id'])
1088 {
1089 ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
1090
1091 $this->objectsObject();
1092 return true;
1093 }
1094 if(isset($_GET['pobject_id']))
1095 {
1096 $pobject_id = (int)$_GET['pobject_id'];
1097 }
1098 else
1099 {
1100 $pobject_id = (int)$_POST['pobject_id'];
1101 }
1102
1103 if(!(int)$_GET['price_id'] && !$_POST['price_id'])
1104 {
1105 ilUtil::sendInfo($this->lng->txt('payment_no_price_selected'));
1106 return $this->editPricesObject();
1107 }
1108 if(isset($_GET['price_id']))
1109 {
1110 $price_id = (int)$_GET['price_id'];
1111 }
1112 else
1113 {
1114 $price_id = (int)$_POST['price_id'];
1115 }
1116
1117 $po = new ilPaymentPrices((int)$pobject_id);
1118 switch($_POST['price_type'])
1119 {
1122 $po->setDuration(NULL);
1123 $po->setDurationFrom(NULL);
1124 $po->setDurationUntil(NULL);
1125 $po->setUnlimitedDuration(1);
1126
1127 break;
1128
1131 $po->setDuration(NULL);
1132 $po->setDurationFrom(ilUtil::stripSlashes(
1133 $_POST['duration_date_from']['date']['y'].'-'.
1134 $_POST['duration_date_from']['date']['m'].'-'.
1135 $_POST['duration_date_from']['date']['d']));
1136 $po->setDurationUntil(ilUtil::stripSlashes(
1137 $_POST['duration_date_until']['date']['y'].'-'.
1138 $_POST['duration_date_until']['date']['m'].'-'.
1139 $_POST['duration_date_until']['date']['d']));
1140 break;
1141
1142 default:
1145 $po->setDuration($_POST['duration_month']);
1146 $po->setDurationFrom(NULL);
1147 $po->setDurationUntil(NULL);
1148 break;
1149 }
1150
1151 $po->setDescription($_POST['description'] ? ilUtil::stripSlashes($_POST['description']) : NULL);
1152 $po->setPrice(ilUtil::stripSlashes($_POST['price']));
1153 $po->setCurrency(ilUtil::stripSlashes($_POST['currency']));
1154 if($_POST['extension_price'])
1155 {
1156 $po->setExtension(1);
1157 }
1158 else
1159 {
1160 $po->setExtension(0);
1161 }
1162 try
1163 {
1164 $po->validate();
1165 $po->update($price_id);
1166 ilUtil::sendInfo($this->lng->txt('paya_updated_price'));
1167 return $this->editPricesObject();
1168 }
1169 catch(ilShopException $e)
1170 {
1171 ilUtil::sendInfo($e->getMessage());
1172 $this->editPriceObject();
1173 return true;
1174 }
1175 }
1176
1177 public function editDetailsObject($a_show_confirm = false)
1178 {
1179 global $ilToolbar;
1180
1181 if(!(int)$_GET['pobject_id'])
1182 {
1183 ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
1184 return $this->objectsObject();
1185 }
1186
1187 $this->__initPaymentObject((int)$_GET['pobject_id']);
1188
1189 $this->ctrl->setParameter($this,'pobject_id', (int)$_GET['pobject_id']);
1190
1191 $ilToolbar->addButton($this->lng->txt('paya_edit_details'), $this->ctrl->getLinkTarget($this, 'editDetails'));
1192 $ilToolbar->addButton($this->lng->txt('paya_edit_prices'), $this->ctrl->getLinkTarget($this, 'editPrices'));
1193 $ilToolbar->addButton($this->lng->txt('pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array('ilshoppagegui'), 'edit'));
1194
1195 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
1196
1197 $tmp_obj = ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(),false);
1198 if($tmp_obj)
1199 {
1200 $tmp_object['title'] = $tmp_obj->getTitle();
1201 $tmp_object['type'] = $tmp_obj->getType();
1202 }
1203 else
1204 {
1205 $tmp_object['title'] = $this->lng->txt('object_not_found');
1206 $tmp_object['type'] = '';
1207
1208 }
1209 if($a_show_confirm)
1210 {
1211 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
1212 $oConfirmationGUI = new ilConfirmationGUI();
1213
1214 // set confirm/cancel commands
1215 $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this,"performObjectDelete"));
1216 $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_object"));
1217 $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "objects");
1218 $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performObjectDelete");
1219
1220 $oConfirmationGUI->addItem('', $tmp_object['title'], $tmp_object['title']);
1221 $this->tpl->setVariable('CONFIRMATION',$oConfirmationGUI->getHTML());
1222
1223 return true;
1224 }
1225
1226 $oForm = new ilPropertyFormGUI();
1227 $oForm->setFormAction($this->ctrl->getFormAction($this, 'updateDetails'));
1228 $oForm->setTitle($tmp_object['title']);
1229
1230 // repository path
1231 $oPathGUI = new ilNonEditableValueGUI($this->lng->txt('path'));
1232 $oPathGUI->setValue($this->__getHTMLPath($this->pobject->getRefId()));
1233 $oForm->addItem($oPathGUI);
1234
1235 // number of purchasers
1236 $oPurchasersGUI = new ilNonEditableValueGUI($this->lng->txt('paya_count_purchaser'));
1237 $oPurchasersGUI->setValue(ilPaymentBookings::_getCountBookingsByObject((int)$_GET['pobject_id']));
1238 $oForm->addItem($oPurchasersGUI);
1239
1240 // vendors
1241 $oVendorsGUI = new ilSelectInputGUI($this->lng->txt('paya_vendor'), 'vendor');
1242 $oVendorsGUI->setOptions($this->__getVendors());
1243 $oVendorsGUI->setValue($this->pobject->getVendorId());
1244 $oForm->addItem($oVendorsGUI);
1245
1246 // status
1247 $oStatusGUI = new ilSelectInputGUI($this->lng->txt('status'), 'status');
1248 $oStatusGUI->setOptions($this->__getStatus());
1249 $oStatusGUI->setValue($this->pobject->getStatus());
1250 $oForm->addItem($oStatusGUI);
1251
1252 // pay methods
1253 $oPayMethodsGUI = new ilSelectInputGUI($this->lng->txt('paya_pay_method'), 'pay_method');
1254 $oPayMethodsGUI->setOptions(ilPayMethods::getPayMethodsOptions('not_specified'));
1255
1256 $oPayMethodsGUI->setValue($this->pobject->getPayMethod());
1257 $oForm->addItem($oPayMethodsGUI);
1258
1259 // topics
1260 include_once './Services/Payment/classes/class.ilShopTopics.php';
1262 if(is_array($topics = ilShopTopics::_getInstance()->getTopics()) && count($topics))
1263 {
1264 $oTopicsGUI = new ilSelectInputGUI($this->lng->txt('topic'), 'topic_id');
1265
1267 $topic_options = array();
1268 $topic_options[''] = $this->lng->txt('please_choose');
1269
1270 foreach($topics as $oTopic)
1271 {
1272 $topic_options[$oTopic->getId()] = $oTopic->getTitle();
1273 }
1274
1275 $oTopicsGUI->setOptions($topic_options);
1276 $oTopicsGUI->setValue($this->pobject->getTopicId());
1277 $oForm->addItem($oTopicsGUI);
1278 }
1279
1280 // vats
1281 $oShopVatsList = new ilShopVatsList();
1282 $oShopVatsList->read();
1283 if($oShopVatsList->hasItems())
1284 {
1285 $oVatsGUI = new ilSelectInputGUI($this->lng->txt('vat_rate'), 'vat_id');
1286
1287 $vats_options = array();
1288 foreach($oShopVatsList as $oVAT)
1289 {
1290 $vats_options[$oVAT->getId()] = ilShopUtils::_formatVAT($oVAT->getRate()).' -> '.$oVAT->getTitle();
1291 }
1292
1293 $oVatsGUI->setOptions($vats_options);
1294 $oVatsGUI->setValue($this->pobject->getVatId());
1295 $oForm->addItem($oVatsGUI);
1296 }
1297 else
1298 {
1299 $oVatsGUI = new ilNonEditableValueGUI($this->lng->txt('vat_rate'));
1300 $oVatsGUI->setValue($this->lng->txt('paya_no_vats_assigned'));
1301 $oForm->addItem($oVatsGUI);
1302 }
1303
1304 $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail');
1305 $oFile = new ilFileDataShop($this->pobject->getPobjectId());
1306 if(($webpath_file = $oFile->getCurrentImageWebPath()) !== false)
1307 {
1308 $oThumbnail->setImage($webpath_file);
1309 }
1310 $oForm->addItem($oThumbnail);
1311
1312 // buttons
1313 $oForm->addCommandButton('updateDetails', $this->lng->txt('save'));
1314 $oForm->addCommandButton('deleteObject', $this->lng->txt('delete'));
1315
1316 $this->tpl->setVariable('FORM', $oForm->getHTML());
1317 return true;
1318
1319 }
1320
1321 public function deleteObjectObject()
1322 {
1323 //include_once './Services/Payment/classes/class.ilPaymentBookings.php';
1324
1325 if(!$_GET['pobject_id'])
1326 {
1327 ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
1328
1329 $this->editDetailsObject();
1330 return true;
1331 }
1332 if(ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']))
1333 {
1334 ilUtil::sendInfo($this->lng->txt('paya_bookings_available'));
1335 $this->editDetailsObject();
1336
1337 return false;
1338 }
1339 else
1340 {
1341 ilUtil::sendQuestion($this->lng->txt('paya_sure_delete_object'));
1342 $this->editDetailsObject(true);
1343
1344 return true;
1345 }
1346 }
1347
1349 {
1350
1351 if(!$_GET['pobject_id'])
1352 {
1353 ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
1354
1355 $this->objectsObject();
1356 return true;
1357 }
1358 $this->__initPaymentObject((int) $_GET['pobject_id']);
1359
1360 // delete object data
1361 $this->pobject->delete();
1362
1363 // delete payment prices
1364 $price_obj = new ilPaymentPrices((int) $_GET['pobject_id']);
1365 $price_obj->deleteAllPrices();
1366 unset($price_obj);
1367
1368 ilUtil::sendInfo($this->lng->txt('paya_deleted_object'));
1369
1370 $this->objectsObject();
1371
1372 return true;
1373 }
1374
1375 private function __getHTMLPath($a_ref_id)
1376 {
1377 global $tree;
1378
1379 $path = $tree->getPathFull($a_ref_id);
1380
1381 unset($path[0]);
1382 $html = '';
1383 if(is_array($path))
1384 {
1385 foreach($path as $data)
1386 {
1387 $html .= $data['title'].' > ';
1388 }
1389 }
1390 return substr($html,0,-2);
1391 }
1392
1393 private function __getVendors()
1394 {
1395 $options = array();
1396 $vendors = array();
1397
1398 $all_vendors = $this->vendors_obj->getVendors();
1399 if (is_array($all_vendors))
1400 {
1401 foreach ($all_vendors as $vendor)
1402 {
1403 $vendors[] = $vendor['vendor_id'];
1404 }
1405 }
1406
1407 foreach($vendors as $vendor)
1408 {
1409 if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($vendor, false))
1410 {
1411 continue;
1412 }
1413
1414 $options[$vendor] = $tmp_obj->getFullname().' ['.$tmp_obj->getLogin().']';
1415 }
1416 return $options;
1417 }
1418
1419 private function __getStatus()
1420 {
1421 $option = array();
1422 $option[$this->pobject->STATUS_NOT_BUYABLE] = $this->lng->txt('paya_not_buyable');
1423 $option[$this->pobject->STATUS_BUYABLE] = $this->lng->txt('paya_buyable');
1424 $option[$this->pobject->STATUS_EXPIRES] = $this->lng->txt('paya_expires');
1425
1426 return $option;
1427 }
1428
1429 public function resetObjectFilterObject()
1430 {
1431 unset($_SESSION['pay_statistics']);
1432 unset($_POST['title_type']);
1433 unset($_POST['title_value']);
1434 unset($_POST['vendor']);
1435 unset($_POST['pay_method']);
1436
1437 ilUtil::sendInfo($this->lng->txt('paya_filter_reseted'));
1438
1439 return $this->objectsObject();
1440 }
1441
1442 public function objectsObject()
1443 {
1444 global $rbacsystem;
1445
1446 // MINIMUM ACCESS LEVEL = 'read'
1447 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
1448 {
1449 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
1450 }
1451
1452 if ($_POST['updateView'] == 1)
1453 {
1454 $_SESSION['pay_objects']['title_type'] = $_POST['title_type'];
1455 $_SESSION['pay_objects']['title_value'] = $_POST['title_value'];
1456 $_SESSION['pay_objects']['pay_method'] = $_POST['pay_method'];
1457 $_SESSION['pay_objects']['vendor'] = $_POST['vendor'];
1458 }
1459
1460 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
1461
1462 $this->__initPaymentObject();
1463 $this->lng->loadLanguageModule('search');
1464
1465 $filter_form = new ilPropertyFormGUI();
1466 $filter_form->setFormAction($this->ctrl->getFormAction($this));
1467 $filter_form->setTitle($this->lng->txt('pay_filter'));
1468 $filter_form->setId('filter_form');
1469 $filter_form->setTableWidth('100 %');
1470
1471 //hide_filter
1472 $o_hide_check = new ilCheckBoxInputGUI($this->lng->txt('show_filter'),'show_filter');
1473 $o_hide_check->setValue(1);
1474 $o_hide_check->setChecked($_POST['show_filter'] ? 1 : 0);
1475
1476 $o_hidden = new ilHiddenInputGUI('updateView');
1477 $o_hidden->setValue(1);
1478 $o_hidden->setPostVar('updateView');
1479 $o_hide_check->addSubItem($o_hidden);
1480
1481 //title
1482 $radio_group = new ilRadioGroupInputGUI($this->lng->txt('search_in_title'), 'title_type');
1483 $radio_option = new ilRadioOption($this->lng->txt('search_any_word'), 'or');
1484 $radio_group->addOption($radio_option);
1485 $radio_option = new ilRadioOption($this->lng->txt('search_all_words'), 'and');
1486 $radio_group->addOption($radio_option);
1487
1488 $radio_group->setRequired(false);
1489 $radio_group->setValue('or');
1490 $radio_group->setPostVar('title_type');
1491
1492 $o_title = new ilTextInputGUI();
1493 $o_title->setValue($_SESSION['pay_objects']['title_value']);
1494 $o_title->setPostVar('title_value');
1495 $o_title->setTitle($this->lng->txt('title'));
1496
1497 $o_hide_check->addSubItem($radio_group);
1498 $o_hide_check->addSubItem($o_title);
1499
1500 //vendor
1501 $o_vendor = new ilTextInputGUI();
1502 $o_vendor->setTitle($this->lng->txt('paya_vendor'));
1503 $o_vendor->setValue($_SESSION['pay_objects']['vendor']);
1504 $o_vendor->setPostVar('vendor');
1505 $o_hide_check->addSubItem($o_vendor);
1506
1507 // paymethod
1508 $o_paymethod = new ilSelectInputGUI();
1509 $o_paymethod->setTitle($this->lng->txt('payment_system'));
1510 $o_paymethod->setOptions(ilPaymethods::getPayMethodsOptions('all'));
1511 $o_paymethod->setValue($_SESSION['pay_objects']['pay_method']);
1512 $o_paymethod->setPostVar('pay_method');
1513 $o_hide_check->addSubItem($o_paymethod);
1514
1515 $filter_form->addCommandButton('objects', $this->lng->txt('pay_update_view'));
1516 $filter_form->addCommandButton('resetObjectFilter', $this->lng->txt('pay_reset_filter'));
1517
1518 $filter_form->addItem($o_hide_check);
1519 if(!count($objects = ilPaymentObject::_getAllObjectsData()))
1520 {
1521 ilUtil::sendInfo($this->lng->txt('paya_no_objects_assigned'));
1522
1523 return true;
1524 }
1525 $this->tpl->setVariable('FORM', $filter_form->getHTML());
1526
1527 $counter = 0;
1528 foreach($objects as $data)
1529 {
1530 $tmp_obj = ilObjectFactory::getInstanceByRefId($data['ref_id'], false);
1531 if($tmp_obj)
1532 {
1533 $f_result[$counter]['title'] = $tmp_obj->getTitle();
1534 }
1535 else
1536 {
1537 $f_result[$counter]['title'] = $this->lng->txt('object_not_found');
1538 }
1539
1540 switch($data['status'])
1541 {
1542 case $this->pobject->STATUS_BUYABLE:
1543 $f_result[$counter]['status'] = $this->lng->txt('paya_buyable');
1544 break;
1545
1546 case $this->pobject->STATUS_NOT_BUYABLE:
1547 $f_result[$counter]['status'] = $this->lng->txt('paya_not_buyable');
1548 break;
1549
1550 case $this->pobject->STATUS_EXPIRES:
1551 $f_result[$counter]['status'] = $this->lng->txt('paya_expires');
1552 break;
1553 }
1554
1555 include_once './Services/Payment/classes/class.ilPayMethods.php';
1556 $str_paymethod = ilPayMethods::getStringByPaymethod($data['pay_method']);
1557 $f_result[$counter]['pay_method'] = $str_paymethod;
1558
1559 if($data['vat_id'] <= 0)
1560 {
1561 $vat_rate = $this->lng->txt('payment_vat_has_to_be_defined_by_administration_short');
1562 }
1563 else
1564 {
1565 try
1566 {
1567 $oVAT = new ilShopVats((int)$data['vat_id']);
1568 $vat_rate = ilShopUtils::_formatVAT((float)$oVAT->getRate());
1569 }
1570 catch(ilShopException $e)
1571 {
1572 $vat_rate = $this->lng->txt('payment_vat_has_to_be_defined_by_administration_short');
1573 }
1574 }
1575
1576 $f_result[$counter]['vat_rate'] = $vat_rate;
1577
1578 $tmp_user = ilObjectFactory::getInstanceByObjId($data['vendor_id'], false);
1579 if($tmp_user )
1580 {
1581 $f_result[$counter]['vendor'] = $tmp_user->getFullname().' ['.$tmp_user->getLogin().']';
1582 }
1583 else
1584 {
1585 $f_result[$counter]['vendor'] = $this->lng->txt('user_not_found');
1586 }
1587
1588 // Get number of purchasers
1589 $f_result[$counter]['purchasers'] = ilPaymentBookings::_getCountBookingsByObject($data['pobject_id']);
1590
1591 // edit link
1592 $this->ctrl->setParameter($this,'pobject_id',$data['pobject_id']);
1593 $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editDetails")."\">".$this->lng->txt("edit")."</a></div>";
1594
1595 $f_result[$counter]['options'] = $link_change;
1596 unset($tmp_user);
1597 unset($tmp_obj);
1598
1599 ++$counter;
1600 }
1601
1602 return $this->__showObjectsTable($f_result);
1603
1604 //return true;
1605 }
1606
1607 private function __showObjectsTable($a_result_set)
1608 {
1609 $this->ctrl->setParameter($this, 'cmd', 'objects');
1610
1611 $tbl = new ilShopTableGUI($this);
1612 $tbl->setTitle($this->lng->txt('objects'));
1613
1614 $tbl->setId('tbl_show_objects');
1615 $tbl->setRowTemplate("tpl.shop_objects_row.html", "Services/Payment");
1616
1617 $tbl->addColumn($this->lng->txt('title'), 'title', '10%');
1618 $tbl->addColumn($this->lng->txt('status'), 'status', '10%');
1619 $tbl->addColumn($this->lng->txt('paya_pay_method'),'pay_method','10%');
1620 $tbl->addColumn($this->lng->txt('vat_rate'), 'vat_rate', '15%');
1621 $tbl->addColumn($this->lng->txt('paya_vendor'), 'vendor', '10%');
1622 $tbl->addColumn($this->lng->txt('paya_count_purchaser'), 'purchasers', '10%');
1623 $tbl->addColumn('','options','10%');
1624
1625 $tbl->setData($a_result_set);
1626
1627 $this->tpl->setVariable('TABLE', $tbl->getHTML());
1628
1629 return true;
1630 }
1631
1632 private function __initPaymentObject($a_pobject_id = 0)
1633 {
1634 $this->pobject = new ilPaymentObject($this->user_obj,$a_pobject_id);
1635 return true;
1636 }
1637
1638 public function gatewayObject()
1639 {
1640 switch($_POST['action'])
1641 {
1642 case 'deleteVendorsObject':
1643 $this->deleteVendors();
1644 break;
1645
1646 case 'editVendorObject':
1647 $this->editVendor();
1648 break;
1649
1650 case 'performEditVendorObject':
1651 $this->performEditVendorObject();
1652 break;
1653
1654 default:
1655 $this->vendorsObject();
1656 break;
1657 }
1658 return true;
1659 }
1660
1661 public function resetFilterObject()
1662 {
1663 unset($_SESSION['pay_statistics']);
1664 unset($_POST['transaction_type']);
1665 unset($_POST['transaction_value']);
1666 unset($_POST['from']);
1667 unset($_POST['til']);
1668 unset($_POST['payed']);
1669 unset($_POST['access']);
1670 unset($_POST['customer']);
1671 unset($_POST['pay_method']);
1672 unset($_POST['updateView']);
1673 unset($_POST["adm_filter_title_id"]);
1674 ilUtil::sendInfo($this->lng->txt('paya_filter_reseted'));
1675
1676 return $this->statisticObject();
1677 }
1678
1679 public function statisticObject()
1680 {
1681 global $rbacsystem, $ilToolbar,$ilObjDataCache;
1682
1683 include_once './Services/Payment/classes/class.ilPayMethods.php';
1684
1685 // MINIMUM ACCESS LEVEL = 'read'
1686 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
1687 {
1688 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
1689 }
1690
1691 $ilToolbar->addButton($this->lng->txt('paya_add_customer'), $this->ctrl->getLinkTarget($this, 'showObjectSelector'));
1692
1693 if ($_POST['updateView'] == 1)
1694 {
1695 $_SESSION['pay_statistics']['show_filter']= $_POST['show_filter'];
1696 $_SESSION['pay_statistics']['updateView'] = true;
1697 $_SESSION['pay_statistics']['until_check'] = $_POST['until_check'];
1698 $_SESSION['pay_statistics']['from_check'] = $_POST['from_check'];
1699 $_SESSION['pay_statistics']['transaction_type'] = isset($_POST['transaction_type']) ? $_POST['transaction_type'] : '' ;
1700 $_SESSION['pay_statistics']['transaction_value'] = isset($_POST['transaction_value']) ? $_POST['transaction_value'] : '';
1701 $_SESSION['pay_statistics']['adm_filter_title_id'] = (int)$_POST['adm_filter_title_id'];
1702
1703 if($_SESSION['pay_statistics']['from_check'] == '1')
1704 {
1705 $_SESSION['pay_statistics']['from']['date']['d'] = $_POST['from']['date']['d'];
1706 $_SESSION['pay_statistics']['from']['date']['m'] = $_POST['from']['date']['m'];
1707 $_SESSION['pay_statistics']['from']['date']['y'] = $_POST['from']['date']['y'];
1708 }
1709 else
1710 {
1711 $_SESSION['pay_statistics']['from']['date']['d'] = '';
1712 $_SESSION['pay_statistics']['from']['date']['m'] = '';
1713 $_SESSION['pay_statistics']['from']['date']['y'] = '';
1714 }
1715
1716 if($_SESSION['pay_statistics']['until_check']== '1')
1717 {
1718 $_SESSION['pay_statistics']['til']['date']['d'] = $_POST['til']['date']['d'];
1719 $_SESSION['pay_statistics']['til']['date']['m'] = $_POST['til']['date']['m'];
1720 $_SESSION['pay_statistics']['til']['date']['y'] = $_POST['til']['date']['y'];
1721 }
1722 else
1723 {
1724 $_SESSION['pay_statistics']['til']['date']['d'] = '';
1725 $_SESSION['pay_statistics']['til']['date']['m'] = '';
1726 $_SESSION['pay_statistics']['til']['date']['y'] = '';
1727 }
1728
1729 $_SESSION['pay_statistics']['payed'] = $_POST['payed'];
1730 $_SESSION['pay_statistics']['access'] = $_POST['access'];
1731 $_SESSION['pay_statistics']['pay_method'] = $_POST['pay_method'];
1732 $_SESSION['pay_statistics']['customer'] = isset ($_POST['customer']) ? $_POST['customer'] : '';
1733 $_SESSION['pay_statistics']['vendor'] = isset ($_POST['vendor']) ? $_POST['vendor']: '';
1734
1735 }
1736
1737 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
1738
1739 $filter_form = new ilPropertyFormGUI();
1740 $filter_form->setFormAction($this->ctrl->getFormAction($this));
1741 $filter_form->setTitle($this->lng->txt('pay_filter'));
1742 $filter_form->setId('formular');
1743 $filter_form->setTableWidth('100 %');
1744 //filter
1745 $o_hide_check = new ilCheckBoxInputGUI($this->lng->txt('show_filter'),'show_filter');
1746 $o_hide_check->setValue(1);
1747 $o_hide_check->setChecked($_POST['show_filter'] ? 1 : 0);
1748
1749 $o_hidden = new ilHiddenInputGUI('updateView');
1750 $o_hidden->setValue(1);
1751 $o_hidden->setPostVar('updateView');
1752 $o_hide_check->addSubItem($o_hidden);
1753
1754 $o_transaction_type = new ilSelectInputGUI();
1755 $trans_option = array($this->lng->txt('pay_starting'),$this->lng->txt('pay_ending'));
1756 $trans_value = array('0','1');
1757 $o_transaction_type->setTitle($this->lng->txt('paya_transaction'));
1758 $o_transaction_type->setOptions($trans_option);
1759 $o_transaction_type->setValue($_SESSION['pay_statistics']['transaction_type']);
1760 $o_transaction_type->setPostVar('transaction_type');
1761 $o_hide_check->addSubItem($o_transaction_type);
1762
1763 $o_transaction_val = new ilTextInputGUI();
1764 $o_transaction_val->setValue($_SESSION['pay_statistics']['transaction_value']);
1765 $o_transaction_val->setPostVar('transaction_value');
1766 $o_hide_check->addSubItem($o_transaction_val);
1767
1768 $o_customer = new ilTextInputGUI();
1769 $o_customer->setTitle($this->lng->txt('paya_customer'));
1770 $o_customer->setValue($_SESSION['pay_statistics']['customer']);
1771 $o_customer->setPostVar('customer');
1772 $o_hide_check->addSubItem($o_customer);
1773
1774 $o_vendor = new ilTextInputGUI();
1775 $o_vendor->setTitle($this->lng->txt('paya_vendor'));
1776 $o_vendor->setValue($_SESSION['pay_statistics']['vendor']);
1777 $o_vendor->setPostVar('vendor');
1778 $o_hide_check->addSubItem($o_vendor);
1779
1780 $o_from_check = new ilCheckBoxInputGUI($this->lng->txt('pay_order_date_from'),'from_check');
1781 $o_from_check->setValue(1);
1782 $o_from_check->setChecked($_SESSION['pay_statistics']['from_check'] ? 1 : 0);
1783
1784 $o_date_from = new ilDateTimeInputGUI();
1785 $o_date_from->setPostVar('from');
1786
1787 if($_SESSION['pay_statistics']['from_check'] == '1')
1788 {
1789 $o_date_from->setValueByArray($_SESSION['pay_statistics']['from']);
1790 $o_date_from->checkInput();
1791 }
1792
1793 $o_from_check->addSubItem($o_date_from);
1794 $o_hide_check->addSubItem($o_from_check);
1795
1796 $o_until_check = new ilCheckBoxInputGUI($this->lng->txt('pay_order_date_til'), 'until_check');
1797 $o_until_check->setValue(1);
1798 $o_until_check->setChecked($_SESSION['pay_statistics']['until_check'] ? 1 : 0);
1799
1800 $o_date_until = new ilDateTimeInputGUI();
1801 $o_date_until->setPostVar('til');
1802
1803 if($_SESSION['pay_statistics']['until_check'] == '1')
1804 {
1805 $o_date_until->setValueByArray($_SESSION['pay_statistics']['til']);
1806 $o_date_until->checkInput();
1807 }
1808
1809 $o_until_check->addSubItem($o_date_until);
1810 $o_hide_check->addSubItem($o_until_check);
1811
1812 // title filter
1813 $this->__initBookingObject();
1814 $title_options['all']=$this->lng->txt('pay_all');
1815 $unique_titles = $this->booking_obj->getUniqueTitles();
1816
1817 if(is_array($unique_titles) && count($unique_titles))
1818 {
1819 foreach($unique_titles as $ref_id)
1820 {
1821 $title_options[$ref_id] = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($ref_id));
1822 }
1823 }
1824
1825 $o_object_title = new ilSelectInputGUI();
1826 $o_object_title->setTitle($this->lng->txt('title'));
1827 $o_object_title->setOptions($title_options);
1828 $o_object_title->setValue($_SESSION["pay_statistics"]["adm_filter_title_id"]);
1829 $o_object_title->setPostVar('adm_filter_title_id');
1830 $o_hide_check->addSubItem($o_object_title);
1831
1832 $o_payed = new ilSelectInputGUI();
1833 $payed_option = array('all'=>$this->lng->txt('pay_all'),'1'=>$this->lng->txt('yes'),'0'=>$this->lng->txt('no'));
1834
1835 $o_payed->setTitle($this->lng->txt('paya_payed'));
1836 $o_payed->setOptions($payed_option);
1837 $o_payed->setValue($_SESSION['pay_statistics']['payed']);
1838 $o_payed->setPostVar('payed');
1839
1840 $o_hide_check->addSubItem($o_payed);
1841
1842 $o_access = new ilSelectInputGUI();
1843 $access_option = array('all'=>$this->lng->txt('pay_all'),'1'=>$this->lng->txt('yes'),'0'=>$this->lng->txt('no'));
1844
1845 $o_access->setTitle($this->lng->txt('paya_access'));
1846 $o_access->setOptions($access_option);
1847 $o_access->setValue($_SESSION['pay_statistics']['access']);
1848 $o_access->setPostVar('access');
1849 $o_hide_check->addSubItem($o_access);
1850
1851 $o_paymethod = new ilSelectInputGUI();
1852 $o_paymethod->setTitle($this->lng->txt('payment_system'));
1853 $o_paymethod->setOptions(ilPaymethods::getPayMethodsOptions('all'));
1854 $o_paymethod->setValue($_SESSION['pay_statistics']['pay_method']);
1855 $o_paymethod->setPostVar('pay_method');
1856 $o_hide_check->addSubItem($o_paymethod);
1857
1858 $filter_form->addCommandButton('statistic', $this->lng->txt('pay_update_view'));
1859 $filter_form->addCommandButton('resetFilter', $this->lng->txt('pay_reset_filter'));
1860
1861 $filter_form->addItem($o_hide_check);
1862
1863 $this->tpl->setVariable('FORM', $filter_form->getHTML());
1864 //else $filter_form->checkInput();
1865
1866 // STATISTICS TABLE
1867 $this->__initBookingObject();
1868
1869 if(!count($bookings = $this->booking_obj->getBookings()))
1870 {
1871 ilUtil::sendInfo($this->lng->txt('paya_no_bookings'));
1872
1873 return true;
1874 }
1875# else
1876# {
1877# $this->__showButton('exportVendors',$this->lng->txt('excel_export'));
1878# }
1879
1880 include_once 'Services/User/classes/class.ilObjUser.php';
1881 $object_title_cache = array();
1882 $user_title_cache = array();
1883
1884 $counter = 0;
1885 foreach($bookings as $booking)
1886 {
1887 if(array_key_exists($booking['ref_id'], $object_title_cache))
1888 {
1889 $tmp_obj = $object_title_cache[$booking['ref_id']];
1890 }
1891 else
1892 {
1893 $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($booking['ref_id']));
1894 $object_title_cache[$booking['ref_id']] = $tmp_obj;
1895 }
1896
1897
1898 if(array_key_exists($booking['b_vendor_id'], $user_title_cache))
1899 {
1900 $tmp_vendor = $user_title_cache[$booking['b_vendor_id']];
1901 }
1902 else
1903 {
1904 $tmp_vendor = ilObjUser::_lookupLogin($booking['b_vendor_id']);
1905 $user_title_cache[$booking['b_vendor_id']] = $tmp_vendor;
1906 }
1907 if(array_key_exists($booking['customer_id'], $user_title_cache))
1908 {
1909 $tmp_purchaser = $user_title_cache[$booking['customer_id']];
1910 }
1911 else
1912 {
1913 if(ANONYMOUS_USER_ID == $booking['customer_id'])
1914 {
1915 $tmp_purchaser = ilObjUser::_lookupLogin($booking['customer_id']);
1916 $purchaser_name = $booking['name_extern'];
1917 $tmp_purchaser_email = $booking['email_extern'];
1918 }
1919 else
1920 {
1921 $tmp_purchaser = ilObjUser::_lookupLogin($booking['customer_id']);
1922 $tmp_purchaser_name = ilObjUser::_lookupName($booking['customer_id']);
1923 $purchaser_name = $tmp_purchaser_name['firstname'].' '.$tmp_purchaser_name['lastname'];
1924 $tmp_purchaser_email = ilObjUser::_lookupEmail($booking['customer_id']);
1925 }
1926 $user_title_cache[$booking['customer_id']] = $tmp_purchaser;
1927 }
1928
1929 $transaction = $booking['transaction_extern'];
1930 $str_paymethod = ilPayMethods::getStringByPaymethod($booking['b_pay_method']);
1931 $transaction .= $booking['transaction']."<br> (" . $str_paymethod . ")";
1932
1933 $f_result[$counter]['transaction'] = $transaction;
1934 $f_result[$counter]['object_title'] = ($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted'));
1935 $f_result[$counter]['vendor'] = ($tmp_vendor != '' ? '['.$tmp_vendor.']' : $this->lng->txt('user_deleted'));
1936 $f_result[$counter]['customer'] = ($tmp_purchaser != '' ?
1937 $purchaser_name. ' ['.$tmp_purchaser.']<br>'
1938 .$tmp_purchaser_email
1939 : $this->lng->txt('user_deleted'));
1940 $f_result[$counter]['order_date'] = ilDatePresentation::formatDate(new ilDate($booking['order_date'], IL_CAL_UNIX));
1941
1942
1943 if($booking['duration'] == 0 && $booking['access_enddate'] == NULL)
1944 {
1945 $f_result[$counter]['duration'] = $this->lng->txt("unlimited_duration");
1946 }
1947 else
1948 {
1949// if($booking['duration'] > 0 )
1950// {
1951// $f_result[$counter]['duration'] = $booking['duration'].' '.$this->lng->txt('paya_months').' / </br>';
1952// }
1953 $f_result[$counter]['duration'] .= ilDatePresentation::formatDate(new ilDate($booking['access_startdate'], IL_CAL_DATETIME))
1954 .' - '.ilDatePresentation::formatDate(new ilDate($booking['access_enddate'], IL_CAL_DATETIME));
1955 }
1956
1957 $f_result[$counter]['price'] = $booking['price'].' '.$booking['currency_unit'];
1958 $f_result[$counter]['discount'] = ($booking['discount'] != '' ? ($booking['discount'].' '.$booking['currency_unit']) : '&nbsp;');
1959
1960 $payed_access = $booking['payed'] ?
1961 $this->lng->txt('yes') :
1962 $this->lng->txt('no');
1963
1964 $payed_access .= '/';
1965 $payed_access .= $booking['access_granted'] ?
1966 $this->lng->txt('yes') :
1967 $this->lng->txt('no');
1968
1969 $f_result[$counter]['payed_access'] = $payed_access;
1970
1971 $this->ctrl->setParameter($this,"booking_id",$booking['booking_id']);
1972 $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editStatistic")."\">".$this->lng->txt("edit")."</a></div>";
1973
1974 $f_result[$counter]['edit'] = $link_change;
1975
1976 unset($tmp_obj);
1977 unset($tmp_vendor);
1978 unset($tmp_purchaser);
1979
1980 ++$counter;
1981 }
1982 return $this->__showStatisticTable($f_result);
1983 }
1984
1985 public function editStatisticObject($a_show_confirm_delete = false)
1986 {
1987 global $ilToolbar;
1988
1989 include_once './Services/Payment/classes/class.ilPayMethods.php';
1990
1991 if(!isset($_GET['booking_id']))
1992 {
1993 ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
1994 $this->showStatistics();
1995
1996 return true;
1997 }
1998
1999 $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'statistic'));
2000
2001 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
2002 $this->ctrl->setParameter($this,'booking_id',(int) $_GET['booking_id']);
2003
2004 // confirm delete
2005 if($a_show_confirm_delete)
2006 {
2007 $oConfirmationGUI = new ilConfirmationGUI();
2008
2009 // set confirm/cancel commands
2010 $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this,"performDelete"));
2011 $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_stat"));
2012 $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "statistic");
2013 $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDelete");
2014
2015 $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHTML());
2016 return true;
2017 }
2018
2019
2020 $this->__initBookingObject();
2021 $bookings = $this->booking_obj->getBookings();
2022 $booking = $bookings[(int) $_GET['booking_id']];
2023
2024 // get customer_obj
2025 $tmp_user = ilObjectFactory::getInstanceByObjId($booking['customer_id'], false);
2026
2027 $oForm = new ilPropertyFormGUI();
2028 $oForm->setFormAction($this->ctrl->getFormAction($this));
2029 $oForm->setId('stat_form');
2030 $oForm->setTableWidth('50 %');
2031 if(is_object($tmp_user))
2032 {
2033 $frm_user = $tmp_user->getFullname().' ['.$tmp_user->getLogin().']';
2034 }
2035 else
2036 {
2037 $frm_user = $this->lng->txt('user_deleted');
2038 }
2039 $oForm->setTitle($frm_user);
2040
2041 $pObj = new ilPaymentObject($this->user_obj, $booking['pobject_id']);
2042 $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($pObj->getRefId()));
2043
2044 // object_title
2045 $oTitleGUI = new ilNonEditableValueGUI($this->lng->txt('title'));
2046 $oTitleGUI->setValue($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted'));
2047 $oForm->addItem($oTitleGUI);
2048
2049 // transaction
2050 $oTransactionGUI = new ilNonEditableValueGUI($this->lng->txt('paya_transaction'));
2051 $oTransactionGUI->setValue($booking['transaction']);
2052 $oForm->addItem($oTransactionGUI);
2053
2054 //vendor
2055 $oVendorGUI = new ilNonEditableValueGUI($this->lng->txt('paya_vendor'));
2056 $tmp_vendor = ilObjectFactory::getInstanceByObjId($booking['b_vendor_id'], false);
2057 if(is_object($tmp_vendor))
2058 {
2059 $frm_vendor = $tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']';
2060 }
2061 else
2062 {
2063 $frm_vendor = $this->lng->txt('user_deleted');
2064 }
2065 $oVendorGUI->setValue($frm_vendor);
2066 $oForm->addItem($oVendorGUI);
2067
2068 // paymethod
2069 $oPaymethodGUI = new ilNonEditableValueGUI($this->lng->txt('paya_pay_method'));
2070 $oPaymethodGUI->setValue(ilPayMethods::getStringByPaymethod($booking['b_pay_method']));
2071 $oForm->addItem($oPaymethodGUI);
2072
2073 // order_date
2074 $oOrderdateGUI = new ilNonEditableValueGUI($this->lng->txt('paya_order_date'));
2075 $oOrderdateGUI->setValue(ilDatePresentation::formatDate(new ilDate($booking['order_date'], IL_CAL_UNIX)));
2076 $oForm->addItem($oOrderdateGUI);
2077
2078 // duration
2079 $oDurationGUI = new ilNonEditableValueGUI($this->lng->txt('duration'));
2080 if($booking['duration'] == 0 && $booking['access_enddate'] == NULL)
2081 {
2082 $frm_duration = $this->lng->txt("unlimited_duration");
2083
2084 }
2085 else
2086 {
2087 if($booking['duration'] > 0)
2088 {
2089 $frm_duration = $booking['duration'].' '.$this->lng->txt('paya_months').'</br>';
2090 }
2091 $frm_duration .= ilDatePresentation::formatDate(new ilDate($booking['access_startdate'], IL_CAL_DATETIME))
2092 .' - '.ilDatePresentation::formatDate(new ilDate($booking['access_enddate'], IL_CAL_DATETIME));
2093
2094 }
2095 $oDurationGUI->setValue($frm_duration);
2096 $oForm->addItem($oDurationGUI);
2097
2098 // price
2099 $oPriceGUI = new ilNonEditableValueGUI($this->lng->txt('price_a'));
2100 $oPriceGUI->setValue($booking['price'].' '.$booking['currency_unit']);
2101 $oForm->addItem($oPriceGUI);
2102
2103 //discount
2104 $oDiscountGUI = new ilNonEditableValueGUI($this->lng->txt('paya_coupons_coupon'));
2105 $oDiscountGUI->setValue($booking['discount'].' '.$booking['currency_unit']);
2106 $oForm->addItem($oDiscountGUI);
2107
2108 // payed
2109 $oPayedGUI = new ilSelectInputGUI();
2110 $payed_option = array(0 => $this->lng->txt('no'),1 => $this->lng->txt('yes'));
2111
2112 $oPayedGUI->setTitle($this->lng->txt('paya_payed'));
2113 $oPayedGUI->setOptions($payed_option);
2114 $oPayedGUI->setValue($booking['payed']);
2115 $oPayedGUI->setPostVar('payed');
2116 $oForm->addItem($oPayedGUI);
2117
2118 // access
2119 $oAccessGUI = new ilSelectInputGUI();
2120 $access_option = array(0 => $this->lng->txt('no'),1 => $this->lng->txt('yes'));
2121
2122 $oAccessGUI->setTitle($this->lng->txt('paya_access'));
2123 $oAccessGUI->setOptions($access_option);
2124 $oAccessGUI->setValue($booking['access_granted']);
2125 $oAccessGUI->setPostVar('access');
2126 $oForm->addItem($oAccessGUI);
2127
2128 $oForm->addCommandButton('updateStatistic',$this->lng->txt('save'));
2129 $oForm->addCommandButton('deleteStatistic',$this->lng->txt('delete'));
2130
2131 // show CUSTOMER_DATA if isset -> setting: save_user_address
2132 if(ilPayMethods::_PMEnabled($booking['b_pay_method']))
2133 {
2134 $oForm2 = new ilPropertyFormGUI();
2135 $oForm2->setId('cust_form');
2136 $oForm2->setTableWidth('50%');
2137 $oForm2->setTitle($frm_user);
2138
2139 // email
2140 $oEmailGUI = new ilNonEditableValueGUI($this->lng->txt('email'));
2141 $email = (!$tmp_user) ? $this->lng->txt('user_deleted') : $tmp_user->getEmail();
2142 $oEmailGUI->setValue($email);
2143 $oForm2->addItem($oEmailGUI);
2144
2145 // street
2146 $oStreetGUI = new ilNonEditableValueGUI($this->lng->txt('street'));
2147 $oStreetGUI->setValue($booking['street']);
2148 $oForm2->addItem($oStreetGUI);
2149
2150 // pobox
2151 $oPoBoxGUI = new ilNonEditableValueGUI($this->lng->txt('pay_bmf_po_box'));
2152 $oPoBoxGUI->setValue($booking['po_box']);
2153 $oForm2->addItem($oPoBoxGUI);
2154
2155 // zipcode
2156 $oPoBoxGUI = new ilNonEditableValueGUI($this->lng->txt('zipcode'));
2157 $oPoBoxGUI->setValue($booking['zipcode']);
2158 $oForm2->addItem($oPoBoxGUI);
2159
2160 // city
2161 $oCityGUI = new ilNonEditableValueGUI($this->lng->txt('city'));
2162 $oCityGUI->setValue($booking['city']);
2163 $oForm2->addItem($oCityGUI);
2164
2165 // country
2166 $oCountryGUI = new ilNonEditableValueGUI($this->lng->txt('country'));
2167 $oCountryGUI->setValue($booking['country']);
2168 $oForm2->addItem($oCountryGUI);
2169 }
2170
2171 $this->tpl->setVariable('FORM',$oForm->getHTML());
2172 $this->tpl->setVariable('FORM_2',$oForm2->getHTML());
2173 return true;
2174
2175 }
2176 public function updateStatisticObject()
2177 {
2178 if(!isset($_GET['booking_id']))
2179 {
2180 ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
2181 $this->statisticObject();
2182
2183 return true;
2184 }
2185 $this->__initBookingObject();
2186
2187 $this->booking_obj->setBookingId((int) $_GET['booking_id']);
2188 $this->booking_obj->setAccess((int) $_POST['access']);
2189 $this->booking_obj->setPayed((int) $_POST['payed']);
2190
2191 if($this->booking_obj->update())
2192 {
2193 ilUtil::sendSuccess($this->lng->txt('paya_updated_booking'));
2194
2195 $this->statisticObject();
2196 return true;
2197 }
2198 else
2199 {
2200 ilUtil::sendInfo($this->lng->txt('paya_error_update_booking'));
2201 $this->statisticObject();
2202
2203 return true;
2204 }
2205 }
2206
2207 public function deleteStatisticObject()
2208 {
2209 if(!isset($_GET['booking_id']))
2210 {
2211 ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
2212 $this->statisticObject();
2213
2214 return true;
2215 }
2216 ilUtil::sendQuestion($this->lng->txt('paya_sure_delete_stat'));
2217
2218 $this->editStatisticObject(true);
2219
2220 return true;
2221 }
2222 public function performDeleteObject()
2223 {
2224 if(!isset($_GET['booking_id']))
2225 {
2226 ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
2227 $this->statisticObject();
2228
2229 return true;
2230 }
2231
2232 $this->__initBookingObject();
2233 $this->booking_obj->setBookingId((int) $_GET['booking_id']);
2234 if(!$this->booking_obj->delete())
2235 {
2236 die('Error deleting booking');
2237 }
2238 ilUtil::sendInfo($this->lng->txt('pay_deleted_booking'));
2239
2240 $this->statisticObject();
2241
2242 return true;
2243 }
2244
2250 public function getTabs($tabs_gui)
2251 {
2252 global $rbacsystem, $ilHelp;
2253
2254 $tabs_gui->clearTargets();
2255 $ilHelp->setScreenIdComponent("pays");
2256 if ($rbacsystem->checkAccess('visible,read',$this->object->getRefId()))
2257 {
2258 // Settings
2259 $tabs_gui->addTarget('settings', $this->ctrl->getLinkTarget($this, 'generalSettings'),
2260 array('saveGeneralSettings','generalSettings ','saveBmfSettings','savePaypalSettings','paypalSettings',
2261// 'saveEPaySettings','epaySettings','saveERPsettings','delERPpreview','','testERPsettings','erpSettings',
2262 '','view'), '', '');
2263
2264 // Bookings
2265 $tabs_gui->addTarget('bookings', $this->ctrl->getLinkTarget($this, 'statistic'),
2266 array( 'statistic','editStatistic','updateStatistic','deleteStatistic','performDelete',
2267 'resetFilter','exportVendors','addCustomer', 'saveCustomer','showObjectSelector',
2268 'searchUserSP','performSearchSP'), '', '');
2269 // Objects
2270 $tabs_gui->addTarget('objects', $this->ctrl->getLinkTarget($this, 'objects'),
2271 array('updateObjectDetails','deleteObject','performObjectDelete','objects',
2272 'editPrices','addPrice','editDetails','resetObjectFilter'), '', '');
2273 // Vendors
2274 $tabs_gui->addTarget('vendors', $this->ctrl->getLinkTarget($this, 'vendors'),
2275 array('vendors','searchUser','search','performSearch','addVendor','addUser','exportVendors','deleteVendors','performDeleteVendors',
2276 'cancelDeleteVendors','editVendor','performEditVendor'), '', '');
2277
2278#TODO: CURRENCY not finished yet
2279/*
2280 // Currencies
2281 $tabs_gui->addTarget('currencies',
2282 $this->ctrl->getLinkTarget($this, 'currencies'),
2283 array('currencies','editCurrency','deleteCurrency','performDeleteCurrency','updateCurrency','updateDefaultCurrency'), '','');
2284/**/
2285 // Paymethods
2286 $tabs_gui->addTarget('pay_methods', $this->ctrl->getLinkTarget($this, 'payMethods'),
2287 #array('payMethods','savePayMethods'), '', '');
2288 array('payMethods','savePayMethods ','saveBmfSettings','savePaypalSettings','paypalSettings',
2289// 'saveEPaySettings','epaySettings','saveERPsettings','delERPpreview','','testERPsettings','erpSettings',
2290 '','view'), '', '');
2291
2292 // Topics
2293 $tabs_gui->addTarget('topics',
2294 $this->ctrl->getLinkTargetByClass('ilshoptopicsgui', ''), 'payment_topics', '', '');
2295
2296 // Vats
2297 $tabs_gui->addTarget('vats',
2298 $this->ctrl->getLinkTarget($this, 'vats'), 'vats', '', '');
2299
2300 // Documents
2301 $tabs_gui->addTarget('documents', $this->ctrl->getLinkTarget($this, 'documents'),
2302 array('documents','TermsConditions','saveTermsConditions','BillingMail',
2303 'saveBillingMail','InvoiceNumber','saveInvoiceNumber','StatutoryRegulations', 'saveStatutoryRegulations'), '', '');
2304 }
2305
2306 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
2307 {
2308 // Permissions
2309 $tabs_gui->addTarget('perm_settings',
2310 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), 'perm'), array('perm','info','owner'), 'ilpermissiongui');
2311 }
2312 }
2313
2314 private function getSubTabs($a_tab, $a_sub_tab = null)
2315 {
2316 switch($a_tab)
2317 {
2318 case 'bookings':
2319 break;
2320 case 'objects':
2321 break;
2322 case 'vendors':
2323 break;
2324 case 'payMethods':
2325
2326 if(!$a_sub_tab) $a_sub_tab = 'payMethods';
2327 $this->tabs_gui->addSubTabTarget('settings',
2328 $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'payMethods'),
2329 '','', '',$a_sub_tab == 'payMethods' ? true : false);
2330
2331 $this->tabs_gui->addSubTabTarget('pays_bmf',
2332 $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'bmfSettings'),
2333 '','', '',$a_sub_tab == 'bmfSettings' ? true : false);
2334
2335 $this->tabs_gui->addSubTabTarget('pays_paypal',
2336 $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'paypalSettings'),
2337 '','', '',$a_sub_tab == 'paypalSettings' ? true : false);
2338
2339 break;
2340 case 'currencies':
2341 break;
2342 case 'vats':
2343 break;
2344 case 'topics':
2345 if(!$a_sub_tab) $a_sub_tab = 'topics';
2346 $this->tabs_gui->addSubTabTarget('topics',
2347 $this->ctrl->getLinkTargetByClass('ilshoptopicsgui', 'showTopicsList'),
2348 '','', '',$a_sub_tab == 'showTopicsList' ? true : false);
2349
2350 $this->tabs_gui->addSubTabTarget('topics_settings',
2351 $this->ctrl->getLinkTargetByClass('ilshoptopicsgui', 'showTopicsSettings'),
2352 '','', '',$a_sub_tab == 'showTopicsSettings' ? true : false);
2353
2354 break;
2355 case 'documents':
2356 if(!$a_sub_tab) $a_sub_tab = 'terms_conditions';
2357 $this->tabs_gui->addSubTabTarget('terms_conditions',
2358 $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'TermsConditions'),
2359 '','', '',$a_sub_tab == 'terms_conditions' ? true : false);
2360
2361 $this->tabs_gui->addSubTabTarget('billing_mail',
2362 $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'BillingMail'),
2363 '','', '',$a_sub_tab == 'billing_mail' ? true : false);
2364 $this->tabs_gui->addSubTabTarget('invoice_number',
2365 $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'InvoiceNumber'),
2366 '','', '',$a_sub_tab == 'invoice_number' ? true : false);
2367 $this->tabs_gui->addSubTabTarget('statutory_regulations',
2368 $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'StatutoryRegulations'),
2369 '','', '',$a_sub_tab == 'statutory_regulations' ? true : false);
2370 break;
2371
2372 default:
2373 case 'settings':
2374 if (($_GET['cmd'] == '') || ($_GET['cmd'] == 'view') || ($a_sub_tab == 'generalSettings'))
2375 $a_sub_tab = 'generalSettings';
2376 break;
2377 }
2378 }
2379
2380 public function generalSettingsObject()
2381 {
2382 global $rbacsystem, $ilSetting;
2383
2387 // MINIMUM ACCESS LEVEL = 'read'
2388 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2389 {
2390 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
2391 }
2392
2393 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html','Services/Payment');
2394
2396 $genSetData = $genSet->getAll();
2397
2398 $form = new ilPropertyFormGUI();
2399 $form->setFormAction($this->ctrl->getFormAction($this, 'saveGeneralSettings'));
2400 $form->setTitle($this->lng->txt('pays_general_settings'));
2401
2402 $form->addCommandButton('saveGeneralSettings',$this->lng->txt('save'));
2403
2404 // enable webshop
2405 $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_enable_shop'), 'shop_enabled');
2406 $formItem->setChecked((int)$genSetData['shop_enabled']);
2407 $formItem->setInfo($this->lng->txt('pay_enable_shop_info'));
2408 $form->addItem($formItem);
2409
2410 $formItem = new ilTextInputGUI($this->lng->txt('pays_currency_unit'), 'currency_unit');
2411 $formItem->setSize(5);
2412 $formItem->setValue($this->error != '' && isset($_POST['currency_unit'])
2413 ? ilUtil::prepareFormOutput($_POST['currency_unit'],true)
2414 : ilUtil::prepareFormOutput($genSetData['currency_unit'],true));
2415 $formItem->setRequired(true);
2416 $form->addItem($formItem);
2417
2418 $formItem = new ilTextAreaInputGUI($this->lng->txt('pays_address'), 'address');
2419 $formItem->setRows(7);
2420 $formItem->setCols(35);
2421 $formItem->setRequired(true);
2422 $formItem->setValue($this->error != '' && isset($_POST['address'])
2423 ? ilUtil::prepareFormOutput($_POST['address'],true)
2424 : $genSetData['address']);
2425 $form->addItem($formItem);
2426
2427 $formItem = new ilTextAreaInputGUI($this->lng->txt('pays_bank_data'), 'bank_data');
2428 $formItem->setRows(7);
2429 $formItem->setCols(35);
2430 $formItem->setRequired(true);
2431 $formItem->setValue($this->error != '' && isset($_POST['bank_data'])
2432 ? ilUtil::prepareFormOutput($_POST['bank_data'],true)
2433 : $genSetData['bank_data']);
2434 $form->addItem($formItem);
2435
2436 $formItem = new ilTextAreaInputGUI($this->lng->txt('pays_add_info'), 'add_info');
2437 $formItem->setRows(7);
2438 $formItem->setCols(35);
2439 $formItem->setValue($this->error != '' && isset($_POST['add_info'])
2440 ? ilUtil::prepareFormOutput($_POST['add_info'],true)
2441 : $genSetData['add_info']);
2442 $form->addItem($formItem);
2443
2444 $formItem = new ilTextInputGUI($this->lng->txt('pays_pdf_path'), 'pdf_path');
2445 $formItem->setValue($this->error != "" && isset($_POST['pdf_path'])
2446 ? ilUtil::prepareFormOutput($_POST['pdf_path'],true)
2447 : ilUtil::prepareFormOutput($genSetData['pdf_path'],true));
2448 $formItem->setRequired(true);
2449 $form->addItem($formItem);
2450
2451 // max hits
2452 $formItem = new ilSelectInputGUI($this->lng->txt('pay_max_hits'), 'max_hits');
2453 $formItem->setValue($genSetData['max_hits']);
2454 $options = array();
2455 for($i = 10; $i <= 100; $i += 10)
2456 {
2457 $options[$i] = $i;
2458 }
2459 $formItem->setOptions($options);
2460 $formItem->setInfo($this->lng->txt('pay_max_hits_info'));
2461 $form->addItem($formItem);
2462
2463 // hide advanced search
2464 $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_hide_advanced_search'), 'hide_advanced_search');
2465 $formItem->setChecked((int)$genSetData['hide_advanced_search']);
2466 $formItem->setInfo($this->lng->txt('pay_hide_advanced_search_info'));
2467 $form->addItem($formItem);
2468
2469 // hide shop news
2470 $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_hide_news'), 'hide_news');
2471 $formItem->setChecked((int)$genSetData['hide_news']);
2472 $formItem->setInfo($this->lng->txt('pay_hide_news_info'));
2473 $form->addItem($formItem);
2474
2475 // Hide coupons
2476 $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_hide_coupons'), 'hide_coupons');
2477 $formItem->setChecked((int)$genSetData['hide_coupons']);
2478 $formItem->setInfo($this->lng->txt('pay_hide_coupons'));
2479 $form->addItem($formItem);
2480
2481 // hide shop news
2482 $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_hide_shop_info'), 'hide_shop_info');
2483 $formItem->setChecked((int)$genSetData['hide_shop_info']);
2484 $formItem->setInfo($this->lng->txt('pay_hide_shop_info_info'));
2485 $form->addItem($formItem);
2486
2487 // use shop specials
2488 $formItem = new ilCheckboxInputGUI($this->lng->txt('use_shop_specials'), 'use_shop_specials');
2489 $formItem->setChecked((int)$genSetData['use_shop_specials']);
2490 $formItem->setInfo($this->lng->txt('use_shop_specials_info'));
2491 $form->addItem($formItem);
2492
2493 // show general filter
2494 $formItem = new ilCheckboxInputGUI($this->lng->txt('show_general_filter'), 'show_general_filter');
2495 $formItem->setChecked((int)$genSetData['show_general_filter']);
2496 $formItem->setInfo($this->lng->txt('show_general_filter_info'));
2497 $form->addItem($formItem);
2498
2499 // show shop explorer
2500 $formItem = new ilCheckboxInputGUI($this->lng->txt('show_shop_explorer'), 'show_shop_explorer');
2501 $formItem->setChecked((int)$genSetData['show_shop_explorer']);
2502 $formItem->setInfo($this->lng->txt('show_shop_explorer_info'));
2503 $form->addItem($formItem);
2504
2505
2506 // Enable payment notifications
2507 $payment_noti = new ilCheckboxInputGUI($this->lng->txt("payment_notification"), "payment_notification");
2508 $payment_noti->setValue(1);
2509 $payment_noti->setChecked((int)$ilSetting->get('payment_notification', 0) == 1);
2510 $payment_noti->setInfo($this->lng->txt('payment_notification_desc'));
2511
2512 $num_days = new ilNumberInputGUI($this->lng->txt('payment_notification_days'),'payment_notification_days');
2513 $num_days->setSize(3);
2514 $num_days->setMinValue(0);
2515 $num_days->setMaxValue(120);
2516 $num_days->setRequired(true);
2517 $num_days->setValue($ilSetting->get('payment_notification_days'));
2518 $num_days->setInfo($this->lng->txt('payment_notification_days_desc'));
2519
2520 $payment_noti->addSubItem($num_days);
2521 $form->addItem($payment_noti);
2522
2523
2524 $this->tpl->setVariable('FORM',$form->getHTML());
2525 return true;
2526 }
2527
2528 public function saveGeneralSettingsObject()
2529 {
2530 global $rbacsystem, $ilSetting;
2531
2532 // MINIMUM ACCESS LEVEL = 'read'
2533 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2534 {
2535 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
2536 }
2537
2542
2543 if ($_POST['currency_unit'] == '' ||
2544 $_POST['address'] == '' ||
2545 $_POST['bank_data'] == '' ||
2546 $_POST['pdf_path'] == '')
2547 {
2548 $this->error = $this->lng->txt('pays_general_settings_not_valid');
2549 ilUtil::sendFailure($this->error);
2550 return $this->generalSettingsObject();
2551
2552 }
2553
2554 $genSet->set('currency_unit', $_POST['currency_unit'], 'currencies');
2555 $genSet->set('address', $_POST['address'], 'invoice');
2556 $genSet->set('bank_data', $_POST['bank_data'], 'invoice');
2557 $genSet->set('add_info', $_POST['add_info'], 'invoice');
2558 $genSet->set('pdf_path', $_POST['pdf_path'], 'invoice');
2559
2560 $genSet->set('max_hits', $_POST['max_hits'], 'gui');
2561
2562 $genSet->set('hide_advanced_search', $_POST['hide_advanced_search'], 'gui');
2563 #$genSet->set('hide_filtering', $_POST['hide_filtering'], 'gui');
2564 $genSet->set('objects_allow_custom_sorting', $_POST['objects_allow_custom_sorting'], 'gui');
2565 $genSet->set('hide_coupons', $_POST['hide_coupons'], 'gui');
2566 $genSet->set('hide_news', $_POST['hide_news'], 'gui');
2567
2568 if( (int)$_POST['hide_news'] == 0 )
2569 {
2570 if( (int)$ilSetting->get('payment_news_archive_period') == 0)
2571 {
2572 $ilSetting->set('payment_news_archive_period', '5');
2573 }
2574 }
2575
2576 $genSet->set('hide_shop_info', $_POST['hide_shop_info'], 'gui');
2577 $genSet->set('use_shop_specials', $_POST['use_shop_specials'], 'gui');
2578 $genSet->set('show_general_filter', $_POST['show_general_filter'], 'gui');
2579 $genSet->set('show_shop_explorer', $_POST['show_shop_explorer'], 'gui');
2580
2581 // payment notification
2582 $ilSetting->set('payment_notification', $_POST['payment_notification'] ? 1 : 0);
2583 $ilSetting->set('payment_notification_days', $_POST['payment_notification_days']);
2584
2585 $check = $this->checkShopActivationObject();
2586 if($check == true && (int)$_POST['shop_enabled'])
2587 {
2588 $genSet->set('shop_enabled', 1, 'common');
2589 }
2590 else
2591 {
2592 $genSet->set('shop_enabled', 0, 'common');
2593 }
2594 ilUtil::sendSuccess($this->lng->txt('pays_updated_general_settings'));
2595
2596 $this->generalSettingsObject();
2597 return true;
2598 }
2599
2600 public function paypalSettingsObject()
2601 {
2606 global $rbacsystem;
2607
2608 // MINIMUM ACCESS LEVEL = 'read'
2609 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2610 {
2611 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
2612 }
2613
2614 include_once './Services/Payment/classes/class.ilPaypalSettings.php';
2615
2616 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html','Services/Payment');
2617
2619
2620 $form = new ilPropertyFormGUI();
2621 $form->setFormAction($this->ctrl->getFormAction($this, 'savePaypalSettings'));
2622 $form->setTitle($this->lng->txt('pays_paypal_settings'));
2623
2624 $form->addCommandButton('savePaypalSettings',$this->lng->txt('save'));
2625
2626 $formItem = new ilTextInputGUI($this->lng->txt('pays_server_host'), 'server_host');
2627 $formItem->setValue($ppSet->getServerHost());
2628 $form->addItem($formItem);
2629
2630 $formItem = new ilTextInputGUI($this->lng->txt('pays_server_path'), 'server_path');
2631 $formItem->setValue($ppSet->getServerPath());
2632 $form->addItem($formItem);
2633
2634 $formItem = new ilTextInputGUI($this->lng->txt('pays_email_vendor'), 'vendor');
2635 $formItem->setValue($ppSet->getVendor());
2636 $form->addItem($formItem);
2637
2638// $formItem = new ilPasswordInputGUI($this->lng->txt('password'), 'vendor_password');
2639// $formItem->setRetype(false);
2640// $formItem->setValue($ppSet->getVendorPassword());
2641// $form->addItem($formItem);
2642
2643 $formItem = new ilTextInputGUI($this->lng->txt('pays_auth_token'), 'auth_token');
2644 $formItem->setValue($ppSet->getAuthToken());
2645 $form->addItem($formItem);
2646
2647 $formItem = new ilTextInputGUI($this->lng->txt('pays_page_style'), 'page_style');
2648 $formItem->setValue($ppSet->getPageStyle());
2649 $form->addItem($formItem);
2650
2651 $this->tpl->setVariable('FORM',$form->getHTML());
2652 }
2653
2655 {
2656 include_once './Services/Payment/classes/class.ilPaypalSettings.php';
2657
2658 global $rbacsystem;
2659
2660 // MINIMUM ACCESS LEVEL = 'read'
2661 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2662 {
2663 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
2664 }
2665
2667
2668 $ppSet->setServerHost(ilUtil::stripSlashes($_POST['server_host']));
2669 $ppSet->setServerPath(ilUtil::stripSlashes($_POST['server_path']));
2670 $ppSet->setVendor(ilUtil::stripSlashes($_POST['vendor']));
2671// $ppSet->setVendorPassword(ilUtil::stripSlashes($_POST['vendor_password']));
2672 $ppSet->setAuthToken(ilUtil::stripSlashes($_POST['auth_token']));
2673 $ppSet->setPageStyle(ilUtil::stripSlashes($_POST['page_style']));
2674 $ppSet->setSsl(ilUtil::stripSlashes($_POST['ssl']));
2675
2676 if ($_POST['server_host'] == '' ||
2677 $_POST['server_path'] == '' ||
2678 $_POST['vendor'] == '' ||
2679// $_POST['vendor_password'] == '' ||
2680 $_POST['auth_token'] == '')
2681 {
2682 $this->error = $this->lng->txt('pays_paypal_settings_not_valid');
2683 ilUtil::sendFailure($this->error);
2684 $this->paypalSettingsObject();
2685 return true;
2686
2687 }
2688
2689 $ppSet->save();
2690
2691 $this->paypalSettingsObject();
2692
2693 ilUtil::sendSuccess($this->lng->txt('pays_updated_paypal_settings'));
2694
2695 return true;
2696 }
2697
2698 //function vendorsObject($a_show_confirm = false)
2699 public function vendorsObject($a_show_confirm = false)
2700 {
2701 // include_once './Services/Payment/classes/class.ilPaymentBookings.php';
2702 #include_once './Services/Table/classes/class.ilTable2GUI.php';
2703
2704 global $rbacsystem, $ilToolbar;
2705
2706 // MINIMUM ACCESS LEVEL = 'read'
2707 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2708 {
2709 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
2710 }
2711
2712 $_SESSION['pays_vendor'] = is_array($_SESSION['pays_vendor']) ? $_SESSION['pays_vendor'] : array();
2713
2714 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html','Services/Payment');
2715
2716 // add vendors
2718 $this,
2719 $ilToolbar,
2720 array(
2721 'auto_complete_name' => $this->lng->txt('user'),
2722 'user_type' => null,
2723 'submit_name' => $this->lng->txt('add')
2724 ));
2725
2726 if(!count($vendors = $this->vendors_obj->getVendors()))
2727 {
2728 ilUtil::sendInfo($this->lng->txt('pay_no_vendors_created'));
2729 }
2730
2731 if($a_show_confirm)
2732 {
2733 $oConfirmationGUI = new ilConfirmationGUI();
2734
2735 // set confirm/cancel commands
2736 $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this,"performDeleteVendors"));
2737 $oConfirmationGUI->setHeaderText($this->lng->txt("pays_sure_delete_selected_vendors"));
2738 $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "vendors");
2739 $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDeleteVendors");
2740
2741 foreach($vendors as $vendor)
2742 {
2743 if(in_array($vendor['vendor_id'],$_SESSION['pays_vendor']))
2744 {
2745 // GET USER OBJ
2746 if($tmp_obj = ilObjectFactory::getInstanceByObjId($vendor['vendor_id'],false))
2747 {
2748 $delete_row = '';
2749 $delete_row = $tmp_obj->getLogin().' '.
2750 $vendor['cost_center'].' '.
2752 $oConfirmationGUI->addItem('',$delete_row, $delete_row);
2753 unset($tmp_obj);
2754 }
2755 }
2756 } // END VENDORS TABLE
2757
2758 if(count($vendors) == count($_SESSION['pays_vendor']))
2759 {
2760 ilUtil::sendInfo($this->lng->txt('shop_disabled_no_vendors'));
2761 $_SESSION['disable_shop'] = true;
2762 }
2763 $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHTML()); #
2764 return true;
2765 }
2766
2767 $counter = 0;
2768 $f_result = array();
2769 foreach($vendors as $vendor)
2770 {
2771 // GET USER OBJ
2772 if($tmp_obj = ilObjectFactory::getInstanceByObjId($vendor['vendor_id'],false))
2773 {
2774 $f_result[$counter]['vendor_id'] = ilUtil::formCheckbox(in_array($vendor['vendor_id'],
2775 $_SESSION['pays_vendor']) ? 1 : 0, "vendor[]", $vendor['vendor_id']);
2776 $f_result[$counter]['login'] = $tmp_obj->getLogin();
2777 $f_result[$counter]['cost_center'] = $vendor['cost_center'];
2778 $f_result[$counter]['number_bookings'] = ilPaymentBookings::_getCountBookingsByVendor($vendor['vendor_id']);
2779
2780 unset($tmp_obj);
2781 ++$counter;
2782 }
2783 } // END VENDORS TABLE
2784 $this->__showVendorsTable($f_result);
2785
2786 return true;
2787 }
2788
2789 public function exportVendorsObject()
2790 {
2791 include_once './Services/Payment/classes/class.ilPaymentExcelWriterAdapter.php';
2792
2793 $pewa = new ilPaymentExcelWriterAdapter('payment_vendors.xls');
2794
2795 // add/fill worksheet
2796 $this->addVendorWorksheet($pewa);
2797 $this->addStatisticWorksheet($pewa);
2798
2799 // HEADER SENT
2800
2801 $workbook = $pewa->getWorkbook();
2802 @$workbook->close();
2803 }
2804
2805 public function addStatisticWorksheet(&$pewa)
2806 {
2807 include_once './Services/Excel/classes/class.ilExcelUtils.php';
2808 include_once './Services/Payment/classes/class.ilPaymentVendors.php';
2809
2810 $this->__initBookingObject();
2811
2812 $workbook = $pewa->getWorkbook();
2813 $worksheet = $workbook->addWorksheet(utf8_decode($this->lng->txt('bookings')));
2814
2815 $worksheet->mergeCells(0,0,0,3);
2816 $worksheet->setColumn(0,0,16);
2817 $worksheet->setColumn(0,1,32);
2818 $worksheet->setColumn(0,2,32);
2819 $worksheet->setColumn(0,3,16);
2820 $worksheet->setColumn(0,4,16);
2821 $worksheet->setColumn(0,5,16);
2822 $worksheet->setColumn(0,6,24);
2823 $worksheet->setColumn(0,7,8);
2824 $worksheet->setColumn(0,8,12);
2825 $worksheet->setColumn(0,9,16);
2826
2827 $title = $this->lng->txt('bookings');
2828 $title .= ' '.$this->lng->txt('as_of').' ';
2829 $title .= strftime('%Y-%m-%d %R',time());
2830
2831 $worksheet->writeString(0,0,$title,$pewa->getFormatTitle());
2832
2833 $worksheet->writeString(1,0,$this->lng->txt('payment_system'),$pewa->getFormatHeader());
2834 $worksheet->writeString(1,1,$this->lng->txt('paya_transaction'),$pewa->getFormatHeader());
2835 $worksheet->writeString(1,2,$this->lng->txt('title'),$pewa->getFormatHeader());
2836 $worksheet->writeString(1,3,$this->lng->txt('paya_vendor'),$pewa->getFormatHeader());
2837 $worksheet->writeString(1,4,$this->lng->txt('pays_cost_center'),$pewa->getFormatHeader());
2838 $worksheet->writeString(1,5,$this->lng->txt('paya_customer'),$pewa->getFormatHeader());
2839 $worksheet->writeString(1,6,$this->lng->txt('email'),$pewa->getFormatHeader());
2840 $worksheet->writeString(1,7,$this->lng->txt('paya_order_date'),$pewa->getFormatHeader());
2841 $worksheet->writeString(1,8,$this->lng->txt('duration'),$pewa->getFormatHeader());
2842 $worksheet->writeString(1,9,$this->lng->txt('price_a'),$pewa->getFormatHeader());
2843 $worksheet->writeString(1,10,$this->lng->txt('paya_payed_access'),$pewa->getFormatHeader());
2844
2845 $worksheet->writeString(1,11,$this->lng->txt('street'),$pewa->getFormatHeader());
2846 $worksheet->writeString(1,12,$this->lng->txt('pay_bmf_po_box'),$pewa->getFormatHeader());
2847 $worksheet->writeString(1,13,$this->lng->txt('zipcode'),$pewa->getFormatHeader());
2848 $worksheet->writeString(1,14,$this->lng->txt('city'),$pewa->getFormatHeader());
2849 $worksheet->writeString(1,15,$this->lng->txt('country'),$pewa->getFormatHeader());
2850
2851 if(!count($bookings = $this->booking_obj->getBookings()))
2852 {
2853 return false;
2854 }
2855
2856 include_once 'Services/User/classes/class.ilObjUser.php';
2857 $object_title_cache = array();
2858 $user_title_cache = array();
2859
2860 $counter = 2;
2861 foreach($bookings as $booking)
2862 {
2863 if(array_key_exists($booking['ref_id'], $object_title_cache))
2864 {
2865 $tmp_obj = $object_title_cache[$booking['ref_id']];
2866 }
2867 else
2868 {
2869 $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($booking['ref_id']));
2870 $object_title_cache[$booking['ref_id']] = $tmp_obj;
2871 }
2872 if(array_key_exists($booking['b_vendor_id'], $user_title_cache))
2873 {
2874 $tmp_vendor = $user_title_cache[$booking['b_vendor_id']];
2875 }
2876 else
2877 {
2878 $tmp_vendor = ilObjUser::_lookupLogin($booking['b_vendor_id']);
2879 $user_title_cache[$booking['b_vendor_id']] = $tmp_vendor;
2880 }
2881 if(array_key_exists($booking['customer_id'], $user_title_cache))
2882 {
2883 $tmp_purchaser = $user_title_cache[$booking['customer_id']];
2884 }
2885 else
2886 {
2887 $tmp_purchaser_name = ilObjUser::_lookupName($booking['customer_id']);
2888 $tmp_purchaser_login = ilObjUser::_lookupLogin($booking['customer_id']);
2889 $tmp_purchaser_email = ilObjUser::_lookupEmail($booking['customer_id']);
2890 $tmp_purchaser = ''.$tmp_purchaser_name['firstname'].' '.$tmp_purchaser_name['lastname'].' ['.$tmp_purchaser_login.']';
2891 $user_title_cache[$booking['customer_id']] = $tmp_purchaser;
2892 }
2893
2894 include_once './Services/Payment/classes/class.ilPayMethods.php';
2895 $str_paymethod = ilPayMethods::getStringByPaymethod($booking['b_pay_method']);
2896
2897 $worksheet->writeString($counter,0,$str_paymethod);
2898 $worksheet->writeString($counter,1,$booking['transaction']);
2899 $worksheet->writeString($counter,2,($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted')));
2900 $worksheet->writeString($counter,3,($tmp_vendor != '' ? $tmp_vendor : $this->lng->txt('user_deleted')));
2901 $worksheet->writeString($counter,4,ilPaymentVendors::_getCostCenter($booking['b_vendor_id']));
2902 $worksheet->writeString($counter,5,($tmp_purchaser != '' ? $tmp_purchaser : $this->lng->txt('user_deleted')));
2903 $worksheet->writeString($counter,6,$tmp_purchaser_email);
2904 $worksheet->writeString($counter,7,strftime('%Y-%m-%d %R',$booking['order_date']));
2905 $worksheet->writeString($counter,8,$booking['duration']);
2906 $worksheet->writeString($counter,9,$booking['price']);
2907
2908 $payed_access = $booking['payed'] ?
2909 $this->lng->txt('yes') :
2910 $this->lng->txt('no');
2911
2912 $payed_access .= '/';
2913 $payed_access .= $booking['access_granted'] ?
2914 $this->lng->txt('yes') :
2915 $this->lng->txt('no');
2916
2917 $worksheet->writeString($counter,10,$payed_access);
2918
2919 $worksheet->writeString($counter,11,$booking['street']);
2920 $worksheet->writeString($counter,12,$booking['po_box']);
2921 $worksheet->writeString($counter,13,$booking['zipcode']);
2922 $worksheet->writeString($counter,14,$booking['city']);
2923 $worksheet->writeString($counter,15,$booking['country']);
2924
2925 unset($tmp_obj);
2926 unset($tmp_vendor);
2927 unset($tmp_purchaser);
2928
2929 ++$counter;
2930 }
2931 return true;
2932 }
2933
2934 public function addVendorWorksheet($pewa)
2935 {
2936 include_once './Services/Excel/classes/class.ilExcelUtils.php';
2937
2938 $workbook = $pewa->getWorkbook();
2939 $worksheet = $workbook->addWorksheet($this->lng->txt('pays_vendor'));
2940
2941 // SHOW HEADER
2942 $worksheet->mergeCells(0,0,0,2);
2943 $worksheet->setColumn(1,0,32);
2944 $worksheet->setColumn(1,1,32);
2945 $worksheet->setColumn(1,2,32);
2946
2947 $title = $this->lng->txt('pays_vendor');
2948 $title .= ' '.$this->lng->txt('as_of').' ';
2949 $title .= strftime('%Y-%m-%d %R',time());
2950
2951 $worksheet->writeString(0,0,$title,$pewa->getFormatTitle());
2952
2953 $worksheet->writeString(1,0,$this->lng->txt('login'),$pewa->getFormatHeader());
2954 $worksheet->writeString(1,1,$this->lng->txt('fullname'),$pewa->getFormatHeader());
2955 $worksheet->writeString(1,2,$this->lng->txt('pays_cost_center'),$pewa->getFormatHeader());
2956
2957 if(!count($vendors = $this->vendors_obj->getVendors()))
2958 {
2959 return false;
2960 }
2961
2962 $counter = 2;
2963 foreach($vendors as $vendor)
2964 {
2965 // GET USER OBJ
2966 if($tmp_obj = ilObjectFactory::getInstanceByObjId($vendor['vendor_id'],false))
2967 {
2968 $worksheet->writeString($counter,0,$tmp_obj->getLogin());
2969 $worksheet->writeString($counter,1,$tmp_obj->getFullname());
2970 $worksheet->writeString($counter,2,$vendor['cost_center']);
2971 }
2972 unset($tmp_obj);
2973 ++$counter;
2974 }
2975 return true;
2976 }
2977
2978 public function payMethodsObject($askForDeletingAddresses = array())
2979 {
2980 include_once './Services/Payment/classes/class.ilPayMethods.php';
2981
2982 global $rbacsystem, $ilCtrl;
2983
2984 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html','Services/Payment');
2985
2986 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
2987 {
2988 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
2989 }
2990
2991 if(count($askForDeletingAddresses))
2992 {
2993 $oConfirmationGUI = new ilConfirmationGUI();
2994
2995 // set confirm/cancel commands
2996 $oConfirmationGUI->setFormAction($ilCtrl->getFormAction($this, "deleteAddressesForPaymethods"));
2997 $oConfirmationGUI->setHeaderText($this->lng->txt("info_delete_sure"));
2998 $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "payMethods");
2999 $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "deleteAddressesForPaymethods");
3000
3001 foreach($askForDeletingAddresses as $pm_id)
3002 {
3003 $pm_obj = new ilPayMethods($pm_id);
3004 $oConfirmationGUI->additem('paymethod['.$pm_obj->getPmId().']',$pm_obj->getPmId(), $this->lng->txt('delete_addresses_bill').' -> '.ilPayMethods::getStringByPaymethod($pm_obj->getPmTitle()));
3005 }
3006
3007 $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHtml());
3008 return true;
3009 }
3010
3011 $obj_paymethods = new ilPayMethods();
3012 $paymethods = $obj_paymethods->readAll();
3013
3014 $result = array();
3015 $counter = 0;
3016 foreach($paymethods as $paymethod)
3017 {
3018 if($paymethod['pm_title'] != 'epay')
3019 {
3020 $result[$counter]['pm_title'] = ilPayMethods::getStringByPaymethod($paymethod['pm_title']);
3021 $result[$counter]['pm_enabled'] = ilUtil::formCheckbox($paymethod['pm_enabled'] ? 1 : 0,'pm_enabled['.$paymethod['pm_id'].']',1);
3022 $result[$counter]['save_usr_adr'] = ilUtil::formCheckbox($paymethod['save_usr_adr'] ? 1 : 0,'save_usr_adr['.$paymethod['pm_id'].']',1);
3023 $this->ctrl->clearParameters($this);
3024 $counter++;
3025 }
3026 }
3027
3028 $this->ctrl->setParameter($this, 'cmd', 'savePayMethods');
3029 $tbl = new ilShopTableGUI($this);
3030 $tbl->setTitle($this->lng->txt('pays_pay_methods'));
3031
3032 $tbl->setId('tbl_paymethods');
3033 $tbl->setRowTemplate("tpl.shop_paymethods_row.html", "Services/Payment");
3034
3035 $tbl->addColumn($this->lng->txt('title'), 'pm_title', '10%');
3036 $tbl->addColumn($this->lng->txt('enabled'), 'pm_enabled', '10%');
3037 $tbl->addColumn($this->lng->txt('save_customer_address'),'save_usr_adr','10%');
3038 $tbl->addCommandButton('savePayMethods', $this->lng->txt('save'));
3039
3040 $tbl->disable('sort');
3041 $tbl->setData($result);
3042
3043 $this->tpl->setVariable('TABLE', $tbl->getHTML());
3044
3045 return true;
3046 }
3047
3048 public function savePayMethodsObject()
3049 {
3050 include_once './Services/Payment/classes/class.ilPayMethods.php';
3051
3052 global $rbacsystem;
3053
3054 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
3055 {
3056 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
3057 }
3058
3059 $obj_paymethods = new ilPayMethods();
3060 $paymethods = $obj_paymethods->readAll();
3061
3062 $askForDeletingAddresses = array();
3063
3064 $pm_enabled = (array)$_POST['pm_enabled'];
3065 $pm_addr = (array)$_POST['save_usr_adr'];
3066
3067 if(!$pm_enabled)
3068 {
3069 ilUtil::sendInfo($this->lng->txt('shop_disabled_no_paymethods'));
3070 $this->genSetData->set('shop_enabled', 0, 'common');
3071 $_SESSION['disable_shop'] = false;
3072 }
3073
3074 $info_msg = array();
3075 foreach($paymethods as $paymethod)
3076 {
3077 if(
3078 (!isset($pm_enabled[$paymethod['pm_id']]) || !$pm_enabled[$paymethod['pm_id']]) &&
3079 $paymethod['pm_enabled']
3080 )
3081 {
3082 if(ilPaymentObject::_getCountObjectsByPayMethod($paymethod['pm_id']))
3083 {
3084 $info_msg[] = $this->lng->txt('pays_objects_'.$paymethod['pm_title'].'_exist');
3085 }
3086 }
3087 }
3088 if($info_msg)
3089 {
3090 ilUtil::sendInfo(implode('<br />', $info_msg));
3091 $this->payMethodsObject();
3092 return;
3093 }
3094
3095 $num_changed = 0;
3096 foreach($paymethods as $paymethod)
3097 {
3098 if(
3099 (!isset($pm_enabled[$paymethod['pm_id']]) || !$pm_enabled[$paymethod['pm_id']]) &&
3100 $paymethod['pm_enabled']
3101 )
3102 {
3103 ilPayMethods::_PMdisable($paymethod['pm_id']);
3104 ++$num_changed;
3105 }
3106 else if(isset($pm_enabled[$paymethod['pm_id']]) && $pm_enabled[$paymethod['pm_id']] && !$paymethod['pm_enabled'])
3107 {
3108 ilPayMethods::_PMenable($paymethod['pm_id']);
3109 ++$num_changed;
3110 }
3111
3112 if(
3113 (!isset($pm_addr[$paymethod['pm_id']]) || !$pm_addr[$paymethod['pm_id']]) &&
3114 $paymethod['save_usr_adr'])
3115 {
3116 $askForDeletingAddresses[] = $paymethod['pm_id'];
3117 }
3118 else if(
3119 (!isset($pm_addr[$paymethod['pm_id']]) || !$pm_addr[$paymethod['pm_id']]) &&
3120 !$paymethod['save_usr_adr']
3121 )
3122 {
3123 continue;
3124 }
3125 else
3126 {
3127 ilPayMethods::_enableSaveUserAddress($paymethod['pm_id']);
3128 ++$num_changed;
3129 }
3130 }
3131 if($num_changed && !$askForDeletingAddresses)
3132 {
3133 ilUtil::sendSuccess($this->lng->txt('pays_updated_pay_method'));
3134 }
3135 $this->payMethodsObject($askForDeletingAddresses);
3136
3137 return true;
3138 }
3139
3141 {
3142 unset($_SESSION['pays_vendor']);
3143 $_SESSION['disable_shop'] = false;
3144 $this->vendorsObject();
3145
3146 return true;
3147 }
3148
3149 public function deleteVendorsObject()
3150 {
3151 //include_once './Services/Payment/classes/class.ilPaymentBookings.php';
3152
3153 if(!count($_POST['vendor']))
3154 {
3155 ilUtil::sendFailure($this->lng->txt('pays_no_vendor_selected'));
3156 $this->vendorsObject();
3157
3158 return true;
3159 }
3160 // CHECK BOOKINGS
3161 foreach($_POST['vendor'] as $vendor)
3162 {
3164 {
3165 ilUtil::sendInfo($this->lng->txt('pays_active_bookings'));
3166 $this->vendorsObject();
3167
3168 return true;
3169 }
3170 }
3171
3172 $_SESSION['pays_vendor'] = $_POST['vendor'];
3173 ilUtil::sendQuestion($this->lng->txt('pays_sure_delete_selected_vendors'));
3174 $this->vendorsObject(true);
3175
3176 return true;
3177 }
3178
3180 {
3181 include_once './Services/Payment/classes/class.ilPaymentTrustees.php';
3182
3183 global $rbacsystem;
3184
3185 // MINIMUM ACCESS LEVEL = 'read'
3186 if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
3187 {
3188 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$this->ilErr->MESSAGE);
3189 }
3190
3191 foreach($_SESSION['pays_vendor'] as $vendor)
3192 {
3193 $this->vendors_obj->delete($vendor);
3195 }
3196
3197 ilUtil::sendInfo($this->lng->txt('pays_deleted_number_vendors').' '.count($_SESSION['pays_vendor']));
3198 unset($_SESSION['pays_vendor']);
3199 if($_SESSION['disable_shop'] == true)
3200 {
3201 $this->genSetData->set('shop_enabled', 0, 'common');
3202 $_SESSION['disable_shop'] = false;
3203 }
3204
3205 $this->vendorsObject();
3206
3207 return true;
3208 }
3209
3210 public function editVendorObject()
3211 {
3212 global $rbacsystem;
3213
3214 // MINIMUM ACCESS LEVEL = 'read'
3215 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
3216 {
3217 $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
3218 }
3219
3220 if(!count($_POST['vendor']))
3221 {
3222 ilUtil::sendInfo($this->lng->txt('pays_no_vendor_selected'));
3223 $this->vendorsObject();
3224
3225 return true;
3226 }
3227 if(count($_POST['vendor']) > 1)
3228 {
3229 ilUtil::sendInfo($this->lng->txt('pays_too_many_vendors_selected'));
3230 $this->vendorsObject();
3231
3232 return true;
3233 }
3234
3235 $_SESSION['pays_vendor'] = $_POST['vendor'][0];
3236
3237 if (!is_array($this->vendors_obj->vendors[$_SESSION['pays_vendor']]))
3238 {
3239 $this->vendorsObject();
3240
3241 return true;
3242 }
3243
3244 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
3245
3246 $form_gui = new ilPropertyFormGUI();
3247 $form_gui->setFormAction($this->ctrl->getFormAction($this, 'performEditVendor'));
3248 $form_gui->setTitle($this->lng->txt('pays_vendor'));
3249
3250 $oVendorGUI = new ilNonEditableValueGUI($this->lng->txt('pays_vendor'));
3251 $oVendorGUI->setValue(ilObjUser::getLoginByUserId($this->vendors_obj->vendors[$_SESSION['pays_vendor']]['vendor_id']), true);
3252 $form_gui->addItem($oVendorGUI);
3253
3254 $oCostcenterGUI = new ilTextInputGUI($this->lng->txt('pays_cost_center'),'cost_center');
3255 $oCostcenterGUI->setValue($this->error != '' && isset($_POST['cost_center'])
3256 ? ilUtil::prepareFormOutput($_POST['cost_center'],true)
3257 : ilUtil::prepareFormOutput($this->vendors_obj->vendors[$_SESSION['pays_vendor']]['cost_center'],true));
3258 $form_gui->addItem($oCostcenterGUI);
3259
3260 $form_gui->addCommandButton('performEditVendor',$this->lng->txt('save'));
3261 $this->tpl->setVariable('FORM', $form_gui->getHTML());
3262 return true;
3263 }
3264
3265 public function performEditVendorObject()
3266 {
3267 global $rbacsystem;
3268
3269 // MINIMUM ACCESS LEVEL = 'read'
3270 if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
3271 {
3272 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$this->ilErr->MESSAGE);
3273 }
3274
3275 if(!count($_SESSION['pays_vendor']))
3276 {
3277 ilUtil::sendInfo($this->lng->txt('pays_no_vendor_selected'));
3278 $this->vendorsObject();
3279
3280 return true;
3281 }
3282 if(count($_SESSION['pays_vendor']) > 1)
3283 {
3284 ilUtil::sendInfo($this->lng->txt('pays_too_many_vendors_selected'));
3285 $this->vendorsObject();
3286
3287 return true;
3288 }
3289
3290 if (!is_array($this->vendors_obj->vendors[$_SESSION['pays_vendor']]))
3291 {
3292 $this->vendorsObject();
3293 return true;
3294 }
3295
3296 if ($_POST['cost_center'] == '')
3297 {
3298 $this->error = $this->lng->txt('pays_cost_center_not_valid');
3299 ilUtil::sendFailure($this->error);
3300 $_POST['vendor'] = array($_SESSION['pays_vendor']);
3301 return $this->editVendor();
3302
3303 }
3304
3305 $this->vendors_obj->update($_SESSION['pays_vendor'], $_POST['cost_center']);
3306
3307 unset($_SESSION['pays_vendor']);
3308
3309 $this->vendorsObject();
3310
3311 return true;
3312 }
3313
3315 {
3316 global $rbacsystem, $ilToolbar;
3317
3318 // MINIMUM ACCESS LEVEL = 'read'
3319 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
3320 {
3321 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
3322 }
3323
3324 $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'statistic'));
3325
3326 ilUtil::sendInfo($this->lng->txt('paya_select_object_to_sell'));
3327
3328 include_once("./Services/Payment/classes/class.ilPaymentObjectSelector.php");
3329 $exp = new ilPaymentObjectSelector($this, "showObjectSelector");
3330 if (!$exp->handleCommand())
3331 {
3332 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paya_object_selector.html",'Services/Payment');
3333 $this->tpl->setVariable("EXPLORER",$exp->getHTML());
3334 }
3335
3336 return true;
3337 }
3338
3339 public function searchObject()
3340 {
3341 global $rbacsystem;
3342
3343 if(!$rbacsystem->checkAccess('read', $this->object->getRefId()))
3344 {
3345 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$this->ilErr->MESSAGE);
3346 }
3347
3348 $_SESSION['pays_search_str'] = $_POST['search_str'] = $_POST['search_str'] ? $_POST['search_str'] : $_SESSION['pays_search_str'];
3349
3350 if(!isset($_POST['search_str']))
3351 {
3352 ilUtil::sendInfo($this->lng->txt('crs_search_enter_search_string'));
3353 $this->searchUserObject();
3354
3355 return false;
3356 }
3357 if(!count($result = $this->__search(ilUtil::stripSlashes($_POST['search_str']))))
3358 {
3359 ilUtil::sendInfo($this->lng->txt('crs_no_results_found'));
3360 $this->searchUserObject();
3361
3362 return false;
3363 }
3364
3365 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html','Services/Payment');
3366
3367 $counter = 0;
3368 $f_result = array();
3369 foreach($result as $user)
3370 {
3371 if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user['id'],false))
3372 {
3373 continue;
3374 }
3375 $f_result[$counter]['vendor_id'] = ilUtil::formCheckbox(0,'user[]',$user['id']);
3376 $f_result[$counter]['login'] = $tmp_obj->getLogin();
3377 $f_result[$counter]['lastname'] = $tmp_obj->getLastname();
3378 $f_result[$counter]['firstname'] = $tmp_obj->getFirstname();
3379
3380 unset($tmp_obj);
3381 ++$counter;
3382 }
3383 $this->__showSearchUserTable($f_result);
3384
3385 return true;
3386 }
3387
3389 {
3390 global $rbacsystem;
3391
3392 // MINIMUM ACCESS LEVEL = 'administrate'
3393 if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
3394 {
3395 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$this->ilErr->MESSAGE);
3396 }
3397 if(!$_POST['user_login'])
3398 {
3399 ilUtil::sendFailure($this->lng->txt('pays_no_username_given'));
3400 $this->vendorsObject();
3401
3402 return true;
3403 }
3404 if(!($usr_id = ilObjUser::getUserIdByLogin(ilUtil::stripSlashes($_POST['user_login']))))
3405 {
3406 ilUtil::sendFailure($this->lng->txt('pays_no_valid_username_given'));
3407 $this->vendorsObject();
3408
3409 return true;
3410 }
3411
3412 if($this->vendors_obj->isAssigned($usr_id))
3413 {
3414 ilUtil::sendFailure($this->lng->txt('pays_user_already_assigned'));
3415 $this->vendorsObject();
3416
3417 return true;
3418 }
3419 $this->vendors_obj->add($usr_id);
3420
3421 ilUtil::sendSuccess($this->lng->txt('pays_added_vendor'));
3422 $this->vendorsObject();
3423
3424 return true;
3425 }
3426
3427 public function addUserObject()
3428 {
3429 global $rbacsystem;
3430
3431 // MINIMUM ACCESS LEVEL = 'administrate'
3432 if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
3433 {
3434 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$this->ilErr->MESSAGE);
3435 }
3436
3437 $this->lng->loadLanguageModule('crs');
3438 if(!is_array($_POST['user']))
3439 {
3440 ilUtil::sendFailure($this->lng->txt('crs_no_users_selected'));
3441 $this->searchObject();
3442
3443 return false;
3444 }
3445
3446 $already_assigned = $assigned = 0;
3447 foreach($_POST['user'] as $usr_id)
3448 {
3449 if($this->vendors_obj->isAssigned($usr_id))
3450 {
3451 ++$already_assigned;
3452 continue;
3453 }
3454 $this->vendors_obj->add($usr_id);
3455 ++$assigned;
3456
3457 // TODO: SEND NOTIFICATION
3458 }
3459 $message = '';
3460 if($assigned)
3461 {
3462 $message .= $this->lng->txt('pays_assigned_vendors').' '.$assigned;
3463 }
3464 if($already_assigned)
3465 {
3466 $message .= '<br />'.$this->lng->txt('pays_already_assigned_vendors').' '.$already_assigned;
3467 }
3468
3469 ilUtil::sendInfo($message);
3470 $this->vendorsObject();
3471
3472 return true;
3473 }
3474
3475 public function searchUserSPObject()
3476 {
3477 global $ilToolbar;
3478
3479 if(!isset($_GET['sell_id']))
3480 {
3481 ilUtil::sendFailiure($this->lng->txt('paya_no_booking_id_given'));
3482 $this->showObjectSelectorObject();
3483
3484 return false;
3485 }
3486
3487 $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'showObjectSelector'));
3488 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
3489
3490 $this->lng->loadLanguageModule('search');
3491 $this->ctrl->setParameter($this, 'sell_id', $_GET['sell_id']);
3492
3493 $form_gui = new ilPropertyFormGUI();
3494 $form_gui->setFormAction($this->ctrl->getFormAction($this));
3495 $form_gui->setTitle($this->lng->txt('search_user'));
3496 $form_gui->setId('search_form');
3497
3498 $oTitle = new ilTextInputGUI($this->lng->txt('search_search_term'), 'search_str');
3499 $oTitle->setMaxLength(255);
3500 $oTitle->setSize(40);
3501 $oTitle->setValue($_POST['search_str']);
3502 $form_gui->addItem($oTitle);
3503
3504 // buttons
3505 $form_gui->addCommandButton('performSearchSP', $this->lng->txt('search'));
3506 $form_gui->addCommandButton('bookings', $this->lng->txt('cancel'));
3507
3508 $this->tpl->setVariable('FORM',$form_gui->getHTML());
3509 return true;
3510 }
3511
3512 public function performSearchSPObject()
3513 {
3514 global $ilToolbar;
3515 // SAVE it to allow sort in tables
3516 $_SESSION['paya_search_str_user_sp'] = $_POST['search_str'] = $_POST['search_str'] ? $_POST['search_str'] : $_SESSION['paya_search_str_user_sp'];
3517
3518 if(!trim($_POST['search_str']))
3519 {
3520 ilUtil::sendFailure($this->lng->txt('search_no_search_term'));
3521 $this->statistics();
3522
3523 return false;
3524 }
3525 if(!count($result = $this->__search(ilUtil::stripSlashes($_POST['search_str']))))
3526 {
3527 ilUtil::sendInfo($this->lng->txt('search_no_match'));
3528 $this->searchUserSPObject();
3529
3530 return false;
3531 }
3532
3533 if(!isset($_GET['sell_id']))
3534 {
3535 ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
3536 $this->showObjectSelectorObject();
3537
3538 return false;
3539 }
3540
3541 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html','Services/Payment');
3542 $this->ctrl->setParameter($this, 'sell_id', $_GET['sell_id']);
3543
3544 $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'searchUserSP'));
3545
3546 $counter = 0;
3547 $f_result = array();
3548 foreach($result as $user)
3549 {
3550 if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user['id'],false))
3551 {
3552 continue;
3553 }
3554 $f_result[$counter]['user_id'] = $user['id'];
3555 $f_result[$counter]['login'] = $tmp_obj->getLogin();
3556 $f_result[$counter]['firstname'] = $tmp_obj->getFirstname();
3557 $f_result[$counter]['lastname'] = $tmp_obj->getLastname();
3558
3559 unset($tmp_obj);
3560 ++$counter;
3561 }
3562 return $this->__showSearchUserSPTable($f_result);
3563 }
3564
3565 public function addCustomerObject()
3566 {
3567 global $ilToolbar;
3568
3569 if ($_POST['sell_id'] != '') $_GET['sell_id'] = $_POST['sell_id'];
3570 if ($_GET['user_id'] != '') $_POST['user_id'] = $_GET['user_id'];
3571
3572 if(!isset($_GET['sell_id']))
3573 {
3574 ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
3575 $this->showObjectSelectorObject();
3576
3577 return true;
3578 }
3579
3580 if(!isset($_POST['user_id']))
3581 {
3582 ilUtil::sendInfo($this->lng->txt('paya_no_user_id_given'));
3583 $this->searchUserSPObject();
3584
3585 return true;
3586 }
3587 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html','Services/Payment');
3588 $this->ctrl->setParameter($this, 'sell_id', $_GET['sell_id']);
3589
3590 $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'searchUserSP'));
3591
3592 $this->ctrl->setParameter($this, 'user_id', $_POST['user_id']);
3593
3594 $pObjectId = ilPaymentObject::_lookupPobjectId($_GET['sell_id']);
3595 $obj = new ilPaymentObject($this->user_obj, $pObjectId);
3596
3597 // get obj
3598 $tmp_obj = ilObjectFactory::getInstanceByRefId($_GET['sell_id'], false);
3599 if($tmp_obj)
3600 {
3601 $tmp_object['title'] = $tmp_obj->getTitle();
3602 }
3603 else
3604 {
3605 $tmp_object['title'] = $this->lng->txt('object_not_found');
3606 }
3607 // get customer_obj
3608 $tmp_user = ilObjectFactory::getInstanceByObjId($_POST['user_id']);
3609 // get vendor_obj
3610 $tmp_vendor = ilObjectFactory::getInstanceByObjId($obj->getVendorId());
3611
3612 $oForm = new ilPropertyFormGUI();
3613 $oForm->setFormAction($this->ctrl->getFormAction($this, 'saveCustomer'));
3614 $oForm->setTitle($this->lng->txt($tmp_user->getFullname().' ['.$tmp_user->getLogin().']'));
3615
3616 //transaction
3617 $oTransaction = new ilTextInputGUI();
3618 $oTransaction->setTitle($this->lng->txt('paya_transaction'));
3619 //$oTransaction->setValue(ilUtil::prepareFormOutut($_POST['transaction'], true));
3620 $oTransaction->setValue($_POST['transaction']);
3621 $oTransaction->setPostVar('transaction');
3622 $oForm->addItem($oTransaction);
3623
3624 //object
3625 $oObject = new ilNonEditableValueGUI($this->lng->txt('title'));
3626 $oObject->setValue($tmp_obj->getTitle());
3627 $oForm->addItem($oObject);
3628
3629 //vendor
3630 $oVendor = new ilNonEditableValueGUI($this->lng->txt('paya_vendor'));
3631 $oVendor->setValue($tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']');
3632 $oForm->addItem($oVendor);
3633
3634 // pay methods
3635 $oPayMethods = new ilSelectInputGUI($this->lng->txt('paya_pay_method'), 'pay_method');
3636 $payOptions = ilPaymethods::getPayMethodsOptions(false);
3637 $oPayMethods->setOptions($payOptions);
3638 $oPayMethods->setValue($_POST['pay_method']);
3639 $oPayMethods->setPostVar('pay_method');
3640 $oForm->addItem($oPayMethods);
3641
3642 //duration
3643 $duration_options = array();
3644 $price_obj = new ilPaymentPrices($pObjectId);
3645
3646 $standard_prices = array();
3647 $extension_prices = array();
3648 $standard_prices = $price_obj->getPrices();
3649 $extension_prices = $price_obj->getExtensionPrices();
3650
3651 $prices = array_merge($standard_prices, $extension_prices );
3652
3653 if (is_array($prices))
3654 {
3656 $currency_unit = $genSet->get('currency_unit');
3657
3658 foreach($prices as $price)
3659 {
3660 switch($price['price_type'])
3661 {
3663 $txt_duration =
3664 $price['duration'].' '.$this->lng->txt('paya_months').' -> '.$price['price'].' '. $currency_unit;
3665 break;
3666
3668 include_once './Services/Calendar/classes/class.ilDatePresentation.php';
3669 $txt_duration = ilDatePresentation::formatDate(new ilDate($price['duration_from'], IL_CAL_DATE))
3670 .' - '.ilDatePresentation::formatDate(new ilDate($price['duration_until'], IL_CAL_DATE))
3671 ." -> ".ilPaymentPrices::_getPriceString($price["price_id"]) .' '.$currency_unit;
3672 break;
3673
3675 $txt_duration = $this->lng->txt('unlimited_duration').' -> '.$price['price'].' '. $currency_unit;
3676 break;
3677 }
3678 $txt_extension = '';
3679 if($price['extension'] == 1)
3680 {
3681 $txt_extension = ' ('.$this->lng->txt('extension_price').') ';
3682 }
3683 $duration_options[$price['price_id']] .= $txt_duration.''.$txt_extension;
3684 }
3685 }
3686
3687 $oDuration = new ilSelectInputGUI($this->lng->txt('duration'), 'price_id');
3688 $oDuration->setOptions($duration_options);
3689 $oDuration->setValue($_POST['price_id']);
3690 $oForm->addItem($oDuration);
3691
3692 //payed
3693 $o_payed = new ilSelectInputGUI();
3694 $payed_option = array('1'=>$this->lng->txt('yes'),'0'=>$this->lng->txt('no'));
3695
3696 $o_payed->setTitle($this->lng->txt('paya_payed'));
3697 $o_payed->setOptions($payed_option);
3698 $o_payed->setValue($_POST['payed']);
3699 $o_payed->setPostVar('payed');
3700 $oForm->addItem($o_payed);
3701
3702
3703 $o_access = new ilSelectInputGUI();
3704 $access_option = array('1'=>$this->lng->txt('yes'),'0'=>$this->lng->txt('no'));
3705
3706 $o_access->setTitle($this->lng->txt('paya_access'));
3707 $o_access->setOptions($access_option);
3708 $o_access->setValue($_POST['access']);
3709 $o_access->setPostVar('access');
3710
3711 $oForm->addItem($o_access);
3712
3713 $oForm->addCommandButton('saveCustomer',$this->lng->txt('save'));
3714 $oForm->addCommandButton('bookings', $this->lng->txt('cancel'));
3715
3716 $this->tpl->setVariable('FORM',$oForm->getHTML());
3717 return true;
3718 }
3719
3720 public function saveCustomerObject()
3721 {
3722 global $ilUser,$ilObjDataCache;
3723
3724 if(!isset($_GET['sell_id']))
3725 {
3726 ilUtil::sendInfo($this->lng->txt('paya_error_no_object_id_given'));
3727 $this->showObjectSelectorObject();
3728
3729 return true;
3730 }
3731
3732 if(!isset($_GET['user_id']))
3733 {
3734 ilUtil::sendInfo($this->lng->txt('paya_error_no_user_id_given'));
3735 $this->searchUserSPObject();
3736
3737 return true;
3738 }
3739
3740 if ($_POST['pay_method'] == '' ||
3741 $_POST['price_id'] == '')
3742 {
3743 ilUtil::sendInfo($this->lng->txt('paya_error_mandatory_fields'));
3744 $this->addCustomerObject();
3745
3746 return true;
3747 }
3748
3749 $pObjectId = ilPaymentObject::_lookupPobjectId($_GET['sell_id']);
3750 $obj = new ilPaymentObject($this->user_obj, $pObjectId);
3751
3752 $this->__initBookingObject();
3753
3755
3756 $this->booking_obj->setTransaction($transaction);
3757 $this->booking_obj->setTransactionExtern($_POST['transaction']);
3758 $this->booking_obj->setPobjectId($pObjectId);
3759 $this->booking_obj->setCustomerId($_GET['user_id']);
3760 $this->booking_obj->setVendorId($obj->getVendorId());
3761
3762 $this->booking_obj->setPayMethod($_POST['pay_method']);
3763 $this->booking_obj->setOrderDate(time());
3764
3765 $price = ilPaymentPrices::_getPrice($_POST['price_id']);
3766// $currency = ilPaymentCurrency::_getUnit($price['currency']);
3767
3768#@todo check this.
3769 switch($price['price_type'])
3770 {
3772 $this->booking_obj->setDuration($price['duration']);
3773 break;
3774
3776 $this->booking_obj->setDuration(0);
3777 $this->booking_obj->setAccessStartdate($price['duration_from']);
3778 $this->booking_obj->setAccessEnddate($price['duration_until']);
3779 break;
3781 $this->booking_obj->setDuration(0);
3782 $this->booking_obj->setAccessEnddate(NULL);
3783 break;
3784 }
3785
3786 $this->booking_obj->setPriceType($price['price_type']);
3787 $this->booking_obj->setPrice($price['price']);
3788
3789 $this->booking_obj->setAccess((int) $_POST['access']);
3790 $this->booking_obj->setPayed((int) $_POST['payed']);
3791 $this->booking_obj->setVoucher('');
3792
3793 $obj_id = $ilObjDataCache->lookupObjId($obj->getRefId());
3794 $obj_type = $ilObjDataCache->lookupType($obj_id);
3795 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
3796
3797 // include_once 'Services/Payment/classes/class.ilShopVatsList.php';
3798 $oVAT = new ilShopVats((int)$obj->getVatId());
3799 $obj_vat_rate = $oVAT->getRate();
3800 $obj_vat_unit = $obj->getVat($this->booking_obj->getPrice());
3801
3802 $this->booking_obj->setObjectTitle($obj_title);
3803 $this->booking_obj->setVatRate($obj_vat_rate);
3804 $this->booking_obj->setVatUnit($obj_vat_unit);
3805
3807 $this->booking_obj->setCurrencyUnit( $genSet->get('currency_unit'));
3808
3809 include_once './Services/Payment/classes/class.ilPayMethods.php';
3810
3811 $save_user_address_enabled = ilPayMethods::_EnabledSaveUserAddress($this->booking_obj->getPayMethod());
3812 if($save_user_address_enabled == 1)
3813 {
3814 global $ilObjUser;
3815 $user_id[] = $_GET["user_id"];
3816
3817 $cust_obj = ilObjUser::_readUsersProfileData($user_id);
3818
3819 $this->booking_obj->setStreet($cust_obj[$_GET["user_id"]]['street'],'');
3820
3821 $this->booking_obj->setZipcode($cust_obj[$_GET["user_id"]]['zipcode']);
3822 $this->booking_obj->setCity($cust_obj[$_GET["user_id"]]['city']);
3823 $this->booking_obj->setCountry($cust_obj[$_GET["user_id"]]['country']);
3824 }
3825
3826 if($this->booking_obj->add())
3827 {
3828 // add purchased item to desktop
3829 ilShopUtils::_addPurchasedObjToDesktop($obj, $this->booking_obj->getCustomerId());
3830
3831 // autosubscribe user if purchased object is a course
3832 if($obj_type == 'crs')
3833 {
3834 ilShopUtils::_assignPurchasedCourseMemberRole($obj, $this->booking_obj->getCustomerId());
3835 }
3836
3837 ilUtil::sendInfo($this->lng->txt('paya_customer_added_successfully'));
3838 $this->statisticObject();
3839 }
3840 else
3841 {
3842 ilUtil::sendInfo($this->lng->txt('paya_error_adding_customer'));
3843 $this->addCustomerObject();
3844 }
3845 return true;
3846 }
3847
3848 // PRIVATE
3849 private function __showStatisticTable($a_result_set)
3850 {
3851 $this->ctrl->setParameter($this, 'cmd', 'statistic');
3852
3853 $tbl = new ilShopTableGUI($this);
3854 $tbl->setTitle($this->lng->txt("bookings"));
3855 $tbl->setId('tbl_show_statistics');
3856 $tbl->setRowTemplate("tpl.shop_statistics_row.html", "Services/Payment");
3857
3858 $tbl->addColumn($this->lng->txt('paya_transaction'), 'transaction', '10%');
3859 $tbl->addColumn($this->lng->txt('title'), 'object_title', '10%');
3860 $tbl->addColumn($this->lng->txt('paya_vendor'), 'vendor', '10%');
3861 $tbl->addColumn($this->lng->txt('paya_customer'), 'customer', '10%');
3862 $tbl->addColumn($this->lng->txt('paya_order_date'), 'order_date', '10%');
3863 $tbl->addColumn($this->lng->txt('duration'), 'duration', '20%');
3864 $tbl->addColumn($this->lng->txt('price_a'), 'price', '5%');
3865 $tbl->addColumn($this->lng->txt('paya_coupons_coupon'), 'discount', '5%');
3866 $tbl->addColumn($this->lng->txt('paya_payed_access'), 'payed_access', '1%');
3867 $tbl->addColumn('','edit', '5%');
3868
3869 $tbl->addCommandButton('exportVendors',$this->lng->txt('excel_export'));
3870 $tbl->setData($a_result_set);
3871
3872 $this->tpl->setVariable('TABLE', $tbl->getHTML());
3873
3874 return true;
3875 }
3876
3877 private function __initBookingObject()
3878 {
3879 include_once './Services/Payment/classes/class.ilPaymentBookings.php';
3880
3881 $this->booking_obj = new ilPaymentBookings($this->user_obj->getId(),true);
3882 }
3883
3884 private function __showVendorsTable($a_result_set)
3885 {
3886 $this->ctrl->setParameter($this, 'cmd', 'vendors');
3887
3888 $tbl = new ilShopTableGUI($this);
3889 $tbl->setTitle($this->lng->txt("vendors"));
3890 $tbl->setId('tbl_show_vendors');
3891 $tbl->setRowTemplate("tpl.shop_users_row.html", "Services/Payment");
3892
3893 $tbl->addColumn('', 'vendor_id', '1%');
3894 $tbl->addColumn($this->lng->txt('paya_vendor'), 'login', '10%');
3895 $tbl->addColumn($this->lng->txt('pays_cost_center'), 'cost_center', '10%');
3896 $tbl->addColumn($this->lng->txt('pays_number_bookings'), 'number_bookings', '10%');
3897
3898 $tbl->addMultiCommand("editVendor", $this->lng->txt('pays_edit_vendor'));
3899 $tbl->addMultiCommand("deleteVendors", $this->lng->txt('pays_delete_vendor'));
3900
3901 $tbl->addCommandButton('exportVendors',$this->lng->txt('excel_export'));
3902
3903 $tbl->setData($a_result_set);
3904 $this->tpl->setVariable('TABLE', $tbl->getHTML());
3905
3906 return true;
3907 }
3908
3909 private function __showSearchUserTable($a_result_set)
3910 {
3911 $tbl = new ilShopTableGUI($this);
3912
3913 $tbl->setTitle($this->lng->txt("pays_header_select_vendor"));
3914 $tbl->setId('tbl_search_user_vendor');
3915 $tbl->setRowTemplate("tpl.shop_users_row.html", "Services/Payment");
3916
3917 $tbl->addColumn(' ', 'vendor_id', '3%', true);
3918 $tbl->addColumn($this->lng->txt('login'), 'login', '32%');
3919 $tbl->addColumn($this->lng->txt('firstname'),'firstname','32%');
3920 $tbl->addColumn($this->lng->txt('lastname'), 'lastname', '32%');
3921
3922 $tbl->setSelectAllCheckbox('vendor_id');
3923 $tbl->addMultiCommand("addUser", $this->lng->txt("add"));
3924 $tbl->addCommandButton('vendors',$this->lng->txt('cancel'));
3925
3926 $tbl->fillFooter();
3927 $tbl->setData($a_result_set);
3928 $this->tpl->setVariable('TABLE', $tbl->getHTML());
3929
3930 return true;
3931 }
3932
3933 private function __search($a_search_string)
3934 {
3935 include_once('./Services/Search/classes/class.ilSearch.php');
3936
3937 $this->lng->loadLanguageModule('content');
3938
3939 $search = new ilSearch($_SESSION['AccountId']);
3940 $search->setPerformUpdate(false);
3941 $search->setSearchString(ilUtil::stripSlashes($a_search_string));
3942 $search->setCombination('and');
3943 $search->setSearchFor(array(0 => 'usr'));
3944 $search->setSearchType('new');
3945
3946 if($search->validate($message))
3947 {
3948 $search->performSearch();
3949 }
3950 else
3951 {
3952 ilUtil::sendInfo($message,true);
3953 $this->ctrl->redirect($this,'searchUser');
3954 }
3955 return $search->getResultByType('usr');
3956 }
3957
3958 private function __searchSP($a_search_string)
3959 {
3960 include_once('./Services/Search/classes/class.ilSearch.php');
3961
3962 $this->lng->loadLanguageModule('content');
3963
3964 $search = new ilSearch($this->user_obj->getId());
3965 $search->setPerformUpdate(false);
3966 $search->setSearchString(ilUtil::stripSlashes($a_search_string));
3967 $search->setCombination('and');
3968 $search->setSearchFor(array(0 => 'usr'));
3969 $search->setSearchType('new');
3970
3971 if($search->validate($message))
3972 {
3973 $search->performSearchSPObject();
3974 }
3975 else
3976 {
3977 ilUtil::sendInfo($message,true);
3978 $this->ctrl->redirect($this,'searchUserSP');
3979 }
3980 return $search->getResultByType('usr');
3981 }
3982 private function __showSearchUserSPTable($a_result_set)
3983 {
3984 $this->ctrl->setParameter($this, 'sell_id', $_GET['sell_id']);
3985 $tbl = new ilShopTableGUI($this);
3986
3987 $tbl->setTitle($this->lng->txt('users'));
3988 $tbl->setId('tbl_search_user_vendor');
3989 $tbl->setRowTemplate("tpl.shop_users_row.html", "Services/Payment");
3990
3991 $tbl->addColumn(' ', 'user_id', '3%', true);
3992 $tbl->addColumn($this->lng->txt('login'), 'login', '32%');
3993 $tbl->addColumn($this->lng->txt('firstname'),'firstname','32%');
3994 $tbl->addColumn($this->lng->txt('lastname'), 'lastname', '32%');
3995
3996
3997 $tbl->addMultiCommand("addCustomer", $this->lng->txt("add"));
3998 $tbl->addCommandButton('statistic',$this->lng->txt('cancel'));
3999
4000 $tbl->fillFooter();
4001 $tbl->setData($a_result_set);
4002 $this->tpl->setVariable('TABLE', $tbl->getHTML());
4003 return true;
4004 }
4005
4006 public function vatsObject()
4007 {
4008 global $ilAccess;
4009
4010 if(!$ilAccess->checkAccess('read', '', $this->object->getRefId()))
4011 {
4012 $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilErr->MESSAGE);
4013 }
4014
4015 include_once 'Services/Table/classes/class.ilTable2GUI.php';
4016 $tbl = new ilTable2GUI($this, 'vats');
4017 $tbl->setId('pay_vats_tbl');
4018 $tbl->setFormAction($this->ctrl->getFormAction($this), 'createVat');
4019 $tbl->setTitle($this->lng->txt('payment_tax_rates'));
4020 $tbl->setRowTemplate('tpl.shop_vats_list_row.html', 'Services/Payment');
4021
4022 $tbl->setDefaultOrderField('title');
4023
4024 $tbl->addColumn('', 'check', '1%');
4025 $tbl->addColumn($this->lng->txt('vat_title'), 'vat_title', '33%');
4026 $tbl->addColumn($this->lng->txt('vat_rate'), 'vat_rate', '33%');
4027 $tbl->addColumn('', 'commands', '33%');
4028
4029 $oShopVatsList = new ilShopVatsList();
4030 $oShopVatsList->read();
4031
4032 $result = array();
4033
4034 $_SESSION['count_vats'] = $oShopVatsList->getNumItems();
4035
4036 if($oShopVatsList->hasItems())
4037 {
4038 $tbl->enable('select_all');
4039 $tbl->setSelectAllCheckbox('vat_id');
4040
4041 $counter = 0;
4042 foreach($oShopVatsList as $oVAT)
4043 {
4044 $result[$counter]['check'] = ilUtil::formCheckbox(0, 'vat_id[]', $oVAT->getId());
4045 $result[$counter]['vat_title'] = $oVAT->getTitle();
4046 $result[$counter]['vat_rate'] = ilShopUtils::_formatVAT((float)$oVAT->getRate());
4047 $this->ctrl->setParameter($this, 'vat_id', $oVAT->getId());
4048 $result[$counter]['edit_text'] = $this->lng->txt('edit');
4049 $result[$counter]['edit_url'] = $this->ctrl->getLinkTarget($this, 'editVat');
4050 $result[$counter]['delete_text'] = $this->lng->txt('delete');
4051 $result[$counter]['delete_url'] = $this->ctrl->getLinkTarget($this, 'confirmDeleteVat');
4052 $this->ctrl->clearParameters($this);
4053 ++$counter;
4054 }
4055
4056 $tbl->addMultiCommand('confirmDeleteVat', $this->lng->txt('delete'));
4057 }
4058 else
4059 {
4060 $tbl->disable('header');
4061 $tbl->disable('footer');
4062
4063 $tbl->setNoEntriesText($this->lng->txt('paya_no_vats_assigned'));
4064 }
4065
4066 $tbl->setData($result);
4067
4068 $tbl->addCommandButton('createVat', $this->lng->txt('paya_insert_vats'));
4069
4070 $this->tpl->setContent($tbl->getHTML());
4071
4072 return true;
4073 }
4074
4075 public function confirmDeleteVatObject()
4076 {
4077 if((int)$_GET['vat_id'] && !isset($_POST['vat_id']))
4078 {
4079 $_POST['vat_id'][] = $_GET['vat_id'];
4080 }
4081
4082 if($_SESSION['count_vats'] == count($_POST['vat_id']))
4083 {
4084 ilUtil::sendInfo($this->lng->txt('shop_disabled_no_vats'));
4085 $_SESSION['disable_shop'] = true;
4086 }
4087
4088 $c_gui = new ilConfirmationGUI();
4089 $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDeleteVat'));
4090 $c_gui->setHeaderText($this->lng->txt('paya_sure_delete_vats'));
4091 $c_gui->setCancel($this->lng->txt('cancel'), 'vats');
4092 $c_gui->setConfirm($this->lng->txt('confirm'), 'performDeleteVat');
4093
4094 $counter = 0;
4095 foreach((array)$_POST['vat_id'] as $vat_id)
4096 {
4097 try
4098 {
4099 $oVAT = new ilShopVats((int)$vat_id);
4100 $c_gui->addItem('vat_id[]', $oVAT->getId(), $oVAT->getTitle());
4101 ++$counter;
4102 }
4103 catch(ilShopException $e)
4104 {
4105 ilUtil::sendInfo($e->getMessage());
4106 return $this->vatsObject();
4107 }
4108 }
4109
4110 if($counter)
4111 {
4112 $this->tpl->setContent($c_gui->getHTML());
4113 return true;
4114 }
4115 else
4116 {
4117 $this->vatsObject();
4118 return true;
4119 }
4120 }
4121
4122 public function performDeleteVatObject()
4123 {
4124 if(!is_array($_POST['vat_id']))
4125 {
4126 return $this->vatsObject();
4127 }
4128
4129 foreach($_POST['vat_id'] as $vat_id)
4130 {
4131 try
4132 {
4133 $oVAT = new ilShopVats((int)$vat_id);
4134 $oVAT->delete();
4135
4136 }
4137 catch(ilShopException $e)
4138 {
4139 ilUtil::sendInfo($e->getMessage());
4140 $_SESSION['disable_shop'] = false;
4141 return $this->vatsObject();
4142 }
4143 }
4144
4145 if($_SESSION['disable_shop'] == true)
4146 {
4147 $this->genSetData->set('shop_enabled', 0, 'common');
4148 $_SESSION['disable_shop'] = false;
4149 }
4150 ilUtil::sendSuccess($this->lng->txt('payment_vat_deleted_successfully'));
4151 return $this->vatsObject();
4152 }
4153 public function createVatObject()
4154 {
4155 $this->initVatForm('create');
4156 $this->tpl->setContent($this->form->getHtml());
4157 }
4158
4159 public function editVatObject()
4160 {
4161 $this->initVatForm('edit');
4162 $this->fillVATDataIntoVATForm();
4163 $this->tpl->setContent($this->form->getHtml());
4164 }
4165
4166 private function initVatForm($a_type = 'create')
4167 {
4168 $this->form = new ilPropertyFormGUI();
4169 if($a_type == 'edit')
4170 {
4171 $this->ctrl->setParameter($this, 'vat_id', $_GET['vat_id']);
4172 $this->form->setFormAction($this->ctrl->getFormAction($this, 'updateVat'));
4173 $this->form->setTitle($this->lng->txt('payment_edit_vat'));
4174 }
4175 else
4176 {
4177 $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveVat'));
4178 $this->form->setTitle($this->lng->txt('payment_add_vat'));
4179 }
4180
4181 $oTitle = new ilTextInputGUI($this->lng->txt('title'), 'vat_title');
4182 $oTitle->setMaxLength(255);
4183 $oTitle->setSize(40);
4184 $oTitle->setRequired(true);
4185 $oTitle->setInfo($this->lng->txt('payment_vat_title_info'));
4186 $this->form->addItem($oTitle);
4187
4188 $oRate = new ilTextInputGUI($this->lng->txt('vat_rate'), 'vat_rate');
4189 $oRate->setMaxLength(5);
4190 $oRate->setSize(5);
4191 $oRate->setRequired(true);
4192 $oRate->setInfo($this->lng->txt('payment_vat_rate_info'));
4193 $this->form->addItem($oRate);
4194
4195 if($a_type == 'edit')
4196 {
4197 $this->form->addCommandButton('updateVat', $this->lng->txt('save'));
4198 }
4199 else
4200 {
4201 $this->form->addCommandButton('saveVat', $this->lng->txt('save'));
4202 }
4203
4204 $this->form->addCommandButton('vats', $this->lng->txt('cancel'));
4205 }
4206
4207 private function fillVATDataIntoVATForm()
4208 {
4209 $oVAT = new ilShopVats((int)$_GET['vat_id']);
4210 $this->form->setValuesByArray(array(
4211 'vat_title' => $oVAT->getTitle(),
4212 'vat_rate' => $oVAT->getRate()
4213 ));
4214 }
4215
4216 public function updateVatObject()
4217 {
4218 $this->initVatForm('edit');
4219 if(!$this->form->checkInput())
4220 {
4221 $this->form->setValuesByPost();
4222 $this->tpl->setContent($this->form->getHtml());
4223 return true;
4224 }
4225
4226 if(!ilShopUtils::_checkVATRate($this->form->getInput('vat_rate')))
4227 {
4228 $this->form->getItemByPostVar('vat_rate')->setAlert($this->lng->txt('payment_vat_input_invalid'));
4229 $this->form->setValuesByPost();
4230 $this->tpl->setContent($this->form->getHtml());
4231 return true;
4232 }
4233
4234 try
4235 {
4236 $oVAT = new ilShopVats((int)$_GET['vat_id']);
4237 $oVAT->setTitle($this->form->getInput('vat_title'));
4238 $oVAT->setRate((float)str_replace(',', '.', $this->form->getInput('vat_rate')));
4239 $oVAT->update();
4240 }
4241 catch(ilShopException $e)
4242 {
4243 ilUtil::sendInfo($e->getMessage());
4244 $this->form->setValuesByPost();
4245 $this->tpl->setContent($this->form->getHtml());
4246 return true;
4247 }
4248
4249 ilUtil::sendInfo($this->lng->txt('saved_successfully'));
4250 return $this->vatsObject();
4251 }
4252
4253 public function saveVatObject()
4254 {
4255 $this->initVatForm('create');
4256 if(!$this->form->checkInput())
4257 {
4258 $this->form->setValuesByPost();
4259 $this->tpl->setContent($this->form->getHtml());
4260 return true;
4261 }
4262
4263 if(!ilShopUtils::_checkVATRate($this->form->getInput('vat_rate')))
4264 {
4265 $this->form->getItemByPostVar('vat_rate')->setAlert($this->lng->txt('payment_vat_input_invalid'));
4266 $this->form->setValuesByPost();
4267 $this->tpl->setContent($this->form->getHtml());
4268 return true;
4269 }
4270
4271 try
4272 {
4273 $oVAT = new ilShopVats();
4274 $oVAT->setTitle($this->form->getInput('vat_title'));
4275 $oVAT->setRate((float)str_replace(',', '.', $this->form->getInput('vat_rate')));
4276 $oVAT->save();
4277 }
4278 catch(ilShopException $e)
4279 {
4280 ilUtil::sendInfo($e->getMessage());
4281 $this->form->setValuesByPost();
4282 $this->tpl->setContent($this->form->getHtml());
4283 return true;
4284
4285 }
4286
4287 ilUtil::sendInfo($this->lng->txt('saved'));
4288 $this->vatsObject();
4289 return true;
4290
4291 }
4292
4294 {
4295 // delete addresses here
4296 include_once './Services/Payment/classes/class.ilPayMethods.php';
4297 $this->__initBookingObject();
4298
4299 foreach($_POST['paymethod'] as $pay_method)
4300 {
4302 $del_bookings = $this->booking_obj->deleteAddressesByPaymethod((int)$pay_method);
4303 }
4304 ilUtil::sendSuccess($this->lng->txt('pays_updated_pay_method'));
4305 return $this->payMethodsObject();
4306 }
4307
4308 // show currencies
4309 public function currenciesObject()
4310 {
4311 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
4313 // currency table
4314 $counter = 0;
4315 foreach($currency_res as $cur)
4316 {
4317 $f_result[$counter]['currency_id'] = ilUtil::formRadioButton(0,'currency_id',$cur['currency_id']);
4318 $f_result[$counter]['is_default'] = $cur['is_default'] == 1 ? $this->lng->txt('yes') : $this->lng->txt('no');
4319
4320 $f_result[$counter]['currency_unit'] = $cur['unit'];
4321 $f_result[$counter]['iso_code'] = $cur['iso_code'];
4322 $f_result[$counter]['currency_symbol'] = $cur['symbol'];
4323 $f_result[$counter]['conversion_rate'] = $cur['conversion_rate'];
4324
4325 $counter++;
4326 }
4327
4328 $tbl = new ilShopTableGUI($this);
4329
4330 $tbl->setTitle($this->lng->txt("currencies"));
4331 $tbl->setId('tbl_show_currencies');
4332 $tbl->setRowTemplate("tpl.shop_currencies_row.html", "Services/Payment");
4333
4334 $tbl->addColumn(' ', 'currency_id', '1%', true);
4335 $tbl->addColumn($this->lng->txt('is_default'), 'is_default', '5%');
4336 $tbl->addColumn($this->lng->txt('currency_unit'), 'currency_unit', '10%');
4337 $tbl->addColumn($this->lng->txt('iso_code'),'iso_code','20%');
4338 $tbl->addColumn($this->lng->txt('currency_symbol'), 'currency_symbol', '20%');
4339 $tbl->addColumn($this->lng->txt('conversion_rate'), 'conversion_rate', '15%');
4340 $tbl->addColumn('', 'options', '5%');
4341
4342 $this->ctrl->setParameter($this, 'cmd', 'currencies');
4343
4344 $tbl->addMultiCommand('updateDefaultCurrency', $this->lng->txt('paya_set_default_currency'));
4345 $tbl->addMultiCommand("editCurrency",$this->lng->txt('edit'));
4346 $tbl->addMultiCommand("deleteCurrency", $this->lng->txt('delete'));
4347
4348 $tbl->addCommandButton('addCurrency',$this->lng->txt('add_currency'));
4349 $tbl->setData($f_result);
4350 $this->tpl->setVariable('TABLE', $tbl->getHTML());
4351 return true;
4352 }
4354 {
4355 if(isset($_POST['currency_id'] ))
4356 {
4358 }
4359 else ilUtil::sendFailure($this->lng->txt('please_select_currency'));
4360
4361 $this->currenciesObject();
4362 }
4363
4364 public function addCurrencyObject()
4365 {
4366 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
4367 $form = new ilPropertyFormGUI();
4368 $form->setFormAction($this->ctrl->getFormAction($this));
4369 $form->setTitle($this->lng->txt('paya_add_currency'));
4370
4371 $o_Unit = new ilTextInputGUI($this->lng->txt('paya_currency_unit'),'currency_unit');
4372 $o_Unit->setValue($_POST['currency_unit']);
4373 $o_Unit->setPostVar('currency_unit');
4374 $o_Unit->setRequired(true);
4375
4376 $o_Isocode = new ilTextInputGUI($this->lng->txt('iso_code'),'iso_code');
4377 $o_Isocode->setValue($_POST['iso_code']);
4378 $o_Isocode->setPostVar('iso_code');
4379 $o_Isocode->setRequired(true);
4380
4381 $o_Symbol = new ilTextInputGUI($this->lng->txt('symbol'), 'symbol');
4382 $o_Symbol->setValue($_POST['symbol']);
4383 $o_Symbol->setPostVar('symbol');
4384 $o_Symbol->setRequired(true);
4385
4386 $o_Conversionrate = new IlTextInputGUI($this->lng->txt('conversion_rate'), 'conversion_rate');
4387 $o_Conversionrate->setValue($_POST['conversion_rate']);
4388 $o_Conversionrate->setPostVar('conversion_rate');
4389 $o_Conversionrate->setRequired(true);
4390
4391 $form->addItem($o_Unit);
4392 $form->addItem($o_Isocode);
4393 $form->addItem($o_Symbol);
4394 $form->addItem($o_Conversionrate);
4395
4396 $form->addCommandButton('saveCurrency', $this->lng->txt('save'));
4397 $form->addCommandButton('currencies', $this->lng->txt('cancel'));
4398
4399 $this->tpl->setVariable('FORM', $form->getHTML());
4400 }
4401
4402 public function saveCurrencyObject()
4403 {
4404 $obj_currency = new ilPaymentCurrency();
4405 $obj_currency->setUnit($_POST['currency_unit']);
4406 $obj_currency->setIsoCode($_POST['iso_code']);
4407 $obj_currency->setSymbol($_POST['symbol']);
4408 $obj_currency->setConversionRate($_POST['conversion_rate']);
4409 $obj_currency->addCurrency();
4410 $this->currenciesObject();
4411 }
4412
4413 public function editCurrencyObject()
4414 {
4415 $currency_id = $_POST['currency_id'];
4416 $obj_currency = ilPaymentCurrency::_getCurrency($currency_id);
4417
4418 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
4419 $form = new ilPropertyFormGUI();
4420 $form->setFormAction($this->ctrl->getFormAction($this));
4421 $form->setTitle($this->lng->txt('paya_edit_currency'));
4422
4423 $o_Unit = new ilTextInputGUI($this->lng->txt('paya_currency_unit'),'currency_unit');
4424 $o_Unit->setValue($obj_currency[$currency_id]['unit']);
4425 $o_Unit->setPostVar('currency_unit');
4426 $o_Unit->setRequired(true);
4427
4428 $o_Isocode = new ilTextInputGUI($this->lng->txt('iso_code'),'iso_code');
4429 $o_Isocode->setValue($obj_currency[$currency_id]['iso_code']);
4430 $o_Isocode->setPostVar('iso_code');
4431 $o_Isocode->setRequired(true);
4432
4433 $o_Symbol = new ilTextInputGUI($this->lng->txt('symbol'), 'symbol');
4434 $o_Symbol->setValue($obj_currency[$currency_id]['symbol']);
4435 $o_Symbol->setPostVar('symbol');
4436 $o_Symbol->setRequired(true);
4437
4438 $o_Conversionrate = new IlTextInputGUI($this->lng->txt('conversion_rate'), 'conversion_rate');
4439 $o_Conversionrate->setValue($obj_currency[$currency_id]['conversion_rate']);
4440 $o_Conversionrate->setPostVar('conversion_rate');
4441 $o_Conversionrate->setRequired(true);
4442
4443 $o_hidden = new ilHiddenInputGUI('currency_id');
4444 $o_hidden->setValue($obj_currency[$currency_id]['currency_id']);
4445 $o_hidden->setPostVar('currency_id');
4446 $form->addItem($o_hidden);
4447
4448 $form->addItem($o_Unit);
4449 $form->addItem($o_Isocode);
4450 $form->addItem($o_Symbol);
4451 $form->addItem($o_Conversionrate);
4452
4453 $form->addCommandButton('updateCurrency', $this->lng->txt('save'));
4454 $form->addCommandButton('currencies', $this->lng->txt('cancel'));
4455
4456 $this->tpl->setVariable('FORM', $form->getHTML());
4457 }
4458
4459 public function deleteCurrencyObject()
4460 {
4461
4462 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
4463 if(ilPaymentCurrency::_isDefault($_POST['currency_id'])) return false;
4464 $_SESSION['currency_id'] = $_POST['currency_id'];
4465
4466 $oConfirmationGUI = new ilConfirmationGUI();
4467 $this->ctrl->setParameter($this,'currency_id',(int) $_POST['currency_id']);
4468 // set confirm/cancel commands
4469 $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this,"performDeleteCurrency"));
4470
4471 $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_selected_currency"));
4472 $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "currencies");
4473 $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDeleteCurrency");
4474
4475 $oConfirmationGUI->addItem('currency_id','', ilPaymentCurrency::_getUnit($_POST['currency_id']),'' );
4476
4477 $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHtml());
4478 return true;
4479 }
4480
4482 {
4483 if(!$_SESSION['currency_id']) return false;
4484
4485 $obj_currency = new ilPaymentCurrency((int)$_SESSION['currency_id']);
4486 $obj_currency->deleteCurrency();
4487
4488 return $this->currenciesObject();
4489 }
4490 public function updateCurrencyObject()
4491 {
4492 if(!$_POST['currency_id']) return false;
4493
4494 $obj_currency = new ilPaymentCurrency($_POST['currency_id']);
4495 $obj_currency->setUnit($_POST['currency_unit']);
4496 $obj_currency->setIsoCode($_POST['iso_code']);
4497 $obj_currency->setSymbol($_POST['symbol']);
4498 $obj_currency->setConversionRate($_POST['conversion_rate']);
4499
4500 $obj_currency->updateCurrency();
4501
4502 $this->currenciesObject();
4503
4504 return true;
4505 }
4506
4507 public function TermsConditionsObject()
4508 {
4509 global $ilToolbar;
4510
4511 $ilToolbar->addButton($this->lng->txt('edit_page'), $this->ctrl->getLinkTargetByClass(array('ilshoppagegui'), 'edit'));
4512
4513 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
4514 $this->tpl->setVariable('FORM', $this->getDocumentsPageHTML(self::CONDITIONS_EDITOR_PAGE_ID));
4515
4516 return true;
4517 }
4518
4519 public function BillingMailObject()
4520 {
4521 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
4522
4523 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
4524 $this->tpl->addJavaScript('Services/Mail/js/ilMailComposeFunctions.js');
4525
4526 $form_gui = new ilPropertyFormGUI();
4527 $form_gui->setFormAction($this->ctrl->getFormAction($this, 'savebillingmail'));
4528 $form_gui->setTitle($this->lng->txt('billing_mail'));
4529
4530
4531 // MESSAGE
4532 $inp = new ilTextAreaInputGUI($this->lng->txt('message_content'), 'm_message');
4533
4534 $inp->setValue(ilPaymentSettings::getMailBillingText());
4535 $inp->setRequired(false);
4536 $inp->setCols(60);
4537 $inp->setRows(10);
4538
4539 // PLACEHOLDERS
4540 $chb = new ilCheckboxInputGUI($this->lng->txt('activate_placeholders'), 'use_placeholders');
4541 $chb->setOptionTitle($this->lng->txt('activate_placeholders'));
4542 $chb->setValue(1);
4544 $form_gui->addItem($inp);
4545
4546 include_once 'Services/Payment/classes/class.ilBillingMailPlaceholdersPropertyGUI.php';
4548
4549 $chb->addSubItem($prop);
4550 $chb->setChecked(true);
4551
4552 $form_gui->addItem($chb);
4553
4554 $form_gui->addCommandButton('saveBillingMail', $this->lng->txt('save'));
4555 $this->tpl->setVariable('FORM', $form_gui->getHTML());
4556
4557 return true;
4558 }
4559
4560 public function saveBillingMailObject()
4561 {
4562 if($_POST['m_message'])
4563 {
4565 }
4566
4567 $_POST['use_placeholders'] ? $placeholders = 1: $placeholders = 0;
4569
4570 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
4571 $this->BillingMailObject();
4572 }
4573
4574 public function getDocumentsPageHTML($a_editor_page_id)
4575 {
4576
4577 // page object
4578
4579 include_once 'Services/Payment/classes/class.ilShopPage.php';
4580 include_once 'Services/Payment/classes/class.ilShopPageGUI.php';
4581
4582 // if page does not exist, return nothing
4583 if(!ilShopPage::_exists('shop', $a_editor_page_id))
4584 {
4585 return '';
4586 }
4587
4588 include_once 'Services/Style/classes/class.ilObjStyleSheet.php';
4589 $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
4590
4591 // get page object
4592 $page_gui = new ilShopPageGUI($a_editor_page_id);
4593
4594 return $page_gui->showPage();
4595 }
4596
4597 public function forwardToDocumentsPageObject($a_editor_page_id)
4598 {
4599 global $ilTabs;
4600
4601 $ilTabs->clearTargets();
4602 $ilTabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this,'documents'), '_self');
4603
4604 include_once 'Services/Payment/classes/class.ilShopPage.php';
4605 include_once 'Services/Payment/classes/class.ilShopPageGUI.php';
4606 include_once('./Services/Style/classes/class.ilObjStyleSheet.php');
4607
4608 $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
4609
4610 if(!ilShopPage::_exists('shop', $a_editor_page_id))
4611 {
4612 // doesn't exist -> create new one
4613 $new_page_object = new ilShopPage();
4614 $new_page_object->setParentId(0);
4615 $new_page_object->setId($a_editor_page_id);
4616 $new_page_object->createFromXML();
4617 }
4618
4619 $this->ctrl->setReturnByClass('ilshoppagegui', 'edit');
4620
4621 $page_gui = new ilShopPageGUI(self::CONDITIONS_EDITOR_PAGE_ID);
4622
4623 return $this->ctrl->forwardCommand($page_gui);
4624 }
4625
4626 public function InvoiceNumberObject()
4627 {
4628 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
4629
4630 $invObj = new ilUserDefinedInvoiceNumber();
4631
4632 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
4633 $this->tpl->addJavaScript('Services/Mail/js/ilMailComposeFunctions.js');
4634
4635 $form_gui = new ilPropertyFormGUI();
4636 $form_gui->setFormAction($this->ctrl->getFormAction($this, 'saveInvoiceNumber'));
4637 $form_gui->setTitle($this->lng->txt('invoice_number_setting'));
4638
4639 // invoice_type
4640 $radio_group = new ilRadioGroupInputGUI($this->lng->txt('invoice_number'), 'ud_invoice_number');
4641 $radio_option_1 = new ilRadioOption($this->lng->txt('ilias_invoice_number'), '0');
4642 $radio_group->addOption($radio_option_1);
4643 $radio_option_2 = new ilRadioOption($this->lng->txt('userdefined_invoice_number'), '1');
4644 $radio_group->addOption($radio_option_2);
4645 $radio_group->setRequired(true);
4646 $radio_group->setValue($invObj->getUDInvoiceNumberActive(),'0');
4647 $radio_group->setPostVar('ud_invoice_number');
4648 $form_gui->addItem($radio_group);
4649
4650 // incremental current value
4651 $cur_num = new ilNonEditableValueGUI($this->lng->txt('incremental_current_value'), 'inc_current_value');
4652 $cur_num->setValue(ilUserDefinedInvoiceNumber::_getIncCurrentValue(), 1);
4653 $radio_option_2->addSubItem($cur_num);
4654
4655 // incremental start value
4656 $inc_num = new ilNumberInputGUI($this->lng->txt('incremental_start_value'), 'inc_start_value');
4657 $inc_num->setValue($this->error != "" && isset($_POST['incremental_start_value'])
4658 ? ilUtil::prepareFormOutput($_POST['incremental_start_value'],true)
4659 : ilUtil::prepareFormOutput($invObj->getIncStartValue(),true));
4660 $inc_num->setInfo($this->lng->txt('incremental_start_value_info'));
4661 $radio_option_2->addSubItem($inc_num);
4662
4663 // reset period of current value
4664 $sel_reset = new ilSelectInputGUI($this->lng->txt('invoice_number_reset_period'), 'inc_reset_period');
4665 $sel_reset->setValue($this->error != "" && isset($_POST['inc_reset_period'])
4666 ? $_POST['inc_reset_period']
4667 : $invObj->getIncResetPeriod());
4668
4669 $reset_options = array(
4670 1 => $this->lng->txt('yearly'),
4671 2 => $this->lng->txt('monthly'));
4672 $sel_reset->setOptions($reset_options);
4673
4674 $radio_option_2->addSubItem($sel_reset);
4675
4676 // invoice_number_text
4677 $inp = new ilTextAreaInputGUI($this->lng->txt('invoice_number_text'), 'invoice_number_text');
4678 $inp->setValue( $this->error != "" && isset($_POST['invoice_number_text'])
4679 ? ilUtil::prepareFormOutput($_POST['invoice_number_text'],true)
4680 : ilUtil::prepareFormOutput($invObj->getInvoiceNumberText(),true));
4681
4682
4683 $inp->setRequired(false);
4684 $inp->setCols(60);
4685 $inp->setRows(3);
4686 $radio_option_2->addSubItem($inp);
4687
4688 // PLACEHOLDERS
4689
4691 $radio_option_2->addSubItem($prop);
4692
4693 $form_gui->addCommandButton('saveInvoiceNumber', $this->lng->txt('save'));
4694 $this->tpl->setVariable('FORM', $form_gui->getHTML());
4695 }
4696
4697 public function saveInvoiceNumberObject()
4698 {
4699 // check conditions
4700 if($_POST['ud_invoice_number'] == 1)
4701 {
4702 if($_POST['inc_start_value'] <= 0 || $_POST['inc_start_value'] == NULL)
4703 {
4704 $this->error = $this->lng->txt('start_value_cannot_be_null');
4705 ilUtil::sendFailure($this->error);
4707 return $this->InvoiceNumberObject();
4708 }
4709
4710 if($_POST['invoice_number_text'] !== NULL)
4711 {
4712 $check_text = $_POST['invoice_number_text'];
4713
4714 if(strpos($check_text, '[INCREMENTAL_NUMBER]') === FALSE)
4715 {
4716 $this->error = $this->lng->txt('invoice_number_must_contain_incremental_number');
4717 ilUtil::sendFailure($this->error);
4718 $this->InvoiceNumberObject();
4719 return true;
4720 }
4721 else
4722 {
4723 if($_POST['inc_reset_period'] == 1) // yearly
4724 {
4725 if(strpos($check_text, '[YEAR]') === FALSE && strpos($check_text, '[CURRENT_TIMESTAMP]') === FALSE)
4726 {
4727 $this->error = $this->lng->txt('invoice_number_must_contain_year_ct');
4728 ilUtil::sendFailure($this->error);
4729 $this->InvoiceNumberObject();
4730 return true;
4731 }
4732 }
4733 else if($_POST['inc_reset_period'] == 2) // monthly
4734 {
4735 if((strpos($check_text, '[YEAR]') === FALSE || strpos($check_text, '[MONTH]') === FALSE )
4736 && (strpos($check_text, '[CURRENT_TIMESTAMP]') === FALSE))
4737 {
4738 $this->error = $this->lng->txt('invoice_number_must_contain_year_month_ct');
4739 ilUtil::sendFailure($this->error);
4740 $this->InvoiceNumberObject();
4741 return true;
4742 }
4743 }
4744 }
4745 }
4746 else
4747 {
4748 ilUtil::sendFailure($this->lng->txt('invoice_number_text_cannot_be_null'));
4749 $this->InvoiceNumberObject();
4750 return true;
4751 }
4752 }
4753 // everythink ok .... update settings
4754 $invObj = new ilUserDefinedInvoiceNumber();
4755 $invObj->setUDInvoiceNumberActive($_POST['ud_invoice_number']);
4756 $invObj->setIncStartValue($_POST['inc_start_value']);
4757 $invObj->setIncResetPeriod($_POST['inc_reset_period']);
4758 $invObj->setInvoiceNumberText($_POST['invoice_number_text']);
4759 $invObj->update();
4760
4761 $this->InvoiceNumberObject();
4762 ilUtil::sendSuccess($this->lng->txt('pays_updated_general_settings'));
4763
4764 return true;
4765 }
4766
4768 {
4769 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
4770 $form = new ilPropertyFormGUI();
4771 $form->setFormAction($this->ctrl->getFormAction($this, 'saveStatutoryRegulations'));
4772 $form->setTitle($this->lng->txt('statutory_regulations'));
4773 $form->setTableWidth('100%');
4774 // message
4775 $post_gui = new ilTextAreaInputGUI($this->lng->txt('content'), 'statutory_regulations');
4776 $post_gui->setCols(50);
4777 $post_gui->setRows(15);
4778 $post_gui->setUseRte(true);
4779 $post_gui->addPlugin('latex');
4780 $post_gui->addButton('latex');
4781 $post_gui->addButton('pastelatex');
4782 $post_gui->addPlugin('ilimgupload');
4783 $post_gui->addButton('ilimgupload');
4784 $post_gui->removePlugin('advlink');
4785 $post_gui->removePlugin(ilRTE::ILIAS_IMG_MANAGER_PLUGIN);
4786 $post_gui->removePlugin('image');
4787 $post_gui->usePurifier(true);
4788 $post_gui->setRTERootBlockElement('');
4789 $post_gui->setRTESupport(ilObject::_lookupObjId($this->ref_id), 'pays~', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.4.7');
4790 $post_gui->disableButtons(array(
4791 'charmap',
4792 'undo',
4793 'redo',
4794 'justifyleft',
4795 'justifycenter',
4796 'justifyright',
4797 'justifyfull',
4798 'anchor',
4799 'fullscreen',
4800 'cut',
4801 'copy',
4802 'paste',
4803 'pastetext',
4804 'formatselect',
4805 'image'
4806 ));
4807 // purifier
4808 require_once 'Services/Html/classes/class.ilHtmlPurifierFactory.php';
4809 require_once 'Services/RTE/classes/class.ilRTE.php';
4810 $post_gui->setPurifier(ilHtmlPurifierFactory::_getInstanceByType('frm_post'));
4811 $post_gui->setValue(ilRTE::_replaceMediaObjectImageSrc($this->genSetData->get('statutory_regulations'),1));
4812 $form->addItem($post_gui);
4813
4814 // show staturaltyio regulations in shoppingcart
4815 $cb_showShoppingCart = new ilCheckboxInputGUI($this->lng->txt('show_sr_shoppingcart'), 'show_sr_shoppingcart');
4816 $cb_showShoppingCart->setInfo($this->lng->txt('show_sr_shoppingcart_info'));
4817 $cb_showShoppingCart->setValue(1);
4818 $cb_showShoppingCart->setChecked($this->genSetData->get('show_sr_shoppingcart'));
4819 $form->addItem($cb_showShoppingCart);
4820
4821 // attach staturaltyio regulations at invoice
4822 $cb_attachInvoice = new ilCheckboxInputGUI($this->lng->txt('attach_sr_invoice'), 'attach_sr_invoice');
4823 $cb_attachInvoice->setInfo($this->lng->txt('attach_sr_invoice_info'));
4824 $cb_attachInvoice->setValue(1);
4825 $cb_attachInvoice->setChecked($this->genSetData->get('attach_sr_invoice'));
4826 $form->addItem($cb_attachInvoice);
4827
4828 $form->addCommandButton('saveStatutoryRegulations', $this->lng->txt('save'));
4829 $this->tpl->setVariable('FORM', $form->getHTML());
4830
4831 }
4832
4834 {
4835 require_once 'Services/RTE/classes/class.ilRTE.php';
4836
4837 if(isset($_POST['statutory_regulations']) && $_POST['statutory_regulations'] != NULL)
4838 {
4839 $this->genSetData->set('statutory_regulations', ilRTE::_replaceMediaObjectImageSrc($_POST['statutory_regulations'], 0), 'regulations');
4840
4841 // copy temporary media objects (frm~)
4842 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
4843 $mediaObjects = ilRTE::_getMediaObjects($_POST['statutory_regulations'], 0);
4844 $myMediaObjects = ilObjMediaObject::_getMobsOfObject('pays~:html', ilObject::_lookupObjId($this->ref_id));
4845 foreach($mediaObjects as $mob)
4846 {
4847 foreach($myMediaObjects as $myMob)
4848 {
4849 if($mob == $myMob)
4850 {
4851 // change usage
4852 ilObjMediaObject::_removeUsage($mob, 'pays~:html', ilObject::_lookupObjId($this->ref_id));
4853 break;
4854 }
4855 }
4856 ilObjMediaObject::_saveUsage($mob, 'pays~:html',ilObject::_lookupObjId($this->ref_id));
4857 }
4858 }
4859 else
4860 {
4861 $this->genSetData->set('statutory_regulations', NULL, 'regulations');
4862 }
4863
4864 // remove usage of deleted media objects
4865 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
4866 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('pays~:html', ilObject::_lookupObjId($this->ref_id));
4867 $curMediaObjects = ilRTE::_getMediaObjects($_POST['statutory_regulations'], 0);
4868 foreach($oldMediaObjects as $oldMob)
4869 {
4870 $found = false;
4871 foreach($curMediaObjects as $curMob)
4872 {
4873 if($oldMob == $curMob)
4874 {
4875 $found = true;
4876 break;
4877 }
4878 }
4879 if(!$found)
4880 {
4881 if(ilObjMediaObject::_exists($oldMob))
4882 {
4883 ilObjMediaObject::_removeUsage($oldMob, 'pays~:html', ilObject::_lookupObjId($this->ref_id));
4884 $mob_obj = new ilObjMediaObject($oldMob);
4885 $mob_obj->delete();
4886 }
4887 }
4888 }
4889
4890 $this->genSetData->set('show_sr_shoppingcart', isset($_POST['show_sr_shoppingcart']) ? 1 : 0, 'regulations');
4891 $this->genSetData->set('attach_sr_invoice', isset($_POST['attach_sr_invoice']) ? 1 : 0, 'regulations');
4892
4894 ilUtil::sendSuccess($this->lng->txt('pays_updated_general_settings'));
4895 return true;
4896 }
4897
4898 public function editPriceObject()
4899 {
4900 $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
4901
4902 $price_id = $_GET['price_id']?$_GET['price_id']: $_POST['price_id'];
4903 $price= ilPaymentPrices::_getPrice($price_id);
4904 $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
4905 $tmp_pobject = ilPaymentObject::_getObjectData($_GET['pobject_id']);
4906 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
4907 $form = new ilPropertyFormGUI();
4908 $form->setFormAction($this->ctrl->getFormAction($this));
4909
4910 $tmp_obj = ilObjectFactory::getInstanceByRefId($tmp_pobject['ref_id'], false);
4911
4912 if($tmp_obj)
4913 {
4914 $form->setTitle($tmp_obj->getTitle());
4915 }
4916 else
4917 {
4918 $form->setTitle($this->lng->txt('object_not_found'));
4919 }
4920
4921 //price_type
4922 $radio_group = new ilRadioGroupInputGUI('','price_type');
4923 $radio_group->setTitle($this->lng->txt('duration'));
4924 $radio_group->setRequired(true);
4925 $radio_group->setValue($price['price_type']);
4926 $radio_group->setPostVar('price_type');
4927
4928 $radio_option_1 = new ilRadioOption($this->lng->txt('duration_month'), ilPaymentPrices::TYPE_DURATION_MONTH);
4929
4930 // duration month
4931 $oDuration = new ilNumberInputGUI();
4932 $oDuration->setTitle($this->lng->txt('paya_months'));
4933 $oDuration->setSize('20%');
4934 $oDuration->setValue($price['duration']);
4935 $oDuration->setPostVar('duration_month');
4936 $radio_option_1->addSubItem($oDuration);
4937
4938 $radio_group->addOption($radio_option_1);
4939
4940 $radio_option_3 = new ilRadioOption($this->lng->txt('duration_date'), ilPaymentPrices::TYPE_DURATION_DATE);
4941
4942 // duration_date from
4943 $o_date_from = new ilDateTimeInputGUI();
4944 $o_date_from->setTitle($this->lng->txt('cal_from'));
4945 $o_date_from->setDate(new ilDate($price['duration_from'],IL_CAL_DATE));
4946 $o_date_from->setPostVar('duration_date_from');
4947 $radio_option_3->addSubItem($o_date_from);
4948
4949 // duration_date until
4950 $o_date_until = new ilDateTimeInputGUI();
4951 $o_date_until->setTitle($this->lng->txt('cal_until'));
4952 $o_date_until->setDate(new ilDate($price['duration_until'],IL_CAL_DATE));
4953 $o_date_until->setPostVar('duration_date_until');
4954 $radio_option_3->addSubItem($o_date_until);
4955
4956 $radio_group->addOption($radio_option_3);
4957
4958 $radio_option_2 = new ilRadioOption($this->lng->txt('unlimited_duration'), ilPaymentPrices::TYPE_UNLIMITED_DURATION);
4959 $radio_group->addOption($radio_option_2);
4960
4961 $form->addItem($radio_group);
4962
4963 // description
4964 $oDescription = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
4965 $oDescription->setRows(4);
4966 $oDescription->setCols(35);
4967 $oDescription->setValue($price['description']);
4968 $form->addItem($oDescription);
4969
4970 // price
4971 $oPrice = new ilNumberInputGUI();
4972 $oPrice->setTitle($this->lng->txt('price_a'));
4973 $oPrice->setSize('20%');
4974 $oPrice->setRequired(true);
4975 $oPrice->setValue($price['price']);
4976 include_once './Services/Payment/classes/class.ilPaymentSettings.php';
4978 $oPrice->setInfo($genSet->get('currency_unit'));
4979 $oPrice->setPostVar('price');
4980 $oPrice->allowDecimals(true);
4981 $form->addItem($oPrice);
4982
4983 //extension
4984 $oExtension = new ilCheckboxInputGUI($this->lng->txt('extension_price'), 'extension');
4985
4986 $oExtension->setChecked($price['extension']);
4987
4988 $form->addItem($oExtension);
4989
4990 $o_hidden_1 = new ilHiddenInputGUI('pobject_id');
4991 $o_hidden_1->setValue( (int)$_GET['pobject_id']);
4992 $o_hidden_1->setPostVar('pobject_id');
4993
4994 $o_hidden_2 = new ilHiddenInputGUI('price_id');
4995 $o_hidden_2->setValue( (int)$_GET['price_id']);
4996 $o_hidden_2->setPostVar('price_id');
4997
4998 $form->addItem($o_hidden_1);
4999 $form->addItem($o_hidden_2);
5000
5001 $form->addCommandButton('updatePrice',$this->lng->txt('save'));
5002 $form->addCommandButton('editPrices', $this->lng->txt('cancel'));
5003
5004 $this->tpl->setVariable('FORM',$form->getHTML());
5005 }
5006
5007} // END class.ilObjPaymentSettingsGUI
5008?>
$result
$_GET["client_id"]
$_SESSION["AccountId"]
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DATETIME
error($a_errmsg)
set error message @access public
static getInstance()
Static method to get the singleton instance.
This class represents a checkbox property in a property form.
Confirmation screen class.
static formatDate(ilDateTime $date)
Format a date @access public.
This class represents a date/time property in a property form.
Class for single dates.
This class handles all operations on files in directory data/shop.
static _getLocalMoneyFormat($float_number)
converts a float number to money format, depending on system language
This class represents a hidden form property in a property form.
static _getInstanceByType($a_type)
Factory method for creating purifier instances.
This class represents an image file property in a property form.
This class represents a non editable value in a property form.
This class represents a number property in a property form.
Class ilObjMediaObject.
_saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _exists($a_id)
checks wether a lm content object with specified id exists or not
_removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
getTabs($tabs_gui)
get tabs @access public
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor @access public.
editStatisticObject($a_show_confirm_delete=false)
payMethodsObject($askForDeletingAddresses=array())
getContentStylePath($a_style_id)
get content style path
static _lookupLogin($a_user_id)
lookup login
getLoginByUserId($a_userid)
getUserIdByLogin($a_login)
static _lookupName($a_user_id)
lookup user name
_lookupEmail($a_user_id)
Lookup email.
static _readUsersProfileData($a_user_ids)
STATIC METHOD get user data of selected users.
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjectGUI Basic methods of all Output classes.
ilObjectGUI($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor @access public.
prepareOutput()
prepare output
& executeCommand()
execute command
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
Class ilObjPaymentSettingsGUI.
static _disableSaveUserAddress($a_id)
static _PMdisable($a_id)
static _PMEnabled($a_id)
static getPayMethodsOptions($type=0)
static getStringByPaymethod($a_type)
static _EnabledSaveUserAddress($a_id)
static _PMenable($a_id)
static _enableSaveUserAddress($a_id)
static _getCountBookingsByObject($a_pobject_id)
static _getCountBookingsByVendor($a_vendor_id)
static _getUnit($a_currency_id)
static _getCurrency($a_currency_id)
static _isDefault($a_currency_id)
static _updateIsDefault($a_currency_id)
static _getObjectData($a_id)
static _getCountObjectsByPayMethod($a_id)
static _lookupPobjectId($a_ref_id)
static _getPriceString($a_price_id)
static _getPrice($a_price_id)
static setMailBillingText($a_mail_billing_text)
static setMailUsePlaceholders($a_mail_use_placeholders)
static _deleteTrusteesOfVendor($a_vendor_id)
static getInstance()
Static method to get the singleton instance.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static _getMediaObjects($a_text, $a_direction=0)
Returns all media objects found in the passed string.
const ILIAS_IMG_MANAGER_PLUGIN
Definition: class.ilRTE.php:36
This class represents a property in a property form.
This class represents an option in a radio group.
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
This class represents a selection list property in a property form.
Class for shop related exception handling in ILIAS.
Shop page GUI class.
Shop page object.
Class ilShopTableGUI.
Class ilShopTopicsGUI.
static _assignPurchasedCourseMemberRole($oPaymentObject, $a_user_id=0)
static _addPurchasedObjToDesktop($oPaymentObject, $a_user_id=0)
static _checkVATRate($a_vat_rate)
Checks if the passed vat rate is valid.
static _formatVAT($a_vat)
Formats a vat rate for gui output.
Class ilShopVatsList.
Class ilShopVats.
static _readAllVats()
Class ilTable2GUI.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This class represents a text property in a property form.
static formRadioButton($checked, $varname, $value, $onclick=null, $disabled=false)
??? @access public
static formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$_POST['username']
Definition: cron.php:12
$html
Definition: example_001.php:87
$tbl
Definition: example_048.php:81
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
$path
Definition: index.php:22
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15