discount_groups.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',  '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',     'oxobject2discount', 0, 0, 1 ),
00012                                         )
00013                     );
00017 class ajaxComponent extends ajaxListComponent
00018 {
00024     protected function _getQuery()
00025     {
00026         // active AJAX component
00027         $sGroupTable = getViewName('oxgroups');
00028 
00029         $sId      = oxConfig::getParameter( 'oxid' );
00030         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00031 
00032         // category selected or not ?
00033         if ( !$sId) {
00034             $sQAdd  = " from $sGroupTable where 1 ";
00035         } else {
00036             $sQAdd .= " from oxobject2discount, $sGroupTable where $sGroupTable.oxid=oxobject2discount.oxobjectid ";
00037             $sQAdd .= " and oxobject2discount.oxdiscountid = '$sId' and oxobject2discount.oxtype = 'oxgroups' ";
00038         }
00039 
00040         if ( $sSynchId && $sSynchId != $sId) {
00041             $sQAdd .= " and $sGroupTable.oxid not in ( select $sGroupTable.oxid from oxobject2discount, $sGroupTable where $sGroupTable.oxid=oxobject2discount.oxobjectid ";
00042             $sQAdd .= " and oxobject2discount.oxdiscountid = '$sSynchId' and oxobject2discount.oxtype = 'oxgroups' ) ";
00043         }
00044 
00045         return $sQAdd;
00046     }
00047 
00053     public function removediscgroup()
00054     {
00055         $aRemoveGroups = $this->_getActionIds( 'oxobject2discount.oxid' );
00056         if ( oxConfig::getParameter( 'all' ) ) {
00057 
00058             $sQ = $this->_addFilter( "delete oxobject2discount.* ".$this->_getQuery() );
00059             oxDb::getDb()->Execute( $sQ );
00060 
00061         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00062             $sQ = "delete from oxobject2discount where oxobject2discount.oxid in ('" . implode( "', '", $aRemoveGroups ) . "') ";
00063             oxDb::getDb()->Execute( $sQ );
00064         }
00065     }
00066 
00072     public function adddiscgroup()
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                 $oObject2Discount = oxNew( "oxbase" );
00084                 $oObject2Discount->init( 'oxobject2discount' );
00085                 $oObject2Discount->oxobject2discount__oxdiscountid = new oxField($soxId);
00086                 $oObject2Discount->oxobject2discount__oxobjectid   = new oxField($sChosenCat);
00087                 $oObject2Discount->oxobject2discount__oxtype       = new oxField("oxgroups");
00088                 $oObject2Discount->save();
00089             }
00090         }
00091     }
00092 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5