payment_country.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Payment_Country extends oxAdminDetails
00009 {
00010 
00018     public function render()
00019     {
00020         $myConfig = $this->getConfig();
00021         parent::render();
00022 
00023         // remove itm from list
00024         unset($this->_aViewData["sumtype"][2]);
00025 
00026         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00027         if ($soxId != "-1" && isset($soxId)) {
00028             // load object
00029             $oPayment = oxNew("oxpayment");
00030             $oPayment->loadInLang($this->_iEditLang, $soxId);
00031 
00032             $oOtherLang = $oPayment->getAvailableInLangs();
00033             if (!isset($oOtherLang[$this->_iEditLang])) {
00034                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00035                 $oPayment->loadInLang(key($oOtherLang), $soxId);
00036             }
00037             $this->_aViewData["edit"] = $oPayment;
00038 
00039             // remove already created languages
00040             $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
00041             if (count($aLang)) {
00042                 $this->_aViewData["posslang"] = $aLang;
00043             }
00044 
00045             foreach ($oOtherLang as $id => $language) {
00046                 $oLang = new stdClass();
00047                 $oLang->sLangDesc = $language;
00048                 $oLang->selected = ($id == $this->_iEditLang);
00049                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00050             }
00051         }
00052 
00053         if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
00054             $oPaymentCountryAjax = oxNew('payment_country_ajax');
00055             $this->_aViewData['oxajax'] = $oPaymentCountryAjax->getColumns();
00056 
00057             return "popups/payment_country.tpl";
00058         }
00059 
00060         return "payment_country.tpl";
00061     }
00062 
00066     public function addcountry()
00067     {
00068         $sOxId = $this->getEditObjectId();
00069         $aChosenCntr = oxRegistry::getConfig()->getRequestParameter("allcountries");
00070         if (isset($sOxId) && $sOxId != "-1" && is_array($aChosenCntr)) {
00071             foreach ($aChosenCntr as $sChosenCntr) {
00072                 $oObject2Payment = oxNew('oxbase');
00073                 $oObject2Payment->init('oxobject2payment');
00074                 $oObject2Payment->oxobject2payment__oxpaymentid = new oxField($sOxId);
00075                 $oObject2Payment->oxobject2payment__oxobjectid = new oxField($sChosenCntr);
00076                 $oObject2Payment->oxobject2payment__oxtype = new oxField("oxcountry");
00077                 $oObject2Payment->save();
00078             }
00079         }
00080     }
00081 
00085     public function removecountry()
00086     {
00087         $sOxId = $this->getEditObjectId();
00088         $aChosenCntr = oxRegistry::getConfig()->getRequestParameter("countries");
00089         if (isset($sOxId) && $sOxId != "-1" && is_array($aChosenCntr)) {
00090             foreach ($aChosenCntr as $sChosenCntr) {
00091                 $oObject2Payment = oxNew('oxbase');
00092                 $oObject2Payment->init('oxobject2payment');
00093                 $oObject2Payment->delete($sChosenCntr);
00094             }
00095         }
00096     }
00097 }