4 include_once 
'Services/Payment/classes/class.ilPaymentObject.php';
 
    5 include_once 
'Services/Payment/classes/class.ilPaymentBookings.php';
 
    6 include_once 
'Services/Payment/classes/class.ilFileDataShop.php';
 
    7 include_once 
'Services/Payment/classes/class.ilShopVatsList.php';
 
    8 include_once 
'./Services/Payment/classes/class.ilShopTableGUI.php';
 
   36                 $this->lng->loadLanguageModule(
'crs');
 
   51                 $ilTabs->setTabActive(
'paya_header');
 
   52                 $ilTabs->setSubTabActive(
'paya_object');
 
   57                 $cmd = $this->ctrl->getCmd();
 
   58                 switch($this->ctrl->getNextClass($this))
 
   60                         case 'ilpageobjectgui':
 
   62                                 $ret = $this->forwardToPageObject();
 
   65                                         $this->tpl->setContent(
$ret);
 
   80         public function forwardToPageObject()
 
   87                 if(!(
int)
$_GET[
'pobject_id'])
 
   90                         return $this->showObjects();
 
   92                 $this->ctrl->setParameter($this, 
'pobject_id', (
int)$_GET[
'pobject_id']);
 
   95                 $this->lng->loadLanguageModule(
'content');
 
   97                 $ilTabs->clearTargets();
 
   98                 $ilTabs->clearSubTabs();
 
   99                 $ilTabs->setBackTarget($this->lng->txt(
'back'), $this->ctrl->getLinkTarget($this, 
'editDetails'), 
'_top');
 
  102                 include_once 
'Services/COPage/classes/class.ilPageObject.php';
 
  103                 include_once 
'Services/COPage/classes/class.ilPageObjectGUI.php';
 
  104                 include_once(
'./Services/Style/classes/class.ilObjStyleSheet.php');
 
  112                         $new_page_object->setParentId(0);
 
  113                         $new_page_object->setId($this->pobject->getPobjectId());
 
  114                         $new_page_object->createFromXML();
 
  117                 $this->ctrl->setReturnByClass(
'ilpageobjectgui', 
'edit');
 
  119                 $page_gui = 
new ilPageObjectGUI(
'shop', $this->pobject->getPobjectId());
 
  120                 $this->ctrl->setParameter($page_gui, 
'pobject_id', (
int)$_GET[
'pobject_id']);
 
  122                 $page_gui->setTemplateTargetVar(
'ADM_CONTENT');
 
  123                 $page_gui->setLinkXML(
'');
 
  124                 $page_gui->setFileDownloadLink($this->ctrl->getLinkTargetByClass(array(
'ilpageobjectgui'), 
'downloadFile'));
 
  125                 $page_gui->setFullscreenLink($this->ctrl->getLinkTargetByClass(array(
'ilpageobjectgui'), 
'displayMediaFullscreen'));
 
  126                 $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTargetByClass(array(
'ilpageobjectgui'), 
'download_paragraph'));
 
  127                 $page_gui->setPresentationTitle(
'');
 
  128                 $page_gui->setTemplateOutput(
false);
 
  129                 $page_gui->setHeader(
'');
 
  130                 $page_gui->setEnabledRepositoryObjects(
false);
 
  131                 $page_gui->setEnabledFileLists(
true);
 
  132                 $page_gui->setEnabledMaps(
true);
 
  133                 $page_gui->setEnabledPCTabs(
true);
 
  135                 return $this->ctrl->forwardCommand($page_gui);
 
  141                 unset(
$_POST[
'title_type']);
 
  142                 unset(
$_POST[
'title_value']);
 
  144                 unset(
$_POST[
'pay_method']);
 
  145                 unset(
$_POST[
'updateView']);
 
  146                 unset(
$_POST[
'show_filter']);
 
  150                 return $this->showObjects();
 
  153         public function showObjects()
 
  159                 include_once 
'./Services/Payment/classes/class.ilPayMethods.php';
 
  161                 $ilToolbar->addButton($this->lng->txt(
'paya_sell_object'), $this->ctrl->getLinkTarget($this, 
'showObjectSelector'));
 
  163                 if(!
$_POST[
'show_filter'] && 
$_POST[
'updateView'] == 
'1')
 
  168                         if(
$_POST[
'updateView'] == 1)
 
  178                 $this->tpl->addBlockfile(
'ADM_CONTENT', 
'adm_content', 
'tpl.main_view.html', 
'Services/Payment');
 
  181                 $this->lng->loadLanguageModule(
'search');
 
  184                 $filter_form->setFormAction($this->ctrl->getFormAction($this));
 
  185                 $filter_form->setTitle($this->lng->txt(
'pay_filter'));
 
  186                 $filter_form->setId(
'filter_form');
 
  187                 $filter_form->setTableWidth(
'100 %');
 
  190                 $o_hide_check = 
new ilCheckBoxInputGUI($this->lng->txt(
'show_filter'), 
'show_filter');
 
  191                 $o_hide_check->setValue(1);
 
  192                 $o_hide_check->setChecked(
$_SESSION[
'pay_objects'][
'show_filter'] ? 1 : 0);
 
  195                 $o_hidden->setValue(1);
 
  196                 $o_hidden->setPostVar(
'updateView');
 
  197                 $o_hide_check->addSubItem($o_hidden);
 
  201                 $radio_option = 
new ilRadioOption($this->lng->txt(
'search_any_word'), 
'or');
 
  202                 $radio_group->addOption($radio_option);
 
  203                 $radio_option = 
