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