deliveryset_payment.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,         visible, multilanguage, ident
00004                                         array( 'oxdesc',       'oxpayments', 1, 1, 0 ),
00005                                         array( 'oxaddsum',     'oxpayments', 1, 0, 0 ),
00006                                         array( 'oxaddsumtype', 'oxpayments', 0, 0, 0 ),
00007                                         array( 'oxid',         'oxpayments', 0, 0, 1 )
00008                                         ),
00009                      'container2' => array(
00010                                         array( 'oxdesc',       'oxpayments', 1, 1, 0 ),
00011                                         array( 'oxaddsum',     'oxpayments', 1, 0, 0 ),
00012                                         array( 'oxaddsumtype', 'oxpayments', 0, 0, 0 ),
00013                                         array( 'oxid',  'oxobject2payment', 0, 0, 1 )
00014                                         )
00015                     );
00019 class ajaxComponent extends ajaxListComponent
00020 {
00026     protected function _getQuery()
00027     {
00028         $sId      = oxConfig::getParameter( 'oxid' );
00029         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00030 
00031         $sPayTable = getViewName('oxpayments');
00032 
00033         // category selected or not ?
00034         if ( !$sId) {
00035             $sQAdd = " from $sPayTable where 1 ";
00036         } else {
00037             $sQAdd  = " from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = '$sId' ";
00038             $sQAdd .= " and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ";
00039         }
00040 
00041         if ( $sSynchId && $sSynchId != $sId) {
00042             $sQAdd .= "and $sPayTable.oxid not in ( select $sPayTable.oxid from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = '$sSynchId' ";
00043             $sQAdd .= "and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ) ";
00044         }
00045 
00046         return $sQAdd;
00047     }
00048 
00054     public function removepayfromset()
00055     {
00056         $aChosenCntr = $this->_getActionIds( 'oxobject2payment.oxid' );
00057         if ( oxConfig::getParameter( 'all' ) ) {
00058 
00059             $sQ = $this->_addFilter( "delete oxobject2payment.* ".$this->_getQuery() );
00060             oxDb::getDb()->Execute( $sQ );
00061 
00062         } elseif ( is_array( $aChosenCntr ) ) {
00063             $sQ = "delete from oxobject2payment where oxobject2payment.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenCntr ) ) . ") ";
00064             oxDb::getDb()->Execute( $sQ );
00065         }
00066     }
00067 
00073     public function addpaytoset()
00074     {
00075         $aChosenSets = $this->_getActionIds( 'oxpayments.oxid' );
00076         $soxId       = oxConfig::getParameter( 'synchoxid');
00077 
00078         // adding
00079         if ( oxConfig::getParameter( 'all' ) ) {
00080             $sPayTable = getViewName('oxpayments');
00081             $aChosenSets = $this->_getAll( $this->_addFilter( "select $sPayTable.oxid ".$this->_getQuery() ) );
00082         }
00083         if ( $soxId && $soxId != "-1" && is_array( $aChosenSets ) ) {
00084             $oDb = oxDb::getDb();
00085             foreach ( $aChosenSets as $sChosenSet) {
00086                 // check if we have this entry already in
00087                 $sID = $oDb->GetOne("select oxid from oxobject2payment where oxpaymentid = " . oxDb::getDb()->quote( $sChosenSet ) . "  and oxobjectid = '$soxId' and oxtype = 'oxdelset'");
00088                 if ( !isset( $sID) || !$sID) {
00089                     $oObject = oxNew( 'oxbase' );
00090                     $oObject->init( 'oxobject2payment' );
00091                     $oObject->oxobject2payment__oxpaymentid = new oxField($sChosenSet);
00092                     $oObject->oxobject2payment__oxobjectid  = new oxField($soxId);
00093                     $oObject->oxobject2payment__oxtype      = new oxField("oxdelset");
00094                     $oObject->save();
00095                 }
00096             }
00097         }
00098     }
00099 }