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))
 
   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/Payment/classes/class.ilShopPage.php';
 
  103                 include_once 
'Services/Payment/classes/class.ilShopPageGUI.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(
'ilshoppagegui', 
'edit');
 
  119                 $page_gui = 
new ilShopPageGUI($this->pobject->getPobjectId());
 
  120                 $this->ctrl->setParameter($page_gui, 
'pobject_id', (
int)$_GET[
'pobject_id']);
 
  122                 return $this->ctrl->forwardCommand($page_gui);
 
  128                 unset(
$_POST[
'title_type']);
 
  129                 unset(
$_POST[
'title_value']);
 
  131                 unset(
$_POST[
'pay_method']);
 
  132                 unset(
$_POST[
'updateView']);
 
  133                 unset(
$_POST[
'show_filter']);
 
  137                 return $this->showObjects();
 
  140         public function showObjects()
 
  146                 include_once 
'./Services/Payment/classes/class.ilPayMethods.php';
 
  148                 $ilToolbar->addButton($this->lng->txt(
'paya_sell_object'), $this->ctrl->getLinkTarget($this, 
'showObjectSelector'));
 
  150                 if(!
$_POST[
'show_filter'] && 
$_POST[
'updateView'] == 
'1')
 
  155                         if(
$_POST[
'updateView'] == 1)
 
  165                 $this->tpl->addBlockfile(
'ADM_CONTENT', 
'adm_content', 
'tpl.main_view.html', 
'Services/Payment');
 
  168                 $this->lng->loadLanguageModule(
'search');
 
  171                 $filter_form->setFormAction($this->ctrl->getFormAction($this));
 
  172                 $filter_form->setTitle($this->lng->txt(
'pay_filter'));
 
  173                 $filter_form->setId(
'filter_form');
 
  174                 $filter_form->setTableWidth(
'100 %');
 
  177                 $o_hide_check = 
new ilCheckBoxInputGUI($this->lng->txt(
'show_filter'), 
'show_filter');
 
  178                 $o_hide_check->setValue(1);
 
  179                 $o_hide_check->setChecked(
$_SESSION[
'pay_objects'][
'show_filter'] ? 1 : 0);
 
  182                 $o_hidden->setValue(1);
 
  183                 $o_hidden->setPostVar(
'updateView');
 
  184                 $o_hide_check->addSubItem($o_hidden);
 
  188                 $radio_option = 
new ilRadioOption($this->lng->txt(
'search_any_word'), 
'or');
 
  189                 $radio_group->addOption($radio_option);
 
  190                 $radio_option = 
new ilRadioOption($this->lng->txt(
'search_all_words'), 
'and');
 
  191                 $radio_group->addOption($radio_option);
 
  193                 $radio_group->setRequired(
false);
 
  195                 $radio_group->setPostVar(
'title_type');
 
  198                 $o_title->setValue(
$_SESSION[
'pay_objects'][
'title_value']);
 
  199                 $o_title->setPostVar(
'title_value');
 
  200                 $o_title->setTitle($this->lng->txt(
'title'));
 
  202                 $o_hide_check->addSubItem($radio_group);
 
  203                 $o_hide_check->addSubItem($o_title);
 
  207                 $o_vendor->setTitle($this->lng->txt(
'paya_vendor'));
 
  208                 $o_vendor->setValue(
$_SESSION[
'pay_objects'][
'vendor']);
 
  209                 $o_vendor->setPostVar(
'vendor');
 
  210                 $o_hide_check->addSubItem($o_vendor);
 
  214                 $o_paymethod->setTitle($this->lng->txt(
'payment_system'));
 
  215                 $o_paymethod->setOptions(ilPaymethods::getPayMethodsOptions(
'all'));
 
  216                 $o_paymethod->setValue(
$_SESSION[
'pay_objects'][
'pay_method']);
 
  217                 $o_paymethod->setPostVar(
'pay_method');
 
  218                 $o_hide_check->addSubItem($o_paymethod);
 
  220                 $filter_form->addCommandButton(
'showObjects', $this->lng->txt(
'pay_update_view'));
 
  221                 $filter_form->addCommandButton(
'resetObjectFilter', $this->lng->txt(
'pay_reset_filter'));
 
  223                 $filter_form->addItem($o_hide_check);
 
  230                 $this->tpl->setVariable(
'FORM', $filter_form->getHTML());
 
  233                 foreach($objects as $data)
 
  239                                 $f_result[$counter][
'title'] = $tmp_obj->getTitle();
 
  243                                 $f_result[$counter][
'title'] = $this->lng->txt(
'object_not_found');
 
  247                         switch($data[
'status'])
 
  249                                 case $this->pobject->STATUS_BUYABLE:
 
  250                                         $f_result[$counter][
'status'] = $this->lng->txt(
'paya_buyable');
 
  253                                 case $this->pobject->STATUS_NOT_BUYABLE:
 
  254                                         $f_result[$counter][
'status'] = $this->lng->txt(
'paya_not_buyable');
 
  257                                 case $this->pobject->STATUS_EXPIRES:
 
  258                                         $f_result[$counter][
'status'] = $this->lng->txt(
'paya_expires');
 
  262                         $f_result[$counter][
'pay_method'] = $str_paymethod;
 
  264                         if($data[
'vat_id'] <= 0)
 
  266                                 $vat_rate = $this->lng->txt(
'payment_vat_has_to_be_defined_by_administration_short');
 
  277                                         $vat_rate = $this->lng->txt(
'payment_vat_has_to_be_defined_by_administration_short');
 
  280                         $f_result[$counter][
'vat_rate'] = $vat_rate;
 
  284                         $f_result[$counter][
'vendor'] = $tmp_user->getFullname() . 
' [' . $tmp_user->getLogin() . 
']';
 
  290                         $this->ctrl->setParameter($this, 
'pobject_id', $data[
'pobject_id']);
 
  291                         $link_change = 
