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 ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
00049             if ( count( $aLang))
00050                 $this->_aViewData["posslang"] = $aLang;
00051 
00052             foreach ( $oOtherLang as $id => $language) {
00053                 $oLang = new stdClass();
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'] = oxRegistry::getUtils()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00061         }
00062 
00063         if ( oxConfig::getParameter("aoc") ) {
00064             $oPaymentMainAjax = oxNew( 'payment_main_ajax' );
00065             $this->_aViewData['oxajax'] = $oPaymentMainAjax->getColumns();
00066 
00067             return "popups/payment_main.tpl";
00068         }
00069 
00070         $this->_aViewData["editor"] = $this->_generateTextEditor( "100%", 300, $oPayment, "oxpayments__oxlongdesc");
00071 
00072         return "payment_main.tpl";
00073     }
00074 
00080     public function save()
00081     {
00082 
00083         parent::save();
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         // if sum eqals 0, show notice, that default value will be used.
00107         if ( empty($aRules) ) {
00108             $this->_aViewData["noticeoxaddsumrules"] = 1;
00109         }
00110         $oPayment->oxpayments__oxaddsumrules = new oxField( array_sum( $aRules ) );
00111 
00112         //#708
00113         if ( !is_array( $this->_aFieldArray))
00114             $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00115         // build value
00116         $sValdesc = "";
00117         foreach ( $this->_aFieldArray as $oField)
00118             $sValdesc .= $oField->name . "__@@";
00119 
00120         $oPayment->oxpayments__oxvaldesc = new oxField( $sValdesc, oxField::T_RAW );
00121         $oPayment->setLanguage($this->_iEditLang);
00122         $oPayment->save();
00123 
00124         // set oxid if inserted
00125         $this->setEditObjectId( $oPayment->getId() );
00126     }
00127 
00133     public function saveinnlang()
00134     {
00135 
00136         $soxId = $this->getEditObjectId();
00137         $aParams    = oxConfig::getParameter( "editval");
00138 
00139             // shopid
00140             $sShopID = oxSession::getVar( "actshop");
00141             $aParams['oxpayments__oxshopid'] = $sShopID;
00142         $oObj = oxNew( "oxpayment" );
00143 
00144         if ( $soxId != "-1")
00145             $oObj->loadInLang( $this->_iEditLang, $soxId );
00146         else
00147             $aParams['oxpayments__oxid'] = null;
00148         //$aParams = $oObj->ConvertNameArray2Idx( $aParams);
00149 
00150         $oObj->setLanguage(0);
00151         $oObj->assign( $aParams);
00152 
00153         // apply new language
00154         $oObj->setLanguage( oxConfig::getParameter( "new_lang" ) );
00155         $oObj->save();
00156 
00157         // set oxid if inserted
00158         $this->setEditObjectId( $oObj->getId() );
00159     }
00160 
00166     public function delFields()
00167     {
00168 
00169         $oPayment = oxNew( "oxpayment" );
00170         if ( $oPayment->loadInLang( $this->_iEditLang, $this->getEditObjectId() ) ) {
00171 
00172             $aDelFields = oxConfig::getParameter( "aFields" );
00173             $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00174 
00175             if ( is_array( $aDelFields ) && count( $aDelFields ) ) {
00176                 foreach ( $aDelFields as $sDelField ) {
00177                     foreach ( $this->_aFieldArray as $sKey => $oField ) {
00178                         if ( $oField->name == $sDelField ) {
00179                             unset( $this->_aFieldArray[$sKey] );
00180                             break;
00181                         }
00182                     }
00183                 }
00184                 $this->save();
00185             }
00186         }
00187     }
00188 
00194     public function addField()
00195     {
00196 
00197         $oPayment = oxNew( "oxpayment" );
00198         if ( $oPayment->loadInLang( $this->_iEditLang, $this->getEditObjectId() ) ) {
00199 
00200             $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00201 
00202             $oField = new stdClass();
00203             $oField->name = oxConfig::getParameter( "sAddField" );
00204 
00205             $this->_aFieldArray[] = $oField;
00206 
00207             $this->save();
00208         }
00209     }
00210 
00211 }