new ilRadioOption($this->lng->txt(
'search_all_words'), 
'and');
 
  204                 $radio_group->addOption($radio_option);
 
  206                 $radio_group->setRequired(
false);
 
  208                 $radio_group->setPostVar(
'title_type');
 
  211                 $o_title->setValue(
$_SESSION[
'pay_objects'][
'title_value']);
 
  212                 $o_title->setPostVar(
'title_value');
 
  213                 $o_title->setTitle($this->lng->txt(
'title'));
 
  215                 $o_hide_check->addSubItem($radio_group);
 
  216                 $o_hide_check->addSubItem($o_title);
 
  220                 $o_vendor->setTitle($this->lng->txt(
'paya_vendor'));
 
  221                 $o_vendor->setValue(
$_SESSION[
'pay_objects'][
'vendor']);
 
  222                 $o_vendor->setPostVar(
'vendor');
 
  223                 $o_hide_check->addSubItem($o_vendor);
 
  227                 $o_paymethod->setTitle($this->lng->txt(
'payment_system'));
 
  228                 $o_paymethod->setOptions(ilPaymethods::getPayMethodsOptions(
'all'));
 
  229                 $o_paymethod->setValue(
$_SESSION[
'pay_objects'][
'pay_method']);
 
  230                 $o_paymethod->setPostVar(
'pay_method');
 
  231                 $o_hide_check->addSubItem($o_paymethod);
 
  233                 $filter_form->addCommandButton(
'showObjects', $this->lng->txt(
'pay_update_view'));
 
  234                 $filter_form->addCommandButton(
'resetObjectFilter', $this->lng->txt(
'pay_reset_filter'));
 
  236                 $filter_form->addItem($o_hide_check);
 
  243                 $this->tpl->setVariable(
'FORM', $filter_form->getHTML());
 
  246                 foreach($objects as 
$data)
 
  252                                 $f_result[$counter][
'title'] = $tmp_obj->getTitle();
 
  256                                 $f_result[$counter][
'title'] = $this->lng->txt(
'object_not_found');
 
  260                         switch($data[
'status'])
 
  262                                 case $this->pobject->STATUS_BUYABLE:
 
  263                                         $f_result[$counter][
'status'] = $this->lng->txt(
'paya_buyable');
 
  266                                 case $this->pobject->STATUS_NOT_BUYABLE:
 
  267                                         $f_result[$counter][
'status'] = $this->lng->txt(
'paya_not_buyable');
 
  270                                 case $this->pobject->STATUS_EXPIRES:
 
  271                                         $f_result[$counter][
'status'] = $this->lng->txt(
'paya_expires');
 
  275                         $f_result[$counter][
'pay_method'] = $str_paymethod;
 
  277                         if($data[
'vat_id'] <= 0)
 
  279                                 $vat_rate = $this->lng->txt(
'payment_vat_has_to_be_defined_by_administration_short');
 
  290                                         $vat_rate = $this->lng->txt(
'payment_vat_has_to_be_defined_by_administration_short');
 
  293                         $f_result[$counter][
'vat_rate'] = $vat_rate;
 
  297                         $f_result[$counter][
'vendor'] = $tmp_user->getFullname() . 
' [' . $tmp_user->getLogin() . 
']';
 
  303                         $this->ctrl->setParameter($this, 
'pobject_id', $data[
'pobject_id']);
 
  304                         $link_change = 
"<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"" . $this->ctrl->getLinkTarget($this, 
"editDetails") . 
"\">" . $this->lng->txt(
"edit") . 
"</a></div>";
 
  306                         $f_result[$counter][
'options'] = $link_change;
 
  316         public function editDetails($a_show_confirm = 
false)
 
  323                 include_once 
'./Services/Payment/classes/class.ilPaymentSettings.php';
 
  327                 if(!(
int)$_GET[
'pobject_id'])
 
  330                         return $this->showObjects();
 
  335                 $this->ctrl->setParameter($this, 
'pobject_id', (
int)$_GET[
'pobject_id']);
 
  337                 $this->tpl->addBlockFile(
'ADM_CONTENT', 
'adm_content', 
'tpl.main_view.html', 
'Services/Payment');
 
  340                 if(is_object($tmp_obj))
 
  345                                 $trash = 
' (' . $this->lng->txt(
'object_deleted') . 
')';
 
  347                         $tmp_object[
'title'] = $tmp_obj->getTitle() . 
'' . $trash;
 
  348                         $tmp_object[
'type']  = $tmp_obj->getType();
 
  352                         $tmp_object[
'title'] = $this->lng->txt(
'object_not_found');
 
  353                         $tmp_object[
'type']  = 
false;
 
  358                         include_once 
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
 
  362                         $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, 
"performDelete"));
 
  363                         $oConfirmationGUI->setHeaderText($this->lng->txt(
"paya_sure_delete_object"));
 
  364                         $oConfirmationGUI->setCancel($this->lng->txt(
"cancel"), 
"editDetails");
 
  365                         $oConfirmationGUI->setConfirm($this->lng->txt(
"confirm"), 
"performDelete");
 
  367                         $oConfirmationGUI->addItem(
'', $tmp_object[
'title'], $tmp_object[
'title']);
 
  368                         $this->tpl->setVariable(
'CONFIRMATION', $oConfirmationGUI->getHTML());
 
  373                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_details'), $this->ctrl->getLinkTarget($this, 
'editDetails'));
 
  374                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_prices'), $this->ctrl->getLinkTarget($this, 
'editPrices'));
 
  375                 $ilToolbar->addButton($this->lng->txt(
'pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array(
'ilpageobjectgui'), 
'edit'));
 
  377                 include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
  379                 $oForm->setFormAction($this->ctrl->getFormAction($this, 
'updateDetails'));
 
  380                 $oForm->setTitle($tmp_object[
'title']);
 
  381                 if($tmp_object[
'type'])
 
  386                 $oPathGUI->