"<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"" . $this->ctrl->getLinkTarget($this, 
"editDetails") . 
"\">" . $this->lng->txt(
"edit") . 
"</a></div>";
 
  293                         $f_result[$counter][
'options'] = $link_change;
 
  303         public function editDetails($a_show_confirm = 
false)
 
  310                 include_once 
'./Services/Payment/classes/class.ilPaymentSettings.php';
 
  314                 if(!(
int)$_GET[
'pobject_id'])
 
  317                         return $this->showObjects();
 
  322                 $this->ctrl->setParameter($this, 
'pobject_id', (
int)$_GET[
'pobject_id']);
 
  324                 $this->tpl->addBlockFile(
'ADM_CONTENT', 
'adm_content', 
'tpl.main_view.html', 
'Services/Payment');
 
  327                 if(is_object($tmp_obj))
 
  332                                 $trash = 
' (' . $this->lng->txt(
'object_deleted') . 
')';
 
  334                         $tmp_object[
'title'] = $tmp_obj->getTitle() . 
'' . $trash;
 
  335                         $tmp_object[
'type']  = $tmp_obj->getType();
 
  339                         $tmp_object[
'title'] = $this->lng->txt(
'object_not_found');
 
  340                         $tmp_object[
'type']  = 
false;
 
  345                         include_once 
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
 
  349                         $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, 
"performDelete"));
 
  350                         $oConfirmationGUI->setHeaderText($this->lng->txt(
"paya_sure_delete_object"));
 
  351                         $oConfirmationGUI->setCancel($this->lng->txt(
"cancel"), 
"editDetails");
 
  352                         $oConfirmationGUI->setConfirm($this->lng->txt(
"confirm"), 
"performDelete");
 
  354                         $oConfirmationGUI->addItem(
'', $tmp_object[
'title'], $tmp_object[
'title']);
 
  355                         $this->tpl->setVariable(
'CONFIRMATION', $oConfirmationGUI->getHTML());
 
  360                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_details'), $this->ctrl->getLinkTarget($this, 
'editDetails'));
 
  361                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_prices'), $this->ctrl->getLinkTarget($this, 
'editPrices'));
 
  362                 $ilToolbar->addButton($this->lng->txt(
'pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array(
'ilshoppagegui'), 
'edit'));
 
  364                 include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
  366                 $oForm->setFormAction($this->ctrl->getFormAction($this, 
'updateDetails'));
 
  367                 $oForm->setTitle($tmp_object[
'title']);
 
  368                 if($tmp_object[
'type'])
 
  373                 $oPathGUI->
setValue($this->__getHTMLPath($this->pobject->getRefId()));
 
  374                 $oForm->addItem($oPathGUI);
 
  376                 switch($tmp_object[
'type'])
 
  379                                 $exc_subtype_option = array();
 
  382                                 if(!in_array(
'download', $check_subtypes) || $this->pobject->getSubtype() == 
'download')
 
  383                                         $exc_subtype_option[
'download'] = $this->lng->txt(
'download');
 
  384                                 if(!in_array(
'upload', $check_subtypes) || $this->pobject->getSubtype() == 
'upload')
 
  385                                         $exc_subtype_option[
'upload'] = $this->lng->txt(
'upload');
 
  387                                 $oExcSubtype = 
new ilSelectInputGUI($this->lng->txt(
'select_subtype'), 
'exc_subtype');
 
  388                                 $oExcSubtype->
setOptions($exc_subtype_option);
 
  389                                 $oExcSubtype->setValue($this->pobject->getSubtype());
 
  390                                 $oForm->addItem($oExcSubtype);
 
  399                 $oForm->addItem($oPurchasersGUI);
 
  402                 $oVendorsGUI = 
new ilSelectInputGUI($this->lng->txt(
'paya_vendor'), 
'vendor');
 
  403                 $oVendorsGUI->
setOptions($this->__getVendors());
 
  404                 $oVendorsGUI->setValue($this->pobject->getVendorId());
 
  405                 $oForm->addItem($oVendorsGUI);
 
  410                 $oStatusGUI->setValue($this->pobject->getStatus());
 
  411                 $oForm->addItem($oStatusGUI);
 
  414                 $oPayMethodsGUI = 
new ilSelectInputGUI($this->lng->txt(
'paya_pay_method'), 
'pay_method');
 
  415                 $PMoptions      = ilPaymethods::getPayMethodsOptions(
'not_specified');
 
  416                 $oPayMethodsGUI->setOptions($PMoptions);
 
  417                 $oPayMethodsGUI->setValue($this->pobject->getPayMethod());
 
  418                 $oForm->addItem($oPayMethodsGUI);
 
  423                 $shopTopicsObj->read();
 
  424                 if(is_array($topics = $shopTopicsObj->getTopics()) && count($topics))
 
  427                         include_once 
