deliveryset_payment_ajax.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class deliveryset_payment_ajax extends ajaxListComponent
00007 {
00013     protected $_aColumns = array( 'container1' => array(    // field , table,         visible, multilanguage, ident
00014                                         array( 'oxdesc',       'oxpayments', 1, 1, 0 ),
00015                                         array( 'oxaddsum',     'oxpayments', 1, 0, 0 ),
00016                                         array( 'oxaddsumtype', 'oxpayments', 0, 0, 0 ),
00017                                         array( 'oxid',         'oxpayments', 0, 0, 1 )
00018                                         ),
00019                                     'container2' => array(
00020                                         array( 'oxdesc',       'oxpayments', 1, 1, 0 ),
00021                                         array( 'oxaddsum',     'oxpayments', 1, 0, 0 ),
00022                                         array( 'oxaddsumtype', 'oxpayments', 0, 0, 0 ),
00023                                         array( 'oxid',  'oxobject2payment', 0, 0, 1 )
00024                                         )
00025                                 );
00026 
00032     protected function _getQuery()
00033     {
00034         $oDb = oxDb::getDb();
00035         $sId = $this->getConfig()->getRequestParameter( 'oxid' );
00036         $sSynchId = $this->getConfig()->getRequestParameter( 'synchoxid' );
00037 
00038         $sPayTable = $this->_getViewName('oxpayments');
00039 
00040         // category selected or not ?
00041         if ( !$sId) {
00042             $sQAdd = " from $sPayTable where 1 ";
00043         } else {
00044             $sQAdd  = " from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = ".$oDb->quote( $sId );
00045             $sQAdd .= " and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ";
00046         }
00047 
00048         if ( $sSynchId && $sSynchId != $sId) {
00049             $sQAdd .= "and $sPayTable.oxid not in ( select $sPayTable.oxid from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = ".$oDb->quote( $sSynchId );
00050             $sQAdd .= "and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ) ";
00051         }
00052 
00053         return $sQAdd;
00054     }
00055 
00061     public function removePayFromSet()
00062     {
00063         $aChosenCntr = $this->_getActionIds( 'oxobject2payment.oxid' );
00064         if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
00065 
00066             $sQ = $this->_addFilter( "delete oxobject2payment.* ".$this->_getQuery() );
00067             oxDb::getDb()->Execute( $sQ );
00068 
00069         } elseif ( is_array( $aChosenCntr ) ) {
00070             $sQ = "delete from oxobject2payment where oxobject2payment.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenCntr ) ) . ") ";
00071             oxDb::getDb()->Execute( $sQ );
00072         }
00073     }
00074 
00080     public function addPayToSet()
00081     {
00082         $aChosenSets = $this->_getActionIds( 'oxpayments.oxid' );
00083         $soxId       = $this->getConfig()->getRequestParameter( 'synchoxid');
00084 
00085         // adding
00086         if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
00087             $sPayTable = $this->_getViewName('oxpayments');
00088             $aChosenSets = $this->_getAll( $this->_addFilter( "select $sPayTable.oxid ".$this->_getQuery() ) );
00089         }
00090         if ( $soxId && $soxId != "-1" && is_array( $aChosenSets ) ) {
00091             $oDb = oxDb::getDb();
00092             foreach ( $aChosenSets as $sChosenSet) {
00093                 // check if we have this entry already in
00094                 $sID = $oDb->getOne("select oxid from oxobject2payment where oxpaymentid = " . $oDb->quote( $sChosenSet ) . "  and oxobjectid = ".$oDb->quote( $soxId )." and oxtype = 'oxdelset'", false, false);
00095                 if ( !isset( $sID) || !$sID) {
00096                     $oObject = oxNew( 'oxbase' );
00097                     $oObject->init( 'oxobject2payment' );
00098                     $oObject->oxobject2payment__oxpaymentid = new oxField($sChosenSet);
00099                     $oObject->oxobject2payment__oxobjectid  = new oxField($soxId);
00100                     $oObject->oxobject2payment__oxtype      = new oxField("oxdelset");
00101                     $oObject->save();
00102                 }
00103             }
00104         }
00105     }
00106 }