setValue($this->__getHTMLPath($this->pobject->getRefId()));
 
  387                 $oForm->addItem($oPathGUI);
 
  389                 switch($tmp_object[
'type'])
 
  392                                 $exc_subtype_option = array();
 
  395                                 if(!in_array(
'download', $check_subtypes) || $this->pobject->getSubtype() == 
'download')
 
  396                                         $exc_subtype_option[
'download'] = $this->lng->txt(
'download');
 
  397                                 if(!in_array(
'upload', $check_subtypes) || $this->pobject->getSubtype() == 
'upload')
 
  398                                         $exc_subtype_option[
'upload'] = $this->lng->txt(
'upload');
 
  400                                 $oExcSubtype = 
new ilSelectInputGUI($this->lng->txt(
'select_subtype'), 
'exc_subtype');
 
  401                                 $oExcSubtype->
setOptions($exc_subtype_option);
 
  402                                 $oExcSubtype->setValue($this->pobject->getSubtype());
 
  403                                 $oForm->addItem($oExcSubtype);
 
  412                 $oForm->addItem($oPurchasersGUI);
 
  415                 $oVendorsGUI = 
new ilSelectInputGUI($this->lng->txt(
'paya_vendor'), 
'vendor');
 
  416                 $oVendorsGUI->
setOptions($this->__getVendors());
 
  417                 $oVendorsGUI->setValue($this->pobject->getVendorId());
 
  418                 $oForm->addItem($oVendorsGUI);
 
  423                 $oStatusGUI->setValue($this->pobject->getStatus());
 
  424                 $oForm->addItem($oStatusGUI);
 
  427                 $oPayMethodsGUI = 
new ilSelectInputGUI($this->lng->txt(
'paya_pay_method'), 
'pay_method');
 
  428                 $PMoptions      = ilPaymethods::getPayMethodsOptions(
'not_specified');
 
  429                 $oPayMethodsGUI->setOptions($PMoptions);
 
  430                 $oPayMethodsGUI->setValue($this->pobject->getPayMethod());
 
  431                 $oForm->addItem($oPayMethodsGUI);
 
  436                 $shopTopicsObj->read();
 
  437                 if(is_array($topics = $shopTopicsObj->getTopics()) && count($topics))
 
  440                         include_once 
'Services/Payment/classes/class.ilShopTopics.php';
 
  443                         $shopTopicsObj->read();
 
  444                         $topic_options     = array();
 
  445                         $topic_options[
''] = $this->lng->txt(
'please_choose');
 
  448                         foreach($topics as $oTopic)
 
  450                                 $topic_options[$oTopic->getId()] = $oTopic->getTitle();
 
  453                         $oTopicsGUI->setOptions($topic_options);
 
  454                         $oTopicsGUI->setValue($this->pobject->getTopicId());
 
  455                         $oForm->addItem($oTopicsGUI);
 
  460                 $oShopVatsList->read();
 
  461                 if($oShopVatsList->hasItems())
 
  465                         $vats_options = array();
 
  467                         foreach($oShopVatsList as $oVAT)
 
  472                         $oVatsGUI->setOptions($vats_options);
 
  473                         $oVatsGUI->setValue($this->pobject->getVatId());
 
  474                         $oForm->addItem($oVatsGUI);
 
  479                         $oVatsGUI->
setValue($this->lng->txt(
'paya_no_vats_assigned'));
 
  480                         $oForm->addItem($oVatsGUI);
 
  485                 if(($webpath_file = $oFile->getCurrentImageWebPath()) !== 
false)
 
  487                         $oThumbnail->setImage($webpath_file);
 
  489                 $oForm->addItem($oThumbnail);
 
  491                 if($genSet->get(
'use_shop_specials'))
 
  495                         $oSpecial->
setChecked((
int)$this->pobject->getSpecial());
 
  496                         $oSpecial->setInfo($this->lng->txt(
'special_info'));
 
  497                         $oForm->addItem($oSpecial);
 
  500                 $oForm->addCommandButton(
'updateDetails', $this->lng->txt(
'save'));
 
  501                 $oForm->addCommandButton(
'deleteObject', $this->lng->txt(
'delete'));
 
  503                 $this->tpl->setVariable(
'FORM', $oForm->getHTML());
 
  509                 include_once 
'./Services/Payment/classes/class.ilPaymentBookings.php';
 
  511                 if(!$_GET[
'pobject_id'])
 
  515                         $this->showObjects();
 
  521                         $this->editDetails();
 
  528                         $this->editDetails(
true);
 
  536                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
  538                 if(!$_GET[
'pobject_id'])
 
  542                         $this->showObjects();
 
  548                 $this->pobject->delete();
 
  552                 $price_obj->deleteAllPrices();
 
  557                 $this->showObjects();
 
  566                 switch($this->pobject->getPayMethod())
 
  568                         case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
 
  570                                 $this->editDetails();
 
  575                                 $this->editDetails();
 
  580         public function editPrices($a_show_delete = 
false)
 
  587                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
  588                 include_once 
'./Services/Payment/classes/class.ilPaymentCurrency.php';
 
  589                 include_once 
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
 
  590                 include_once 
'./Services/Payment/classes/class.ilPaymentSettings.php';
 
  594                 if($a_show_delete == 
false) unset(
$_SESSION[
'price_ids']);
 
  598                 if(!$_GET[
'pobject_id'] && !
$_POST[
'pobject_id'])
 
  602                         $this->showObjects();
 
  606                 if(isset($_GET[
'pobject_id']))
 
  608                         $pobject_id = (int)$_GET[
'pobject_id'];
 
  612                         $pobject_id = (int)
$_POST[
'pobject_id'];
 
  615                 $this->ctrl->setParameter($this, 
'pobject_id', $pobject_id);
 
  618                 $this->tpl->addBlockfile(
"ADM_CONTENT", 
"adm_content", 
'tpl.main_view.html', 
'Services/Payment');
 
  622                 $standard_prices  = array();
 
  623                 $extension_prices = array();
 
  624                 $standard_prices  = $price_obj->getPrices();
 
  625                 $extension_prices = $price_obj->getExtensionPrices();
 
  627                 $prices = array_merge($standard_prices, $extension_prices);
 
  633                         $ilToolbar->addButton($this->lng->txt(
'paya_add_price'), $this->ctrl->getLinkTarget($this, 
'addPrice'));
 
  637                 else if(!count($standard_prices))
 
  640                         $this->pobject->setStatus(0);
 
  641                         $this->pobject->update();
 
  651                         $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, 
