dyn_ipayment.php

Go to the documentation of this file.
00001 <?php
00005 require_once "shop_config.php";
00006 
00011 class dyn_ipayment extends Shop_Config
00012 {
00019     public function render()
00020     {
00021         parent::render();
00022 
00023         $this->_aViewData['oxid'] = $this->getConfig()->getShopId();
00024         return 'dyn_ipayment.tpl';
00025     }
00026 
00032     public function addPayment()
00033     {
00034         $aAddPayment = oxConfig::getParameter("allpayments");
00035         if ( is_array( $aAddPayment ) && count( $aAddPayment ) ) {
00036             $iShopId = $this->getConfig()->getShopId();
00037             foreach ( $aAddPayment as $sAdd ) {
00038                 $oNewGroup = oxNew( "oxbase" );
00039                 $oNewGroup->init( "oxobject2ipayment" );
00040                 $oNewGroup->oxobject2ipayment__oxpaymentid = new oxField( $sAdd );
00041                 $oNewGroup->oxobject2ipayment__oxshopid    = new oxField( $iShopId );
00042                 $oNewGroup->oxobject2ipayment__oxtype      = new oxField( "cc" );
00043                 $oNewGroup->save();
00044             }
00045         }
00046     }
00047 
00053     public function removePayment()
00054     {
00055         $aRemovePayment = oxConfig::getParameter( "addpayments" );
00056         if ( is_array( $aRemovePayment ) && count( $aRemovePayment ) ) {
00057             $myConfig = $this->getConfig();
00058             $oDb = oxDb::getDb();
00059             $sQ  = "delete from oxobject2ipayment where oxobject2ipayment.oxshopid='".$myConfig->getShopId()."' ";
00060             $sQ .= "and oxobject2ipayment.oxid in (";
00061             $blSep = false;
00062             foreach ( $aRemovePayment as $sRem ) {
00063                 $sQ .= ( ( $blSep ) ? ", ":"" ) . " ".$oDb->quote( $sRem );
00064                 $blSep = true;
00065             }
00066             $sQ .= ")";
00067             $oDb->execute( $sQ );
00068         }
00069     }
00070 
00076     public function savePayment()
00077     {
00078         $myConfig = $this->getConfig();
00079         $sActPayment = oxConfig::getParameter("oxpaymentid");
00080         $aParams     = oxConfig::getParameter("editval");
00081 
00082         $oActPayment = oxNew( "oxbase" );
00083         $oActPayment->init( "oxobject2ipayment" );
00084 
00085         $sQ  = "select * from oxobject2ipayment where oxobject2ipayment.oxshopid='".$myConfig->getShopId()."'
00086                 and oxobject2ipayment.oxid = ".oxDb::getDb()->quote( $sActPayment );
00087 
00088         if ( $oActPayment->assignRecord( $sQ ) && is_array( $aParams ) ) {
00089             foreach ( $aParams as $sField => $sValue ) {
00090                 if ( isset( $oActPayment->$sField ) ) {
00091                     $oActPayment->$sField = new oxField($sValue);
00092                 }
00093             }
00094             $oActPayment->save();
00095         }
00096     }
00097 
00103     public function setFilter()
00104     {
00105         $this->blfiltering = true;
00106     }
00107 
00113     public function getViewId()
00114     {
00115         return 'dyn_interface';
00116     }
00117 }