00001 <?php
00002
00009 class Payment_Country extends oxAdminDetails
00010 {
00018 public function render()
00019 {
00020 $myConfig = $this->getConfig();
00021 parent::render();
00022
00023
00024 unset( $this->_aViewData["sumtype"][2]);
00025
00026 $soxId = oxConfig::getParameter( "oxid");
00027
00028 $sSavedID = oxConfig::getParameter( "saved_oxid");
00029 if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00030 $soxId = $sSavedID;
00031 oxSession::deleteVar( "saved_oxid");
00032 $this->_aViewData["oxid"] = $soxId;
00033
00034 $this->_aViewData["updatelist"] = "1";
00035 }
00036
00037 if ( $soxId != "-1" && isset( $soxId)) {
00038
00039 $oPayment = oxNew( "oxpayment" );
00040 $oPayment->loadInLang( $this->_iEditLang, $soxId );
00041
00042 $oOtherLang = $oPayment->getAvailableInLangs();
00043 if (!isset($oOtherLang[$this->_iEditLang])) {
00044
00045 $oPayment->loadInLang( key($oOtherLang), $soxId );
00046 }
00047 $this->_aViewData["edit"] = $oPayment;
00048
00049
00050 $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang );
00051 if ( count( $aLang))
00052 $this->_aViewData["posslang"] = $aLang;
00053
00054 foreach ( $oOtherLang as $id => $language) {
00055 $oLang= new oxStdClass();
00056 $oLang->sLangDesc = $language;
00057 $oLang->selected = ($id == $this->_iEditLang);
00058 $this->_aViewData["otherlang"][$id] = clone $oLang;
00059 }
00060 }
00061
00062 if ( oxConfig::getParameter("aoc") ) {
00063
00064 $aColumns = array();
00065 include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00066 $this->_aViewData['oxajax'] = $aColumns;
00067
00068 return "popups/payment_country.tpl";
00069 }
00070 return "payment_country.tpl";
00071 }
00072
00078 public function addcountry()
00079 {
00080 $soxId = oxConfig::getParameter( "oxid");
00081 $aChosenCntr = oxConfig::getParameter( "allcountries");
00082
00083 if ( isset( $soxId) && $soxId != "-1" && isset( $aChosenCntr) && $aChosenCntr) {
00084 foreach ( $aChosenCntr as $sChosenCntr) {
00085 $oObject2Payment = oxNew( 'oxbase' );
00086 $oObject2Payment->init( 'oxobject2payment' );
00087 $oObject2Payment->oxobject2payment__oxpaymentid = new oxField($soxId);
00088 $oObject2Payment->oxobject2payment__oxobjectid = new oxField($sChosenCntr);
00089 $oObject2Payment->oxobject2payment__oxtype = new oxField("oxcountry");
00090 $oObject2Payment->save();
00091 }
00092 }
00093 }
00094
00100 public function removecountry()
00101 {
00102 $soxId = oxConfig::getParameter( "oxid");
00103 $aChosenCntr = oxConfig::getParameter( "countries");
00104
00105 if ( isset( $soxId) && $soxId != "-1" && isset( $aChosenCntr) && $aChosenCntr) {
00106 foreach ( $aChosenCntr as $sChosenCntr) {
00107 $oObject2Payment = oxNew( 'oxbase' );
00108 $oObject2Payment->init( 'oxobject2payment' );
00109 $oObject2Payment->delete( $sChosenCntr );
00110 }
00111 }
00112 }
00113 }