'Services/Payment/classes/class.ilShopTopics.php';
 
  430                         $shopTopicsObj->read();
 
  431                         $topic_options     = array();
 
  432                         $topic_options[
''] = $this->lng->txt(
'please_choose');
 
  435                         foreach($topics as $oTopic)
 
  437                                 $topic_options[$oTopic->getId()] = $oTopic->getTitle();
 
  440                         $oTopicsGUI->setOptions($topic_options);
 
  441                         $oTopicsGUI->setValue($this->pobject->getTopicId());
 
  442                         $oForm->addItem($oTopicsGUI);
 
  447                 $oShopVatsList->read();
 
  448                 if($oShopVatsList->hasItems())
 
  452                         $vats_options = array();
 
  454                         foreach($oShopVatsList as $oVAT)
 
  459                         $oVatsGUI->setOptions($vats_options);
 
  460                         $oVatsGUI->setValue($this->pobject->getVatId());
 
  461                         $oForm->addItem($oVatsGUI);
 
  466                         $oVatsGUI->
setValue($this->lng->txt(
'paya_no_vats_assigned'));
 
  467                         $oForm->addItem($oVatsGUI);
 
  472                 if(($webpath_file = $oFile->getCurrentImageWebPath()) !== 
false)
 
  474                         $oThumbnail->setImage($webpath_file);
 
  476                 $oForm->addItem($oThumbnail);
 
  478                 if($genSet->get(
'use_shop_specials'))
 
  482                         $oSpecial->
setChecked((
int)$this->pobject->getSpecial());
 
  483                         $oSpecial->setInfo($this->lng->txt(
'special_info'));
 
  484                         $oForm->addItem($oSpecial);
 
  487                 $oForm->addCommandButton(
'updateDetails', $this->lng->txt(
'save'));
 
  488                 $oForm->addCommandButton(
'deleteObject', $this->lng->txt(
'delete'));
 
  490                 $this->tpl->setVariable(
'FORM', $oForm->getHTML());
 
  496                 include_once 
'./Services/Payment/classes/class.ilPaymentBookings.php';
 
  498                 if(!$_GET[
'pobject_id'])
 
  502                         $this->showObjects();
 
  508                         $this->editDetails();
 
  515                         $this->editDetails(
true);
 
  523                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
  525                 if(!$_GET[
'pobject_id'])
 
  529                         $this->showObjects();
 
  535                 $this->pobject->delete();
 
  539                 $price_obj->deleteAllPrices();
 
  544                 $this->showObjects();
 
  553                 switch($this->pobject->getPayMethod())
 
  555                         case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
 
  557                                 $this->editDetails();
 
  562                                 $this->editDetails();
 
  567         public function editPrices($a_show_delete = 
false)
 
  574                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
  575                 include_once 
'./Services/Payment/classes/class.ilPaymentCurrency.php';
 
  576                 include_once 
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
 
  577                 include_once 
'./Services/Payment/classes/class.ilPaymentSettings.php';
 
  581                 if($a_show_delete == 
false) unset(
$_SESSION[
'price_ids']);
 
  585                 if(!$_GET[
'pobject_id'] && !
$_POST[
'pobject_id'])
 
  589                         $this->showObjects();
 
  593                 if(isset($_GET[
'pobject_id']))
 
  595                         $pobject_id = (int)$_GET[
'pobject_id'];
 
  599                         $pobject_id = (int)
$_POST[
'pobject_id'];
 
  602                 $this->ctrl->setParameter($this, 
'pobject_id', $pobject_id);
 
  605                 $this->tpl->addBlockfile(
"ADM_CONTENT", 
"adm_content", 
'tpl.main_view.html', 
'Services/Payment');
 
  609                 $standard_prices  = array();
 
  610                 $extension_prices = array();
 
  611                 $standard_prices  = $price_obj->getPrices();
 
  612                 $extension_prices = $price_obj->getExtensionPrices();
 
  614                 $prices = array_merge($standard_prices, $extension_prices);
 
  620                         $ilToolbar->addButton($this->lng->txt(
'paya_add_price'), $this->ctrl->getLinkTarget($this, 
'addPrice'));
 
  624                 else if(!count($standard_prices))
 
  627                         $this->pobject->setStatus(0);
 
  628                         $this->pobject->update();
 
  638                         $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, 
"performDeletePrice"));
 
  639                         $oConfirmationGUI->setHeaderText($this->lng->txt(
"paya_sure_delete_selected_prices"));
 
  640                         $oConfirmationGUI->setCancel($this->lng->txt(
"cancel"), 
"editPrices");
 
  641                         $oConfirmationGUI->setConfirm($this->lng->txt(
"confirm"), 
"performDeletePrice");
 
  645                         foreach($prices as $price)
 
  647                                 $currency = $genSet->get(
'currency_unit');
 
  648                                 if(in_array($price[
'price_id'], 
$_SESSION[
'price_ids']))
 
  651                                         if($price[
'unlimited_duration'] == 
'1')
 
  653                                                 $tmp_price = $this->lng->txt(
'unlimited_duration');
 
  657                                                 $tmp_price = $price[
'duration'] . 
' ' . $this->lng->txt(
'paya_months');
 
  659                                         $delete_row = 
'' . $tmp_price . 
'  :  ' .
 
  663                                         $oConfirmationGUI->addItem(
'', $delete_row, $delete_row);
 
  669                         $this->tpl->setVariable(
'CONFIRMATION', $oConfirmationGUI->getHTML());
 
  674                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_details'), $this->ctrl->getLinkTarget($this, 
'editDetails'));
 
  675                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_prices'), $this->ctrl->getLinkTarget($this, 
'editPrices'));
 
  676                 $ilToolbar->addButton($this->lng->txt(
'pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array(
'ilshoppagegui'), 
'edit'));
 
  683                 $tpl->setCurrentBlock(
'tbl_form_header');
 
  685                 $tpl->setVariable(
'FORMACTION', $this->ctrl->getFormAction($this));
 
  686                 $tpl->parseCurrentBlock();
 
  689                 include_once 
