payment_main.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Payment_Main extends oxAdminDetails
00009 {
00013     protected $_aFieldArray = null;
00014 
00022     public function render()
00023     {   $myConfig = $this->getConfig();
00024 
00025         parent::render();
00026 
00027         // remove itm from list
00028         unset( $this->_aViewData["sumtype"][2]);
00029 
00030             // all usergroups
00031             $oGroups = oxNew( "oxlist" );
00032             $oGroups->init( "oxgroups");
00033             $oGroups->selectString( "select * from oxgroups" );
00034         $soxId = oxConfig::getParameter( "oxid");
00035         // check if we right now saved a new entry
00036         $sSavedID = oxConfig::getParameter( "saved_oxid");
00037         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00038             $soxId = $sSavedID;
00039             oxSession::deleteVar( "saved_oxid");
00040             $this->_aViewData["oxid"] =  $soxId;
00041             // for reloading upper frame
00042             $this->_aViewData["updatelist"] =  "1";
00043         }
00044 
00045         if ( $soxId != "-1" && isset( $soxId)) {
00046             // load object
00047             $oPayment = oxNew( "oxpayment" );
00048             $oPayment->loadInLang( $this->_iEditLang, $soxId );
00049 
00050             $oOtherLang = $oPayment->getAvailableInLangs();
00051             if (!isset($oOtherLang[$this->_iEditLang])) {
00052                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00053                 $oPayment->loadInLang( key($oOtherLang), $soxId );
00054             }
00055             $this->_aViewData["edit"] =  $oPayment;
00056 
00057             // remove already created languages
00058             $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00059             if ( count( $aLang))
00060                 $this->_aViewData["posslang"] = $aLang;
00061 
00062             foreach ( $oOtherLang as $id => $language) {
00063                 $oLang = new oxStdClass();
00064                 $oLang->sLangDesc = $language;
00065                 $oLang->selected = ($id == $this->_iEditLang);
00066                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00067             }
00068 
00069             // #708
00070             $this->_aViewData['aFieldNames'] = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00071 
00072         }
00073 
00074         if ( oxConfig::getParameter("aoc") ) {
00075 
00076             $aColumns = array();
00077             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00078             $this->_aViewData['oxajax'] = $aColumns;
00079 
00080             return "popups/payment_main.tpl";
00081         }
00082         return "payment_main.tpl";
00083     }
00084 
00090     public function save()
00091     {
00092         $myConfig  = $this->getConfig();
00093 
00094 
00095         $soxId      = oxConfig::getParameter( "oxid");
00096         $aParams    = oxConfig::getParameter( "editval");
00097         // checkbox handling
00098         if ( !isset( $aParams['oxpayments__oxactive']))
00099             $aParams['oxpayments__oxactive'] = 0;
00100         if ( !isset( $aParams['oxpayments__oxchecked']))
00101             $aParams['oxpayments__oxchecked'] = 0;
00102 
00103         $oPayment = oxNew( "oxpayment" );
00104 
00105         if ( $soxId != "-1")
00106             $oPayment->loadInLang( $this->_iEditLang, $soxId );
00107         else
00108             $aParams['oxpayments__oxid'] = null;
00109         //$aParams = $oPayment->ConvertNameArray2Idx( $aParams);
00110 
00111         $oPayment->setLanguage(0);
00112         $oPayment->assign( $aParams);
00113 
00114         //#708
00115         if ( !is_array( $this->_aFieldArray))
00116             $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00117         // build value
00118         $sValdesc = "";
00119         foreach ( $this->_aFieldArray as $oField)
00120             $sValdesc .= $oField->name . "__@@";
00121 
00122         $oPayment->oxpayments__oxvaldesc = new oxField( $sValdesc, oxField::T_RAW );
00123         $oPayment->setLanguage($this->_iEditLang);
00124         $oPayment->save();
00125         $this->_aViewData["updatelist"] = "1";
00126 
00127         // set oxid if inserted
00128         if ( $soxId == "-1")
00129             oxSession::setVar( "saved_oxid", $oPayment->oxpayments__oxid->value);
00130     }
00131 
00137     public function saveinnlang()
00138     {
00139         $myConfig  = $this->getConfig();
00140 
00141 
00142         $soxId      = oxConfig::getParameter( "oxid");
00143         $aParams    = oxConfig::getParameter( "editval");
00144 
00145             // shopid
00146             $sShopID = oxSession::getVar( "actshop");
00147             $aParams['oxpayments__oxshopid'] = $sShopID;
00148         $oObj = oxNew( "oxpayment" );
00149 
00150         if ( $soxId != "-1")
00151             $oObj->loadInLang( $this->_iEditLang, $soxId );
00152         else
00153             $aParams['oxpayments__oxid'] = null;
00154         //$aParams = $oObj->ConvertNameArray2Idx( $aParams);
00155 
00156         $oObj->setLanguage(0);
00157         $oObj->assign( $aParams);
00158 
00159         // apply new language
00160         $sNewLanguage = oxConfig::getParameter( "new_lang");
00161         $oObj->setLanguage( $sNewLanguage);
00162         $oObj->save();
00163         $this->_aViewData["updatelist"] = "1";
00164 
00165         // set for reload
00166         oxSession::setVar( "new_lang", $sNewLanguage);
00167 
00168         // set oxid if inserted
00169         if ( $soxId == "-1")
00170             oxSession::setVar( "saved_oxid", $oObj->oxpayments__oxid->value);
00171     }
00172 
00178     public function delFields()
00179     {
00180         $myConfig = $this->getConfig();
00181 
00182 
00183         $soxId    = oxConfig::getParameter( "oxid");
00184         $oPayment = oxNew( "oxpayment" );
00185         $oPayment->loadInLang( $this->_iEditLang, $soxId );
00186 
00187         $aDelFields = oxConfig::getParameter("aFields");
00188         $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00189 
00190         if ( isset( $aDelFields) && count( $aDelFields)) {
00191             foreach ( $aDelFields as $sDelField) {
00192                 foreach ( $this->_aFieldArray as $key => $oField) {
00193                     if ( $oField->name == $sDelField) {
00194                         unset(  $this->_aFieldArray[$key]);
00195                         break;
00196                     }
00197                 }
00198             }
00199             $this->save();
00200         }
00201     }
00202 
00208     public function addField()
00209     {
00210         $myConfig = $this->getConfig();
00211 
00212 
00213         $soxId = oxConfig::getParameter( "oxid");
00214         $oPayment = oxNew( "oxpayment" );
00215         $oPayment->loadInLang( $this->_iEditLang, $soxId );
00216 
00217         $sAddField = oxConfig::getParameter("sAddField");
00218         $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00219 
00220         $oField = new stdClass();
00221         $oField->name = $sAddField;
00222 
00223         $this->_aFieldArray[] = $oField;
00224 
00225         $this->save();
00226     }
00227 
00228 }

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5