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 editDetails($a_show_confirm = false)
 {
     /** 
      * @var $ilToolbar ilToolbarGUI 
      */
     global $ilToolbar;
     include_once './Services/Payment/classes/class.ilPaymentSettings.php';
     /** @var $genSet ilPaymentSettings */
     $genSet = ilPaymentSettings::_getInstance();
     if (!(int) $_GET['pobject_id']) {
         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
         return $this->showObjects();
     }
     $this->__initPaymentObject((int) $_GET['pobject_id']);
     $this->ctrl->setParameter($this, 'pobject_id', (int) $_GET['pobject_id']);
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     /** @var $tmp_obj ilObject */
     $tmp_obj = ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
     if (is_object($tmp_obj)) {
         $trash = '';
         if (ilObject::_isInTrash($this->pobject->getRefId())) {
             $trash = ' (' . $this->lng->txt('object_deleted') . ')';
         }
         $tmp_object['title'] = $tmp_obj->getTitle() . '' . $trash;
         $tmp_object['type'] = $tmp_obj->getType();
     } else {
         $tmp_object['title'] = $this->lng->txt('object_not_found');
         $tmp_object['type'] = false;
     }
     if ($a_show_confirm) {
         include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
         $oConfirmationGUI = new ilConfirmationGUI();
         // set confirm/cancel commands
         $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, "performDelete"));
         $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_object"));
         $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "editDetails");
         $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDelete");
         $oConfirmationGUI->addItem('', $tmp_object['title'], $tmp_object['title']);
         $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'));
     include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
     $oForm = new ilPropertyFormGUI();
     $oForm->setFormAction($this->ctrl->getFormAction($this, 'updateDetails'));
     $oForm->setTitle($tmp_object['title']);
     if ($tmp_object['type']) {
         $oForm->setTitleIcon(ilUtil::getImagePath('icon_' . $tmp_object['type'] . '_b.png'));
     }
     // repository path
     $oPathGUI = new ilNonEditableValueGUI($this->lng->txt('path'));
     $oPathGUI->setValue($this->__getHTMLPath($this->pobject->getRefId()));
     $oForm->addItem($oPathGUI);
     switch ($tmp_object['type']) {
         case 'exc':
             $exc_subtype_option = array();
             $check_subtypes = ilPaymentObject::_checkExcSubtype($this->pobject->getRefId());
             if (!in_array('download', $check_subtypes) || $this->pobject->getSubtype() == 'download') {
                 $exc_subtype_option['download'] = $this->lng->txt('download');
             }
             if (!in_array('upload', $check_subtypes) || $this->pobject->getSubtype() == 'upload') {
                 $exc_subtype_option['upload'] = $this->lng->txt('upload');
             }
             $oExcSubtype = new ilSelectInputGUI($this->lng->txt('select_subtype'), 'exc_subtype');
             $oExcSubtype->setOptions($exc_subtype_option);
             $oExcSubtype->setValue($this->pobject->getSubtype());
             $oForm->addItem($oExcSubtype);
             break;
         default:
             break;
     }
     // number of purchasers
     $oPurchasersGUI = new ilNonEditableValueGUI($this->lng->txt('paya_count_purchaser'));
     $oPurchasersGUI->setValue(ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']));
     $oForm->addItem($oPurchasersGUI);
     // vendors
     $oVendorsGUI = new ilSelectInputGUI($this->lng->txt('paya_vendor'), 'vendor');
     $oVendorsGUI->setOptions($this->__getVendors());
     $oVendorsGUI->setValue($this->pobject->getVendorId());
     $oForm->addItem($oVendorsGUI);
     // status
     $oStatusGUI = new ilSelectInputGUI($this->lng->txt('status'), 'status');
     $oStatusGUI->setOptions($this->__getStatus());
     $oStatusGUI->setValue($this->pobject->getStatus());
     $oForm->addItem($oStatusGUI);
     // pay methods
     $oPayMethodsGUI = new ilSelectInputGUI($this->lng->txt('paya_pay_method'), 'pay_method');
     $PMoptions = ilPaymethods::getPayMethodsOptions('not_specified');
     $oPayMethodsGUI->setOptions($PMoptions);
     $oPayMethodsGUI->setValue($this->pobject->getPayMethod());
     $oForm->addItem($oPayMethodsGUI);
     // topics
     /** @var $shopTopicsObj ilShopTopics */
     $shopTopicsObj = ilShopTopics::_getInstance();
     $shopTopicsObj->read();
     if (is_array($topics = $shopTopicsObj->getTopics()) && count($topics)) {
         $oTopicsGUI = new ilSelectInputGUI($this->lng->txt('topic'), 'topic_id');
         include_once 'Services/Payment/classes/class.ilShopTopics.php';
         /** @var $shopTopicsObj ilShopTopics */
         $shopTopicsObj = ilShopTopics::_getInstance();
         $shopTopicsObj->read();
         $topic_options = array();
         $topic_options[''] = $this->lng->txt('please_choose');
         /** @var $oTopic ilShopTopic */
         foreach ($topics as $oTopic) {
             $topic_options[$oTopic->getId()] = $oTopic->getTitle();
         }
         $oTopicsGUI->setOptions($topic_options);
         $oTopicsGUI->setValue($this->pobject->getTopicId());
         $oForm->addItem($oTopicsGUI);
     }
     // vats
     $oShopVatsList = new ilShopVatsList();
     $oShopVatsList->read();
     if ($oShopVatsList->hasItems()) {
         $oVatsGUI = new ilSelectInputGUI($this->lng->txt('vat_rate'), 'vat_id');
         $vats_options = array();
         /** @var $oVAT ilShopVats */
         foreach ($oShopVatsList as $oVAT) {
             $vats_options[$oVAT->getId()] = ilShopUtils::_formatVAT($oVAT->getRate()) . ' -> ' . $oVAT->getTitle();
         }
         $oVatsGUI->setOptions($vats_options);
         $oVatsGUI->setValue($this->pobject->getVatId());
         $oForm->addItem($oVatsGUI);
     } else {
         $oVatsGUI = new ilNonEditableValueGUI($this->lng->txt('vat_rate'));
         $oVatsGUI->setValue($this->lng->txt('paya_no_vats_assigned'));
         $oForm->addItem($oVatsGUI);
     }
     $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail');
     $oFile = new ilFileDataShop($this->pobject->getPobjectId());
     if (($webpath_file = $oFile->getCurrentImageWebPath()) !== false) {
         $oThumbnail->setImage($webpath_file);
     }
     $oForm->addItem($oThumbnail);
     if ($genSet->get('use_shop_specials')) {
         // special object
         $oSpecial = new ilCheckboxInputGUI($this->lng->txt('special'), 'is_special');
         $oSpecial->setChecked((int) $this->pobject->getSpecial());
         $oSpecial->setInfo($this->lng->txt('special_info'));
         $oForm->addItem($oSpecial);
     }
     // buttons
     $oForm->addCommandButton('updateDetails', $this->lng->txt('save'));
     $oForm->addCommandButton('deleteObject', $this->lng->txt('delete'));
     $this->tpl->setVariable('FORM', $oForm->getHTML());
     return true;
 }