"performDeletePrice"));
 
  652                         $oConfirmationGUI->setHeaderText($this->lng->txt(
"paya_sure_delete_selected_prices"));
 
  653                         $oConfirmationGUI->setCancel($this->lng->txt(
"cancel"), 
"editPrices");
 
  654                         $oConfirmationGUI->setConfirm($this->lng->txt(
"confirm"), 
"performDeletePrice");
 
  658                         foreach($prices as $price)
 
  660                                 $currency = $genSet->get(
'currency_unit');
 
  661                                 if(in_array($price[
'price_id'], 
$_SESSION[
'price_ids']))
 
  664                                         if($price[
'unlimited_duration'] == 
'1')
 
  666                                                 $tmp_price = $this->lng->txt(
'unlimited_duration');
 
  670                                                 $tmp_price = $price[
'duration'] . 
' ' . $this->lng->txt(
'paya_months');
 
  672                                         $delete_row = 
'' . $tmp_price . 
'  :  ' .
 
  676                                         $oConfirmationGUI->addItem(
'', $delete_row, $delete_row);
 
  682                         $this->tpl->setVariable(
'CONFIRMATION', $oConfirmationGUI->getHTML());
 
  687                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_details'), $this->ctrl->getLinkTarget($this, 
'editDetails'));
 
  688                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_prices'), $this->ctrl->getLinkTarget($this, 
'editPrices'));
 
  689                 $ilToolbar->addButton($this->lng->txt(
'pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array(
'ilpageobjectgui'), 
'edit'));
 
  696                 $tpl->setCurrentBlock(
'tbl_form_header');
 
  698                 $tpl->setVariable(
'FORMACTION', $this->ctrl->getFormAction($this));
 
  699                 $tpl->parseCurrentBlock();
 
  702                 include_once 
'./Services/Calendar/classes/class.ilDatePresentation.php';
 
  703                 foreach($prices as $price)
 
  705                         $data[$counter][
'price_id'] = ilUtil::formCheckBox(in_array($price[
'price_id'], 
$_SESSION[
'price_ids']) ? 1 : 0,
 
  706                                 'price_ids[]', $price[
'price_id']);
 
  708                         switch($price[
'price_type'])
 
  711                                         $data[$counter][
'duration'] = $price[
'duration'] . 
' ' . $this->lng->txt(
'paya_months');
 
  719                                         $data[$counter][
'duration'] = $this->lng->txt(
'unlimited_duration');
 
  723                         $data[$counter][
'currency_unit'] = $genSet->get(
'currency_unit');
 
  724                         $data[$counter][
'extension']     = ilUtil::formCheckBox($price[
'extension'] ? 1 : 0,
 
  725                                 'extension_ids[]', (
int)$price[
'price_id'], 
true);
 
  727                         $this->ctrl->setParameter($this, 
"price_id", $price[
'price_id']);
 
  728                         $data[$counter][
'edit'] =
 
  729                                 "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"" . $this->ctrl->getLinkTarget($this, 
"editPrice") . 
"\">" . $this->lng->txt(
"edit") . 
"</a></div>";
 
  733                 $this->__editPricesTable($data);
 
  738         private function __editPricesTable($a_result_set)
 
  746                         $tbl->setTitle($tmp_obj->getTitle());
 
  750                         $tbl->setTitle($this->lng->txt(
'object_not_found'));
 
  753                 $tbl->setId(
'tbl_bookings');
 
  754                 $tbl->setRowTemplate(
"tpl.shop_prices_row.html", 
"Services/Payment");
 
  756                 $tbl->addColumn(
' ', 
'price_id', 
'5%');
 
  757                 $tbl->addColumn($this->lng->txt(
'duration'), 
'duration', 
'40%');
 
  758                 $tbl->addColumn($this->lng->txt(
'price_a'), 
'price', 
'1%');
 
  759                 $tbl->addColumn($this->lng->txt(
'currency'), 
'currency_unit', 
'10%');
 
  760                 $tbl->addColumn($this->lng->txt(
'extension_price'), 
'extension', 
'10%');
 
  761                 $tbl->addColumn(
'', 
'edit', 
'30%');
 
  763                 $tbl->setSelectAllCheckbox(
'price_id');
 
  764                 $tbl->addCommandButton(
'addPrice', $this->lng->txt(
'paya_add_price'));
 
  766                 $tbl->addMultiCommand(
"deletePrice", $this->lng->txt(
"paya_delete_price"));
 
  769                 $tbl->setData($a_result_set);
 
  771                 $this->tpl->setVariable(
'TABLE', $tbl->getHTML());
 
  776         public function addPrice()
 
  783                 if(!$_GET[
'pobject_id'])
 
  787                         $this->showObjects();
 
  791                 include_once 
'./Services/Payment/classes/class.ilPaymentSettings.php';
 
  795                 $this->ctrl->setParameter($this, 
'pobject_id', (
int)$_GET[
'pobject_id']);
 
  799                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_details'), $this->ctrl->getLinkTarget($this, 
'editDetails'));
 
  800                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_prices'), $this->ctrl->getLinkTarget($this, 
