コード例 #1
0
 public function addCustomerObject()
 {
     global $ilToolbar;
     if ($_POST['sell_id'] != '') {
         $_GET['sell_id'] = $_POST['sell_id'];
     }
     if ($_GET['user_id'] != '') {
         $_POST['user_id'] = $_GET['user_id'];
     }
     if (!isset($_GET['sell_id'])) {
         ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given'));
         $this->showObjectSelectorObject();
         return true;
     }
     if (!isset($_POST['user_id'])) {
         ilUtil::sendInfo($this->lng->txt('paya_no_user_id_given'));
         $this->searchUserSPObject();
         return true;
     }
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     $this->ctrl->setParameter($this, 'sell_id', $_GET['sell_id']);
     $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'searchUserSP'));
     $this->ctrl->setParameter($this, 'user_id', $_POST['user_id']);
     $pObjectId = ilPaymentObject::_lookupPobjectId($_GET['sell_id']);
     $obj = new ilPaymentObject($this->user_obj, $pObjectId);
     // get obj
     $tmp_obj = ilObjectFactory::getInstanceByRefId($_GET['sell_id'], false);
     if ($tmp_obj) {
         $tmp_object['title'] = $tmp_obj->getTitle();
     } else {
         $tmp_object['title'] = $this->lng->txt('object_not_found');
     }
     // get customer_obj
     $tmp_user = ilObjectFactory::getInstanceByObjId($_POST['user_id']);
     // get vendor_obj
     $tmp_vendor = ilObjectFactory::getInstanceByObjId($obj->getVendorId());
     /**/
     $oForm = new ilPropertyFormGUI();
     $oForm->setFormAction($this->ctrl->getFormAction($this, 'saveCustomer'));
     $oForm->setTitle($this->lng->txt($tmp_user->getFullname() . ' [' . $tmp_user->getLogin() . ']'));
     //transaction
     $oTransaction = new ilTextInputGUI();
     $oTransaction->setTitle($this->lng->txt('paya_transaction'));
     //$oTransaction->setValue(ilUtil::prepareFormOutut($_POST['transaction'], true));
     $oTransaction->setValue($_POST['transaction']);
     $oTransaction->setPostVar('transaction');
     $oForm->addItem($oTransaction);
     //object
     $oObject = new ilNonEditableValueGUI($this->lng->txt('title'));
     $oObject->setValue($tmp_obj->getTitle());
     $oForm->addItem($oObject);
     //vendor
     $oVendor = new ilNonEditableValueGUI($this->lng->txt('paya_vendor'));
     $oVendor->setValue($tmp_vendor->getFullname() . ' [' . $tmp_vendor->getLogin() . ']');
     $oForm->addItem($oVendor);
     // pay methods
     $oPayMethods = new ilSelectInputGUI($this->lng->txt('paya_pay_method'), 'pay_method');
     $payOptions = ilPaymethods::getPayMethodsOptions(false);
     $oPayMethods->setOptions($payOptions);
     $oPayMethods->setValue($_POST['pay_method']);
     $oPayMethods->setPostVar('pay_method');
     $oForm->addItem($oPayMethods);
     //duration
     $duration_options = array();
     $price_obj = new ilPaymentPrices($pObjectId);
     $standard_prices = array();
     $extension_prices = array();
     $standard_prices = $price_obj->getPrices();
     $extension_prices = $price_obj->getExtensionPrices();
     $prices = array_merge($standard_prices, $extension_prices);
     if (is_array($prices)) {
         $genSet = ilPaymentSettings::_getInstance();
         $currency_unit = $genSet->get('currency_unit');
         foreach ($prices as $price) {
             switch ($price['price_type']) {
                 case ilPaymentPrices::TYPE_DURATION_MONTH:
                     $txt_duration = $price['duration'] . ' ' . $this->lng->txt('paya_months') . ' -> ' . $price['price'] . ' ' . $currency_unit;
                     break;
                 case ilPaymentPrices::TYPE_DURATION_DATE:
                     include_once './Services/Calendar/classes/class.ilDatePresentation.php';
                     $txt_duration = ilDatePresentation::formatDate(new ilDate($price['duration_from'], IL_CAL_DATE)) . ' - ' . ilDatePresentation::formatDate(new ilDate($price['duration_until'], IL_CAL_DATE)) . " -> " . ilPaymentPrices::_getPriceString($price["price_id"]) . ' ' . $currency_unit;
                     break;
                 case ilPaymentPrices::TYPE_UNLIMITED_DURATION:
                     $txt_duration = $this->lng->txt('unlimited_duration') . ' -> ' . $price['price'] . ' ' . $currency_unit;
                     break;
             }
             $txt_extension = '';
             if ($price['extension'] == 1) {
                 $txt_extension = ' (' . $this->lng->txt('extension_price') . ') ';
             }
             $duration_options[$price['price_id']] .= $txt_duration . '' . $txt_extension;
         }
     }
     $oDuration = new ilSelectInputGUI($this->lng->txt('duration'), 'price_id');
     $oDuration->setOptions($duration_options);
     $oDuration->setValue($_POST['price_id']);
     $oForm->addItem($oDuration);
     //payed
     $o_payed = new ilSelectInputGUI();
     $payed_option = array('1' => $this->lng->txt('yes'), '0' => $this->lng->txt('no'));
     $o_payed->setTitle($this->lng->txt('paya_payed'));
     $o_payed->setOptions($payed_option);
     $o_payed->setValue($_POST['payed']);
     $o_payed->setPostVar('payed');
     $oForm->addItem($o_payed);
     $o_access = new ilSelectInputGUI();
     $access_option = array('1' => $this->lng->txt('yes'), '0' => $this->lng->txt('no'));
     $o_access->setTitle($this->lng->txt('paya_access'));
     $o_access->setOptions($access_option);
     $o_access->setValue($_POST['access']);
     $o_access->setPostVar('access');
     $oForm->addItem($o_access);
     $oForm->addCommandButton('saveCustomer', $this->lng->txt('save'));
     $oForm->addCommandButton('bookings', $this->lng->txt('cancel'));
     $this->tpl->setVariable('FORM', $oForm->getHTML());
     return true;
 }
