00001 <?php
00002
00003 $aColumns = array( 'container1' => array(
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
00043 if ( !$sOxid && $sSynchOxid ) {
00044 $sQAdd = " from $sArticleTable where 1 ";
00045 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':"and $sArticleTable.oxparentid = '' ";
00046 } else {
00047
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
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
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
00081 public function removediscart()
00082 {
00083 $aChosenArt = $this->_getActionIds( 'oxobject2discount.oxid' );
00084 if ( oxConfig::getParameter( 'all' ) ) {
00085
00086 $sQ = $this->_addFilter( "delete oxobject2discount.* ".$this->_getQuery() );
00087 oxDb::getDb()->Execute( $sQ );
00088
00089 } elseif ( is_array( $aChosenArt ) ) {
00090 $sQ = "delete from oxobject2discount where oxobject2discount.oxid in ('" . implode( "', '", $aChosenArt ) . "') ";
00091 oxDb::getDb()->Execute( $sQ );
00092 }
00093 }
00094
00100 public function adddiscart()
00101 {
00102 $aChosenArt = $this->_getActionIds( 'oxarticles.oxid' );
00103 $soxId = oxConfig::getParameter( 'synchoxid');
00104
00105
00106 if ( oxConfig::getParameter( 'all' ) ) {
00107 $sArticleTable = getViewName('oxarticles');
00108 $aChosenArt = $this->_getAll( $this->_addFilter( "select $sArticleTable.oxid ".$this->_getQuery() ) );
00109 }
00110 if ( $soxId && $soxId != "-1" && is_array( $aChosenArt ) ) {
00111 foreach ( $aChosenArt as $sChosenArt) {
00112 $oObject2Discount = oxNew( "oxbase" );
00113 $oObject2Discount->init( 'oxobject2discount' );
00114 $oObject2Discount->oxobject2discount__oxdiscountid = new oxField($soxId);
00115 $oObject2Discount->oxobject2discount__oxobjectid = new oxField($sChosenArt);
00116 $oObject2Discount->oxobject2discount__oxtype = new oxField("oxarticles");
00117 $oObject2Discount->save();
00118 }
00119 }
00120 }
00121
00128 protected function _getQueryCols()
00129 {
00130 $myConfig = $this->getConfig();
00131 $sQ = '';
00132 $blSep = false;
00133 $aVisiblecols = $this->_getVisibleColNames();
00134 foreach ( $aVisiblecols as $iCnt => $aCol ) {
00135 if ( $blSep )
00136 $sQ .= ', ';
00137 $sViewTable = getViewName( $aCol[1] );
00138
00139 $sCol = $aCol[3]?$aCol[0].oxLang::getInstance()->getLanguageTag():$aCol[0];
00140 if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00141 $sVarSelect = "$sViewTable.oxvarselect".oxLang::getInstance()->getLanguageTag();
00142 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00143 } else {
00144 $sQ .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00145 }
00146 $blSep = true;
00147 }
00148
00149 $aIdentCols = $this->_getIdentColNames();
00150 foreach ( $aIdentCols as $iCnt => $aCol ) {
00151 if ( $blSep )
00152 $sQ .= ', ';
00153
00154
00155 $sCol = $aCol[3]?$aCol[0].oxLang::getInstance()->getLanguageTag():$aCol[0];
00156 $sQ .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00157 }
00158
00159 return " $sQ ";
00160 }
00161
00162 }