ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPaymentObjectGUI.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 
24 include_once 'payment/classes/class.ilPaymentObject.php';
25 include_once 'payment/classes/class.ilPaymentBookings.php';
26 include_once 'Services/Payment/classes/class.ilFileDataShop.php';
27 include_once 'Services/Payment/classes/class.ilShopVatsList.php';
28 
29 
40 {
41  var $ctrl;
42  var $lng;
43  var $user_obj;
44  var $pobject = null;
45 
46  public function ilPaymentObjectGUI($user_obj)
47  {
49 
50  $this->user_obj = $user_obj;
51  $this->lng->loadLanguageModule('crs');
52  }
53 
54  protected function prepareOutput()
55  {
56  global $ilTabs;
57 
58  $this->setSection(6);
59 
61 
62  $ilTabs->setTabActive('paya_header');
63  $ilTabs->setSubTabActive('paya_object');
64  }
65 
66  public function executeCommand()
67  {
68  $cmd = $this->ctrl->getCmd();
69  switch($this->ctrl->getNextClass($this))
70  {
71  case 'ilpageobjectgui':
72  $this->prepareOutput();
73  $ret = $this->forwardToPageObject();
74  if($ret != '')
75  {
76  $this->tpl->setContent($ret);
77  }
78  break;
79 
80  default:
81  if(!$cmd = $this->ctrl->getCmd())
82  {
83  $cmd = 'showObjects';
84  }
85  $this->prepareOutput();
86  $this->$cmd();
87  break;
88  }
89  }
90 
91  public function forwardToPageObject()
92  {
93  global $ilTabs;
94 
95  if(!(int)$_GET['pobject_id'])
96  {
97  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
98  return $this->showObjects();
99  }
100  $this->ctrl->setParameter($this, 'pobject_id', (int)$_GET['pobject_id']);
101  $this->__initPaymentObject((int)$_GET['pobject_id']);
102 
103  $this->lng->loadLanguageModule('content');
104 
105  $ilTabs->clearTargets();
106  $ilTabs->clearSubTabs();
107  $ilTabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'editDetails'), '_top');
108 
109  // page objec
110  include_once 'Services/COPage/classes/class.ilPageObject.php';
111  include_once 'Services/COPage/classes/class.ilPageObjectGUI.php';
112  include_once('./Services/Style/classes/class.ilObjStyleSheet.php');
113 
114  $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
115 
116  if(!ilPageObject::_exists('shop', $this->pobject->getPobjectId()))
117  {
118  // doesn't exist -> create new one
119  $new_page_object = new ilPageObject('shop');
120  $new_page_object->setParentId(0);
121  $new_page_object->setId($this->pobject->getPobjectId());
122  $new_page_object->createFromXML();
123  }
124 
125  $this->ctrl->setReturnByClass('ilpageobjectgui', 'edit');
126 
127  $page_gui = new ilPageObjectGUI('shop', $this->pobject->getPobjectId());
128  $this->ctrl->setParameter($page_gui, 'pobject_id', (int)$_GET['pobject_id']);
129  $page_gui->setIntLinkHelpDefault('StructureObject', $this->pobject->getPobjectId());
130  $page_gui->setTemplateTargetVar('ADM_CONTENT');
131  $page_gui->setLinkXML('');
132  $page_gui->setFileDownloadLink($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'downloadFile'));
133  $page_gui->setFullscreenLink($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'displayMediaFullscreen'));
134  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'download_paragraph'));
135  $page_gui->setPresentationTitle('');
136  $page_gui->setTemplateOutput(false);
137  $page_gui->setHeader('');
138  $page_gui->setEnabledRepositoryObjects(false);
139  $page_gui->setEnabledFileLists(true);
140  $page_gui->setEnabledMaps(true);
141  $page_gui->setEnabledPCTabs(true);
142 
143  return $this->ctrl->forwardCommand($page_gui);
144  }
145 
146  function showObjects()
147  {
148  $this->showButton('showObjectSelector', $this->lng->txt('paya_sell_object'));
149 
150  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.paya_objects.html', 'payment');
151 
152  if(!count($objects = ilPaymentObject::_getObjectsData($this->user_obj->getId())))
153  {
154  ilUtil::sendInfo($this->lng->txt('paya_no_objects_assigned'));
155 
156  return true;
157  }
158 
159  $this->__initPaymentObject();
160 
161 
162  $img_change = "<img src=\"".ilUtil::getImagePath("edit.gif")."\" alt=\"".
163  $this->lng->txt("edit")."\" title=\"".$this->lng->txt("edit").
164  "\" border=\"0\" vspace=\"0\"/>";
165 
166  $counter = 0;
167  foreach($objects as $data)
168  {
169 
170 
171  $tmp_obj = ilObjectFactory::getInstanceByRefId($data['ref_id'], false);
172 
173  if($tmp_obj)
174  {
175  $trash = '';
176  if(ilObject::_isInTrash($data['ref_id']))
177  {
178  $trash = '('.$this->lng->txt('object_deleted').')';
179  }
180  $f_result[$counter][] = $tmp_obj->getTitle().' '.$trash;
181 
182  }
183  else
184  {
185  $f_result[$counter][] = $this->lng->txt('object_not_found');
186  }
187 
188 
189  switch($data['status'])
190  {
191  case $this->pobject->STATUS_BUYABLE:
192  $f_result[$counter][] = $this->lng->txt('paya_buyable');
193  break;
194 
195  case $this->pobject->STATUS_NOT_BUYABLE:
196  $f_result[$counter][] = $this->lng->txt('paya_not_buyable');
197  break;
198 
199  case $this->pobject->STATUS_EXPIRES:
200  $f_result[$counter][] = $this->lng->txt('paya_expires');
201  break;
202  }
203  switch($data['pay_method'])
204  {
205  case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
206  $f_result[$counter][] = $this->lng->txt('paya_pay_method_not_specified');
207  break;
208 
209  case $this->pobject->PAY_METHOD_BILL:
210  $f_result[$counter][] = $this->lng->txt('pays_bill');
211  break;
212 
213  case $this->pobject->PAY_METHOD_BMF:
214  $f_result[$counter][] = $this->lng->txt('pays_bmf');
215  break;
216 
217  case $this->pobject->PAY_METHOD_PAYPAL:
218  $f_result[$counter][] = $this->lng->txt('pays_paypal');
219  break;
220 
221  case $this->pobject->PAY_METHOD_EPAY:
222  $f_result[$counter][] = $this->lng->txt('pays_epay');
223  break;
224  }
225 
226  if($data['vat_id'] <= 0)
227  {
228 
229  $vat_rate = $this->lng->txt('payment_vat_has_to_be_defined_by_administration_short');
230  }
231  else
232  {
233 
234  try
235  {
236  $oVAT = new ilShopVats((int)$data['vat_id']);
237  $vat_rate = ilShopUtils::_formatVAT((float)$oVAT->getRate());
238  }
239  catch(ilShopException $e)
240  {
241  $vat_rate = $this->lng->txt('payment_vat_has_to_be_defined_by_administration_short');
242  }
243 
244  }
245 
246 
247  $f_result[$counter][] = $vat_rate;
248 
249 
250  $tmp_user =& ilObjectFactory::getInstanceByObjId($data['vendor_id']);
251  $f_result[$counter][] = $tmp_user->getFullname().' ['.$tmp_user->getLogin().']';
252 
253  // Get number of purchasers
254 
255  $f_result[$counter][] = ilPaymentBookings::_getCountBookingsByObject($data['pobject_id']);
256 
257 
258  // edit link
259  $this->ctrl->setParameter($this,'pobject_id',$data['pobject_id']);
260 # $link_change = "<a href=\"".$this->ctrl->getLinkTarget($this,"editDetails")."\"> ".
261 # $img_change."</a>";
262  $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editDetails")."\">".$this->lng->txt("edit")."</a></div>";
263 
264  $f_result[$counter][] = $link_change;
265  unset($tmp_user);
266  unset($tmp_obj);
267 
268  ++$counter;
269  }
270 
271  return $this->__showObjectsTable($f_result);
272  }
273 
274  function editDetails($a_show_confirm = false)
275  {
276  global $ilToolbar;
277 
278  if(!(int)$_GET['pobject_id'])
279  {
280  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
281  return $this->showObjects();
282  }
283 
284  $this->__initPaymentObject((int)$_GET['pobject_id']);
285 
286  $this->ctrl->setParameter($this,'pobject_id', (int)$_GET['pobject_id']);
287 
288  $this->showButton('editDetails', $this->lng->txt('paya_edit_details'));
289 
290  $this->showButton('editPrices', $this->lng->txt('paya_edit_prices'));
291 
292  $ilToolbar->addButton($this->lng->txt('pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'edit'));
293 
294  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_edit.html','payment');
295  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.shop_content.html', 'Services/Payment');
296 
297  if($a_show_confirm)
298  {
299  $this->tpl->setCurrentBlock('confirm_delete');
300  $this->tpl->setVariable('CONFIRM_FORMACTION',$this->ctrl->getFormAction($this));
301  $this->tpl->setVariable('TXT_CANCEL',$this->lng->txt('cancel'));
302  $this->tpl->setVariable('CONFIRM_CMD','performDelete');
303  $this->tpl->setVariable('TXT_CONFIRM',$this->lng->txt('confirm'));
304  $this->tpl->parseCurrentBlock();
305  }
306 
307  $tmp_obj = ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
308  if($tmp_obj)
309  {
310  $tmp_object['title'] = $tmp_obj->getTitle();
311  $tmp_object['type'] = $tmp_obj->getType();
312  }
313  else
314  {
315  $tmp_object['title'] = $this->lng->txt('object_not_found');
316  $tmp_object['type'] = '';
317  }
318  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
319  $oForm = new ilPropertyFormGUI();
320  $oForm->setFormAction($this->ctrl->getFormAction($this, 'updateDetails'));
321 
322  $oForm->setTitle($tmp_object['title']);
323  $oForm->setTitleIcon(ilUtil::getImagePath('icon_'.$tmp_object['type'].'_b.gif'));
324 
325  // repository path
326  $oPathGUI = new ilNonEditableValueGUI($this->lng->txt('path'));
327  $oPathGUI->setValue($this->__getHTMLPath($this->pobject->getRefId()));
328  $oForm->addItem($oPathGUI);
329 
330  // number of purchasers
331  $oPurchasersGUI = new ilNonEditableValueGUI($this->lng->txt('paya_count_purchaser'));
332  $oPurchasersGUI->setValue(ilPaymentBookings::_getCountBookingsByObject((int)$_GET['pobject_id']));
333  $oForm->addItem($oPurchasersGUI);
334 
335  // vendors
336  $oVendorsGUI = new ilSelectInputGUI($this->lng->txt('paya_vendor'), 'vendor');
337  $oVendorsGUI->setOptions($this->__getVendors());
338  $oVendorsGUI->setValue($this->pobject->getVendorId());
339  $oForm->addItem($oVendorsGUI);
340 
341  // status
342  $oStatusGUI = new ilSelectInputGUI($this->lng->txt('status'), 'status');
343  $oStatusGUI->setOptions($this->__getStatus());
344  $oStatusGUI->setValue($this->pobject->getStatus());
345  $oForm->addItem($oStatusGUI);
346 
347  // pay methods
348  $oPayMethodsGUI = new ilSelectInputGUI($this->lng->txt('paya_pay_method'), 'pay_method');
349  $oPayMethodsGUI->setOptions($this->__getPayMethods());
350  $oPayMethodsGUI->setValue($this->pobject->getPayMethod());
351  $oForm->addItem($oPayMethodsGUI);
352 
353  // topics
354  ilShopTopics::_getInstance()->read();
355  if(is_array($topics = ilShopTopics::_getInstance()->getTopics()) && count($topics))
356  {
357  $oTopicsGUI = new ilSelectInputGUI($this->lng->txt('topic'), 'topic_id');
358  include_once 'Services/Payment/classes/class.ilShopTopics.php';
359  ilShopTopics::_getInstance()->read();
360  $topic_options = array();
361  $topic_options[''] = $this->lng->txt('please_choose');
362 
363  foreach($topics as $oTopic)
364  {
365  $topic_options[$oTopic->getId()] = $oTopic->getTitle();
366  }
367 
368  $oTopicsGUI->setOptions($topic_options);
369  $oTopicsGUI->setValue($this->pobject->getTopicId());
370  $oForm->addItem($oTopicsGUI);
371  }
372 
373  // vats
374  $oShopVatsList = new ilShopVatsList();
375  $oShopVatsList->read();
376  if($oShopVatsList->hasItems())
377  {
378  $oVatsGUI = new ilSelectInputGUI($this->lng->txt('vat_rate'), 'vat_id');
379 
380  $vats_options = array();
381  foreach($oShopVatsList as $oVAT)
382  {
383  $vats_options[$oVAT->getId()] = ilShopUtils::_formatVAT($oVAT->getRate()).' -> '.$oVAT->getTitle();
384  }
385 
386  $oVatsGUI->setOptions($vats_options);
387  $oVatsGUI->setValue($this->pobject->getVatId());
388  $oForm->addItem($oVatsGUI);
389  }
390  else
391  {
392  $oVatsGUI = new ilNonEditableValueGUI($this->lng->txt('vat_rate'));
393  $oVatsGUI->setValue($this->lng->txt('paya_no_vats_assigned'));
394  $oForm->addItem($oVatsGUI);
395  }
396 
397  $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail');
398  $oFile = new ilFileDataShop($this->pobject->getPobjectId());
399  if(($webpath_file = $oFile->getCurrentImageWebPath()) !== false)
400  {
401  $oThumbnail->setImage($webpath_file);
402  }
403  $oForm->addItem($oThumbnail);
404 
405  // buttons
406  $oForm->addCommandButton('updateDetails', $this->lng->txt('save'));
407  $oForm->addCommandButton('deleteObject', $this->lng->txt('delete'));
408 
409  $this->tpl->setVariable('PAYMENT_OBJECT_FORM', $oForm->getHTML());
410  }
411 
412  function deleteObject()
413  {
414  include_once './payment/classes/class.ilPaymentBookings.php';
415 
416  if(!$_GET['pobject_id'])
417  {
418  ilUtil::sendFailure($this->lng->txt('paya_no_object_selected'));
419 
420  $this->showObjects();
421  return true;
422  }
423  if(ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']))
424  {
425  ilUtil::sendInfo($this->lng->txt('paya_bookings_available'));
426  $this->editDetails();
427 
428  return false;
429  }
430  else
431  {
432  ilUtil::sendQuestion($this->lng->txt('paya_sure_delete_object'));
433  $this->editDetails(true);
434 
435  return true;
436  }
437  }
438 
439  function performDelete()
440  {
441  include_once './payment/classes/class.ilPaymentPrices.php';
442  include_once './payment/classes/class.ilPaymentBillVendor.php';
443 
444  if(!$_GET['pobject_id'])
445  {
446  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
447 
448  $this->showObjects();
449  return true;
450  }
451  $this->__initPaymentObject((int) $_GET['pobject_id']);
452 
453  // delete object data
454  $this->pobject->delete();
455 
456  // delete payment prices
457  $price_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
458  $price_obj->deleteAllPrices();
459  unset($price_obj);
460 
461  $bv =& new ilPaymentBillVendor((int) $_GET['pobject_id']);
462  $bv->delete();
463  unset($bv);
464 
465  // delete bill vendor data if exists
466  ilUtil::sendInfo($this->lng->txt('paya_deleted_object'));
467 
468  $this->showObjects();
469 
470  return true;
471  }
472 
473  function editPayMethod()
474  {
475  $this->__initPaymentObject((int) $_GET['pobject_id']);
476 
477  switch($this->pobject->getPayMethod())
478  {
479  case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
480  ilUtil::sendFailiure($this->lng->txt('paya_select_pay_method_first'));
481  $this->editDetails();
482 
483  return true;
484  case $this->pobject->PAY_METHOD_BILL:
485  ilUtil::sendInfo($this->lng->txt('paya_no_settings_necessary'));
486  $this->editDetails();
487 
488  return true;
489  case $this->pobject->PAY_METHOD_BMF:
490  ilUtil::sendInfo($this->lng->txt('paya_no_settings_necessary'));
491  $this->editDetails();
492 
493  return true;
494  case $this->pobject->PAY_METHOD_PAYPAL:
495  ilUtil::sendInfo($this->lng->txt('paya_no_settings_necessary'));
496  $this->editDetails();
497 
498  return true;
499  }
500 
501  $this->editDetails();
502 
503  return true;
504  }
505 
506  function editPrices($a_show_delete = false)
507  {
508  if($a_show_delete == false) unset($_SESSION['price_ids']);
509 
510  include_once './payment/classes/class.ilPaymentPrices.php';
511  include_once './payment/classes/class.ilPaymentCurrency.php';
512  include_once './Services/Table/classes/class.ilTableGUI.php';
513  include_once './payment/classes/class.ilGeneralSettings.php';
514 
515  $genSet = new ilGeneralSettings();
516 
517  $_SESSION['price_ids'] = $_SESSION['price_ids'] ? $_SESSION['price_ids'] : array();
518 
519  if(!$_GET['pobject_id'])
520  {
521  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
522 
523  $this->objectsObject();
524  return true;
525  }
526  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
527 
528 
529  $this->__showButton('showObjects',$this->lng->txt('back'));
530  $this->__showButton('editDetails',$this->lng->txt('paya_edit_details'));
531  $this->__showButton('editPrices',$this->lng->txt('paya_edit_prices'));
532 
533  // edit abstract
534  $this->tpl->setCurrentBlock('btn_cell');
535  $this->tpl->setVariable('BTN_LINK', $this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'edit'));
536  $this->tpl->setVariable('BTN_TXT', $this->lng->txt('pay_edit_abstract'));
537  $this->tpl->parseCurrentBlock();
538 
539  $this->__initPaymentObject((int) $_GET['pobject_id']);
540 
541  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content",'tpl.paya_edit_prices.html','payment');
542  $price_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
543  $prices = $price_obj->getPrices();
544 
545  // No prices created
546  if(!count($prices))
547  {
548  ilUtil::sendInfo($this->lng->txt('paya_no_price_available'));
549 
550  $this->tpl->setCurrentBlock('price_info');
551  $this->tpl->setVariable('CONFIRM_FORMACTION',$this->ctrl->getFormAction($this));
552  $this->tpl->setVariable('CONFIRM_CMD','addPrice');
553  $this->tpl->setVariable('TXT_CONFIRM',$this->lng->txt('paya_add_price'));
554  $this->tpl->parseCurrentBlock();
555 
556  return true;
557  }
558  // Show confirm delete
559  if($a_show_delete)
560  {
561  ilUtil::sendQuestion($this->lng->txt('paya_sure_delete_selected_prices'));
562 
563  $this->tpl->setCurrentBlock('cancel');
564  $this->tpl->setVariable('CANCEL_CMD','editPrices');
565  $this->tpl->setVariable('TXT_CANCEL',$this->lng->txt('cancel'));
566  $this->tpl->parseCurrentBlock();
567 
568  $this->tpl->setCurrentBlock('price_info');
569  $this->tpl->setVariable('CONFIRM_FORMACTION',$this->ctrl->getFormAction($this));
570  $this->tpl->setVariable('CONFIRM_CMD','performDeletePrice');
571  $this->tpl->setVariable('TXT_CONFIRM',$this->lng->txt('paya_delete_price'));
572  $this->tpl->parseCurrentBlock();
573 
574  }
575 
576  // Fill table cells
577  $tpl =& new ilTemplate('tpl.table.html',true,true);
578 
579  // set table header
580  $tpl->setCurrentBlock('tbl_form_header');
581 
582  $tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
583  $tpl->parseCurrentBlock();
584 
585  $counter = 0;
586  foreach($prices as $price)
587  {
588  $currency = ilPaymentCurrency::_getCurrency($price['currency']);
589  if($a_show_delete == true )
590  {
591  $this->ctrl->setParameter($this, 'show_delete', 'true');
592 
593  if(in_array($price['price_id'],$_SESSION['price_ids']))
594  {
595 
596  $data[$counter]['price_id'] = '';
597  $data[$counter]['duration'] =$price['duration'] ;
598  $data[$counter]['month'] = $this->lng->txt('paya_months');
599 
600  $data[$counter]['unlimited_duration'] = ilUtil::formCheckBox($price['unlimited_duration'] ? 1 : 0,
601  'duration_ids[]', (int)$price['price_id']);
602 
603  $data[$counter]['price'] = ilFormat::_getLocalMoneyFormat($price['price']);
604  $data[$counter]['currency_unit'] = $genSet->get('currency_unit');
605  }
606  }
607  else
608  {
609  $data[$counter]['price_id'] = ilUtil::formCheckBox(in_array($price['price_id'],$_SESSION['price_ids']) ? 1 : 0,
610  'price_ids[]', $price['price_id']);
611 
612  $data[$counter]['duration'] = ilUtil::formInput('prices['.$price['price_id'].'][duration]',$price['duration']);
613  $data[$counter]['month'] = $this->lng->txt('paya_months');
614 
615  $data[$counter]['unlimited_duration'] = ilUtil::formCheckBox($price['unlimited_duration'] ? 1 : 0,
616  'duration_ids[]', (int)$price['price_id']);
617 
618  $data[$counter]['price'] = ilUtil::formInput('prices['.$price['price_id'].'][price]', ilFormat::_getLocalMoneyFormat($price['price']));
619  $data[$counter]['currency_unit'] = $genSet->get('currency_unit');
620  }
621  ++$counter;
622  }
623  $this->__editPricesTable($data);
624 
625  return true;
626  }
627 
628  function __editPricesTable($a_result_set)
629  {
630  $tpl =& new ilTemplate('tpl.table.html',true,true);
631 
632  $parmeter = $this->ctrl->getParameterArray($this, 'show_delete');
633 
634  if(!$parmeter['show_delete'])
635  {
636  // SET FOOTER
637  $tpl->setCurrentBlock("tbl_action_btn");
638  $tpl->setVariable("BTN_NAME","deletePrice");
639  $tpl->setVariable("BTN_VALUE",$this->lng->txt("paya_delete_price"));
640  $tpl->parseCurrentBlock();
641 
642  $tpl->setCurrentBlock("plain_buttons");
643  $tpl->setVariable("PBTN_NAME","addPrice");
644  $tpl->setVariable("PBTN_VALUE",$this->lng->txt("paya_add_price"));
645  $tpl->parseCurrentBlock();
646 
647  $tpl->setCurrentBlock("plain_buttons");
648  $tpl->setVariable("PBTN_NAME","updatePrice");
649  $tpl->setVariable("PBTN_VALUE",$this->lng->txt("paya_update_price"));
650  $tpl->parseCurrentBlock();
651 
652  $tpl->setCurrentBlock("tbl_action_row");
653  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
654  $tpl->setVariable("COLUMN_COUNTS",6);
655  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
656  $tpl->parseCurrentBlock();
657  }
658  $tbl = new ilTableGUI();
659  $tbl->setTemplate($tpl);
660 
661  // SET FORMAACTION
662  $tpl->setCurrentBlock("tbl_form_header");
663  $this->ctrl->setParameter($this, 'cmd', 'editprices');
664 
665  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
666  $tpl->parseCurrentBlock();
667 
668  $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
669  if($tmp_obj)
670  {
671  $tbl->setTitle($tmp_obj->getTitle(),
672  'icon_'.$tmp_obj->getType().'_b.gif',
673  $this->lng->txt('objs_'.$tmp_obj->getType()));
674  }
675  else
676  {
677  $tbl->setTitle($this->lng->txt('object_not_found'));
678  }
679  $tbl->setHeaderNames(array( '',
680  $this->lng->txt("duration"),
681  '',
682  $this->lng->txt("unlimited_duration"),
683  $this->lng->txt("price_a"),
684  ''),
685  '');
686  $header_params = $this->ctrl->getParameterArray($this,'');
687  $tbl->setHeaderVars(array( "price_id",
688  "duration",
689  "month",
690  "unlimited_duration",
691  "price",
692  "currency_unit",
693  "options"),$header_params);
694  $tbl->setColumnWidth(array('5%', "10%","10%","15%","15%","50%"));
695 
696  $offset = $_GET["offset"];
697  if($_GET["sort_by"] == NULL) $order = 'duration';
698  else $order = $_GET["sort_by"];
699  $direction = $_GET["sort_order"];
700 
701  $tbl->setOrderColumn($order);
702  $tbl->setOrderDirection($direction);
703  $tbl->setOffset($offset);
704  $tbl->setLimit($_GET["limit"]);
705  $tbl->setMaxCount(count($a_result_set));
706  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
707  $tbl->setData($a_result_set);
708 
709  $tbl->render();
710 
711  $this->tpl->setVariable("PRICES_TABLE",$tbl->tpl->get());
712 
713  return true;
714 
715  }
716 
717  function addPrice()
718  {
719  if(!$_GET['pobject_id'])
720  {
721  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
722 
723  $this->showObjects();
724  return true;
725  }
726 
727  include_once './payment/classes/class.ilGeneralSettings.php';
728 
729  $genSet = new ilGeneralSettings();
730 
731  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
732 
733  $this->__initPaymentObject((int) $_GET['pobject_id']);
734 
735  $this->showButton('editDetails',$this->lng->txt('paya_edit_details'));
736  $this->showButton('editPrices',$this->lng->txt('paya_edit_prices'));
737 # $this->__showPayMethodLink();
738 
739  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_add_price.html','payment');
740 
741  $this->tpl->setVariable('ADD_FORMACTION',$this->ctrl->getFormAction($this));
742 
743  $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
744  if($tmp_obj)
745  {
746  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$tmp_obj->getType().'_b.gif'));
747  $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_'.$tmp_obj->getType()));
748  $this->tpl->setVariable('TITLE',$tmp_obj->getTitle());
749  $this->tpl->setVariable('DESCRIPTION',$this->lng->txt('paya_add_price_title'));
750  }
751  else
752  {
753  $this->tpl->setVariable('TITLE',$this->lng->txt('object_not_found'));
754  }
755  // TODO show curency selector
756 # $this->tpl->setVariable('TXT_PRICE_A',$this->lng->txt('currency_euro'));
757 # $this->tpl->setVariable('TXT_PRICE_B',$this->lng->txt('currency_cent'));
758  $this->tpl->setVariable('TXT_PRICE_A',$genSet->get('currency_unit'));
759  //$this->tpl->setVariable('TXT_PRICE_B',$genSet->get('currency_subunit'));
760 
761  $this->tpl->setVariable('MONTH',$this->lng->txt('paya_months'));
762  $this->tpl->setVariable('TXT_UNLIMITED_DURATION', $this->lng->txt('unlimited_duration'));
763 
764  $this->tpl->setVariable('TXT_DURATION',$this->lng->txt('duration'));
765  $this->tpl->setVariable('TXT_PRICE',$this->lng->txt('price_a'));
766  $this->tpl->setVariable('CANCEL',$this->lng->txt('cancel'));
767  $this->tpl->setVariable('ADD',$this->lng->txt('paya_add_price'));
768 
769  $this->tpl->setVariable('DURATION',$_POST['duration']);
770  $this->tpl->setVariable('UNLIMITED_DURATION', $_POST['unlimited_duration']);
771 
772  $this->tpl->setVariable('PRICE',$_POST['price']);
773  return true;
774  }
775 
776  function performAddPrice()
777  {
778 
779  if(!$_GET['pobject_id'])
780  {
781  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
782 
783  $this->showObjects();
784  return true;
785  }
786 
787  include_once './payment/classes/class.ilPaymentPrices.php';
788  include_once './payment/classes/class.ilPaymentCurrency.php';
789 
791 
792  $prices =& new ilPaymentPrices((int) $_GET['pobject_id']);
793 
794  $prices->setDuration($_POST['duration']);
795  $prices->setUnlimitedDuration($_POST['unlimited_duration']);
796  if($_POST['unlimited_duration'] == '1')
797  {
798  $prices->setUnlimitedDuration(1);
799  }
800 
801  $prices->setPrice($_POST['price']);
802  $prices->setCurrency($currency[1]['currency_id']);
803 
804 
805  if(!$prices->validate())
806  {
807  ilUtil::sendInfo($this->lng->txt('paya_price_not_valid'));
808  $this->addPrice();
809 
810  return true;
811  }
812  $prices->add();
813 
814  ilUtil::sendSuccess($this->lng->txt('paya_added_new_price'));
815  $this->editPrices();
816 
817  return true;
818  }
819 
821  {
822  if(!$_GET['pobject_id'])
823  {
824  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
825 
826  $this->showObjects();
827  return true;
828  }
829 
830  if(!count($_SESSION['price_ids']))
831  {
832  ilUtil::sendInfo($this->lng->txt('paya_no_prices_selected'));
833 
834  $this->editPrices();
835  return true;
836  }
837  include_once './payment/classes/class.ilPaymentPrices.php';
838 
839  $prices =& new ilPaymentPrices((int) $_GET['pobject_id']);
840 
841  foreach($_SESSION['price_ids'] as $price_id)
842  {
843  $prices->delete($price_id);
844  }
845 
846  // check if it was last price otherwise set status to 'not_buyable'
847  if(!count($prices->getPrices()))
848  {
849  $this->__initPaymentObject((int) $_GET['pobject_id']);
850 
851  $this->pobject->setStatus($this->pobject->STATUS_NOT_BUYABLE);
852  $this->pobject->update();
853 
854  ilUtil::sendInfo($this->lng->txt('paya_deleted_last_price'));
855  }
856  unset($prices);
857  unset($_SESSION['price_ids']);
858 
859  return $this->editPrices();
860  }
861 
862 
863  function deletePrice()
864  {
865  if(!$_GET['pobject_id'])
866  {
867  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
868 
869  $this->showObjects();
870  return true;
871  }
872 
873  if(!count($_POST['price_ids']))
874  {
875  ilUtil::sendInfo($this->lng->txt('paya_no_prices_selected'));
876 
877  $this->editPrices();
878  return true;
879  }
880  $_SESSION['price_ids'] = $_POST['price_ids'];
881 
882  $this->editPrices(true);
883  return true;
884  }
885 
886  function updatePrice()
887  {
888  include_once './payment/classes/class.ilPaymentPrices.php';
889 
890  if(!$_GET['pobject_id'])
891  {
892  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
893 
894  $this->showObjects();
895  return true;
896  }
897  $po =& new ilPaymentPrices((int) $_GET['pobject_id']);
898 
899  $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
900 
901  // validate
902  foreach($_POST['prices'] as $price_id => $price)
903  {
904  $old_price = $po->getPrice($price_id);
905 
906  $po->setDuration($price['duration']);
907  $po->setUnlimitedDuration($price['unlimited_duration']);
908  $po->setPrice($price['price']);
909  $po->setCurrency($old_price['currency']);
910 
911  if(!$po->validate())
912  {
913  $error = true;
914  }
915  }
916  if($error)
917  {
918  ilUtil::sendInfo($this->lng->txt('paya_insert_only_numbers'));
919 
920  $this->editPrices();
921  return false;
922  }
923  foreach($_POST['prices'] as $price_id => $price)
924  {
925  $old_price = $po->getPrice($price_id);
926  if(isset($_POST['duration_ids']))
927  {
928 
929  $search = in_array((string)$price_id, $_POST['duration_ids']);
930 
931 
932  if($_POST['duration_ids'] == NULL)
933  {
934  $po->setUnlimitedDuration(0);
935  $po->setDuration($price['duration']);
936 
937  }
938 
939  else if( $search = in_array((string)$price_id, $_POST['duration_ids']))
940  {
941 
942  $po->setUnlimitedDuration(1);
943  $po->setDuration(0);
944  }
945  else
946  {
947  $po->setUnlimitedDuration(0);
948  }
949  }
950 
951  $po->setDuration($price['duration']);
952 
953  $po->setPrice($price['price']);
954  $po->setCurrency($old_price['currency']);
955 
956  $po->update($price_id);
957  }
958  ilUtil::sendInfo($this->lng->txt('paya_updated_prices'));
959  $this->editPrices();
960 
961  return true;
962  }
963 
964 
965  function updateDetails()
966  {
967 
968 
969  if(!$_GET['pobject_id'])
970  {
971  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
972 
973  $this->showObjects();
974  return true;
975  }
976  $this->__initPaymentObject((int)$_GET['pobject_id']);
977  $this->ctrl->setParameter($this, 'pobject_id', (int)$_GET['pobject_id']);
978 
979  // read old settings
980  $old_pay_method = $this->pobject->getPayMethod();
981  $old_status = $this->pobject->getStatus();
982 
983 
984  // check status changed from not_buyable
985  if($old_status == $this->pobject->STATUS_NOT_BUYABLE and
986  (int) $_POST['status'] != $old_status)
987  {
988  // check pay_method edited
989  switch((int) $_POST['pay_method'])
990  {
991  case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
992  ilUtil::sendInfo($this->lng->txt('paya_select_pay_method_first'));
993  $this->editDetails();
994 
995  return false;
996 
997  default:
998  ;
999  }
1000  // check minimum one price
1001  include_once './payment/classes/class.ilPaymentPrices.php';
1002 
1003  $prices_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
1004  if(!count($prices_obj->getPrices()))
1005  {
1006  ilUtil::sendInfo($this->lng->txt('paya_edit_prices_first'));
1007  $this->editDetails();
1008 
1009  return false;
1010  }
1011 
1012  }
1013 
1014  $this->pobject->setStatus((int)$_POST['status']);
1015  $this->pobject->setVendorId((int)$_POST['vendor']);
1016  $this->pobject->setPayMethod((int)$_POST['pay_method']);
1017  $this->pobject->setTopicId((int)$_POST['topic_id']);
1018  $this->pobject->setVatId((int)$_POST['vat_id']);
1019  //$this->pobject->setVatRate((float) $_POST['vat_rate']);
1020 
1021  if((int)$_POST['thumbnail_delete'])
1022  {
1023  $oFile = new ilFileDataShop($this->pobject->getPobjectId());
1025  }
1026  else if($_FILES['thumbnail']['tmp_name'] != '')
1027  {
1028  $this->lng->loadLanguageModule('form');
1029  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1030  $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail');
1031  if($oThumbnail->checkInput())
1032  {
1033  $oFile = new ilFileDataShop($this->pobject->getPobjectId());
1034  if(($oFile->storeUploadedFile($_FILES['thumbnail'])) !== false)
1035  {
1036  $oFile->assignFileToPaymentObject();
1037  }
1038  }
1039  else
1040  {
1041  ilUtil::sendInfo($oThumbnail->getAlert());
1042  return $this->editDetails();
1043  }
1044  }
1045 
1046  $this->pobject->update();
1047 
1048  ilUtil::sendInfo($this->lng->txt('paya_details_updated'));
1049  //$this->editDetails();
1050  $this->showObjects();
1051 
1052  return true;
1053  }
1054 
1056  {
1057  global $tree;
1058 
1059  include_once './payment/classes/class.ilPaymentObjectSelector.php';
1060 
1061  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.paya_object_selector.html','payment');
1062  $this->showButton('showObjects',$this->lng->txt('back'));
1063 
1064 
1065  ilUtil::sendInfo($this->lng->txt('paya_select_object_to_sell'));
1066 
1067  $exp = new ilPaymentObjectSelector($this->ctrl->getLinkTarget($this,'showObjectSelector'), strtolower(get_class($this)));
1068  $exp->setExpand($_GET['paya_link_expand'] ? $_GET['paya_link_expand'] : $tree->readRootId());
1069  $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showObjectSelector'));
1070 
1071  $exp->setOutput(0);
1072 
1073  $this->tpl->setVariable("EXPLORER",$exp->getOutput());
1074 
1075  return true;
1076  }
1077 
1079  {
1080  if(!(int)$_GET['sell_id'])
1081  {
1082  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
1083  return $this->showObjectSelector();
1084  }
1085 
1086  $this->showButton('showObjectSelector',$this->lng->txt('back'));
1087 
1088  // save ref_id of selected object
1089  $this->ctrl->setParameter($this, 'sell_id', (int)$_GET['sell_id']);
1090 
1091  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1092  $oForm = new ilPropertyFormGUI();
1093  $oForm->setFormAction($this->ctrl->getFormAction($this, 'updateDetails'));
1094  $oForm->setTitle($this->lng->txt('details'));
1095  $oForm->setTitleIcon(ilUtil::getImagePath('icon_pays.gif', false));
1096 
1097  $tmp_obj = ilObjectFactory::getInstanceByRefId($_GET['sell_id'], false);
1098  if(is_object($tmp_obj))
1099  {
1100  $tmp_object['title'] = $tmp_obj->getTitle();
1101  $tmp_object['description'] = $tmp_obj->getDescription();
1102  $tmp_object['owner'] = $tmp_obj->getOwnerName();
1103  }
1104  else
1105  {
1106  $tmp_object['title'] = $this->lng->txt('object_not_found');
1107  $tmp_object['description'] = '';
1108  $tmp_object['owner'] = '';
1109 
1110  }
1111  // title
1112  $oTitleGUI = new ilNonEditableValueGUI($this->lng->txt('title'));
1113  $oTitleGUI->setValue($tmp_object['title']);
1114  $oForm->addItem($oTitleGUI);
1115 
1116  // description
1117  $oDescriptionGUI = new ilNonEditableValueGUI($this->lng->txt('description'));
1118  $oDescriptionGUI->setValue($tmp_object['description']);
1119  $oForm->addItem($oDescriptionGUI);
1120 
1121  // owner
1122  $oOwnerGUI = new ilNonEditableValueGUI($this->lng->txt('owner'));
1123  $oOwnerGUI->setValue($tmp_object['owner']);
1124  $oForm->addItem($oOwnerGUI);
1125 
1126  // path
1127  $oPathGUI = new ilNonEditableValueGUI($this->lng->txt('paya_count_purchaser'));
1128  $oPathGUI->setValue($this->__getHTMLPath((int)$_GET['sell_id']));
1129  $oForm->addItem($oPathGUI);
1130 
1131  // vendors
1132  $oVendorsGUI = new ilSelectInputGUI($this->lng->txt('paya_vendor'), 'vendor');
1133  $oVendorsGUI->setOptions($this->__getVendors());
1134  $oForm->addItem($oVendorsGUI);
1135 
1136  // buttons
1137  $oForm->addCommandButton('addObject', $this->lng->txt('next'));
1138  $oForm->addCommandButton('showObjects', $this->lng->txt('cancel'));
1139 
1140  $this->tpl->setVariable('ADM_CONTENT', $oForm->getHTML());
1141  }
1142 
1143  function addObject()
1144  {
1145  if(!$_GET['sell_id'])
1146  {
1147  ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
1148 
1149  return $this->showObjectSelector();
1150  }
1151  if(!(int)$_POST['vendor'])
1152  {
1153  ilUtil::sendInfo($this->lng->txt('paya_no_vendor_selected'));
1154 
1155  return $this->showSelectedObject();
1156  }
1157  if(!ilPaymentObject::_isPurchasable($_GET['sell_id']))
1158  {
1159  ilUtil::sendInfo($this->lng->txt('paya_object_not_purchasable'));
1160 
1161  return $this->showObjectSelector();
1162  }
1163 
1164  include_once 'payment/classes/class.ilPaymentObject.php';
1165 
1166  $p_obj = new ilPaymentObject($this->user_obj);
1167 
1168  $p_obj->setRefId((int)$_GET['sell_id']);
1169  $p_obj->setStatus($p_obj->STATUS_NOT_BUYABLE);
1170  $p_obj->setPayMethod($p_obj->PAY_METHOD_NOT_SPECIFIED);
1171  $p_obj->setVendorId((int)$_POST['vendor']);
1172  $p_obj->setTopicId((int)$_POST['topic_id']);
1173  //$p_obj->setVatRate((float)$_POST['vat_rate']);
1174  $p_obj->setVatId((int)$_POST['vat_id']);
1175 
1176 
1177  if($new_id = $p_obj->add())
1178  {
1179  ilUtil::sendInfo($this->lng->txt('paya_added_new_object'));
1180  $_GET['pobject_id'] = $new_id;
1181  return $this->editDetails();
1182  //return $this->addPrice();
1183  }
1184  else
1185  {
1186  ilUtil::sendInfo($this->lng->txt('paya_err_adding_object'));
1187  return $this->showObjects();
1188  }
1189  }
1190 
1191  private function __getVendors()
1192  {
1193  include_once 'payment/classes/class.ilPaymentVendors.php';
1194 
1195  $options = array();
1196  $vendors = array();
1197  if(ilPaymentVendors::_isVendor($this->user_obj->getId()))
1198  {
1199  $vendors[] = $this->user_obj->getId();
1200  }
1201  if($vend = ilPaymentTrustees::_getVendorsForObjects($this->user_obj->getId()))
1202  {
1203  $vendors = array_merge($vendors, $vend);
1204  }
1205  foreach($vendors as $vendor)
1206  {
1207  $tmp_obj = ilObjectFactory::getInstanceByObjId($vendor, false);
1208  $options[$vendor] = $tmp_obj->getFullname().' ['.$tmp_obj->getLogin().']';
1209  }
1210 
1211  return $options;
1212  }
1213 
1214 
1215  private function __getStatus()
1216  {
1217 
1218  $option = array();
1219  $option[$this->pobject->STATUS_NOT_BUYABLE] = $this->lng->txt('paya_not_buyable');
1220  $option[$this->pobject->STATUS_BUYABLE] = $this->lng->txt('paya_buyable');
1221  $option[$this->pobject->STATUS_EXPIRES] = $this->lng->txt('paya_expires');
1222 
1223  return $option;
1224  }
1225 
1226  private function __getPayMethods()
1227  {
1228  include_once 'payment/classes/class.ilPayMethods.php';
1229 
1230  $options = array();
1231 
1232  $options[$this->pobject->PAY_METHOD_NOT_SPECIFIED] = $this->lng->txt('paya_pay_method_not_specified');
1233  if(ilPayMethods::_enabled('pm_bill'))
1234  {
1235  $options[$this->pobject->PAY_METHOD_BILL] = $this->lng->txt('pays_bill');
1236  }
1237  if(ilPayMethods::_enabled('pm_bmf'))
1238  {
1239  $options[$this->pobject->PAY_METHOD_BMF] = $this->lng->txt('pays_bmf');
1240  }
1241  if(ilPayMethods::_enabled('pm_paypal'))
1242  {
1243  $options[$this->pobject->PAY_METHOD_PAYPAL] = $this->lng->txt('pays_paypal');
1244  }
1245  if(ilPayMethods::_enabled('pm_epay'))
1246  {
1247  $options[$this->pobject->PAY_METHOD_EPAY] = $this->lng->txt('pays_epay');
1248  }
1249 
1250  return $options;
1251  }
1252 
1253 
1254 /*unused*/
1255 /* function __showPayMethodLink()
1256  {
1257  switch($this->pobject->getPayMethod())
1258  {
1259  case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
1260  $this->showButton('editPayMethod',$this->lng->txt('paya_edit_pay_method'));
1261  break;
1262 
1263  case $this->pobject->PAY_METHOD_BILL:
1264  /*
1265  $this->ctrl->setParameterByClass('ilpaymentbilladmingui','pobject_id',(int) $_GET['pobject_id']);
1266  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
1267  $this->tpl->setCurrentBlock("btn_cell");
1268  $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTargetByClass('ilpaymentbilladmingui'));
1269  $this->tpl->setVariable("BTN_TXT",$this->lng->txt('paya_edit_pay_method'));
1270  $this->tpl->parseCurrentBlock();
1271  */
1272 /* $this->showButton('editPayMethod',$this->lng->txt('paya_edit_pay_method'));
1273  break;
1274 
1275  case $this->pobject->PAY_METHOD_BMF:
1276  $this->showButton('editPayMethod',$this->lng->txt('paya_edit_pay_method'));
1277  break;
1278 
1279  case $this->pobject->PAY_METHOD_PAYPAL:
1280  $this->showButton('editPayMethod',$this->lng->txt('paya_edit_pay_method'));
1281  break;
1282  }
1283  }
1284 */
1285  function __showButton($a_cmd,$a_text,$a_target = '')
1286  {
1287  $this->tpl->addBlockfile('BUTTONS', 'buttons', 'tpl.buttons.html');
1288 
1289  // display button
1290  $this->tpl->setCurrentBlock('btn_cell');
1291  $this->tpl->setVariable('BTN_LINK',$this->ctrl->getLinkTarget($this,$a_cmd));
1292  $this->tpl->setVariable('BTN_TXT',$a_text);
1293  if($a_target)
1294  {
1295  $this->tpl->setVariable('BTN_TARGET',$a_target);
1296  }
1297 
1298  $this->tpl->parseCurrentBlock();
1299  }
1300 
1301  function __showObjectsTable($a_result_set)
1302  {
1303  $tbl =& $this->initTableGUI();
1304  $tpl =& $tbl->getTemplateObject();
1305 
1306  // SET FORMAACTION
1307  $tpl->setCurrentBlock('tbl_form_header');
1308 
1309  $tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
1310  $tpl->parseCurrentBlock();
1311 
1312  /*
1313  $tpl->setCurrentBlock("tbl_action_row");
1314  $tpl->setCurrentBlock("plain_buttons");
1315  $tpl->parseCurrentBlock();
1316 
1317  $tpl->setVariable("COLUMN_COUNTS",6);
1318  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1319 
1320  $tpl->setCurrentBlock("tbl_action_button");
1321  $tpl->setVariable("BTN_NAME","deleteTrustee");
1322  $tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
1323  $tpl->parseCurrentBlock();
1324  $tpl->setCurrentBlock("tbl_action_row");
1325  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
1326  $tpl->parseCurrentBlock();
1327  */
1328 
1329  $tbl->setTitle($this->lng->txt('objects'),'icon_pays.gif',$this->lng->txt('objects'));
1330  $tbl->setHeaderNames(array($this->lng->txt('title'),
1331  $this->lng->txt('status'),
1332  $this->lng->txt('paya_pay_method'),
1333  $this->lng->txt('vat_rate'),
1334  $this->lng->txt('paya_vendor'),
1335  $this->lng->txt('paya_count_purchaser'),
1336  ''));
1337  $header_params = $this->ctrl->getParameterArray($this,'');
1338  $tbl->setHeaderVars(array('title',
1339  'status',
1340  'pay_method',
1341  'vat_rate',
1342  'vendor',
1343  'purchasers',
1344  'options'),$header_params);
1345  /*
1346  array('cmd' => '',
1347  'cmdClass' => 'ilpaymentobjectgui',
1348  'cmdNode' => $_GET['cmdNode']));
1349  */
1350  $tbl->setColumnWidth(array('15%','15%','15%','15%','20%','20%'));
1351 
1352 # $this->setTableGUIBasicData($tbl,$a_result_set);
1353 
1354  $offset = $_GET['offset'];
1355  $order = $_GET['sort_by'];
1356  $direction = $_GET['sort_order'] ? $_GET['sort_order'] : 'desc';
1357 
1358  $tbl->setOrderColumn($order,'order_date');
1359  $tbl->setOrderDirection($direction);
1360  $tbl->setOffset($offset);
1361  $tbl->setLimit($_GET['limit']);
1362  $tbl->setMaxCount(count($a_result_set));
1363  $tbl->setFooter('tblfooter',$this->lng->txt('previous'),$this->lng->txt('next'));
1364  $tbl->setData($a_result_set);
1365 
1366  $tbl->render();
1367 
1368  $this->tpl->setVariable('OBJECTS_TABLE',$tbl->tpl->get());
1369 
1370  return true;
1371  }
1372 
1373 
1374  function __getHTMLPath($a_ref_id)
1375  {
1376  global $tree;
1377 
1378  $path = array();
1379  $path = $tree->getPathFull($a_ref_id);
1380  unset($path[0]);
1381  if($path)
1382  {
1383  foreach($path as $data)
1384  {
1385  $html .= $data['title'].' > ';
1386  }
1387  return substr($html,0,-2);
1388  }
1389  else
1390  {
1391  return $this->lng->txt('object_deleted');
1392  }
1393  }
1394 
1395  function __initPaymentObject($a_pobject_id = 0)
1396  {
1397  include_once './payment/classes/class.ilPaymentObject.php';
1398 
1399  $this->pobject =& new ilPaymentObject($this->user_obj,$a_pobject_id);
1400 
1401  return true;
1402  }
1403 }
1404 ?>