'./Services/Calendar/classes/class.ilDatePresentation.php';
 
  690                 foreach($prices as $price)
 
  692                         $data[$counter][
'price_id'] = ilUtil::formCheckBox(in_array($price[
'price_id'], 
$_SESSION[
'price_ids']) ? 1 : 0,
 
  693                                 'price_ids[]', $price[
'price_id']);
 
  695                         switch($price[
'price_type'])
 
  698                                         $data[$counter][
'duration'] = $price[
'duration'] . 
' ' . $this->lng->txt(
'paya_months');
 
  706                                         $data[$counter][
'duration'] = $this->lng->txt(
'unlimited_duration');
 
  710                         $data[$counter][
'currency_unit'] = $genSet->get(
'currency_unit');
 
  711                         $data[$counter][
'extension']     = ilUtil::formCheckBox($price[
'extension'] ? 1 : 0,
 
  712                                 'extension_ids[]', (
int)$price[
'price_id'], 
true);
 
  714                         $this->ctrl->setParameter($this, 
"price_id", $price[
'price_id']);
 
  715                         $data[$counter][
'edit'] =
 
  716                                 "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"" . $this->ctrl->getLinkTarget($this, 
"editPrice") . 
"\">" . $this->lng->txt(
"edit") . 
"</a></div>";
 
  720                 $this->__editPricesTable($data);
 
  725         private function __editPricesTable($a_result_set)
 
  733                         $tbl->setTitle($tmp_obj->getTitle());
 
  737                         $tbl->setTitle($this->lng->txt(
'object_not_found'));
 
  740                 $tbl->setId(
'tbl_bookings');
 
  741                 $tbl->setRowTemplate(
"tpl.shop_prices_row.html", 
"Services/Payment");
 
  743                 $tbl->addColumn(
' ', 
'price_id', 
'5%');
 
  744                 $tbl->addColumn($this->lng->txt(
'duration'), 
'duration', 
'40%');
 
  745                 $tbl->addColumn($this->lng->txt(
'price_a'), 
'price', 
'1%');
 
  746                 $tbl->addColumn($this->lng->txt(
'currency'), 
'currency_unit', 
'10%');
 
  747                 $tbl->addColumn($this->lng->txt(
'extension_price'), 
'extension', 
'10%');
 
  748                 $tbl->addColumn(
'', 
'edit', 
'30%');
 
  750                 $tbl->setSelectAllCheckbox(
'price_id');
 
  751                 $tbl->addCommandButton(
'addPrice', $this->lng->txt(
'paya_add_price'));
 
  753                 $tbl->addMultiCommand(
"deletePrice", $this->lng->txt(
"paya_delete_price"));
 
  756                 $tbl->setData($a_result_set);
 
  758                 $this->tpl->setVariable(
'TABLE', $tbl->getHTML());
 
  763         public function addPrice()
 
  770                 if(!$_GET[
'pobject_id'])
 
  774                         $this->showObjects();
 
  778                 include_once 
'./Services/Payment/classes/class.ilPaymentSettings.php';
 
  782                 $this->ctrl->setParameter($this, 
'pobject_id', (
int)$_GET[
'pobject_id']);
 
  786                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_details'), $this->ctrl->getLinkTarget($this, 
'editDetails'));
 
  787                 $ilToolbar->addButton($this->lng->txt(
'paya_edit_prices'), $this->ctrl->getLinkTarget($this, 
'editPrices'));
 
  789                 $this->tpl->addBlockfile(
'ADM_CONTENT', 
'adm_content', 
'tpl.main_view.html', 
'Services/Payment');
 
  792                 $form->setFormAction($this->ctrl->getFormAction($this));
 
  793                 $form->setTitle($this->lng->txt(
'paya_add_price_title'));
 
  799                 if(is_object($tmp_obj))
 
  801                         $oTitle->setValue($tmp_obj->
getTitle());
 
  805                         $oTitle->setValue($this->lng->txt(
'object_not_found'));
 
  807                 $form->addItem($oTitle);
 
  812                 $radio_group->setTitle($this->lng->txt(
'duration'));
 
  813                 $radio_group->setRequired(
true);
 
  814                 $radio_group->setValue(
$_POST[
'price_type']);
 
  815                 $radio_group->setPostVar(
'price_type');
 
  817                 $radio_option_1 = 
new ilRadioOption($this->lng->txt(
'duration_month'), 
'duration_month');
 
  821                 $oDuration->
setTitle($this->lng->txt(
'paya_months'));
 
  822                 $oDuration->setSize(
'30%');
 
  825                 $oDuration->setPostVar(
'duration_month');
 
  828                 $radio_group->addOption($radio_option_1);
 
  830                 $radio_option_3 = 
new ilRadioOption($this->lng->txt(
'duration_date'), 
'duration_date');
 
  834                 $o_date_from->
setTitle($this->lng->txt(
'from'));
 
  835                 $o_date_from->setPostVar(
'duration_date_from');
 
  840                 $o_date_until->setTitle($this->lng->txt(
'until'));
 
  841                 $o_date_until->setPostVar(
'duration_date_until');
 
  842                 $radio_option_3->addSubItem($o_date_until);
 
  844                 $radio_group->addOption($radio_option_3);
 
  846                 $radio_option_2 = 
