public function __construct($user_obj, $a_pobject_id = null) { global $ilDB; $this->db = $ilDB; $this->user_obj = $user_obj; $this->STATUS_NOT_BUYABLE = 0; $this->STATUS_BUYABLE = 1; $this->STATUS_EXPIRES = 2; $this->PAY_METHOD_NOT_SPECIFIED = 0; $this->pobject_id = $a_pobject_id; include_once './Services/Payment/classes/class.ilPayMethods.php'; $pmObj = new ilPayMethods(); $tmp = $pmObj->readAll(); foreach ($tmp as $pm) { $tmp = strtoupper($pm['pm_title']); $this->PAY_METHOD_ . ($tmp = $pm['pm_id']); } $this->__read(); }
public function savePayMethodsObject() { include_once './Services/Payment/classes/class.ilPayMethods.php'; global $rbacsystem; if (!$rbacsystem->checkAccess('read', $this->object->getRefId())) { $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilErr->MESSAGE); } $obj_paymethods = new ilPayMethods(); $paymethods = $obj_paymethods->readAll(); $askForDeletingAddresses = array(); $pm_enabled = (array) $_POST['pm_enabled']; $pm_addr = (array) $_POST['save_usr_adr']; if (!$pm_enabled) { ilUtil::sendInfo($this->lng->txt('shop_disabled_no_paymethods')); $this->genSetData->set('shop_enabled', 0, 'common'); $_SESSION['disable_shop'] = false; } $info_msg = array(); foreach ($paymethods as $paymethod) { if ((!isset($pm_enabled[$paymethod['pm_id']]) || !$pm_enabled[$paymethod['pm_id']]) && $paymethod['pm_enabled']) { if (ilPaymentObject::_getCountObjectsByPayMethod($paymethod['pm_id'])) { $info_msg[] = $this->lng->txt('pays_objects_' . $paymethod['pm_title'] . '_exist'); } } } if ($info_msg) { ilUtil::sendInfo(implode('<br />', $info_msg)); $this->payMethodsObject(); return; } $num_changed = 0; foreach ($paymethods as $paymethod) { if ((!isset($pm_enabled[$paymethod['pm_id']]) || !$pm_enabled[$paymethod['pm_id']]) && $paymethod['pm_enabled']) { ilPayMethods::_PMdisable($paymethod['pm_id']); ++$num_changed; } else { if (isset($pm_enabled[$paymethod['pm_id']]) && $pm_enabled[$paymethod['pm_id']] && !$paymethod['pm_enabled']) { ilPayMethods::_PMenable($paymethod['pm_id']); ++$num_changed; } } if ((!isset($pm_addr[$paymethod['pm_id']]) || !$pm_addr[$paymethod['pm_id']]) && $paymethod['save_usr_adr']) { $askForDeletingAddresses[] = $paymethod['pm_id']; } else { if ((!isset($pm_addr[$paymethod['pm_id']]) || !$pm_addr[$paymethod['pm_id']]) && !$paymethod['save_usr_adr']) { continue; } else { ilPayMethods::_enableSaveUserAddress($paymethod['pm_id']); ++$num_changed; } } } if ($num_changed && !$askForDeletingAddresses) { ilUtil::sendSuccess($this->lng->txt('pays_updated_pay_method')); } $this->payMethodsObject($askForDeletingAddresses); return true; }
private function _getPayMethods($limitToEnabled = false) { $objPM = new ilPayMethods(); $get_paymethods = $objPM->readAll(); if (!$limitToEnabled) { foreach ($get_paymethods as $pm) { $pay_methods[$pm['pm_id']]['pm_title'] = $pm['pm_title']; $pay_methods[$pm['pm_id']]['pm_id'] = $pm['pm_id']; $pay_methods[$pm['pm_id']]['pm_enabled'] = $pm['pm_enabled']; $pay_methods[$pm['pm_id']]['save_usr_adr'] = $pm['save_usr_adr']; } } else { foreach ($get_paymethods as $pm) { if ($pm['pm_enabled'] == 1) { $pay_methods[$pm['pm_id']]['pm_title'] = $pm['pm_title']; $pay_methods[$pm['pm_id']]['pm_id'] = $pm['pm_id']; $pay_methods[$pm['pm_id']]['pm_enabled'] = $pm['pm_enabled']; $pay_methods[$pm['pm_id']]['save_usr_adr'] = $pm['save_usr_adr']; } } } return $pay_methods; }
public function payMethodsObject($askForDeletingAddresses = array(), $oConfirmationGUI = '') { include_once './Services/Payment/classes/class.ilPayMethods.php'; global $rbacsystem, $ilCtrl; $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment'); // MINIMUM ACCESS LEVEL = 'read' if (!$rbacsystem->checkAccess('read', $this->object->getRefId())) { $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilErr->MESSAGE); } if (count($askForDeletingAddresses)) { $oConfirmationGUI = new ilConfirmationGUI(); // set confirm/cancel commands $oConfirmationGUI->setFormAction($ilCtrl->getFormAction($this, "deleteAddressesForPaymethods")); $oConfirmationGUI->setHeaderText($this->lng->txt("info_delete_sure")); $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "paymethods"); $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "deleteAddressesForPaymethods"); foreach ($askForDeletingAddresses as $pm_id) { $pm_obj = new ilPayMethods($pm_id); $oConfirmationGUI->additem('paymethod[' . $pm_obj->getPmId() . ']', $pm_obj->getPmId(), $this->lng->txt('delete_addresses_bill') . ' -> ' . ilPayMethods::getStringByPaymethod($pm_obj->getPmTitle())); } $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHtml()); return true; } $obj_paymethods = new ilPayMethods(); $paymethods = $obj_paymethods->readAll(); $result = array(); $counter = 0; foreach ($paymethods as $paymethod) { if ($paymethod['pm_title'] != 'epay') { $result[$counter]['pm_title'] = ilPayMethods::getStringByPaymethod($paymethod['pm_title']); $result[$counter]['pm_enabled'] = ilUtil::formCheckbox($paymethod['pm_enabled'] ? 1 : 0, 'pm_enabled[' . $paymethod['pm_id'] . ']', 1); $result[$counter]['save_usr_adr'] = ilUtil::formCheckbox($paymethod['save_usr_adr'] ? 1 : 0, 'save_usr_adr[' . $paymethod['pm_id'] . ']', 1); $this->ctrl->clearParameters($this); $counter++; } } $counter = 0; $this->ctrl->setParameter($this, 'cmd', 'savePayMethods'); $tbl = new ilShopTableGUI($this); $tbl->setTitle($this->lng->txt('pays_pay_methods')); $tbl->setId('tbl_paymethods'); $tbl->setRowTemplate("tpl.shop_paymethods_row.html", "Services/Payment"); $tbl->addColumn($this->lng->txt('title'), 'pm_title', '10%'); $tbl->addColumn($this->lng->txt('enabled'), 'pm_enabled', '10%'); $tbl->addColumn($this->lng->txt('save_customer_address'), 'save_usr_adr', '10%'); $tbl->addCommandButton('savePayMethods', $this->lng->txt('save')); $tbl->disable('sort'); $tbl->setData($result); $this->tpl->setVariable('TABLE', $tbl->getHTML()); return true; }