discount_categories.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', 'oxcategories', 1, 1, 0 ),
00005                                         array( 'oxdesc',  'oxcategories', 1, 1, 0 ),
00006                                         array( 'oxid',    'oxcategories', 0, 0, 1 )
00007                                         ),
00008                      'container2' => array(
00009                                         array( 'oxtitle', 'oxcategories', 1, 1, 0 ),
00010                                         array( 'oxdesc',  'oxcategories', 1, 1, 0 ),
00011                                         array( 'oxid',    'oxobject2discount', 0, 0, 1 ),
00012                                         array( 'oxid',    'oxcategories',      0, 0, 1 )
00013                                         ),
00014                    );
00018 class ajaxComponent extends ajaxListComponent
00019 {
00025     protected function _getQuery()
00026     {
00027         $sId      = oxConfig::getParameter( 'oxid' );
00028         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00029 
00030         $sCategoryTable = getViewName('oxcategories');
00031 
00032         // category selected or not ?
00033         if ( !$sId) {
00034             $sQAdd  = " from $sCategoryTable";
00035         } else {
00036             $sQAdd  = " from oxobject2discount, $sCategoryTable where $sCategoryTable.oxid=oxobject2discount.oxobjectid ";
00037             $sQAdd .= " and oxobject2discount.oxdiscountid = '$sId' and oxobject2discount.oxtype = 'oxcategories' ";
00038         }
00039 
00040         if ( $sSynchId && $sSynchId != $sId) {
00041             // dodger performance
00042             $sSubSelect  = " select $sCategoryTable.oxid from oxobject2discount, $sCategoryTable where $sCategoryTable.oxid=oxobject2discount.oxobjectid ";
00043             $sSubSelect .= " and oxobject2discount.oxdiscountid = '$sSynchId' and oxobject2discount.oxtype = 'oxcategories' ";
00044             if ( stristr( $sQAdd, 'where' ) === false )
00045                 $sQAdd .= ' where ';
00046             else
00047                 $sQAdd .= ' and ';
00048             $sQAdd .= " $sCategoryTable.oxid not in ( $sSubSelect ) ";
00049         }
00050 
00051         return $sQAdd;
00052     }
00053 
00059     public function removedisccat()
00060     {
00061         $aChosenCat = $this->_getActionIds( 'oxobject2discount.oxid' );
00062         if ( oxConfig::getParameter( 'all' ) ) {
00063 
00064             $sQ = $this->_addFilter( "delete oxobject2discount.* ".$this->_getQuery() );
00065             oxDb::getDb()->Execute( $sQ );
00066 
00067         } elseif ( is_array( $aChosenCat ) ) {
00068             $sQ = "delete from oxobject2discount where oxobject2discount.oxid in ('" . implode( "', '", $aChosenCat ) . "') ";
00069             oxDb::getDb()->Execute( $sQ );
00070         }
00071     }
00072 
00078     public function adddisccat()
00079     {
00080         $aChosenCat = $this->_getActionIds( 'oxcategories.oxid' );
00081         $soxId      = oxConfig::getParameter( 'synchoxid');
00082 
00083         if ( oxConfig::getParameter( 'all' ) ) {
00084             $sCategoryTable = getViewName('oxcategories');
00085             $aChosenCat = $this->_getAll( $this->_addFilter( "select $sCategoryTable.oxid ".$this->_getQuery() ) );
00086         }
00087         if ( $soxId && $soxId != "-1" && is_array( $aChosenCat ) ) {
00088             foreach ( $aChosenCat as $sChosenCat) {
00089                 $oObject2Discount = oxNew( "oxbase" );
00090                 $oObject2Discount->init( 'oxobject2discount' );
00091                 $oObject2Discount->oxobject2discount__oxdiscountid = new oxField($soxId);
00092                 $oObject2Discount->oxobject2discount__oxobjectid   = new oxField($sChosenCat);
00093                 $oObject2Discount->oxobject2discount__oxtype       = new oxField("oxcategories");
00094                 $oObject2Discount->save();
00095             }
00096         }
00097     }
00098 }

Generated on Tue Aug 18 09:21:04 2009 for OXID eShop CE by  doxygen 1.5.5