00001 <?php
00002
00003 $aColumns = array( 'container1' => array(
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', 'oxobject2discount', 0, 0, 1 )
00016 )
00017 );
00021 class ajaxComponent extends ajaxListComponent
00022 {
00028 protected function _getQuery()
00029 {
00030 $sCountryTable = $this->_getViewName('oxcountry');
00031 $oDb = oxDb::getDb();
00032 $sId = oxConfig::getParameter( 'oxid' );
00033 $sSynchId = oxConfig::getParameter( 'synchoxid' );
00034
00035
00036 if ( !$sId) {
00037 $sQAdd = " from $sCountryTable where $sCountryTable.oxactive = '1' ";
00038 } else {
00039 $sQAdd = " from oxobject2discount, $sCountryTable where $sCountryTable.oxid=oxobject2discount.oxobjectid ";
00040 $sQAdd .= "and oxobject2discount.oxdiscountid = ".$oDb->quote( $sId )." and oxobject2discount.oxtype = 'oxcountry' ";
00041 }
00042
00043 if ( $sSynchId && $sSynchId != $sId) {
00044 $sQAdd .= "and $sCountryTable.oxid not in ( select $sCountryTable.oxid from oxobject2discount, $sCountryTable where $sCountryTable.oxid=oxobject2discount.oxobjectid ";
00045 $sQAdd .= "and oxobject2discount.oxdiscountid = ".$oDb->quote( $sSynchId )." and oxobject2discount.oxtype = 'oxcountry' ) ";
00046 }
00047
00048 return $sQAdd;
00049 }
00050
00056 public function removedisccountry()
00057 {
00058 $aChosenCntr = $this->_getActionIds( 'oxobject2discount.oxid' );
00059 if ( oxConfig::getParameter( 'all' ) ) {
00060
00061 $sQ = $this->_addFilter( "delete oxobject2discount.* ".$this->_getQuery() );
00062 oxDb::getDb()->Execute( $sQ );
00063
00064 } elseif ( is_array( $aChosenCntr ) ) {
00065 $sQ = "delete from oxobject2discount where oxobject2discount.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenCntr ) ) . ") ";
00066 oxDb::getDb()->Execute( $sQ );
00067 }
00068 }
00069
00075 public function adddisccountry()
00076 {
00077 $aChosenCntr = $this->_getActionIds( 'oxcountry.oxid' );
00078 $soxId = oxConfig::getParameter( 'synchoxid');
00079
00080 if ( oxConfig::getParameter( 'all' ) ) {
00081 $sCountryTable = $this->_getViewName('oxcountry');
00082 $aChosenCntr = $this->_getAll( $this->_addFilter( "select $sCountryTable.oxid ".$this->_getQuery() ) );
00083 }
00084 if ( $soxId && $soxId != "-1" && is_array( $aChosenCntr ) ) {
00085 foreach ( $aChosenCntr as $sChosenCntr) {
00086 $oObject2Discount = oxNew( "oxbase" );
00087 $oObject2Discount->init( 'oxobject2discount' );
00088 $oObject2Discount->oxobject2discount__oxdiscountid = new oxField($soxId);
00089 $oObject2Discount->oxobject2discount__oxobjectid = new oxField($sChosenCntr);
00090 $oObject2Discount->oxobject2discount__oxtype = new oxField("oxcountry");
00091 $oObject2Discount->save();
00092 }
00093 }
00094 }
00095 }