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;
 }
 public function updateDetails()
 {
     if (!$_GET['pobject_id']) {
         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
         $this->showObjects();
         return true;
     }
     $this->__initPaymentObject((int) $_GET['pobject_id']);
     $this->ctrl->setParameter($this, 'pobject_id', (int) $_GET['pobject_id']);
     // read old settings
     $old_status = $this->pobject->getStatus();
     // check status changed from not_buyable
     if ($old_status == $this->pobject->STATUS_NOT_BUYABLE and (int) $_POST['status'] != $old_status) {
         // check pay_method edited
         switch ((int) $_POST['pay_method']) {
             case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
                 ilUtil::sendInfo($this->lng->txt('paya_select_pay_method_first'));
                 $this->editDetails();
                 return false;
             default:
         }
         // check minimum one price
         include_once './Services/Payment/classes/class.ilPaymentPrices.php';
         $prices_obj = new ilPaymentPrices((int) $_GET['pobject_id']);
         if (!count($prices_obj->getPrices())) {
             ilUtil::sendInfo($this->lng->txt('paya_edit_prices_first'));
             $this->editDetails();
             return false;
         }
     }
     if ((int) $_POST['status'] == 0) {
         // Status: not buyable -> delete depending shoppingcart entries
         include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
         ilPaymentShoppingCart::_deleteShoppingCartEntries($this->pobject->getPobjectId());
     }
     $this->pobject->setStatus((int) $_POST['status']);
     $this->pobject->setVendorId((int) $_POST['vendor']);
     $this->pobject->setPayMethod((int) $_POST['pay_method']);
     $this->pobject->setTopicId((int) $_POST['topic_id']);
     $this->pobject->setVatId((int) $_POST['vat_id']);
     $this->pobject->setSubtype((string) $_POST['exc_subtype']);
     $this->pobject->setSpecial((int) $_POST['is_special']);
     if ((int) $_POST['thumbnail_delete']) {
         $oFile = new ilFileDataShop($this->pobject->getPobjectId());
         $oFile->deassignFileFromPaymentObject();
     } else {
         if ($_FILES['thumbnail']['tmp_name'] != '') {
             $this->lng->loadLanguageModule('form');
             include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
             $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail');
             if ($oThumbnail->checkInput()) {
                 $oFile = new ilFileDataShop($this->pobject->getPobjectId());
                 if ($oFile->storeUploadedFile($_FILES['thumbnail']) !== false) {
                     $oFile->assignFileToPaymentObject();
                 }
             } else {
                 ilUtil::sendInfo($oThumbnail->getAlert());
                 return $this->editDetails();
             }
         }
     }
     $this->pobject->update();
     ilUtil::sendInfo($this->lng->txt('paya_details_updated'));
     $this->showObjects();
     return true;
 }