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 
00113         //#708
00114         if ( !is_array( $this->_aFieldArray))
00115             $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00116         // build value
00117         $sValdesc = "";
00118         foreach ( $this->_aFieldArray as $oField)
00119             $sValdesc .= $oField->name . "[email protected]@";
00120 
00121         $oPayment->oxpayments__oxvaldesc = new oxField( $sValdesc, oxField::T_RAW );
00122         $oPayment->setLanguage($this->_iEditLang);
00123         $oPayment->save();
00124 
00125         // set oxid if inserted
00126         $this->setEditObjectId( $oPayment->getId() );
00127     }
00128 
00134     public function saveinnlang()
00135     {
00136 
00137         $soxId = $this->getEditObjectId();
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         $oObj->setLanguage( oxConfig::getParameter( "new_lang" ) );
00156         $oObj->save();
00157 
00158         // set oxid if inserted
00159         $this->setEditObjectId( $oObj->getId() );
00160     }
00161 
00167     public function delFields()
00168     {
00169 
00170         $oPayment = oxNew( "oxpayment" );
00171         if ( $oPayment->loadInLang( $this->_iEditLang, $this->getEditObjectId() ) ) {
00172 
00173             $aDelFields = oxConfig::getParameter( "aFields" );
00174             $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00175 
00176             if ( is_array( $aDelFields ) && count( $aDelFields ) ) {
00177                 foreach ( $aDelFields as $sDelField ) {
00178                     foreach ( $this->_aFieldArray as $sKey => $oField ) {
00179                         if ( $oField->name == $sDelField ) {
00180                             unset( $this->_aFieldArray[$sKey] );
00181                             break;
00182                         }
00183                     }
00184                 }
00185                 $this->save();
00186             }
00187         }
00188     }
00189 
00195     public function addField()
00196     {
00197 
00198         $oPayment = oxNew( "oxpayment" );
00199         if ( $oPayment->loadInLang( $this->_iEditLang, $this->getEditObjectId() ) ) {
00200 
00201             $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value );
00202 
00203             $oField = new stdClass();
00204             $oField->name = oxConfig::getParameter( "sAddField" );
00205 
00206             $this->_aFieldArray[] = $oField;
00207 
00208             $this->save();
00209         }
00210     }
00211 
00212 }