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         parent::save();
00086 
00087         $soxId = $this->getEditObjectId();
00088         $aParams    = oxConfig::getParameter( "editval");
00089         // checkbox handling
00090         if ( !isset( $aParams['oxpayments__oxactive']))
00091             $aParams['oxpayments__oxactive'] = 0;
00092         if ( !isset( $aParams['oxpayments__oxchecked']))
00093             $aParams['oxpayments__oxchecked'] = 0;
00094 
00095         $oPayment = oxNew( "oxpayment" );
00096 
00097         if ( $soxId != "-1")
00098             $oPayment->loadInLang( $this->_iEditLang, $soxId );
00099         else
00100             $aParams['oxpayments__oxid'] = null;
00101         //$aParams = $oPayment->ConvertNameArray2Idx( $aParams);
00102 
00103         $oPayment->setLanguage(0);
00104         $oPayment->assign( $aParams);
00105 
00106         // setting add sum calculation rules
00107         $aRules = (array) oxConfig::getParameter( "oxpayments__oxaddsumrules" );
00108         $oPayment->oxpayments__oxaddsumrules = new oxField( array_sum( $aRules ) );
00109 
00110         //#708
00111         if ( !is_array( $this->_aFieldArray))
00112             $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00113         // build value
00114         $sValdesc = "";
00115         foreach ( $this->_aFieldArray as $oField)
00116             $sValdesc .= $oField->name . "__@@";
00117 
00118         $oPayment->oxpayments__oxvaldesc = new oxField( $sValdesc, oxField::T_RAW );
00119         $oPayment->setLanguage($this->_iEditLang);
00120         $oPayment->save();
00121 
00122         // set oxid if inserted
00123         $this->setEditObjectId( $oPayment->getId() );
00124     }
00125 
00131     public function saveinnlang()
00132     {
00133 
00134         $soxId = $this->getEditObjectId();
00135         $aParams    = oxConfig::getParameter( "editval");
00136 
00137             // shopid
00138             $sShopID = oxSession::getVar( "actshop");
00139             $aParams['oxpayments__oxshopid'] = $sShopID;
00140         $oObj = oxNew( "oxpayment" );
00141 
00142         if ( $soxId != "-1")
00143             $oObj->loadInLang( $this->_iEditLang, $soxId );
00144         else
00145             $aParams['oxpayments__oxid'] = null;
00146         //$aParams = $oObj->ConvertNameArray2Idx( $aParams);
00147 
00148         $oObj->setLanguage(0);
00149         $oObj->assign( $aParams);
00150 
00151         // apply new language
00152         $oObj->setLanguage( oxConfig::getParameter( "new_lang" ) );
00153         $oObj->save();
00154 
00155         // set oxid if inserted
00156         $this->setEditObjectId( $oObj->getId() );
00157     }
00158 
00164     public function delFields()
00165     {
00166 
00167         $oPayment = oxNew( "oxpayment" );
00168         if ( $oPayment->loadInLang( $this->_iEditLang, $this->getEditObjectId() ) ) {
00169 
00170             $aDelFields = oxConfig::getParameter( "aFields" );
00171             $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00172 
00173             if ( is_array( $aDelFields ) && count( $aDelFields ) ) {
00174                 foreach ( $aDelFields as $sDelField ) {
00175                     foreach ( $this->_aFieldArray as $sKey => $oField ) {
00176                         if ( $oField->name == $sDelField ) {
00177                             unset( $this->_aFieldArray[$sKey] );
00178                             break;
00179                         }
00180                     }
00181                 }
00182                 $this->save();
00183             }
00184         }
00185     }
00186 
00192     public function addField()
00193     {
00194 
00195         $oPayment = oxNew( "oxpayment" );
00196         if ( $oPayment->loadInLang( $this->_iEditLang, $this->getEditObjectId() ) ) {
00197 
00198             $this->_aFieldArray = oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00199 
00200             $oField = new OxstdClass();
00201             $oField->name = oxConfig::getParameter( "sAddField" );
00202 
00203             $this->_aFieldArray[] = $oField;
00204 
00205             $this->save();
00206         }
00207     }
00208 
00209 }