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 ".getViewName( "oxgroups", $this->_iEditLang ) );
00033 
00034         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00035         if ( $soxId != "-1" && isset( $soxId)) {
00036             // load object
00037             $oPayment = oxNew( "oxpayment" );
00038             $oPayment->loadInLang( $this->_iEditLang, $soxId );
00039 
00040             $oOtherLang = $oPayment->getAvailableInLangs();
00041             if (!isset($oOtherLang[$this->_iEditLang])) {
00042                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00043                 $oPayment->loadInLang( key($oOtherLang), $soxId );
00044             }
00045             $this->_aViewData["edit"] =  $oPayment;
00046 
00047             // remove already created languages
00048             $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00049             if ( count( $aLang))
00050                 $this->_aViewData["posslang"] = $aLang;
00051 
00052             foreach ( $oOtherLang as $id => $language) {
00053                 $oLang = new oxStdClass();
00054                 $oLang->sLangDesc = $language;
00055                 $oLang->selected = ($id == $this->_iEditLang);
00056                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00057             }
00058 
00059             // #708
00060             $this->_aViewData['aFieldNames'] = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00061         }
00062 
00063         if ( oxConfig::getParameter("aoc") ) {
00064 
00065             $aColumns = array();
00066             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00067             $this->_aViewData['oxajax'] = $aColumns;
00068 
00069             return "popups/payment_main.tpl";
00070         }
00071 
00072         $this->_aViewData["editor"] = $this->_generateTextEditor( "100%", 300, $oPayment, "oxpayments__oxlongdesc");
00073 
00074         return "payment_main.tpl";
00075     }
00076 
00082     public function save()
00083     {
00084 
00085         $soxId = $this->getEditObjectId();
00086         $aParams    = oxConfig::getParameter( "editval");
00087         // checkbox handling
00088         if ( !isset( $aParams['oxpayments__oxactive']))
00089             $aParams['oxpayments__oxactive'] = 0;
00090         if ( !isset( $aParams['oxpayments__oxchecked']))
00091             $aParams['oxpayments__oxchecked'] = 0;
00092 
00093         $oPayment = oxNew( "oxpayment" );
00094 
00095         if ( $soxId != "-1")
00096             $oPayment->loadInLang( $this->_iEditLang, $soxId );
00097         else
00098             $aParams['oxpayments__oxid'] = null;
00099         //$aParams = $oPayment->ConvertNameArray2Idx( $aParams);
00100 
00101         $oPayment->setLanguage(0);
00102         $oPayment->assign( $aParams);
00103 
00104         // setting add sum calculation rules
00105         $aRules = (array) oxConfig::getParameter( "oxpayments__oxaddsumrules" );
00106         $oPayment->oxpayments__oxaddsumrules = new oxField( array_sum( $aRules ) );
00107 
00108         //#708
00109         if ( !is_array( $this->_aFieldArray))
00110             $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00111         // build value
00112         $sValdesc = "";
00113         foreach ( $this->_aFieldArray as $oField)
00114             $sValdesc .= $oField->name . "__@@";
00115 
00116         $oPayment->oxpayments__oxvaldesc = new oxField( $sValdesc, oxField::T_RAW );
00117         $oPayment->setLanguage($this->_iEditLang);
00118         $oPayment->save();
00119 
00120         // set oxid if inserted
00121         $this->setEditObjectId( $oPayment->getId() );
00122     }
00123 
00129     public function saveinnlang()
00130     {
00131 
00132         $soxId = $this->getEditObjectId();
00133         $aParams    = oxConfig::getParameter( "editval");
00134 
00135             // shopid
00136             $sShopID = oxSession::getVar( "actshop");
00137             $aParams['oxpayments__oxshopid'] = $sShopID;
00138         $oObj = oxNew( "oxpayment" );
00139 
00140         if ( $soxId != "-1")
00141             $oObj->loadInLang( $this->_iEditLang, $soxId );
00142         else
00143             $aParams['oxpayments__oxid'] = null;
00144         //$aParams = $oObj->ConvertNameArray2Idx( $aParams);
00145 
00146         $oObj->setLanguage(0);
00147         $oObj->assign( $aParams);
00148 
00149         // apply new language
00150         $oObj->setLanguage( oxConfig::getParameter( "new_lang" ) );
00151         $oObj->save();
00152 
00153         // set oxid if inserted
00154         $this->setEditObjectId( $oObj->getId() );
00155     }
00156 
00162     public function delFields()
00163     {
00164 
00165         $oPayment = oxNew( "oxpayment" );
00166         if ( $oPayment->loadInLang( $this->_iEditLang, $this->getEditObjectId() ) ) {
00167 
00168             $aDelFields = oxConfig::getParameter( "aFields" );
00169             $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00170 
00171             if ( is_array( $aDelFields ) && count( $aDelFields ) ) {
00172                 foreach ( $aDelFields as $sDelField ) {
00173                     foreach ( $this->_aFieldArray as $sKey => $oField ) {
00174                         if ( $oField->name == $sDelField ) {
00175                             unset( $this->_aFieldArray[$sKey] );
00176                             break;
00177                         }
00178                     }
00179                 }
00180                 $this->save();
00181             }
00182         }
00183     }
00184 
00190     public function addField()
00191     {
00192 
00193         $oPayment = oxNew( "oxpayment" );
00194         if ( $oPayment->loadInLang( $this->_iEditLang, $this->getEditObjectId() ) ) {
00195 
00196             $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00197 
00198             $oField = new OxstdClass();
00199             $oField->name = oxConfig::getParameter( "sAddField" );
00200 
00201             $this->_aFieldArray[] = $oField;
00202 
00203             $this->save();
00204         }
00205     }
00206 
00207 }