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     {
00024         parent::render();
00025 
00026         // remove itm from list
00027         unset( $this->_aViewData["sumtype"][2]);
00028 
00029             // all usergroups
00030             $oGroups = oxNew( "oxlist" );
00031             $oGroups->init( "oxgroups");
00032             $oGroups->selectString( "select * from oxgroups" );
00033 
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         if ( oxConfig::getParameter("aoc") ) {
00074 
00075             $aColumns = array();
00076             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00077             $this->_aViewData['oxajax'] = $aColumns;
00078 
00079             return "popups/payment_main.tpl";
00080         }
00081         return "payment_main.tpl";
00082     }
00083 
00089     public function save()
00090     {
00091 
00092         $soxId      = oxConfig::getParameter( "oxid");
00093         $aParams    = oxConfig::getParameter( "editval");
00094         // checkbox handling
00095         if ( !isset( $aParams['oxpayments__oxactive']))
00096             $aParams['oxpayments__oxactive'] = 0;
00097         if ( !isset( $aParams['oxpayments__oxchecked']))
00098             $aParams['oxpayments__oxchecked'] = 0;
00099 
00100         $oPayment = oxNew( "oxpayment" );
00101 
00102         if ( $soxId != "-1")
00103             $oPayment->loadInLang( $this->_iEditLang, $soxId );
00104         else
00105             $aParams['oxpayments__oxid'] = null;
00106         //$aParams = $oPayment->ConvertNameArray2Idx( $aParams);
00107 
00108         $oPayment->setLanguage(0);
00109         $oPayment->assign( $aParams);
00110 
00111         //#708
00112         if ( !is_array( $this->_aFieldArray))
00113             $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00114         // build value
00115         $sValdesc = "";
00116         foreach ( $this->_aFieldArray as $oField)
00117             $sValdesc .= $oField->name . "__@@";
00118 
00119         $oPayment->oxpayments__oxvaldesc = new oxField( $sValdesc, oxField::T_RAW );
00120         $oPayment->setLanguage($this->_iEditLang);
00121         $oPayment->save();
00122         $this->_aViewData["updatelist"] = "1";
00123 
00124         // set oxid if inserted
00125         if ( $soxId == "-1")
00126             oxSession::setVar( "saved_oxid", $oPayment->oxpayments__oxid->value);
00127     }
00128 
00134     public function saveinnlang()
00135     {
00136 
00137         $soxId      = oxConfig::getParameter( "oxid");
00138         $aParams    = oxConfig::getParameter( "editval");
00139 
00140             // shopid
00141             $sShopID = oxSession::getVar( "actshop");
00142             $aParams['oxpayments__oxshopid'] = $sShopID;
00143         $oObj = oxNew( "oxpayment" );
00144 
00145         if ( $soxId != "-1")
00146             $oObj->loadInLang( $this->_iEditLang, $soxId );
00147         else
00148             $aParams['oxpayments__oxid'] = null;
00149         //$aParams = $oObj->ConvertNameArray2Idx( $aParams);
00150 
00151         $oObj->setLanguage(0);
00152         $oObj->assign( $aParams);
00153 
00154         // apply new language
00155         $sNewLanguage = oxConfig::getParameter( "new_lang");
00156         $oObj->setLanguage( $sNewLanguage);
00157         $oObj->save();
00158         $this->_aViewData["updatelist"] = "1";
00159 
00160         // set for reload
00161         oxSession::setVar( "new_lang", $sNewLanguage);
00162 
00163         // set oxid if inserted
00164         if ( $soxId == "-1")
00165             oxSession::setVar( "saved_oxid", $oObj->oxpayments__oxid->value);
00166     }
00167 
00173     public function delFields()
00174     {
00175 
00176         $oPayment = oxNew( "oxpayment" );
00177         if ( $oPayment->loadInLang( $this->_iEditLang, oxConfig::getParameter( "oxid") ) ) {
00178 
00179             $aDelFields = oxConfig::getParameter( "aFields" );
00180             $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00181 
00182             if ( is_array( $aDelFields ) && count( $aDelFields ) ) {
00183                 foreach ( $aDelFields as $sDelField ) {
00184                     foreach ( $this->_aFieldArray as $sKey => $oField ) {
00185                         if ( $oField->name == $sDelField ) {
00186                             unset( $this->_aFieldArray[$sKey] );
00187                             break;
00188                         }
00189                     }
00190                 }
00191                 $this->save();
00192             }
00193         }
00194     }
00195 
00201     public function addField()
00202     {
00203 
00204         $oPayment = oxNew( "oxpayment" );
00205         if ( $oPayment->loadInLang( $this->_iEditLang, oxConfig::getParameter( "oxid" ) ) ) {
00206 
00207             $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00208 
00209             $oField = new OxstdClass();
00210             $oField->name = oxConfig::getParameter( "sAddField" );
00211 
00212             $this->_aFieldArray[] = $oField;
00213 
00214             $this->save();
00215         }
00216     }
00217 
00218 }