ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjPaymentSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
38 require_once "./classes/class.ilObjectGUI.php";
39 
41 {
42  var $user_obj = null;
43  var $pobject = null;
44 
45  var $section;
47 
52  function ilObjPaymentSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
53  {
54  global $ilias;
55 
56  $this->user_obj =& $ilias->account;
57 
58  include_once "./payment/classes/class.ilPaymentObject.php";
59 
60  $this->pobject =& new ilPaymentObject($this->user_obj);
61 
62 
63  $this->type = "pays";
64  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
65 
66  $this->SECTION_GENERAL = 1;
67  $this->SECTION_PAYPAL = 2;
68  $this->SETTINGS = 3;
69  $this->OTHERS = 0;
70  $this->STATISTIC = 4;
71  $this->VENDORS = 5;
72  $this->PAY_METHODS = 6;
73  $this->OBJECTS = 7;
74  $this->SECTION_BMF = 8;
75  $this->TOPICS = 9;
76 
77  $this->lng->loadLanguageModule('payment');
78  }
79 
80  function &executeCommand()
81  {
82  $next_class = $this->ctrl->getNextClass($this);
83  $cmd = $this->ctrl->getCmd();
84  $this->prepareOutput();
85 
86  switch($next_class)
87  {
88  case 'ilpermissiongui':
89  include_once("./classes/class.ilPermissionGUI.php");
90  $perm_gui =& new ilPermissionGUI($this);
91  $ret =& $this->ctrl->forwardCommand($perm_gui);
92  break;
93 
94  case 'ilpageobjectgui':
95  $this->prepareOutput();
96  $ret = $this->forwardToPageObject();
97  if($ret != '')
98  {
99  $this->tpl->setContent($ret);
100  }
101  break;
102 
103  case 'ilshoptopicsgui':
104  include_once 'Services/Payment/classes/class.ilShopTopicsGUI.php';
105  $topics_gui = new ilShopTopicsGUI($this);
106  $ret = $this->ctrl->forwardCommand($topics_gui);
107  break;
108 
109  default:
110  if ($cmd == "" || $cmd == "view")
111  {
112  $cmd = "generalSettings";
113  }
114  switch ($cmd)
115  {
116  case "vendors" :
117  case "searchUser" :
118  case "search" :
119  case "performSearch" :
120  case "addVendor" :
121  case "exportVendors" :
122  case "performDeleteVendors" :
123  case "cancelDeleteVendors" :
124  case "performEditVendor" : $this->__setSection($this->OTHERS);
125  $this->__setMainSection($this->STATISTIC);
126  $this->tabs_gui->setTabActive("vendors");
127  break;
128  case "statistic" :
129  case "editStatistic" :
130  case "updateStatistic" :
131  case "deleteStatistic" :
132  case "performDelete" :
133  case "resetFilter" :
134  case "exportVendors" :
135  case "addCustomer" :
136  case "saveCustomer" :
137  case "showObjectSelector" :
138  case "searchUserSP" :
139  case "performSearchSP" : $this->__setSection($this->OTHERS);
140  $this->__setMainSection($this->STATISTIC);
141  $this->tabs_gui->setTabActive("statistic");
142  break;
143  case "updateObjectDetails" :
144  case "deleteObject" :
145  case "performObjectDelete" :
146  case "objects" :
147  case "editPrices" :
148  case "addPrice" :
149  case "editObject" :
150  case "resetObjectFilter" :
151  include_once "./payment/classes/class.ilPaymentObject.php";
152  include_once "./payment/classes/class.ilPaymentBookings.php";
153  $this->__setSection($this->OTHERS);
154  $this->__setMainSection($this->OBJECTS);
155  $this->tabs_gui->setTabActive("objects");
156  break;
157  case "saveGeneralSettings" :
158  case "generalSettings" : $this->__setSection($this->SECTION_GENERAL);
159  $this->__setMainSection($this->SETTINGS);
160  $this->tabs_gui->setTabActive("settings");
161  break;
162  case "saveBmfSettings" :
163  case "bmfSettings" : $this->__setSection($this->SECTION_BMF);
164  $this->__setMainSection($this->SETTINGS);
165  $this->tabs_gui->setTabActive("settings");
166  break;
167  case "savePaypalSettings" :
168  case "paypalSettings" : $this->__setSection($this->SECTION_PAYPAL);
169  $this->__setMainSection($this->SETTINGS);
170  $this->tabs_gui->setTabActive("settings");
171  break;
172  case "savePayMethods" : $this->__setSection($this->OTHERS);
173  $this->__setMainSection($this->PAY_METHODS);
174  $this->tabs_gui->setTabActive("pay_methods");
175  break;
176  case "gateway" : if ($_POST["action"] == "editVendorObject" ||
177  $_POST["action"] == "deleteVendorsObject")
178  {
179  $this->__setSection($this->OTHERS);
180  $this->__setMainSection($this->STATISTIC);
181  $this->tabs_gui->setTabActive("vendors");
182  }
183  break;
184  default : $this->__setSection($this->OTHERS);
185  $this->__setMainSection($this->OTHERS);
186  break;
187  }
188  $cmd .= "Object";
189 
190  $this->__buildSettingsButtons();
191 
192  $this->$cmd();
193 
194  break;
195  }
196  return true;
197  }
198 
199  public function forwardToPageObject()
200  {
201  global $ilTabs;
202 
203  if(!(int)$_GET['pobject_id'])
204  {
205  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
206  return $this->showObjects();
207  }
208  $this->ctrl->setParameter($this, 'pobject_id', (int)$_GET['pobject_id']);
209  $this->__initPaymentObject((int)$_GET['pobject_id']);
210 
211  $this->lng->loadLanguageModule('content');
212 
213  $ilTabs->clearTargets();
214  $ilTabs->clearSubTabs();
215  $ilTabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'editObject'));
216 
217  // page objec
218  include_once 'Services/COPage/classes/class.ilPageObject.php';
219  include_once 'Services/COPage/classes/class.ilPageObjectGUI.php';
220  include_once('./Services/Style/classes/class.ilObjStyleSheet.php');
221 
222  $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
223 
224  if(!ilPageObject::_exists('shop', $this->pobject->getPobjectId()))
225  {
226  // doesn't exist -> create new one
227  $new_page_object = new ilPageObject('shop');
228  $new_page_object->setParentId(0);
229  $new_page_object->setId($this->pobject->getPobjectId());
230  $new_page_object->createFromXML();
231  }
232 
233  $this->ctrl->setReturnByClass('ilpageobjectgui', 'edit');
234 
235  $page_gui = new ilPageObjectGUI('shop', $this->pobject->getPobjectId());
236  $this->ctrl->setParameter($page_gui, 'pobject_id', (int)$_GET['pobject_id']);
237  $page_gui->setIntLinkHelpDefault('StructureObject', $this->pobject->getPobjectId());
238  $page_gui->setTemplateTargetVar('ADM_CONTENT');
239  $page_gui->setLinkXML('');
240  $page_gui->setFileDownloadLink($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'downloadFile'));
241  $page_gui->setFullscreenLink($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'displayMediaFullscreen'));
242  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'download_paragraph'));
243  $page_gui->setPresentationTitle('');
244  $page_gui->setTemplateOutput(false);
245  $page_gui->setHeader('');
246  $page_gui->setEnabledRepositoryObjects(false);
247  $page_gui->setEnabledFileLists(true);
248  $page_gui->setEnabledMaps(true);
249  $page_gui->setEnabledPCTabs(true);
250 
251  return $this->ctrl->forwardCommand($page_gui);
252  }
253 
255  {
256  global $rbacsystem;
257 
258  // MINIMUM ACCESS LEVEL = 'read'
259  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
260  {
261  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
262  }
263 
264  include_once './payment/classes/class.ilBMFSettings.php';
265 
266  $this->error = "";
267 
268  $bmfSetObj = ilBMFSettings::getInstance();
269 
270  $bmfSetObj->setClientId(ilUtil::stripSlashes($_POST["mandantNr"]));
271  $bmfSetObj->setBewirtschafterNr(ilUtil::stripSlashes($_POST["bewirtschafterNr"]));
272  $bmfSetObj->setHaushaltsstelle(ilUtil::stripSlashes($_POST["haushaltsstelle"]));
273  $bmfSetObj->setObjectId(ilUtil::stripSlashes($_POST["objektNr"]));
274  $bmfSetObj->setKennzeichenMahnverfahren(ilUtil::stripSlashes($_POST["kennzeichenMahnverfahren"]));
275  $bmfSetObj->setWaehrungsKennzeichen(ilUtil::stripSlashes($_POST["waehrungskennzeichen"]));
276  $bmfSetObj->setEpaymentServer(ilUtil::stripSlashes($_POST["ePaymentServer"]));
277  $bmfSetObj->setClientCertificate(ilUtil::stripSlashes($_POST["clientCertificate"]));
278  $bmfSetObj->setCaCertificate(ilUtil::stripSlashes($_POST["caCertificate"]));
279  $bmfSetObj->setTimeout(ilUtil::stripSlashes($_POST["timeOut"]));
280 
281  if ($_POST["mandantNr"] == "" ||
282  $_POST["bewirtschafterNr"] == "" ||
283  $_POST["haushaltsstelle"] == "" ||
284  $_POST["objektNr"] == "" ||
285  $_POST["kennzeichenMahnverfahren"] == "" ||
286  $_POST["waehrungskennzeichen"] == "" ||
287  $_POST["ePaymentServer"] == "" ||
288  $_POST["clientCertificate"] == "" ||
289  $_POST["caCertificate"] == "" ||
290  $_POST["timeOut"] == "")
291  {
292  $this->error = $this->lng->txt('pays_bmf_settings_not_valid');
293  ilUtil::sendInfo($this->error);
294  $this->bmfSettingsObject();
295  return;
296  }
297 
298  $bmfSetObj->save();
299 
300  $this->bmfSettingsObject();
301 
302  ilUtil::sendInfo($this->lng->txt('pays_updated_bmf_settings'));
303 
304  return true;
305  }
306 
307  function bmfSettingsObject()
308  {
309  global $rbacsystem;
310 
311  // MINIMUM ACCESS LEVEL = 'read'
312  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
313  {
314  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
315  }
316  include_once './payment/classes/class.ilBMFSettings.php';
317  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
318 
319  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_bmf_settings.html",'payment');
320 
321  $bmfSetObj = ilBMFSettings::getInstance();
322 
323  $form = new ilPropertyFormGUI();
324  $form->setFormAction($this->ctrl->getFormAction($this, "saveBmfSettings"));
325  $form->setTitle($this->lng->txt('pays_bmf_settings'));
326 
327  $form->addCommandButton('saveBmfSettings',$this->lng->txt('save'));
328 
329  $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_client_id"), "mandantNr");
330  $formItem->setValue($bmfSetObj->getClientId());
331  $form->addItem($formItem);
332 
333  $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_bewirtschafter_nr"), "bewirtschafterNr");
334  $formItem->setValue($bmfSetObj->getBewirtschafterNr());
335  $form->addItem($formItem);
336 
337  $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_haushaltsstelle"), "haushaltsstelle");
338  $formItem->setValue($bmfSetObj->getHaushaltsstelle());
339  $form->addItem($formItem);
340 
341  $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_object_id"), "objektNr");
342  $formItem->setValue($bmfSetObj->getObjectId());
343  $form->addItem($formItem);
344 
345  $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_kennzeichen_mahnverfahren"), "kennzeichenMahnverfahren");
346  $formItem->setValue($bmfSetObj->getKennzeichenMahnverfahren());
347  $form->addItem($formItem);
348 
349  $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_waehrungskennzeichen"), "waehrungskennzeichen");
350  $formItem->setValue($bmfSetObj->getWaehrungsKennzeichen());
351  $form->addItem($formItem);
352 
353  $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_epayment_server"), "ePaymentServer");
354  $formItem->setValue($bmfSetObj->getEpaymentServer());
355  $form->addItem($formItem);
356 
357  $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_client_certificate"), "clientCertificate");
358  $formItem->setValue($bmfSetObj->getClientCertificate());
359  $form->addItem($formItem);
360 
361  $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_ca_certificate"), "caCertificate");
362  $formItem->setValue($bmfSetObj->getCaCertificate());
363  $form->addItem($formItem);
364 
365  $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_timeout"), "timeOut");
366  $formItem->setValue($bmfSetObj->getTimeOut());
367  $form->addItem($formItem);
368 
369  $this->tpl->setVariable('BMF_SETTINGS',$form->getHTML());
370  }
371 
373  {
374  if(!$_GET['pobject_id'])
375  {
376  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
377 
378  $this->objectObjects();
379  return true;
380  }
381  $this->__initPaymentObject((int) $_GET['pobject_id']);
382  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
383 
384  // read old settings
385  $old_pay_method = $this->pobject->getPayMethod();
386  $old_status = $this->pobject->getStatus();
387 
388  // check status changed from not_buyable
389  if($old_status == $this->pobject->STATUS_NOT_BUYABLE and
390  (int) $_POST['status'] != $old_status)
391  {
392  // check pay_method edited
393  switch((int) $_POST['pay_method'])
394  {
395  case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
396  ilUtil::sendInfo($this->lng->txt('paya_select_pay_method_first'));
397  $this->editObjectObject();
398 
399  return false;
400 
401  case $this->pobject->PAY_METHOD_BILL:
402  include_once './payment/classes/class.ilPaymentBillVendor.php';
403 
404  $bill_vendor =& new ilPaymentBillVendor((int) $_GET['pobject_id']);
405  if(!$bill_vendor->validate())
406  {
407  ilUtil::sendInfo($this->lng->txt('paya_select_pay_method_first'));
408  $this->editObjectObject();
409 
410  return false;
411  }
412  break;
413 
414  default:
415  ;
416  }
417  // check minimum one price
418  include_once './payment/classes/class.ilPaymentPrices.php';
419 
420  $prices_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
421  if(!count($prices_obj->getPrices()))
422  {
423  ilUtil::sendInfo($this->lng->txt('paya_edit_prices_first'));
424  $this->editObjectObject();
425 
426  return false;
427  }
428  }
429 
430 
431  $this->pobject->setStatus((int) $_POST['status']);
432  $this->pobject->setVendorId((int) $_POST['vendor']);
433  $this->pobject->setPayMethod((int) $_POST['pay_method']);
434  $this->pobject->setTopicId((int) $_POST['topic_id']);
435 
436  $this->pobject->update();
437 
438  ilUtil::sendInfo($this->lng->txt('paya_details_updated'));
439  $this->editObjectObject();
440 
441  return true;
442  }
443 
444  function editPricesObject($a_show_delete = false)
445  {
446  include_once './payment/classes/class.ilPaymentPrices.php';
447  include_once './payment/classes/class.ilPaymentCurrency.php';
448  include_once "./Services/Table/classes/class.ilTableGUI.php";
449  include_once './payment/classes/class.ilGeneralSettings.php';
450 
451  $genSet = new ilGeneralSettings();
452 
453  $_SESSION['price_ids'] = $_SESSION['price_ids'] ? $_SESSION['price_ids'] : array();
454 
455  if(!$_GET['pobject_id'])
456  {
457  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
458 
459  $this->objectsObject();
460  return true;
461  }
462  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
463 
464  $this->__showButton('objects',$this->lng->txt('back'));
465  $this->__showButton('editObject',$this->lng->txt('paya_edit_details'));
466  $this->__showButton('editPrices',$this->lng->txt('paya_edit_prices'));
467 
468  $this->__initPaymentObject((int) $_GET['pobject_id']);
469 
470  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_edit_prices.html','payment');
471 
472  $price_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
473  $prices = $price_obj->getPrices();
474 
475  // No prices created
476  if(!count($prices))
477  {
478  ilUtil::sendInfo($this->lng->txt('paya_no_price_available'));
479 
480  $this->tpl->setCurrentBlock("price_info");
481  $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
482  $this->tpl->setVariable("CONFIRM_CMD",'addPrice');
483  $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('paya_add_price'));
484  $this->tpl->parseCurrentBlock();
485 
486  return true;
487  }
488  // Show confirm delete
489  if($a_show_delete)
490  {
491  ilUtil::sendInfo($this->lng->txt('paya_sure_delete_selected_prices'));
492 
493  $this->tpl->setCurrentBlock("cancel");
494  $this->tpl->setVariable("CANCEL_CMD",'editPrices');
495  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
496  $this->tpl->parseCurrentBlock();
497 
498  $this->tpl->setCurrentBlock("price_info");
499  $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
500  $this->tpl->setVariable("CONFIRM_CMD",'performDeletePrice');
501  $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('paya_delete_price'));
502  $this->tpl->parseCurrentBlock();
503  }
504 
505  // Fill table cells
506  $tpl =& new ilTemplate('tpl.table.html',true,true);
507 
508  // set table header
509  $tpl->setCurrentBlock("tbl_form_header");
510 
511  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
512  $tpl->parseCurrentBlock();
513 
514  $tpl->addBlockfile("TBL_CONTENT", "tbl_content",'tpl.paya_adm_edit_prices_row.html','payment');
515 
516  $counter = 0;
517  foreach($prices as $price)
518  {
519  $currency = ilPaymentCurrency::_getCurrency($price['currency']);
520 
521  $tpl->setCurrentBlock("tbl_content");
522  $tpl->setVariable("ROWCOL", ilUtil::switchColor($counter,"tblrow2","tblrow1"));
523 
524  $tpl->setVariable("CHECKBOX",ilUtil::formCheckBox(in_array($price['price_id'],$_SESSION['price_ids']) ? 1 : 0,
525  'price_ids[]',
526  $price['price_id']));
527  $tpl->setVariable("DURATION_NAME",'prices['.$price['price_id'].'][duration]');
528  $tpl->setVariable("DURATION",$price['duration']);
529  $tpl->setVariable("MONTH",$this->lng->txt('paya_months'));
530  $tpl->setVariable("UNIT_NAME",'prices['.$price['price_id'].'][unit_value]');
531  $tpl->setVariable("UNIT",$price['unit_value']);
532 # $tpl->setVariable("SHORTFORM",$this->lng->txt('currency_'.$currency['unit']));
533  $tpl->setVariable("SHORTFORM",$genSet->get("currency_unit"));
534 
535  $tpl->setVariable("SUB_UNIT_NAME",'prices['.$price['price_id'].'][sub_unit_value]');
536  $tpl->setVariable("SUB_UNIT",$price['sub_unit_value']);
537 # $tpl->setVariable("SUB_UNIT_TXT",$this->lng->txt('currency_'.$currency['sub_unit']));
538  $tpl->setVariable("SUB_UNIT_TXT",$genSet->get("currency_subunit"));
539  $tpl->parseCurrentBlock();
540 
541  ++$counter;
542  }
543 
544  // SET FOOTER
545  $tpl->setCurrentBlock("tbl_action_button");
546  $tpl->setVariable("BTN_NAME","deletePrice");
547  $tpl->setVariable("BTN_VALUE",$this->lng->txt("paya_delete_price"));
548  $tpl->parseCurrentBlock();
549 
550  $tpl->setCurrentBlock("plain_buttons");
551  $tpl->setVariable("PBTN_NAME","updatePrice");
552  $tpl->setVariable("PBTN_VALUE",$this->lng->txt("paya_update_price"));
553  $tpl->parseCurrentBlock();
554 
555  $tpl->setCurrentBlock("plain_buttons");
556  $tpl->setVariable("PBTN_NAME","addPrice");
557  $tpl->setVariable("PBTN_VALUE",$this->lng->txt("paya_add_price"));
558  $tpl->parseCurrentBlock();
559 
560 
561  $tpl->setCurrentBlock("tbl_action_row");
562  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
563  $tpl->setVariable("COLUMN_COUNTS",4);
564  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
565  $tpl->parseCurrentBlock();
566 
567 
568  $tbl = new ilTableGUI();
569  $tbl->setTemplate($tpl);
570 
571  // title & header columns
572  $tbl->setStyle('table','std');
573 
574  $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId());
575 
576  $tbl->setTitle($tmp_obj->getTitle(),
577  "icon_".$tmp_obj->getType()."_b.gif",
578  $this->lng->txt("objs_".$tmp_obj->getType()));
579  $tbl->setHeaderNames(array('',
580  $this->lng->txt('duration'),
581  $this->lng->txt('price_a'),
582  ''));
583  $tbl->setHeaderVars(array("",
584  "duration",
585  "price_unit",
586  "price_sub_unit"),
587  array("ref_id" => $this->cur_ref_id));
588 
589  // control
590  $tbl->setLimit($_GET["limit"]);
591  $tbl->setOffset($_GET["offset"]);
592  $tbl->setMaxCount(count($price_obj->getPrices()));
593 
594  $tbl->disable("sort");
595 
596  // render table
597  $tbl->render();
598 
599  $this->tpl->setVariable("PRICES_TABLE",$tpl->get());
600 
601  return true;
602  }
603 
604  function addPriceObject()
605  {
606  if(!$_GET['pobject_id'])
607  {
608  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
609 
610  $this->showObjects();
611  return true;
612  }
613 
614  include_once './payment/classes/class.ilGeneralSettings.php';
615 
616  $genSet = new ilGeneralSettings();
617 
618  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
619 
620  $this->__initPaymentObject((int) $_GET['pobject_id']);
621 
622  $this->__showButton('editObject',$this->lng->txt('paya_edit_details'));
623  $this->__showButton('editPrices',$this->lng->txt('paya_edit_prices'));
624 
625  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_add_price.html','payment');
626 
627  $this->tpl->setVariable("ADD_FORMACTION",$this->ctrl->getFormAction($this));
628 
629  $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId());
630  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$tmp_obj->getType().'_b.gif'));
631  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_'.$tmp_obj->getType()));
632  $this->tpl->setVariable("TITLE",$tmp_obj->getTitle());
633  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('paya_add_price_title'));
634 
635  // TODO show curency selector
636 # $this->tpl->setVariable("TXT_PRICE_A",$this->lng->txt('currency_euro'));
637 # $this->tpl->setVariable("TXT_PRICE_B",$this->lng->txt('currency_cent'));
638  $this->tpl->setVariable("TXT_PRICE_A",$genSet->get("currency_unit"));
639  $this->tpl->setVariable("TXT_PRICE_B",$genSet->get("currency_subunit"));
640 
641  $this->tpl->setVariable("MONTH",$this->lng->txt('paya_months'));
642  $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('duration'));
643  $this->tpl->setVariable("TXT_PRICE",$this->lng->txt('price_a'));
644  $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
645  $this->tpl->setVariable("ADD",$this->lng->txt('paya_add_price'));
646 
647  $this->tpl->setVariable("DURATION",$_POST['duration']);
648  $this->tpl->setVariable("UNIT_VALUE",$_POST['unit']);
649  $this->tpl->setVariable("SUB_UNIT",$_POST['SUB_UNIT']);
650 
651  return true;
652  }
653 
655  {
656  if(!$_GET['pobject_id'])
657  {
658  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
659 
660  $this->objectsObject();
661  return true;
662  }
663 
664  include_once './payment/classes/class.ilPaymentPrices.php';
665  include_once './payment/classes/class.ilPaymentCurrency.php';
666 
668 
669  $prices =& new ilPaymentPrices((int) $_GET['pobject_id']);
670 
671  $prices->setDuration($_POST['duration']);
672  $prices->setUnitValue($_POST['unit']);
673  $prices->setSubUnitValue($_POST['sub_unit']);
674  $prices->setCurrency($currency[1]['currency_id']);
675 
676  if(!$prices->validate())
677  {
678  ilUtil::sendInfo($this->lng->txt('paya_price_not_valid'));
679  $this->addPriceObject();
680 
681  return true;
682  }
683  $prices->add();
684 
685  ilUtil::sendInfo($this->lng->txt('paya_added_new_price'));
686  $this->editPricesObject();
687 
688  return true;
689  }
690 
692  {
693  if(!$_GET['pobject_id'])
694  {
695  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
696 
697  $this->objectsObject();
698  return true;
699  }
700 
701  if(!count($_SESSION['price_ids']))
702  {
703  ilUtil::sendInfo($this->lng->txt('paya_no_prices_selected'));
704 
705  $this->editPricesObject();
706  return true;
707  }
708  include_once './payment/classes/class.ilPaymentPrices.php';
709 
710  $prices =& new ilPaymentPrices((int) $_GET['pobject_id']);
711 
712  foreach($_SESSION['price_ids'] as $price_id)
713  {
714  $prices->delete($price_id);
715  }
716 
717  // check if it was last price otherwise set status to 'not_buyable'
718  if(!count($prices->getPrices()))
719  {
720  $this->__initPaymentObject((int) $_GET['pobject_id']);
721 
722  $this->pobject->setStatus($this->pobject->STATUS_NOT_BUYABLE);
723  $this->pobject->update();
724 
725  ilUtil::sendInfo($this->lng->txt('paya_deleted_last_price'));
726  }
727  unset($prices);
728  unset($_SESSION['price_ids']);
729 
730  return $this->editPricesObject();
731  }
732 
733  function deletePriceObject()
734  {
735  if(!$_GET['pobject_id'])
736  {
737  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
738 
739  $this->objectsObject();
740  return true;
741  }
742 
743  if(!count($_POST['price_ids']))
744  {
745  ilUtil::sendInfo($this->lng->txt('paya_no_prices_selected'));
746 
747  $this->editPricesObject();
748  return true;
749  }
750  $_SESSION['price_ids'] = $_POST['price_ids'];
751 
752  $this->editPricesObject(true);
753  return true;
754  }
755 
756  function updatePriceObject()
757  {
758  include_once './payment/classes/class.ilPaymentPrices.php';
759 
760  if(!$_GET['pobject_id'])
761  {
762  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
763 
764  $this->objectsObject();
765  return true;
766  }
767  $po =& new ilPaymentPrices((int) $_GET['pobject_id']);
768 
769  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
770 
771  // validate
772  foreach($_POST['prices'] as $price_id => $price)
773  {
774  $old_price = $po->getPrice($price_id);
775 
776  $po->setDuration($price['duration']);
777  $po->setUnitValue($price['unit_value']);
778  $po->setSubUnitValue($price['sub_unit_value']);
779  $po->setCurrency($old_price['currency']);
780 
781  if(!$po->validate())
782  {
783  $error = true;
784  }
785  }
786  if($error)
787  {
788  ilUtil::sendInfo($this->lng->txt('paya_insert_only_numbers'));
789 
790  $this->editPricesObject();
791  return false;
792  }
793  foreach($_POST['prices'] as $price_id => $price)
794  {
795  $old_price = $po->getPrice($price_id);
796 
797  $po->setDuration($price['duration']);
798  $po->setUnitValue($price['unit_value']);
799  $po->setSubUnitValue($price['sub_unit_value']);
800  $po->setCurrency($old_price['currency']);
801 
802  $po->update($price_id);
803  }
804  ilUtil::sendInfo($this->lng->txt('paya_updated_prices'));
805  $this->editPricesObject();
806 
807  return true;
808  }
809 
810  function editObjectObject($a_show_confirm = false)
811  {
812  if(!isset($_GET['pobject_id']))
813  {
814  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
815  $this->objectsObject();
816 
817  return true;
818  }
819 
820  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
821 
822  $this->__showButton('objects',$this->lng->txt('back'));
823  $this->__showButton('editObject',$this->lng->txt('paya_edit_details'));
824  $this->__showButton('editPrices',$this->lng->txt('paya_edit_prices'));
825  $this->tpl->setCurrentBlock('btn_cell');
826  $this->tpl->setVariable('BTN_LINK', $this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'edit'));
827  $this->tpl->setVariable('BTN_TXT', $this->lng->txt('pay_edit_abstract'));
828  $this->tpl->parseCurrentBlock();
829 
830  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_edit_objects.html','payment');
831 
832  $this->__initPaymentObject((int) $_GET['pobject_id']);
833 
834  if($a_show_confirm)
835  {
836  $this->tpl->setCurrentBlock("confirm_delete");
837  $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
838  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
839  $this->tpl->setVariable("CONFIRM_CMD",'performObjectDelete');
840  $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('confirm'));
841  $this->tpl->parseCurrentBlock();
842  }
843 
844  $this->tpl->setVariable("DETAILS_FORMACTION",$this->ctrl->getFormAction($this));
845 
846 
847  $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId());
848 
849  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$tmp_obj->getType().'_b.gif'));
850  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_'.$tmp_obj->getType()));
851  $this->tpl->setVariable("TITLE",$tmp_obj->getTitle());
852  $this->tpl->setVariable("DESCRIPTION",$tmp_obj->getDescription());
853  $this->tpl->setVariable("TXT_PATH",$this->lng->txt('path'));
854  $this->tpl->setVariable("PATH",$this->__getHTMLPath($this->pobject->getRefId()));
855  $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
856  $this->tpl->setVariable("VENDOR",$this->__showVendorSelector($this->pobject->getVendorId()));
857  $this->tpl->setVariable("TXT_COUNT_PURCHASER",$this->lng->txt('paya_count_purchaser'));
858  $this->tpl->setVariable("COUNT_PURCHASER",ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']));
859  $this->tpl->setVariable("TXT_STATUS",$this->lng->txt('status'));
860  $this->tpl->setVariable("STATUS",$this->__showStatusSelector());
861  $this->tpl->setVariable("TXT_PAY_METHOD",$this->lng->txt('paya_pay_method'));
862  $this->tpl->setVariable("PAY_METHOD",$this->__showPayMethodSelector());
863 
864  // topics
865  include_once 'Services/Payment/classes/class.ilShopTopics.php';
866  ilShopTopics::_getInstance()->read();
867  if (is_array($topics = ilShopTopics::_getInstance()->getTopics()) && count($topics))
868  {
869  $selectable_topics = array();
870  $selectable_topics[''] = $this->lng->txt('please_choose');
871  foreach ($topics as $topic)
872  {
873  $selectable_topics[$topic->getId()] = $topic->getTitle();
874  }
875 
876  $this->tpl->setVariable('TXT_TOPIC', $this->lng->txt('topic'));
877  $this->tpl->setVariable('TOPICS', ilUtil::formSelect(array($this->pobject->getTopicId()), 'topic_id', $selectable_topics, false, true));
878  }
879 
880  $this->tpl->setVariable("INPUT_CMD",'updateObjectDetails');
881  $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('save'));
882 
883  $this->tpl->setVariable("DELETE_CMD",'deleteObject');
884  $this->tpl->setVariable("DELETE_VALUE",$this->lng->txt('delete'));
885  }
886 
887 
888 
890  {
891  include_once './payment/classes/class.ilPaymentBookings.php';
892 
893  if(!$_GET['pobject_id'])
894  {
895  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
896 
897  $this->editObjectObject();
898  return true;
899  }
900  if(ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']))
901  {
902  ilUtil::sendInfo($this->lng->txt('paya_bookings_available'));
903  $this->editObjectObject();
904 
905  return false;
906  }
907  else
908  {
909  ilUtil::sendInfo($this->lng->txt('paya_sure_delete_object'));
910  $this->editObjectObject(true);
911 
912  return true;
913  }
914  }
915 
917  {
918  include_once './payment/classes/class.ilPaymentPrices.php';
919  include_once './payment/classes/class.ilPaymentBillVendor.php';
920 
921  if(!$_GET['pobject_id'])
922  {
923  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
924 
925  $this->objectsObject();
926  return true;
927  }
928  $this->__initPaymentObject((int) $_GET['pobject_id']);
929 
930  // delete object data
931  $this->pobject->delete();
932 
933  // delete payment prices
934  $price_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
935  $price_obj->deleteAllPrices();
936  unset($price_obj);
937 
938  $bv =& new ilPaymentBillVendor((int) $_GET['pobject_id']);
939  $bv->delete();
940  unset($bv);
941 
942  // delete bill vendor data if exists
943  ilUtil::sendInfo($this->lng->txt('paya_deleted_object'));
944 
945  $this->objectsObject();
946 
947  return true;
948  }
949 
950  function __getHTMLPath($a_ref_id)
951  {
952  global $tree;
953 
954  $path = $tree->getPathFull($a_ref_id);
955  unset($path[0]);
956 
957  foreach($path as $data)
958  {
959  $html .= $data['title'].' > ';
960  }
961  return substr($html,0,-2);
962  }
963 
964  function __showVendorSelector($a_selected = 0)
965  {
966  include_once './payment/classes/class.ilPaymentVendors.php';
967 
968  $vendors = array();
969 
970  $vendor_obj = new ilPaymentVendors();
971  $all_vendors = $vendor_obj->getVendors();
972  if (is_array($all_vendors))
973  {
974  foreach ($all_vendors as $vendor)
975  {
976  $vendors[] = $vendor["vendor_id"];
977  }
978  }
979 
980  foreach($vendors as $vendor)
981  {
982  $tmp_obj =& ilObjectFactory::getInstanceByObjId($vendor,false);
983 
984  $action[$vendor] = $tmp_obj->getFullname().' ['.$tmp_obj->getLogin().']';
985  }
986 
987  return ilUtil::formSelect($a_selected,'vendor',$action,false,true);
988  }
989 
991  {
992  $action = array();
993  $action[$this->pobject->STATUS_NOT_BUYABLE] = $this->lng->txt('paya_not_buyable');
994  $action[$this->pobject->STATUS_BUYABLE] = $this->lng->txt('paya_buyable');
995  $action[$this->pobject->STATUS_EXPIRES] = $this->lng->txt('paya_expires');
996 
997  return ilUtil::formSelect($this->pobject->getStatus(),'status',$action,false,true);
998  }
999 
1001  {
1002  include_once './payment/classes/class.ilPayMethods.php';
1003 
1004  $action = array();
1005 
1006  $action[$this->pobject->PAY_METHOD_NOT_SPECIFIED] = $this->lng->txt('paya_pay_method_not_specified');
1007  if(ilPayMethods::_enabled('pm_bill'))
1008  {
1009  $action[$this->pobject->PAY_METHOD_BILL] = $this->lng->txt('pays_bill');
1010  }
1011  if(ilPayMethods::_enabled('pm_bmf'))
1012  {
1013  $action[$this->pobject->PAY_METHOD_BMF] = $this->lng->txt('pays_bmf');
1014  }
1015  if(ilPayMethods::_enabled('pm_paypal'))
1016  {
1017  $action[$this->pobject->PAY_METHOD_PAYPAL] = $this->lng->txt('pays_paypal');
1018  }
1019 
1020 
1021  return ilUtil::formSelect($this->pobject->getPayMethod(),'pay_method',$action,false,true);
1022  }
1023 
1025  {
1026  unset($_SESSION["pay_statistics"]);
1027  unset($_POST["title_type"]);
1028  unset($_POST["title_value"]);
1029  unset($_POST["vendor"]);
1030  unset($_POST["pay_method"]);
1031 
1032  ilUtil::sendInfo($this->lng->txt('paya_filter_reseted'));
1033 
1034  return $this->objectsObject();
1035  }
1036 
1037  function objectsObject()
1038  {
1039  global $rbacsystem;
1040 
1041  // MINIMUM ACCESS LEVEL = 'read'
1042  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
1043  {
1044  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1045  }
1046 
1047  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_objects.html','payment');
1048 
1049  if ($_POST["updateView"] == 1)
1050  {
1051  $_SESSION["pay_objects"]["title_type"] = $_POST["title_type"];
1052  $_SESSION["pay_objects"]["title_value"] = $_POST["title_value"];
1053  $_SESSION["pay_objects"]["pay_method"] = $_POST["pay_method"];
1054  $_SESSION["pay_objects"]["vendor"] = $_POST["vendor"];
1055  }
1056 
1057  $this->__initPaymentObject();
1058  $this->lng->loadLanguageModule('search');
1059  $this->tpl->setVariable("TXT_FILTER",$this->lng->txt('pay_filter'));
1060  $this->tpl->setVariable("FORM_ACTION",$this->ctrl->getFormAction($this));
1061  $this->tpl->setVariable("TXT_TITLE",$this->lng->txt("title"));
1062  $this->tpl->setVariable("TXT_AND",$this->lng->txt('search_all_words'));
1063  $this->tpl->setVariable("TXT_OR",$this->lng->txt('search_any_word'));
1064  $this->tpl->setVariable("TXT_BILL",$this->lng->txt('pays_bill'));
1065  $this->tpl->setVariable("TXT_BMF",$this->lng->txt('pays_bmf'));
1066  $this->tpl->setVariable("TXT_PAYPAL",$this->lng->txt('pays_paypal'));
1067  $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
1068  $this->tpl->setVariable("TXT_PAYMENT",$this->lng->txt('payment_system'));
1069  $this->tpl->setVariable("TXT_UPDATE_VIEW",$this->lng->txt('pay_update_view'));
1070  $this->tpl->setVariable("TXT_RESET_FILTER",$this->lng->txt('pay_reset_filter'));
1071 
1072  $this->tpl->setVariable(($_SESSION["pay_objects"]["title_type"] != "" ? strtoupper($_SESSION["pay_objects"]["title_type"]) : "OR") . "_CHECKED", " checked");
1073  $this->tpl->setVariable("TITLE_VALUE", ilUtil::prepareFormOutput($_SESSION["pay_objects"]["title_value"], true));
1074  $this->tpl->setVariable("PAYMENT_" . $_SESSION["pay_objects"]["pay_method"], " selected");
1075  $this->tpl->setVariable("VENDOR", ilUtil::prepareFormOutput($_SESSION["pay_objects"]["vendor"], true));
1076 
1077  if(!count($objects = ilPaymentObject::_getAllObjectsData()))
1078  {
1079  ilUtil::sendInfo($this->lng->txt('paya_no_objects_assigned'));
1080 
1081  return true;
1082  }
1083 
1084  $counter = 0;
1085  foreach($objects as $data)
1086  {
1087  $tmp_obj =& ilObjectFactory::getInstanceByRefId($data['ref_id']);
1088  $f_result[$counter][] = $tmp_obj->getTitle();
1089 
1090 
1091  switch($data['status'])
1092  {
1093  case $this->pobject->STATUS_BUYABLE:
1094  $f_result[$counter][] = $this->lng->txt('paya_buyable');
1095  break;
1096 
1097  case $this->pobject->STATUS_NOT_BUYABLE:
1098  $f_result[$counter][] = $this->lng->txt('paya_not_buyable');
1099  break;
1100 
1101  case $this->pobject->STATUS_EXPIRES:
1102  $f_result[$counter][] = $this->lng->txt('paya_expires');
1103  break;
1104  }
1105  switch($data['pay_method'])
1106  {
1107  case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
1108  $f_result[$counter][] = $this->lng->txt('paya_pay_method_not_specified');
1109  break;
1110 
1111  case $this->pobject->PAY_METHOD_BILL:
1112  $f_result[$counter][] = $this->lng->txt('pays_bill');
1113  break;
1114 
1115  case $this->pobject->PAY_METHOD_BMF:
1116  $f_result[$counter][] = $this->lng->txt('pays_bmf');
1117  break;
1118 
1119  case $this->pobject->PAY_METHOD_PAYPAL:
1120  $f_result[$counter][] = $this->lng->txt('pays_paypal');
1121  break;
1122  }
1123  $tmp_user =& ilObjectFactory::getInstanceByObjId($data['vendor_id']);
1124  $f_result[$counter][] = $tmp_user->getFullname().' ['.$tmp_user->getLogin().']';
1125 
1126  // Get number of purchasers
1127 
1128  $f_result[$counter][] = ilPaymentBookings::_getCountBookingsByObject($data['pobject_id']);
1129 
1130 
1131  // edit link
1132  $this->ctrl->setParameter($this,"pobject_id",$data['pobject_id']);
1133  $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editObject")."\">".$this->lng->txt("edit")."</a></div>";
1134 
1135  $f_result[$counter][] = $link_change;
1136  unset($tmp_user);
1137  unset($tmp_obj);
1138 
1139  ++$counter;
1140  }
1141 
1142  $this->__showObjectsTable($f_result);
1143 
1144  return true;
1145  }
1146 
1147  function __showObjectsTable($a_result_set)
1148  {
1149  $tbl =& $this->initTableGUI();
1150  $tpl =& $tbl->getTemplateObject();
1151 
1152  // SET FORMAACTION
1153  $tpl->setCurrentBlock("tbl_form_header");
1154 
1155  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1156  $tpl->parseCurrentBlock();
1157 
1158  /*
1159  $tpl->setCurrentBlock("tbl_action_row");
1160  $tpl->setCurrentBlock("plain_buttons");
1161  $tpl->parseCurrentBlock();
1162 
1163  $tpl->setVariable("COLUMN_COUNTS",6);
1164  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1165 
1166  $tpl->setCurrentBlock("tbl_action_button");
1167  $tpl->setVariable("BTN_NAME","deleteTrustee");
1168  $tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
1169  $tpl->parseCurrentBlock();
1170  $tpl->setCurrentBlock("tbl_action_row");
1171  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
1172  $tpl->parseCurrentBlock();
1173  */
1174 
1175  $tbl->setTitle($this->lng->txt("objects"),"icon_pays.gif",$this->lng->txt("objects"));
1176  $tbl->setHeaderNames(array($this->lng->txt("title"),
1177  $this->lng->txt("status"),
1178  $this->lng->txt("paya_pay_method"),
1179  $this->lng->txt("paya_vendor"),
1180  $this->lng->txt("paya_count_purchaser"),
1181  ''));
1182  $header_params = $this->ctrl->getParameterArray($this,'objects');
1183  $tbl->setHeaderVars(array("title",
1184  "status",
1185  "pay_method",
1186  "vendor",
1187  "purchasers",
1188  "options"),$header_params);
1189  /*
1190  array("cmd" => "",
1191  "cmdClass" => "ilpaymentobjectgui",
1192  "cmdNode" => $_GET["cmdNode"]));
1193  */
1194  $tbl->setColumnWidth(array("15%","15%","15%","20%","20%"));
1195 
1196 # $this->setTableGUIBasicData($tbl,$a_result_set);
1197 
1198  $offset = $_GET["offset"];
1199  $order = $_GET["sort_by"];
1200  $direction = $_GET["sort_order"] ? $_GET['sort_order'] : 'desc';
1201 
1202  $tbl->setOrderColumn($order,'order_date');
1203  $tbl->setOrderDirection($direction);
1204  $tbl->setOffset($offset);
1205  $tbl->setLimit($_GET["limit"]);
1206  $tbl->setMaxCount(count($a_result_set));
1207  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1208  $tbl->setData($a_result_set);
1209 
1210  $tbl->render();
1211 
1212  $this->tpl->setVariable("OBJECTS_TABLE",$tbl->tpl->get());
1213 
1214  return true;
1215  }
1216 
1217  function __initPaymentObject($a_pobject_id = 0)
1218  {
1219  include_once './payment/classes/class.ilPaymentObject.php';
1220 
1221  $this->pobject =& new ilPaymentObject($this->user_obj,$a_pobject_id);
1222 
1223  return true;
1224  }
1225 
1226  function gatewayObject()
1227  {
1228  switch($_POST["action"])
1229  {
1230  case "deleteVendorsObject":
1231  $this->deleteVendors();
1232  break;
1233 
1234  case "editVendorObject":
1235  $this->editVendor();
1236  break;
1237 
1238  case "performEditVendorObject":
1239  $this->performEditVendorObject();
1240  break;
1241 
1242  default:
1243  $this->vendorsObject();
1244  break;
1245  }
1246  return true;
1247  }
1248 
1250  {
1251  unset($_SESSION["pay_statistics"]);
1252  unset($_POST["transaction_type"]);
1253  unset($_POST["transaction_value"]);
1254  unset($_POST["from"]["day"]);
1255  unset($_POST["from"]["month"]);
1256  unset($_POST["from"]["year"]);
1257  unset($_POST["til"]["day"]);
1258  unset($_POST["til"]["month"]);
1259  unset($_POST["til"]["year"]);
1260  unset($_POST["payed"]);
1261  unset($_POST["access"]);
1262  unset($_POST["customer"]);
1263  unset($_POST["pay_method"]);
1264  unset($_POST["updateView"]);
1265  ilUtil::sendInfo($this->lng->txt('paya_filter_reseted'));
1266 
1267  return $this->statisticObject();
1268  }
1269 
1270  function statisticObject()
1271  {
1272  global $rbacsystem;
1273 
1274  // MINIMUM ACCESS LEVEL = 'read'
1275  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
1276  {
1277  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1278  }
1279 
1280  $this->__showButton('showObjectSelector',$this->lng->txt('paya_add_customer'));
1281 
1282  if ($_POST["updateView"] == 1)
1283  {
1284  $_SESSION["pay_statistics"]["updateView"] = true;
1285  $_SESSION["pay_statistics"]["transaction_type"] = $_POST["transaction_type"];
1286  $_SESSION["pay_statistics"]["transaction_value"] = $_POST["transaction_value"];
1287  $_SESSION["pay_statistics"]["from"]["day"] = $_POST["from"]["day"];
1288  $_SESSION["pay_statistics"]["from"]["month"] = $_POST["from"]["month"];
1289  $_SESSION["pay_statistics"]["from"]["year"] = $_POST["from"]["year"];
1290  $_SESSION["pay_statistics"]["til"]["day"] = $_POST["til"]["day"];
1291  $_SESSION["pay_statistics"]["til"]["month"] = $_POST["til"]["month"];
1292  $_SESSION["pay_statistics"]["til"]["year"] = $_POST["til"]["year"];
1293  $_SESSION["pay_statistics"]["payed"] = $_POST["payed"];
1294  $_SESSION["pay_statistics"]["access"] = $_POST["access"];
1295  $_SESSION["pay_statistics"]["pay_method"] = $_POST["pay_method"];
1296  $_SESSION["pay_statistics"]["customer"] = $_POST["customer"];
1297  $_SESSION["pay_statistics"]["vendor"] = $_POST["vendor"];
1298  }
1299 
1300  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_statistic.html','payment');
1301 
1302  $this->tpl->setVariable("TXT_FILTER",$this->lng->txt('pay_filter'));
1303  $this->tpl->setVariable("FORM_ACTION",$this->ctrl->getFormAction($this));
1304  $this->tpl->setVariable("TXT_TRANSACTION",$this->lng->txt('paya_transaction'));
1305  $this->tpl->setVariable("TXT_STARTING",$this->lng->txt('pay_starting'));
1306  $this->tpl->setVariable("TXT_ENDING",$this->lng->txt('pay_ending'));
1307  $this->tpl->setVariable("TXT_PAYED",$this->lng->txt('paya_payed'));
1308  $this->tpl->setVariable("TXT_ALL",$this->lng->txt('pay_all'));
1309  $this->tpl->setVariable("TXT_YES",$this->lng->txt('yes'));
1310  $this->tpl->setVariable("TXT_NO",$this->lng->txt('no'));
1311  $this->tpl->setVariable("TXT_BILL",$this->lng->txt('pays_bill'));
1312  $this->tpl->setVariable("TXT_BMF",$this->lng->txt('pays_bmf'));
1313  $this->tpl->setVariable("TXT_PAYPAL",$this->lng->txt('pays_paypal'));
1314  $this->tpl->setVariable("TXT_PAYMENT",$this->lng->txt('payment_system'));
1315  $this->tpl->setVariable("TXT_CUSTOMER",$this->lng->txt('paya_customer'));
1316  $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
1317  $this->tpl->setVariable("TXT_ACCESS",$this->lng->txt('paya_access'));
1318  $this->tpl->setVariable("TXT_ORDER_DATE_FROM",$this->lng->txt('pay_order_date_from'));
1319  $this->tpl->setVariable("TXT_ORDER_DATE_TIL",$this->lng->txt('pay_order_date_til'));
1320  $this->tpl->setVariable("TXT_UPDATE_VIEW",$this->lng->txt('pay_update_view'));
1321  $this->tpl->setVariable("TXT_RESET_FILTER",$this->lng->txt('pay_reset_filter'));
1322 
1323  $this->tpl->setVariable("TRANSACTION_TYPE_" . $_SESSION["pay_statistics"]["transaction_type"], " selected");
1324  $this->tpl->setVariable("TRANSACTION_VALUE", ilUtil::prepareFormOutput($_SESSION["pay_statistics"]["transaction_value"], true));
1325  $this->tpl->setVariable("PAYED_" . $_SESSION["pay_statistics"]["payed"], " selected");
1326  $this->tpl->setVariable("ACCESS_" . $_SESSION["pay_statistics"]["access"], " selected");
1327  $this->tpl->setVariable("PAYMENT_" . $_SESSION["pay_statistics"]["pay_method"], " selected");
1328  $this->tpl->setVariable("CUSTOMER", ilUtil::prepareFormOutput($_SESSION["pay_statistics"]["customer"], true));
1329  $this->tpl->setVariable("VENDOR", ilUtil::prepareFormOutput($_SESSION["pay_statistics"]["vendor"], true));
1330 
1331  for ($i = 1; $i <= 31; $i++)
1332  {
1333  $this->tpl->setCurrentBlock("loop_from_day");
1334  $this->tpl->setVariable("LOOP_FROM_DAY", $i < 10 ? "0" . $i : $i);
1335  if ($_SESSION["pay_statistics"]["from"]["day"] == $i)
1336  {
1337  $this->tpl->setVariable("LOOP_FROM_DAY_SELECTED", " selected");
1338  }
1339  $this->tpl->parseCurrentBlock("loop_from_day");
1340  $this->tpl->setCurrentBlock("loop_til_day");
1341  $this->tpl->setVariable("LOOP_TIL_DAY", $i < 10 ? "0" . $i : $i);
1342  if ($_SESSION["pay_statistics"]["til"]["day"] == $i)
1343  {
1344  $this->tpl->setVariable("LOOP_TIL_DAY_SELECTED", " selected");
1345  }
1346  $this->tpl->parseCurrentBlock("loop_til_day");
1347  }
1348  for ($i = 1; $i <= 12; $i++)
1349  {
1350  $this->tpl->setCurrentBlock("loop_from_month");
1351  $this->tpl->setVariable("LOOP_FROM_MONTH", $i < 10 ? "0" . $i : $i);
1352  if ($_SESSION["pay_statistics"]["from"]["month"] == $i)
1353  {
1354  $this->tpl->setVariable("LOOP_FROM_MONTH_SELECTED", " selected");
1355  }
1356  $this->tpl->parseCurrentBlock("loop_from_month");
1357  $this->tpl->setCurrentBlock("loop_til_month");
1358  $this->tpl->setVariable("LOOP_TIL_MONTH", $i < 10 ? "0" . $i : $i);
1359  if ($_SESSION["pay_statistics"]["til"]["month"] == $i)
1360  {
1361  $this->tpl->setVariable("LOOP_TIL_MONTH_SELECTED", " selected");
1362  }
1363  $this->tpl->parseCurrentBlock("loop_til_month");
1364  }
1365  for ($i = 2004; $i <= date("Y"); $i++)
1366  {
1367  $this->tpl->setCurrentBlock("loop_from_year");
1368  $this->tpl->setVariable("LOOP_FROM_YEAR", $i);
1369  if ($_SESSION["pay_statistics"]["from"]["year"] == $i)
1370  {
1371  $this->tpl->setVariable("LOOP_FROM_YEAR_SELECTED", " selected");
1372  }
1373  $this->tpl->parseCurrentBlock("loop_from_year");
1374  $this->tpl->setCurrentBlock("loop_til_year");
1375  $this->tpl->setVariable("LOOP_TIL_YEAR", $i);
1376  if ($_SESSION["pay_statistics"]["til"]["year"] == $i)
1377  {
1378  $this->tpl->setVariable("LOOP_TIL_YEAR_SELECTED", " selected");
1379  }
1380  $this->tpl->parseCurrentBlock("loop_til_year");
1381  }
1382 
1383  if(!$_SESSION['pay_statistics']['updateView'])
1384  {
1385  $this->tpl->setVariable('FILTER_MESSAGE', $this->lng->txt('statistics_filter_advice'));
1386  return true;
1387  }
1388 
1389  $this->__initBookingObject();
1390 
1391  if(!count($bookings = $this->booking_obj->getBookings()))
1392  {
1393  ilUtil::sendInfo($this->lng->txt('paya_no_bookings'));
1394 
1395  return true;
1396  }
1397 # else
1398 # {
1399 # $this->__showButton('exportVendors',$this->lng->txt('excel_export'));
1400 # }
1401  $img_change = "<img src=\"".ilUtil::getImagePath("edit.gif")."\" alt=\"".
1402  $this->lng->txt("edit")."\" title=\"".$this->lng->txt("edit").
1403  "\" border=\"0\" vspace=\"0\"/>";
1404 
1405  include_once 'Services/User/classes/class.ilObjUser.php';
1406  $object_title_cache = array();
1407  $user_title_cache = array();
1408 
1409  $counter = 0;
1410  foreach($bookings as $booking)
1411  {
1412  if(array_key_exists($booking['ref_id'], $object_title_cache))
1413  {
1414  $tmp_obj = $object_title_cache[$booking['ref_id']];
1415  }
1416  else
1417  {
1418  $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($booking['ref_id']));
1419  $object_title_cache[$booking['ref_id']] = $tmp_obj;
1420  }
1421  if(array_key_exists($booking['b_vendor_id'], $user_title_cache))
1422  {
1423  $tmp_vendor = $user_title_cache[$booking['b_vendor_id']];
1424  }
1425  else
1426  {
1427  $tmp_vendor = ilObjUser::_lookupLogin($booking['b_vendor_id']);
1428  $user_title_cache[$booking['b_vendor_id']] = $tmp_vendor;
1429  }
1430  if(array_key_exists($booking['customer_id'], $user_title_cache))
1431  {
1432  $tmp_purchaser = $user_title_cache[$booking['customer_id']];
1433  }
1434  else
1435  {
1436  $tmp_purchaser = ilObjUser::_lookupLogin($booking['customer_id']);
1437  $user_title_cache[$booking['customer_id']] = $tmp_purchaser;
1438  }
1439 
1440  $transaction = $booking['transaction_extern'];
1441  switch ($booking['b_pay_method'])
1442  {
1443  case $this->pobject->PAY_METHOD_BILL :
1444  $transaction .= " (" . $this->lng->txt("pays_bill") . ")";
1445  break;
1446  case $this->pobject->PAY_METHOD_BMF :
1447  $transaction .= " (" . $this->lng->txt("pays_bmf") . ")";
1448  break;
1449  case $this->pobject->PAY_METHOD_PAYPAL :
1450  $transaction .= " (" . $this->lng->txt("pays_paypal") . ")";
1451  break;
1452  }
1453  $f_result[$counter][] = $transaction;
1454  $f_result[$counter][] = ($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted'));
1455  $f_result[$counter][] = ($tmp_vendor != '' ? '['.$tmp_vendor.']' : $this->lng->txt('user_deleted'));
1456  $f_result[$counter][] = ($tmp_purchaser != '' ? '['.$tmp_purchaser.']' : $this->lng->txt('user_deleted'));
1457  $f_result[$counter][] = date("Y-m-d H:i:s", $booking['order_date']);
1458  $f_result[$counter][] = $booking['duration'];
1459  $f_result[$counter][] = $booking['price'];
1460  $f_result[$counter][] = ($booking['discount'] != '' ? $booking['discount'] : '&nbsp;');
1461 
1462  $payed_access = $booking['payed'] ?
1463  $this->lng->txt('yes') :
1464  $this->lng->txt('no');
1465 
1466  $payed_access .= '/';
1467  $payed_access .= $booking['access'] ?
1468  $this->lng->txt('yes') :
1469  $this->lng->txt('no');
1470 
1471  $f_result[$counter][] = $payed_access;
1472 
1473  $this->ctrl->setParameter($this,"booking_id",$booking['booking_id']);
1474 # $link_change = "<a href=\"".$this->ctrl->getLinkTarget($this,"editStatistic")."\"> ".
1475 # $img_change."</a>";
1476  $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editStatistic")."\">".$this->lng->txt("edit")."</a></div>";
1477 
1478  $f_result[$counter][] = $link_change;
1479 
1480  unset($tmp_obj);
1481  unset($tmp_vendor);
1482  unset($tmp_purchaser);
1483 
1484  ++$counter;
1485  }
1486  return $this->__showStatisticTable($f_result);
1487  }
1488 
1489  function editStatisticObject($a_show_confirm_delete = false)
1490  {
1491  if(!isset($_GET['booking_id']))
1492  {
1493  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
1494  $this->showStatistics();
1495 
1496  return true;
1497  }
1498 
1499  $this->__showButton('statistic',$this->lng->txt('back'));
1500 
1501  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_edit_statistic.html','payment');
1502  $this->ctrl->setParameter($this,'booking_id',(int) $_GET['booking_id']);
1503 
1504  // confirm delete
1505  if($a_show_confirm_delete)
1506  {
1507  $this->tpl->setCurrentBlock("confirm_delete");
1508  $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
1509  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
1510  $this->tpl->setVariable("CONFIRM_CMD",'performDelete');
1511  $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('confirm'));
1512  $this->tpl->parseCurrentBlock();
1513  }
1514 
1515 
1516  $this->__initBookingObject();
1517  $bookings = $this->booking_obj->getBookings();
1518  $booking = $bookings[(int) $_GET['booking_id']];
1519 
1520  // get customer_obj
1521  $tmp_user = ilObjectFactory::getInstanceByObjId($booking['customer_id'], false);
1522 
1523  $this->tpl->setVariable("STAT_FORMACTION",$this->ctrl->getFormAction($this));
1524  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_usr.gif'));
1525  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
1526  if(is_object($tmp_user))
1527  {
1528  $this->tpl->setVariable('TITLE', $tmp_user->getFullname().' ['.$tmp_user->getLogin().']');
1529  }
1530  else
1531  {
1532  $this->tpl->setVariable('TITLE', $this->lng->txt('user_deleted'));
1533  }
1534 
1535  // TXT
1536  $pObj = new ilPaymentObject($this->user_obj, $booking["pobject_id"]);
1537  $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($pObj->getRefId()));
1538 
1539  $this->tpl->setVariable("TXT_OBJECT",$this->lng->txt('title'));
1540  $this->tpl->setVariable("OBJECT", ($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted')));
1541 
1542  $this->tpl->setVariable("TXT_TRANSACTION",$this->lng->txt('paya_transaction'));
1543  $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
1544  $this->tpl->setVariable("TXT_PAY_METHOD",$this->lng->txt('paya_pay_method'));
1545  $this->tpl->setVariable("TXT_ORDER_DATE",$this->lng->txt('paya_order_date'));
1546  $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('duration'));
1547  $this->tpl->setVariable("TXT_PRICE",$this->lng->txt('price_a'));
1548  $this->tpl->setVariable("TXT_PAYED",$this->lng->txt('paya_payed'));
1549  $this->tpl->setVariable("TXT_ACCESS",$this->lng->txt('paya_access'));
1550 
1551  $this->tpl->setVariable("TRANSACTION",$booking['transaction']);
1552 
1553  $tmp_vendor = ilObjectFactory::getInstanceByObjId($booking['b_vendor_id'], false);
1554  if(is_object($tmp_vendor))
1555  {
1556  $this->tpl->setVariable('VENDOR', $tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']');
1557  }
1558  else
1559  {
1560  $this->tpl->setVariable('VENDOR', $this->lng->txt('user_deleted'));
1561  }
1562 
1563  switch($booking['b_pay_method'])
1564  {
1565  case $this->pobject->PAY_METHOD_BILL:
1566  $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('pays_bill'));
1567  break;
1568 
1569  case $this->pobject->PAY_METHOD_BMF:
1570  $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('pays_bmf'));
1571  break;
1572 
1573  case $this->pobject->PAY_METHOD_PAYPAL:
1574  $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('pays_paypal'));
1575  break;
1576 
1577  default:
1578  $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('paya_pay_method_not_specified'));
1579  break;
1580  }
1581  $this->tpl->setVariable("ORDER_DATE",date('Y m d H:i:s',$booking['order_date']));
1582  $this->tpl->setVariable("DURATION",$booking['duration'].' '.$this->lng->txt('paya_months'));
1583  $this->tpl->setVariable("PRICE",$booking['price']);
1584 
1585  $yes_no = array(0 => $this->lng->txt('no'),1 => $this->lng->txt('yes'));
1586 
1587  $this->tpl->setVariable("PAYED",ilUtil::formSelect((int) $booking['payed'],'payed',$yes_no,false,true));
1588  $this->tpl->setVariable("ACCESS",ilUtil::formSelect((int) $booking['access'],'access',$yes_no,false,true));
1589 
1590  // buttons
1591  $this->tpl->setVariable("INPUT_CMD",'updateStatistic');
1592  $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('save'));
1593 
1594  $this->tpl->setVariable("DELETE_CMD",'deleteStatistic');
1595  $this->tpl->setVariable("DELETE_VALUE",$this->lng->txt('delete'));
1596  }
1598  {
1599  if(!isset($_GET['booking_id']))
1600  {
1601  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
1602  $this->statisticObject();
1603 
1604  return true;
1605  }
1606  $this->__initBookingObject();
1607 
1608  $this->booking_obj->setBookingId((int) $_GET['booking_id']);
1609  $this->booking_obj->setAccess((int) $_POST['access']);
1610  $this->booking_obj->setPayed((int) $_POST['payed']);
1611 
1612  if($this->booking_obj->update())
1613  {
1614  ilUtil::sendInfo($this->lng->txt('paya_updated_booking'));
1615 
1616  $this->statisticObject();
1617  return true;
1618  }
1619  else
1620  {
1621  ilUtil::sendInfo($this->lng->txt('paya_error_update_booking'));
1622 
1623  $this->statisticObject();
1624 
1625  return true;
1626  }
1627  }
1628 
1630  {
1631  if(!isset($_GET['booking_id']))
1632  {
1633  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
1634  $this->statisticObject();
1635 
1636  return true;
1637  }
1638  ilUtil::sendInfo($this->lng->txt('paya_sure_delete_stat'));
1639 
1640  $this->editStatisticObject(true);
1641 
1642  return true;
1643  }
1645  {
1646  if(!isset($_GET['booking_id']))
1647  {
1648  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
1649  $this->statisticObject();
1650 
1651  return true;
1652  }
1653 
1654  $this->__initBookingObject();
1655  $this->booking_obj->setBookingId((int) $_GET['booking_id']);
1656  if(!$this->booking_obj->delete())
1657  {
1658  die('Error deleting booking');
1659  }
1660  ilUtil::sendInfo($this->lng->txt('pay_deleted_booking'));
1661 
1662  $this->statisticObject();
1663 
1664  return true;
1665  }
1666 
1667  function getAdminTabs(&$tabs_gui)
1668  {
1669  $this->getTabs($tabs_gui);
1670  }
1671 
1677  function getTabs(&$tabs_gui)
1678  {
1679  global $rbacsystem;
1680 
1681  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
1682  {
1683  $tabs_gui->addTarget("settings",
1684  $this->ctrl->getLinkTarget($this, "generalSettings"), array("generalSettings","", "view"), "", "");
1685 
1686  $tabs_gui->addTarget("statistic",
1687  $this->ctrl->getLinkTarget($this, "statistic"), "statistic", "", "");
1688 
1689  $tabs_gui->addTarget("objects",
1690  $this->ctrl->getLinkTarget($this, "objects"), "objects", "", "");
1691 
1692  $tabs_gui->addTarget("vendors",
1693  $this->ctrl->getLinkTarget($this, "vendors"), "vendors", "", "");
1694 
1695  $tabs_gui->addTarget("pay_methods",
1696  $this->ctrl->getLinkTarget($this, "payMethods"), "payMethods", "", "");
1697 
1698  $tabs_gui->addTarget('topics',
1699  $this->ctrl->getLinkTargetByClass('ilshoptopicsgui', ''), 'payment_topics', '', '');
1700  }
1701 
1702  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
1703  {
1704  $tabs_gui->addTarget("perm_settings",
1705  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1706  }
1707  }
1708 
1709  function generalSettingsObject($a_show_confirm = false)
1710  {
1711  global $rbacsystem;
1712 
1713  // MINIMUM ACCESS LEVEL = 'read'
1714  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
1715  {
1716  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1717  }
1718 
1719  include_once './payment/classes/class.ilGeneralSettings.php';
1720 
1721  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_general_settings.html",'payment');
1722 
1723  $genSet = new ilGeneralSettings();
1724  $genSetData = $genSet->getAll();
1725 
1726  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1727 
1728  $form = new ilPropertyFormGUI();
1729  $form->setFormAction($this->ctrl->getFormAction($this, "saveGeneralSettings"));
1730  $form->setTitle($this->lng->txt('pays_general_settings'));
1731 
1732  $form->addCommandButton('saveGeneralSettings',$this->lng->txt('save'));
1733 
1734  // enable webshop
1735  $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_enable_shop'), 'shop_enabled');
1736  $formItem->setChecked((int)$genSetData['shop_enabled']);
1737  $formItem->setInfo($this->lng->txt('pay_enable_shop_info'));
1738  $form->addItem($formItem);
1739 
1740  $formItem = new ilTextInputGUI($this->lng->txt("pays_currency_unit"), "currency_unit");
1741  $formItem->setSize(5);
1742  $formItem->setValue($this->error != "" && isset($_POST['currency_unit'])
1743  ? ilUtil::prepareFormOutput($_POST['currency_unit'],true)
1744  : ilUtil::prepareFormOutput($genSetData['currency_unit'],true));
1745  $form->addItem($formItem);
1746 
1747  $formItem = new ilTextInputGUI($this->lng->txt("pays_currency_subunit"), "currency_subunit");
1748  $formItem->setSize(5);
1749  $formItem->setValue($this->error != "" && isset($_POST['currency_subunit'])
1750  ? ilUtil::prepareFormOutput($_POST['currency_subunit'],true)
1751  : ilUtil::prepareFormOutput($genSetData['currency_subunit'],true));
1752  $form->addItem($formItem);
1753 
1754  $formItem = new ilTextAreaInputGUI($this->lng->txt("pays_address"), "address");
1755  $formItem->setRows(7);
1756  $formItem->setCols(35);
1757  $formItem->setValue($this->error != "" && isset($_POST['address'])
1758  ? ilUtil::prepareFormOutput($_POST['address'],true)
1759  : ilUtil::prepareFormOutput($genSetData['address'],true));
1760  $form->addItem($formItem);
1761 
1762  $formItem = new ilTextAreaInputGUI($this->lng->txt("pays_bank_data"), "bank_data");
1763  $formItem->setRows(7);
1764  $formItem->setCols(35);
1765  $formItem->setValue($this->error != "" && isset($_POST['bank_data'])
1766  ? ilUtil::prepareFormOutput($_POST['bank_data'],true)
1767  : ilUtil::prepareFormOutput($genSetData['bank_data'],true));
1768  $form->addItem($formItem);
1769 
1770  $formItem = new ilTextAreaInputGUI($this->lng->txt("pays_add_info"), "add_info");
1771  $formItem->setRows(7);
1772  $formItem->setCols(35);
1773  $formItem->setValue($this->error != "" && isset($_POST['add_info'])
1774  ? ilUtil::prepareFormOutput($_POST['add_info'],true)
1775  : ilUtil::prepareFormOutput($genSetData['add_info'],true));
1776  $form->addItem($formItem);
1777 
1778  $formItem = new ilTextInputGUI($this->lng->txt("pays_vat_rate"), "vat_rate");
1779  $formItem->setSize(5);
1780  $formItem->setValue($this->error != "" && isset($_POST['vat_rate'])
1781  ? ilUtil::prepareFormOutput($_POST['vat_rate'],true)
1782  : ilUtil::prepareFormOutput($genSetData['vat_rate'],true));
1783  $form->addItem($formItem);
1784 
1785  $formItem = new ilTextInputGUI($this->lng->txt("pays_pdf_path"), "pdf_path");
1786  $formItem->setValue($this->error != "" && isset($_POST['pdf_path'])
1787  ? ilUtil::prepareFormOutput($_POST['pdf_path'],true)
1788  : ilUtil::prepareFormOutput($genSetData['pdf_path'],true));
1789  $form->addItem($formItem);
1790 
1791  // default sorting type
1792  $formItem = new ilSelectInputGUI($this->lng->txt('pay_topics_default_sorting_type'), 'topics_sorting_type');
1793  $formItem->setValue($genSetData['topics_sorting_type']);
1794  $options = array(
1795  1 => $this->lng->txt('pay_topics_sort_by_title'),
1796  2 => $this->lng->txt('pay_topics_sort_by_date'),
1797  3 => $this->lng->txt('pay_topics_sort_manually')
1798  );
1799  $formItem->setOptions($options);
1800  $form->addItem($formItem);
1801 
1802  // default sorting direction
1803  $formItem = new ilSelectInputGUI($this->lng->txt('pay_topics_default_sorting_direction'), 'topics_sorting_direction');
1804  $formItem->setValue($genSetData['topics_sorting_direction']);
1805  $options = array(
1806  'asc' => $this->lng->txt('sort_asc'),
1807  'desc' => $this->lng->txt('sort_desc'),
1808  );
1809  $formItem->setOptions($options);
1810  $form->addItem($formItem);
1811 
1812  // custom sorting
1813  $formItem = new ilCheckboxInputGUI($this->lng->txt('pay_topics_allow_custom_sorting'), 'topics_allow_custom_sorting');
1814  $formItem->setChecked((int)$genSetData['topics_allow_custom_sorting']);
1815  $formItem->setInfo($this->lng->txt('pay_topics_allow_custom_sorting_info'));
1816  $form->addItem($formItem);
1817 
1818  // max hits
1819  $formItem = new ilSelectInputGUI($this->lng->txt('pay_max_hits'), 'max_hits');
1820  $formItem->setValue($genSetData['max_hits']);
1821  $options = array();
1822  for($i = 10; $i <= 100; $i += 10)
1823  {
1824  $options[$i] = $i;
1825  }
1826  $formItem->setOptions($options);
1827  $formItem->setInfo($this->lng->txt('pay_max_hits_info'));
1828  $form->addItem($formItem);
1829 
1830  $this->tpl->setVariable('GENERAL_SETTINGS',$form->getHTML());
1831  }
1832 
1834  {
1835  global $rbacsystem;
1836 
1837  // MINIMUM ACCESS LEVEL = 'read'
1838  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
1839  {
1840  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1841  }
1842 
1843  include_once './payment/classes/class.ilGeneralSettings.php';
1844 
1845  $genSet = new ilGeneralSettings();
1846 
1847  if ($_POST["currency_unit"] == "" ||
1848  $_POST["currency_subunit"] == "" ||
1849  $_POST["address"] == "" ||
1850  $_POST["bank_data"] == "" ||
1851  $_POST["pdf_path"] == "")
1852  {
1853  $this->error = $this->lng->txt('pays_general_settings_not_valid');
1854  ilUtil::sendInfo($this->error);
1855  $this->generalSettingsObject();
1856  return;
1857  }
1858 
1859  $genSet->clearAll();
1860  $values = array(
1861  "currency_unit" => ilUtil::stripSlashes($_POST['currency_unit']),
1862  "currency_subunit" => ilUtil::stripSlashes($_POST['currency_subunit']),
1863  "address" => ilUtil::stripSlashes($_POST['address']),
1864  "bank_data" => ilUtil::stripSlashes($_POST['bank_data']),
1865  "add_info" => ilUtil::stripSlashes($_POST['add_info']),
1866  "vat_rate" => (float) str_replace(",", ".", ilUtil::stripSlashes($_POST['vat_rate'])),
1867  "pdf_path" => ilUtil::stripSlashes($_POST['pdf_path']),
1868  "topics_allow_custom_sorting" => ilUtil::stripSlashes($_POST['topics_allow_custom_sorting']),
1869  "topics_sorting_type" => ilUtil::stripSlashes($_POST['topics_sorting_type']),
1870  "topics_sorting_direction" => ilUtil::stripSlashes($_POST['topics_sorting_direction']),
1871  "max_hits" => ilUtil::stripSlashes($_POST['max_hits']),
1872  "shop_enabled" => ilUtil::stripSlashes($_POST['shop_enabled'])
1873  );
1874  $genSet->setAll($values);
1875  $this->generalSettingsObject();
1876 
1877  ilUtil::sendInfo($this->lng->txt('pays_updated_general_settings'));
1878 
1879  return true;
1880  }
1881 
1882  function paypalSettingsObject($a_show_confirm = false)
1883  {
1884  global $rbacsystem;
1885 
1886  // MINIMUM ACCESS LEVEL = 'read'
1887  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
1888  {
1889  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1890  }
1891 
1892  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1893  include_once './payment/classes/class.ilPaypalSettings.php';
1894 
1895  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_paypal_settings.html",'payment');
1896 
1897  $ppSet = ilPaypalSettings::getInstance();
1898 
1899  $form = new ilPropertyFormGUI();
1900  $form->setFormAction($this->ctrl->getFormAction($this, "savePaypalSettings"));
1901  $form->setTitle($this->lng->txt('pays_paypal_settings'));
1902 
1903  $form->addCommandButton('savePaypalSettings',$this->lng->txt('save'));
1904 
1905  $formItem = new ilTextInputGUI($this->lng->txt("pays_server_host"), "server_host");
1906  $formItem->setValue($ppSet->getServerHost());
1907  $form->addItem($formItem);
1908 
1909  $formItem = new ilTextInputGUI($this->lng->txt("pays_server_path"), "server_path");
1910  $formItem->setValue($ppSet->getServerPath());
1911  $form->addItem($formItem);
1912 
1913  $formItem = new ilTextInputGUI($this->lng->txt("pays_email_vendor"), "vendor");
1914  $formItem->setValue($ppSet->getVendor());
1915  $form->addItem($formItem);
1916 
1917  $formItem = new ilTextInputGUI($this->lng->txt("pays_auth_token"), "auth_token");
1918  $formItem->setValue($ppSet->getAuthToken());
1919  $form->addItem($formItem);
1920 
1921  $formItem = new ilTextInputGUI($this->lng->txt("pays_page_style"), "page_style");
1922  $formItem->setValue($ppSet->getPageStyle());
1923  $form->addItem($formItem);
1924 
1925  $this->tpl->setVariable('PAYPAL_SETTINGS',$form->getHTML());
1926  }
1927 
1929  {
1930  include_once './payment/classes/class.ilPaypalSettings.php';
1931 
1932  global $rbacsystem;
1933 
1934  // MINIMUM ACCESS LEVEL = 'read'
1935  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
1936  {
1937  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1938  }
1939 
1940  $ppSet = ilPaypalSettings::getInstance();
1941 
1942  $ppSet->setServerHost(ilUtil::stripSlashes($_POST["server_host"]));
1943  $ppSet->setServerPath(ilUtil::stripSlashes($_POST["server_path"]));
1944  $ppSet->setVendor(ilUtil::stripSlashes($_POST["vendor"]));
1945  $ppSet->setAuthToken(ilUtil::stripSlashes($_POST["auth_token"]));
1946  $ppSet->setPageStyle(ilUtil::stripSlashes($_POST["page_style"]));
1947  $ppSet->setSsl(ilUtil::stripSlashes($_POST["ssl"]));
1948 
1949  if ($_POST["server_host"] == "" ||
1950  $_POST["server_path"] == "" ||
1951  $_POST["vendor"] == "" ||
1952  $_POST["auth_token"] == "")
1953  {
1954  $this->error = $this->lng->txt('pays_paypal_settings_not_valid');
1955  ilUtil::sendInfo($this->error);
1956  $this->paypalSettingsObject();
1957  return;
1958  }
1959 
1960  $ppSet->save();
1961 
1962  $this->paypalSettingsObject();
1963 
1964  ilUtil::sendInfo($this->lng->txt('pays_updated_paypal_settings'));
1965 
1966  return true;
1967  }
1968 
1969  function vendorsObject($a_show_confirm = false)
1970  {
1971  include_once './payment/classes/class.ilPaymentBookings.php';
1972 
1973  global $rbacsystem;
1974 
1975  // MINIMUM ACCESS LEVEL = 'read'
1976  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
1977  {
1978  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1979  }
1980 
1981  $_SESSION['pays_vendor'] = is_array($_SESSION['pays_vendor']) ? $_SESSION['pays_vendor'] : array();
1982 
1983 
1984  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_vendors.html",'payment');
1985 
1986  $this->__showButton('searchUser',$this->lng->txt('search_user'));
1987 
1988  $this->object->initPaymentVendorsObject();
1989  if(!count($vendors = $this->object->payment_vendors_obj->getVendors()))
1990  {
1991  ilUtil::sendInfo($this->lng->txt('pay_no_vendors_created'));
1992  }
1993 # else
1994 # {
1995 # $this->__showButton('exportVendors',$this->lng->txt('excel_export'));
1996 # }
1997 
1998 
1999 
2000  if($a_show_confirm)
2001  {
2002  $this->tpl->setCurrentBlock("confirm_delete");
2003  $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
2004  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
2005  $this->tpl->setVariable("CONFIRM_CMD",'performDeleteVendors');
2006  $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('delete'));
2007  $this->tpl->parseCurrentBlock();
2008  }
2009 
2010  $counter = 0;
2011  $f_result = array();
2012  foreach($vendors as $vendor)
2013  {
2014  // GET USER OBJ
2015  if($tmp_obj = ilObjectFactory::getInstanceByObjId($vendor['vendor_id'],false))
2016  {
2017  $f_result[$counter][] = ilUtil::formCheckbox(in_array($vendor['vendor_id'],$_SESSION['pays_vendor']) ? 1 : 0,
2018  "vendor[]",
2019  $vendor['vendor_id']);
2020  $f_result[$counter][] = $tmp_obj->getLogin();
2021  $f_result[$counter][] = $vendor['cost_center'];
2022  $f_result[$counter][] = ilPaymentBookings::_getCountBookingsByVendor($vendor['vendor_id']);
2023 
2024  unset($tmp_obj);
2025  ++$counter;
2026  }
2027  } // END VENDORS TABLE
2028  $this->__showVendorsTable($f_result);
2029 
2030  return true;
2031  }
2032 
2034  {
2035  include_once './payment/classes/class.ilPaymentExcelWriterAdapter.php';
2036 
2037  $pewa =& new ilPaymentExcelWriterAdapter('payment_vendors.xls');
2038 
2039  // add/fill worksheet
2040  $this->addVendorWorksheet($pewa);
2041  $this->addStatisticWorksheet($pewa);
2042 
2043  // HEADER SENT
2044 
2045  $workbook =& $pewa->getWorkbook();
2046  $workbook->close();
2047  }
2048 
2049  function addStatisticWorksheet(&$pewa)
2050  {
2051  include_once './classes/class.ilExcelUtils.php';
2052  include_once './payment/classes/class.ilPaymentVendors.php';
2053 
2054  $this->__initBookingObject();
2055 
2056  if(!count($bookings = $this->booking_obj->getBookings()))
2057  {
2058  return false;
2059  }
2060 
2061  $workbook =& $pewa->getWorkbook();
2062  $worksheet =& $workbook->addWorksheet(utf8_decode($this->lng->txt('paya_statistic')));
2063 
2064  $worksheet->mergeCells(0,0,0,8);
2065  $worksheet->setColumn(0,0,16);
2066  $worksheet->setColumn(0,1,32);
2067  $worksheet->setColumn(0,2,32);
2068  $worksheet->setColumn(0,3,16);
2069  $worksheet->setColumn(0,4,16);
2070  $worksheet->setColumn(0,5,16);
2071  $worksheet->setColumn(0,6,24);
2072  $worksheet->setColumn(0,7,8);
2073  $worksheet->setColumn(0,8,12);
2074  $worksheet->setColumn(0,9,16);
2075 
2076  $title = $this->lng->txt('paya_statistic');
2077  $title .= ' '.$this->lng->txt('as_of');
2078  $title .= strftime('%Y-%m-%d %R',time());
2079 
2080  $worksheet->writeString(0,0,$title,$pewa->getFormatTitle());
2081 
2082  $worksheet->writeString(1,0,ilExcelUtils::_convert_text($this->lng->txt('payment_system')),$pewa->getFormatHeader());
2083  $worksheet->writeString(1,1,ilExcelUtils::_convert_text($this->lng->txt('paya_transaction')),$pewa->getFormatHeader());
2084  $worksheet->writeString(1,2,ilExcelUtils::_convert_text($this->lng->txt('title')),$pewa->getFormatHeader());
2085  $worksheet->writeString(1,3,ilExcelUtils::_convert_text($this->lng->txt('paya_vendor')),$pewa->getFormatHeader());
2086  $worksheet->writeString(1,4,ilExcelUtils::_convert_text($this->lng->txt('pays_cost_center')),$pewa->getFormatHeader());
2087  $worksheet->writeString(1,5,ilExcelUtils::_convert_text($this->lng->txt('paya_customer')),$pewa->getFormatHeader());
2088  $worksheet->writeString(1,6,ilExcelUtils::_convert_text($this->lng->txt('paya_order_date')),$pewa->getFormatHeader());
2089  $worksheet->writeString(1,7,ilExcelUtils::_convert_text($this->lng->txt('duration')),$pewa->getFormatHeader());
2090  $worksheet->writeString(1,8,ilExcelUtils::_convert_text($this->lng->txt('price_a')),$pewa->getFormatHeader());
2091  $worksheet->writeString(1,9,ilExcelUtils::_convert_text($this->lng->txt('paya_payed_access')),$pewa->getFormatHeader());
2092 
2093  include_once 'Services/User/classes/class.ilObjUser.php';
2094  $object_title_cache = array();
2095  $user_title_cache = array();
2096 
2097  $counter = 2;
2098  foreach($bookings as $booking)
2099  {
2100  if(array_key_exists($booking['ref_id'], $object_title_cache))
2101  {
2102  $tmp_obj = $object_title_cache[$booking['ref_id']];
2103  }
2104  else
2105  {
2106  $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($booking['ref_id']));
2107  $object_title_cache[$booking['ref_id']] = $tmp_obj;
2108  }
2109  if(array_key_exists($booking['b_vendor_id'], $user_title_cache))
2110  {
2111  $tmp_vendor = $user_title_cache[$booking['b_vendor_id']];
2112  }
2113  else
2114  {
2115  $tmp_vendor = ilObjUser::_lookupLogin($booking['b_vendor_id']);
2116  $user_title_cache[$booking['b_vendor_id']] = $tmp_vendor;
2117  }
2118  if(array_key_exists($booking['customer_id'], $user_title_cache))
2119  {
2120  $tmp_purchaser = $user_title_cache[$booking['customer_id']];
2121  }
2122  else
2123  {
2124  $tmp_purchaser = ilObjUser::_lookupLogin($booking['customer_id']);
2125  $user_title_cache[$booking['customer_id']] = $tmp_purchaser;
2126  }
2127 
2128  switch ($booking['b_pay_method'])
2129  {
2130  case $this->pobject->PAY_METHOD_BILL :
2131  $pay_method = $this->lng->txt("pays_bill");
2132  break;
2133  case $this->pobject->PAY_METHOD_BMF :
2134  $pay_method = $this->lng->txt("pays_bmf");
2135  break;
2136  case $this->pobject->PAY_METHOD_PAYPAL :
2137  $pay_method = $this->lng->txt("pays_paypal");
2138  break;
2139  }
2140  $worksheet->writeString($counter,0,ilExcelUtils::_convert_text($pay_method));
2141  $worksheet->writeString($counter,1,ilExcelUtils::_convert_text($booking['transaction_extern']));
2142  $worksheet->writeString($counter,2,ilExcelUtils::_convert_text(($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted'))));
2143  $worksheet->writeString($counter,3,ilExcelUtils::_convert_text(($tmp_vendor != '' ? $tmp_vendor : $this->lng->txt('user_deleted'))));
2144  $worksheet->writeString($counter,4,ilExcelUtils::_convert_text(ilPaymentVendors::_getCostCenter($booking['b_vendor_id'])));
2145  $worksheet->writeString($counter,5,ilExcelUtils::_convert_text(($tmp_purchaser != '' ? $tmp_purchaser : $this->lng->txt('user_deleted'))));
2146  $worksheet->writeString($counter,6,strftime('%Y-%m-%d %R',$booking['order_date']));
2147  /*
2148  $worksheet->write($counter,5,ilUtil::excelTime(date('Y',$booking['order_date']),
2149  date('m',$booking['order_date']),
2150  date('d',$booking['order_date']),
2151  date('H',$booking['order_date']),
2152  date('i',$booking['order_date']),
2153  date('s',$booking['order_date'])),$pewa->getFormatDate());
2154  */
2155  $worksheet->writeString($counter,7,$booking['duration']);
2156  $worksheet->writeString($counter,8,ilExcelUtils::_convert_text($booking['price']));
2157 
2158  $payed_access = $booking['payed'] ?
2159  $this->lng->txt('yes') :
2160  $this->lng->txt('no');
2161 
2162  $payed_access .= '/';
2163  $payed_access .= $booking['access'] ?
2164  $this->lng->txt('yes') :
2165  $this->lng->txt('no');
2166 
2167  $worksheet->writeString($counter,9,$payed_access);
2168 
2169  unset($tmp_obj);
2170  unset($tmp_vendor);
2171  unset($tmp_purchaser);
2172 
2173  ++$counter;
2174  }
2175  }
2176 
2177  function addVendorWorksheet(&$pewa)
2178  {
2179  include_once './classes/class.ilExcelUtils.php';
2180 
2181  $this->object->initPaymentVendorsObject();
2182  if(!count($vendors = $this->object->payment_vendors_obj->getVendors()))
2183  {
2184  return false;
2185  }
2186 
2187  $workbook =& $pewa->getWorkbook();
2188  $worksheet =& $workbook->addWorksheet(ilExcelUtils::_convert_text($this->lng->txt('pays_vendor')));
2189 
2190  // SHOW HEADER
2191  $worksheet->mergeCells(0,0,0,2);
2192  $worksheet->setColumn(1,0,32);
2193  $worksheet->setColumn(1,1,32);
2194  $worksheet->setColumn(1,2,32);
2195 
2196  $title = $this->lng->txt('paya_vendor_list');
2197  $title .= ' '.$this->lng->txt('as_of');
2198  $title .= strftime('%Y-%m-%d %R',time());
2199 
2200  $worksheet->writeString(0,0,$title,$pewa->getFormatTitle());
2201 
2202  $worksheet->writeString(1,0,ilExcelUtils::_convert_text($this->lng->txt('login')),$pewa->getFormatHeader());
2203  $worksheet->writeString(1,1,ilExcelUtils::_convert_text($this->lng->txt('fullname')),$pewa->getFormatHeader());
2204  $worksheet->writeString(1,2,ilExcelUtils::_convert_text($this->lng->txt('pays_cost_center')),$pewa->getFormatHeader());
2205 
2206  $counter = 2;
2207  foreach($vendors as $vendor)
2208  {
2209  // GET USER OBJ
2210  if($tmp_obj = ilObjectFactory::getInstanceByObjId($vendor['vendor_id'],false))
2211  {
2212  $worksheet->writeString($counter,0,ilExcelUtils::_convert_text($tmp_obj->getLogin()));
2213  $worksheet->writeString($counter,1,ilExcelUtils::_convert_text($tmp_obj->getFullname()));
2214  $worksheet->writeString($counter,2,ilExcelUtils::_convert_text($vendor['cost_center']));
2215  }
2216  unset($tmp_obj);
2217  ++$counter;
2218  }
2219  }
2220 
2221  function payMethodsObject()
2222  {
2223  include_once './payment/classes/class.ilPayMethods.php';
2224 
2225  global $rbacsystem;
2226 
2227  // MINIMUM ACCESS LEVEL = 'read'
2228  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
2229  {
2230  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
2231  }
2232 
2233  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_pay_methods.html",'payment');
2234 
2235  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2236  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_pays.gif'));
2237  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_pays'));
2238  $this->tpl->setVariable("TITLE",$this->lng->txt('pays_pay_methods'));
2239  $this->tpl->setVariable("TXT_OFFLINE",$this->lng->txt('pays_offline'));
2240  $this->tpl->setVariable("TXT_BILL",$this->lng->txt('pays_bill'));
2241  $this->tpl->setVariable("BILL_CHECK",ilUtil::formCheckbox(
2242  (int) ilPayMethods::_enabled('pm_bill') ? 1 : 0,'pm_bill',1,true));
2243 
2244  $this->tpl->setVariable("TXT_ENABLED",$this->lng->txt('enabled'));
2245  $this->tpl->setVariable("TXT_ONLINE",$this->lng->txt('pays_online'));
2246  $this->tpl->setVariable("TXT_BMF",$this->lng->txt('pays_bmf'));
2247  $this->tpl->setVariable("BMF_ONLINE_CHECK",ilUtil::formCheckbox((int) ilPayMethods::_enabled('pm_bmf'),'pm_bmf',1));
2248 
2249  $this->tpl->setVariable("TXT_ENABLED",$this->lng->txt('enabled'));
2250  $this->tpl->setVariable("TXT_ONLINE",$this->lng->txt('pays_online'));
2251  $this->tpl->setVariable("TXT_PAYPAL",$this->lng->txt('pays_paypal'));
2252  $this->tpl->setVariable("PAYPAL_ONLINE_CHECK",ilUtil::formCheckbox((int) ilPayMethods::_enabled('pm_paypal'),'pm_paypal',1));
2253 
2254  // footer
2255  $this->tpl->setVariable("COLUMN_COUNT",3);
2256  $this->tpl->setVariable("PBTN_NAME",'savePayMethods');
2257  $this->tpl->setVariable("PBTN_VALUE",$this->lng->txt('save'));
2258 
2259  }
2260 
2262  {
2263  include_once './payment/classes/class.ilPayMethods.php';
2264  include_once './payment/classes/class.ilPaymentObject.php';
2265 
2266 
2267  global $rbacsystem;
2268 
2269  // MINIMUM ACCESS LEVEL = 'read'
2270  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
2271  {
2272  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
2273  }
2274 
2275 
2276  // check current payings
2277  if(ilPayMethods::_enabled('pm_bill') and !$_POST['pm_bill'])
2278  {
2280  {
2281  ilUtil::sendInfo($this->lng->txt('pays_objects_bill_exist'));
2282  $this->payMethodsObject();
2283 
2284  return false;
2285  }
2286  }
2287 
2288  if(ilPayMethods::_enabled('pm_bmf') and !$_POST['pm_bmf'])
2289  {
2291  {
2292  ilUtil::sendInfo($this->lng->txt('pays_objects_bmf_exist'));
2293  $this->payMethodsObject();
2294 
2295  return false;
2296  }
2297  }
2298 
2299  if(ilPayMethods::_enabled('pm_paypal') and !$_POST['pm_paypal'])
2300  {
2302  {
2303  ilUtil::sendInfo($this->lng->txt('pays_objects_paypal_exist'));
2304  $this->payMethodsObject();
2305 
2306  return false;
2307  }
2308  }
2309 
2311  if(isset($_POST['pm_bill']))
2312  {
2313  ilPayMethods::_enable('pm_bill');
2314  }
2315  if(isset($_POST['pm_bmf']))
2316  {
2317  ilPayMethods::_enable('pm_bmf');
2318  }
2319  if(isset($_POST['pm_paypal']))
2320  {
2321  ilPayMethods::_enable('pm_paypal');
2322  }
2323  $this->payMethodsObject();
2324 
2325  ilUtil::sendInfo($this->lng->txt('pays_updated_pay_method'));
2326 
2327  return true;
2328  }
2329 
2331  {
2332  unset($_SESSION['pays_vendor']);
2333  $this->vendorsObject();
2334 
2335  return true;
2336  }
2337 
2338  function deleteVendors()
2339  {
2340  include_once './payment/classes/class.ilPaymentBookings.php';
2341 
2342  if(!count($_POST['vendor']))
2343  {
2344  ilUtil::sendInfo($this->lng->txt('pays_no_vendor_selected'));
2345  $this->vendorsObject();
2346 
2347  return true;
2348  }
2349  // CHECK BOOKINGS
2350  foreach($_POST['vendor'] as $vendor)
2351  {
2353  {
2354  ilUtil::sendInfo($this->lng->txt('pays_active_bookings'));
2355  $this->vendorsObject();
2356 
2357  return true;
2358  }
2359  }
2360 
2361  $_SESSION["pays_vendor"] = $_POST["vendor"];
2362  ilUtil::sendInfo($this->lng->txt("pays_sure_delete_selected_vendors"));
2363  $this->vendorsObject(true);
2364 
2365  return true;
2366  }
2368  {
2369  include_once './payment/classes/class.ilPaymentTrustees.php';
2370 
2371  global $rbacsystem;
2372 
2373  // MINIMUM ACCESS LEVEL = 'read'
2374  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
2375  {
2376  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2377  }
2378 
2379  $this->object->initPaymentVendorsObject();
2380 
2381  foreach($_SESSION['pays_vendor'] as $vendor)
2382  {
2383  $this->object->payment_vendors_obj->delete($vendor);
2385  }
2386 
2387  ilUtil::sendInfo($this->lng->txt('pays_deleted_number_vendors').' '.count($_SESSION['pays_vendor']));
2388  unset($_SESSION['pays_vendor']);
2389 
2390  $this->vendorsObject();
2391 
2392  return true;
2393  }
2394 
2395  function editVendor()
2396  {
2397  global $rbacsystem;
2398 
2399  // MINIMUM ACCESS LEVEL = 'read'
2400  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
2401  {
2402  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2403  }
2404 
2405  if(!count($_POST['vendor']))
2406  {
2407  ilUtil::sendInfo($this->lng->txt('pays_no_vendor_selected'));
2408  $this->vendorsObject();
2409 
2410  return true;
2411  }
2412  if(count($_POST['vendor']) > 1)
2413  {
2414  ilUtil::sendInfo($this->lng->txt('pays_too_many_vendors_selected'));
2415  $this->vendorsObject();
2416 
2417  return true;
2418  }
2419 
2420  $_SESSION["pays_vendor"] = $_POST["vendor"][0];
2421 
2422  $this->object->initPaymentVendorsObject();
2423 
2424  if (!is_array($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]))
2425  {
2426  $this->vendorsObject();
2427 
2428  return true;
2429  }
2430 
2431  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pays_vendor.html','payment');
2432 
2433  $this->tpl->setVariable("VENDOR_FORMACTION",$this->ctrl->getFormAction($this));
2434 
2435  // set table header
2436  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_usr.gif'));
2437  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
2438  $this->tpl->setVariable("TITLE",$this->lng->txt('pays_vendor'));
2439 
2440  // set plain text variables
2441  $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('pays_vendor'));
2442  $this->tpl->setVariable("TXT_COST_CENTER",$this->lng->txt('pays_cost_center'));
2443 
2444  $this->tpl->setVariable("INPUT_VALUE",ucfirst($this->lng->txt('save')));
2445 
2446  // fill defaults
2447 
2448  $this->tpl->setVariable("VENDOR",
2449  ilObjUser::getLoginByUserId($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]["vendor_id"]), true);
2450  $this->tpl->setVariable("COST_CENTER",
2451  $this->error != "" && isset($_POST['cost_center'])
2452  ? ilUtil::prepareFormOutput($_POST['cost_center'],true)
2453  : ilUtil::prepareFormOutput($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]["cost_center"],true));
2454 
2455  // Button
2456  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
2457  $this->tpl->setCurrentBlock("btn_cell");
2458  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "vendors"));
2459  $this->tpl->setVariable("BTN_TXT", $this->lng->txt('pay_bmf_back'));
2460  $this->tpl->parseCurrentBlock("btn_cell");
2461 
2462  }
2464  {
2465  global $rbacsystem;
2466 
2467  // MINIMUM ACCESS LEVEL = 'read'
2468  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
2469  {
2470  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2471  }
2472 
2473  if(!count($_SESSION['pays_vendor']))
2474  {
2475  ilUtil::sendInfo($this->lng->txt('pays_no_vendor_selected'));
2476  $this->vendorsObject();
2477 
2478  return true;
2479  }
2480  if(count($_SESSION['pays_vendor']) > 1)
2481  {
2482  ilUtil::sendInfo($this->lng->txt('pays_too_many_vendors_selected'));
2483  $this->vendorsObject();
2484 
2485  return true;
2486  }
2487 
2488  $this->object->initPaymentVendorsObject();
2489 
2490  if (!is_array($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]))
2491  {
2492  $this->vendorsObject();
2493 
2494  return true;
2495  }
2496 
2497  if ($_POST["cost_center"] == "")
2498  {
2499  $this->error = $this->lng->txt('pays_cost_center_not_valid');
2500  ilUtil::sendInfo($this->error);
2501  $_POST["vendor"] = array($_SESSION["pays_vendor"]);
2502  $this->editVendor();
2503  return;
2504  }
2505 
2506  $this->object->initPaymentVendorsObject();
2507  $this->object->payment_vendors_obj->update($_SESSION["pays_vendor"], $_POST["cost_center"]);
2508 
2509  unset($_SESSION['pays_vendor']);
2510 
2511  $this->vendorsObject();
2512 
2513  return true;
2514  }
2515 
2517  {
2518  global $rbacsystem, $tree;
2519 
2520  // MINIMUM ACCESS LEVEL = 'read'
2521  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
2522  {
2523  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
2524  }
2525 
2526  include_once './payment/classes/class.ilPaymentObjectSelector.php';
2527 
2528  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paya_object_selector.html",'payment');
2529  $this->__showButton('statistic',$this->lng->txt('back'));
2530 
2531 
2532  ilUtil::sendInfo($this->lng->txt("paya_select_object_to_sell"));
2533 
2534  $exp = new ilPaymentObjectSelector($this->ctrl->getLinkTarget($this,'showObjectSelector'), strtolower(get_class($this)));
2535  $exp->setExpand($_GET["paya_link_expand"] ? $_GET["paya_link_expand"] : $tree->readRootId());
2536  $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showObjectSelector'));
2537 
2538  $exp->setOutput(0);
2539 
2540  $this->tpl->setVariable("EXPLORER",$exp->getOutput());
2541 
2542  return true;
2543  }
2544 
2545  function searchUserObject()
2546  {
2547  global $rbacsystem;
2548 
2549  // MINIMUM ACCESS LEVEL = 'read'
2550  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
2551  {
2552  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
2553  }
2554 
2555  $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.pays_user_search.html",'payment');
2556  $this->__showButton('vendors',$this->lng->txt('back'));
2557 
2558  $this->lng->loadLanguageModule('search');
2559 
2560  $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
2561  $this->tpl->setVariable("SEARCH_ASSIGN_USR",$this->lng->txt("crs_search_members"));
2562  $this->tpl->setVariable("SEARCH_SEARCH_TERM",$this->lng->txt("search_search_term"));
2563  $this->tpl->setVariable("SEARCH_VALUE",$_SESSION["pays_search_str"] ? $_SESSION["pays_search_str"] : "");
2564  $this->tpl->setVariable("BTN2_VALUE",$this->lng->txt("cancel"));
2565  $this->tpl->setVariable("BTN1_VALUE",$this->lng->txt("search"));
2566 
2567  return true;
2568  }
2569 
2570  function searchObject()
2571  {
2572  global $rbacsystem,$tree;
2573 
2574  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
2575  {
2576  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
2577  }
2578 
2579  $_SESSION["pays_search_str"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["pays_search_str"];
2580 
2581  if(!isset($_POST["search_str"]))
2582  {
2583  ilUtil::sendInfo($this->lng->txt("crs_search_enter_search_string"));
2584  $this->searchUserObject();
2585 
2586  return false;
2587  }
2588  if(!count($result = $this->__search(ilUtil::stripSlashes($_POST["search_str"]))))
2589  {
2590  ilUtil::sendInfo($this->lng->txt("crs_no_results_found"));
2591  $this->searchUserObject();
2592 
2593  return false;
2594  }
2595 
2596  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_usr_selection.html",'payment');
2597  $this->__showButton("searchUser",$this->lng->txt("crs_new_search"));
2598 
2599  $counter = 0;
2600  $f_result = array();
2601  foreach($result as $user)
2602  {
2603  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user["id"],false))
2604  {
2605  continue;
2606  }
2607  $f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user["id"]);
2608  $f_result[$counter][] = $tmp_obj->getLogin();
2609  $f_result[$counter][] = $tmp_obj->getLastname();
2610  $f_result[$counter][] = $tmp_obj->getFirstname();
2611 
2612  unset($tmp_obj);
2613  ++$counter;
2614  }
2615  $this->__showSearchUserTable($f_result);
2616 
2617  return true;
2618  }
2619  function addVendorObject()
2620  {
2621  global $rbacsystem;
2622 
2623  // MINIMUM ACCESS LEVEL = 'administrate'
2624  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
2625  {
2626  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2627  }
2628  if(!$_POST['vendor_login'])
2629  {
2630  ilUtil::sendInfo($this->lng->txt('pays_no_username_given'));
2631  $this->vendorsObject();
2632 
2633  return true;
2634  }
2635  if(!($usr_id = ilObjUser::getUserIdByLogin(ilUtil::stripSlashes($_POST['vendor_login']))))
2636  {
2637  ilUtil::sendInfo($this->lng->txt('pays_no_valid_username_given'));
2638  $this->vendorsObject();
2639 
2640  return true;
2641  }
2642 
2643  $this->object->initPaymentVendorsObject();
2644 
2645  if($this->object->payment_vendors_obj->isAssigned($usr_id))
2646  {
2647  ilUtil::sendInfo($this->lng->txt('pays_user_already_assigned'));
2648  $this->vendorsObject();
2649 
2650  return true;
2651  }
2652  $this->object->payment_vendors_obj->add($usr_id);
2653 
2654  ilUtil::sendInfo($this->lng->txt('pays_added_vendor'));
2655  $this->vendorsObject();
2656 
2657  return true;
2658  }
2659 
2660  function addUserObject()
2661  {
2662  global $rbacsystem;
2663 
2664  // MINIMUM ACCESS LEVEL = 'administrate'
2665  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
2666  {
2667  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2668  }
2669 
2670  $this->lng->loadLanguageModule('crs');
2671  if(!is_array($_POST["user"]))
2672  {
2673  ilUtil::sendInfo($this->lng->txt("crs_no_users_selected"));
2674  $this->searchObject();
2675 
2676  return false;
2677  }
2678 
2679  $this->object->initPaymentVendorsObject();
2680 
2681  $already_assigned = $assigned = 0;
2682  foreach($_POST['user'] as $usr_id)
2683  {
2684  if($this->object->payment_vendors_obj->isAssigned($usr_id))
2685  {
2686  ++$already_assigned;
2687 
2688  continue;
2689  }
2690  $this->object->payment_vendors_obj->add($usr_id);
2691  ++$assigned;
2692 
2693  // TODO: SEND NOTIFICATION
2694  }
2695  $message = '';
2696  if($assigned)
2697  {
2698  $message .= $this->lng->txt('pays_assigned_vendors').' '.$assigned;
2699  }
2700  if($already_assigned)
2701  {
2702  $message .= '<br />'.$this->lng->txt('pays_already_assigned_vendors').' '.$already_assigned;
2703  }
2704 
2705  ilUtil::sendInfo($message);
2706  $this->vendorsObject();
2707 
2708  return true;
2709  }
2710 
2711 
2713  {
2714  if(!isset($_GET['sell_id']))
2715  {
2716  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
2717  $this->showObjectSelectorObject();
2718 
2719  return false;
2720  }
2721 
2722  $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.paya_user_search.html",'payment');
2723  $this->__showButton('showObjectSelector',$this->lng->txt('back'));
2724 
2725  $this->lng->loadLanguageModule('search');
2726 
2727  $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
2728  $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
2729  $this->tpl->setVariable("SEARCH_ASSIGN_USR",$this->lng->txt("search_user"));
2730  $this->tpl->setVariable("SEARCH_SEARCH_TERM",$this->lng->txt("search_search_term"));
2731  $this->tpl->setVariable("SEARCH_VALUE",$_SESSION["paya_search_str_user_sp"] ? $_SESSION["paya_search_str_user_sp"] : "");
2732  $this->tpl->setVariable("BTN2_VALUE",$this->lng->txt("cancel"));
2733  $this->tpl->setVariable("BTN1_VALUE",$this->lng->txt("search"));
2734  $this->tpl->setVariable("SEARCH","performSearchSP");
2735  $this->tpl->setVariable("CANCEL","statistic");
2736 
2737  return true;
2738  }
2739 
2741  {
2742  // SAVE it to allow sort in tables
2743  $_SESSION["paya_search_str_user_sp"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["paya_search_str_user_sp"];
2744 
2745  if(!trim($_POST["search_str"]))
2746  {
2747  ilUtil::sendInfo($this->lng->txt("search_no_search_term"));
2748  $this->statistics();
2749 
2750  return false;
2751  }
2752  if(!count($result = $this->__search(ilUtil::stripSlashes($_POST["search_str"]))))
2753  {
2754  ilUtil::sendInfo($this->lng->txt("search_no_match"));
2755  $this->searchUserSPObject();
2756 
2757  return false;
2758  }
2759 
2760  if(!isset($_GET['sell_id']))
2761  {
2762  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
2763  $this->showObjectSelectorObject();
2764 
2765  return false;
2766  }
2767 
2768  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paya_usr_selection.html",'payment');
2769  $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
2770  $this->__showButton("searchUserSP",$this->lng->txt("back"));
2771 
2772  $counter = 0;
2773  $f_result = array();
2774  foreach($result as $user)
2775  {
2776  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user["id"],false))
2777  {
2778  continue;
2779  }
2780  $f_result[$counter][] = ilUtil::formRadiobutton(0,"user_id",$user["id"]);
2781  $f_result[$counter][] = $tmp_obj->getLogin();
2782  $f_result[$counter][] = $tmp_obj->getFirstname();
2783  $f_result[$counter][] = $tmp_obj->getLastname();
2784 
2785  unset($tmp_obj);
2786  ++$counter;
2787  }
2788  $this->__showSearchUserSPTable($f_result);
2789  }
2790 
2792  {
2793  if ($_POST["sell_id"] != "") $_GET["sell_id"] = $_POST["sell_id"];
2794  if ($_GET["user_id"] != "") $_POST["user_id"] = $_GET["user_id"];
2795 
2796  if(!isset($_GET['sell_id']))
2797  {
2798  ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
2799  $this->showObjectSelectorObject();
2800 
2801  return true;
2802  }
2803 
2804  if(!isset($_POST['user_id']))
2805  {
2806  ilUtil::sendInfo($this->lng->txt('paya_no_user_id_given'));
2807  $this->searchUserSPObject();
2808 
2809  return true;
2810  }
2811 
2812  $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
2813  $this->__showButton('searchUserSP',$this->lng->txt('back'));
2814 
2815  $this->ctrl->setParameter($this, "user_id", $_POST["user_id"]);
2816 
2817  $pObjectId = ilPaymentObject::_lookupPobjectId($_GET["sell_id"]);
2818  $obj =& new ilPaymentObject($this->user_obj, $pObjectId);
2819 
2820  // get obj
2821  $tmp_obj =& ilObjectFactory::getInstanceByRefId($_GET["sell_id"]);
2822  // get customer_obj
2823  $tmp_user =& ilObjectFactory::getInstanceByObjId($_POST["user_id"]);
2824  // get vendor_obj
2825  $tmp_vendor =& ilObjectFactory::getInstanceByObjId($obj->getVendorId());
2826 
2827  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_add_customer.html','payment');
2828 
2829  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2830 
2831  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_usr.gif'));
2832  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
2833  $this->tpl->setVariable("TITLE",$tmp_user->getFullname().' ['.$tmp_user->getLogin().']');
2834 
2835  // TXT
2836  $this->tpl->setVariable("TXT_TRANSACTION",$this->lng->txt('paya_transaction'));
2837  $this->tpl->setVariable("TRANSACTION",ilUtil::prepareFormOutput($_POST["transaction"], true));
2838 
2839  $this->tpl->setVariable("TXT_OB JECT",$this->lng->txt('title'));
2840  $this->tpl->setVariable("OBJECT",$tmp_obj->getTitle());
2841 
2842  $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
2843  $this->tpl->setVariable("VENDOR",$tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']');
2844 
2845  $this->tpl->setVariable("TXT_PAY_METHOD",$this->lng->txt('paya_pay_method'));
2846  $this->tpl->setVariable("TXT_PAY_METHOD_BILL",$this->lng->txt('pays_bill'));
2847  $this->tpl->setVariable("TXT_PAY_METHOD_BMF",$this->lng->txt('pays_bmf'));
2848  $this->tpl->setVariable("TXT_PAY_METHOD_PAYPAL",$this->lng->txt('pays_paypal'));
2849  $this->tpl->setVariable("PAY_METHOD_".$_POST["pay_method"], " selected");
2850 
2851  $this->tpl->setVariable("TXT_ORDER_DATE",$this->lng->txt('paya_order_date'));
2852  $this->tpl->setVariable("ORDER_DATE",ilDatePresentation::formatDate(new ilDateTime(time(),IL_CAL_UNIX)));
2853 
2854  $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('duration'));
2855  include_once './payment/classes/class.ilPaymentPrices.php';
2856  $prices_obj =& new ilPaymentPrices($pObjectId);
2857  if (is_array($prices = $prices_obj->getPrices()))
2858  {
2859  foreach($prices as $price)
2860  {
2861  $this->tpl->setCurrentBlock("duration_loop");
2862  if ($_POST["duration"] == $price["price_id"]) $this->tpl->setVariable("DURATION_LOOP_SELECTED", " selected");
2863  $this->tpl->setVariable("DURATION_LOOP_ID", $price["price_id"]);
2864  $this->tpl->setVariable("DURATION_LOOP_NAME", $price["duration"]." ".$this->lng->txt("paya_months").", ".ilPaymentPrices::_getPriceString($price["price_id"]));
2865  $this->tpl->parseCurrentBlock();
2866  }
2867  }
2868 
2869  $this->tpl->setVariable("TXT_PAYED",$this->lng->txt('paya_payed'));
2870  if ($_POST["payed"] == 1) $this->tpl->setVariable("PAYED_1", " selected");
2871  $this->tpl->setVariable("TXT_ACCESS",$this->lng->txt('paya_access'));
2872  if ($_POST["access"] == 1) $this->tpl->setVariable("ACCESS_1", " selected");
2873 
2874  $this->tpl->setVariable("TXT_NO",$this->lng->txt('no'));
2875  $this->tpl->setVariable("TXT_YES",$this->lng->txt('yes'));
2876  $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
2877  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
2878  $this->tpl->setVariable("STATISTICS","statistic");
2879 
2880  }
2881 
2883  {
2884  global $ilias;
2885 
2886  if(!isset($_GET['sell_id']))
2887  {
2888  ilUtil::sendInfo($this->lng->txt('paya_error_no_object_id_given'));
2889  $this->showObjectSelectorObject();
2890 
2891  return true;
2892  }
2893 
2894  if(!isset($_GET['user_id']))
2895  {
2896  ilUtil::sendInfo($this->lng->txt('paya_error_no_user_id_given'));
2897  $this->searchUserSPObject();
2898 
2899  return true;
2900  }
2901 
2902  if ($_POST["pay_method"] == "" ||
2903  $_POST["duration"] == "")
2904  {
2905  ilUtil::sendInfo($this->lng->txt('paya_error_mandatory_fields'));
2906  $this->addCustomerObject();
2907 
2908  return true;
2909  }
2910 
2911  $pObjectId = ilPaymentObject::_lookupPobjectId($_GET["sell_id"]);
2912  $obj =& new ilPaymentObject($this->user_obj, $pObjectId);
2913 
2914  $this->__initBookingObject();
2915 
2916  $inst_id_time = $ilias->getSetting('inst_id').'_'.$this->user_obj->getId().'_'.substr((string) time(),-3);
2917  $transaction = $inst_id_time.substr(md5(uniqid(rand(), true)), 0, 4);
2918  $this->booking_obj->setTransaction($transaction);
2919  $this->booking_obj->setTransactionExtern($_POST["transaction"]);
2920  $this->booking_obj->setPobjectId($pObjectId);
2921  $this->booking_obj->setCustomerId($_GET["user_id"]);
2922  $this->booking_obj->setVendorId($obj->getVendorId());
2923  $this->booking_obj->setPayMethod((int) $_POST["pay_method"]);
2924  $this->booking_obj->setOrderDate(time());
2925  include_once './payment/classes/class.ilPaymentPrices.php';
2926  $price = ilPaymentPrices::_getPrice($_POST["duration"]);
2927  $this->booking_obj->setDuration($price["duration"]);
2928  $this->booking_obj->setPrice(ilPaymentPrices::_getPriceString($_POST["duration"]));
2929  $this->booking_obj->setAccess((int) $_POST['access']);
2930  $this->booking_obj->setPayed((int) $_POST['payed']);
2931  $this->booking_obj->setVoucher('');
2932 
2933  if($this->booking_obj->add())
2934  {
2935  ilUtil::sendInfo($this->lng->txt('paya_customer_added_successfully'));
2936  $this->statisticObject();
2937  }
2938  else
2939  {
2940  ilUtil::sendInfo($this->lng->txt('paya_error_adding_customer'));
2941  $this->addCustomerObject();
2942  }
2943 
2944  return true;
2945  }
2946 
2947  // PRIVATE
2948  function __setSection($a_section)
2949  {
2950  $this->section = $a_section;
2951  }
2952  function __getSection()
2953  {
2954  return $this->section;
2955  }
2956  function __setMainSection($a_section)
2957  {
2958  $this->mainSection = $a_section;
2959  }
2960  function __getMainSection()
2961  {
2962  return $this->mainSection;
2963  }
2964 
2966  {
2967  if($this->__getMainSection() == $this->SETTINGS)
2968  {
2969  $this->tabs_gui->addSubTabTarget('pays_general',
2970  $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'generalSettings'),
2971  '',
2972  '',
2973  '',
2974  $this->__getSection() == $this->SECTION_GENERAL ? true : false);
2975  $this->tabs_gui->addSubTabTarget('pays_bmf',
2976  $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'bmfSettings'),
2977  '',
2978  '',
2979  '',
2980  $this->__getSection() == $this->SECTION_BMF ? true : false);
2981  $this->tabs_gui->addSubTabTarget('pays_paypal',
2982  $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'paypalSettings'),
2983  '',
2984  '',
2985  '',
2986  $this->__getSection() == $this->SECTION_PAYPAL ? true : false);
2987  }
2988  }
2989 
2990  function __showStatisticTable($a_result_set)
2991  {
2992  $tbl =& $this->__initTableGUI();
2993  $tpl =& $tbl->getTemplateObject();
2994 
2995  // SET FORMAACTION
2996  $tpl->setCurrentBlock("tbl_form_header");
2997 
2998  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2999  $tpl->parseCurrentBlock();
3000 
3001 
3002  $tbl->setTitle($this->lng->txt("paya_statistic"),"icon_pays.gif",$this->lng->txt("paya_statistic"));
3003  $tbl->setHeaderNames(array($this->lng->txt("paya_transaction"),
3004  $this->lng->txt("title"),
3005  $this->lng->txt("paya_vendor"),
3006  $this->lng->txt("paya_customer"),
3007  $this->lng->txt("paya_order_date"),
3008  $this->lng->txt("duration"),
3009  $this->lng->txt("price_a"),
3010  $this->lng->txt("paya_coupons_coupons"),
3011  $this->lng->txt("paya_payed_access"),
3012  ''));
3013 
3014  $tbl->setHeaderVars(array("transaction",
3015  "title",
3016  "vendor",
3017  "customer",
3018  "order_date",
3019  "duration",
3020  "price",
3021  "discount",
3022  "payed_access",
3023  "options"),
3024  $this->ctrl->getParameterArray($this,"statistic",false));
3025 
3026  $offset = $_GET["offset"];
3027  $order = $_GET["sort_by"];
3028  $direction = $_GET["sort_order"] ? $_GET['sort_order'] : 'desc';
3029 
3030  $tbl->setOrderColumn($order,'order_date');
3031  $tbl->setOrderDirection($direction);
3032  $tbl->setOffset($offset);
3033  $tbl->setLimit($_GET["limit"]);
3034  $tbl->setMaxCount(count($a_result_set));
3035  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
3036  $tbl->setData($a_result_set);
3037 
3038  $tpl->setVariable("COLUMN_COUNTS",10);
3039  $tpl->setCurrentBlock("plain_buttons");
3040  $tpl->setVariable("PBTN_NAME","exportVendors");
3041  $tpl->setVariable("PBTN_VALUE",$this->lng->txt("excel_export"));
3042  $tpl->parseCurrentBlock();
3043  $tbl->render();
3044 
3045  $this->tpl->setVariable("STATISTIC_TABLE",$tbl->tpl->get());
3046 
3047  return true;
3048  }
3049 
3051  {
3052  include_once './payment/classes/class.ilPaymentBookings.php';
3053 
3054  $this->booking_obj =& new ilPaymentBookings($this->user_obj->getId(),true);
3055  }
3056 
3057  function __showVendorsTable($a_result_set)
3058  {
3059  $actions = array(
3060  "editVendorObject" => $this->lng->txt("pays_edit_vendor"),
3061  "deleteVendorsObject" => $this->lng->txt("pays_delete_vendor")
3062  );
3063 
3064  $tbl =& $this->__initTableGUI();
3065  $tpl =& $tbl->getTemplateObject();
3066 
3067  // SET FORMAACTION
3068  $tpl->setCurrentBlock("tbl_form_header");
3069 
3070  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3071  $tpl->parseCurrentBlock();
3072 
3073  $tpl->setCurrentBlock("tbl_action_row");
3074 
3075  $tpl->setCurrentBlock("input_text");
3076  $tpl->setVariable("PB_TXT_NAME",'vendor_login');
3077  $tpl->parseCurrentBlock();
3078 
3079  $tpl->setCurrentBlock("plain_button");
3080  $tpl->setVariable("PBTN_NAME","addVendor");
3081  $tpl->setVariable("PBTN_VALUE",$this->lng->txt("pays_add_vendor"));
3082  $tpl->parseCurrentBlock();
3083  $tpl->setCurrentBlock("plain_buttons");
3084  $tpl->parseCurrentBlock();
3085 
3086  $tpl->setVariable("COLUMN_COUNTS",4);
3087 
3088  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
3089 
3090  $tpl->setCurrentBlock("tbl_action_select");
3091  $tpl->setVariable("SELECT_ACTION",ilUtil::formSelect(1,"action",$actions,false,true));
3092  $tpl->setVariable("BTN_NAME","gateway");
3093  $tpl->setVariable("BTN_VALUE",$this->lng->txt("execute"));
3094  $tpl->parseCurrentBlock();
3095  $tpl->setCurrentBlock("tbl_action_row");
3096  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
3097  $tpl->parseCurrentBlock();
3098 
3099  $tbl->setTitle($this->lng->txt("vendors"),"icon_usr.gif",$this->lng->txt("vendors"));
3100  $tbl->setHeaderNames(array('',
3101  $this->lng->txt("pays_vendor"),
3102  $this->lng->txt("pays_cost_center"),
3103  $this->lng->txt("pays_number_bookings")));
3104  $tbl->setHeaderVars(array("",
3105  "login",
3106  "cost_center",
3107  "bookings"),
3108  array("ref_id" => $this->object->getRefId(),
3109  "cmd" => "vendors",
3110  "update_members" => 1,
3111  "baseClass" => "ilAdministrationGUI",
3112  "cmdClass" => "ilobjpaymentsettingsgui",
3113  "cmdNode" => $_GET["cmdNode"]));
3114 # $tbl->setColumnWidth(array("4%","48%","25%","24%"));
3115 
3116  $tpl->setVariable("COLUMN_COUNTS",9);
3117  $tpl->setCurrentBlock("plain_buttons");
3118  $tpl->setVariable("PBTN_NAME","exportVendors");
3119  $tpl->setVariable("PBTN_VALUE",$this->lng->txt("excel_export"));
3120  $tpl->parseCurrentBlock();
3121 
3122  $this->__setTableGUIBasicData($tbl,$a_result_set);
3123  $tbl->render();
3124 
3125  $this->tpl->setVariable("VENDOR_TABLE",$tbl->tpl->get());
3126 
3127  return true;
3128  }
3129 
3130 
3131  function __showSearchUserTable($a_result_set,$a_cmd = "search")
3132  {
3133  $tbl =& $this->__initTableGUI();
3134  $tpl =& $tbl->getTemplateObject();
3135 
3136 
3137  // SET FORMACTION
3138  $tpl->setCurrentBlock("tbl_form_header");
3139  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3140  $tpl->parseCurrentBlock();
3141 
3142  $tpl->setCurrentBlock("tbl_action_btn");
3143  $tpl->setVariable("BTN_NAME","addUser");
3144  $tpl->setVariable("BTN_VALUE",$this->lng->txt("add"));
3145  $tpl->parseCurrentBlock();
3146 
3147  $tpl->setCurrentBlock("tbl_action_btn");
3148  $tpl->setVariable("BTN_NAME","vendors");
3149  $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
3150  $tpl->parseCurrentBlock();
3151 
3152  $tpl->setCurrentBlock("tbl_action_row");
3153  $tpl->setVariable("COLUMN_COUNTS",5);
3154  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
3155  $tpl->parseCurrentBlock();
3156 
3157  $tbl->setTitle($this->lng->txt("pays_header_select_vendor"),"icon_usr.gif",$this->lng->txt("pays_header_select_vendor"));
3158  $tbl->setHeaderNames(array("",
3159  $this->lng->txt("login"),
3160  $this->lng->txt("firstname"),
3161  $this->lng->txt("lastname")));
3162  $tbl->setHeaderVars(array("",
3163  "login",
3164  "firstname",
3165  "lastname"),
3166  array("ref_id" => $this->object->getRefId(),
3167  "cmd" => $a_cmd,
3168  "cmdClass" => "ilobjpaymentsettingsgui",
3169  "cmdNode" => $_GET["cmdNode"]));
3170 
3171  $tbl->setColumnWidth(array("3%","32%","32%","32%"));
3172 
3173  $this->__setTableGUIBasicData($tbl,$a_result_set);
3174  $tbl->render();
3175 
3176  $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
3177 
3178  return true;
3179  }
3180 
3181  function __showButton($a_cmd,$a_text,$a_target = '')
3182  {
3183  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
3184 
3185  // display button
3186  $this->tpl->setCurrentBlock("btn_cell");
3187  $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,$a_cmd));
3188  $this->tpl->setVariable("BTN_TXT",$a_text);
3189  if($a_target)
3190  {
3191  $this->tpl->setVariable("BTN_TARGET",$a_target);
3192  }
3193 
3194  $this->tpl->parseCurrentBlock();
3195  }
3196 
3197  function &__initTableGUI()
3198  {
3199  include_once "./Services/Table/classes/class.ilTableGUI.php";
3200 
3201  return new ilTableGUI(0,false);
3202  }
3203 
3204  function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
3205  {
3206  $offset = $_GET["offset"];
3207  $order = $_GET["sort_by"];
3208  $direction = $_GET["sort_order"];
3209 
3210  $tbl->setOrderColumn($order);
3211  $tbl->setOrderDirection($direction);
3212  $tbl->setOffset($offset);
3213  $tbl->setLimit($_GET["limit"]);
3214  $tbl->setMaxCount(count($result_set));
3215  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
3216  $tbl->setData($result_set);
3217  }
3218 
3219  function __search($a_search_string)
3220  {
3221  include_once("./classes/class.ilSearch.php");
3222 
3223  $this->lng->loadLanguageModule("content");
3224 
3225  $search =& new ilSearch($_SESSION["AccountId"]);
3226  $search->setPerformUpdate(false);
3227  $search->setSearchString(ilUtil::stripSlashes($a_search_string));
3228  $search->setCombination("and");
3229  $search->setSearchFor(array(0 => 'usr'));
3230  $search->setSearchType('new');
3231 
3232  if($search->validate($message))
3233  {
3234  $search->performSearch();
3235  }
3236  else
3237  {
3238  ilUtil::sendInfo($message,true);
3239  $this->ctrl->redirect($this,"searchUser");
3240  }
3241  return $search->getResultByType('usr');
3242  }
3243 
3244  function __searchSP($a_search_string)
3245  {
3246  include_once("./classes/class.ilSearch.php");
3247 
3248  $this->lng->loadLanguageModule("content");
3249 
3250  $search =& new ilSearch($this->user_obj->getId());
3251  $search->setPerformUpdate(false);
3252  $search->setSearchString(ilUtil::stripSlashes($a_search_string));
3253  $search->setCombination("and");
3254  $search->setSearchFor(array(0 => 'usr'));
3255  $search->setSearchType('new');
3256 
3257  if($search->validate($message))
3258  {
3259  $search->performSearchSPObject();
3260  }
3261  else
3262  {
3263  ilUtil::sendInfo($message,true);
3264  $this->ctrl->redirect($this,"searchUserSP");
3265  }
3266  return $search->getResultByType('usr');
3267  }
3268  function __showSearchUserSPTable($a_result_set)
3269  {
3270  $tbl =& $this->initTableGUI();
3271  $tpl =& $tbl->getTemplateObject();
3272 
3273 
3274  // SET FORMACTION
3275  $tpl->setCurrentBlock("tbl_form_header");
3276  $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
3277  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3278  $tpl->parseCurrentBlock();
3279 
3280  $tpl->setCurrentBlock("tbl_action_btn");
3281  $tpl->setVariable("BTN_NAME","addCustomer");
3282  $tpl->setVariable("BTN_VALUE",$this->lng->txt("add"));
3283  $tpl->parseCurrentBlock();
3284 
3285  $tpl->setCurrentBlock("tbl_action_btn");
3286  $tpl->setVariable("BTN_NAME","statistic");
3287  $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
3288  $tpl->parseCurrentBlock();
3289 
3290  $tpl->setCurrentBlock("tbl_action_row");
3291  $tpl->setVariable("COLUMN_COUNTS",5);
3292  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
3293  $tpl->parseCurrentBlock();
3294 
3295  $tbl->setTitle($this->lng->txt("users"),"icon_usr.gif",$this->lng->txt("crs_header_edit_members"));
3296  $tbl->setHeaderNames(array("",
3297  $this->lng->txt("login"),
3298  $this->lng->txt("firstname"),
3299  $this->lng->txt("lastname")));
3300  $this->ctrl->setParameter($this, "cmd", "addCustomer");
3301  $header_params = $this->ctrl->getParameterArray($this,'');
3302  $tbl->setHeaderVars(array("",
3303  "login",
3304  "firstname",
3305  "lastname"), $header_params);
3306  /*
3307  array("cmd" => 'performSearch',
3308  "cmdClass" => "ilpaymentstatisticgui",
3309  "cmdNode" => $_GET["cmdNode"]));
3310  */
3311 
3312  $tbl->setColumnWidth(array("3%","32%","32%","32%"));
3313 
3314  $this->setTableGUIBasicData($tbl,$a_result_set);
3315  $tbl->render();
3316 
3317  $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
3318 
3319  return true;
3320  }
3321 
3322  function &initTableGUI()
3323  {
3324  include_once "./Services/Table/classes/class.ilTableGUI.php";
3325 
3326  return new ilTableGUI(0,false);
3327  }
3328  function setTableGUIBasicData(&$tbl,&$result_set,$a_default_order_column = '')
3329  {
3330  $offset = $_GET["offset"];
3331  $order = $_GET["sort_by"];
3332  $direction = $_GET["sort_order"];
3333 
3334  $tbl->setOrderColumn($order,$a_default_order_column);
3335  $tbl->setOrderDirection($direction);
3336  $tbl->setOffset($offset);
3337  $tbl->setLimit($_GET["limit"]);
3338  $tbl->setMaxCount(count($result_set));
3339  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
3340  $tbl->setData($result_set);
3341  }
3342 } // END class.ilObjPaymentSettingsGUI
3343 ?>