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', 'oxarticles', 0, 0, 1 )
00018 )
00019 );
00020
00024 class ajaxComponent extends ajaxListComponent
00025 {
00031 protected function _getQuery()
00032 {
00033 $myConfig = $this->getConfig();
00034
00035
00036 $sArtTable = getViewName('oxarticles');
00037 $sO2CView = getViewName('oxobject2category');
00038
00039 $sVendorId = oxConfig::getParameter( 'oxid' );
00040 $sSynchVendorId = oxConfig::getParameter( 'synchoxid' );
00041
00042
00043 if ( !$sVendorId ) {
00044
00045 $sQAdd = ' from '.$sArtTable.' where '.$sArtTable.'.oxshopid="'.$myConfig->getShopId().'" and 1 ';
00046 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' ) ?'':" and $sArtTable.oxparentid = '' and $sArtTable.oxvendorid != '$sSynchVendorId' ";
00047 } else {
00048
00049 if ( $sSynchVendorId && $sSynchVendorId != $sVendorId ) {
00050 $sQAdd = " from $sO2CView left join $sArtTable on ";
00051 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArtTable.oxid = $sO2CView.oxobjectid or $sArtTable.oxparentid = oxobject2category.oxobjectid )":" $sArtTable.oxid = $sO2CView.oxobjectid ";
00052 $sQAdd .= 'where '.$sArtTable.'.oxshopid="'.$myConfig->getShopId().'" and '.$sO2CView.'.oxcatnid = "'.$sVendorId.'" and '.$sArtTable.'.oxvendorid != "'. $sSynchVendorId .'" ';
00053 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00054 } else {
00055 $sQAdd = " from $sArtTable where $sArtTable.oxvendorid = '$sVendorId' ";
00056 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00057 }
00058 }
00059
00060 return $sQAdd;
00061 }
00062
00068 public function removevendor()
00069 {
00070 $myConfig = $this->getConfig();
00071 $aRemoveArt = $this->_getActionIds( 'oxarticles.oxid' );
00072
00073 if ( oxConfig::getParameter( 'all' ) ) {
00074 $sArtTable = getViewName( 'oxarticles' );
00075 $aRemoveArt = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00076 }
00077
00078 if ( is_array( $aRemoveArt ) ) {
00079 $sSelect = "update oxarticles set oxvendorid = null where oxid in ( '".implode("', '", $aRemoveArt )."') ";
00080 oxDb::getDb()->Execute( $sSelect);
00081 $this->resetCounter( "vendorArticle", oxConfig::getParameter( 'oxid' ) );
00082 }
00083 }
00084
00090 public function addvendor()
00091 {
00092 $myConfig = $this->getConfig();
00093
00094 $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00095 $soxId = oxConfig::getParameter( 'synchoxid' );
00096
00097 if ( oxConfig::getParameter( 'all' ) ) {
00098 $sArtTable = getViewName( 'oxarticles' );
00099 $aAddArticle = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00100 }
00101
00102 if ( $soxId && $soxId != "-1" && is_array( $aAddArticle ) ) {
00103 $sSelect = "update oxarticles set oxvendorid = '$soxId' where oxid in ( '".implode("', '", $aAddArticle )."' )";
00104
00105 oxDb::getDb()->Execute( $sSelect);
00106 $this->resetCounter( "vendorArticle", $soxId );
00107 }
00108 }
00109
00116 protected function _getQueryCols()
00117 {
00118 $myConfig = $this->getConfig();
00119 $sLangTag = oxLang::getInstance()->getLanguageTag();
00120
00121 $sQ = '';
00122 $blSep = false;
00123 $aVisiblecols = $this->_getVisibleColNames();
00124 foreach ( $aVisiblecols as $iCnt => $aCol ) {
00125 if ( $blSep )
00126 $sQ .= ', ';
00127 $sViewTable = getViewName( $aCol[1] );
00128
00129 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00130 if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00131 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00132 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00133 } else {
00134 $sQ .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00135 }
00136 $blSep = true;
00137 }
00138
00139 $aIdentCols = $this->_getIdentColNames();
00140 foreach ( $aIdentCols as $iCnt => $aCol ) {
00141 if ( $blSep )
00142 $sQ .= ', ';
00143
00144
00145 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00146 $sQ .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00147 }
00148
00149 return " $sQ ";
00150 }
00151
00152 }