'editPrices'));
 
  802                 $this->tpl->addBlockfile(
'ADM_CONTENT', 
'adm_content', 
'tpl.main_view.html', 
'Services/Payment');
 
  805                 $form->setFormAction($this->ctrl->getFormAction($this));
 
  806                 $form->setTitle($this->lng->txt(
'paya_add_price_title'));
 
  812                 if(is_object($tmp_obj))
 
  814                         $oTitle->setValue($tmp_obj->
getTitle());
 
  818                         $oTitle->setValue($this->lng->txt(
'object_not_found'));
 
  820                 $form->addItem($oTitle);
 
  825                 $radio_group->setTitle($this->lng->txt(
'duration'));
 
  826                 $radio_group->setRequired(
true);
 
  827                 $radio_group->setValue(
$_POST[
'price_type']);
 
  828                 $radio_group->setPostVar(
'price_type');
 
  830                 $radio_option_1 = 
new ilRadioOption($this->lng->txt(
'duration_month'), 
'duration_month');
 
  834                 $oDuration->
setTitle($this->lng->txt(
'paya_months'));
 
  835                 $oDuration->setSize(
'30%');
 
  838                 $oDuration->setPostVar(
'duration_month');
 
  841                 $radio_group->addOption($radio_option_1);
 
  843                 $radio_option_3 = 
new ilRadioOption($this->lng->txt(
'duration_date'), 
'duration_date');
 
  847                 $o_date_from->
setTitle($this->lng->txt(
'from'));
 
  848                 $o_date_from->setPostVar(
'duration_date_from');
 
  853                 $o_date_until->setTitle($this->lng->txt(
'until'));
 
  854                 $o_date_until->setPostVar(
'duration_date_until');
 
  855                 $radio_option_3->addSubItem($o_date_until);
 
  857                 $radio_group->addOption($radio_option_3);
 
  859                 $radio_option_2 = 
new ilRadioOption($this->lng->txt(
'unlimited_duration'), 
'unlimited_duration');
 
  860                 $radio_group->addOption($radio_option_2);
 
  862                 $form->addItem($radio_group);
 
  864                 $oDescription = 
new ilTextAreaInputGUI($this->lng->txt(
'description'), 
'description');
 
  866                 $oDescription->setCols(35);
 
  867                 $oDescription->setValue(
$_POST[
'description']);
 
  868                 $form->addItem($oDescription);
 
  872                 $oPrice->setTitle($this->lng->txt(
'price_a'));
 
  873                 $oPrice->setValue(
$_POST[
'price']);
 
  874                 $oPrice->setPostVar(
'price');
 
  875                 $oPrice->setRequired(
true);
 
  876                 $oPrice->allowDecimals(
true);
 
  877                 $form->addItem($oPrice);
 
  880                 $this->tpl->setVariable(
'TXT_PRICE_A', $genSet->get(
'currency_unit'));
 
  883                 $oExtension = 
new ilCheckboxInputGUI($this->lng->txt(
'extension_price'), 
'extension');
 
  884                 isset(
$_POST[
'extension']) ? $ext_value = 1 : $ext_value = 0;
 
  887                 $form->addItem($oExtension);
 
  889                 $form->addCommandButton(
'performAddPrice', $this->lng->txt(
'paya_add_price'));
 
  890                 $form->addCommandButton(
'editPrices', $this->lng->txt(
'cancel'));
 
  891                 $this->tpl->setVariable(
'FORM', $form->getHTML());
 
  898                 if(!(
int)$_GET[
'pobject_id'])
 
  902                         $this->showObjects();
 
  906                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
  907                 include_once 
'./Services/Payment/classes/class.ilPaymentCurrency.php';
 
  913                 switch(
$_POST[
'price_type'])
 
  915                         case 'unlimited_duration':
 
  918                                 $po->setDurationFrom(NULL);
 
  919                                 $po->setDurationUntil(NULL);
 
  920                                 $po->setUnlimitedDuration(1);
 
  924                         case 'duration_date':
 
  927                                 $po->setDuration(NULL);
 
  929                                         $_POST[
'duration_date_from'][
'date'][
'y'] . 
'-' .
 
  930                                                 $_POST[
'duration_date_from'][
'date'][
'm'] . 
'-' .
 
  931                                                 $_POST[
'duration_date_from'][
'date'][
'd']));
 
  933                                         $_POST[
'duration_date_until'][
'date'][
'y'] . 
'-' .
 
  934                                                 $_POST[
'duration_date_until'][
'date'][
'm'] . 
'-' .
 
  935                                                 $_POST[
'duration_date_until'][
'date'][
'd']));
 
  939                         case 'duration_month':
 
  941                                 $po->setDuration($_POST[
'duration_month']);
 
  942                                 $po->setDurationFrom(NULL);
 
  943                                 $po->setDurationUntil(NULL);
 
  949                 $po->setCurrency($currency[1][
'currency_id']);
 
  951                 if(
$_POST[
'extension_price'])
 
  953                         $po->setExtension(1);
 
  957                         $po->setExtension(0);
 
  966                         return $this->editPrices();
 
  972                         return $this->addPrice();
 
  979                 if(!$_GET[
'pobject_id'])
 
  983                         $this->showObjects();
 
  994                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
  998                 foreach(
$_SESSION[
'price_ids'] as $price_id)
 
 1000                         $prices->delete($price_id);
 
 1004                 if(!count($prices->getPrices()))
 
 1008                         $this->pobject->setStatus($this->pobject->STATUS_NOT_BUYABLE);
 
 1009                         $this->pobject->update();
 
 1016                 return $this->editPrices();
 
 1022                 if(!$_GET[
'pobject_id'])
 
 1026                         $this->showObjects();
 
 1030                 if(!count(
$_POST[
'price_ids']))
 
 1034                         $this->editPrices();
 
 1039                 $this->editPrices(
true);
 
 1045                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
 1047                 if(!$_GET[
'pobject_id'] && !
$_POST[
'pobject_id'])
 
 1051                         $this->showObjects();
 
 1054                 if(isset($_GET[
'pobject_id']))
 
 1056                         $pobject_id = (int)$_GET[
'pobject_id'];
 
 1060                         $pobject_id = (int)
$_POST[
'pobject_id'];
 
 1064                 $this->ctrl->setParameter($this, 
'pobject_id', $pobject_id);
 
 1066                 $price_id = (int)
