discount_articles.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,         visible, multilanguage, ident
00004                                         array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00005                                         array( 'oxtitle',  'oxarticles', 1, 1, 0 ),
00006                                         array( 'oxean',    'oxarticles', 1, 0, 0 ),
00007                                         array( 'oxprice',  'oxarticles', 0, 0, 0 ),
00008                                         array( 'oxstock',  'oxarticles', 0, 0, 0 ),
00009                                         array( 'oxid',     'oxarticles', 0, 0, 1 )
00010                                         ),
00011                      'container2' => array(
00012                                         array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00013                                         array( 'oxtitle',  'oxarticles', 1, 1, 0 ),
00014                                         array( 'oxean',    'oxarticles', 1, 0, 0 ),
00015                                         array( 'oxprice',  'oxarticles', 0, 0, 0 ),
00016                                         array( 'oxstock',  'oxarticles', 0, 0, 0 ),
00017                                         array( 'oxid',     'oxobject2discount', 0, 0, 1 )
00018                                         )
00019                     );
00020 
00024 class ajaxComponent extends ajaxListComponent
00025 {
00031     protected function _getQuery()
00032     {
00033         $myConfig = $this->getConfig();
00034 
00035         $sArticleTable = getViewName('oxarticles');
00036         $sCatTable     = getViewName('oxcategories');
00037         $sO2CView      = getViewName('oxobject2category');
00038 
00039         $sOxid      = oxConfig::getParameter( 'oxid' );
00040         $sSynchOxid = oxConfig::getParameter( 'synchoxid' );
00041 
00042         // category selected or not ?
00043         if ( !$sOxid && $sSynchOxid ) {
00044             $sQAdd  = " from $sArticleTable where 1 ";
00045             $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':"and $sArticleTable.oxparentid = '' ";
00046         } else {
00047             // selected category ?
00048             if ( $sSynchOxid && $sOxid != $sSynchOxid ) {
00049                 $sQAdd  = " from $sO2CView left join $sArticleTable on ";
00050                 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?"($sArticleTable.oxid=$sO2CView.oxobjectid or $sArticleTable.oxparentid=$sO2CView.oxobjectid)":" $sArticleTable.oxid=$sO2CView.oxobjectid ";
00051                 $sQAdd .= " where $sO2CView.oxcatnid = '$sOxid' and $sArticleTable.oxid is not null ";
00052 
00053                 // resetting
00054                 $sId = null;
00055             } else {
00056                 $sQAdd  = " from oxobject2discount, $sArticleTable where $sArticleTable.oxid=oxobject2discount.oxobjectid ";
00057                 $sQAdd .= " and oxobject2discount.oxdiscountid = '$sOxid' and oxobject2discount.oxtype = 'oxarticles' ";
00058             }
00059         }
00060 
00061         if ( $sSynchOxid && $sSynchOxid != $sOxid) {
00062             // dodger performance
00063             $sSubSelect .= " select $sArticleTable.oxid from oxobject2discount, $sArticleTable where $sArticleTable.oxid=oxobject2discount.oxobjectid ";
00064             $sSubSelect .= " and oxobject2discount.oxdiscountid = '$sSynchOxid' and oxobject2discount.oxtype = 'oxarticles' ";
00065 
00066             if ( stristr( $sQAdd, 'where' ) === false )
00067                 $sQAdd .= ' where ';
00068             else
00069                 $sQAdd .= ' and ';
00070             $sQAdd .= " $sArticleTable.oxid not in ( $sSubSelect ) ";
00071         }
00072 
00073         return $sQAdd;
00074     }
00075 
00083     protected function _getDataQuery( $sQ )
00084     {
00085         $sArtTable = getViewName('oxarticles');
00086         $sQ = parent::_getDataQuery( $sQ );
00087 
00088         // display variants or not ?
00089         $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00090         return $sQ;
00091     }
00092 
00098     public function removediscart()
00099     {
00100         $aChosenArt = $this->_getActionIds( 'oxobject2discount.oxid' );
00101         if ( oxConfig::getParameter( 'all' ) ) {
00102 
00103             $sQ = $this->_addFilter( "delete oxobject2discount.* ".$this->_getQuery() );
00104             oxDb::getDb()->Execute( $sQ );
00105 
00106         } elseif ( is_array( $aChosenArt ) ) {
00107             $sQ = "delete from oxobject2discount where oxobject2discount.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenArt ) ) . ") ";
00108             oxDb::getDb()->Execute( $sQ );
00109         }
00110     }
00111 
00117     public function adddiscart()
00118     {
00119         $aChosenArt = $this->_getActionIds( 'oxarticles.oxid' );
00120         $soxId      = oxConfig::getParameter( 'synchoxid');
00121 
00122         // adding
00123         if ( oxConfig::getParameter( 'all' ) ) {
00124             $sArticleTable = getViewName('oxarticles');
00125             $aChosenArt = $this->_getAll( $this->_addFilter( "select $sArticleTable.oxid ".$this->_getQuery() ) );
00126         }
00127         if ( $soxId && $soxId != "-1" && is_array( $aChosenArt ) ) {
00128             foreach ( $aChosenArt as $sChosenArt) {
00129                 $oObject2Discount = oxNew( "oxbase" );
00130                 $oObject2Discount->init( 'oxobject2discount' );
00131                 $oObject2Discount->oxobject2discount__oxdiscountid = new oxField($soxId);
00132                 $oObject2Discount->oxobject2discount__oxobjectid   = new oxField($sChosenArt);
00133                 $oObject2Discount->oxobject2discount__oxtype       = new oxField("oxarticles");
00134                 $oObject2Discount->save();
00135             }
00136         }
00137     }
00138 
00145     protected function _getQueryCols()
00146     {
00147         $myConfig = $this->getConfig();
00148         $sLangTag = oxLang::getInstance()->getLanguageTag();
00149 
00150         $sQ = '';
00151         $blSep = false;
00152         $aVisiblecols = $this->_getVisibleColNames();
00153         foreach ( $aVisiblecols as $iCnt => $aCol ) {
00154             if ( $blSep )
00155                 $sQ .= ', ';
00156             $sViewTable = getViewName( $aCol[1] );
00157             // multilanguage
00158             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00159             if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00160                 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00161                 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00162             } else {
00163                 $sQ  .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00164             }
00165             $blSep = true;
00166         }
00167 
00168         $aIdentCols = $this->_getIdentColNames();
00169         foreach ( $aIdentCols as $iCnt => $aCol ) {
00170             if ( $blSep )
00171                 $sQ .= ', ';
00172 
00173             // multilanguage
00174             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00175             $sQ  .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00176         }
00177 
00178         return " $sQ ";
00179     }
00180 
00181 }

Generated on Tue Sep 29 16:45:12 2009 for OXID eShop CE by  doxygen 1.5.5