payment_country.php

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