public function editDetails($a_show_confirm = false)
 {
     /** 
      * @var $ilToolbar ilToolbarGUI 
      */
     global $ilToolbar;
     include_once './Services/Payment/classes/class.ilPaymentSettings.php';
     /** @var $genSet ilPaymentSettings */
     $genSet = ilPaymentSettings::_getInstance();
     if (!(int) $_GET['pobject_id']) {
         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
         return $this->showObjects();
     }
     $this->__initPaymentObject((int) $_GET['pobject_id']);
     $this->ctrl->setParameter($this, 'pobject_id', (int) $_GET['pobject_id']);
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     /** @var $tmp_obj ilObject */
     $tmp_obj = ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
     if (is_object($tmp_obj)) {
         $trash = '';
         if (ilObject::_isInTrash($this->pobject->getRefId())) {
             $trash = ' (' . $this->lng->txt('object_deleted') . ')';
         }
         $tmp_object['title'] = $tmp_obj->getTitle() . '' . $trash;
         $tmp_object['type'] = $tmp_obj->getType();
     } else {
         $tmp_object['title'] = $this->lng->txt('object_not_found');
         $tmp_object['type'] = false;
     }
     if ($a_show_confirm) {
         include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
         $oConfirmationGUI = new ilConfirmationGUI();
         // set confirm/cancel commands
         $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, "performDelete"));
         $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_object"));
         $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "editDetails");
         $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDelete");
         $oConfirmationGUI->addItem('', $tmp_object['title'], $tmp_object['title']);
         $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHTML());
         return true;
     }
     $ilToolbar->addButton($this->lng->txt('paya_edit_details'), $this->ctrl->getLinkTarget($this, 'editDetails'));
     $ilToolbar->addButton($this->lng->txt('paya_edit_prices'), $this->ctrl->getLinkTarget($this, 'editPrices'));
     $ilToolbar->addButton($this->lng->txt('pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'edit'));
     include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
     $oForm = new ilPropertyFormGUI();
     $oForm->setFormAction($this->ctrl->getFormAction($this, 'updateDetails'));
     $oForm->setTitle($tmp_object['title']);
     if ($tmp_object['type']) {
         $oForm->setTitleIcon(ilUtil::getImagePath('icon_' . $tmp_object['type'] . '_b.png'));
     }
     // repository path
     $oPathGUI = new ilNonEditableValueGUI($this->lng->txt('path'));
     $oPathGUI->setValue($this->__getHTMLPath($this->pobject->getRefId()));
     $oForm->addItem($oPathGUI);
     switch ($tmp_object['type']) {
         case 'exc':
             $exc_subtype_option = array();
             $check_subtypes = ilPaymentObject::_checkExcSubtype($this->pobject->getRefId());
             if (!in_array('download', $check_subtypes) || $this->pobject->getSubtype() == 'download') {
                 $exc_subtype_option['download'] = $this->lng->txt('download');
             }
             if (!in_array('upload', $check_subtypes) || $this->pobject->getSubtype() == 'upload') {
                 $exc_subtype_option['upload'] = $this->lng->txt('upload');
             }
             $oExcSubtype = new ilSelectInputGUI($this->lng->txt('select_subtype'), 'exc_subtype');
             $oExcSubtype->setOptions($exc_subtype_option);
             $oExcSubtype->setValue($this->pobject->getSubtype());
             $oForm->addItem($oExcSubtype);
             break;
         default:
             break;
     }
     // number of purchasers
     $oPurchasersGUI = new ilNonEditableValueGUI($this->lng->txt('paya_count_purchaser'));
     $oPurchasersGUI->setValue(ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']));
     $oForm->addItem($oPurchasersGUI);
     // vendors
     $oVendorsGUI = new ilSelectInputGUI($this->lng->txt('paya_vendor'), 'vendor');
     $oVendorsGUI->setOptions($this->__getVendors());
     $oVendorsGUI->setValue($this->pobject->getVendorId());
     $oForm->addItem($oVendorsGUI);
     // status
     $oStatusGUI = new ilSelectInputGUI($this->lng->txt('status'), 'status');
     $oStatusGUI->setOptions($this->__getStatus());
     $oStatusGUI->setValue($this->pobject->getStatus());
     $oForm->addItem($oStatusGUI);
     // pay methods
     $oPayMethodsGUI = new ilSelectInputGUI($this->lng->txt('paya_pay_method'), 'pay_method');
     $PMoptions = ilPaymethods::getPayMethodsOptions('not_specified');
     $oPayMethodsGUI->setOptions($PMoptions);
     $oPayMethodsGUI->setValue($this->pobject->getPayMethod());
     $oForm->addItem($oPayMethodsGUI);
     // topics
     /** @var $shopTopicsObj ilShopTopics */
     $shopTopicsObj = ilShopTopics::_getInstance();
     $shopTopicsObj->read();
     if (is_array($topics = $shopTopicsObj->getTopics()) && count($topics)) {
         $oTopicsGUI = new ilSelectInputGUI($this->lng->txt('topic'), 'topic_id');
         include_once 'Services/Payment/classes/class.ilShopTopics.php';
         /** @var $shopTopicsObj ilShopTopics */
         $shopTopicsObj = ilShopTopics::_getInstance();
         $shopTopicsObj->read();
         $topic_options = array();
         $topic_options[''] = $this->lng->txt('please_choose');
         /** @var $oTopic ilShopTopic */
         foreach ($topics as $oTopic) {
             $topic_options[$oTopic->getId()] = $oTopic->getTitle();
         }
         $oTopicsGUI->setOptions($topic_options);
         $oTopicsGUI->setValue($this->pobject->getTopicId());
         $oForm->addItem($oTopicsGUI);
     }
     // vats
     $oShopVatsList = new ilShopVatsList();
     $oShopVatsList->read();
     if ($oShopVatsList->hasItems()) {
         $oVatsGUI = new ilSelectInputGUI($this->lng->txt('vat_rate'), 'vat_id');
         $vats_options = array();
         /** @var $oVAT ilShopVats */
         foreach ($oShopVatsList as $oVAT) {
             $vats_options[$oVAT->getId()] = ilShopUtils::_formatVAT($oVAT->getRate()) . ' -> ' . $oVAT->getTitle();
         }
         $oVatsGUI->setOptions($vats_options);
         $oVatsGUI->setValue($this->pobject->getVatId());
         $oForm->addItem($oVatsGUI);
     } else {
         $oVatsGUI = new ilNonEditableValueGUI($this->lng->txt('vat_rate'));
         $oVatsGUI->setValue($this->lng->txt('paya_no_vats_assigned'));
         $oForm->addItem($oVatsGUI);
     }
     $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail');
     $oFile = new ilFileDataShop($this->pobject->getPobjectId());
     if (($webpath_file = $oFile->getCurrentImageWebPath()) !== false) {
         $oThumbnail->setImage($webpath_file);
     }
     $oForm->addItem($oThumbnail);
     if ($genSet->get('use_shop_specials')) {
         // special object
         $oSpecial = new ilCheckboxInputGUI($this->lng->txt('special'), 'is_special');
         $oSpecial->setChecked((int) $this->pobject->getSpecial());
         $oSpecial->setInfo($this->lng->txt('special_info'));
         $oForm->addItem($oSpecial);
     }
     // buttons
     $oForm->addCommandButton('updateDetails', $this->lng->txt('save'));
     $oForm->addCommandButton('deleteObject', $this->lng->txt('delete'));
     $this->tpl->setVariable('FORM', $oForm->getHTML());
     return true;
 }
 public function vatsObject()
 {
     global $ilAccess;
     if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
         $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilErr->MESSAGE);
     }
     include_once 'Services/Table/classes/class.ilTable2GUI.php';
     $tbl = new ilTable2GUI($this, 'vats');
     $tbl->setId('pay_vats_tbl');
     $tbl->setFormAction($this->ctrl->getFormAction($this), 'createVat');
     $tbl->setTitle($this->lng->txt('payment_tax_rates'));
     $tbl->setRowTemplate('tpl.shop_vats_list_row.html', 'Services/Payment');
     $tbl->setDefaultOrderField('title');
     $tbl->addColumn('', 'check', '1%');
     $tbl->addColumn($this->lng->txt('vat_title'), 'vat_title', '33%');
     $tbl->addColumn($this->lng->txt('vat_rate'), 'vat_rate', '33%');
     $tbl->addColumn('', 'commands', '33%');
     $oShopVatsList = new ilShopVatsList();
     $oShopVatsList->read();
     $result = array();
     $_SESSION['count_vats'] = $oShopVatsList->getNumItems();
     if ($oShopVatsList->hasItems()) {
         $tbl->enable('select_all');
         $tbl->setSelectAllCheckbox('vat_id');
         $counter = 0;
         foreach ($oShopVatsList as $oVAT) {
             $result[$counter]['check'] = ilUtil::formCheckbox(0, 'vat_id[]', $oVAT->getId());
             $result[$counter]['vat_title'] = $oVAT->getTitle();
             $result[$counter]['vat_rate'] = ilShopUtils::_formatVAT((double) $oVAT->getRate());
             $this->ctrl->setParameter($this, 'vat_id', $oVAT->getId());
             $result[$counter]['edit_text'] = $this->lng->txt('edit');
             $result[$counter]['edit_url'] = $this->ctrl->getLinkTarget($this, 'editVat');
             $result[$counter]['delete_text'] = $this->lng->txt('delete');
             $result[$counter]['delete_url'] = $this->ctrl->getLinkTarget($this, 'confirmDeleteVat');
             $this->ctrl->clearParameters($this);
             ++$counter;
         }
         $tbl->addMultiCommand('confirmDeleteVat', $this->lng->txt('delete'));
     } else {
         $tbl->disable('header');
         $tbl->disable('footer');
         $tbl->setNoEntriesText($this->lng->txt('paya_no_vats_assigned'));
     }
     $tbl->setData($result);
     $tbl->addCommandButton('createVat', $this->lng->txt('paya_insert_vats'));
     $this->tpl->setContent($tbl->getHTML());
     return true;
 }
Beispiel #3
0
    /**
     * Saves a new vat dataset.
     * 
     * @access	public
     * @return	bool	Returns true if no error occured.
     * @throws   ilShopException
     */
    public function save()
    {
        if (!(int) $this->id) {
            if (ilShopVatsList::_isVATAlreadyCreated($this->rate)) {
                throw new ilShopException($this->lng->txt('payment_vat_already_created'));
            }
            $next_id = $this->db->nextId('payment_vats');
            $this->db->manipulateF('
				INSERT INTO payment_vats
				(vat_id, vat_title, vat_rate)
				VALUES (%s,%s,%s)', array('integer', 'text', 'float'), array($next_id, $this->getTitle(), $this->getRate()));
            return true;
        }
        throw new ilShopException($this->lng->txt('payment_cannot_save_existing_vat'));
    }