$_POST[
'price_id'];
 
 1069                 $old_price = $po->getPrice($price_id);
 
 1072                 $po->setDuration((
int)
$_POST[
'duration']);
 
 1073                 $po->setUnlimitedDuration($_POST[
'unlimited_duration']);
 
 1074                 $po->setPrice($_POST[
'price']);
 
 1075                 $po->setPriceType($_POST[
'price_type']);
 
 1076                 $po->setCurrency($old_price[
'currency']);
 
 1077                 $po->setExtension((
int)$_POST[
'extension']);
 
 1079                 if(!$po->validate())
 
 1087                         $this->editPrices();
 
 1091                 foreach($_POST[
'prices'] as $price_id => $price)
 
 1093                         $old_price = $po->getPrice($price_id);
 
 1094                         if(isset($_POST[
'duration_ids']))
 
 1097                                 if($_POST[
'duration_ids'] == NULL)
 
 1099                                         $po->setUnlimitedDuration(0);
 
 1100                                         $po->setDuration($price[
'duration']);
 
 1103                                 else if($search = in_array((
string)$price_id, $_POST[
'duration_ids']))
 
 1105                                         $po->setUnlimitedDuration(1);
 
 1106                                         $po->setDuration(0);
 
 1110                                         $po->setUnlimitedDuration(0);
 
 1114                         if(isset($_POST[
'extension_ids']))
 
 1117                                 if($search = in_array((
string)$price_id, $_POST[
'extension_ids']))
 
 1119                                         $po->setExtension(1);
 
 1123                                         $po->setExtension(0);
 
 1127                         $po->setDuration($price[
'duration']);
 
 1129                         $po->setPrice($price[
'price']);
 
 1130                         $po->setCurrency($old_price[
'currency']);
 
 1131                         $po->update($price_id);
 
 1134                 $this->editPrices();
 
 1141                 if(!$_GET[
'pobject_id'])
 
 1145                         $this->showObjects();
 
 1149                 $this->ctrl->setParameter($this, 
'pobject_id', (
int)$_GET[
'pobject_id']);
 
 1152                 $old_status = $this->pobject->getStatus();
 
 1155                 if($old_status == $this->pobject->STATUS_NOT_BUYABLE and
 
 1156                         (
int)
$_POST[
'status'] != $old_status
 
 1160                         switch((
int)
$_POST[
'pay_method'])
 
 1162                                 case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
 
 1164                                         $this->editDetails();
 
 1172                         include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
 1175                         if(!count($prices_obj->getPrices()))
 
 1178                                 $this->editDetails();
 
 1184                 if((
int)
$_POST[
'status'] == 0)
 
 1187                         include_once 
'./Services/Payment/classes/class.ilPaymentShoppingCart.php';
 
 1191                 $this->pobject->setStatus((
int)
$_POST[
'status']);
 
 1192                 $this->pobject->setVendorId((
int)$_POST[
'vendor']);
 
 1193                 $this->pobject->setPayMethod((
int)$_POST[
'pay_method']);
 
 1194                 $this->pobject->setTopicId((
int)$_POST[
'topic_id']);
 
 1195                 $this->pobject->setVatId((
int)$_POST[
'vat_id']);
 
 1196                 $this->pobject->setSubtype((
string)$_POST[
'exc_subtype']);
 
 1197                 $this->pobject->setSpecial((
int)$_POST[
'is_special']);
 
 1199                 if((
int)$_POST[
'thumbnail_delete'])
 
 1202                         $oFile->deassignFileFromPaymentObject();
 
 1204                 else if($_FILES[
'thumbnail'][
'tmp_name'] != 
'')
 
 1206                         $this->lng->loadLanguageModule(
'form');
 
 1207                         include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
 1209                         if($oThumbnail->checkInput())
 
 1212                                 if(($oFile->storeUploadedFile($_FILES[
'thumbnail'])) !== 
false)
 
 1214                                         $oFile->assignFileToPaymentObject();
 
 1220                                 return $this->editDetails();
 
 1224                 $this->pobject->update();
 
 1227                 $this->showObjects();
 
 1232         public function showObjectSelector()
 
 1237                 global $tree, $ilToolbar;
 
 1239                 include_once 
'./Services/Payment/classes/class.ilPaymentObjectSelector.php';
 
 1241                 $this->tpl->addBlockFile(
'ADM_CONTENT', 
'adm_content', 
'tpl.paya_object_selector.html', 
'Services/Payment');
 
 1242                 $ilToolbar->addButton($this->lng->txt(
'back'), $this->ctrl->getLinkTarget($this, 
'showObjects'));
 
 1247                 $exp = 
new ilPaymentObjectSelector($this->ctrl->getLinkTarget($this, 
'showObjectSelector'), (string)strtolower(get_class($this)));
 
 1248                 $exp->setExpand($_GET[
'paya_link_expand'] ? $_GET[
'paya_link_expand'] : $tree->readRootId());
 
 1249                 $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 
'showObjectSelector'));
 
 1253                 $this->tpl->setVariable(
"EXPLORER", $exp->getOutput());
 
 1262                 if(!(
int)$_GET[
'sell_id'])
 
 1265                         return $this->showObjectSelector();
 
 1268                 $ilToolbar->addButton($this->lng->txt(
'back'), $this->ctrl->getLinkTarget($this, 
'showObjectSelector'));
 
 1271                 $this->ctrl->setParameter($this, 
'sell_id', (
int)$_GET[
'sell_id']);
 
 1273                 include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
 1275                 $oForm->setFormAction($this->ctrl->getFormAction($this, 
'updateDetails'));
 
 1276                 $oForm->setTitle($this->lng->txt(
'details'));
 
 1280                 if(is_object($tmp_obj))
 
 1282                         $tmp_object[
'title']       = $tmp_obj->
getTitle();
 
 1283                         $tmp_object[
'description'] = $tmp_obj->getDescription();
 
 1284                         $tmp_object[
'owner']       = $tmp_obj->getOwnerName();
 
 1285                         $tmp_object[
'path']        = $this->__getHTMLPath((
int)$_GET[
'sell_id']);
 
 1289                         $tmp_object[
'title']       = $this->lng->txt(
'object_not_found');
 
 1290                         $tmp_object[
'description'] = 
'';
 
 1291                         $tmp_object[
'owner']       = 
'';
 
 1292                         $tmp_object[
'path']        = 
'';
 
 1297                 $oTitleGUI->
