voucherserie_groups.inc.php
Go to the documentation of this file.00001 <?php
00002
00003 $aColumns = array( 'container1' => array(
00004 array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
00005 array( 'oxid', 'oxgroups', 0, 0, 0 ),
00006 array( 'oxid', 'oxgroups', 0, 0, 1 ),
00007 ),
00008 'container2' => array(
00009 array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
00010 array( 'oxid', 'oxgroups', 0, 0, 0 ),
00011 array( 'oxid', 'oxobject2group', 0, 0, 1 ),
00012 )
00013 );
00017 class ajaxComponent extends ajaxListComponent
00018 {
00024 protected function _getQuery()
00025 {
00026
00027 $sGroupTable = getViewName('oxgroups');
00028
00029 $sVoucherId = oxConfig::getParameter( 'oxid' );
00030 $sSynchVoucherId = oxConfig::getParameter( 'synchoxid' );
00031
00032
00033 if ( !$sVoucherId) {
00034 $sQAdd = " from $sGroupTable where 1 ";
00035 } else {
00036 $sQAdd = " from $sGroupTable, oxobject2group where ";
00037 $sQAdd .= " oxobject2group.oxobjectid = '$sVoucherId' and $sGroupTable.oxid = oxobject2group.oxgroupsid ";
00038 }
00039
00040 if ( $sSynchVoucherId && $sSynchVoucherId != $sVoucherId) {
00041 $sQAdd .= " and $sGroupTable.oxid not in ( select $sGroupTable.oxid from $sGroupTable, oxobject2group where ";
00042 $sQAdd .= " oxobject2group.oxobjectid = '$sSynchVoucherId' and $sGroupTable.oxid = oxobject2group.oxgroupsid ) ";
00043 }
00044
00045 return $sQAdd;
00046 }
00047
00053 public function removegroupfromvoucher()
00054 {
00055 $aRemoveGroups = $this->_getActionIds( 'oxobject2group.oxid' );
00056 if ( oxConfig::getParameter( 'all' ) ) {
00057
00058 $sQ = $this->_addFilter( "delete oxobject2group.* ".$this->_getQuery() );
00059 oxDb::getDb()->Execute( $sQ );
00060
00061 } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00062 $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
00063 oxDb::getDb()->Execute( $sQ );
00064 }
00065 }
00066
00072 public function addgrouptovoucher()
00073 {
00074 $aChosenCat = $this->_getActionIds( 'oxgroups.oxid' );
00075 $soxId = oxConfig::getParameter( 'synchoxid');
00076
00077 if ( oxConfig::getParameter( 'all' ) ) {
00078 $sGroupTable = getViewName('oxgroups');
00079 $aChosenCat = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
00080 }
00081 if ( $soxId && $soxId != "-1" && is_array( $aChosenCat ) ) {
00082 foreach ( $aChosenCat as $sChosenCat) {
00083 $oNewGroup = oxNew( "oxobject2group" );
00084 $oNewGroup->oxobject2group__oxobjectid = new oxField($soxId);
00085 $oNewGroup->oxobject2group__oxgroupsid = new oxField($sChosenCat);
00086 $oNewGroup->save();
00087 }
00088 }
00089 }
00090 }