new ilRadioOption($this->lng->txt(
'unlimited_duration'), 
'unlimited_duration');
 
  847                 $radio_group->addOption($radio_option_2);
 
  849                 $form->addItem($radio_group);
 
  851                 $oDescription = 
new ilTextAreaInputGUI($this->lng->txt(
'description'), 
'description');
 
  853                 $oDescription->setCols(35);
 
  854                 $oDescription->setValue(
$_POST[
'description']);
 
  855                 $form->addItem($oDescription);
 
  859                 $oPrice->setTitle($this->lng->txt(
'price_a'));
 
  860                 $oPrice->setValue(
$_POST[
'price']);
 
  861                 $oPrice->setPostVar(
'price');
 
  862                 $oPrice->setRequired(
true);
 
  863                 $oPrice->allowDecimals(
true);
 
  864                 $form->addItem($oPrice);
 
  867                 $this->tpl->setVariable(
'TXT_PRICE_A', $genSet->get(
'currency_unit'));
 
  870                 $oExtension = 
new ilCheckboxInputGUI($this->lng->txt(
'extension_price'), 
'extension');
 
  871                 isset(
$_POST[
'extension']) ? $ext_value = 1 : $ext_value = 0;
 
  874                 $form->addItem($oExtension);
 
  876                 $form->addCommandButton(
'performAddPrice', $this->lng->txt(
'paya_add_price'));
 
  877                 $form->addCommandButton(
'editPrices', $this->lng->txt(
'cancel'));
 
  878                 $this->tpl->setVariable(
'FORM', $form->getHTML());
 
  885                 if(!(
int)$_GET[
'pobject_id'])
 
  889                         $this->showObjects();
 
  893                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
  894                 include_once 
'./Services/Payment/classes/class.ilPaymentCurrency.php';
 
  900                 switch(
$_POST[
'price_type'])
 
  902                         case 'unlimited_duration':
 
  905                                 $po->setDurationFrom(NULL);
 
  906                                 $po->setDurationUntil(NULL);
 
  907                                 $po->setUnlimitedDuration(1);
 
  911                         case 'duration_date':
 
  914                                 $po->setDuration(NULL);
 
  916                                         $_POST[
'duration_date_from'][
'date'][
'y'] . 
'-' .
 
  917                                                 $_POST[
'duration_date_from'][
'date'][
'm'] . 
'-' .
 
  918                                                 $_POST[
'duration_date_from'][
'date'][
'd']));
 
  920                                         $_POST[
'duration_date_until'][
'date'][
'y'] . 
'-' .
 
  921                                                 $_POST[
'duration_date_until'][
'date'][
'm'] . 
'-' .
 
  922                                                 $_POST[
'duration_date_until'][
'date'][
'd']));
 
  926                         case 'duration_month':
 
  928                                 $po->setDuration($_POST[
'duration_month']);
 
  929                                 $po->setDurationFrom(NULL);
 
  930                                 $po->setDurationUntil(NULL);
 
  936                 $po->setCurrency($currency[1][
'currency_id']);
 
  938                 if(
$_POST[
'extension_price'])
 
  940                         $po->setExtension(1);
 
  944                         $po->setExtension(0);
 
  953                         return $this->editPrices();
 
  959                         return $this->addPrice();
 
  966                 if(!$_GET[
'pobject_id'])
 
  970                         $this->showObjects();
 
  981                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
  985                 foreach(
$_SESSION[
'price_ids'] as $price_id)
 
  987                         $prices->delete($price_id);
 
  991                 if(!count($prices->getPrices()))
 
  995                         $this->pobject->setStatus($this->pobject->STATUS_NOT_BUYABLE);
 
  996                         $this->pobject->update();
 
 1003                 return $this->editPrices();
 
 1009                 if(!$_GET[
'pobject_id'])
 
 1013                         $this->showObjects();
 
 1017                 if(!count(
$_POST[
'price_ids']))
 
 1021                         $this->editPrices();
 
 1026                 $this->editPrices(
true);
 
 1032                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
 1034                 if(!$_GET[
'pobject_id'] && !
$_POST[
'pobject_id'])
 
 1038                         $this->showObjects();
 
 1041                 if(isset($_GET[
'pobject_id']))
 
 1043                         $pobject_id = (int)$_GET[
'pobject_id'];
 
 1047                         $pobject_id = (int)
$_POST[
'pobject_id'];
 
 1051                 $this->ctrl->setParameter($this, 
'pobject_id', $pobject_id);
 
 1053                 $price_id = (int)