setValue($tmp_object[
'title']);
 
 1298                 $oForm->addItem($oTitleGUI);
 
 1302                 $oDescriptionGUI->
setValue($tmp_object[
'description']);
 
 1303                 $oForm->addItem($oDescriptionGUI);
 
 1307                 $oOwnerGUI->
setValue($tmp_object[
'owner']);
 
 1308                 $oForm->addItem($oOwnerGUI);
 
 1312                 $oPathGUI->
setValue($tmp_object[
'path']);
 
 1313                 $oForm->addItem($oPathGUI);
 
 1316                 $oVendorsGUI = 
new ilSelectInputGUI($this->lng->txt(
'paya_vendor'), 
'vendor');
 
 1317                 $oVendorsGUI->
setOptions($this->__getVendors());
 
 1318                 $oForm->addItem($oVendorsGUI);
 
 1321                 $oForm->addCommandButton(
'addObject', $this->lng->txt(
'next'));
 
 1322                 $oForm->addCommandButton(
'showObjects', $this->lng->txt(
'cancel'));
 
 1324                 $this->tpl->setVariable(
'ADM_CONTENT', $oForm->getHTML());
 
 1330                 if(!$_GET[
'sell_id'])
 
 1334                         return $this->showObjectSelector();
 
 1336                 if(!(
int)
$_POST[
'vendor'])
 
 1343                 include_once 
'Services/Payment/classes/class.ilPaymentObject.php';
 
 1348                         if(!in_array(
'download', $check_subtypes))
 
 1349                                 $p_obj->setSubtype(
'download');
 
 1351                                 if(!in_array(
'upload', $check_subtypes))
 
 1352                                         $p_obj->setSubtype(
'upload');
 
 1362                                 return $this->showObjectSelector();
 
 1365                 $p_obj->setRefId((
int)$_GET[
'sell_id']);
 
 1366                 $p_obj->setStatus($p_obj->STATUS_NOT_BUYABLE);
 
 1367                 $p_obj->setPayMethod($p_obj->PAY_METHOD_NOT_SPECIFIED);
 
 1368                 $p_obj->setVendorId((
int)$_POST[
'vendor']);
 
 1369                 $p_obj->setTopicId((
int)$_POST[
'topic_id']);
 
 1370                 $p_obj->setVatId((
int)$_POST[
'vat_id']);
 
 1372                 $new_id = $p_obj->add();
 
 1376                         $_GET[
'pobject_id'] = $new_id;
 
 1377                         $this->editPrices();
 
 1383                         return $this->showObjects();
 
 1387         private function __getVendors()
 
 1389                 include_once 
'Services/Payment/classes/class.ilPaymentVendors.php';
 
 1393                 if(ilPaymentVendors::_isVendor($this->user_obj->getId()))
 
 1395                         $vendors[] = $this->user_obj->getId();
 
 1399                         $vendors = array_merge($vendors, $vend);
 
 1402                 foreach($vendors as $vendor)
 
 1406                         $options[$vendor] = $tmp_obj->getFullname() . 
' [' . $tmp_obj->getLogin() . 
']';
 
 1416                 $option[$this->pobject->STATUS_NOT_BUYABLE] = $this->lng->txt(
'paya_not_buyable');
 
 1417                 $option[$this->pobject->STATUS_BUYABLE]     = $this->lng->txt(
'paya_buyable');
 
 1418                 $option[$this->pobject->STATUS_EXPIRES]     = $this->lng->txt(
'paya_expires');
 
 1426                 $tbl->setTitle($this->lng->txt(
'objects'));
 
 1428                 $tbl->setId(
'tbl_objects');
 
 1429                 $tbl->setRowTemplate(
"tpl.shop_objects_row.html", 
"Services/Payment");
 
 1431                 $tbl->addColumn($this->lng->txt(
'title'), 
'title', 
'10%');
 
 1432                 $tbl->addColumn($this->lng->txt(
'status'), 
'status', 
'10%');
 
 1433                 $tbl->addColumn($this->lng->txt(
'paya_pay_method'), 
'pay_method', 
'10%');
 
 1434                 $tbl->addColumn($this->lng->txt(
'vat_rate'), 
'vat_rate', 
'15%');
 
 1435                 $tbl->addColumn($this->lng->txt(
'paya_vendor'), 
'vendor', 
'10%');
 
 1436                 $tbl->addColumn($this->lng->txt(
'paya_count_purchaser'), 
'purchasers', 
'10%');
 
 1437                 $tbl->addColumn(
'', 
'options', 
'10%');
 
 1439                 $tbl->setData($a_result_set);
 
 1441                 $this->tpl->setVariable(
'TABLE', $tbl->getHTML());
 
 1447         private function __getHTMLPath($a_ref_id)
 
 1453                 $path = $tree->getPathFull($a_ref_id);
 
 1457                 foreach(
$path as $data)
 
 1459                         $html .= $data[
'title'] . 
' > ';
 
 1461                 return substr($html, 0, -2);
 
 1466                 include_once 
