Go to the documentation of this file.00001 <?php
00002
00006 class voucherserie_groups_ajax extends ajaxListComponent
00007 {
00013 protected $_aColumns = array( 'container1' => array(
00014 array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
00015 array( 'oxid', 'oxgroups', 0, 0, 0 ),
00016 array( 'oxid', 'oxgroups', 0, 0, 1 ),
00017 ),
00018 'container2' => array(
00019 array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
00020 array( 'oxid', 'oxgroups', 0, 0, 0 ),
00021 array( 'oxid', 'oxobject2group', 0, 0, 1 ),
00022 )
00023 );
00024
00030 protected function _getQuery()
00031 {
00032
00033 $sGroupTable = $this->_getViewName('oxgroups');
00034 $oDb = oxDb::getDb();
00035 $oConfig = oxRegistry::getConfig();
00036 $sVoucherId = $oConfig->getRequestParameter( 'oxid' );
00037 $sSynchVoucherId = $oConfig->getRequestParameter( 'synchoxid' );
00038
00039
00040 if ( !$sVoucherId) {
00041 $sQAdd = " from $sGroupTable where 1 ";
00042 } else {
00043 $sQAdd = " from $sGroupTable, oxobject2group where ";
00044 $sQAdd .= " oxobject2group.oxobjectid = ".$oDb->quote( $sVoucherId )." and $sGroupTable.oxid = oxobject2group.oxgroupsid ";
00045 }
00046
00047 if ( $sSynchVoucherId && $sSynchVoucherId != $sVoucherId) {
00048 $sQAdd .= " and $sGroupTable.oxid not in ( select $sGroupTable.oxid from $sGroupTable, oxobject2group where ";
00049 $sQAdd .= " oxobject2group.oxobjectid = ".$oDb->quote( $sSynchVoucherId )." and $sGroupTable.oxid = oxobject2group.oxgroupsid ) ";
00050 }
00051
00052 return $sQAdd;
00053 }
00054
00060 public function removeGroupFromVoucher()
00061 {
00062 $aRemoveGroups = $this->_getActionIds( 'oxobject2group.oxid' );
00063 if ( oxRegistry::getConfig()->getRequestParameter( 'all' ) ) {
00064
00065 $sQ = $this->_addFilter( "delete oxobject2group.* ".$this->_getQuery() );
00066 oxDb::getDb()->Execute( $sQ );
00067
00068 } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00069 $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
00070 oxDb::getDb()->Execute( $sQ );
00071 }
00072 }
00073
00079 public function addGroupToVoucher()
00080 {
00081 $oConfig = oxRegistry::getConfig();
00082 $aChosenCat = $this->_getActionIds( 'oxgroups.oxid' );
00083 $soxId = $oConfig->getRequestParameter( 'synchoxid');
00084
00085 if ( $oConfig->getRequestParameter( 'all' ) ) {
00086 $sGroupTable = $this->_getViewName('oxgroups');
00087 $aChosenCat = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
00088 }
00089 if ( $soxId && $soxId != "-1" && is_array( $aChosenCat ) ) {
00090 foreach ( $aChosenCat as $sChosenCat) {
00091 $oNewGroup = oxNew( "oxobject2group" );
00092 $oNewGroup->oxobject2group__oxobjectid = new oxField($soxId);
00093 $oNewGroup->oxobject2group__oxgroupsid = new oxField($sChosenCat);
00094 $oNewGroup->save();
00095 }
00096 }
00097 }
00098 }