コード例 #2
0
 public function editPrices($a_show_delete = false)
 {
     /** 
      * @var $ilToolbar ilToolbarGUI
      */
     global $ilToolbar;
     include_once './Services/Payment/classes/class.ilPaymentPrices.php';
     include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
     include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
     include_once './Services/Payment/classes/class.ilPaymentSettings.php';
     /** @var $genSet ilPaymentSettings */
     $genSet = ilPaymentSettings::_getInstance();
     if ($a_show_delete == false) {
         unset($_SESSION['price_ids']);
     }
     $_SESSION['price_ids'] = $_SESSION['price_ids'] ? $_SESSION['price_ids'] : array();
     if (!$_GET['pobject_id'] && !$_POST['pobject_id']) {
         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
         $this->showObjects();
         return true;
     }
     if (isset($_GET['pobject_id'])) {
         $pobject_id = (int) $_GET['pobject_id'];
     } else {
         $pobject_id = (int) $_POST['pobject_id'];
     }
     $this->ctrl->setParameter($this, 'pobject_id', $pobject_id);
     $this->__initPaymentObject((int) $_GET['pobject_id']);
     $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", 'tpl.main_view.html', 'Services/Payment');
     $price_obj = new ilPaymentPrices($pobject_id);
     $standard_prices = array();
     $extension_prices = array();
     $standard_prices = $price_obj->getPrices();
     $extension_prices = $price_obj->getExtensionPrices();
     $prices = array_merge($standard_prices, $extension_prices);
     // No prices created
     if (!count($prices)) {
         ilUtil::sendInfo($this->lng->txt('paya_no_price_available'));
         $ilToolbar->addButton($this->lng->txt('paya_add_price'), $this->ctrl->getLinkTarget($this, 'addPrice'));
         return true;
     } else {
         if (!count($standard_prices)) {
             //set pobject status to "not buyable" if there is no standard_price defined
             $this->pobject->setStatus(0);
             $this->pobject->update();
             ilUtil::sendInfo($this->lng->txt('paya_no_price_available'));
         }
     }
     // Show confirm delete
     if ($a_show_delete) {
         $oConfirmationGUI = new ilConfirmationGUI();
         // set confirm/cancel commands
         $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, "performDeletePrice"));
         $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_selected_prices"));
         $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "editPrices");
         $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDeletePrice");
         $counter = 0;
         foreach ($prices as $price) {
             $currency = $genSet->get('currency_unit');
             if (in_array($price['price_id'], $_SESSION['price_ids'])) {
                 if ($price['unlimited_duration'] == '1') {
                     $tmp_price = $this->lng->txt('unlimited_duration');
                 } else {
                     $tmp_price = $price['duration'] . ' ' . $this->lng->txt('paya_months');
                 }
                 $delete_row = '' . $tmp_price . '  :  ' . ilFormat::_getLocalMoneyFormat($price['price']) . ' ' . $currency;
                 $oConfirmationGUI->addItem('', $delete_row, $delete_row);
                 $delete_row = '';
             }
             $counter++;
         }
         $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHTML());
         return true;
     }
     $ilToolbar->addButton($this->lng->txt('paya_edit_details'), $this->ctrl->getLinkTarget($this, 'editDetails'));
     $ilToolbar->addButton($this->lng->txt('paya_edit_prices'), $this->ctrl->getLinkTarget($this, 'editPrices'));
     $ilToolbar->addButton($this->lng->txt('pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'edit'));
     // Fill table cells
     /** @var $tpl ilTemplate */
     $tpl = new ilTemplate('tpl.table.html', true, true);
     // set table header
     $tpl->setCurrentBlock('tbl_form_header');
     $tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this));
     $tpl->parseCurrentBlock();
     $counter = 0;
     include_once './Services/Calendar/classes/class.ilDatePresentation.php';
     foreach ($prices as $price) {
         $data[$counter]['price_id'] = ilUtil::formCheckBox(in_array($price['price_id'], $_SESSION['price_ids']) ? 1 : 0, 'price_ids[]', $price['price_id']);
         switch ($price['price_type']) {
             case ilPaymentPrices::TYPE_DURATION_MONTH:
                 $data[$counter]['duration'] = $price['duration'] . ' ' . $this->lng->txt('paya_months');
                 break;
             case ilPaymentPrices::TYPE_DURATION_DATE:
                 $data[$counter]['duration'] = ilDatePresentation::formatDate(new ilDate($price['duration_from'], IL_CAL_DATE)) . ' - ' . ilDatePresentation::formatDate(new ilDate($price['duration_until'], IL_CAL_DATE));
                 break;
             case ilPaymentPrices::TYPE_UNLIMITED_DURATION:
                 $data[$counter]['duration'] = $this->lng->txt('unlimited_duration');
                 break;
         }
         $data[$counter]['price'] = ilFormat::_getLocalMoneyFormat($price['price']);
         $data[$counter]['currency_unit'] = $genSet->get('currency_unit');
         $data[$counter]['extension'] = ilUtil::formCheckBox($price['extension'] ? 1 : 0, 'extension_ids[]', (int) $price['price_id'], true);
         $this->ctrl->setParameter($this, "price_id", $price['price_id']);
         $data[$counter]['edit'] = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"" . $this->ctrl->getLinkTarget($this, "editPrice") . "\">" . $this->lng->txt("edit") . "</a></div>";
         ++$counter;
     }
     $this->__editPricesTable($data);
     return true;
 }