$_POST[
'price_id'];
 
 1056                 $old_price = $po->getPrice($price_id);
 
 1059                 $po->setDuration((
int)
$_POST[
'duration']);
 
 1060                 $po->setUnlimitedDuration($_POST[
'unlimited_duration']);
 
 1061                 $po->setPrice($_POST[
'price']);
 
 1062                 $po->setPriceType($_POST[
'price_type']);
 
 1063                 $po->setCurrency($old_price[
'currency']);
 
 1064                 $po->setExtension((
int)$_POST[
'extension']);
 
 1066                 if(!$po->validate())
 
 1074                         $this->editPrices();
 
 1078                 foreach($_POST[
'prices'] as $price_id => $price)
 
 1080                         $old_price = $po->getPrice($price_id);
 
 1081                         if(isset($_POST[
'duration_ids']))
 
 1084                                 if($_POST[
'duration_ids'] == NULL)
 
 1086                                         $po->setUnlimitedDuration(0);
 
 1087                                         $po->setDuration($price[
'duration']);
 
 1090                                 else if($search = in_array((
string)$price_id, $_POST[
'duration_ids']))
 
 1092                                         $po->setUnlimitedDuration(1);
 
 1093                                         $po->setDuration(0);
 
 1097                                         $po->setUnlimitedDuration(0);
 
 1101                         if(isset($_POST[
'extension_ids']))
 
 1104                                 if($search = in_array((
string)$price_id, $_POST[
'extension_ids']))
 
 1106                                         $po->setExtension(1);
 
 1110                                         $po->setExtension(0);
 
 1114                         $po->setDuration($price[
'duration']);
 
 1116                         $po->setPrice($price[
'price']);
 
 1117                         $po->setCurrency($old_price[
'currency']);
 
 1118                         $po->update($price_id);
 
 1121                 $this->editPrices();
 
 1128                 if(!$_GET[
'pobject_id'])
 
 1132                         $this->showObjects();
 
 1136                 $this->ctrl->setParameter($this, 
'pobject_id', (
int)$_GET[
'pobject_id']);
 
 1139                 $old_status = $this->pobject->getStatus();
 
 1142                 if($old_status == $this->pobject->STATUS_NOT_BUYABLE and
 
 1143                         (
int)
$_POST[
'status'] != $old_status
 
 1147                         switch((
int)
$_POST[
'pay_method'])
 
 1149                                 case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
 
 1151                                         $this->editDetails();
 
 1159                         include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
 1162                         if(!count($prices_obj->getPrices()))
 
 1165                                 $this->editDetails();
 
 1171                 if((
int)
$_POST[
'status'] == 0)
 
 1174                         include_once 
'./Services/Payment/classes/class.ilPaymentShoppingCart.php';
 
 1178                 $this->pobject->setStatus((
int)
$_POST[
'status']);
 
 1179                 $this->pobject->setVendorId((
int)$_POST[
'vendor']);
 
 1180                 $this->pobject->setPayMethod((
int)$_POST[
'pay_method']);
 
 1181                 $this->pobject->setTopicId((
int)$_POST[
'topic_id']);
 
 1182                 $this->pobject->setVatId((
int)$_POST[
'vat_id']);
 
 1183                 $this->pobject->setSubtype((
string)$_POST[
'exc_subtype']);
 
 1184                 $this->pobject->setSpecial((
int)$_POST[
'is_special']);
 
 1186                 if((
int)$_POST[
'thumbnail_delete'])
 
 1189                         $oFile->deassignFileFromPaymentObject();
 
 1191                 else if($_FILES[
'thumbnail'][
'tmp_name'] != 
'')
 
 1193                         $this->lng->loadLanguageModule(
'form');
 
 1194                         include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
 1196                         if($oThumbnail->checkInput())
 
 1199                                 if(($oFile->storeUploadedFile($_FILES[
'thumbnail'])) !== 
false)
 
 1201                                         $oFile->assignFileToPaymentObject();
 
 1207                                 return $this->editDetails();
 
 1211                 $this->pobject->update();
 
 1214                 $this->showObjects();
 
 1219         public function showObjectSelector()
 
 1224                 global $tree, $ilToolbar;
 
 1226                 include_once 
'./Services/Payment/classes/class.ilPaymentObjectSelector.php';
 
 1228                 $this->tpl->addBlockFile(
'ADM_CONTENT', 
'adm_content', 
'tpl.paya_object_selector.html', 
'Services/Payment');
 
 1229                 $ilToolbar->addButton($this->lng->txt(
'back'), $this->ctrl->getLinkTarget($this, 
'showObjects'));
 
 1234                 $exp = 
new ilPaymentObjectSelector($this->ctrl->getLinkTarget($this, 
'showObjectSelector'), (string)strtolower(get_class($this)));
 
 1235                 $exp->setExpand($_GET[
'paya_link_expand'] ? $_GET[
'paya_link_expand'] : $tree->readRootId());
 
 1236                 $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 
'showObjectSelector'));
 
 1240                 $this->tpl->setVariable(
"EXPLORER", $exp->getOutput());
 
 1249                 if(!(
int)$_GET[
'sell_id'])
 
 1252                         return $this->showObjectSelector();
 
 1255                 $ilToolbar->addButton($this->lng->txt(
'back'), $this->ctrl->getLinkTarget($this, 
'showObjectSelector'));
 
 1258                 $this->ctrl->setParameter($this, 
'sell_id', (
int)$_GET[
'sell_id']);
 
 1260                 include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
 1262                 $oForm->setFormAction($this->ctrl->getFormAction($this, 
'updateDetails'));
 
 1263                 $oForm->setTitle($this->lng->txt(
'details'));
 
 1267                 if(is_object($tmp_obj))
 
 1269                         $tmp_object[
'title']       = $tmp_obj->
getTitle();
 
 1270                         $tmp_object[
'description'] = $tmp_obj->getDescription();
 
 1271                         $tmp_object[
'owner']       = $tmp_obj->getOwnerName();
 
 1272                         $tmp_object[
'path']        = $this->__getHTMLPath((
int)$_GET[
'sell_id']);
 
 1276                         $tmp_object[
'title']       = $this->lng->txt(
'object_not_found');
 
 1277                         $tmp_object[
'description'] = 
'';
 
 1278                         $tmp_object[
'owner']       = 
'';
 
 1279                         $tmp_object[
'path']        = 
'';
 
 1284                 $oTitleGUI->
setValue($tmp_object[
'title']);
 
 1285                 $oForm->addItem($oTitleGUI);
 
 1289                 $oDescriptionGUI->