'./Services/Payment/classes/class.ilPaymentObject.php';
 
 1473         public function editPrice()
 
 1475                 $this->tpl->addBlockfile(
'ADM_CONTENT', 
'adm_content', 
'tpl.main_view.html', 
'Services/Payment');
 
 1477                 $price_id = $_GET[
'price_id'] ? $_GET[
'price_id'] : 
$_POST[
'price_id'];
 
 1481                 include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
 1483                 $form->setFormAction($this->ctrl->getFormAction($this));
 
 1487                 $radio_group->setTitle($this->lng->txt(
'duration'));
 
 1488                 $radio_group->setRequired(
true);
 
 1489                 $radio_group->setValue($price[
'price_type']);
 
 1490                 $radio_group->setPostVar(
'price_type');
 
 1496                 $oDuration->
setTitle($this->lng->txt(
'paya_months'));
 
 1497                 $oDuration->setSize(
'20%');
 
 1498                 $oDuration->
setValue($price[
'duration']);
 
 1499                 $oDuration->setPostVar(
'duration_month');
 
 1502                 $radio_group->addOption($radio_option_1);
 
 1506                 $now_date = date(
'Y-m-d');
 
 1510                 $o_date_from->
setTitle($this->lng->txt(
'from'));
 
 1512                 $o_date_from->setDate(
new ilDate($price[
'duration_from'] == NULL ? $now_date : $price[
'duration_from'], 
IL_CAL_DATE));
 
 1513                 $o_date_from->setPostVar(
'duration_date_from');
 
 1518                 $o_date_until->setTitle($this->lng->txt(
'until'));
 
 1519                 $o_date_until->setDate(
new ilDate($price[
'duration_until'] == NULL ? $now_date : $price[
'duration_until'], 
IL_CAL_DATE));
 
 1520                 $o_date_until->setPostVar(
'duration_date_until');
 
 1521                 $radio_option_3->addSubItem($o_date_until);
 
 1523                 $radio_group->addOption($radio_option_3);
 
 1526                 $radio_group->addOption($radio_option_2);
 
 1528                 $form->addItem($radio_group);
 
 1531                 $oDescription = 
new ilTextAreaInputGUI($this->lng->txt(
'description'), 
'description');
 
 1533                 $oDescription->setCols(35);
 
 1534                 $oDescription->setValue($price[
'description']);
 
 1535                 $form->addItem($oDescription);
 
 1539                 $oPrice->setTitle($this->lng->txt(
'price_a'));
 
 1540                 $oPrice->allowDecimals(
true);
 
 1541                 $oPrice->setRequired(
true);
 
 1542                 $oPrice->setSize(
'20%');
 
 1543                 $oPrice->setValue($price[
'price']);
 
 1544                 include_once 
'./Services/Payment/classes/class.ilPaymentSettings.php';
 
 1547                 $oPrice->setInfo($genSet->get(
'currency_unit'));
 
 1548                 $oPrice->setPostVar(
'price');
 
 1549                 $oPrice->allowDecimals(
true);
 
 1550                 $form->addItem($oPrice);
 
 1553                 $oExtension = 
new ilCheckboxInputGUI($this->lng->txt(
'extension_price'), 
'extension');
 
 1554                 $oExtension->
setChecked((
int)$price[
'extension']);
 
 1555                 $form->addItem($oExtension);
 
 1558                 $o_hidden_1->setValue((
int)$_GET[
'pobject_id']);
 
 1559                 $o_hidden_1->setPostVar(
'pobject_id');
 
 1562                 $o_hidden_2->setValue((
int)$_GET[
'price_id']);
 
 1563                 $o_hidden_2->setPostVar(
'price_id');
 
 1565                 $form->addItem($o_hidden_1);
 
 1566                 $form->addItem($o_hidden_2);
 
 1568                 $form->addCommandButton(
'updatePrice', $this->lng->txt(
'save'));
 
 1569                 $form->addCommandButton(
'editPrices', $this->lng->txt(
'cancel'));
 
 1571                 $this->tpl->setVariable(
'FORM', $form->getHTML());
 
 1576                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
 1578                 if(!$_GET[
'pobject_id'] && !
$_POST[
'pobject_id'])
 
 1582                         $this->showObjects();
 
 1585                 if(isset($_GET[
'pobject_id']))
 
 1587                         $pobject_id = (int)$_GET[
'pobject_id'];
 
 1591                         $pobject_id = (int)
$_POST[
'pobject_id'];
 
 1594                 if(!(
int)$_GET[
'price_id'] && !
$_POST[
'price_id'])
 
 1597                         return $this->editPrices();
 
 1599                 if(isset($_GET[
'price_id']))
 
 1601                         $price_id = (int)$_GET[
'price_id'];
 
 1605                         $price_id = (int)
$_POST[
'price_id'];
 
 1609                 switch(
$_POST[
'price_type'])
 
 1613                                 $po->setDuration(NULL);
 
 1614                                 $po->setDurationFrom(NULL);
 
 1615                                 $po->setDurationUntil(NULL);
 
 1616                                 $po->setUnlimitedDuration(1);
 
 1623                                 $po->setDuration(NULL);
 
 1625                                         $_POST[
'duration_date_from'][
'date'][
'y'] . 
'-' .
 
 1626                                                 $_POST[
'duration_date_from'][
'date'][
'm'] . 
'-' .
 
 1627                                                 $_POST[
'duration_date_from'][
'date'][
'd']));
 
 1629                                         $_POST[
'duration_date_until'][
'date'][
'y'] . 
'-' .
 
 1630                                                 $_POST[
'duration_date_until'][
'date'][
'm'] . 
'-' .
 
 1631                                                 $_POST[
'duration_date_until'][
'date'][
'd']));
 
 1637                                 $po->setDuration($_POST[
'duration_month']);
 
 1638                                 $po->setDurationFrom(NULL);
 
 1639                                 $po->setDurationUntil(NULL);
 
 1648                         $po->setExtension(1);
 
 1652                         $po->setExtension(0);
 
 1657                         $po->update($price_id);
 
 1659                         return $this->editPrices();
 
 1664                         return $this->editPrices();