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', 'oxobject2payment', 0, 0, 1 )
00016 )
00017 );
00021 class ajaxComponent extends ajaxListComponent
00022 {
00028 protected function _getQuery()
00029 {
00030
00031 $sCountryTable = getViewName('oxcountry');
00032
00033 $sCountryId = oxConfig::getParameter( 'oxid' );
00034 $sSynchCountryId = oxConfig::getParameter( 'synchoxid' );
00035
00036
00037 if ( !$sCountryId) {
00038
00039 $sQAdd = " from $sCountryTable where $sCountryTable.oxactive = '1' ";
00040 } else {
00041
00042 $sQAdd = " from oxobject2payment left join $sCountryTable on $sCountryTable.oxid=oxobject2payment.oxobjectid ";
00043 $sQAdd .= "where $sCountryTable.oxactive = '1' and oxobject2payment.oxpaymentid = '$sCountryId' and oxobject2payment.oxtype = 'oxcountry' ";
00044 }
00045
00046 if ( $sSynchCountryId && $sSynchCountryId != $sCountryId ) {
00047 $sQAdd .= "and $sCountryTable.oxid not in ( ";
00048 $sQAdd .= "select $sCountryTable.oxid from oxobject2payment left join $sCountryTable on $sCountryTable.oxid=oxobject2payment.oxobjectid ";
00049 $sQAdd .= "where oxobject2payment.oxpaymentid = '$sSynchCountryId' and oxobject2payment.oxtype = 'oxcountry' ) ";
00050 }
00051
00052 return $sQAdd;
00053 }
00054
00060 public function addpaycountry()
00061 {
00062 $aChosenCntr = $this->_getActionIds( 'oxcountry.oxid' );
00063 $soxId = oxConfig::getParameter( 'synchoxid');
00064
00065 if ( oxConfig::getParameter( 'all' ) ) {
00066 $sCountryTable = getViewName('oxcountry');
00067 $aChosenCntr = $this->_getAll( $this->_addFilter( "select $sCountryTable.oxid ".$this->_getQuery() ) );
00068 }
00069 if ( $soxId && $soxId != "-1" && is_array( $aChosenCntr ) ) {
00070 foreach ( $aChosenCntr as $sChosenCntr) {
00071 $oObject2Payment = oxNew( 'oxbase' );
00072 $oObject2Payment->init( 'oxobject2payment' );
00073 $oObject2Payment->oxobject2payment__oxpaymentid = new oxField($soxId);
00074 $oObject2Payment->oxobject2payment__oxobjectid = new oxField($sChosenCntr);
00075 $oObject2Payment->oxobject2payment__oxtype = new oxField("oxcountry");
00076 $oObject2Payment->save();
00077 }
00078 }
00079 }
00080
00086 public function removepaycountry()
00087 {
00088 $aChosenCntr = $this->_getActionIds( 'oxobject2payment.oxid' );
00089 if ( oxConfig::getParameter( 'all' ) ) {
00090
00091 $sQ = $this->_addFilter( "delete oxobject2payment.* ".$this->_getQuery() );
00092 oxDb::getDb()->Execute( $sQ );
00093
00094 } elseif ( is_array( $aChosenCntr ) ) {
00095 $sQ = "delete from oxobject2payment where oxobject2payment.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenCntr ) ) . ") ";
00096 oxDb::getDb()->Execute( $sQ );
00097 }
00098 }
00099 }