setValue($tmp_object[
'description']);
 
 1290                 $oForm->addItem($oDescriptionGUI);
 
 1294                 $oOwnerGUI->
setValue($tmp_object[
'owner']);
 
 1295                 $oForm->addItem($oOwnerGUI);
 
 1299                 $oPathGUI->
setValue($tmp_object[
'path']);
 
 1300                 $oForm->addItem($oPathGUI);
 
 1303                 $oVendorsGUI = 
new ilSelectInputGUI($this->lng->txt(
'paya_vendor'), 
'vendor');
 
 1304                 $oVendorsGUI->
setOptions($this->__getVendors());
 
 1305                 $oForm->addItem($oVendorsGUI);
 
 1308                 $oForm->addCommandButton(
'addObject', $this->lng->txt(
'next'));
 
 1309                 $oForm->addCommandButton(
'showObjects', $this->lng->txt(
'cancel'));
 
 1311                 $this->tpl->setVariable(
'ADM_CONTENT', $oForm->getHTML());
 
 1317                 if(!$_GET[
'sell_id'])
 
 1321                         return $this->showObjectSelector();
 
 1323                 if(!(
int)
$_POST[
'vendor'])
 
 1330                 include_once 
'Services/Payment/classes/class.ilPaymentObject.php';
 
 1335                         if(!in_array(
'download', $check_subtypes))
 
 1336                                 $p_obj->setSubtype(
'download');
 
 1338                                 if(!in_array(
'upload', $check_subtypes))
 
 1339                                         $p_obj->setSubtype(
'upload');
 
 1349                                 return $this->showObjectSelector();
 
 1352                 $p_obj->setRefId((
int)$_GET[
'sell_id']);
 
 1353                 $p_obj->setStatus($p_obj->STATUS_NOT_BUYABLE);
 
 1354                 $p_obj->setPayMethod($p_obj->PAY_METHOD_NOT_SPECIFIED);
 
 1355                 $p_obj->setVendorId((
int)$_POST[
'vendor']);
 
 1356                 $p_obj->setTopicId((
int)$_POST[
'topic_id']);
 
 1357                 $p_obj->setVatId((
int)$_POST[
'vat_id']);
 
 1359                 $new_id = $p_obj->add();
 
 1363                         $_GET[
'pobject_id'] = $new_id;
 
 1364                         $this->editPrices();
 
 1370                         return $this->showObjects();
 
 1374         private function __getVendors()
 
 1376                 include_once 
'Services/Payment/classes/class.ilPaymentVendors.php';
 
 1380                 if(ilPaymentVendors::_isVendor($this->user_obj->getId()))
 
 1382                         $vendors[] = $this->user_obj->getId();
 
 1386                         $vendors = array_merge($vendors, $vend);
 
 1389                 foreach($vendors as $vendor)
 
 1393                         $options[$vendor] = $tmp_obj->getFullname() . 
' [' . $tmp_obj->getLogin() . 
']';
 
 1403                 $option[$this->pobject->STATUS_NOT_BUYABLE] = $this->lng->txt(
'paya_not_buyable');
 
 1404                 $option[$this->pobject->STATUS_BUYABLE]     = $this->lng->txt(
'paya_buyable');
 
 1405                 $option[$this->pobject->STATUS_EXPIRES]     = $this->lng->txt(
'paya_expires');
 
 1413                 $tbl->setTitle($this->lng->txt(
'objects'));
 
 1415                 $tbl->setId(
'tbl_objects');
 
 1416                 $tbl->setRowTemplate(
"tpl.shop_objects_row.html", 
"Services/Payment");
 
 1418                 $tbl->addColumn($this->lng->txt(
'title'), 
'title', 
'10%');
 
 1419                 $tbl->addColumn($this->lng->txt(
'status'), 
'status', 
'10%');
 
 1420                 $tbl->addColumn($this->lng->txt(
'paya_pay_method'), 
'pay_method', 
'10%');
 
 1421                 $tbl->addColumn($this->lng->txt(
'vat_rate'), 
'vat_rate', 
'15%');
 
 1422                 $tbl->addColumn($this->lng->txt(
'paya_vendor'), 
'vendor', 
'10%');
 
 1423                 $tbl->addColumn($this->lng->txt(
'paya_count_purchaser'), 
'purchasers', 
'10%');
 
 1424                 $tbl->addColumn(
'', 
'options', 
'10%');
 
 1426                 $tbl->setData($a_result_set);
 
 1428                 $this->tpl->setVariable(
'TABLE', $tbl->getHTML());
 
 1434         private function __getHTMLPath($a_ref_id)
 
 1440                 $path = $tree->getPathFull($a_ref_id);
 
 1444                 foreach(
$path as $data)
 
 1446                         $html .= $data[
'title'] . 
' > ';
 
 1448                 return substr($html, 0, -2);
 
 1453                 include_once 
'./Services/Payment/classes/class.ilPaymentObject.php';
 
 1460         public function editPrice()
 
 1462                 $this->tpl->addBlockfile(
'ADM_CONTENT', 
'adm_content', 
'tpl.main_view.html', 
'Services/Payment');
 
 1464                 $price_id = $_GET[
'price_id'] ? $_GET[
'price_id'] : 
$_POST[
'price_id'];
 
 1468                 include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
 1470                 $form->setFormAction($this->ctrl->getFormAction($this));
 
 1474                 $radio_group->setTitle($this->lng->txt(
'duration'));
 
 1475                 $radio_group->setRequired(
true);
 
 1476                 $radio_group->setValue($price[
'price_type']);
 
 1477                 $radio_group->setPostVar(
'price_type');
 
 1483                 $oDuration->
