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         $oDb = oxDb::getDb();
00029         $sId = oxConfig::getParameter( 'oxid' );
00030         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00031 
00032         $sPayTable = $this->_getViewName('oxpayments');
00033 
00034         // category selected or not ?
00035         if ( !$sId) {
00036             $sQAdd = " from $sPayTable where 1 ";
00037         } else {
00038             $sQAdd  = " from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = ".$oDb->quote( $sId );
00039             $sQAdd .= " and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ";
00040         }
00041 
00042         if ( $sSynchId && $sSynchId != $sId) {
00043             $sQAdd .= "and $sPayTable.oxid not in ( select $sPayTable.oxid from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = ".$oDb->quote( $sSynchId );
00044             $sQAdd .= "and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ) ";
00045         }
00046 
00047         return $sQAdd;
00048     }
00049 
00055     public function removepayfromset()
00056     {
00057         $aChosenCntr = $this->_getActionIds( 'oxobject2payment.oxid' );
00058         if ( oxConfig::getParameter( 'all' ) ) {
00059 
00060             $sQ = $this->_addFilter( "delete oxobject2payment.* ".$this->_getQuery() );
00061             oxDb::getDb()->Execute( $sQ );
00062 
00063         } elseif ( is_array( $aChosenCntr ) ) {
00064             $sQ = "delete from oxobject2payment where oxobject2payment.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenCntr ) ) . ") ";
00065             oxDb::getDb()->Execute( $sQ );
00066         }
00067     }
00068 
00074     public function addpaytoset()
00075     {
00076         $aChosenSets = $this->_getActionIds( 'oxpayments.oxid' );
00077         $soxId       = oxConfig::getParameter( 'synchoxid');
00078 
00079         // adding
00080         if ( oxConfig::getParameter( 'all' ) ) {
00081             $sPayTable = $this->_getViewName('oxpayments');
00082             $aChosenSets = $this->_getAll( $this->_addFilter( "select $sPayTable.oxid ".$this->_getQuery() ) );
00083         }
00084         if ( $soxId && $soxId != "-1" && is_array( $aChosenSets ) ) {
00085             $oDb = oxDb::getDb();
00086             foreach ( $aChosenSets as $sChosenSet) {
00087                 // check if we have this entry already in
00088                 $sID = $oDb->GetOne("select oxid from oxobject2payment where oxpaymentid = " . $oDb->quote( $sChosenSet ) . "  and oxobjectid = ".$oDb->quote( $soxId )." and oxtype = 'oxdelset'");
00089                 if ( !isset( $sID) || !$sID) {
00090                     $oObject = oxNew( 'oxbase' );
00091                     $oObject->init( 'oxobject2payment' );
00092                     $oObject->oxobject2payment__oxpaymentid = new oxField($sChosenSet);
00093                     $oObject->oxobject2payment__oxobjectid  = new oxField($soxId);
00094                     $oObject->oxobject2payment__oxtype      = new oxField("oxdelset");
00095                     $oObject->save();
00096                 }
00097             }
00098         }
00099     }
00100 }