user_payment.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class User_Payment extends oxAdminDetails
00009 {
00014     protected $_blDelete = false;
00015 
00022     public function render()
00023     {
00024         parent::render();
00025 
00026         // all paymenttypes
00027         $oPaymentTypes = oxNew( "oxlist" );
00028         $oPaymentTypes->init( "oxpayment");
00029         $oPaymentTypes->getList();
00030 
00031         $soxId = oxConfig::getParameter( "oxid");
00032         if ( $soxId != "-1" && isset( $soxId)) {
00033             // load object
00034             $oUser = oxNew( "oxuser" );
00035             $oUser->load( $soxId);
00036 
00037             // load payment
00038             $soxPaymentId = oxConfig::getParameter( "oxpaymentid");
00039             if ( (!$soxPaymentId || $this->_blDelete) && isset( $oUser->oPayments[0]))
00040                 $soxPaymentId = $oUser->oPayments[0]->oxuserpayments__oxid->value;
00041             if ( $soxPaymentId != "-1" && isset( $soxPaymentId)) {
00042                 $oUserPayment = oxNew( "oxuserpayment" );
00043                 $oUserPayment->load( $soxPaymentId);
00044                 $sTemplate = $oUserPayment->oxuserpayments__oxvalue->value;
00045 
00046                 // generate selected paymenttype
00047                 foreach ( $oPaymentTypes as $oPayment ) {
00048                     if ( $oPayment->oxpayments__oxid->value == $oUserPayment->oxuserpayments__oxpaymentsid->value) {
00049                         $oPayment->selected = 1;
00050                         // if there are no values assigned we set default from paymenttype
00051                         if ( !$sTemplate )
00052                             $sTemplate = $oPayment->oxpayments__oxvaldesc->value;
00053                         break;
00054                     }
00055                 }
00056                 $oUserPayment->setDynValues( oxUtils::getInstance()->assignValuesFromText( $sTemplate ) );
00057                 $this->_aViewData["edit"] =  $oUserPayment;
00058 
00059             }
00060             if ( !$soxPaymentId)
00061                 $soxPaymentId = "-1";
00062             $this->_aViewData["oxpaymentid"]    = $soxPaymentId;
00063 
00064             $this->_aViewData["paymenttypes"]    = $oPaymentTypes;
00065 
00066             // generate selected
00067             $oUserPayments = $oUser->getUserPayments();
00068             foreach ( $oUserPayments as $oPayment ) {
00069                 if ( $oPayment->oxuserpayments__oxid->value == $soxPaymentId ) {
00070                     $oPayment->selected = 1;
00071                     break;
00072                 }
00073             }
00074 
00075             $this->_aViewData["edituser"] =  $oUser;
00076         }
00077 
00078         if (!$this->_allowAdminEdit($soxId))
00079             $this->_aViewData['readonly'] = true;
00080 
00081 
00082         return "user_payment.tpl";
00083     }
00084 
00090     public function save()
00091     {
00092 
00093         $soxId      = oxConfig::getParameter( "oxid");
00094         if (!$this->_allowAdminEdit($soxId))
00095             return;
00096 
00097         $aParams    = oxConfig::getParameter( "editval");
00098         $aDynvalues = oxConfig::getParameter( "dynvalue");
00099 
00100         if ( isset($aDynvalues)) {
00101             // store the dynvalues
00102             $aParams['oxuserpayments__oxvalue'] = oxUtils::getInstance()->assignValuesToText( $aDynvalues);
00103         }
00104 
00105         $oAdress = oxNew( "oxuserpayment" );
00106 
00107         if ( $aParams['oxuserpayments__oxid'] == "-1")
00108             $aParams['oxuserpayments__oxid'] = null;
00109         //$aParams = $oAdress->ConvertNameArray2Idx( $aParams);
00110         $oAdress->assign( $aParams);
00111         $oAdress->save();
00112     }
00113 
00119     public function delPayment()
00120     {
00121         $aParams = oxConfig::getParameter( "editval" );
00122         $soxId   = oxConfig::getParameter( "oxid" );
00123         if (!$this->_allowAdminEdit($soxId))
00124             return;
00125 
00126         $oAdress = oxNew( "oxuserpayment" );
00127 
00128         if ( $aParams['oxuserpayments__oxid'] != "-1") {
00129             $oAdress->load( $aParams['oxuserpayments__oxid']);
00130             $oAdress->delete();
00131             $this->_blDelete = true;
00132         }
00133     }
00134 }

Generated on Wed Apr 22 12:26:30 2009 for OXID eShop CE by  doxygen 1.5.5