setTitle($this->lng->txt(
'paya_months'));
 
 1484                 $oDuration->setSize(
'20%');
 
 1485                 $oDuration->
setValue($price[
'duration']);
 
 1486                 $oDuration->setPostVar(
'duration_month');
 
 1489                 $radio_group->addOption($radio_option_1);
 
 1493                 $now_date = date(
'Y-m-d');
 
 1497                 $o_date_from->
setTitle($this->lng->txt(
'from'));
 
 1499                 $o_date_from->setDate(
new ilDate($price[
'duration_from'] == NULL ? $now_date : $price[
'duration_from'], 
IL_CAL_DATE));
 
 1500                 $o_date_from->setPostVar(
'duration_date_from');
 
 1505                 $o_date_until->setTitle($this->lng->txt(
'until'));
 
 1506                 $o_date_until->setDate(
new ilDate($price[
'duration_until'] == NULL ? $now_date : $price[
'duration_until'], 
IL_CAL_DATE));
 
 1507                 $o_date_until->setPostVar(
'duration_date_until');
 
 1508                 $radio_option_3->addSubItem($o_date_until);
 
 1510                 $radio_group->addOption($radio_option_3);
 
 1513                 $radio_group->addOption($radio_option_2);
 
 1515                 $form->addItem($radio_group);
 
 1518                 $oDescription = 
new ilTextAreaInputGUI($this->lng->txt(
'description'), 
'description');
 
 1520                 $oDescription->setCols(35);
 
 1521                 $oDescription->setValue($price[
'description']);
 
 1522                 $form->addItem($oDescription);
 
 1526                 $oPrice->setTitle($this->lng->txt(
'price_a'));
 
 1527                 $oPrice->allowDecimals(
true);
 
 1528                 $oPrice->setRequired(
true);
 
 1529                 $oPrice->setSize(
'20%');
 
 1530                 $oPrice->setValue($price[
'price']);
 
 1531                 include_once 
'./Services/Payment/classes/class.ilPaymentSettings.php';
 
 1534                 $oPrice->setInfo($genSet->get(
'currency_unit'));
 
 1535                 $oPrice->setPostVar(
'price');
 
 1536                 $oPrice->allowDecimals(
true);
 
 1537                 $form->addItem($oPrice);
 
 1540                 $oExtension = 
new ilCheckboxInputGUI($this->lng->txt(
'extension_price'), 
'extension');
 
 1541                 $oExtension->
setChecked((
int)$price[
'extension']);
 
 1542                 $form->addItem($oExtension);
 
 1545                 $o_hidden_1->setValue((
int)$_GET[
'pobject_id']);
 
 1546                 $o_hidden_1->setPostVar(
'pobject_id');
 
 1549                 $o_hidden_2->setValue((
int)$_GET[
'price_id']);
 
 1550                 $o_hidden_2->setPostVar(
'price_id');
 
 1552                 $form->addItem($o_hidden_1);
 
 1553                 $form->addItem($o_hidden_2);
 
 1555                 $form->addCommandButton(
'updatePrice', $this->lng->txt(
'save'));
 
 1556                 $form->addCommandButton(
'editPrices', $this->lng->txt(
'cancel'));
 
 1558                 $this->tpl->setVariable(
'FORM', $form->getHTML());
 
 1563                 include_once 
'./Services/Payment/classes/class.ilPaymentPrices.php';
 
 1565                 if(!$_GET[
'pobject_id'] && !
$_POST[
'pobject_id'])
 
 1569                         $this->showObjects();
 
 1572                 if(isset($_GET[
'pobject_id']))
 
 1574                         $pobject_id = (int)$_GET[
'pobject_id'];
 
 1578                         $pobject_id = (int)
$_POST[
'pobject_id'];
 
 1581                 if(!(
int)$_GET[
'price_id'] && !
$_POST[
'price_id'])
 
 1584                         return $this->editPrices();
 
 1586                 if(isset($_GET[
'price_id']))
 
 1588                         $price_id = (int)$_GET[
'price_id'];
 
 1592                         $price_id = (int)
$_POST[
'price_id'];
 
 1596                 switch(
$_POST[
'price_type'])
 
 1600                                 $po->setDuration(NULL);
 
 1601                                 $po->setDurationFrom(NULL);
 
 1602                                 $po->setDurationUntil(NULL);
 
 1603                                 $po->setUnlimitedDuration(1);
 
 1610                                 $po->setDuration(NULL);
 
 1612                                         $_POST[
'duration_date_from'][
'date'][
'y'] . 
'-' .
 
 1613                                                 $_POST[
'duration_date_from'][
'date'][
'm'] . 
'-' .
 
 1614                                                 $_POST[
'duration_date_from'][
'date'][
'd']));
 
 1616                                         $_POST[
'duration_date_until'][
'date'][
'y'] . 
'-' .
 
 1617                                                 $_POST[
'duration_date_until'][
'date'][
'm'] . 
'-' .
 
 1618                                                 $_POST[
'duration_date_until'][
'date'][
'd']));
 
 1624                                 $po->setDuration($_POST[
'duration_month']);
 
 1625                                 $po->setDurationFrom(NULL);
 
 1626                                 $po->setDurationUntil(NULL);
 
 1635                         $po->setExtension(1);
 
 1639                         $po->setExtension(0);
 
 1644                         $po->update($price_id);
 
 1646                         return $this->editPrices();
 
 1651                         return $this->editPrices();