deliveryset_country.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,         visible, multilanguage, ident
00004                                         array( 'oxtitle',     'oxcountry', 1, 1, 0 ),
00005                                         array( 'oxisoalpha2', 'oxcountry', 1, 0, 0 ),
00006                                         array( 'oxisoalpha3', 'oxcountry', 0, 0, 0 ),
00007                                         array( 'oxunnum3',    'oxcountry', 0, 0, 0 ),
00008                                         array( 'oxid',        'oxcountry', 0, 0, 1 )
00009                                         ),
00010                      'container2' => array(
00011                                         array( 'oxtitle',     'oxcountry', 1, 1, 0 ),
00012                                         array( 'oxisoalpha2', 'oxcountry', 1, 0, 0 ),
00013                                         array( 'oxisoalpha3', 'oxcountry', 0, 0, 0 ),
00014                                         array( 'oxunnum3',    'oxcountry', 0, 0, 0 ),
00015                                         array( 'oxid', 'oxobject2delivery', 0, 0, 1 )
00016                                         )
00017                     );
00021 class ajaxComponent extends ajaxListComponent
00022 {
00028     protected function _getQuery()
00029     {
00030         $oDb = oxDb::getDb();
00031         $sId = oxConfig::getParameter( 'oxid' );
00032         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00033 
00034         $sCountryTable = $this->_getViewName('oxcountry');
00035 
00036         // category selected or not ?
00037         if ( !$sId ) {
00038             $sQAdd  = " from $sCountryTable where $sCountryTable.oxactive = '1' ";
00039         } else {
00040             $sQAdd  = " from oxobject2delivery, $sCountryTable where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sId );
00041             $sQAdd .= " and oxobject2delivery.oxobjectid = $sCountryTable.oxid and oxobject2delivery.oxtype = 'oxdelset' ";
00042         }
00043 
00044         if ( $sSynchId && $sSynchId != $sId) {
00045             $sQAdd .= "and $sCountryTable.oxid not in ( select $sCountryTable.oxid from oxobject2delivery, $sCountryTable where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sSynchId );
00046             $sQAdd .= "and oxobject2delivery.oxobjectid = $sCountryTable.oxid and oxobject2delivery.oxtype = 'oxdelset' ) ";
00047         }
00048 
00049         return $sQAdd;
00050     }
00051 
00057     public function removecountryfromset()
00058     {
00059         $aChosenCntr = $this->_getActionIds( 'oxobject2delivery.oxid' );
00060         // removing all
00061         if ( oxConfig::getParameter( 'all' ) ) {
00062 
00063             $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
00064             oxDb::getDb()->Execute( $sQ );
00065 
00066         } elseif ( is_array( $aChosenCntr ) ) {
00067             $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenCntr ) ) . ") ";
00068             oxDb::getDb()->Execute( $sQ );
00069         }
00070     }
00071 
00077     public function addcountrytoset()
00078     {
00079         $aChosenCntr = $this->_getActionIds( 'oxcountry.oxid' );
00080         $soxId       = oxConfig::getParameter( 'synchoxid');
00081 
00082         // adding
00083         if ( oxConfig::getParameter( 'all' ) ) {
00084             $sCountryTable = $this->_getViewName('oxcountry');
00085             $aChosenCntr = $this->_getAll( $this->_addFilter( "select $sCountryTable.oxid ".$this->_getQuery() ) );
00086         }
00087 
00088         if ( $soxId && $soxId != "-1" && is_array( $aChosenCntr ) ) {
00089             foreach ( $aChosenCntr as $sChosenCntr) {
00090                 $oObject2Delivery = oxNew( 'oxbase' );
00091                 $oObject2Delivery->init( 'oxobject2delivery' );
00092                 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00093                 $oObject2Delivery->oxobject2delivery__oxobjectid   = new oxField($sChosenCntr);
00094                 $oObject2Delivery->oxobject2delivery__oxtype       = new oxField("oxdelset");
00095                 $oObject2Delivery->save();
00096             }
00097         }
00098     }
00099 }