00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00074 $this->lng->loadLanguageModule('payment');
00075 }
00076
00077 function &executeCommand()
00078 {
00079 $next_class = $this->ctrl->getNextClass($this);
00080 $cmd = $this->ctrl->getCmd();
00081 $this->prepareOutput();
00082
00083 switch($next_class)
00084 {
00085 case 'ilpermissiongui':
00086 include_once("./classes/class.ilPermissionGUI.php");
00087 $perm_gui =& new ilPermissionGUI($this);
00088 $ret =& $this->ctrl->forwardCommand($perm_gui);
00089 break;
00090
00091 default:
00092 if ($cmd == "" || $cmd == "view")
00093 {
00094 $cmd = "generalSettings";
00095 }
00096 switch ($cmd)
00097 {
00098 case "vendors" :
00099 case "searchUser" :
00100 case "search" :
00101 case "performSearch" :
00102 case "addVendor" :
00103 case "exportVendors" :
00104 case "performDeleteVendors" :
00105 case "cancelDeleteVendors" :
00106 case "performEditVendor" : $this->__setSection($this->OTHERS);
00107 $this->__setMainSection($this->STATISTIC);
00108 $this->tabs_gui->setTabActive("vendors");
00109 break;
00110 case "statistic" :
00111 case "editStatistic" :
00112 case "updateStatistic" :
00113 case "deleteStatistic" :
00114 case "performDelete" :
00115 case "resetFilter" :
00116 case "exportVendors" :
00117 case "addCustomer" :
00118 case "saveCustomer" :
00119 case "showObjectSelector" :
00120 case "searchUserSP" :
00121 case "performSearchSP" : $this->__setSection($this->OTHERS);
00122 $this->__setMainSection($this->STATISTIC);
00123 $this->tabs_gui->setTabActive("statistic");
00124 break;
00125 case "saveGeneralSettings" :
00126 case "generalSettings" : $this->__setSection($this->SECTION_GENERAL);
00127 $this->__setMainSection($this->SETTINGS);
00128 $this->tabs_gui->setTabActive("settings");
00129 break;
00130 case "savePaypalSettings" :
00131 case "paypalSettings" : $this->__setSection($this->SECTION_PAYPAL);
00132 $this->__setMainSection($this->SETTINGS);
00133 $this->tabs_gui->setTabActive("settings");
00134 break;
00135 case "savePayMethods" : $this->__setSection($this->OTHERS);
00136 $this->__setMainSection($this->PAY_METHODS);
00137 $this->tabs_gui->setTabActive("pay_methods");
00138 break;
00139 case "gateway" : if ($_POST["action"] == "editVendorObject" ||
00140 $_POST["action"] == "deleteVendorsObject")
00141 {
00142 $this->__setSection($this->OTHERS);
00143 $this->__setMainSection($this->STATISTIC);
00144 $this->tabs_gui->setTabActive("vendors");
00145 }
00146 break;
00147 default : $this->__setSection($this->OTHERS);
00148 $this->__setMainSection($this->OTHERS);
00149 break;
00150 }
00151 $cmd .= "Object";
00152
00153 $this->__buildSettingsButtons();
00154
00155 $this->$cmd();
00156
00157 break;
00158 }
00159 return true;
00160 }
00161
00162 function gatewayObject()
00163 {
00164 switch($_POST["action"])
00165 {
00166 case "deleteVendorsObject":
00167 $this->deleteVendors();
00168 break;
00169
00170 case "editVendorObject":
00171 $this->editVendor();
00172 break;
00173
00174 case "performEditVendorObject":
00175 $this->performEditVendorObject();
00176 break;
00177
00178 default:
00179 $this->vendorsObject();
00180 break;
00181 }
00182 return true;
00183 }
00184
00185 function resetFilterObject()
00186 {
00187 unset($_SESSION["pay_statistics"]);
00188 unset($_POST["transaction_type"]);
00189 unset($_POST["transaction_value"]);
00190 unset($_POST["from"]["day"]);
00191 unset($_POST["from"]["month"]);
00192 unset($_POST["from"]["year"]);
00193 unset($_POST["til"]["day"]);
00194 unset($_POST["til"]["month"]);
00195 unset($_POST["til"]["year"]);
00196 unset($_POST["payed"]);
00197 unset($_POST["access"]);
00198 unset($_POST["customer"]);
00199 unset($_POST["pay_method"]);
00200
00201 sendInfo($this->lng->txt('paya_filter_reseted'));
00202
00203 return $this->statisticObject();
00204 }
00205
00206 function statisticObject()
00207 {
00208 global $rbacsystem;
00209
00210
00211 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
00212 {
00213 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00214 }
00215
00216 $this->__showButton('showObjectSelector',$this->lng->txt('paya_add_customer'));
00217
00218 if ($_POST["updateView"] == 1)
00219 {
00220 $_SESSION["pay_statistics"]["transaction_type"] = $_POST["transaction_type"];
00221 $_SESSION["pay_statistics"]["transaction_value"] = $_POST["transaction_value"];
00222 $_SESSION["pay_statistics"]["from"]["day"] = $_POST["from"]["day"];
00223 $_SESSION["pay_statistics"]["from"]["month"] = $_POST["from"]["month"];
00224 $_SESSION["pay_statistics"]["from"]["year"] = $_POST["from"]["year"];
00225 $_SESSION["pay_statistics"]["til"]["day"] = $_POST["til"]["day"];
00226 $_SESSION["pay_statistics"]["til"]["month"] = $_POST["til"]["month"];
00227 $_SESSION["pay_statistics"]["til"]["year"] = $_POST["til"]["year"];
00228 $_SESSION["pay_statistics"]["payed"] = $_POST["payed"];
00229 $_SESSION["pay_statistics"]["access"] = $_POST["access"];
00230 $_SESSION["pay_statistics"]["pay_method"] = $_POST["pay_method"];
00231 $_SESSION["pay_statistics"]["customer"] = $_POST["customer"];
00232 $_SESSION["pay_statistics"]["vendor"] = $_POST["vendor"];
00233 }
00234
00235 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_statistic.html','payment');
00236
00237 $this->tpl->setVariable("TXT_FILTER",$this->lng->txt('pay_filter'));
00238 $this->tpl->setVariable("FORM_ACTION",$this->ctrl->getFormAction($this));
00239 $this->tpl->setVariable("TXT_TRANSACTION",$this->lng->txt('paya_transaction'));
00240 $this->tpl->setVariable("TXT_STARTING",$this->lng->txt('pay_starting'));
00241 $this->tpl->setVariable("TXT_ENDING",$this->lng->txt('pay_ending'));
00242 $this->tpl->setVariable("TXT_PAYED",$this->lng->txt('paya_payed'));
00243 $this->tpl->setVariable("TXT_ALL",$this->lng->txt('pay_all'));
00244 $this->tpl->setVariable("TXT_YES",$this->lng->txt('yes'));
00245 $this->tpl->setVariable("TXT_NO",$this->lng->txt('no'));
00246 $this->tpl->setVariable("TXT_BILL",$this->lng->txt('pays_bill'));
00247 $this->tpl->setVariable("TXT_BMF",$this->lng->txt('pays_bmf'));
00248 $this->tpl->setVariable("TXT_PAYPAL",$this->lng->txt('pays_paypal'));
00249 $this->tpl->setVariable("TXT_PAYMENT",$this->lng->txt('payment_system'));
00250 $this->tpl->setVariable("TXT_CUSTOMER",$this->lng->txt('paya_customer'));
00251 $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
00252 $this->tpl->setVariable("TXT_ACCESS",$this->lng->txt('paya_access'));
00253 $this->tpl->setVariable("TXT_ORDER_DATE_FROM",$this->lng->txt('pay_order_date_from'));
00254 $this->tpl->setVariable("TXT_ORDER_DATE_TIL",$this->lng->txt('pay_order_date_til'));
00255 $this->tpl->setVariable("TXT_UPDATE_VIEW",$this->lng->txt('pay_update_view'));
00256 $this->tpl->setVariable("TXT_RESET_FILTER",$this->lng->txt('pay_reset_filter'));
00257
00258 $this->tpl->setVariable("TRANSACTION_TYPE_" . $_SESSION["pay_statistics"]["transaction_type"], " selected");
00259 $this->tpl->setVariable("TRANSACTION_VALUE", ilUtil::prepareFormOutput($_SESSION["pay_statistics"]["transaction_value"], true));
00260 $this->tpl->setVariable("PAYED_" . $_SESSION["pay_statistics"]["payed"], " selected");
00261 $this->tpl->setVariable("ACCESS_" . $_SESSION["pay_statistics"]["access"], " selected");
00262 $this->tpl->setVariable("PAYMENT_" . $_SESSION["pay_statistics"]["pay_method"], " selected");
00263 $this->tpl->setVariable("CUSTOMER", ilUtil::prepareFormOutput($_SESSION["pay_statistics"]["customer"], true));
00264 $this->tpl->setVariable("VENDOR", ilUtil::prepareFormOutput($_SESSION["pay_statistics"]["vendor"], true));
00265
00266 for ($i = 1; $i <= 31; $i++)
00267 {
00268 $this->tpl->setCurrentBlock("loop_from_day");
00269 $this->tpl->setVariable("LOOP_FROM_DAY", $i < 10 ? "0" . $i : $i);
00270 if ($_SESSION["pay_statistics"]["from"]["day"] == $i)
00271 {
00272 $this->tpl->setVariable("LOOP_FROM_DAY_SELECTED", " selected");
00273 }
00274 $this->tpl->parseCurrentBlock("loop_from_day");
00275 $this->tpl->setCurrentBlock("loop_til_day");
00276 $this->tpl->setVariable("LOOP_TIL_DAY", $i < 10 ? "0" . $i : $i);
00277 if ($_SESSION["pay_statistics"]["til"]["day"] == $i)
00278 {
00279 $this->tpl->setVariable("LOOP_TIL_DAY_SELECTED", " selected");
00280 }
00281 $this->tpl->parseCurrentBlock("loop_til_day");
00282 }
00283 for ($i = 1; $i <= 12; $i++)
00284 {
00285 $this->tpl->setCurrentBlock("loop_from_month");
00286 $this->tpl->setVariable("LOOP_FROM_MONTH", $i < 10 ? "0" . $i : $i);
00287 if ($_SESSION["pay_statistics"]["from"]["month"] == $i)
00288 {
00289 $this->tpl->setVariable("LOOP_FROM_MONTH_SELECTED", " selected");
00290 }
00291 $this->tpl->parseCurrentBlock("loop_from_month");
00292 $this->tpl->setCurrentBlock("loop_til_month");
00293 $this->tpl->setVariable("LOOP_TIL_MONTH", $i < 10 ? "0" . $i : $i);
00294 if ($_SESSION["pay_statistics"]["til"]["month"] == $i)
00295 {
00296 $this->tpl->setVariable("LOOP_TIL_MONTH_SELECTED", " selected");
00297 }
00298 $this->tpl->parseCurrentBlock("loop_til_month");
00299 }
00300 for ($i = 2004; $i <= date("Y"); $i++)
00301 {
00302 $this->tpl->setCurrentBlock("loop_from_year");
00303 $this->tpl->setVariable("LOOP_FROM_YEAR", $i);
00304 if ($_SESSION["pay_statistics"]["from"]["year"] == $i)
00305 {
00306 $this->tpl->setVariable("LOOP_FROM_YEAR_SELECTED", " selected");
00307 }
00308 $this->tpl->parseCurrentBlock("loop_from_year");
00309 $this->tpl->setCurrentBlock("loop_til_year");
00310 $this->tpl->setVariable("LOOP_TIL_YEAR", $i);
00311 if ($_SESSION["pay_statistics"]["til"]["year"] == $i)
00312 {
00313 $this->tpl->setVariable("LOOP_TIL_YEAR_SELECTED", " selected");
00314 }
00315 $this->tpl->parseCurrentBlock("loop_til_year");
00316 }
00317
00318 $this->__initBookingObject();
00319
00320 if(!count($bookings = $this->booking_obj->getBookings()))
00321 {
00322 sendInfo($this->lng->txt('paya_no_bookings'));
00323
00324 return true;
00325 }
00326 # else
00327 # {
00328 # $this->__showButton('exportVendors',$this->lng->txt('excel_export'));
00329 # }
00330 $img_change = "<img src=\"".ilUtil::getImagePath("edit.gif")."\" alt=\"".
00331 $this->lng->txt("edit")."\" title=\"".$this->lng->txt("edit").
00332 "\" border=\"0\" vspace=\"0\"/>";
00333
00334 $counter = 0;
00335 foreach($bookings as $booking)
00336 {
00337 $tmp_obj =& ilObjectFactory::getInstanceByRefId($booking['ref_id']);
00338 $tmp_vendor =& ilObjectFactory::getInstanceByObjId($booking['b_vendor_id']);
00339 $tmp_purchaser =& ilObjectFactory::getInstanceByObjId($booking['customer_id']);
00340
00341 $transaction = $booking['transaction_extern'];
00342 switch ($booking['b_pay_method'])
00343 {
00344 case $this->pobject->PAY_METHOD_BILL :
00345 $transaction .= " (" . $this->lng->txt("pays_bill") . ")";
00346 break;
00347 case $this->pobject->PAY_METHOD_BMF :
00348 $transaction .= " (" . $this->lng->txt("pays_bmf") . ")";
00349 break;
00350 case $this->pobject->PAY_METHOD_PAYPAL :
00351 $transaction .= " (" . $this->lng->txt("pays_paypal") . ")";
00352 break;
00353 }
00354 $f_result[$counter][] = $transaction;
00355 $f_result[$counter][] = $tmp_obj->getTitle();
00356 $f_result[$counter][] = '['.$tmp_vendor->getLogin().']';
00357 $f_result[$counter][] = '['.$tmp_purchaser->getLogin().']';
00358 $f_result[$counter][] = date('Y m d H:i:s',$booking['order_date']);
00359 $f_result[$counter][] = $booking['duration'];
00360 $f_result[$counter][] = $booking['price'];
00361
00362 $payed_access = $booking['payed'] ?
00363 $this->lng->txt('yes') :
00364 $this->lng->txt('no');
00365
00366 $payed_access .= '/';
00367 $payed_access .= $booking['access'] ?
00368 $this->lng->txt('yes') :
00369 $this->lng->txt('no');
00370
00371 $f_result[$counter][] = $payed_access;
00372
00373 $this->ctrl->setParameter($this,"booking_id",$booking['booking_id']);
00374 # $link_change = "<a href=\"".$this->ctrl->getLinkTarget($this,"editStatistic")."\"> ".
00375 # $img_change."</a>";
00376 $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,"editStatistic")."\">".$this->lng->txt("edit")."</a></div>";
00377
00378 $f_result[$counter][] = $link_change;
00379
00380 unset($tmp_obj);
00381 unset($tmp_vendor);
00382 unset($tmp_purchaser);
00383
00384 ++$counter;
00385 }
00386 return $this->__showStatisticTable($f_result);
00387 }
00388
00389 function editStatisticObject($a_show_confirm_delete = false)
00390 {
00391 if(!isset($_GET['booking_id']))
00392 {
00393 sendInfo($this->lng->txt('paya_no_booking_id_given'));
00394 $this->showStatistics();
00395
00396 return true;
00397 }
00398
00399 $this->__showButton('statistic',$this->lng->txt('back'));
00400
00401 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_adm_edit_statistic.html','payment');
00402 $this->ctrl->setParameter($this,'booking_id',(int) $_GET['booking_id']);
00403
00404
00405 if($a_show_confirm_delete)
00406 {
00407 $this->tpl->setCurrentBlock("confirm_delete");
00408 $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
00409 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00410 $this->tpl->setVariable("CONFIRM_CMD",'performDelete');
00411 $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('confirm'));
00412 $this->tpl->parseCurrentBlock();
00413 }
00414
00415
00416 $this->__initBookingObject();
00417 $bookings = $this->booking_obj->getBookings();
00418 $booking = $bookings[(int) $_GET['booking_id']];
00419
00420
00421 $tmp_user =& ilObjectFactory::getInstanceByObjId($booking['customer_id']);
00422
00423 $this->tpl->setVariable("STAT_FORMACTION",$this->ctrl->getFormAction($this));
00424 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_usr.gif'));
00425 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
00426 $this->tpl->setVariable("TITLE",$tmp_user->getFullname().' ['.$tmp_user->getLogin().']');
00427
00428
00429 $pObj =& new ilPaymentObject($this->user_obj, $booking["pobject_id"]);
00430 $tmp_obj =& ilObjectFactory::getInstanceByRefId($pObj->getRefId());
00431
00432 $this->tpl->setVariable("TXT_OBJECT",$this->lng->txt('title'));
00433 $this->tpl->setVariable("OBJECT",$tmp_obj->getTitle());
00434
00435 $this->tpl->setVariable("TXT_TRANSACTION",$this->lng->txt('paya_transaction'));
00436 $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
00437 $this->tpl->setVariable("TXT_PAY_METHOD",$this->lng->txt('paya_pay_method'));
00438 $this->tpl->setVariable("TXT_ORDER_DATE",$this->lng->txt('paya_order_date'));
00439 $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('duration'));
00440 $this->tpl->setVariable("TXT_PRICE",$this->lng->txt('price_a'));
00441 $this->tpl->setVariable("TXT_PAYED",$this->lng->txt('paya_payed'));
00442 $this->tpl->setVariable("TXT_ACCESS",$this->lng->txt('paya_access'));
00443
00444 $this->tpl->setVariable("TRANSACTION",$booking['transaction']);
00445
00446 $tmp_vendor =& ilObjectFactory::getInstanceByObjId($booking['b_vendor_id']);
00447
00448 $this->tpl->setVariable("VENDOR",$tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']');
00449
00450 switch($booking['b_pay_method'])
00451 {
00452 case $this->pobject->PAY_METHOD_BILL:
00453 $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('pays_bill'));
00454 break;
00455
00456 case $this->pobject->PAY_METHOD_BMF:
00457 $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('pays_bmf'));
00458 break;
00459
00460 case $this->pobject->PAY_METHOD_PAYPAL:
00461 $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('pays_paypal'));
00462 break;
00463
00464 default:
00465 $this->tpl->setVariable("PAY_METHOD",$this->lng->txt('paya_pay_method_not_specified'));
00466 break;
00467 }
00468 $this->tpl->setVariable("ORDER_DATE",date('Y m d H:i:s',$booking['order_date']));
00469 $this->tpl->setVariable("DURATION",$booking['duration'].' '.$this->lng->txt('paya_months'));
00470 $this->tpl->setVariable("PRICE",$booking['price']);
00471
00472 $yes_no = array(0 => $this->lng->txt('no'),1 => $this->lng->txt('yes'));
00473
00474 $this->tpl->setVariable("PAYED",ilUtil::formSelect((int) $booking['payed'],'payed',$yes_no,false,true));
00475 $this->tpl->setVariable("ACCESS",ilUtil::formSelect((int) $booking['access'],'access',$yes_no,false,true));
00476
00477
00478 $this->tpl->setVariable("INPUT_CMD",'updateStatistic');
00479 $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('save'));
00480
00481 $this->tpl->setVariable("DELETE_CMD",'deleteStatistic');
00482 $this->tpl->setVariable("DELETE_VALUE",$this->lng->txt('delete'));
00483 }
00484 function updateStatisticObject()
00485 {
00486 if(!isset($_GET['booking_id']))
00487 {
00488 sendInfo($this->lng->txt('paya_no_booking_id_given'));
00489 $this->statisticObject();
00490
00491 return true;
00492 }
00493 $this->__initBookingObject();
00494
00495 $this->booking_obj->setBookingId((int) $_GET['booking_id']);
00496 $this->booking_obj->setAccess((int) $_POST['access']);
00497 $this->booking_obj->setPayed((int) $_POST['payed']);
00498
00499 if($this->booking_obj->update())
00500 {
00501 sendInfo($this->lng->txt('paya_updated_booking'));
00502
00503 $this->statisticObject();
00504 return true;
00505 }
00506 else
00507 {
00508 sendInfo($this->lng->txt('paya_error_update_booking'));
00509
00510 $this->statisticObject();
00511
00512 return true;
00513 }
00514 }
00515
00516 function deleteStatisticObject()
00517 {
00518 if(!isset($_GET['booking_id']))
00519 {
00520 sendInfo($this->lng->txt('paya_no_booking_id_given'));
00521 $this->statisticObject();
00522
00523 return true;
00524 }
00525 sendInfo($this->lng->txt('paya_sure_delete_stat'));
00526
00527 $this->editStatisticObject(true);
00528
00529 return true;
00530 }
00531 function performDeleteObject()
00532 {
00533 if(!isset($_GET['booking_id']))
00534 {
00535 sendInfo($this->lng->txt('paya_no_booking_id_given'));
00536 $this->statisticObject();
00537
00538 return true;
00539 }
00540
00541 $this->__initBookingObject();
00542 $this->booking_obj->setBookingId((int) $_GET['booking_id']);
00543 if(!$this->booking_obj->delete())
00544 {
00545 die('Error deleting booking');
00546 }
00547 sendInfo($this->lng->txt('pay_deleted_booking'));
00548
00549 $this->statisticObject();
00550
00551 return true;
00552 }
00553
00554 function getAdminTabs(&$tabs_gui)
00555 {
00556 $this->getTabs(&$tabs_gui);
00557 }
00558
00564 function getTabs(&$tabs_gui)
00565 {
00566 global $rbacsystem;
00567
00568 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00569 {
00570 $tabs_gui->addTarget("settings",
00571 $this->ctrl->getLinkTarget($this, "generalSettings"), array("generalSettings","", "view"), "", "");
00572
00573 $tabs_gui->addTarget("statistic",
00574 $this->ctrl->getLinkTarget($this, "statistic"), "statistic", "", "");
00575
00576 $tabs_gui->addTarget("vendors",
00577 $this->ctrl->getLinkTarget($this, "vendors"), "vendors", "", "");
00578
00579 $tabs_gui->addTarget("pay_methods",
00580 $this->ctrl->getLinkTarget($this, "payMethods"), "payMethods", "", "");
00581 }
00582
00583 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00584 {
00585 $tabs_gui->addTarget("perm_settings",
00586 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00587 }
00588 }
00589
00590 function generalSettingsObject($a_show_confirm = false)
00591 {
00592 include_once './payment/classes/class.ilGeneralSettings.php';
00593
00594 $genSet = new ilGeneralSettings();
00595 $genSetData = $genSet->getAll();
00596
00597 global $rbacsystem;
00598
00599
00600 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
00601 {
00602 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00603 }
00604
00605 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_general_settings.html",'payment');
00606
00607 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00608 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_pays.gif'));
00609 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_pays'));
00610 $this->tpl->setVariable("TITLE",$this->lng->txt('pays_general_settings'));
00611 $this->tpl->setVariable("TXT_CURRENCY_UNIT",$this->lng->txt('pays_currency_unit'));
00612 $this->tpl->setVariable("TXT_CURRENCY_SUBUNIT",$this->lng->txt('pays_currency_subunit'));
00613 $this->tpl->setVariable("TXT_ADDRESS",$this->lng->txt('pays_address'));
00614 $this->tpl->setVariable("TXT_BANK_DATA",$this->lng->txt('pays_bank_data'));
00615 $this->tpl->setVariable("TXT_ADD_INFO",$this->lng->txt('pays_add_info'));
00616 $this->tpl->setVariable("TXT_VAT_RATE",$this->lng->txt('pays_vat_rate'));
00617 $this->tpl->setVariable("TXT_PDF_PATH",$this->lng->txt('pays_pdf_path'));
00618 $this->tpl->setVariable("CURRENCY_UNIT",
00619 $this->error != "" && isset($_POST['currency_unit'])
00620 ? ilUtil::prepareFormOutput($_POST['currency_unit'],true)
00621 : ilUtil::prepareFormOutput($genSetData['currency_unit'],true));
00622 $this->tpl->setVariable("CURRENCY_SUBUNIT",
00623 $this->error != "" && isset($_POST['currency_subunit'])
00624 ? ilUtil::prepareFormOutput($_POST['currency_subunit'],true)
00625 : ilUtil::prepareFormOutput($genSetData['currency_subunit'],true));
00626 $this->tpl->setVariable("ADDRESS",
00627 $this->error != "" && isset($_POST['address'])
00628 ? ilUtil::prepareFormOutput($_POST['address'],true)
00629 : ilUtil::prepareFormOutput($genSetData['address'],true));
00630 $this->tpl->setVariable("BANK_DATA",
00631 $this->error != "" && isset($_POST['bank_data'])
00632 ? ilUtil::prepareFormOutput($_POST['bank_data'],true)
00633 : ilUtil::prepareFormOutput($genSetData['bank_data'],true));
00634 $this->tpl->setVariable("ADD_INFO",
00635 $this->error != "" && isset($_POST['add_info'])
00636 ? ilUtil::prepareFormOutput($_POST['add_info'],true)
00637 : ilUtil::prepareFormOutput($genSetData['add_info'],true));
00638 $this->tpl->setVariable("VAT_RATE",
00639 $this->error != "" && isset($_POST['vat_rate'])
00640 ? ilUtil::prepareFormOutput($_POST['vat_rate'],true)
00641 : ilUtil::prepareFormOutput($genSetData['vat_rate'],true));
00642 $this->tpl->setVariable("PDF_PATH",
00643 $this->error != "" && isset($_POST['pdf_path'])
00644 ? ilUtil::prepareFormOutput($_POST['pdf_path'],true)
00645 : ilUtil::prepareFormOutput($genSetData['pdf_path'],true));
00646
00647
00648 $this->tpl->setVariable("COLUMN_COUNT",2);
00649 $this->tpl->setVariable("PBTN_NAME",'saveGeneralSettings');
00650 $this->tpl->setVariable("PBTN_VALUE",$this->lng->txt('save'));
00651 }
00652
00653 function saveGeneralSettingsObject()
00654 {
00655 include_once './payment/classes/class.ilGeneralSettings.php';
00656
00657 $genSet = new ilGeneralSettings();
00658
00659 global $rbacsystem;
00660
00661
00662 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
00663 {
00664 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00665 }
00666
00667 if ($_POST["currency_unit"] == "" ||
00668 $_POST["currency_subunit"] == "" ||
00669 $_POST["address"] == "" ||
00670 $_POST["bank_data"] == "" ||
00671 $_POST["pdf_path"] == "")
00672 {
00673 $this->error = $this->lng->txt('pays_general_settings_not_valid');
00674 sendInfo($this->error);
00675 $this->generalSettingsObject();
00676 return;
00677 }
00678
00679 $genSet->clearAll();
00680 $values = array(
00681 "currency_unit" => ilUtil::stripSlashes($_POST['currency_unit']),
00682 "currency_subunit" => ilUtil::stripSlashes($_POST['currency_subunit']),
00683 "address" => ilUtil::stripSlashes($_POST['address']),
00684 "bank_data" => ilUtil::stripSlashes($_POST['bank_data']),
00685 "add_info" => ilUtil::stripSlashes($_POST['add_info']),
00686 "vat_rate" => (float) str_replace(",", ".", ilUtil::stripSlashes($_POST['vat_rate'])),
00687 "pdf_path" => ilUtil::stripSlashes($_POST['pdf_path'])
00688 );
00689 $genSet->setAll($values);
00690 $this->generalSettingsObject();
00691
00692 sendInfo($this->lng->txt('pays_updated_general_settings'));
00693
00694 return true;
00695 }
00696
00697 function paypalSettingsObject($a_show_confirm = false)
00698 {
00699 include_once './payment/classes/class.ilPaypalSettings.php';
00700
00701 $ppSet = new ilPaypalSettings();
00702 $ppSetData = $ppSet->getAll();
00703
00704 global $rbacsystem;
00705
00706
00707 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
00708 {
00709 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00710 }
00711
00712 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_paypal_settings.html",'payment');
00713
00714 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00715 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_pays.gif'));
00716 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_pays'));
00717 $this->tpl->setVariable("TITLE",$this->lng->txt('pays_paypal_settings'));
00718 $this->tpl->setVariable("TXT_SERVER_HOST",$this->lng->txt('pays_server_host'));
00719 $this->tpl->setVariable("TXT_SERVER_PATH",$this->lng->txt('pays_server_path'));
00720 $this->tpl->setVariable("TXT_EMAIL_VENDOR",$this->lng->txt('pays_email_vendor'));
00721 $this->tpl->setVariable("TXT_AUTH_TOKEN",$this->lng->txt('pays_auth_token'));
00722 $this->tpl->setVariable("TXT_PAGE_STYLE",$this->lng->txt('pays_page_style'));
00723 $this->tpl->setVariable("TXT_NO",$this->lng->txt('no'));
00724 $this->tpl->setVariable("TXT_YES",$this->lng->txt('yes'));
00725 $this->tpl->setVariable("SERVER_HOST",
00726 $this->error != "" && isset($_POST['server_host'])
00727 ? ilUtil::prepareFormOutput($_POST['server_host'],true)
00728 : ilUtil::prepareFormOutput($ppSetData['server_host'],true));
00729 $this->tpl->setVariable("SERVER_PATH",
00730 $this->error != "" && isset($_POST['server_path'])
00731 ? ilUtil::prepareFormOutput($_POST['server_path'],true)
00732 : ilUtil::prepareFormOutput($ppSetData['server_path'],true));
00733 $this->tpl->setVariable("VENDOR",
00734 $this->error != "" && isset($_POST['vendor'])
00735 ? ilUtil::prepareFormOutput($_POST['vendor'],true)
00736 : ilUtil::prepareFormOutput($ppSetData['vendor'],true));
00737 $this->tpl->setVariable("AUTH_TOKEN",
00738 $this->error != "" && isset($_POST['auth_token'])
00739 ? ilUtil::prepareFormOutput($_POST['auth_token'],true)
00740 : ilUtil::prepareFormOutput($ppSetData['auth_token'],true));
00741 $this->tpl->setVariable("PAGE_STYLE",
00742 $this->error != "" && isset($_POST['page_style'])
00743 ? ilUtil::prepareFormOutput($_POST['page_style'],true)
00744 : ilUtil::prepareFormOutput($ppSetData['page_style'],true));
00745
00746
00747 $this->tpl->setVariable("COLUMN_COUNT",2);
00748 $this->tpl->setVariable("PBTN_NAME",'savePaypalSettings');
00749 $this->tpl->setVariable("PBTN_VALUE",$this->lng->txt('save'));
00750
00751 }
00752
00753 function savePaypalSettingsObject()
00754 {
00755 include_once './payment/classes/class.ilPaypalSettings.php';
00756
00757 $ppSet = new ilPaypalSettings();
00758
00759 global $rbacsystem;
00760
00761
00762 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
00763 {
00764 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00765 }
00766
00767 if ($_POST["server_host"] == "" ||
00768 $_POST["server_path"] == "" ||
00769 $_POST["vendor"] == "" ||
00770 $_POST["auth_token"] == "")
00771 {
00772 $this->error = $this->lng->txt('pays_paypal_settings_not_valid');
00773 sendInfo($this->error);
00774 $this->paypalSettingsObject();
00775 return;
00776 }
00777
00778 $ppSet->clearAll();
00779 $values = array(
00780 "server_host" => ilUtil::stripSlashes($_POST['server_host']),
00781 "server_path" => ilUtil::stripSlashes($_POST['server_path']),
00782 "vendor" => ilUtil::stripSlashes($_POST['vendor']),
00783 "auth_token" => ilUtil::stripSlashes($_POST['auth_token']),
00784 "page_style" => ilUtil::stripSlashes($_POST['page_style']),
00785 "ssl" => ilUtil::stripSlashes($_POST['ssl'])
00786 );
00787 $ppSet->setAll($values);
00788 $this->paypalSettingsObject();
00789
00790 sendInfo($this->lng->txt('pays_updated_paypal_settings'));
00791
00792 return true;
00793 }
00794
00795 function vendorsObject($a_show_confirm = false)
00796 {
00797 include_once './payment/classes/class.ilPaymentBookings.php';
00798
00799 global $rbacsystem;
00800
00801
00802 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
00803 {
00804 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00805 }
00806
00807 $_SESSION['pays_vendor'] = is_array($_SESSION['pays_vendor']) ? $_SESSION['pays_vendor'] : array();
00808
00809
00810 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_vendors.html",'payment');
00811
00812 $this->__showButton('searchUser',$this->lng->txt('search_user'));
00813
00814 $this->object->initPaymentVendorsObject();
00815 if(!count($vendors = $this->object->payment_vendors_obj->getVendors()))
00816 {
00817 sendInfo($this->lng->txt('pay_no_vendors_created'));
00818 }
00819 # else
00820 # {
00821 # $this->__showButton('exportVendors',$this->lng->txt('excel_export'));
00822 # }
00823
00824
00825
00826 if($a_show_confirm)
00827 {
00828 $this->tpl->setCurrentBlock("confirm_delete");
00829 $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
00830 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00831 $this->tpl->setVariable("CONFIRM_CMD",'performDeleteVendors');
00832 $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('delete'));
00833 $this->tpl->parseCurrentBlock();
00834 }
00835
00836 $counter = 0;
00837 $f_result = array();
00838 foreach($vendors as $vendor)
00839 {
00840
00841 if($tmp_obj = ilObjectFactory::getInstanceByObjId($vendor['vendor_id'],false))
00842 {
00843 $f_result[$counter][] = ilUtil::formCheckbox(in_array($vendor['vendor_id'],$_SESSION['pays_vendor']) ? 1 : 0,
00844 "vendor[]",
00845 $vendor['vendor_id']);
00846 $f_result[$counter][] = $tmp_obj->getLogin();
00847 $f_result[$counter][] = $vendor['cost_center'];
00848 $f_result[$counter][] = ilPaymentBookings::_getCountBookingsByVendor($vendor['vendor_id']);
00849
00850 unset($tmp_obj);
00851 ++$counter;
00852 }
00853 }
00854 $this->__showVendorsTable($f_result);
00855
00856 return true;
00857 }
00858
00859 function exportVendorsObject()
00860 {
00861 include_once './payment/classes/class.ilPaymentExcelWriterAdapter.php';
00862
00863 $pewa =& new ilPaymentExcelWriterAdapter('payment_vendors.xls');
00864
00865
00866 $this->addVendorWorksheet($pewa);
00867 $this->addStatisticWorksheet($pewa);
00868
00869
00870
00871 $workbook =& $pewa->getWorkbook();
00872 $workbook->close();
00873 }
00874
00875 function addStatisticWorksheet(&$pewa)
00876 {
00877 include_once './classes/class.ilExcelUtils.php';
00878 include_once './payment/classes/class.ilPaymentVendors.php';
00879
00880 $this->__initBookingObject();
00881
00882 if(!count($bookings = $this->booking_obj->getBookings()))
00883 {
00884 return false;
00885 }
00886
00887 $workbook =& $pewa->getWorkbook();
00888 $worksheet =& $workbook->addWorksheet(utf8_decode($this->lng->txt('paya_statistic')));
00889
00890 $worksheet->mergeCells(0,0,0,8);
00891 $worksheet->setColumn(0,0,16);
00892 $worksheet->setColumn(0,1,32);
00893 $worksheet->setColumn(0,2,32);
00894 $worksheet->setColumn(0,3,16);
00895 $worksheet->setColumn(0,4,16);
00896 $worksheet->setColumn(0,5,16);
00897 $worksheet->setColumn(0,6,24);
00898 $worksheet->setColumn(0,7,8);
00899 $worksheet->setColumn(0,8,12);
00900 $worksheet->setColumn(0,9,16);
00901
00902 $title = $this->lng->txt('paya_statistic');
00903 $title .= ' '.$this->lng->txt('as_of');
00904 $title .= strftime('%Y-%m-%d %R',time());
00905
00906 $worksheet->writeString(0,0,$title,$pewa->getFormatTitle());
00907
00908 $worksheet->writeString(1,0,ilExcelUtils::_convert_text($this->lng->txt('payment_system')),$pewa->getFormatHeader());
00909 $worksheet->writeString(1,1,ilExcelUtils::_convert_text($this->lng->txt('paya_transaction')),$pewa->getFormatHeader());
00910 $worksheet->writeString(1,2,ilExcelUtils::_convert_text($this->lng->txt('title')),$pewa->getFormatHeader());
00911 $worksheet->writeString(1,3,ilExcelUtils::_convert_text($this->lng->txt('paya_vendor')),$pewa->getFormatHeader());
00912 $worksheet->writeString(1,4,ilExcelUtils::_convert_text($this->lng->txt('pays_cost_center')),$pewa->getFormatHeader());
00913 $worksheet->writeString(1,5,ilExcelUtils::_convert_text($this->lng->txt('paya_customer')),$pewa->getFormatHeader());
00914 $worksheet->writeString(1,6,ilExcelUtils::_convert_text($this->lng->txt('paya_order_date')),$pewa->getFormatHeader());
00915 $worksheet->writeString(1,7,ilExcelUtils::_convert_text($this->lng->txt('duration')),$pewa->getFormatHeader());
00916 $worksheet->writeString(1,8,ilExcelUtils::_convert_text($this->lng->txt('price_a')),$pewa->getFormatHeader());
00917 $worksheet->writeString(1,9,ilExcelUtils::_convert_text($this->lng->txt('paya_payed_access')),$pewa->getFormatHeader());
00918
00919 $counter = 2;
00920 foreach($bookings as $booking)
00921 {
00922 $tmp_obj =& ilObjectFactory::getInstanceByRefId($booking['ref_id']);
00923 $tmp_vendor =& ilObjectFactory::getInstanceByObjId($booking['b_vendor_id']);
00924 $tmp_purchaser =& ilObjectFactory::getInstanceByObjId($booking['customer_id']);
00925
00926 switch ($booking['b_pay_method'])
00927 {
00928 case $this->pobject->PAY_METHOD_BILL :
00929 $pay_method = $this->lng->txt("pays_bill");
00930 break;
00931 case $this->pobject->PAY_METHOD_BMF :
00932 $pay_method = $this->lng->txt("pays_bmf");
00933 break;
00934 case $this->pobject->PAY_METHOD_PAYPAL :
00935 $pay_method = $this->lng->txt("pays_paypal");
00936 break;
00937 }
00938 $worksheet->writeString($counter,0,ilExcelUtils::_convert_text($pay_method));
00939 $worksheet->writeString($counter,1,ilExcelUtils::_convert_text($booking['transaction_extern']));
00940 $worksheet->writeString($counter,2,ilExcelUtils::_convert_text($tmp_obj->getTitle()));
00941 $worksheet->writeString($counter,3,ilExcelUtils::_convert_text($tmp_vendor->getLogin()));
00942 $worksheet->writeString($counter,4,ilExcelUtils::_convert_text(ilPaymentVendors::_getCostCenter($tmp_vendor->getId())));
00943 $worksheet->writeString($counter,5,ilExcelUtils::_convert_text($tmp_purchaser->getLogin()));
00944 $worksheet->writeString($counter,6,strftime('%Y-%m-%d %R',$booking['order_date']));
00945
00946
00947
00948
00949
00950
00951
00952
00953 $worksheet->writeString($counter,7,$booking['duration']);
00954 $worksheet->writeString($counter,8,ilExcelUtils::_convert_text($booking['price']));
00955
00956 $payed_access = $booking['payed'] ?
00957 $this->lng->txt('yes') :
00958 $this->lng->txt('no');
00959
00960 $payed_access .= '/';
00961 $payed_access .= $booking['access'] ?
00962 $this->lng->txt('yes') :
00963 $this->lng->txt('no');
00964
00965 $worksheet->writeString($counter,9,$payed_access);
00966
00967 unset($tmp_obj);
00968 unset($tmp_vendor);
00969 unset($tmp_purchaser);
00970
00971 ++$counter;
00972 }
00973 }
00974
00975 function addVendorWorksheet(&$pewa)
00976 {
00977 include_once './classes/class.ilExcelUtils.php';
00978
00979 $this->object->initPaymentVendorsObject();
00980 if(!count($vendors = $this->object->payment_vendors_obj->getVendors()))
00981 {
00982 return false;
00983 }
00984
00985 $workbook =& $pewa->getWorkbook();
00986 $worksheet =& $workbook->addWorksheet(ilExcelUtils::_convert_text($this->lng->txt('pays_vendor')));
00987
00988
00989 $worksheet->mergeCells(0,0,0,2);
00990 $worksheet->setColumn(1,0,32);
00991 $worksheet->setColumn(1,1,32);
00992 $worksheet->setColumn(1,2,32);
00993
00994 $title = $this->lng->txt('paya_vendor_list');
00995 $title .= ' '.$this->lng->txt('as_of');
00996 $title .= strftime('%Y-%m-%d %R',time());
00997
00998 $worksheet->writeString(0,0,$title,$pewa->getFormatTitle());
00999
01000 $worksheet->writeString(1,0,ilExcelUtils::_convert_text($this->lng->txt('login')),$pewa->getFormatHeader());
01001 $worksheet->writeString(1,1,ilExcelUtils::_convert_text($this->lng->txt('fullname')),$pewa->getFormatHeader());
01002 $worksheet->writeString(1,2,ilExcelUtils::_convert_text($this->lng->txt('pays_cost_center')),$pewa->getFormatHeader());
01003
01004 $counter = 2;
01005 foreach($vendors as $vendor)
01006 {
01007
01008 if($tmp_obj = ilObjectFactory::getInstanceByObjId($vendor['vendor_id'],false))
01009 {
01010 $worksheet->writeString($counter,0,ilExcelUtils::_convert_text($tmp_obj->getLogin()));
01011 $worksheet->writeString($counter,1,ilExcelUtils::_convert_text($tmp_obj->getFullname()));
01012 $worksheet->writeString($counter,2,ilExcelUtils::_convert_text($vendor['cost_center']));
01013 }
01014 unset($tmp_obj);
01015 ++$counter;
01016 }
01017 }
01018
01019 function payMethodsObject()
01020 {
01021 include_once './payment/classes/class.ilPayMethods.php';
01022
01023 global $rbacsystem;
01024
01025
01026 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01027 {
01028 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
01029 }
01030
01031 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_pay_methods.html",'payment');
01032
01033 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01034 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_pays.gif'));
01035 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_pays'));
01036 $this->tpl->setVariable("TITLE",$this->lng->txt('pays_pay_methods'));
01037 $this->tpl->setVariable("TXT_OFFLINE",$this->lng->txt('pays_offline'));
01038 $this->tpl->setVariable("TXT_BILL",$this->lng->txt('pays_bill'));
01039 $this->tpl->setVariable("BILL_CHECK",ilUtil::formCheckbox(
01040 (int) ilPayMethods::_enabled('pm_bill') ? 1 : 0,'pm_bill',1,true));
01041
01042 $this->tpl->setVariable("TXT_ENABLED",$this->lng->txt('enabled'));
01043 $this->tpl->setVariable("TXT_ONLINE",$this->lng->txt('pays_online'));
01044 $this->tpl->setVariable("TXT_BMF",$this->lng->txt('pays_bmf'));
01045 $this->tpl->setVariable("BMF_ONLINE_CHECK",ilUtil::formCheckbox((int) ilPayMethods::_enabled('pm_bmf'),'pm_bmf',1));
01046
01047 $this->tpl->setVariable("TXT_ENABLED",$this->lng->txt('enabled'));
01048 $this->tpl->setVariable("TXT_ONLINE",$this->lng->txt('pays_online'));
01049 $this->tpl->setVariable("TXT_PAYPAL",$this->lng->txt('pays_paypal'));
01050 $this->tpl->setVariable("PAYPAL_ONLINE_CHECK",ilUtil::formCheckbox((int) ilPayMethods::_enabled('pm_paypal'),'pm_paypal',1));
01051
01052
01053 $this->tpl->setVariable("COLUMN_COUNT",3);
01054 $this->tpl->setVariable("PBTN_NAME",'savePayMethods');
01055 $this->tpl->setVariable("PBTN_VALUE",$this->lng->txt('save'));
01056
01057 }
01058
01059 function savePayMethodsObject()
01060 {
01061 include_once './payment/classes/class.ilPayMethods.php';
01062 include_once './payment/classes/class.ilPaymentObject.php';
01063
01064
01065 global $rbacsystem;
01066
01067
01068 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01069 {
01070 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
01071 }
01072
01073
01074
01075 if(ilPayMethods::_enabled('pm_bill') and !$_POST['pm_bill'])
01076 {
01077 if(ilPaymentObject::_getCountObjectsByPayMethod('pm_bill'))
01078 {
01079 sendInfo($this->lng->txt('pays_objects_bill_exist'));
01080 $this->payMethodsObject();
01081
01082 return false;
01083 }
01084 }
01085
01086 if(ilPayMethods::_enabled('pm_bmf') and !$_POST['pm_bmf'])
01087 {
01088 if(ilPaymentObject::_getCountObjectsByPayMethod('pm_bmf'))
01089 {
01090 sendInfo($this->lng->txt('pays_objects_bmf_exist'));
01091 $this->payMethodsObject();
01092
01093 return false;
01094 }
01095 }
01096
01097 if(ilPayMethods::_enabled('pm_paypal') and !$_POST['pm_paypal'])
01098 {
01099 if(ilPaymentObject::_getCountObjectsByPayMethod('pm_paypal'))
01100 {
01101 sendInfo($this->lng->txt('pays_objects_paypal_exist'));
01102 $this->payMethodsObject();
01103
01104 return false;
01105 }
01106 }
01107
01108 ilPayMethods::_disableAll();
01109 if(isset($_POST['pm_bill']))
01110 {
01111 ilPayMethods::_enable('pm_bill');
01112 }
01113 if(isset($_POST['pm_bmf']))
01114 {
01115 ilPayMethods::_enable('pm_bmf');
01116 }
01117 if(isset($_POST['pm_paypal']))
01118 {
01119 ilPayMethods::_enable('pm_paypal');
01120 }
01121 $this->payMethodsObject();
01122
01123 sendInfo($this->lng->txt('pays_updated_pay_method'));
01124
01125 return true;
01126 }
01127
01128 function cancelDeleteVendorsObject()
01129 {
01130 unset($_SESSION['pays_vendor']);
01131 $this->vendorsObject();
01132
01133 return true;
01134 }
01135
01136 function deleteVendors()
01137 {
01138 include_once './payment/classes/class.ilPaymentBookings.php';
01139
01140 if(!count($_POST['vendor']))
01141 {
01142 sendInfo($this->lng->txt('pays_no_vendor_selected'));
01143 $this->vendorsObject();
01144
01145 return true;
01146 }
01147
01148 foreach($_POST['vendor'] as $vendor)
01149 {
01150 if(ilPaymentBookings::_getCountBookingsByVendor($vendor))
01151 {
01152 sendInfo($this->lng->txt('pays_active_bookings'));
01153 $this->vendorsObject();
01154
01155 return true;
01156 }
01157 }
01158
01159 $_SESSION["pays_vendor"] = $_POST["vendor"];
01160 sendInfo($this->lng->txt("pays_sure_delete_selected_vendors"));
01161 $this->vendorsObject(true);
01162
01163 return true;
01164 }
01165 function performDeleteVendorsObject()
01166 {
01167 include_once './payment/classes/class.ilPaymentTrustees.php';
01168
01169 global $rbacsystem;
01170
01171
01172 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
01173 {
01174 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01175 }
01176
01177 $this->object->initPaymentVendorsObject();
01178
01179 foreach($_SESSION['pays_vendor'] as $vendor)
01180 {
01181 $this->object->payment_vendors_obj->delete($vendor);
01182 ilPaymentTrustees::_deleteTrusteesOfVendor($vendor);
01183 }
01184
01185 sendInfo($this->lng->txt('pays_deleted_number_vendors').' '.count($_SESSION['pays_vendor']));
01186 unset($_SESSION['pays_vendor']);
01187
01188 $this->vendorsObject();
01189
01190 return true;
01191 }
01192
01193 function editVendor()
01194 {
01195 global $rbacsystem;
01196
01197
01198 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
01199 {
01200 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01201 }
01202
01203 if(!count($_POST['vendor']))
01204 {
01205 sendInfo($this->lng->txt('pays_no_vendor_selected'));
01206 $this->vendorsObject();
01207
01208 return true;
01209 }
01210 if(count($_POST['vendor']) > 1)
01211 {
01212 sendInfo($this->lng->txt('pays_too_many_vendors_selected'));
01213 $this->vendorsObject();
01214
01215 return true;
01216 }
01217
01218 $_SESSION["pays_vendor"] = $_POST["vendor"][0];
01219
01220 $this->object->initPaymentVendorsObject();
01221
01222 if (!is_array($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]))
01223 {
01224 $this->vendorsObject();
01225
01226 return true;
01227 }
01228
01229 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pays_vendor.html','payment');
01230
01231 $this->tpl->setVariable("VENDOR_FORMACTION",$this->ctrl->getFormAction($this));
01232
01233
01234 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_usr.gif'));
01235 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
01236 $this->tpl->setVariable("TITLE",$this->lng->txt('pays_vendor'));
01237
01238
01239 $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('pays_vendor'));
01240 $this->tpl->setVariable("TXT_COST_CENTER",$this->lng->txt('pays_cost_center'));
01241
01242 $this->tpl->setVariable("INPUT_VALUE",ucfirst($this->lng->txt('save')));
01243
01244
01245
01246 $this->tpl->setVariable("VENDOR",
01247 ilObjUser::getLoginByUserId($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]["vendor_id"]), true);
01248 $this->tpl->setVariable("COST_CENTER",
01249 $this->error != "" && isset($_POST['cost_center'])
01250 ? ilUtil::prepareFormOutput($_POST['cost_center'],true)
01251 : ilUtil::prepareFormOutput($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]["cost_center"],true));
01252
01253
01254 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01255 $this->tpl->setCurrentBlock("btn_cell");
01256 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "vendors"));
01257 $this->tpl->setVariable("BTN_TXT", $this->lng->txt('pay_bmf_back'));
01258 $this->tpl->parseCurrentBlock("btn_cell");
01259
01260 }
01261 function performEditVendorObject()
01262 {
01263 global $rbacsystem;
01264
01265
01266 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
01267 {
01268 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01269 }
01270
01271 if(!count($_SESSION['pays_vendor']))
01272 {
01273 sendInfo($this->lng->txt('pays_no_vendor_selected'));
01274 $this->vendorsObject();
01275
01276 return true;
01277 }
01278 if(count($_SESSION['pays_vendor']) > 1)
01279 {
01280 sendInfo($this->lng->txt('pays_too_many_vendors_selected'));
01281 $this->vendorsObject();
01282
01283 return true;
01284 }
01285
01286 $this->object->initPaymentVendorsObject();
01287
01288 if (!is_array($this->object->payment_vendors_obj->vendors[$_SESSION["pays_vendor"]]))
01289 {
01290 $this->vendorsObject();
01291
01292 return true;
01293 }
01294
01295 if ($_POST["cost_center"] == "")
01296 {
01297 $this->error = $this->lng->txt('pays_cost_center_not_valid');
01298 sendInfo($this->error);
01299 $_POST["vendor"] = array($_SESSION["pays_vendor"]);
01300 $this->editVendor();
01301 return;
01302 }
01303
01304 $this->object->initPaymentVendorsObject();
01305 $this->object->payment_vendors_obj->update($_SESSION["pays_vendor"], $_POST["cost_center"]);
01306
01307 unset($_SESSION['pays_vendor']);
01308
01309 $this->vendorsObject();
01310
01311 return true;
01312 }
01313
01314 function showObjectSelectorObject()
01315 {
01316 global $rbacsystem, $tree;
01317
01318
01319 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01320 {
01321 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
01322 }
01323
01324 include_once './payment/classes/class.ilPaymentObjectSelector.php';
01325
01326 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paya_object_selector.html",'payment');
01327 $this->__showButton('statistic',$this->lng->txt('back'));
01328
01329
01330 sendInfo($this->lng->txt("paya_select_object_to_sell"));
01331
01332 $exp = new ilPaymentObjectSelector($this->ctrl->getLinkTarget($this,'showObjectSelector'), strtolower(get_class($this)));
01333 $exp->setExpand($_GET["paya_link_expand"] ? $_GET["paya_link_expand"] : $tree->readRootId());
01334 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showObjectSelector'));
01335
01336 $exp->setOutput(0);
01337
01338 $this->tpl->setVariable("EXPLORER",$exp->getOutput());
01339
01340 return true;
01341 }
01342
01343 function searchUserObject()
01344 {
01345 global $rbacsystem;
01346
01347
01348 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01349 {
01350 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
01351 }
01352
01353 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.pays_user_search.html",'payment');
01354 $this->__showButton('vendors',$this->lng->txt('back'));
01355
01356 $this->lng->loadLanguageModule('search');
01357
01358 $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
01359 $this->tpl->setVariable("SEARCH_ASSIGN_USR",$this->lng->txt("crs_search_members"));
01360 $this->tpl->setVariable("SEARCH_SEARCH_TERM",$this->lng->txt("search_search_term"));
01361 $this->tpl->setVariable("SEARCH_VALUE",$_SESSION["pays_search_str"] ? $_SESSION["pays_search_str"] : "");
01362 $this->tpl->setVariable("BTN2_VALUE",$this->lng->txt("cancel"));
01363 $this->tpl->setVariable("BTN1_VALUE",$this->lng->txt("search"));
01364
01365 return true;
01366 }
01367
01368 function searchObject()
01369 {
01370 global $rbacsystem,$tree;
01371
01372 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01373 {
01374 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
01375 }
01376
01377 $_SESSION["pays_search_str"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["pays_search_str"];
01378
01379 if(!isset($_POST["search_str"]))
01380 {
01381 sendInfo($this->lng->txt("crs_search_enter_search_string"));
01382 $this->searchUserObject();
01383
01384 return false;
01385 }
01386 if(!count($result = $this->__search(ilUtil::stripSlashes($_POST["search_str"]))))
01387 {
01388 sendInfo($this->lng->txt("crs_no_results_found"));
01389 $this->searchUserObject();
01390
01391 return false;
01392 }
01393
01394 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pays_usr_selection.html",'payment');
01395 $this->__showButton("searchUser",$this->lng->txt("crs_new_search"));
01396
01397 $counter = 0;
01398 $f_result = array();
01399 foreach($result as $user)
01400 {
01401 if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user["id"],false))
01402 {
01403 continue;
01404 }
01405 $f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user["id"]);
01406 $f_result[$counter][] = $tmp_obj->getLogin();
01407 $f_result[$counter][] = $tmp_obj->getLastname();
01408 $f_result[$counter][] = $tmp_obj->getFirstname();
01409
01410 unset($tmp_obj);
01411 ++$counter;
01412 }
01413 $this->__showSearchUserTable($f_result);
01414
01415 return true;
01416 }
01417 function addVendorObject()
01418 {
01419 global $rbacsystem;
01420
01421
01422 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
01423 {
01424 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01425 }
01426 if(!$_POST['vendor_login'])
01427 {
01428 sendInfo($this->lng->txt('pays_no_username_given'));
01429 $this->vendorsObject();
01430
01431 return true;
01432 }
01433 if(!($usr_id = ilObjUser::getUserIdByLogin(ilUtil::stripSlashes($_POST['vendor_login']))))
01434 {
01435 sendInfo($this->lng->txt('pays_no_valid_username_given'));
01436 $this->vendorsObject();
01437
01438 return true;
01439 }
01440
01441 $this->object->initPaymentVendorsObject();
01442
01443 if($this->object->payment_vendors_obj->isAssigned($usr_id))
01444 {
01445 sendInfo($this->lng->txt('pays_user_already_assigned'));
01446 $this->vendorsObject();
01447
01448 return true;
01449 }
01450 $this->object->payment_vendors_obj->add($usr_id);
01451
01452 sendInfo($this->lng->txt('pays_added_vendor'));
01453 $this->vendorsObject();
01454
01455 return true;
01456 }
01457
01458 function addUserObject()
01459 {
01460 global $rbacsystem;
01461
01462
01463 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
01464 {
01465 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
01466 }
01467
01468 $this->lng->loadLanguageModule('crs');
01469 if(!is_array($_POST["user"]))
01470 {
01471 sendInfo($this->lng->txt("crs_no_users_selected"));
01472 $this->searchObject();
01473
01474 return false;
01475 }
01476
01477 $this->object->initPaymentVendorsObject();
01478
01479 $already_assigned = $assigned = 0;
01480 foreach($_POST['user'] as $usr_id)
01481 {
01482 if($this->object->payment_vendors_obj->isAssigned($usr_id))
01483 {
01484 ++$already_assigned;
01485
01486 continue;
01487 }
01488 $this->object->payment_vendors_obj->add($usr_id);
01489 ++$assigned;
01490
01491
01492 }
01493 $message = '';
01494 if($assigned)
01495 {
01496 $message .= $this->lng->txt('pays_assigned_vendors').' '.$assigned;
01497 }
01498 if($already_assigned)
01499 {
01500 $message .= '<br />'.$this->lng->txt('pays_already_assigned_vendors').' '.$already_assigned;
01501 }
01502
01503 sendInfo($message);
01504 $this->vendorsObject();
01505
01506 return true;
01507 }
01508
01509
01510 function searchUserSPObject()
01511 {
01512 if(!isset($_GET['sell_id']))
01513 {
01514 sendInfo($this->lng->txt('paya_no_booking_id_given'));
01515 $this->showObjectSelectorObject();
01516
01517 return false;
01518 }
01519
01520 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.paya_user_search.html",'payment');
01521 $this->__showButton('showObjectSelector',$this->lng->txt('back'));
01522
01523 $this->lng->loadLanguageModule('search');
01524
01525 $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
01526 $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
01527 $this->tpl->setVariable("SEARCH_ASSIGN_USR",$this->lng->txt("search_user"));
01528 $this->tpl->setVariable("SEARCH_SEARCH_TERM",$this->lng->txt("search_search_term"));
01529 $this->tpl->setVariable("SEARCH_VALUE",$_SESSION["paya_search_str_user_sp"] ? $_SESSION["paya_search_str_user_sp"] : "");
01530 $this->tpl->setVariable("BTN2_VALUE",$this->lng->txt("cancel"));
01531 $this->tpl->setVariable("BTN1_VALUE",$this->lng->txt("search"));
01532 $this->tpl->setVariable("SEARCH","performSearchSP");
01533 $this->tpl->setVariable("CANCEL","statistic");
01534
01535 return true;
01536 }
01537
01538 function performSearchSPObject()
01539 {
01540
01541 $_SESSION["paya_search_str_user_sp"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["paya_search_str_user_sp"];
01542
01543 if(!trim($_POST["search_str"]))
01544 {
01545 sendInfo($this->lng->txt("search_no_search_term"));
01546 $this->statistics();
01547
01548 return false;
01549 }
01550 if(!count($result = $this->__search(ilUtil::stripSlashes($_POST["search_str"]))))
01551 {
01552 sendInfo($this->lng->txt("search_no_match"));
01553 $this->searchUserSPObject();
01554
01555 return false;
01556 }
01557
01558 if(!isset($_GET['sell_id']))
01559 {
01560 sendInfo($this->lng->txt('paya_no_booking_id_given'));
01561 $this->showObjectSelectorObject();
01562
01563 return false;
01564 }
01565
01566 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paya_usr_selection.html",'payment');
01567 $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
01568 $this->__showButton("searchUserSP",$this->lng->txt("back"));
01569
01570 $counter = 0;
01571 $f_result = array();
01572 foreach($result as $user)
01573 {
01574 if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user["id"],false))
01575 {
01576 continue;
01577 }
01578 $f_result[$counter][] = ilUtil::formRadiobutton(0,"user_id",$user["id"]);
01579 $f_result[$counter][] = $tmp_obj->getLogin();
01580 $f_result[$counter][] = $tmp_obj->getFirstname();
01581 $f_result[$counter][] = $tmp_obj->getLastname();
01582
01583 unset($tmp_obj);
01584 ++$counter;
01585 }
01586 $this->__showSearchUserSPTable($f_result);
01587 }
01588
01589 function addCustomerObject()
01590 {
01591 if ($_POST["sell_id"] != "") $_GET["sell_id"] = $_POST["sell_id"];
01592 if ($_GET["user_id"] != "") $_POST["user_id"] = $_GET["user_id"];
01593
01594 if(!isset($_GET['sell_id']))
01595 {
01596 sendInfo($this->lng->txt('paya_no_booking_id_given'));
01597 $this->showObjectSelectorObject();
01598
01599 return true;
01600 }
01601
01602 if(!isset($_POST['user_id']))
01603 {
01604 sendInfo($this->lng->txt('paya_no_user_id_given'));
01605 $this->searchUserSPObject();
01606
01607 return true;
01608 }
01609
01610 $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
01611 $this->__showButton('searchUserSP',$this->lng->txt('back'));
01612
01613 $this->ctrl->setParameter($this, "user_id", $_POST["user_id"]);
01614
01615 $pObjectId = ilPaymentObject::_lookupPobjectId($_GET["sell_id"]);
01616 $obj =& new ilPaymentObject($this->user_obj, $pObjectId);
01617
01618
01619 $tmp_obj =& ilObjectFactory::getInstanceByRefId($_GET["sell_id"]);
01620
01621 $tmp_user =& ilObjectFactory::getInstanceByObjId($_POST["user_id"]);
01622
01623 $tmp_vendor =& ilObjectFactory::getInstanceByObjId($obj->getVendorId());
01624
01625 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_add_customer.html','payment');
01626
01627 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01628
01629 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_usr.gif'));
01630 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
01631 $this->tpl->setVariable("TITLE",$tmp_user->getFullname().' ['.$tmp_user->getLogin().']');
01632
01633
01634 $this->tpl->setVariable("TXT_TRANSACTION",$this->lng->txt('paya_transaction'));
01635 $this->tpl->setVariable("TRANSACTION",ilUtil::prepareFormOutput($_POST["transaction"], true));
01636
01637 $this->tpl->setVariable("TXT_OB JECT",$this->lng->txt('title'));
01638 $this->tpl->setVariable("OBJECT",$tmp_obj->getTitle());
01639
01640 $this->tpl->setVariable("TXT_VENDOR",$this->lng->txt('paya_vendor'));
01641 $this->tpl->setVariable("VENDOR",$tmp_vendor->getFullname().' ['.$tmp_vendor->getLogin().']');
01642
01643 $this->tpl->setVariable("TXT_PAY_METHOD",$this->lng->txt('paya_pay_method'));
01644 $this->tpl->setVariable("TXT_PAY_METHOD_BILL",$this->lng->txt('pays_bill'));
01645 $this->tpl->setVariable("TXT_PAY_METHOD_BMF",$this->lng->txt('pays_bmf'));
01646 $this->tpl->setVariable("TXT_PAY_METHOD_PAYPAL",$this->lng->txt('pays_paypal'));
01647 $this->tpl->setVariable("PAY_METHOD_".$_POST["pay_method"], " selected");
01648
01649 $this->tpl->setVariable("TXT_ORDER_DATE",$this->lng->txt('paya_order_date'));
01650 $this->tpl->setVariable("ORDER_DATE",ilFormat::formatUnixTime(time(), true));
01651
01652 $this->tpl->setVariable("TXT_DURATION",$this->lng->txt('duration'));
01653 include_once './payment/classes/class.ilPaymentPrices.php';
01654 $prices_obj =& new ilPaymentPrices($pObjectId);
01655 if (is_array($prices = $prices_obj->getPrices()))
01656 {
01657 foreach($prices as $price)
01658 {
01659 $this->tpl->setCurrentBlock("duration_loop");
01660 if ($_POST["duration"] == $price["price_id"]) $this->tpl->setVariable("DURATION_LOOP_SELECTED", " selected");
01661 $this->tpl->setVariable("DURATION_LOOP_ID", $price["price_id"]);
01662 $this->tpl->setVariable("DURATION_LOOP_NAME", $price["duration"]." ".$this->lng->txt("paya_months").", ".ilPaymentPrices::_getPriceString($price["price_id"]));
01663 $this->tpl->parseCurrentBlock();
01664 }
01665 }
01666
01667 $this->tpl->setVariable("TXT_PAYED",$this->lng->txt('paya_payed'));
01668 if ($_POST["payed"] == 1) $this->tpl->setVariable("PAYED_1", " selected");
01669 $this->tpl->setVariable("TXT_ACCESS",$this->lng->txt('paya_access'));
01670 if ($_POST["access"] == 1) $this->tpl->setVariable("ACCESS_1", " selected");
01671
01672 $this->tpl->setVariable("TXT_NO",$this->lng->txt('no'));
01673 $this->tpl->setVariable("TXT_YES",$this->lng->txt('yes'));
01674 $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
01675 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
01676 $this->tpl->setVariable("STATISTICS","statistic");
01677
01678 }
01679
01680 function saveCustomerObject()
01681 {
01682 global $ilias;
01683
01684 if(!isset($_GET['sell_id']))
01685 {
01686 sendInfo($this->lng->txt('paya_error_no_object_id_given'));
01687 $this->showObjectSelectorObject();
01688
01689 return true;
01690 }
01691
01692 if(!isset($_GET['user_id']))
01693 {
01694 sendInfo($this->lng->txt('paya_error_no_user_id_given'));
01695 $this->searchUserSPObject();
01696
01697 return true;
01698 }
01699
01700 if ($_POST["pay_method"] == "" ||
01701 $_POST["duration"] == "")
01702 {
01703 sendInfo($this->lng->txt('paya_error_mandatory_fields'));
01704 $this->addCustomerObject();
01705
01706 return true;
01707 }
01708
01709 $pObjectId = ilPaymentObject::_lookupPobjectId($_GET["sell_id"]);
01710 $obj =& new ilPaymentObject($this->user_obj, $pObjectId);
01711
01712 $this->__initBookingObject();
01713
01714 $inst_id_time = $ilias->getSetting('inst_id').'_'.$this->user_obj->getId().'_'.substr((string) time(),-3);
01715 $transaction = $inst_id_time.substr(md5(uniqid(rand(), true)), 0, 4);
01716 $this->booking_obj->setTransaction($transaction);
01717 $this->booking_obj->setTransactionExtern($_POST["transaction"]);
01718 $this->booking_obj->setPobjectId($pObjectId);
01719 $this->booking_obj->setCustomerId($_GET["user_id"]);
01720 $this->booking_obj->setVendorId($obj->getVendorId());
01721 $this->booking_obj->setPayMethod((int) $_POST["pay_method"]);
01722 $this->booking_obj->setOrderDate(time());
01723 include_once './payment/classes/class.ilPaymentPrices.php';
01724 $price = ilPaymentPrices::_getPrice($_POST["duration"]);
01725 $this->booking_obj->setDuration($price["duration"]);
01726 $this->booking_obj->setPrice(ilPaymentPrices::_getPriceString($_POST["duration"]));
01727 $this->booking_obj->setAccess((int) $_POST['access']);
01728 $this->booking_obj->setPayed((int) $_POST['payed']);
01729 $this->booking_obj->setVoucher('');
01730
01731 if($this->booking_obj->add())
01732 {
01733 sendInfo($this->lng->txt('paya_customer_added_successfully'));
01734 $this->statisticObject();
01735 }
01736 else
01737 {
01738 sendInfo($this->lng->txt('paya_error_adding_customer'));
01739 $this->addCustomerObject();
01740 }
01741
01742 return true;
01743 }
01744
01745
01746 function __setSection($a_section)
01747 {
01748 $this->section = $a_section;
01749 }
01750 function __getSection()
01751 {
01752 return $this->section;
01753 }
01754 function __setMainSection($a_section)
01755 {
01756 $this->mainSection = $a_section;
01757 }
01758 function __getMainSection()
01759 {
01760 return $this->mainSection;
01761 }
01762
01763 function __buildSettingsButtons()
01764 {
01765 if($this->__getMainSection() == $this->SETTINGS)
01766 {
01767 $this->tabs_gui->addSubTabTarget('pays_general',
01768 $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'generalSettings'),
01769 '',
01770 '',
01771 '',
01772 $this->__getSection() == $this->SECTION_GENERAL ? true : false);
01773 $this->tabs_gui->addSubTabTarget('pays_paypal',
01774 $this->ctrl->getLinkTargetByClass('ilobjpaymentsettingsgui', 'paypalSettings'),
01775 '',
01776 '',
01777 '',
01778 $this->__getSection() == $this->SECTION_PAYPAL ? true : false);
01779 }
01780 }
01781
01782 function __showStatisticTable($a_result_set)
01783 {
01784 $tbl =& $this->__initTableGUI();
01785 $tpl =& $tbl->getTemplateObject();
01786
01787
01788 $tpl->setCurrentBlock("tbl_form_header");
01789
01790 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01791 $tpl->parseCurrentBlock();
01792
01793
01794 $tbl->setTitle($this->lng->txt("paya_statistic"),"icon_pays.gif",$this->lng->txt("paya_statistic"));
01795 $tbl->setHeaderNames(array($this->lng->txt("paya_transaction"),
01796 $this->lng->txt("title"),
01797 $this->lng->txt("paya_vendor"),
01798 $this->lng->txt("paya_customer"),
01799 $this->lng->txt("paya_order_date"),
01800 $this->lng->txt("duration"),
01801 $this->lng->txt("price_a"),
01802 $this->lng->txt("paya_payed_access"),
01803 ''));
01804
01805 $tbl->setHeaderVars(array("transaction",
01806 "title",
01807 "vendor",
01808 "customer",
01809 "order_date",
01810 "duration",
01811 "price",
01812 "payed_access",
01813 "options"),
01814 $this->ctrl->getParameterArray($this,"statistic",false));
01815
01816 $offset = $_GET["offset"];
01817 $order = $_GET["sort_by"];
01818 $direction = $_GET["sort_order"] ? $_GET['sort_order'] : 'desc';
01819
01820 $tbl->setOrderColumn($order,'order_date');
01821 $tbl->setOrderDirection($direction);
01822 $tbl->setOffset($offset);
01823 $tbl->setLimit($_GET["limit"]);
01824 $tbl->setMaxCount(count($a_result_set));
01825 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01826 $tbl->setData($a_result_set);
01827
01828 $tpl->setVariable("COLUMN_COUNTS",9);
01829 $tpl->setCurrentBlock("plain_buttons");
01830 $tpl->setVariable("PBTN_NAME","exportVendors");
01831 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("excel_export"));
01832 $tpl->parseCurrentBlock();
01833 $tbl->render();
01834
01835 $this->tpl->setVariable("STATISTIC_TABLE",$tbl->tpl->get());
01836
01837 return true;
01838 }
01839
01840 function __initBookingObject()
01841 {
01842 include_once './payment/classes/class.ilPaymentBookings.php';
01843
01844 $this->booking_obj =& new ilPaymentBookings($this->user_obj->getId(),true);
01845 }
01846
01847 function __showVendorsTable($a_result_set)
01848 {
01849 $actions = array(
01850 "editVendorObject" => $this->lng->txt("pays_edit_vendor"),
01851 "deleteVendorsObject" => $this->lng->txt("pays_delete_vendor")
01852 );
01853
01854 $tbl =& $this->__initTableGUI();
01855 $tpl =& $tbl->getTemplateObject();
01856
01857
01858 $tpl->setCurrentBlock("tbl_form_header");
01859
01860 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01861 $tpl->parseCurrentBlock();
01862
01863 $tpl->setCurrentBlock("tbl_action_row");
01864
01865 $tpl->setCurrentBlock("input_text");
01866 $tpl->setVariable("PB_TXT_NAME",'vendor_login');
01867 $tpl->parseCurrentBlock();
01868
01869 $tpl->setCurrentBlock("plain_button");
01870 $tpl->setVariable("PBTN_NAME","addVendor");
01871 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("pays_add_vendor"));
01872 $tpl->parseCurrentBlock();
01873 $tpl->setCurrentBlock("plain_buttons");
01874 $tpl->parseCurrentBlock();
01875
01876 $tpl->setVariable("COLUMN_COUNTS",4);
01877
01878 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01879
01880 $tpl->setCurrentBlock("tbl_action_select");
01881 $tpl->setVariable("SELECT_ACTION",ilUtil::formSelect(1,"action",$actions,false,true));
01882 $tpl->setVariable("BTN_NAME","gateway");
01883 $tpl->setVariable("BTN_VALUE",$this->lng->txt("execute"));
01884 $tpl->parseCurrentBlock();
01885 $tpl->setCurrentBlock("tbl_action_row");
01886 $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
01887 $tpl->parseCurrentBlock();
01888
01889 $tbl->setTitle($this->lng->txt("vendors"),"icon_usr.gif",$this->lng->txt("vendors"));
01890 $tbl->setHeaderNames(array('',
01891 $this->lng->txt("pays_vendor"),
01892 $this->lng->txt("pays_cost_center"),
01893 $this->lng->txt("pays_number_bookings")));
01894 $tbl->setHeaderVars(array("",
01895 "login",
01896 "cost_center",
01897 "bookings"),
01898 array("ref_id" => $this->object->getRefId(),
01899 "cmd" => "vendors",
01900 "update_members" => 1,
01901 "baseClass" => "ilAdministrationGUI",
01902 "cmdClass" => "ilobjpaymentsettingsgui",
01903 "cmdNode" => $_GET["cmdNode"]));
01904 # $tbl->setColumnWidth(array("4%","48%","25%","24%"));
01905
01906 $tpl->setVariable("COLUMN_COUNTS",9);
01907 $tpl->setCurrentBlock("plain_buttons");
01908 $tpl->setVariable("PBTN_NAME","exportVendors");
01909 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("excel_export"));
01910 $tpl->parseCurrentBlock();
01911
01912 $this->__setTableGUIBasicData($tbl,$a_result_set);
01913 $tbl->render();
01914
01915 $this->tpl->setVariable("VENDOR_TABLE",$tbl->tpl->get());
01916
01917 return true;
01918 }
01919
01920
01921 function __showSearchUserTable($a_result_set,$a_cmd = "search")
01922 {
01923 $tbl =& $this->__initTableGUI();
01924 $tpl =& $tbl->getTemplateObject();
01925
01926
01927
01928 $tpl->setCurrentBlock("tbl_form_header");
01929 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01930 $tpl->parseCurrentBlock();
01931
01932 $tpl->setCurrentBlock("tbl_action_btn");
01933 $tpl->setVariable("BTN_NAME","addUser");
01934 $tpl->setVariable("BTN_VALUE",$this->lng->txt("add"));
01935 $tpl->parseCurrentBlock();
01936
01937 $tpl->setCurrentBlock("tbl_action_btn");
01938 $tpl->setVariable("BTN_NAME","vendors");
01939 $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
01940 $tpl->parseCurrentBlock();
01941
01942 $tpl->setCurrentBlock("tbl_action_row");
01943 $tpl->setVariable("COLUMN_COUNTS",5);
01944 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01945 $tpl->parseCurrentBlock();
01946
01947 $tbl->setTitle($this->lng->txt("pays_header_select_vendor"),"icon_usr.gif",$this->lng->txt("pays_header_select_vendor"));
01948 $tbl->setHeaderNames(array("",
01949 $this->lng->txt("login"),
01950 $this->lng->txt("firstname"),
01951 $this->lng->txt("lastname")));
01952 $tbl->setHeaderVars(array("",
01953 "login",
01954 "firstname",
01955 "lastname"),
01956 array("ref_id" => $this->object->getRefId(),
01957 "cmd" => $a_cmd,
01958 "cmdClass" => "ilobjpaymentsettingsgui",
01959 "cmdNode" => $_GET["cmdNode"]));
01960
01961 $tbl->setColumnWidth(array("3%","32%","32%","32%"));
01962
01963 $this->__setTableGUIBasicData($tbl,$a_result_set);
01964 $tbl->render();
01965
01966 $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
01967
01968 return true;
01969 }
01970
01971 function __showButton($a_cmd,$a_text,$a_target = '')
01972 {
01973 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01974
01975
01976 $this->tpl->setCurrentBlock("btn_cell");
01977 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,$a_cmd));
01978 $this->tpl->setVariable("BTN_TXT",$a_text);
01979 if($a_target)
01980 {
01981 $this->tpl->setVariable("BTN_TARGET",$a_target);
01982 }
01983
01984 $this->tpl->parseCurrentBlock();
01985 }
01986
01987 function &__initTableGUI()
01988 {
01989 include_once "./classes/class.ilTableGUI.php";
01990
01991 return new ilTableGUI(0,false);
01992 }
01993
01994 function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
01995 {
01996 $offset = $_GET["offset"];
01997 $order = $_GET["sort_by"];
01998 $direction = $_GET["sort_order"];
01999
02000 $tbl->setOrderColumn($order);
02001 $tbl->setOrderDirection($direction);
02002 $tbl->setOffset($offset);
02003 $tbl->setLimit($_GET["limit"]);
02004 $tbl->setMaxCount(count($result_set));
02005 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02006 $tbl->setData($result_set);
02007 }
02008
02009 function __search($a_search_string)
02010 {
02011 include_once("./classes/class.ilSearch.php");
02012
02013 $this->lng->loadLanguageModule("content");
02014
02015 $search =& new ilSearch($_SESSION["AccountId"]);
02016 $search->setPerformUpdate(false);
02017 $search->setSearchString(ilUtil::stripSlashes($a_search_string));
02018 $search->setCombination("and");
02019 $search->setSearchFor(array(0 => 'usr'));
02020 $search->setSearchType('new');
02021
02022 if($search->validate($message))
02023 {
02024 $search->performSearch();
02025 }
02026 else
02027 {
02028 sendInfo($message,true);
02029 $this->ctrl->redirect($this,"searchUser");
02030 }
02031 return $search->getResultByType('usr');
02032 }
02033
02034 function __searchSP($a_search_string)
02035 {
02036 include_once("./classes/class.ilSearch.php");
02037
02038 $this->lng->loadLanguageModule("content");
02039
02040 $search =& new ilSearch($this->user_obj->getId());
02041 $search->setPerformUpdate(false);
02042 $search->setSearchString(ilUtil::stripSlashes($a_search_string));
02043 $search->setCombination("and");
02044 $search->setSearchFor(array(0 => 'usr'));
02045 $search->setSearchType('new');
02046
02047 if($search->validate($message))
02048 {
02049 $search->performSearchSPObject();
02050 }
02051 else
02052 {
02053 sendInfo($message,true);
02054 $this->ctrl->redirect($this,"searchUserSP");
02055 }
02056 return $search->getResultByType('usr');
02057 }
02058 function __showSearchUserSPTable($a_result_set)
02059 {
02060 $tbl =& $this->initTableGUI();
02061 $tpl =& $tbl->getTemplateObject();
02062
02063
02064
02065 $tpl->setCurrentBlock("tbl_form_header");
02066 $this->ctrl->setParameter($this, "sell_id", $_GET["sell_id"]);
02067 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
02068 $tpl->parseCurrentBlock();
02069
02070 $tpl->setCurrentBlock("tbl_action_btn");
02071 $tpl->setVariable("BTN_NAME","addCustomer");
02072 $tpl->setVariable("BTN_VALUE",$this->lng->txt("add"));
02073 $tpl->parseCurrentBlock();
02074
02075 $tpl->setCurrentBlock("tbl_action_btn");
02076 $tpl->setVariable("BTN_NAME","statistic");
02077 $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
02078 $tpl->parseCurrentBlock();
02079
02080 $tpl->setCurrentBlock("tbl_action_row");
02081 $tpl->setVariable("COLUMN_COUNTS",5);
02082 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
02083 $tpl->parseCurrentBlock();
02084
02085 $tbl->setTitle($this->lng->txt("users"),"icon_usr.gif",$this->lng->txt("crs_header_edit_members"));
02086 $tbl->setHeaderNames(array("",
02087 $this->lng->txt("login"),
02088 $this->lng->txt("firstname"),
02089 $this->lng->txt("lastname")));
02090 $this->ctrl->setParameter($this, "cmd", "addCustomer");
02091 $header_params = $this->ctrl->getParameterArray($this,'');
02092 $tbl->setHeaderVars(array("",
02093 "login",
02094 "firstname",
02095 "lastname"), $header_params);
02096
02097
02098
02099
02100
02101
02102 $tbl->setColumnWidth(array("3%","32%","32%","32%"));
02103
02104 $this->setTableGUIBasicData($tbl,$a_result_set);
02105 $tbl->render();
02106
02107 $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
02108
02109 return true;
02110 }
02111
02112 function &initTableGUI()
02113 {
02114 include_once "./classes/class.ilTableGUI.php";
02115
02116 return new ilTableGUI(0,false);
02117 }
02118 function setTableGUIBasicData(&$tbl,&$result_set,$a_default_order_column = '')
02119 {
02120 $offset = $_GET["offset"];
02121 $order = $_GET["sort_by"];
02122 $direction = $_GET["sort_order"];
02123
02124 $tbl->setOrderColumn($order,$a_default_order_column);
02125 $tbl->setOrderDirection($direction);
02126 $tbl->setOffset($offset);
02127 $tbl->setLimit($_GET["limit"]);
02128 $tbl->setMaxCount(count($result_set));
02129 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02130 $tbl->setData($result_set);
02131 }
02132 }
02133 ?>