• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

payment/classes/class.ilObjPaymentSettingsGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00038 require_once "./classes/class.ilObjectGUI.php";
00039 
00040 class ilObjPaymentSettingsGUI extends ilObjectGUI
00041 {
00042         var $user_obj = null;
00043         var $pobject = null;
00044 
00045         var $section;
00046         var $mainSection;
00047 
00052         function ilObjPaymentSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
00053         {
00054                 global $ilias;
00055 
00056                 $this->user_obj =& $ilias->account;
00057 
00058                 include_once "./payment/classes/class.ilPaymentObject.php";
00059 
00060                 $this->pobject =& new ilPaymentObject($this->user_obj);
00061 
00062 
00063                 $this->type = "pays";
00064                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
00065 
00066                 $this->SECTION_GENERAL = 1;
00067                 $this->SECTION_PAYPAL = 2;
00068                 $this->SETTINGS = 3;
00069                 $this->OTHERS = 0;
00070                 $this->STATISTIC = 4;
00071                 $this->VENDORS = 5;
00072                 $this->PAY_METHODS = 6;
00073                 $this->OBJECTS = 7;
00074                 $this->SECTION_BMF = 8;
00075 
00076                 $this->lng->loadLanguageModule('payment');
00077         }
00078         
00079         function &executeCommand()
00080         {
00081                 $next_class = $this->ctrl->getNextClass($this);
00082                 $cmd = $this->ctrl->getCmd();
00083                 $this->prepareOutput();
00084 
00085                 switch($next_class)
00086                 {
00087                         case 'ilpermissiongui':
00088                                 include_once("./classes/class.ilPermissionGUI.php");
00089                                 $perm_gui =& new ilPermissionGUI($this);
00090                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00091                                 break;
00092 
00093                         default:
00094                                 if ($cmd == "" || $cmd == "view")
00095                                 {
00096                                         $cmd = "generalSettings";
00097                                 }
00098                                 switch ($cmd)
00099                                 {
00100                                         case "vendors" :
00101                                         case "searchUser" :
00102                                         case "search" :
00103                                         case "performSearch" :
00104                                         case "addVendor" :
00105                                         case "exportVendors" :
00106                                         case "performDeleteVendors" :
00107                                         case "cancelDeleteVendors" :
00108                                         case "performEditVendor" :      $this->__setSection($this->OTHERS);
00109                                                                                                 $this->__setMainSection($this->STATISTIC);
00110                                                                                                 $this->tabs_gui->setTabActive("vendors");
00111                                                                                                 break;
00112                                         case "statistic" :
00113                                         case "editStatistic" :
00114                                         case "updateStatistic" :
00115                                         case "deleteStatistic" :
00116                                         case "performDelete" :
00117                                         case "resetFilter" :
00118                                         case "exportVendors" :
00119                                         case "addCustomer" :
00120                                         case "saveCustomer" :
00121                                         case "showObjectSelector" :
00122                                         case "searchUserSP" :
00123                                         case "performSearchSP" :        $this->__setSection($this->OTHERS);
00124                                                                                                 $this->__setMainSection($this->STATISTIC);
00125                                                                                                 $this->tabs_gui->setTabActive("statistic");
00126                                                                                                 break;
00127                                         case "updateObjectDetails" :
00128                                         case "deleteObject" :
00129                                         case "performObjectDelete" :
00130                                         case "objects" :
00131                                         case "editPrices" :
00132                                         case "addPrice" :                                       
00133                                         case "editObject" :
00134                                         case "resetObjectFilter" :
00135                                                                                                 include_once "./payment/classes/class.ilPaymentObject.php";                                                                                             
00136                                                                                                 include_once "./payment/classes/class.ilPaymentBookings.php";
00137                                                                                                 $this->__setSection($this->OTHERS);
00138                                                                                                 $this->__setMainSection($this->OBJECTS);
00139                                                                                                 $this->tabs_gui->setTabActive("objects");
00140                                                                                                 break;
00141                                         case "saveGeneralSettings" :
00142                                         case "generalSettings" :        $this->__setSection($this->SECTION_GENERAL);
00143                                                                                                 $this->__setMainSection($this->SETTINGS);
00144                                                                                                 $this->tabs_gui->setTabActive("settings");
00145                                                                                                 break;
00146                                         case "saveBmfSettings" :
00147                                         case "bmfSettings" :            $this->__setSection($this->SECTION_BMF);
00148                                                                                                 $this->__setMainSection($this->SETTINGS);
00149                                                                                                 $this->tabs_gui->setTabActive("settings");
00150                                                                                                 break;
00151                                         case "savePaypalSettings" :
00152                                         case "paypalSettings" :         $this->__setSection($this->SECTION_PAYPAL);
00153                                                                                                 $this->__setMainSection($this->SETTINGS);
00154                                                                                                 $this->tabs_gui->setTabActive("settings");
00155                                                                                                 break;
00156                                         case "savePayMethods" :         $this->__setSection($this->OTHERS);
00157                                                                                                 $this->__setMainSection($this->PAY_METHODS);
00158                                                                                                 $this->tabs_gui->setTabActive("pay_methods");
00159                                                                                                 break;
00160                                         case "gateway" :                        if ($_POST["action"] == "editVendorObject" ||
00161                                                                                                         $_POST["action"] == "deleteVendorsObject")
00162                                                                                                 {
00163                                                                                                         $this->__setSection($this->OTHERS);
00164                                                                                                         $this->__setMainSection($this->STATISTIC);
00165                                                                                                         $this->tabs_gui->setTabActive("vendors");
00166                                                                                                 }
00167                                                                                                 break;
00168                                         default :                                       $this->__setSection($this->OTHERS);
00169                                                                                                 $this->__setMainSection($this->OTHERS);
00170                                                                                                 break;
00171                                 }
00172                                 $cmd .= "Object";
00173 
00174                                 $this->__buildSettingsButtons();
00175 
00176                                 $this->$cmd();
00177 
00178                                 break;
00179                 }
00180                 return true;
00181         }
00182         
00183         function saveBmfSettingsObject()
00184         {
00185                 global $rbacsystem;
00186 
00187                 // MINIMUM ACCESS LEVEL = 'read'
00188                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
00189                 {
00190                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00191                 }
00192                 
00193                 include_once './payment/classes/class.ilBMFSettings.php';
00194                 
00195                 $this->error = "";
00196                 
00197                 $bmfSetObj = ilBMFSettings::getInstance();                      
00198                 
00199                 $bmfSetObj->setClientId(ilUtil::stripSlashes($_POST["mandantNr"]));
00200                 $bmfSetObj->setBewirtschafterNr(ilUtil::stripSlashes($_POST["bewirtschafterNr"]));
00201                 $bmfSetObj->setHaushaltsstelle(ilUtil::stripSlashes($_POST["haushaltsstelle"]));
00202                 $bmfSetObj->setObjectId(ilUtil::stripSlashes($_POST["objektNr"]));
00203                 $bmfSetObj->setKennzeichenMahnverfahren(ilUtil::stripSlashes($_POST["kennzeichenMahnverfahren"]));
00204                 $bmfSetObj->setWaehrungsKennzeichen(ilUtil::stripSlashes($_POST["waehrungskennzeichen"]));
00205                 $bmfSetObj->setEpaymentServer(ilUtil::stripSlashes($_POST["ePaymentServer"]));
00206                 $bmfSetObj->setClientCertificate(ilUtil::stripSlashes($_POST["clientCertificate"]));
00207                 $bmfSetObj->setCaCertificate(ilUtil::stripSlashes($_POST["caCertificate"]));
00208                 $bmfSetObj->setTimeout(ilUtil::stripSlashes($_POST["timeOut"]));
00209                 
00210                 if ($_POST["mandantNr"] == "" ||
00211                         $_POST["bewirtschafterNr"] == "" ||
00212                         $_POST["haushaltsstelle"] == "" ||
00213                         $_POST["objektNr"] == "" ||
00214                         $_POST["kennzeichenMahnverfahren"] == "" ||
00215                         $_POST["waehrungskennzeichen"] == "" ||
00216                         $_POST["ePaymentServer"] == "" ||
00217                         $_POST["clientCertificate"] == "" ||
00218                         $_POST["caCertificate"] == "" ||                        
00219                         $_POST["timeOut"] == "")
00220                 {
00221                         $this->error = $this->lng->txt('pays_bmf_settings_not_valid');
00222                         ilUtil::sendInfo($this->error);
00223                         $this->bmfSettingsObject();
00224                         return;
00225                 }
00226                 
00227                 $bmfSetObj->save();
00228                                 
00229                 $this->bmfSettingsObject();
00230 
00231                 ilUtil::sendInfo($this->lng->txt('pays_updated_bmf_settings'));
00232 
00233                 return true;
00234         }
00235         
00236         function bmfSettingsObject()
00237         {       
00238                 global $rbacsystem;
00239 
00240                 // MINIMUM ACCESS LEVEL = 'read'
00241                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
00242                 {
00243                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00244                 }
00245                 include_once './payment/classes/class.ilBMFSettings.php';
00246                 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");            
00247 
00248                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_bmf_settings.html",'payment');
00249                 
00250                 $bmfSetObj = ilBMFSettings::getInstance();              
00251                                                 
00252                 $form = new ilPropertyFormGUI();
00253                 $form->setFormAction($this->ctrl->getFormAction($this, "saveBmfSettings"));
00254                 $form->setTitle($this->lng->txt('pays_bmf_settings'));
00255                 
00256                 $form->addCommandButton('saveBmfSettings',$this->lng->txt('save'));
00257                 
00258                 $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_client_id"), "mandantNr");
00259                 $formItem->setValue($bmfSetObj->getClientId());
00260                 $form->addItem($formItem);
00261                 
00262                 $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_bewirtschafter_nr"), "bewirtschafterNr");
00263                 $formItem->setValue($bmfSetObj->getBewirtschafterNr());
00264                 $form->addItem($formItem);
00265                 
00266                 $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_haushaltsstelle"), "haushaltsstelle");
00267                 $formItem->setValue($bmfSetObj->getHaushaltsstelle());
00268                 $form->addItem($formItem);
00269                 
00270                 $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_object_id"), "objektNr");
00271                 $formItem->setValue($bmfSetObj->getObjectId());
00272                 $form->addItem($formItem);
00273                 
00274                 $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_kennzeichen_mahnverfahren"), "kennzeichenMahnverfahren");
00275                 $formItem->setValue($bmfSetObj->getKennzeichenMahnverfahren());
00276                 $form->addItem($formItem);
00277                 
00278                 $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_waehrungskennzeichen"), "waehrungskennzeichen");
00279                 $formItem->setValue($bmfSetObj->getWaehrungsKennzeichen());
00280                 $form->addItem($formItem);
00281                 
00282                 $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_epayment_server"), "ePaymentServer");
00283                 $formItem->setValue($bmfSetObj->getEpaymentServer());
00284                 $form->addItem($formItem);
00285                 
00286                 $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_client_certificate"), "clientCertificate");
00287                 $formItem->setValue($bmfSetObj->getClientCertificate());
00288                 $form->addItem($formItem);
00289                 
00290                 $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_ca_certificate"), "caCertificate");
00291                 $formItem->setValue($bmfSetObj->getCaCertificate());
00292                 $form->addItem($formItem);
00293                 
00294                 $formItem = new ilTextInputGUI($this->lng->txt("pays_bmf_timeout"), "timeOut");
00295                 $formItem->setValue($bmfSetObj->getTimeOut());
00296                 $form->addItem($formItem);                              
00297                                 
00298                 $this->tpl->setVariable('BMF_SETTINGS',$form->getHTML());
00299         }
00300         
00301         function updateObjectDetailsObject()
00302         {
00303                 if(!$_GET['pobject_id'])
00304                 {
00305                         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
00306 
00307                         $this->objectObjects();
00308                         return true;
00309                 }
00310                 $this->__initPaymentObject((int) $_GET['pobject_id']);
00311                 $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
00312 
00313                 // read old settings
00314                 $old_pay_method = $this->pobject->getPayMethod();
00315                 $old_status = $this->pobject->getStatus();
00316 
00317                 // check status changed from not_buyable
00318                 if($old_status == $this->pobject->STATUS_NOT_BUYABLE and
00319                    (int) $_POST['status'] != $old_status)
00320                 {
00321                         // check pay_method edited
00322                         switch((int) $_POST['pay_method'])
00323                         {
00324                                 case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
00325                                         ilUtil::sendInfo($this->lng->txt('paya_select_pay_method_first'));
00326                                         $this->editObjectObject();
00327 
00328                                         return false;
00329                                         
00330                                 case $this->pobject->PAY_METHOD_BILL:
00331                                         include_once './payment/classes/class.ilPaymentBillVendor.php';
00332 
00333                                         $bill_vendor =& new ilPaymentBillVendor((int) $_GET['pobject_id']);
00334                                         if(!$bill_vendor->validate())
00335                                         {
00336                                                 ilUtil::sendInfo($this->lng->txt('paya_select_pay_method_first'));
00337                                                 $this->editObjectObject();
00338                                                 
00339                                                 return false;
00340                                         }
00341                                         break;
00342 
00343                                 default:
00344                                         ;
00345                         }
00346                         // check minimum one price
00347                         include_once './payment/classes/class.ilPaymentPrices.php';
00348 
00349                         $prices_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
00350                         if(!count($prices_obj->getPrices()))
00351                         {
00352                                 ilUtil::sendInfo($this->lng->txt('paya_edit_prices_first'));
00353                                 $this->editObjectObject();
00354                                                 
00355                                 return false;
00356                         }                               
00357                 }
00358                 
00359 
00360                 $this->pobject->setStatus((int) $_POST['status']);
00361                 $this->pobject->setVendorId((int) $_POST['vendor']);
00362                 $this->pobject->setPayMethod((int) $_POST['pay_method']);
00363                 
00364                 $this->pobject->update();
00365 
00366                 ilUtil::sendInfo($this->lng->txt('paya_details_updated'));
00367                 $this->editObjectObject();
00368 
00369                 return true;
00370         }
00371         
00372         function editPricesObject($a_show_delete = false)
00373         {
00374                 include_once './payment/classes/class.ilPaymentPrices.php';
00375                 include_once './payment/classes/class.ilPaymentCurrency.php';
00376                 include_once "./Services/Table/classes/class.ilTableGUI.php";
00377                 include_once './payment/classes/class.ilGeneralSettings.php';
00378 
00379                 $genSet = new ilGeneralSettings();
00380 
00381                 $_SESSION['price_ids'] = $_SESSION['price_ids'] ? $_SESSION['price_ids'] : array();
00382 
00383                 if(!$_GET['pobject_id'])
00384                 {
00385                         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
00386 
00387                         $this->objectsObject();
00388                         return true;
00389                 }
00390                 $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
00391 
00392                 $this->__showButton('objects',$this->lng->txt('back')); 
00393                 $this->__showButton('editObject',$this->lng->txt('paya_edit_details'));
00394                 $this->__showButton('editPrices',$this->lng->txt('paya_edit_prices'));
00395 
00396                 $this->__initPaymentObject((int) $_GET['pobject_id']);
00397 
00398                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_edit_prices.html','payment');
00399 
00400                 $price_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
00401                 $prices = $price_obj->getPrices();
00402 
00403                 // No prices created
00404                 if(!count($prices))
00405                 {
00406                         ilUtil::sendInfo($this->lng->txt('paya_no_price_available'));
00407 
00408                         $this->tpl->setCurrentBlock("price_info");
00409                         $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
00410                         $this->tpl->setVariable("CONFIRM_CMD",'addPrice');
00411                         $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('paya_add_price'));
00412                         $this->tpl->parseCurrentBlock();
00413                         
00414                         return true;
00415                 }
00416                 // Show confirm delete
00417                 if($a_show_delete)
00418                 {
00419                         ilUtil::sendInfo($this->lng->txt('paya_sure_delete_selected_prices'));
00420 
00421                         $this->tpl->setCurrentBlock("cancel");
00422                         $this->tpl->setVariable("CANCEL_CMD",'editPrices');
00423                         $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00424                         $this->tpl->parseCurrentBlock();
00425 
00426                         $this->tpl->setCurrentBlock("price_info");
00427                         $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
00428                         $this->tpl->setVariable("CONFIRM_CMD",'performDeletePrice');
00429                         $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('paya_delete_price'));
00430                         $this->tpl->parseCurrentBlock();
00431                 }                       
00432 
00433                 // Fill table cells
00434                 $tpl =& new ilTemplate('tpl.table.html',true,true);
00435 
00436                 // set table header
00437                 $tpl->setCurrentBlock("tbl_form_header");
00438                 
00439                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00440                 $tpl->parseCurrentBlock();
00441 
00442                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content",'tpl.paya_adm_edit_prices_row.html','payment');
00443                 
00444                 $counter = 0;
00445                 foreach($prices as $price)
00446                 {
00447                         $currency = ilPaymentCurrency::_getCurrency($price['currency']);
00448 
00449                         $tpl->setCurrentBlock("tbl_content");
00450                         $tpl->setVariable("ROWCOL", ilUtil::switchColor($counter,"tblrow2","tblrow1"));
00451 
00452                         $tpl->setVariable("CHECKBOX",ilUtil::formCheckBox(in_array($price['price_id'],$_SESSION['price_ids']) ? 1 : 0,
00453                                                                                                                           'price_ids[]',
00454                                                                                                                           $price['price_id']));
00455                         $tpl->setVariable("DURATION_NAME",'prices['.$price['price_id'].'][duration]');
00456                         $tpl->setVariable("DURATION",$price['duration']);
00457                         $tpl->setVariable("MONTH",$this->lng->txt('paya_months'));
00458                         $tpl->setVariable("UNIT_NAME",'prices['.$price['price_id'].'][unit_value]');
00459                         $tpl->setVariable("UNIT",$price['unit_value']);
00460 #                       $tpl->setVariable("SHORTFORM",$this->lng->txt('currency_'.$currency['unit']));
00461                         $tpl->setVariable("SHORTFORM",$genSet->get("currency_unit"));
00462                         
00463                         $tpl->setVariable("SUB_UNIT_NAME",'prices['.$price['price_id'].'][sub_unit_value]');
00464                         $tpl->setVariable("SUB_UNIT",$price['sub_unit_value']);
00465 #                       $tpl->setVariable("SUB_UNIT_TXT",$this->lng->txt('currency_'.$currency['sub_unit']));
00466                         $tpl->setVariable("SUB_UNIT_TXT",$genSet->get("currency_subunit"));
00467                         $tpl->parseCurrentBlock();
00468                         
00469                         ++$counter;
00470                 }
00471 
00472                 // SET FOOTER
00473                 $tpl->setCurrentBlock("tbl_action_button");
00474                 $tpl->setVariable("BTN_NAME","deletePrice");
00475                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("paya_delete_price"));
00476                 $tpl->parseCurrentBlock();
00477 
00478                 $tpl->setCurrentBlock("plain_buttons");
00479                 $tpl->setVariable("PBTN_NAME","updatePrice");
00480                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("paya_update_price"));
00481                 $tpl->parseCurrentBlock();
00482 
00483                 $tpl->setCurrentBlock("plain_buttons");
00484                 $tpl->setVariable("PBTN_NAME","addPrice");
00485                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("paya_add_price"));
00486                 $tpl->parseCurrentBlock();
00487 
00488 
00489                 $tpl->setCurrentBlock("tbl_action_row");
00490                 $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
00491                 $tpl->setVariable("COLUMN_COUNTS",4);
00492                 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00493                 $tpl->parseCurrentBlock();
00494 
00495 
00496                 $tbl = new ilTableGUI();
00497                 $tbl->setTemplate($tpl);
00498 
00499                 // title & header columns
00500                 $tbl->setStyle('table','std');
00501 
00502                 $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId());
00503 
00504                 $tbl->setTitle($tmp_obj->getTitle(),
00505                                            "icon_".$tmp_obj->getType()."_b.gif",
00506                                            $this->lng->txt("objs_".$tmp_obj->getType()));
00507                 $tbl->setHeaderNames(array('',
00508                                                                    $this->lng->txt('duration'),
00509                                                                    $this->lng->txt('price_a'),
00510                                                                    ''));
00511                 $tbl->setHeaderVars(array("",
00512                                                                   "duration",
00513                                                                   "price_unit",
00514                                                                   "price_sub_unit"),
00515                                                         array("ref_id" => $this->cur_ref_id));
00516 
00517                 // control
00518                 $tbl->setLimit($_GET["limit"]);
00519                 $tbl->setOffset($_GET["offset"]);
00520                 $tbl->setMaxCount(count($price_obj->getPrices()));
00521 
00522                 $tbl->disable("sort");
00523 
00524                 // render table
00525                 $tbl->render();
00526 
00527                 $this->tpl->setVariable("PRICES_TABLE",$tpl->get());
00528                 
00529                 return true;
00530         }
00531         
00532         function addPriceObject()
00533         {
00534                 if(!$_GET['pobject_id'])
00535                 {
00536                         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
00537 
00538                         $this->showObjects();
00539                         return true;
00540                 }
00541 
00542                 include_once './payment/classes/class.ilGeneralSettings.php';
00543 
00544                 $genSet = new ilGeneralSettings();
00545 
00546                 $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
00547 
00548                 $this->__initPaymentObject((int) $_GET['pobject_id']);
00549 
00550                 $this->__showButton('editObject',$this->lng->txt('paya_edit_details'));
00551                 $this->__showButton('editPrices',$this->lng->txt('paya_edit_prices'));
00552 
00553                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_add_price.html','payment');
00554 
00555                 $this->tpl->setVariable("ADD_FORMACTION",$this->ctrl->getFormAction($this));
00556 
00557                 $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId());
00558                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$tmp_obj->getType().'_b.gif'));
00559                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_'.$tmp_obj->getType()));
00560                 $this->tpl->setVariable("TITLE",$tmp_obj->getTitle());
00561                 $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('paya_add_price_title'));
00562                 
00563                 // TODO show curency selector
00564 #               $this->tpl->setVariable("TXT_PRICE_A",$this->lng->txt('currency_euro'));
00565 #               $this->tpl->setVariable("TXT_PRICE_B",$this->lng->txt('currency_cent'));
00566                 $this->tpl->setVariable("TXT_PRICE_A",$genSet->get("currency_unit"));
00567                 $this->tpl->setVariable("TXT_PRICE_B",$genSet->get("currency_subunit"));
00568                 
00569                 $this->tpl->setVariable("MONTH",$this->lng->txt('paya_months'));
00570                 $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('duration'));
00571                 $this->tpl->setVariable("TXT_PRICE",$this->lng->txt('price_a'));
00572                 $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
00573                 $this->tpl->setVariable("ADD",$this->lng->txt('paya_add_price'));
00574 
00575                 $this->tpl->setVariable("DURATION",$_POST['duration']);
00576                 $this->tpl->setVariable("UNIT_VALUE",$_POST['unit']);
00577                 $this->tpl->setVariable("SUB_UNIT",$_POST['SUB_UNIT']);
00578                 
00579                 return true;
00580         }
00581 
00582         function performAddPriceObject()
00583         {
00584                 if(!$_GET['pobject_id'])
00585                 {
00586                         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
00587 
00588                         $this->objectsObject();
00589                         return true;
00590                 }
00591                 
00592                 include_once './payment/classes/class.ilPaymentPrices.php';
00593                 include_once './payment/classes/class.ilPaymentCurrency.php';
00594 
00595                 $currency = ilPaymentCurrency::_getAvailableCurrencies();
00596 
00597                 $prices =& new ilPaymentPrices((int) $_GET['pobject_id']);
00598 
00599                 $prices->setDuration($_POST['duration']);
00600                 $prices->setUnitValue($_POST['unit']);
00601                 $prices->setSubUnitValue($_POST['sub_unit']);
00602                 $prices->setCurrency($currency[1]['currency_id']);
00603 
00604                 if(!$prices->validate())
00605                 {
00606                         ilUtil::sendInfo($this->lng->txt('paya_price_not_valid'));
00607                         $this->addPriceObject();
00608 
00609                         return true;
00610                 }
00611                 $prices->add();
00612 
00613                 ilUtil::sendInfo($this->lng->txt('paya_added_new_price'));
00614                 $this->editPricesObject();
00615 
00616                 return true;
00617         }               
00618 
00619         function performDeletePriceObject()
00620         {
00621                 if(!$_GET['pobject_id'])
00622                 {
00623                         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
00624 
00625                         $this->objectsObject();
00626                         return true;
00627                 }
00628 
00629                 if(!count($_SESSION['price_ids']))
00630                 {
00631                         ilUtil::sendInfo($this->lng->txt('paya_no_prices_selected'));
00632                         
00633                         $this->editPricesObject();
00634                         return true;
00635                 }
00636                 include_once './payment/classes/class.ilPaymentPrices.php';
00637                 
00638                 $prices =& new ilPaymentPrices((int) $_GET['pobject_id']);
00639 
00640                 foreach($_SESSION['price_ids'] as $price_id)
00641                 {
00642                         $prices->delete($price_id);
00643                 }
00644 
00645                 // check if it was last price otherwise set status to 'not_buyable'
00646                 if(!count($prices->getPrices()))
00647                 {
00648                         $this->__initPaymentObject((int) $_GET['pobject_id']);
00649 
00650                         $this->pobject->setStatus($this->pobject->STATUS_NOT_BUYABLE);
00651                         $this->pobject->update();
00652                         
00653                         ilUtil::sendInfo($this->lng->txt('paya_deleted_last_price'));
00654                 }
00655                 unset($prices);
00656                 unset($_SESSION['price_ids']);
00657                 
00658                 return $this->editPricesObject();
00659         }
00660 
00661         function deletePriceObject()
00662         {
00663                 if(!$_GET['pobject_id'])
00664                 {
00665                         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
00666 
00667                         $this->objectsObject();
00668                         return true;
00669                 }
00670 
00671                 if(!count($_POST['price_ids']))
00672                 {
00673                         ilUtil::sendInfo($this->lng->txt('paya_no_prices_selected'));
00674                         
00675                         $this->editPricesObject();
00676                         return true;
00677                 }
00678                 $_SESSION['price_ids'] = $_POST['price_ids'];
00679 
00680                 $this->editPricesObject(true);
00681                 return true;
00682         }       
00683 
00684         function updatePriceObject()
00685         {
00686                 include_once './payment/classes/class.ilPaymentPrices.php';
00687 
00688                 if(!$_GET['pobject_id'])
00689                 {
00690                         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
00691 
00692                         $this->objectsObject();
00693                         return true;
00694                 }
00695                 $po =& new ilPaymentPrices((int) $_GET['pobject_id']);
00696 
00697                 $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
00698 
00699                 // validate
00700                 foreach($_POST['prices'] as $price_id => $price)
00701                 {
00702                         $old_price = $po->getPrice($price_id);
00703 
00704                         $po->setDuration($price['duration']);
00705                         $po->setUnitValue($price['unit_value']);
00706                         $po->setSubUnitValue($price['sub_unit_value']);
00707                         $po->setCurrency($old_price['currency']);
00708 
00709                         if(!$po->validate())
00710                         {
00711                                 $error = true;
00712                         }
00713                 }
00714                 if($error)
00715                 {
00716                         ilUtil::sendInfo($this->lng->txt('paya_insert_only_numbers'));
00717 
00718                         $this->editPricesObject();
00719                         return false;
00720                 }
00721                 foreach($_POST['prices'] as $price_id => $price)
00722                 {
00723                         $old_price = $po->getPrice($price_id);
00724 
00725                         $po->setDuration($price['duration']);
00726                         $po->setUnitValue($price['unit_value']);
00727                         $po->setSubUnitValue($price['sub_unit_value']);
00728                         $po->setCurrency($old_price['currency']);
00729 
00730                         $po->update($price_id);
00731                 }
00732                 ilUtil::sendInfo($this->lng->txt('paya_updated_prices'));
00733                 $this->editPricesObject();
00734 
00735                 return true;
00736         }
00737         
00738         function editObjectObject($a_show_confirm = false)
00739         {
00740                 if(!isset($_GET['pobject_id']))
00741                 {
00742                         ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
00743                         $this->objectsObject();
00744 
00745                         return true;
00746                 }       
00747 
00748                 $this->ctrl->setParameter($this,'pobject_id',(int) $_GET['pobject_id']);
00749                 
00750                 $this->__showButton('objects',$this->lng->txt('back'));         
00751                 $this->__showButton('editObject',$this->lng->txt('paya_edit_details'));
00752                 $this->__showButton('editPrices',$this->lng->txt('paya_edit_prices'));
00753 
00754                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_edit_objects.html','payment');
00755                                 
00756                 $this->__initPaymentObject((int) $_GET['pobject_id']);
00757                 
00758                 
00759                 if($a_show_confirm)
00760                 {
00761                         $this->tpl->setCurrentBlock("confirm_delete");
00762                         $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
00763                         $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00764                         $this->tpl->setVariable("CONFIRM_CMD",'performObjectDelete');
00765                         $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('confirm'));
00766                         $this->tpl->parseCurrentBlock();
00767                 }
00768 
00769                 $this->tpl->setVariable("DETAILS_FORMACTION",$this->ctrl->getFormAction($this));
00770 
00771                         
00772                 $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId());
00773                 
00774                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$tmp_obj->getType().'_b.gif'));
00775                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_'.$tmp_obj->getType()));
00776                 $this->tpl->setVariable("TITLE",$tmp_obj->getTitle());
00777                 $this->tpl->setVariable("DESCRIPTION",$tmp_obj->getDescription());
00778                 $this->tpl->setVariable("TXT_PATH",$this->lng->txt('path'));
00779                 $this->tpl->setVariable("PATH",$this->__getHTMLPath($this->pobject->getRefId()));
00780                 $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
00781                 $this->tpl->setVariable("VENDOR",$this->__showVendorSelector($this->pobject->getVendorId()));
00782                 $this->tpl->setVariable("TXT_COUNT_PURCHASER",$this->lng->txt('paya_count_purchaser'));
00783                 $this->tpl->setVariable("COUNT_PURCHASER",ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']));
00784                 $this->tpl->setVariable("TXT_STATUS",$this->lng->txt('status'));
00785                 $this->tpl->setVariable("STATUS",$this->__showStatusSelector());
00786                 $this->tpl->setVariable("TXT_PAY_METHOD",$this->lng->txt('paya_pay_method'));
00787                 $this->tpl->setVariable("PAY_METHOD",$this->__showPayMethodSelector());
00788 
00789                 $this->tpl->setVariable("INPUT_CMD",'updateObjectDetails');
00790                 $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('save'));
00791 
00792                 $this->tpl->setVariable("DELETE_CMD",'deleteObject');
00793                 $this->tpl->setVariable("DELETE_VALUE",$this->lng->txt('delete'));
00794         }
00795         
00796         
00797         
00798         function deleteObjectObject()
00799         {
00800                 include_once './payment/classes/class.ilPaymentBookings.php';
00801 
00802                 if(!$_GET['pobject_id'])
00803                 {
00804                         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
00805 
00806                         $this->editObjectObject();
00807                         return true;
00808                 }
00809                 if(ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']))
00810                 {
00811                         ilUtil::sendInfo($this->lng->txt('paya_bookings_available'));
00812                         $this->editObjectObject();
00813 
00814                         return false;
00815                 }
00816                 else
00817                 {
00818                         ilUtil::sendInfo($this->lng->txt('paya_sure_delete_object'));
00819                         $this->editObjectObject(true);
00820 
00821                         return true;
00822                 }
00823         }
00824         
00825         function performObjectDeleteObject()
00826         {
00827                 include_once './payment/classes/class.ilPaymentPrices.php';
00828                 include_once './payment/classes/class.ilPaymentBillVendor.php';
00829 
00830                 if(!$_GET['pobject_id'])
00831                 {
00832                         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
00833 
00834                         $this->objectsObject();
00835                         return true;
00836                 }
00837                 $this->__initPaymentObject((int) $_GET['pobject_id']);
00838 
00839                 // delete object data
00840                 $this->pobject->delete();
00841                 
00842                 // delete payment prices
00843                 $price_obj =& new ilPaymentPrices((int) $_GET['pobject_id']);
00844                 $price_obj->deleteAllPrices();
00845                 unset($price_obj);
00846 
00847                 $bv =& new ilPaymentBillVendor((int) $_GET['pobject_id']);
00848                 $bv->delete();
00849                 unset($bv);
00850 
00851                 // delete bill vendor data if exists
00852                 ilUtil::sendInfo($this->lng->txt('paya_deleted_object'));
00853 
00854                 $this->objectsObject();
00855 
00856                 return true;
00857         }
00858         
00859         function __getHTMLPath($a_ref_id)
00860         {
00861                 global $tree;
00862 
00863                 $path = $tree->getPathFull($a_ref_id);
00864                 unset($path[0]);
00865 
00866                 foreach($path as $data)
00867                 {
00868                         $html .= $data['title'].' > ';
00869                 }
00870                 return substr($html,0,-2);
00871         }
00872         
00873         function __showVendorSelector($a_selected = 0)
00874         {               
00875                 include_once './payment/classes/class.ilPaymentVendors.php';
00876                                 
00877                 $vendors = array();
00878                 
00879                 $vendor_obj = new ilPaymentVendors();
00880                 $all_vendors = $vendor_obj->getVendors();
00881                 if (is_array($all_vendors))
00882                 {
00883                         foreach ($all_vendors as $vendor)
00884                         {                               
00885                                 $vendors[] = $vendor["vendor_id"];
00886                         }
00887                 }               
00888                 
00889                 foreach($vendors as $vendor)
00890                 {
00891                         $tmp_obj =& ilObjectFactory::getInstanceByObjId($vendor,false);
00892 
00893                         $action[$vendor] = $tmp_obj->getFullname().' ['.$tmp_obj->getLogin().']';
00894                 }
00895                 
00896                 return ilUtil::formSelect($a_selected,'vendor',$action,false,true);
00897         }
00898         
00899         function __showStatusSelector()
00900         {
00901                 $action = array();
00902                 $action[$this->pobject->STATUS_NOT_BUYABLE] = $this->lng->txt('paya_not_buyable');
00903                 $action[$this->pobject->STATUS_BUYABLE] = $this->lng->txt('paya_buyable');
00904                 $action[$this->pobject->STATUS_EXPIRES] = $this->lng->txt('paya_expires');
00905 
00906                 return ilUtil::formSelect($this->pobject->getStatus(),'status',$action,false,true);
00907         }
00908         
00909         function __showPayMethodSelector()
00910         {
00911                 include_once './payment/classes/class.ilPayMethods.php';
00912 
00913                 $action = array();
00914 
00915                 $action[$this->pobject->PAY_METHOD_NOT_SPECIFIED] = $this->lng->txt('paya_pay_method_not_specified');
00916                 if(ilPayMethods::_enabled('pm_bill'))
00917                 {
00918                         $action[$this->pobject->PAY_METHOD_BILL] = $this->lng->txt('pays_bill');
00919                 }
00920                 if(ilPayMethods::_enabled('pm_bmf'))
00921                 {
00922                         $action[$this->pobject->PAY_METHOD_BMF] = $this->lng->txt('pays_bmf');
00923                 }
00924                 if(ilPayMethods::_enabled('pm_paypal'))
00925                 {
00926                         $action[$this->pobject->PAY_METHOD_PAYPAL] = $this->lng->txt('pays_paypal');
00927                 }
00928 
00929 
00930                 return ilUtil::formSelect($this->pobject->getPayMethod(),'pay_method',$action,false,true);
00931         }
00932         
00933         function resetObjectFilterObject()
00934         {
00935                 unset($_SESSION["pay_statistics"]);
00936                 unset($_POST["title_type"]);
00937                 unset($_POST["title_value"]);
00938                 unset($_POST["vendor"]);
00939                 unset($_POST["pay_method"]);
00940 
00941                 ilUtil::sendInfo($this->lng->txt('paya_filter_reseted'));
00942 
00943                 return $this->objectsObject();
00944         }
00945         
00946         function objectsObject()
00947         {
00948                 global $rbacsystem;
00949 
00950                 // MINIMUM ACCESS LEVEL = 'read'
00951                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
00952                 {
00953                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00954                 }
00955                 
00956                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_objects.html','payment');
00957                 
00958                 if ($_POST["updateView"] == 1)
00959                 {
00960                         $_SESSION["pay_objects"]["title_type"] = $_POST["title_type"];
00961                         $_SESSION["pay_objects"]["title_value"] = $_POST["title_value"];                        
00962                         $_SESSION["pay_objects"]["pay_method"] = $_POST["pay_method"];                  
00963                         $_SESSION["pay_objects"]["vendor"] = $_POST["vendor"];
00964                 }                       
00965 
00966                 $this->__initPaymentObject();
00967                 $this->lng->loadLanguageModule('search');
00968                 $this->tpl->setVariable("TXT_FILTER",$this->lng->txt('pay_filter'));
00969                 $this->tpl->setVariable("FORM_ACTION",$this->ctrl->getFormAction($this));
00970                 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt("title"));
00971                 $this->tpl->setVariable("TXT_AND",$this->lng->txt('search_all_words'));
00972                 $this->tpl->setVariable("TXT_OR",$this->lng->txt('search_any_word'));
00973                 $this->tpl->setVariable("TXT_BILL",$this->lng->txt('pays_bill'));
00974                 $this->tpl->setVariable("TXT_BMF",$this->lng->txt('pays_bmf'));
00975                 $this->tpl->setVariable("TXT_PAYPAL",$this->lng->txt('pays_paypal'));
00976                 $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));           
00977                 $this->tpl->setVariable("TXT_PAYMENT",$this->lng->txt('payment_system'));               
00978                 $this->tpl->setVariable("TXT_UPDATE_VIEW",$this->lng->txt('pay_update_view'));
00979                 $this->tpl->setVariable("TXT_RESET_FILTER",$this->lng->txt('pay_reset_filter'));
00980 
00981                 $this->tpl->setVariable(($_SESSION["pay_objects"]["title_type"] != "" ? strtoupper($_SESSION["pay_objects"]["title_type"]) : "OR") . "_CHECKED", " checked");
00982                 $this->tpl->setVariable("TITLE_VALUE", ilUtil::prepareFormOutput($_SESSION["pay_objects"]["title_value"], true));
00983                 $this->tpl->setVariable("PAYMENT_" . $_SESSION["pay_objects"]["pay_method"], " selected");
00984                 $this->tpl->setVariable("VENDOR", ilUtil::prepareFormOutput($_SESSION["pay_objects"]["vendor"], true));
00985                 
00986                 if(!count($objects = ilPaymentObject::_getAllObjectsData()))
00987                 {
00988                         ilUtil::sendInfo($this->lng->txt('paya_no_objects_assigned'));
00989                         
00990                         return true;
00991                 }
00992 
00993                 $counter = 0;
00994                 foreach($objects as $data)
00995                 {
00996                         $tmp_obj =& ilObjectFactory::getInstanceByRefId($data['ref_id']);
00997                         $f_result[$counter][] = $tmp_obj->getTitle();
00998 
00999 
01000                         switch($data['status'])
01001                         {
01002                                 case $this->pobject->STATUS_BUYABLE:
01003                                         $f_result[$counter][] = $this->lng->txt('paya_buyable');
01004                                         break;
01005 
01006                                 case $this->pobject->STATUS_NOT_BUYABLE:
01007                                         $f_result[$counter][] = $this->lng->txt('paya_not_buyable');
01008                                         break;
01009                                         
01010                                 case $this->pobject->STATUS_EXPIRES:
01011                                         $f_result[$counter][] = $this->lng->txt('paya_expires');
01012                                         break;
01013                         }
01014                         switch($data['pay_method'])
01015                         {
01016                                 case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
01017                                         $f_result[$counter][] = $this->lng->txt('paya_pay_method_not_specified');
01018                                         break;
01019 
01020                                 case $this->pobject->PAY_METHOD_BILL:
01021                                         $f_result[$counter][] = $this->lng->txt('pays_bill');
01022                                         break;
01023 
01024                                 case $this->pobject->PAY_METHOD_BMF:
01025                                         $f_result[$counter][] = $this->lng->txt('pays_bmf');
01026                                         break;
01027 
01028                                 case $this->pobject->PAY_METHOD_PAYPAL:
01029                                         $f_result[$counter][] = $this->lng->txt('pays_paypal');
01030                                         break;
01031                         }
01032                         $tmp_user =& ilObjectFactory::getInstanceByObjId($data['vendor_id']);
01033                         $f_result[$counter][] = $tmp_user->getFullname().' ['.$tmp_user->getLogin().']';
01034 
01035                         // Get number of purchasers
01036                         
01037                         $f_result[$counter][] = ilPaymentBookings::_getCountBookingsByObject($data['pobject_id']);
01038 
01039 
01040                         // edit link
01041                         $this->ctrl->setParameter($this,"pobject_id",$data['pobject_id']);
01042                         $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editObject")."\">".$this->lng->txt("edit")."</a></div>";
01043 
01044                         $f_result[$counter][] = $link_change;
01045                         unset($tmp_user);
01046                         unset($tmp_obj);
01047 
01048                         ++$counter;
01049                 }
01050                 
01051                 $this->__showObjectsTable($f_result);   
01052 
01053                 return true;
01054         }
01055         
01056         function __showObjectsTable($a_result_set)
01057         {
01058                 $tbl =& $this->initTableGUI();
01059                 $tpl =& $tbl->getTemplateObject();
01060 
01061                 // SET FORMAACTION
01062                 $tpl->setCurrentBlock("tbl_form_header");
01063 
01064                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01065                 $tpl->parseCurrentBlock();
01066 
01067                 /*
01068                 $tpl->setCurrentBlock("tbl_action_row");
01069                 $tpl->setCurrentBlock("plain_buttons");
01070                 $tpl->parseCurrentBlock();
01071 
01072                 $tpl->setVariable("COLUMN_COUNTS",6);
01073                 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01074 
01075                 $tpl->setCurrentBlock("tbl_action_button");
01076                 $tpl->setVariable("BTN_NAME","deleteTrustee");
01077                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
01078                 $tpl->parseCurrentBlock();
01079                 $tpl->setCurrentBlock("tbl_action_row");
01080                 $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
01081                 $tpl->parseCurrentBlock();
01082                 */
01083 
01084                 $tbl->setTitle($this->lng->txt("objects"),"icon_pays.gif",$this->lng->txt("objects"));
01085                 $tbl->setHeaderNames(array($this->lng->txt("title"),
01086                                                                    $this->lng->txt("status"),
01087                                                                    $this->lng->txt("paya_pay_method"),
01088                                                                    $this->lng->txt("paya_vendor"),
01089                                                                    $this->lng->txt("paya_count_purchaser"),
01090                                                                    ''));
01091                 $header_params = $this->ctrl->getParameterArray($this,'');
01092                 $tbl->setHeaderVars(array("title",
01093                                                                   "status",
01094                                                                   "pay_method",
01095                                                                   "vendor",
01096                                                                   "purchasers",
01097                                                                   "options"),$header_params);
01098                                                                   /*
01099                                                         array("cmd" => "",
01100                                                                   "cmdClass" => "ilpaymentobjectgui",
01101                                                                   "cmdNode" => $_GET["cmdNode"]));
01102                                                                   */
01103                 $tbl->setColumnWidth(array("15%","15%","15%","20%","20%"));
01104 
01105 #               $this->setTableGUIBasicData($tbl,$a_result_set);
01106 
01107                 $offset = $_GET["offset"];
01108                 $order = $_GET["sort_by"];
01109                 $direction = $_GET["sort_order"] ? $_GET['sort_order'] : 'desc';
01110 
01111                 $tbl->setOrderColumn($order,'order_date');
01112                 $tbl->setOrderDirection($direction);
01113                 $tbl->setOffset($offset);
01114                 $tbl->setLimit($_GET["limit"]);
01115                 $tbl->setMaxCount(count($a_result_set));
01116                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01117                 $tbl->setData($a_result_set);
01118 
01119                 $tbl->render();
01120 
01121                 $this->tpl->setVariable("OBJECTS_TABLE",$tbl->tpl->get());
01122 
01123                 return true;
01124         }
01125         
01126         function __initPaymentObject($a_pobject_id = 0)
01127         {
01128                 include_once './payment/classes/class.ilPaymentObject.php';
01129 
01130                 $this->pobject =& new ilPaymentObject($this->user_obj,$a_pobject_id);
01131 
01132                 return true;
01133         }
01134 
01135         function gatewayObject()
01136         {
01137                 switch($_POST["action"])
01138                 {
01139                         case "deleteVendorsObject":
01140                                 $this->deleteVendors();
01141                                 break;
01142 
01143                         case "editVendorObject":
01144                                 $this->editVendor();
01145                                 break;
01146 
01147                         case "performEditVendorObject":
01148                                 $this->performEditVendorObject();
01149                                 break;
01150 
01151                         default:
01152                                 $this->vendorsObject();
01153                                 break;
01154                 }
01155                 return true;
01156         }
01157 
01158         function resetFilterObject()
01159         {
01160                 unset($_SESSION["pay_statistics"]);
01161                 unset($_POST["transaction_type"]);
01162                 unset($_POST["transaction_value"]);
01163                 unset($_POST["from"]["day"]);
01164                 unset($_POST["from"]["month"]);
01165                 unset($_POST["from"]["year"]);
01166                 unset($_POST["til"]["day"]);
01167                 unset($_POST["til"]["month"]);
01168                 unset($_POST["til"]["year"]);
01169                 unset($_POST["payed"]);
01170                 unset($_POST["access"]);
01171                 unset($_POST["customer"]);
01172                 unset($_POST["pay_method"]);
01173                 unset($_POST["updateView"]);
01174                 ilUtil::sendInfo($this->lng->txt('paya_filter_reseted'));
01175 
01176                 return $this->statisticObject();
01177         }
01178 
01179         function statisticObject()
01180         {
01181                 global $rbacsystem;
01182 
01183                 // MINIMUM ACCESS LEVEL = 'read'
01184                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01185                 {
01186                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
01187                 }
01188 
01189                 $this->__showButton('showObjectSelector',$this->lng->txt('paya_add_customer'));
01190 
01191                 if ($_POST["updateView"] == 1)
01192                 {
01193                         $_SESSION["pay_statistics"]["updateView"] = true;
01194                         $_SESSION["pay_statistics"]["transaction_type"] = $_POST["transaction_type"];
01195                         $_SESSION["pay_statistics"]["transaction_value"] = $_POST["transaction_value"];
01196                         $_SESSION["pay_statistics"]["from"]["day"] = $_POST["from"]["day"];
01197                         $_SESSION["pay_statistics"]["from"]["month"] = $_POST["from"]["month"];
01198                         $_SESSION["pay_statistics"]["from"]["year"] = $_POST["from"]["year"];
01199                         $_SESSION["pay_statistics"]["til"]["day"] = $_POST["til"]["day"];
01200                         $_SESSION["pay_statistics"]["til"]["month"] = $_POST["til"]["month"];
01201                         $_SESSION["pay_statistics"]["til"]["year"] = $_POST["til"]["year"];
01202                         $_SESSION["pay_statistics"]["payed"] = $_POST["payed"];
01203                         $_SESSION["pay_statistics"]["access"] = $_POST["access"];
01204                         $_SESSION["pay_statistics"]["pay_method"] = $_POST["pay_method"];
01205                         $_SESSION["pay_statistics"]["customer"] = $_POST["customer"];
01206                         $_SESSION["pay_statistics"]["vendor"] = $_POST["vendor"];
01207                 }
01208 
01209                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_statistic.html','payment');
01210                 
01211                 $this->tpl->setVariable("TXT_FILTER",$this->lng->txt('pay_filter'));
01212                 $this->tpl->setVariable("FORM_ACTION",$this->ctrl->getFormAction($this));
01213                 $this->tpl->setVariable("TXT_TRANSACTION",$this->lng->txt('paya_transaction'));
01214                 $this->tpl->setVariable("TXT_STARTING",$this->lng->txt('pay_starting'));
01215                 $this->tpl->setVariable("TXT_ENDING",$this->lng->txt('pay_ending'));
01216                 $this->tpl->setVariable("TXT_PAYED",$this->lng->txt('paya_payed'));
01217                 $this->tpl->setVariable("TXT_ALL",$this->lng->txt('pay_all'));
01218                 $this->tpl->setVariable("TXT_YES",$this->lng->txt('yes'));
01219                 $this->tpl->setVariable("TXT_NO",$this->lng->txt('no'));
01220                 $this->tpl->setVariable("TXT_BILL",$this->lng->txt('pays_bill'));
01221                 $this->tpl->setVariable("TXT_BMF",$this->lng->txt('pays_bmf'));
01222                 $this->tpl->setVariable("TXT_PAYPAL",$this->lng->txt('pays_paypal'));
01223                 $this->tpl->setVariable("TXT_PAYMENT",$this->lng->txt('payment_system'));
01224                 $this->tpl->setVariable("TXT_CUSTOMER",$this->lng->txt('paya_customer'));
01225                 $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
01226                 $this->tpl->setVariable("TXT_ACCESS",$this->lng->txt('paya_access'));
01227                 $this->tpl->setVariable("TXT_ORDER_DATE_FROM",$this->lng->txt('pay_order_date_from'));
01228                 $this->tpl->setVariable("TXT_ORDER_DATE_TIL",$this->lng->txt('pay_order_date_til'));
01229                 $this->tpl->setVariable("TXT_UPDATE_VIEW",$this->lng->txt('pay_update_view'));
01230                 $this->tpl->setVariable("TXT_RESET_FILTER",$this->lng->txt('pay_reset_filter'));
01231 
01232                 $this->tpl->setVariable("TRANSACTION_TYPE_" . $_SESSION["pay_statistics"]["transaction_type"], " selected");
01233                 $this->tpl->setVariable("TRANSACTION_VALUE", ilUtil::prepareFormOutput($_SESSION["pay_statistics"]["transaction_value"], true));
01234                 $this->tpl->setVariable("PAYED_" . $_SESSION["pay_statistics"]["payed"], " selected");
01235                 $this->tpl->setVariable("ACCESS_" . $_SESSION["pay_statistics"]["access"], " selected");
01236                 $this->tpl->setVariable("PAYMENT_" . $_SESSION["pay_statistics"]["pay_method"], " selected");
01237                 $this->tpl->setVariable("CUSTOMER", ilUtil::prepareFormOutput($_SESSION["pay_statistics"]["customer"], true));
01238                 $this->tpl->setVariable("VENDOR", ilUtil::prepareFormOutput($_SESSION["pay_statistics"]["vendor"], true));
01239 
01240                 for ($i = 1; $i <= 31; $i++)
01241                 {
01242                         $this->tpl->setCurrentBlock("loop_from_day");
01243                         $this->tpl->setVariable("LOOP_FROM_DAY", $i < 10 ? "0" . $i : $i);
01244                         if ($_SESSION["pay_statistics"]["from"]["day"] == $i)
01245                         {
01246                                 $this->tpl->setVariable("LOOP_FROM_DAY_SELECTED", " selected");
01247                         }
01248                         $this->tpl->parseCurrentBlock("loop_from_day");
01249                         $this->tpl->setCurrentBlock("loop_til_day");
01250                         $this->tpl->setVariable("LOOP_TIL_DAY", $i < 10 ? "0" . $i : $i);
01251                         if ($_SESSION["pay_statistics"]["til"]["day"] == $i)
01252                         {
01253                                 $this->tpl->setVariable("LOOP_TIL_DAY_SELECTED", " selected");
01254                         }
01255                         $this->tpl->parseCurrentBlock("loop_til_day");
01256                 }
01257                 for ($i = 1; $i <= 12; $i++)
01258                 {
01259                         $this->tpl->setCurrentBlock("loop_from_month");
01260                         $this->tpl->setVariable("LOOP_FROM_MONTH", $i < 10 ? "0" . $i : $i);
01261                         if ($_SESSION["pay_statistics"]["from"]["month"] == $i)
01262                         {
01263                                 $this->tpl->setVariable("LOOP_FROM_MONTH_SELECTED", " selected");
01264                         }
01265                         $this->tpl->parseCurrentBlock("loop_from_month");
01266                         $this->tpl->setCurrentBlock("loop_til_month");
01267                         $this->tpl->setVariable("LOOP_TIL_MONTH", $i < 10 ? "0" . $i : $i);
01268                         if ($_SESSION["pay_statistics"]["til"]["month"] == $i)
01269                         {
01270                                 $this->tpl->setVariable("LOOP_TIL_MONTH_SELECTED", " selected");
01271                         }
01272                         $this->tpl->parseCurrentBlock("loop_til_month");
01273                 }
01274                 for ($i = 2004; $i <= date("Y"); $i++)
01275                 {
01276                         $this->tpl->setCurrentBlock("loop_from_year");
01277                         $this->tpl->setVariable("LOOP_FROM_YEAR", $i);
01278                         if ($_SESSION["pay_statistics"]["from"]["year"] == $i)
01279                         {
01280                                 $this->tpl->setVariable("LOOP_FROM_YEAR_SELECTED", " selected");
01281                         }
01282                         $this->tpl->parseCurrentBlock("loop_from_year");
01283                         $this->tpl->setCurrentBlock("loop_til_year");
01284                         $this->tpl->setVariable("LOOP_TIL_YEAR", $i);
01285                         if ($_SESSION["pay_statistics"]["til"]["year"] == $i)
01286                         {
01287                                 $this->tpl->setVariable("LOOP_TIL_YEAR_SELECTED", " selected");
01288                         }
01289                         $this->tpl->parseCurrentBlock("loop_til_year");
01290                 }
01291                 
01292                 if(!$_SESSION['pay_statistics']['updateView'])
01293                 {
01294                         $this->tpl->setVariable('FILTER_MESSAGE', $this->lng->txt('statistics_filter_advice'));
01295                         return true;
01296                 }
01297 
01298                 $this->__initBookingObject();
01299 
01300                 if(!count($bookings = $this->booking_obj->getBookings()))
01301                 {
01302                         ilUtil::sendInfo($this->lng->txt('paya_no_bookings'));
01303 
01304                         return true;
01305                 }
01306 #               else
01307 #               {
01308 #                       $this->__showButton('exportVendors',$this->lng->txt('excel_export'));
01309 #               }
01310                 $img_change = "<img src=\"".ilUtil::getImagePath("edit.gif")."\" alt=\"".
01311                         $this->lng->txt("edit")."\" title=\"".$this->lng->txt("edit").
01312                         "\" border=\"0\" vspace=\"0\"/>";
01313                         
01314                 include_once 'Services/User/classes/class.ilObjUser.php';
01315                 $object_title_cache = array();
01316                 $user_title_cache = array();
01317                 
01318                 $counter = 0;
01319                 foreach($bookings as $booking)
01320                 {
01321                         if(array_key_exists($booking['ref_id'], $object_title_cache))
01322                         {
01323                                 $tmp_obj = $object_title_cache[$booking['ref_id']];
01324                         }
01325                         else
01326                         {
01327                                 $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($booking['ref_id']));                          
01328                                 $object_title_cache[$booking['ref_id']] = $tmp_obj;
01329                         }
01330                         if(array_key_exists($booking['b_vendor_id'], $user_title_cache))
01331                         {
01332                                 $tmp_vendor = $user_title_cache[$booking['b_vendor_id']];
01333                         }
01334                         else
01335                         {
01336                                 $tmp_vendor = ilObjUser::_lookupLogin($booking['b_vendor_id']);
01337                                 $user_title_cache[$booking['b_vendor_id']] = $tmp_vendor;
01338                         }
01339                         if(array_key_exists($booking['customer_id'], $user_title_cache))
01340                         {
01341                                 $tmp_purchaser = $user_title_cache[$booking['customer_id']];
01342                         }
01343                         else
01344                         {
01345                                 $tmp_purchaser = ilObjUser::_lookupLogin($booking['customer_id']);
01346                                 $user_title_cache[$booking['customer_id']] = $tmp_purchaser;
01347                         }
01348                         
01349                         $transaction = $booking['transaction_extern'];
01350                         switch ($booking['b_pay_method'])
01351                         {
01352                                 case $this->pobject->PAY_METHOD_BILL :
01353                                         $transaction .= " (" . $this->lng->txt("pays_bill") . ")";
01354                                         break;
01355                                 case $this->pobject->PAY_METHOD_BMF :
01356                                         $transaction .= " (" . $this->lng->txt("pays_bmf") . ")";
01357                                         break;
01358                                 case $this->pobject->PAY_METHOD_PAYPAL :
01359                                         $transaction .= " (" . $this->lng->txt("pays_paypal") . ")";
01360                                         break;
01361                         }
01362                         $f_result[$counter][] = $transaction;
01363                         $f_result[$counter][] = ($tmp_obj != '' ?  $tmp_obj : $this->lng->txt('object_deleted'));
01364                         $f_result[$counter][] = ($tmp_vendor != '' ?  '['.$tmp_vendor.']' : $this->lng->txt('user_deleted'));
01365                         $f_result[$counter][] = ($tmp_purchaser != '' ?  '['.$tmp_purchaser.']' : $this->lng->txt('user_deleted'));
01366                         $f_result[$counter][] = date("Y-m-d H:i:s", $booking['order_date']);
01367                         $f_result[$counter][] = $booking['duration'];
01368                         $f_result[$counter][] = $booking['price'];
01369                         $f_result[$counter][] = ($booking['discount'] != '' ? $booking['discount'] : '&nbsp;');
01370 
01371                         $payed_access = $booking['payed'] ? 
01372                                 $this->lng->txt('yes') : 
01373                                 $this->lng->txt('no');
01374 
01375                         $payed_access .= '/';
01376                         $payed_access .= $booking['access'] ?
01377                                 $this->lng->txt('yes') : 
01378                                 $this->lng->txt('no');
01379 
01380                         $f_result[$counter][] = $payed_access;
01381 
01382                         $this->ctrl->setParameter($this,"booking_id",$booking['booking_id']);
01383 #                       $link_change = "<a href=\"".$this->ctrl->getLinkTarget($this,"editStatistic")."\"> ".
01384 #                               $img_change."</a>";
01385                         $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editStatistic")."\">".$this->lng->txt("edit")."</a></div>";
01386 
01387                         $f_result[$counter][] = $link_change;
01388 
01389                         unset($tmp_obj);
01390                         unset($tmp_vendor);
01391                         unset($tmp_purchaser);
01392 
01393                         ++$counter;
01394                 }
01395                 return $this->__showStatisticTable($f_result);
01396         }
01397         
01398         function editStatisticObject($a_show_confirm_delete = false)
01399         {
01400                 if(!isset($_GET['booking_id']))
01401                 {
01402                         ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
01403                         $this->showStatistics();
01404 
01405                         return true;
01406                 }
01407 
01408                 $this->__showButton('statistic',$this->lng->txt('back'));
01409 
01410                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_edit_statistic.html','payment');
01411                 $this->ctrl->setParameter($this,'booking_id',(int) $_GET['booking_id']);
01412 
01413                 // confirm delete
01414                 if($a_show_confirm_delete)
01415                 {
01416                         $this->tpl->setCurrentBlock("confirm_delete");
01417                         $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
01418                         $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
01419                         $this->tpl->setVariable("CONFIRM_CMD",'performDelete');
01420                         $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('confirm'));
01421                         $this->tpl->parseCurrentBlock();
01422                 }
01423                         
01424 
01425                 $this->__initBookingObject();
01426                 $bookings = $this->booking_obj->getBookings();
01427                 $booking = $bookings[(int) $_GET['booking_id']];
01428 
01429                 // get customer_obj
01430                 $tmp_user = ilObjectFactory::getInstanceByObjId($booking['customer_id'], false);
01431 
01432                 $this->tpl->setVariable("STAT_FORMACTION",$this->ctrl->getFormAction($this));
01433                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_usr.gif'));
01434                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
01435                 if(is_object($tmp_user))
01436                 {
01437                         $this->tpl->setVariable('TITLE', $tmp_user->getFullname().' ['.$tmp_user->getLogin().']');
01438                 }
01439                 else
01440                 {
01441                         $this->tpl->setVariable('TITLE', $this->lng->txt('user_deleted'));
01442                 }
01443 
01444                 // TXT
01445                 $pObj = new ilPaymentObject($this->user_obj, $booking["pobject_id"]);
01446                 $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($pObj->getRefId()));                           
01447 
01448                 $this->tpl->setVariable("TXT_OBJECT",$this->lng->txt('title'));
01449                 $this->tpl->setVariable("OBJECT", ($tmp_obj != '' ?  $tmp_obj : $this->lng->txt('object_deleted')));
01450 
01451                 $this->tpl->setVariable("TXT_TRANSACTION",$this->lng->txt('paya_transaction'));
01452                 $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
01453                 $this->tpl->setVariable("TXT_PAY_METHOD",$this->lng->txt('paya_pay_method'));
01454                 $this->tpl->setVariable("TXT_ORDER_DATE",$this->lng->txt('paya_order_date'));
01455                 $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('duration'));
01456                 $this->tpl->setVariable("TXT_PRICE",$this->lng->txt('price_a'));
01457                 $this->tpl->setVariable("TXT_PAYED",$this->lng->txt('paya_payed'));
01458                 $this->tpl->setVariable("TXT_ACCESS",$this->lng->txt('paya_access'));
01459 
01460                 $this->tpl->setVariable("TRANSACTION",$booking['transaction']);
01461 
01462                 $tmp_vendor = ilObjectFactory::getInstanceByObjId($booking['b_vendor_id'], false);
01463                 if(is_object($tmp_vendor))
01464                 {
01465                         $this->tpl->setVariable('VENDOR', $tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']');
01466                 }
01467                 else
01468                 {
01469                         $this->tpl->setVariable('VENDOR', $this->lng->txt('user_deleted'));
01470                 }
01471 
01472                 switch($booking['b_pay_method'])
01473                 {
01474                         case $this->pobject->PAY_METHOD_BILL:
01475                                 $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('pays_bill'));
01476                                 break;
01477 
01478                         case $this->pobject->PAY_METHOD_BMF:
01479                                 $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('pays_bmf'));
01480                                 break;
01481 
01482                         case $this->pobject->PAY_METHOD_PAYPAL:
01483                                 $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('pays_paypal'));
01484                                 break;
01485 
01486                         default:
01487                                 $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('paya_pay_method_not_specified'));
01488                                 break;
01489                 }
01490                 $this->tpl->setVariable("ORDER_DATE",date('Y m d H:i:s',$booking['order_date']));
01491                 $this->tpl->setVariable("DURATION",$booking['duration'].' '.$this->lng->txt('paya_months'));
01492                 $this->tpl->setVariable("PRICE",$booking['price']);
01493                 
01494                 $yes_no = array(0 => $this->lng->txt('no'),1 => $this->lng->txt('yes'));
01495 
01496                 $this->tpl->setVariable("PAYED",ilUtil::formSelect((int) $booking['payed'],'payed',$yes_no,false,true));
01497                 $this->tpl->setVariable("ACCESS",ilUtil::formSelect((int) $booking['access'],'access',$yes_no,false,true));
01498 
01499                 // buttons
01500                 $this->tpl->setVariable("INPUT_CMD",'updateStatistic');
01501                 $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('save'));
01502 
01503                 $this->tpl->setVariable("DELETE_CMD",'deleteStatistic');
01504                 $this->tpl->setVariable("DELETE_VALUE",$this->lng->txt('delete'));
01505         }
01506         function updateStatisticObject()
01507         {
01508                 if(!isset($_GET['booking_id']))
01509                 {
01510                         ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
01511                         $this->statisticObject();
01512 
01513                         return true;
01514                 }
01515                 $this->__initBookingObject();
01516 
01517                 $this->booking_obj->setBookingId((int) $_GET['booking_id']);
01518                 $this->booking_obj->setAccess((int) $_POST['access']);
01519                 $this->booking_obj->setPayed((int) $_POST['payed']);
01520                 
01521                 if($this->booking_obj->update())
01522                 {
01523                         ilUtil::sendInfo($this->lng->txt('paya_updated_booking'));
01524 
01525                         $this->statisticObject();
01526                         return true;
01527                 }
01528                 else
01529                 {
01530                         ilUtil::sendInfo($this->lng->txt('paya_error_update_booking'));
01531 
01532                         $this->statisticObject();
01533                         
01534                         return true;
01535                 }
01536         }
01537 
01538         function deleteStatisticObject()
01539         {
01540                 if(!isset($_GET['booking_id']))
01541                 {
01542                         ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
01543                         $this->statisticObject();
01544 
01545                         return true;
01546                 }
01547                 ilUtil::sendInfo($this->lng->txt('paya_sure_delete_stat'));
01548 
01549                 $this->editStatisticObject(true);
01550 
01551                 return true;
01552         }
01553         function performDeleteObject()
01554         {
01555                 if(!isset($_GET['booking_id']))
01556                 {
01557                         ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
01558                         $this->statisticObject();
01559 
01560                         return true;
01561                 }
01562 
01563                 $this->__initBookingObject();
01564                 $this->booking_obj->setBookingId((int) $_GET['booking_id']);
01565                 if(!$this->booking_obj->delete())
01566                 {
01567                         die('Error deleting booking');
01568                 }
01569                 ilUtil::sendInfo($this->lng->txt('pay_deleted_booking'));
01570 
01571                 $this->statisticObject();
01572 
01573                 return true;
01574         }
01575 
01576         function getAdminTabs(&$tabs_gui)
01577         {
01578                 $this->getTabs($tabs_gui);
01579         }
01580 
01586         function getTabs(&$tabs_gui)
01587         {
01588                 global $rbacsystem;
01589 
01590                 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
01591                 {
01592                         $tabs_gui->addTarget("settings",
01593                                 $this->ctrl->getLinkTarget($this, "generalSettings"), array("generalSettings","", "view"), "", "");
01594                                 
01595                         $tabs_gui->addTarget("statistic",
01596                                 $this->ctrl->getLinkTarget($this, "statistic"), "statistic", "", "");
01597                                 
01598                         $tabs_gui->addTarget("objects",
01599                                 $this->ctrl->getLinkTarget($this, "objects"), "objects", "", "");
01600                                 
01601                         $tabs_gui->addTarget("vendors",
01602                                 $this->ctrl->getLinkTarget($this, "vendors"), "vendors", "", "");
01603                                 
01604                         $tabs_gui->addTarget("pay_methods",
01605                                 $this->ctrl->getLinkTarget($this, "payMethods"), "payMethods", "", "");
01606                 }
01607 
01608                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
01609                 {
01610                         $tabs_gui->addTarget("perm_settings",
01611                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
01612                 }
01613         }
01614 
01615         function generalSettingsObject($a_show_confirm = false)
01616         {       
01617                 global $rbacsystem;
01618 
01619                 // MINIMUM ACCESS LEVEL = 'read'
01620                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01621                 {
01622                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
01623                 }
01624                 
01625                 include_once './payment/classes/class.ilGeneralSettings.php';
01626 
01627                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_general_settings.html",'payment');             
01628 
01629                 $genSet = new ilGeneralSettings();
01630                 $genSetData = $genSet->getAll();                
01631                                 
01632                 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");                    
01633                                                 
01634                 $form = new ilPropertyFormGUI();
01635                 $form->setFormAction($this->ctrl->getFormAction($this, "saveGeneralSettings"));
01636                 $form->setTitle($this->lng->txt('pays_general_settings'));
01637                 
01638                 $form->addCommandButton('saveGeneralSettings',$this->lng->txt('save'));
01639                 
01640                 $formItem = new ilTextInputGUI($this->lng->txt("pays_currency_unit"), "currency_unit");
01641                 $formItem->setSize(5);
01642                 $formItem->setValue($this->error != "" && isset($_POST['currency_unit'])
01643                                                 ? ilUtil::prepareFormOutput($_POST['currency_unit'],true)
01644                                                 : ilUtil::prepareFormOutput($genSetData['currency_unit'],true));
01645                 $form->addItem($formItem);
01646                 
01647                 $formItem = new ilTextInputGUI($this->lng->txt("pays_currency_subunit"), "currency_subunit");
01648                 $formItem->setSize(5);
01649                 $formItem->setValue($this->error != "" && isset($_POST['currency_subunit'])
01650                                                         ? ilUtil::prepareFormOutput($_POST['currency_subunit'],true)
01651                                                         : ilUtil::prepareFormOutput($genSetData['currency_subunit'],true));
01652                 $form->addItem($formItem);
01653                 
01654                 $formItem = new ilTextAreaInputGUI($this->lng->txt("pays_address"), "address");
01655                 $formItem->setRows(7);
01656                 $formItem->setCols(35);
01657                 $formItem->setValue($this->error != "" && isset($_POST['address'])
01658                                                         ? ilUtil::prepareFormOutput($_POST['address'],true)
01659                                                         : ilUtil::prepareFormOutput($genSetData['address'],true));
01660                 $form->addItem($formItem);
01661                 
01662                 $formItem = new ilTextAreaInputGUI($this->lng->txt("pays_bank_data"), "bank_data");
01663                 $formItem->setRows(7);
01664                 $formItem->setCols(35);
01665                 $formItem->setValue($this->error != "" && isset($_POST['bank_data'])
01666                                                         ? ilUtil::prepareFormOutput($_POST['bank_data'],true)
01667                                                         : ilUtil::prepareFormOutput($genSetData['bank_data'],true));
01668                 $form->addItem($formItem);
01669                 
01670                 $formItem = new ilTextAreaInputGUI($this->lng->txt("pays_add_info"), "add_info");
01671                 $formItem->setRows(7);
01672                 $formItem->setCols(35);
01673                 $formItem->setValue($this->error != "" && isset($_POST['add_info'])
01674                                                         ? ilUtil::prepareFormOutput($_POST['add_info'],true)
01675                                                         : ilUtil::prepareFormOutput($genSetData['add_info'],true));
01676                 $form->addItem($formItem);
01677                 
01678                 $formItem = new ilTextInputGUI($this->lng->txt("pays_vat_rate"), "vat_rate");
01679                 $formItem->setSize(5);
01680                 $formItem->setValue($this->error != "" && isset($_POST['vat_rate'])
01681                                                         ? ilUtil::prepareFormOutput($_POST['vat_rate'],true)
01682                                                         : ilUtil::prepareFormOutput($genSetData['vat_rate'],true));
01683                 $form->addItem($formItem);
01684                 
01685                 $formItem = new ilTextInputGUI($this->lng->txt("pays_pdf_path"), "pdf_path");
01686                 $formItem->setValue($this->error != "" && isset($_POST['pdf_path'])
01687                                                         ? ilUtil::prepareFormOutput($_POST['pdf_path'],true)
01688                                                         : ilUtil::prepareFormOutput($genSetData['pdf_path'],true));
01689                 $form->addItem($formItem);                      
01690                                 
01691                 $this->tpl->setVariable('GENERAL_SETTINGS',$form->getHTML());
01692         }
01693         
01694         function saveGeneralSettingsObject()
01695         {
01696                 global $rbacsystem;
01697 
01698                 // MINIMUM ACCESS LEVEL = 'read'
01699                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01700                 {
01701                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
01702                 }
01703                 
01704                 include_once './payment/classes/class.ilGeneralSettings.php';
01705 
01706                 $genSet = new ilGeneralSettings();
01707 
01708                 if ($_POST["currency_unit"] == "" ||
01709                         $_POST["currency_subunit"] == "" ||
01710                         $_POST["address"] == "" ||
01711                         $_POST["bank_data"] == "" ||
01712                         $_POST["pdf_path"] == "")
01713                 {
01714                         $this->error = $this->lng->txt('pays_general_settings_not_valid');
01715                         ilUtil::sendInfo($this->error);
01716                         $this->generalSettingsObject();
01717                         return;
01718                 }
01719 
01720                 $genSet->clearAll();
01721                 $values = array(
01722                         "currency_unit" => ilUtil::stripSlashes($_POST['currency_unit']),
01723                         "currency_subunit" => ilUtil::stripSlashes($_POST['currency_subunit']),
01724                         "address" => ilUtil::stripSlashes($_POST['address']),
01725                         "bank_data" => ilUtil::stripSlashes($_POST['bank_data']),
01726                         "add_info" => ilUtil::stripSlashes($_POST['add_info']),
01727                         "vat_rate" => (float) str_replace(",", ".", ilUtil::stripSlashes($_POST['vat_rate'])),
01728                         "pdf_path" => ilUtil::stripSlashes($_POST['pdf_path'])
01729                 );
01730                 $genSet->setAll($values);
01731                 $this->generalSettingsObject();
01732 
01733                 ilUtil::sendInfo($this->lng->txt('pays_updated_general_settings'));
01734 
01735                 return true;
01736         }
01737 
01738         function paypalSettingsObject($a_show_confirm = false)
01739         {       
01740                 global $rbacsystem;
01741 
01742                 // MINIMUM ACCESS LEVEL = 'read'
01743                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01744                 {
01745                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
01746                 }
01747                 
01748                 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
01749                 include_once './payment/classes/class.ilPaypalSettings.php';            
01750 
01751                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_paypal_settings.html",'payment');
01752                 
01753                 $ppSet = ilPaypalSettings::getInstance();
01754                                 
01755                 $form = new ilPropertyFormGUI();
01756                 $form->setFormAction($this->ctrl->getFormAction($this, "savePaypalSettings"));
01757                 $form->setTitle($this->lng->txt('pays_paypal_settings'));
01758                 
01759                 $form->addCommandButton('savePaypalSettings',$this->lng->txt('save'));
01760                 
01761                 $formItem = new ilTextInputGUI($this->lng->txt("pays_server_host"), "server_host");
01762                 $formItem->setValue($ppSet->getServerHost());
01763                 $form->addItem($formItem);
01764                 
01765                 $formItem = new ilTextInputGUI($this->lng->txt("pays_server_path"), "server_path");
01766                 $formItem->setValue($ppSet->getServerPath());
01767                 $form->addItem($formItem);
01768                 
01769                 $formItem = new ilTextInputGUI($this->lng->txt("pays_email_vendor"), "vendor");
01770                 $formItem->setValue($ppSet->getVendor());
01771                 $form->addItem($formItem);
01772                 
01773                 $formItem = new ilTextInputGUI($this->lng->txt("pays_auth_token"), "auth_token");
01774                 $formItem->setValue($ppSet->getAuthToken());
01775                 $form->addItem($formItem);
01776                 
01777                 $formItem = new ilTextInputGUI($this->lng->txt("pays_page_style"), "page_style");
01778                 $formItem->setValue($ppSet->getPageStyle());
01779                 $form->addItem($formItem);
01780                                 
01781                 $this->tpl->setVariable('PAYPAL_SETTINGS',$form->getHTML());            
01782         }
01783         
01784         function savePaypalSettingsObject()
01785         {
01786                 include_once './payment/classes/class.ilPaypalSettings.php';
01787 
01788                 global $rbacsystem;
01789 
01790                 // MINIMUM ACCESS LEVEL = 'read'
01791                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01792                 {
01793                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
01794                 }
01795                 
01796                 $ppSet = ilPaypalSettings::getInstance();
01797                 
01798                 $ppSet->setServerHost(ilUtil::stripSlashes($_POST["server_host"]));
01799                 $ppSet->setServerPath(ilUtil::stripSlashes($_POST["server_path"]));
01800                 $ppSet->setVendor(ilUtil::stripSlashes($_POST["vendor"]));
01801                 $ppSet->setAuthToken(ilUtil::stripSlashes($_POST["auth_token"]));
01802                 $ppSet->setPageStyle(ilUtil::stripSlashes($_POST["page_style"]));
01803                 $ppSet->setSsl(ilUtil::stripSlashes($_POST["ssl"]));            
01804 
01805                 if ($_POST["server_host"] == "" ||
01806                         $_POST["server_path"] == "" ||
01807                         $_POST["vendor"] == "" ||
01808                         $_POST["auth_token"] == "")
01809                 {
01810                         $this->error = $this->lng->txt('pays_paypal_settings_not_valid');
01811                         ilUtil::sendInfo($this->error);
01812                         $this->paypalSettingsObject();
01813                         return;
01814                 }
01815                 
01816                 $ppSet->save();
01817                                 
01818                 $this->paypalSettingsObject();
01819 
01820                 ilUtil::sendInfo($this->lng->txt('pays_updated_paypal_settings'));
01821 
01822                 return true;
01823         }
01824 
01825         function vendorsObject($a_show_confirm = false)
01826         {
01827                 include_once './payment/classes/class.ilPaymentBookings.php';
01828         
01829                 global $rbacsystem;
01830 
01831                 // MINIMUM ACCESS LEVEL = 'read'
01832                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01833                 {
01834                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
01835                 }
01836 
01837                 $_SESSION['pays_vendor'] = is_array($_SESSION['pays_vendor']) ?  $_SESSION['pays_vendor'] : array();
01838                 
01839 
01840                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_vendors.html",'payment');
01841                 
01842                 $this->__showButton('searchUser',$this->lng->txt('search_user'));
01843 
01844                 $this->object->initPaymentVendorsObject();
01845                 if(!count($vendors = $this->object->payment_vendors_obj->getVendors()))
01846                 {
01847                         ilUtil::sendInfo($this->lng->txt('pay_no_vendors_created'));
01848                 }
01849 #               else
01850 #               {
01851 #                       $this->__showButton('exportVendors',$this->lng->txt('excel_export'));
01852 #               }
01853 
01854 
01855 
01856                 if($a_show_confirm)
01857                 {
01858                         $this->tpl->setCurrentBlock("confirm_delete");
01859                         $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
01860                         $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
01861                         $this->tpl->setVariable("CONFIRM_CMD",'performDeleteVendors');
01862                         $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('delete'));
01863                         $this->tpl->parseCurrentBlock();
01864                 }
01865 
01866                 $counter = 0;
01867                 $f_result = array();
01868                 foreach($vendors as $vendor)
01869                 {
01870                         // GET USER OBJ
01871                         if($tmp_obj = ilObjectFactory::getInstanceByObjId($vendor['vendor_id'],false))
01872                         {
01873                                 $f_result[$counter][]   = ilUtil::formCheckbox(in_array($vendor['vendor_id'],$_SESSION['pays_vendor']) ? 1 : 0,
01874                                                                                                                            "vendor[]",
01875                                                                                                                            $vendor['vendor_id']);
01876                                 $f_result[$counter][]   = $tmp_obj->getLogin();
01877                                 $f_result[$counter][]   = $vendor['cost_center'];
01878                                 $f_result[$counter][]   = ilPaymentBookings::_getCountBookingsByVendor($vendor['vendor_id']);
01879                                 
01880                                 unset($tmp_obj);
01881                                 ++$counter;
01882                         }
01883                 } // END VENDORS TABLE
01884                 $this->__showVendorsTable($f_result);
01885 
01886                 return true;
01887         }
01888 
01889         function exportVendorsObject()
01890         {
01891                 include_once './payment/classes/class.ilPaymentExcelWriterAdapter.php';
01892 
01893                 $pewa =& new ilPaymentExcelWriterAdapter('payment_vendors.xls');
01894 
01895                 // add/fill worksheet
01896                 $this->addVendorWorksheet($pewa);
01897                 $this->addStatisticWorksheet($pewa);
01898 
01899                 // HEADER SENT
01900                 
01901                 $workbook =& $pewa->getWorkbook();
01902                 $workbook->close();
01903         }
01904 
01905         function addStatisticWorksheet(&$pewa)
01906         {
01907                 include_once './classes/class.ilExcelUtils.php';
01908                 include_once './payment/classes/class.ilPaymentVendors.php';
01909 
01910                 $this->__initBookingObject();
01911 
01912                 if(!count($bookings = $this->booking_obj->getBookings()))
01913                 {
01914                         return false;
01915                 }
01916 
01917                 $workbook =& $pewa->getWorkbook();
01918                 $worksheet =& $workbook->addWorksheet(utf8_decode($this->lng->txt('paya_statistic')));
01919                 
01920                 $worksheet->mergeCells(0,0,0,8);
01921                 $worksheet->setColumn(0,0,16);
01922                 $worksheet->setColumn(0,1,32);
01923                 $worksheet->setColumn(0,2,32);
01924                 $worksheet->setColumn(0,3,16);
01925                 $worksheet->setColumn(0,4,16);
01926                 $worksheet->setColumn(0,5,16);
01927                 $worksheet->setColumn(0,6,24);
01928                 $worksheet->setColumn(0,7,8);
01929                 $worksheet->setColumn(0,8,12);
01930                 $worksheet->setColumn(0,9,16);
01931 
01932                 $title = $this->lng->txt('paya_statistic');
01933                 $title .= ' '.$this->lng->txt('as_of');
01934                 $title .= strftime('%Y-%m-%d %R',time());
01935 
01936                 $worksheet->writeString(0,0,$title,$pewa->getFormatTitle());
01937 
01938                 $worksheet->writeString(1,0,ilExcelUtils::_convert_text($this->lng->txt('payment_system')),$pewa->getFormatHeader());
01939                 $worksheet->writeString(1,1,ilExcelUtils::_convert_text($this->lng->txt('paya_transaction')),$pewa->getFormatHeader());
01940                 $worksheet->writeString(1,2,ilExcelUtils::_convert_text($this->lng->txt('title')),$pewa->getFormatHeader());
01941                 $worksheet->writeString(1,3,ilExcelUtils::_convert_text($this->lng->txt('paya_vendor')),$pewa->getFormatHeader());
01942                 $worksheet->writeString(1,4,ilExcelUtils::_convert_text($this->lng->txt('pays_cost_center')),$pewa->getFormatHeader());
01943                 $worksheet->writeString(1,5,ilExcelUtils::_convert_text($this->lng->txt('paya_customer')),$pewa->getFormatHeader());
01944                 $worksheet->writeString(1,6,ilExcelUtils::_convert_text($this->lng->txt('paya_order_date')),$pewa->getFormatHeader());
01945                 $worksheet->writeString(1,7,ilExcelUtils::_convert_text($this->lng->txt('duration')),$pewa->getFormatHeader());
01946                 $worksheet->writeString(1,8,ilExcelUtils::_convert_text($this->lng->txt('price_a')),$pewa->getFormatHeader());
01947                 $worksheet->writeString(1,9,ilExcelUtils::_convert_text($this->lng->txt('paya_payed_access')),$pewa->getFormatHeader());
01948 
01949                 include_once 'Services/User/classes/class.ilObjUser.php';
01950                 $object_title_cache = array();
01951                 $user_title_cache = array();
01952 
01953                 $counter = 2;
01954                 foreach($bookings as $booking)
01955                 {
01956                         if(array_key_exists($booking['ref_id'], $object_title_cache))
01957                         {
01958                                 $tmp_obj = $object_title_cache[$booking['ref_id']];
01959                         }
01960                         else
01961                         {
01962                                 $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($booking['ref_id']));                          
01963                                 $object_title_cache[$booking['ref_id']] = $tmp_obj;
01964                         }
01965                         if(array_key_exists($booking['b_vendor_id'], $user_title_cache))
01966                         {
01967                                 $tmp_vendor = $user_title_cache[$booking['b_vendor_id']];
01968                         }
01969                         else
01970                         {
01971                                 $tmp_vendor = ilObjUser::_lookupLogin($booking['b_vendor_id']);
01972                                 $user_title_cache[$booking['b_vendor_id']] = $tmp_vendor;
01973                         }
01974                         if(array_key_exists($booking['customer_id'], $user_title_cache))
01975                         {
01976                                 $tmp_purchaser = $user_title_cache[$booking['customer_id']];
01977                         }
01978                         else
01979                         {
01980                                 $tmp_purchaser = ilObjUser::_lookupLogin($booking['customer_id']);
01981                                 $user_title_cache[$booking['customer_id']] = $tmp_purchaser;
01982                         }
01983                         
01984                         switch ($booking['b_pay_method'])
01985                         {
01986                                 case $this->pobject->PAY_METHOD_BILL :
01987                                         $pay_method = $this->lng->txt("pays_bill");
01988                                         break;
01989                                 case $this->pobject->PAY_METHOD_BMF :
01990                                         $pay_method = $this->lng->txt("pays_bmf");
01991                                         break;
01992                                 case $this->pobject->PAY_METHOD_PAYPAL :
01993                                         $pay_method = $this->lng->txt("pays_paypal");
01994                                         break;
01995                         }
01996                         $worksheet->writeString($counter,0,ilExcelUtils::_convert_text($pay_method));
01997                         $worksheet->writeString($counter,1,ilExcelUtils::_convert_text($booking['transaction_extern']));
01998                         $worksheet->writeString($counter,2,ilExcelUtils::_convert_text(($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted'))));
01999                         $worksheet->writeString($counter,3,ilExcelUtils::_convert_text(($tmp_vendor != '' ? $tmp_vendor : $this->lng->txt('user_deleted'))));
02000                         $worksheet->writeString($counter,4,ilExcelUtils::_convert_text(ilPaymentVendors::_getCostCenter($booking['b_vendor_id'])));
02001                         $worksheet->writeString($counter,5,ilExcelUtils::_convert_text(($tmp_purchaser != '' ? $tmp_purchaser : $this->lng->txt('user_deleted'))));
02002                         $worksheet->writeString($counter,6,strftime('%Y-%m-%d %R',$booking['order_date']));
02003                         /*
02004                         $worksheet->write($counter,5,ilUtil::excelTime(date('Y',$booking['order_date']),
02005                                                                                                                    date('m',$booking['order_date']),
02006                                                                                                                    date('d',$booking['order_date']),
02007                                                                                                                    date('H',$booking['order_date']),
02008                                                                                                                    date('i',$booking['order_date']),
02009                                                                                                                    date('s',$booking['order_date'])),$pewa->getFormatDate());
02010                         */
02011                         $worksheet->writeString($counter,7,$booking['duration']);
02012                         $worksheet->writeString($counter,8,ilExcelUtils::_convert_text($booking['price']));
02013                         
02014                         $payed_access = $booking['payed'] ? 
02015                                 $this->lng->txt('yes') : 
02016                                 $this->lng->txt('no');
02017 
02018                         $payed_access .= '/';
02019                         $payed_access .= $booking['access'] ?
02020                                 $this->lng->txt('yes') : 
02021                                 $this->lng->txt('no');
02022 
02023                         $worksheet->writeString($counter,9,$payed_access);
02024 
02025                         unset($tmp_obj);
02026                         unset($tmp_vendor);
02027                         unset($tmp_purchaser);
02028 
02029                         ++$counter;
02030                 }
02031         }               
02032 
02033         function addVendorWorksheet(&$pewa)
02034         {
02035                 include_once './classes/class.ilExcelUtils.php';
02036 
02037                 $this->object->initPaymentVendorsObject();
02038                 if(!count($vendors = $this->object->payment_vendors_obj->getVendors()))
02039                 {
02040                         return false;
02041                 }
02042 
02043                 $workbook =& $pewa->getWorkbook();
02044                 $worksheet =& $workbook->addWorksheet(ilExcelUtils::_convert_text($this->lng->txt('pays_vendor')));
02045 
02046                 // SHOW HEADER
02047                 $worksheet->mergeCells(0,0,0,2);
02048                 $worksheet->setColumn(1,0,32);
02049                 $worksheet->setColumn(1,1,32);
02050                 $worksheet->setColumn(1,2,32);
02051 
02052                 $title = $this->lng->txt('paya_vendor_list');
02053                 $title .= ' '.$this->lng->txt('as_of');
02054                 $title .= strftime('%Y-%m-%d %R',time());
02055 
02056                 $worksheet->writeString(0,0,$title,$pewa->getFormatTitle());
02057 
02058                 $worksheet->writeString(1,0,ilExcelUtils::_convert_text($this->lng->txt('login')),$pewa->getFormatHeader());
02059                 $worksheet->writeString(1,1,ilExcelUtils::_convert_text($this->lng->txt('fullname')),$pewa->getFormatHeader());
02060                 $worksheet->writeString(1,2,ilExcelUtils::_convert_text($this->lng->txt('pays_cost_center')),$pewa->getFormatHeader());
02061 
02062                 $counter = 2;
02063                 foreach($vendors as $vendor)
02064                 {
02065                         // GET USER OBJ
02066                         if($tmp_obj = ilObjectFactory::getInstanceByObjId($vendor['vendor_id'],false))
02067                         {
02068                                 $worksheet->writeString($counter,0,ilExcelUtils::_convert_text($tmp_obj->getLogin()));
02069                                 $worksheet->writeString($counter,1,ilExcelUtils::_convert_text($tmp_obj->getFullname()));
02070                                 $worksheet->writeString($counter,2,ilExcelUtils::_convert_text($vendor['cost_center']));
02071                         }
02072                         unset($tmp_obj);
02073                         ++$counter;
02074                 }
02075         }               
02076         
02077         function payMethodsObject()
02078         {
02079                 include_once './payment/classes/class.ilPayMethods.php';
02080 
02081                 global $rbacsystem;
02082 
02083                 // MINIMUM ACCESS LEVEL = 'read'
02084                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
02085                 {
02086                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
02087                 }
02088 
02089                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_pay_methods.html",'payment');
02090 
02091                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
02092                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_pays.gif'));
02093                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_pays'));
02094                 $this->tpl->setVariable("TITLE",$this->lng->txt('pays_pay_methods'));
02095                 $this->tpl->setVariable("TXT_OFFLINE",$this->lng->txt('pays_offline'));
02096                 $this->tpl->setVariable("TXT_BILL",$this->lng->txt('pays_bill'));
02097                 $this->tpl->setVariable("BILL_CHECK",ilUtil::formCheckbox(
02098                                                                         (int) ilPayMethods::_enabled('pm_bill') ? 1 : 0,'pm_bill',1,true));
02099 
02100                 $this->tpl->setVariable("TXT_ENABLED",$this->lng->txt('enabled'));
02101                 $this->tpl->setVariable("TXT_ONLINE",$this->lng->txt('pays_online'));
02102                 $this->tpl->setVariable("TXT_BMF",$this->lng->txt('pays_bmf'));
02103                 $this->tpl->setVariable("BMF_ONLINE_CHECK",ilUtil::formCheckbox((int) ilPayMethods::_enabled('pm_bmf'),'pm_bmf',1));
02104                 
02105                 $this->tpl->setVariable("TXT_ENABLED",$this->lng->txt('enabled'));
02106                 $this->tpl->setVariable("TXT_ONLINE",$this->lng->txt('pays_online'));
02107                 $this->tpl->setVariable("TXT_PAYPAL",$this->lng->txt('pays_paypal'));
02108                 $this->tpl->setVariable("PAYPAL_ONLINE_CHECK",ilUtil::formCheckbox((int) ilPayMethods::_enabled('pm_paypal'),'pm_paypal',1));
02109                 
02110                 // footer
02111                 $this->tpl->setVariable("COLUMN_COUNT",3);
02112                 $this->tpl->setVariable("PBTN_NAME",'savePayMethods');
02113                 $this->tpl->setVariable("PBTN_VALUE",$this->lng->txt('save'));
02114                 
02115         }
02116 
02117         function savePayMethodsObject()
02118         {
02119                 include_once './payment/classes/class.ilPayMethods.php';
02120                 include_once './payment/classes/class.ilPaymentObject.php';
02121 
02122 
02123                 global $rbacsystem;
02124 
02125                 // MINIMUM ACCESS LEVEL = 'read'
02126                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
02127                 {
02128                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
02129                 }
02130                 
02131 
02132                 // check current payings
02133                 if(ilPayMethods::_enabled('pm_bill') and !$_POST['pm_bill'])
02134                 {
02135                         if(ilPaymentObject::_getCountObjectsByPayMethod('pm_bill'))
02136                         {
02137                                 ilUtil::sendInfo($this->lng->txt('pays_objects_bill_exist'));
02138                                 $this->payMethodsObject();
02139 
02140                                 return false;
02141                         }
02142                 }
02143 
02144                 if(ilPayMethods::_enabled('pm_bmf') and !$_POST['pm_bmf'])
02145                 {
02146                         if(ilPaymentObject::_getCountObjectsByPayMethod('pm_bmf'))
02147                         {
02148                                 ilUtil::sendInfo($this->lng->txt('pays_objects_bmf_exist'));
02149                                 $this->payMethodsObject();
02150 
02151                                 return false;
02152                         }
02153                 }
02154 
02155                 if(ilPayMethods::_enabled('pm_paypal') and !$_POST['pm_paypal'])
02156                 {
02157                         if(ilPaymentObject::_getCountObjectsByPayMethod('pm_paypal'))
02158                         {
02159                                 ilUtil::sendInfo($this->lng->txt('pays_objects_paypal_exist'));
02160                                 $this->payMethodsObject();
02161 
02162                                 return false;
02163                         }
02164                 }
02165 
02166                 ilPayMethods::_disableAll();
02167                 if(isset($_POST['pm_bill']))
02168                 {
02169                         ilPayMethods::_enable('pm_bill');
02170                 }
02171                 if(isset($_POST['pm_bmf']))
02172                 {
02173                         ilPayMethods::_enable('pm_bmf');
02174                 }
02175                 if(isset($_POST['pm_paypal']))
02176                 {
02177                         ilPayMethods::_enable('pm_paypal');
02178                 }
02179                 $this->payMethodsObject();
02180 
02181                 ilUtil::sendInfo($this->lng->txt('pays_updated_pay_method'));
02182 
02183                 return true;
02184         }
02185 
02186         function cancelDeleteVendorsObject()
02187         {
02188                 unset($_SESSION['pays_vendor']);
02189                 $this->vendorsObject();
02190 
02191                 return true;
02192         }
02193 
02194         function deleteVendors()
02195         {
02196                 include_once './payment/classes/class.ilPaymentBookings.php';
02197 
02198                 if(!count($_POST['vendor']))
02199                 {
02200                         ilUtil::sendInfo($this->lng->txt('pays_no_vendor_selected'));
02201                         $this->vendorsObject();
02202 
02203                         return true;
02204                 }
02205                 // CHECK BOOKINGS
02206                 foreach($_POST['vendor'] as $vendor)
02207                 {
02208                         if(ilPaymentBookings::_getCountBookingsByVendor($vendor))
02209                         {
02210                                 ilUtil::sendInfo($this->lng->txt('pays_active_bookings'));
02211                                 $this->vendorsObject();
02212 
02213                                 return true;
02214                         }
02215                 }
02216                 
02217                 $_SESSION["pays_vendor"] = $_POST["vendor"];
02218                 ilUtil::sendInfo($this->lng->txt("pays_sure_delete_selected_vendors"));
02219                 $this->vendorsObject(true);
02220 
02221                 return true;
02222         }
02223         function performDeleteVendorsObject()
02224         {
02225                 include_once './payment/classes/class.ilPaymentTrustees.php';
02226                 
02227                 global $rbacsystem;
02228 
02229                 // MINIMUM ACCESS LEVEL = 'read'
02230                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
02231                 {
02232                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
02233                 }
02234 
02235                 $this->object->initPaymentVendorsObject();
02236 
02237                 foreach($_SESSION['pays_vendor'] as $vendor)
02238                 {
02239                         $this->object->payment_vendors_obj->delete($vendor);
02240                         ilPaymentTrustees::_deleteTrusteesOfVendor($vendor);
02241                 }
02242 
02243                 ilUtil::sendInfo($this->lng->txt('pays_deleted_number_vendors').' '.count($_SESSION['pays_vendor']));
02244                 unset($_SESSION['pays_vendor']);
02245                 
02246                 $this->vendorsObject();
02247 
02248                 return true;
02249         }
02250 
02251         function editVendor()
02252         {
02253                 global $rbacsystem;
02254 
02255                 // MINIMUM ACCESS LEVEL = 'read'
02256                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
02257                 {
02258                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
02259                 }
02260 
02261                 if(!count($_POST['vendor']))
02262                 {
02263                         ilUtil::sendInfo($this->lng->txt('pays_no_vendor_selected'));
02264                         $this->vendorsObject();
02265 
02266                         return true;
02267                 }
02268                 if(count($_POST['vendor']) > 1)
02269                 {
02270                         ilUtil::sendInfo($this->lng->txt('pays_too_many_vendors_selected'));
02271                         $this->vendorsObject();
02272 
02273                         return true;
02274                 }
02275 
02276                 $_SESSION["pays_vendor"] = $_POST["vendor"][0];
02277 
02278                 $this->object->initPaymentVendorsObject();
02279 
02280                 if (!is_array($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]))
02281                 {
02282                         $this->vendorsObject();
02283 
02284                         return true;
02285                 }
02286 
02287                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pays_vendor.html','payment');
02288 
02289                 $this->tpl->setVariable("VENDOR_FORMACTION",$this->ctrl->getFormAction($this));
02290 
02291                 // set table header
02292                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_usr.gif'));
02293                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
02294                 $this->tpl->setVariable("TITLE",$this->lng->txt('pays_vendor'));
02295 
02296                 // set plain text variables
02297                 $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('pays_vendor'));
02298                 $this->tpl->setVariable("TXT_COST_CENTER",$this->lng->txt('pays_cost_center'));
02299 
02300                 $this->tpl->setVariable("INPUT_VALUE",ucfirst($this->lng->txt('save')));
02301 
02302                 // fill defaults
02303 
02304                 $this->tpl->setVariable("VENDOR",
02305                                                                 ilObjUser::getLoginByUserId($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]["vendor_id"]), true);
02306                 $this->tpl->setVariable("COST_CENTER",
02307                                                                 $this->error != "" && isset($_POST['cost_center'])
02308                                                                 ? ilUtil::prepareFormOutput($_POST['cost_center'],true)
02309                                                                 : ilUtil::prepareFormOutput($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]["cost_center"],true));
02310 
02311                 // Button
02312                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
02313                 $this->tpl->setCurrentBlock("btn_cell");
02314                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "vendors"));
02315                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt('pay_bmf_back'));
02316                 $this->tpl->parseCurrentBlock("btn_cell");
02317 
02318         }
02319         function performEditVendorObject()
02320         {
02321                 global $rbacsystem;
02322 
02323                 // MINIMUM ACCESS LEVEL = 'read'
02324                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
02325                 {
02326                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
02327                 }
02328 
02329                 if(!count($_SESSION['pays_vendor']))
02330                 {
02331                         ilUtil::sendInfo($this->lng->txt('pays_no_vendor_selected'));
02332                         $this->vendorsObject();
02333 
02334                         return true;
02335                 }
02336                 if(count($_SESSION['pays_vendor']) > 1)
02337                 {
02338                         ilUtil::sendInfo($this->lng->txt('pays_too_many_vendors_selected'));
02339                         $this->vendorsObject();
02340 
02341                         return true;
02342                 }
02343 
02344                 $this->object->initPaymentVendorsObject();
02345 
02346                 if (!is_array($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]))
02347                 {
02348                         $this->vendorsObject();
02349 
02350                         return true;
02351                 }
02352 
02353                 if ($_POST["cost_center"] == "")
02354                 {
02355                         $this->error = $this->lng->txt('pays_cost_center_not_valid');
02356                         ilUtil::sendInfo($this->error);
02357                         $_POST["vendor"] = array($_SESSION["pays_vendor"]);
02358                         $this->editVendor();
02359                         return;
02360                 }
02361 
02362                 $this->object->initPaymentVendorsObject();
02363                 $this->object->payment_vendors_obj->update($_SESSION["pays_vendor"], $_POST["cost_center"]);
02364 
02365                 unset($_SESSION['pays_vendor']);
02366 
02367                 $this->vendorsObject();
02368 
02369                 return true;
02370         }
02371 
02372         function showObjectSelectorObject()
02373         {
02374                 global $rbacsystem, $tree;
02375 
02376                 // MINIMUM ACCESS LEVEL = 'read'
02377                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
02378                 {
02379                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
02380                 }
02381 
02382                 include_once './payment/classes/class.ilPaymentObjectSelector.php';
02383 
02384                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paya_object_selector.html",'payment');
02385                 $this->__showButton('statistic',$this->lng->txt('back'));
02386 
02387 
02388                 ilUtil::sendInfo($this->lng->txt("paya_select_object_to_sell"));
02389 
02390                 $exp = new ilPaymentObjectSelector($this->ctrl->getLinkTarget($this,'showObjectSelector'), strtolower(get_class($this)));
02391                 $exp->setExpand($_GET["paya_link_expand"] ? $_GET["paya_link_expand"] : $tree->readRootId());
02392                 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showObjectSelector'));
02393                 
02394                 $exp->setOutput(0);
02395 
02396                 $this->tpl->setVariable("EXPLORER",$exp->getOutput());
02397 
02398                 return true;
02399         }
02400 
02401         function searchUserObject()
02402         {
02403                 global $rbacsystem;
02404 
02405                 // MINIMUM ACCESS LEVEL = 'read'
02406                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
02407                 {
02408                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
02409                 }
02410 
02411                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.pays_user_search.html",'payment');
02412                 $this->__showButton('vendors',$this->lng->txt('back'));
02413 
02414                 $this->lng->loadLanguageModule('search');
02415 
02416                 $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
02417                 $this->tpl->setVariable("SEARCH_ASSIGN_USR",$this->lng->txt("crs_search_members"));
02418                 $this->tpl->setVariable("SEARCH_SEARCH_TERM",$this->lng->txt("search_search_term"));
02419                 $this->tpl->setVariable("SEARCH_VALUE",$_SESSION["pays_search_str"] ? $_SESSION["pays_search_str"] : "");
02420                 $this->tpl->setVariable("BTN2_VALUE",$this->lng->txt("cancel"));
02421                 $this->tpl->setVariable("BTN1_VALUE",$this->lng->txt("search"));
02422 
02423                 return true;
02424         }
02425 
02426         function searchObject()
02427         {
02428                 global $rbacsystem,$tree;
02429 
02430                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
02431                 {
02432                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
02433                 }
02434 
02435                 $_SESSION["pays_search_str"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["pays_search_str"];
02436 
02437                 if(!isset($_POST["search_str"]))
02438                 {
02439                         ilUtil::sendInfo($this->lng->txt("crs_search_enter_search_string"));
02440                         $this->searchUserObject();
02441                         
02442                         return false;
02443                 }
02444                 if(!count($result = $this->__search(ilUtil::stripSlashes($_POST["search_str"]))))
02445                 {
02446                         ilUtil::sendInfo($this->lng->txt("crs_no_results_found"));
02447                         $this->searchUserObject();
02448 
02449                         return false;
02450                 }
02451 
02452                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_usr_selection.html",'payment');
02453                 $this->__showButton("searchUser",$this->lng->txt("crs_new_search"));
02454                 
02455                 $counter = 0;
02456                 $f_result = array();
02457                 foreach($result as $user)
02458                 {
02459                         if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user["id"],false))
02460                         {
02461                                 continue;
02462                         }
02463                         $f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user["id"]);
02464                         $f_result[$counter][] = $tmp_obj->getLogin();
02465                         $f_result[$counter][] = $tmp_obj->getLastname();
02466                         $f_result[$counter][] = $tmp_obj->getFirstname();
02467 
02468                         unset($tmp_obj);
02469                         ++$counter;
02470                 }
02471                 $this->__showSearchUserTable($f_result);
02472 
02473                 return true;
02474         }
02475         function addVendorObject()
02476         {
02477                 global $rbacsystem;
02478 
02479                 // MINIMUM ACCESS LEVEL = 'administrate'
02480                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
02481                 {
02482                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
02483                 }
02484                 if(!$_POST['vendor_login'])
02485                 {
02486                         ilUtil::sendInfo($this->lng->txt('pays_no_username_given'));
02487                         $this->vendorsObject();
02488 
02489                         return true;
02490                 }
02491                 if(!($usr_id = ilObjUser::getUserIdByLogin(ilUtil::stripSlashes($_POST['vendor_login']))))
02492                 {
02493                         ilUtil::sendInfo($this->lng->txt('pays_no_valid_username_given'));
02494                         $this->vendorsObject();
02495 
02496                         return true;
02497                 }
02498                 
02499                 $this->object->initPaymentVendorsObject();
02500 
02501                 if($this->object->payment_vendors_obj->isAssigned($usr_id))
02502                 {
02503                         ilUtil::sendInfo($this->lng->txt('pays_user_already_assigned'));
02504                         $this->vendorsObject();
02505 
02506                         return true;
02507                 }
02508                 $this->object->payment_vendors_obj->add($usr_id);
02509 
02510                 ilUtil::sendInfo($this->lng->txt('pays_added_vendor'));
02511                 $this->vendorsObject();
02512                 
02513                 return true;
02514         }
02515                 
02516         function addUserObject()
02517         {
02518                 global $rbacsystem;
02519 
02520                 // MINIMUM ACCESS LEVEL = 'administrate'
02521                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
02522                 {
02523                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
02524                 }
02525 
02526                 $this->lng->loadLanguageModule('crs');
02527                 if(!is_array($_POST["user"]))
02528                 {
02529                         ilUtil::sendInfo($this->lng->txt("crs_no_users_selected"));
02530                         $this->searchObject();
02531 
02532                         return false;
02533                 }
02534                 
02535                 $this->object->initPaymentVendorsObject();
02536 
02537                 $already_assigned = $assigned = 0;
02538                 foreach($_POST['user'] as $usr_id)
02539                 {
02540                         if($this->object->payment_vendors_obj->isAssigned($usr_id))
02541                         {
02542                                 ++$already_assigned;
02543 
02544                                 continue;
02545                         }
02546                         $this->object->payment_vendors_obj->add($usr_id);
02547                         ++$assigned;
02548                         
02549                         // TODO: SEND NOTIFICATION
02550                 }
02551                 $message = '';
02552                 if($assigned)
02553                 {
02554                         $message .= $this->lng->txt('pays_assigned_vendors').' '.$assigned;
02555                 }
02556                 if($already_assigned)
02557                 {
02558                         $message .= '<br />'.$this->lng->txt('pays_already_assigned_vendors').' '.$already_assigned;
02559                 }
02560 
02561                 ilUtil::sendInfo($message);
02562                 $this->vendorsObject();
02563 
02564                 return true;
02565         }               
02566 
02567 
02568         function searchUserSPObject()
02569         {
02570                 if(!isset($_GET['sell_id']))
02571                 {
02572                         ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
02573                         $this->showObjectSelectorObject();
02574 
02575                         return false;
02576                 }
02577 
02578                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.paya_user_search.html",'payment');
02579                 $this->__showButton('showObjectSelector',$this->lng->txt('back'));
02580 
02581                 $this->lng->loadLanguageModule('search');
02582 
02583                 $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
02584                 $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
02585                 $this->tpl->setVariable("SEARCH_ASSIGN_USR",$this->lng->txt("search_user"));
02586                 $this->tpl->setVariable("SEARCH_SEARCH_TERM",$this->lng->txt("search_search_term"));
02587                 $this->tpl->setVariable("SEARCH_VALUE",$_SESSION["paya_search_str_user_sp"] ? $_SESSION["paya_search_str_user_sp"] : "");
02588                 $this->tpl->setVariable("BTN2_VALUE",$this->lng->txt("cancel"));
02589                 $this->tpl->setVariable("BTN1_VALUE",$this->lng->txt("search"));
02590                 $this->tpl->setVariable("SEARCH","performSearchSP");
02591                 $this->tpl->setVariable("CANCEL","statistic");
02592 
02593                 return true;
02594         }
02595 
02596         function performSearchSPObject()
02597         {
02598                 // SAVE it to allow sort in tables
02599                 $_SESSION["paya_search_str_user_sp"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["paya_search_str_user_sp"];
02600 
02601                 if(!trim($_POST["search_str"]))
02602                 {
02603                         ilUtil::sendInfo($this->lng->txt("search_no_search_term"));
02604                         $this->statistics();
02605 
02606                         return false;
02607                 }
02608                 if(!count($result = $this->__search(ilUtil::stripSlashes($_POST["search_str"]))))
02609                 {
02610                         ilUtil::sendInfo($this->lng->txt("search_no_match"));
02611                         $this->searchUserSPObject();
02612 
02613                         return false;
02614                 }
02615 
02616                 if(!isset($_GET['sell_id']))
02617                 {
02618                         ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
02619                         $this->showObjectSelectorObject();
02620 
02621                         return false;
02622                 }
02623 
02624                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paya_usr_selection.html",'payment');
02625                 $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
02626                 $this->__showButton("searchUserSP",$this->lng->txt("back"));
02627                 
02628                 $counter = 0;
02629                 $f_result = array();
02630                 foreach($result as $user)
02631                 {
02632                         if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user["id"],false))
02633                         {
02634                                 continue;
02635                         }
02636                         $f_result[$counter][] = ilUtil::formRadiobutton(0,"user_id",$user["id"]);
02637                         $f_result[$counter][] = $tmp_obj->getLogin();
02638                         $f_result[$counter][] = $tmp_obj->getFirstname();
02639                         $f_result[$counter][] = $tmp_obj->getLastname();
02640                         
02641                         unset($tmp_obj);
02642                         ++$counter;
02643                 }
02644                 $this->__showSearchUserSPTable($f_result);
02645         }
02646 
02647         function addCustomerObject()
02648         {
02649                 if ($_POST["sell_id"] != "") $_GET["sell_id"] = $_POST["sell_id"];
02650                 if ($_GET["user_id"] != "") $_POST["user_id"] = $_GET["user_id"];
02651 
02652                 if(!isset($_GET['sell_id']))
02653                 {
02654                         ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
02655                         $this->showObjectSelectorObject();
02656 
02657                         return true;
02658                 }
02659 
02660                 if(!isset($_POST['user_id']))
02661                 {
02662                         ilUtil::sendInfo($this->lng->txt('paya_no_user_id_given'));
02663                         $this->searchUserSPObject();
02664 
02665                         return true;
02666                 }
02667 
02668                 $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
02669                 $this->__showButton('searchUserSP',$this->lng->txt('back'));
02670 
02671                 $this->ctrl->setParameter($this, "user_id", $_POST["user_id"]);
02672 
02673                 $pObjectId = ilPaymentObject::_lookupPobjectId($_GET["sell_id"]);
02674                 $obj =& new ilPaymentObject($this->user_obj, $pObjectId);
02675 
02676                 // get obj
02677                 $tmp_obj =& ilObjectFactory::getInstanceByRefId($_GET["sell_id"]);
02678                 // get customer_obj
02679                 $tmp_user =& ilObjectFactory::getInstanceByObjId($_POST["user_id"]);
02680                 // get vendor_obj
02681                 $tmp_vendor =& ilObjectFactory::getInstanceByObjId($obj->getVendorId());
02682 
02683                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_add_customer.html','payment');
02684 
02685                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
02686 
02687                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_usr.gif'));
02688                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
02689                 $this->tpl->setVariable("TITLE",$tmp_user->getFullname().' ['.$tmp_user->getLogin().']');
02690 
02691                 // TXT
02692                 $this->tpl->setVariable("TXT_TRANSACTION",$this->lng->txt('paya_transaction'));
02693                 $this->tpl->setVariable("TRANSACTION",ilUtil::prepareFormOutput($_POST["transaction"], true));
02694 
02695                 $this->tpl->setVariable("TXT_OB JECT",$this->lng->txt('title'));
02696                 $this->tpl->setVariable("OBJECT",$tmp_obj->getTitle());
02697 
02698                 $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
02699                 $this->tpl->setVariable("VENDOR",$tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']');
02700 
02701                 $this->tpl->setVariable("TXT_PAY_METHOD",$this->lng->txt('paya_pay_method'));
02702                 $this->tpl->setVariable("TXT_PAY_METHOD_BILL",$this->lng->txt('pays_bill'));
02703                 $this->tpl->setVariable("TXT_PAY_METHOD_BMF",$this->lng->txt('pays_bmf'));
02704                 $this->tpl->setVariable("TXT_PAY_METHOD_PAYPAL",$this->lng->txt('pays_paypal'));
02705                 $this->tpl->setVariable("PAY_METHOD_".$_POST["pay_method"], " selected");
02706 
02707                 $this->tpl->setVariable("TXT_ORDER_DATE",$this->lng->txt('paya_order_date'));
02708                 $this->tpl->setVariable("ORDER_DATE",ilFormat::formatUnixTime(time(), true));
02709 
02710                 $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('duration'));
02711                 include_once './payment/classes/class.ilPaymentPrices.php';
02712                 $prices_obj =& new ilPaymentPrices($pObjectId);
02713                 if (is_array($prices = $prices_obj->getPrices()))
02714                 {
02715                         foreach($prices as $price)
02716                         {
02717                                 $this->tpl->setCurrentBlock("duration_loop");
02718                                 if ($_POST["duration"] == $price["price_id"]) $this->tpl->setVariable("DURATION_LOOP_SELECTED", " selected");
02719                                 $this->tpl->setVariable("DURATION_LOOP_ID", $price["price_id"]);
02720                                 $this->tpl->setVariable("DURATION_LOOP_NAME", $price["duration"]." ".$this->lng->txt("paya_months").", ".ilPaymentPrices::_getPriceString($price["price_id"]));
02721                                 $this->tpl->parseCurrentBlock();
02722                         }
02723                 }
02724 
02725                 $this->tpl->setVariable("TXT_PAYED",$this->lng->txt('paya_payed'));
02726                 if ($_POST["payed"] == 1) $this->tpl->setVariable("PAYED_1", " selected");
02727                 $this->tpl->setVariable("TXT_ACCESS",$this->lng->txt('paya_access'));
02728                 if ($_POST["access"] == 1) $this->tpl->setVariable("ACCESS_1", " selected");
02729 
02730                 $this->tpl->setVariable("TXT_NO",$this->lng->txt('no'));
02731                 $this->tpl->setVariable("TXT_YES",$this->lng->txt('yes'));
02732                 $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
02733                 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
02734                 $this->tpl->setVariable("STATISTICS","statistic");
02735 
02736         }
02737 
02738         function saveCustomerObject()
02739         {
02740                 global $ilias;
02741 
02742                 if(!isset($_GET['sell_id']))
02743                 {
02744                         ilUtil::sendInfo($this->lng->txt('paya_error_no_object_id_given'));
02745                         $this->showObjectSelectorObject();
02746 
02747                         return true;
02748                 }
02749 
02750                 if(!isset($_GET['user_id']))
02751                 {
02752                         ilUtil::sendInfo($this->lng->txt('paya_error_no_user_id_given'));
02753                         $this->searchUserSPObject();
02754 
02755                         return true;
02756                 }
02757 
02758                 if ($_POST["pay_method"] == "" ||
02759                         $_POST["duration"] == "")
02760                 {
02761                         ilUtil::sendInfo($this->lng->txt('paya_error_mandatory_fields'));
02762                         $this->addCustomerObject();
02763 
02764                         return true;
02765                 }
02766 
02767                 $pObjectId = ilPaymentObject::_lookupPobjectId($_GET["sell_id"]);
02768                 $obj =& new ilPaymentObject($this->user_obj, $pObjectId);
02769 
02770                 $this->__initBookingObject();
02771 
02772                 $inst_id_time = $ilias->getSetting('inst_id').'_'.$this->user_obj->getId().'_'.substr((string) time(),-3);
02773                 $transaction = $inst_id_time.substr(md5(uniqid(rand(), true)), 0, 4);
02774                 $this->booking_obj->setTransaction($transaction);
02775                 $this->booking_obj->setTransactionExtern($_POST["transaction"]);
02776                 $this->booking_obj->setPobjectId($pObjectId);
02777                 $this->booking_obj->setCustomerId($_GET["user_id"]);
02778                 $this->booking_obj->setVendorId($obj->getVendorId());
02779                 $this->booking_obj->setPayMethod((int) $_POST["pay_method"]);
02780                 $this->booking_obj->setOrderDate(time());
02781                 include_once './payment/classes/class.ilPaymentPrices.php';
02782                 $price = ilPaymentPrices::_getPrice($_POST["duration"]);
02783                 $this->booking_obj->setDuration($price["duration"]);
02784                 $this->booking_obj->setPrice(ilPaymentPrices::_getPriceString($_POST["duration"]));
02785                 $this->booking_obj->setAccess((int) $_POST['access']);
02786                 $this->booking_obj->setPayed((int) $_POST['payed']);
02787                 $this->booking_obj->setVoucher('');
02788 
02789                 if($this->booking_obj->add())
02790                 {
02791                         ilUtil::sendInfo($this->lng->txt('paya_customer_added_successfully'));
02792                         $this->statisticObject();
02793                 }
02794                 else
02795                 {
02796                         ilUtil::sendInfo($this->lng->txt('paya_error_adding_customer'));
02797                         $this->addCustomerObject();
02798                 }
02799 
02800                 return true;
02801         }
02802 
02803         // PRIVATE
02804         function __setSection($a_section)
02805         {
02806                 $this->section = $a_section;
02807         }
02808         function __getSection()
02809         {
02810                 return $this->section;
02811         }
02812         function __setMainSection($a_section)
02813         {
02814                 $this->mainSection = $a_section;
02815         }
02816         function __getMainSection()
02817         {
02818                 return $this->mainSection;
02819         }
02820 
02821         function __buildSettingsButtons()
02822         {
02823                 if($this->__getMainSection() == $this->SETTINGS)
02824                 {
02825                         $this->tabs_gui->addSubTabTarget('pays_general',
02826                                                                                          $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'generalSettings'),
02827                                                                                          '',
02828                                                                                          '',
02829                                                                                          '',
02830                                                                                          $this->__getSection() == $this->SECTION_GENERAL ? true : false);
02831                         $this->tabs_gui->addSubTabTarget('pays_bmf',
02832                                                                                          $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'bmfSettings'),
02833                                                                                          '',
02834                                                                                          '',
02835                                                                                          '',
02836                                                                                          $this->__getSection() == $this->SECTION_BMF ? true : false);
02837                         $this->tabs_gui->addSubTabTarget('pays_paypal',
02838                                                                                          $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'paypalSettings'),
02839                                                                                          '',
02840                                                                                          '',
02841                                                                                          '',
02842                                                                                          $this->__getSection() == $this->SECTION_PAYPAL ? true : false);
02843                 }
02844         }
02845 
02846         function __showStatisticTable($a_result_set)
02847         {
02848                 $tbl =& $this->__initTableGUI();
02849                 $tpl =& $tbl->getTemplateObject();
02850 
02851                 // SET FORMAACTION
02852                 $tpl->setCurrentBlock("tbl_form_header");
02853 
02854                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
02855                 $tpl->parseCurrentBlock();
02856 
02857 
02858                 $tbl->setTitle($this->lng->txt("paya_statistic"),"icon_pays.gif",$this->lng->txt("paya_statistic"));
02859                 $tbl->setHeaderNames(array($this->lng->txt("paya_transaction"),
02860                                                                    $this->lng->txt("title"),
02861                                                                    $this->lng->txt("paya_vendor"),
02862                                                                    $this->lng->txt("paya_customer"),
02863                                                                    $this->lng->txt("paya_order_date"),
02864                                                                    $this->lng->txt("duration"),
02865                                                                    $this->lng->txt("price_a"),
02866                                                                    $this->lng->txt("paya_coupons_coupons"),
02867                                                                    $this->lng->txt("paya_payed_access"),
02868                                                                    ''));
02869 
02870                 $tbl->setHeaderVars(array("transaction",
02871                                                                   "title",
02872                                                                   "vendor",
02873                                                                   "customer",
02874                                                                   "order_date",
02875                                                                   "duration",
02876                                                                   "price",
02877                                                                   "discount",
02878                                                                   "payed_access",
02879                                                                   "options"),
02880                                                         $this->ctrl->getParameterArray($this,"statistic",false));
02881 
02882                 $offset = $_GET["offset"];
02883                 $order = $_GET["sort_by"];
02884                 $direction = $_GET["sort_order"] ? $_GET['sort_order'] : 'desc';
02885 
02886                 $tbl->setOrderColumn($order,'order_date');
02887                 $tbl->setOrderDirection($direction);
02888                 $tbl->setOffset($offset);
02889                 $tbl->setLimit($_GET["limit"]);
02890                 $tbl->setMaxCount(count($a_result_set));
02891                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02892                 $tbl->setData($a_result_set);
02893 
02894                 $tpl->setVariable("COLUMN_COUNTS",10);
02895                 $tpl->setCurrentBlock("plain_buttons");
02896                 $tpl->setVariable("PBTN_NAME","exportVendors");
02897                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("excel_export"));
02898                 $tpl->parseCurrentBlock();
02899                 $tbl->render();
02900 
02901                 $this->tpl->setVariable("STATISTIC_TABLE",$tbl->tpl->get());
02902 
02903                 return true;
02904         }
02905 
02906         function __initBookingObject()
02907         {
02908                 include_once './payment/classes/class.ilPaymentBookings.php';
02909 
02910                 $this->booking_obj =& new ilPaymentBookings($this->user_obj->getId(),true);
02911         }
02912 
02913         function __showVendorsTable($a_result_set)
02914         {
02915                 $actions = array(
02916                         "editVendorObject"      => $this->lng->txt("pays_edit_vendor"),
02917                         "deleteVendorsObject"   => $this->lng->txt("pays_delete_vendor")
02918                 );
02919 
02920                 $tbl =& $this->__initTableGUI();
02921                 $tpl =& $tbl->getTemplateObject();
02922 
02923                 // SET FORMAACTION
02924                 $tpl->setCurrentBlock("tbl_form_header");
02925 
02926                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
02927                 $tpl->parseCurrentBlock();
02928 
02929                 $tpl->setCurrentBlock("tbl_action_row");
02930 
02931                 $tpl->setCurrentBlock("input_text");
02932                 $tpl->setVariable("PB_TXT_NAME",'vendor_login');
02933                 $tpl->parseCurrentBlock();
02934 
02935                 $tpl->setCurrentBlock("plain_button");
02936                 $tpl->setVariable("PBTN_NAME","addVendor");
02937                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("pays_add_vendor"));
02938                 $tpl->parseCurrentBlock();
02939                 $tpl->setCurrentBlock("plain_buttons");
02940                 $tpl->parseCurrentBlock();
02941 
02942                 $tpl->setVariable("COLUMN_COUNTS",4);
02943 
02944                 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
02945 
02946                 $tpl->setCurrentBlock("tbl_action_select");
02947                 $tpl->setVariable("SELECT_ACTION",ilUtil::formSelect(1,"action",$actions,false,true));
02948                 $tpl->setVariable("BTN_NAME","gateway");
02949                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("execute"));
02950                 $tpl->parseCurrentBlock();
02951                 $tpl->setCurrentBlock("tbl_action_row");
02952                 $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
02953                 $tpl->parseCurrentBlock();
02954 
02955                 $tbl->setTitle($this->lng->txt("vendors"),"icon_usr.gif",$this->lng->txt("vendors"));
02956                 $tbl->setHeaderNames(array('',
02957                                                                    $this->lng->txt("pays_vendor"),
02958                                                                    $this->lng->txt("pays_cost_center"),
02959                                                                    $this->lng->txt("pays_number_bookings")));
02960                 $tbl->setHeaderVars(array("",
02961                                                                   "login",
02962                                                                   "cost_center",
02963                                                                   "bookings"),
02964                                                         array("ref_id" => $this->object->getRefId(),
02965                                                                   "cmd" => "vendors",
02966                                                                   "update_members" => 1,
02967                                                                   "baseClass" => "ilAdministrationGUI",
02968                                                                   "cmdClass" => "ilobjpaymentsettingsgui",
02969                                                                   "cmdNode" => $_GET["cmdNode"]));
02970 #               $tbl->setColumnWidth(array("4%","48%","25%","24%"));
02971 
02972                 $tpl->setVariable("COLUMN_COUNTS",9);
02973                 $tpl->setCurrentBlock("plain_buttons");
02974                 $tpl->setVariable("PBTN_NAME","exportVendors");
02975                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("excel_export"));
02976                 $tpl->parseCurrentBlock();
02977 
02978                 $this->__setTableGUIBasicData($tbl,$a_result_set);
02979                 $tbl->render();
02980 
02981                 $this->tpl->setVariable("VENDOR_TABLE",$tbl->tpl->get());
02982 
02983                 return true;
02984         }
02985 
02986 
02987         function __showSearchUserTable($a_result_set,$a_cmd = "search")
02988         {
02989                 $tbl =& $this->__initTableGUI();
02990                 $tpl =& $tbl->getTemplateObject();
02991 
02992 
02993                 // SET FORMACTION
02994                 $tpl->setCurrentBlock("tbl_form_header");
02995                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
02996                 $tpl->parseCurrentBlock();
02997 
02998                 $tpl->setCurrentBlock("tbl_action_btn");
02999                 $tpl->setVariable("BTN_NAME","addUser");
03000                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("add"));
03001                 $tpl->parseCurrentBlock();
03002 
03003                 $tpl->setCurrentBlock("tbl_action_btn");
03004                 $tpl->setVariable("BTN_NAME","vendors");
03005                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
03006                 $tpl->parseCurrentBlock();
03007 
03008                 $tpl->setCurrentBlock("tbl_action_row");
03009                 $tpl->setVariable("COLUMN_COUNTS",5);
03010                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
03011                 $tpl->parseCurrentBlock();
03012 
03013                 $tbl->setTitle($this->lng->txt("pays_header_select_vendor"),"icon_usr.gif",$this->lng->txt("pays_header_select_vendor"));
03014                 $tbl->setHeaderNames(array("",
03015                                                                    $this->lng->txt("login"),
03016                                                                    $this->lng->txt("firstname"),
03017                                                                    $this->lng->txt("lastname")));
03018                 $tbl->setHeaderVars(array("",
03019                                                                   "login",
03020                                                                   "firstname",
03021                                                                   "lastname"),
03022                                                         array("ref_id" => $this->object->getRefId(),
03023                                                                   "cmd" => $a_cmd,
03024                                                                   "cmdClass" => "ilobjpaymentsettingsgui",
03025                                                                   "cmdNode" => $_GET["cmdNode"]));
03026 
03027                 $tbl->setColumnWidth(array("3%","32%","32%","32%"));
03028 
03029                 $this->__setTableGUIBasicData($tbl,$a_result_set);
03030                 $tbl->render();
03031                 
03032                 $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
03033 
03034                 return true;
03035         }
03036 
03037         function __showButton($a_cmd,$a_text,$a_target = '')
03038         {
03039                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
03040                 
03041                 // display button
03042                 $this->tpl->setCurrentBlock("btn_cell");
03043                 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,$a_cmd));
03044                 $this->tpl->setVariable("BTN_TXT",$a_text);
03045                 if($a_target)
03046                 {
03047                         $this->tpl->setVariable("BTN_TARGET",$a_target);
03048                 }
03049 
03050                 $this->tpl->parseCurrentBlock();
03051         }               
03052 
03053         function &__initTableGUI()
03054         {
03055                 include_once "./Services/Table/classes/class.ilTableGUI.php";
03056 
03057                 return new ilTableGUI(0,false);
03058         }
03059 
03060         function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
03061         {
03062                 $offset = $_GET["offset"];
03063                 $order = $_GET["sort_by"];
03064                 $direction = $_GET["sort_order"];
03065 
03066                 $tbl->setOrderColumn($order);
03067                 $tbl->setOrderDirection($direction);
03068                 $tbl->setOffset($offset);
03069                 $tbl->setLimit($_GET["limit"]);
03070                 $tbl->setMaxCount(count($result_set));
03071                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
03072                 $tbl->setData($result_set);
03073         }
03074 
03075         function __search($a_search_string)
03076         {
03077                 include_once("./classes/class.ilSearch.php");
03078 
03079                 $this->lng->loadLanguageModule("content");
03080 
03081                 $search =& new ilSearch($_SESSION["AccountId"]);
03082                 $search->setPerformUpdate(false);
03083                 $search->setSearchString(ilUtil::stripSlashes($a_search_string));
03084                 $search->setCombination("and");
03085                 $search->setSearchFor(array(0 => 'usr'));
03086                 $search->setSearchType('new');
03087 
03088                 if($search->validate($message))
03089                 {
03090                         $search->performSearch();
03091                 }
03092                 else
03093                 {
03094                         ilUtil::sendInfo($message,true);
03095                         $this->ctrl->redirect($this,"searchUser");
03096                 }
03097                 return $search->getResultByType('usr');
03098         }               
03099         
03100         function __searchSP($a_search_string)
03101         {
03102                 include_once("./classes/class.ilSearch.php");
03103 
03104                 $this->lng->loadLanguageModule("content");
03105 
03106                 $search =& new ilSearch($this->user_obj->getId());
03107                 $search->setPerformUpdate(false);
03108                 $search->setSearchString(ilUtil::stripSlashes($a_search_string));
03109                 $search->setCombination("and");
03110                 $search->setSearchFor(array(0 => 'usr'));
03111                 $search->setSearchType('new');
03112 
03113                 if($search->validate($message))
03114                 {
03115                         $search->performSearchSPObject();
03116                 }
03117                 else
03118                 {
03119                         ilUtil::sendInfo($message,true);
03120                         $this->ctrl->redirect($this,"searchUserSP");
03121                 }
03122                 return $search->getResultByType('usr');
03123         }
03124         function __showSearchUserSPTable($a_result_set)
03125         {
03126                 $tbl =& $this->initTableGUI();
03127                 $tpl =& $tbl->getTemplateObject();
03128 
03129 
03130                 // SET FORMACTION
03131                 $tpl->setCurrentBlock("tbl_form_header");
03132                 $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
03133                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
03134                 $tpl->parseCurrentBlock();
03135 
03136                 $tpl->setCurrentBlock("tbl_action_btn");
03137                 $tpl->setVariable("BTN_NAME","addCustomer");
03138                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("add"));
03139                 $tpl->parseCurrentBlock();
03140 
03141                 $tpl->setCurrentBlock("tbl_action_btn");
03142                 $tpl->setVariable("BTN_NAME","statistic");
03143                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
03144                 $tpl->parseCurrentBlock();
03145 
03146                 $tpl->setCurrentBlock("tbl_action_row");
03147                 $tpl->setVariable("COLUMN_COUNTS",5);
03148                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
03149                 $tpl->parseCurrentBlock();
03150 
03151                 $tbl->setTitle($this->lng->txt("users"),"icon_usr.gif",$this->lng->txt("crs_header_edit_members"));
03152                 $tbl->setHeaderNames(array("",
03153                                                                    $this->lng->txt("login"),
03154                                                                    $this->lng->txt("firstname"),
03155                                                                    $this->lng->txt("lastname")));
03156                 $this->ctrl->setParameter($this, "cmd", "addCustomer");
03157                 $header_params = $this->ctrl->getParameterArray($this,'');
03158                 $tbl->setHeaderVars(array("",
03159                                                                   "login",
03160                                                                   "firstname",
03161                                                                   "lastname"), $header_params);
03162                                                                   /*
03163                                                         array("cmd" => 'performSearch',
03164                                                                   "cmdClass" => "ilpaymentstatisticgui",
03165                                                                   "cmdNode" => $_GET["cmdNode"]));
03166                                                                   */
03167 
03168                 $tbl->setColumnWidth(array("3%","32%","32%","32%"));
03169 
03170                 $this->setTableGUIBasicData($tbl,$a_result_set);
03171                 $tbl->render();
03172                 
03173                 $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
03174 
03175                 return true;
03176         }
03177 
03178         function &initTableGUI()
03179         {
03180                 include_once "./Services/Table/classes/class.ilTableGUI.php";
03181 
03182                 return new ilTableGUI(0,false);
03183         }
03184         function setTableGUIBasicData(&$tbl,&$result_set,$a_default_order_column = '')
03185         {
03186                 $offset = $_GET["offset"];
03187                 $order = $_GET["sort_by"];
03188                 $direction = $_GET["sort_order"];
03189 
03190                 $tbl->setOrderColumn($order,$a_default_order_column);
03191                 $tbl->setOrderDirection($direction);
03192                 $tbl->setOffset($offset);
03193                 $tbl->setLimit($_GET["limit"]);
03194                 $tbl->setMaxCount(count($result_set));
03195                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
03196                 $tbl->setData($result_set);
03197         }
03198 } // END class.ilObjPaymentSettingsGUI
03199 ?>

Generated on Fri Dec 13 2013 17:56:54 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1