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 ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang );
00040             if ( count( $aLang))
00041                 $this->_aViewData["posslang"] = $aLang;
00042 
00043             foreach ( $oOtherLang as $id => $language) {
00044                 $oLang= new stdClass();
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             $oPaymentCountryAjax = oxNew( 'payment_country_ajax' );
00053             $this->_aViewData['oxajax'] = $oPaymentCountryAjax->getColumns();
00054 
00055             return "popups/payment_country.tpl";
00056         }
00057         return "payment_country.tpl";
00058     }
00059 
00065     public function addcountry()
00066     {
00067         $sOxId = $this->getEditObjectId();
00068         $aChosenCntr = oxConfig::getParameter( "allcountries" );
00069         if ( isset( $sOxId ) && $sOxId != "-1" && is_array( $aChosenCntr ) ) {
00070             foreach ( $aChosenCntr as $sChosenCntr ) {
00071                 $oObject2Payment = oxNew( 'oxbase' );
00072                 $oObject2Payment->init( 'oxobject2payment' );
00073                 $oObject2Payment->oxobject2payment__oxpaymentid = new oxField( $sOxId );
00074                 $oObject2Payment->oxobject2payment__oxobjectid  = new oxField( $sChosenCntr );
00075                 $oObject2Payment->oxobject2payment__oxtype      = new oxField( "oxcountry" );
00076                 $oObject2Payment->save();
00077             }
00078         }
00079     }
00080 
00086     public function removecountry()
00087     {
00088         $sOxId = $this->getEditObjectId();
00089         $aChosenCntr = oxConfig::getParameter( "countries" );
00090         if ( isset( $sOxId ) && $sOxId != "-1" && is_array( $aChosenCntr ) ) {
00091             foreach ( $aChosenCntr as $sChosenCntr ) {
00092                 $oObject2Payment = oxNew( 'oxbase' );
00093                 $oObject2Payment->init( 'oxobject2payment' );
00094                 $oObject2Payment->delete( $sChosenCntr );
00095             }
00096         }
00097     }
00098 }