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', 'oxaccessoire2article', 0, 0, 1 )
00018 )
00019 );
00020
00024 class ajaxComponent extends ajaxListComponent
00025 {
00031 protected function _getQuery()
00032 {
00033 $myConfig = $this->getConfig();
00034 $sSelId = oxConfig::getParameter( 'oxid' );
00035 $sSynchSelId = oxConfig::getParameter( 'synchoxid' );
00036
00037 $sArticleTable = getViewName('oxarticles');
00038 $sO2CView = getViewName('oxobject2category');
00039
00040
00041 if ( !$sSelId ) {
00042 $sQAdd = " from $sArticleTable where 1 ";
00043 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArticleTable.oxparentid = '' ";
00044 } else {
00045
00046 if ( $sSynchSelId && $sSelId != $sSynchSelId ) {
00047 $sQAdd = " from $sO2CView left join $sArticleTable on ";
00048 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArticleTable.oxid=$sO2CView.oxobjectid or $sArticleTable.oxparentid=$sO2CView.oxobjectid )":" $sArticleTable.oxid=$sO2CView.oxobjectid ";
00049 $sQAdd .= " where $sO2CView.oxcatnid = '$sSelId' ";
00050 } else {
00051 $sQAdd = " from oxaccessoire2article left join $sArticleTable on oxaccessoire2article.oxobjectid=$sArticleTable.oxid ";
00052 $sQAdd .= " where oxaccessoire2article.oxarticlenid = '$sSelId' ";
00053 }
00054 }
00055
00056 if ( $sSynchSelId && $sSynchSelId != $sSelId ) {
00057
00058 $sSubSelect .= " select oxaccessoire2article.oxobjectid from oxaccessoire2article ";
00059 $sSubSelect .= " where oxaccessoire2article.oxarticlenid = '$sSynchSelId' ";
00060 $sQAdd .= " and $sArticleTable.oxid not in ( $sSubSelect ) ";
00061 }
00062
00063
00064 return $sQAdd;
00065 }
00066
00072 public function removearticleacc()
00073 {
00074 $aChosenArt = $this->_getActionIds( 'oxaccessoire2article.oxid' );
00075
00076 if ( oxConfig::getParameter( 'all' ) ) {
00077
00078 $sQ = $this->_addFilter( "delete oxaccessoire2article.* ".$this->_getQuery() );
00079 oxDb::getDb()->Execute( $sQ );
00080
00081 } elseif ( is_array( $aChosenArt ) ) {
00082 $sQ = "delete from oxaccessoire2article where oxaccessoire2article.oxid in ('" . implode( "', '", $aChosenArt ) . "') ";
00083 oxDb::getDb()->Execute( $sQ );
00084 }
00085
00086 }
00087
00093 public function addarticleacc()
00094 {
00095 $oArticle = oxNew( "oxarticle" );
00096 $aChosenArt = $this->_getActionIds( 'oxarticles.oxid' );
00097 $soxId = oxConfig::getParameter( 'synchoxid');
00098
00099
00100 if ( oxConfig::getParameter( 'all' ) ) {
00101 $sArtTable = getViewName('oxarticles');
00102 $aChosenArt = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00103 }
00104
00105 if ( $oArticle->load( $soxId ) && $soxId && $soxId != "-1" && is_array( $aChosenArt ) ) {
00106 foreach ( $aChosenArt as $sChosenArt ) {
00107 $oNewGroup = oxNew( "oxbase" );
00108 $oNewGroup->init( "oxaccessoire2article" );
00109 $oNewGroup->oxaccessoire2article__oxobjectid = new oxField($sChosenArt);
00110 $oNewGroup->oxaccessoire2article__oxarticlenid = new oxField($oArticle->oxarticles__oxid->value);
00111 $oNewGroup->oxaccessoire2article__oxsort = new oxField(0);
00112 $oNewGroup->save();
00113 }
00114 }
00115 }
00116
00123 protected function _getQueryCols()
00124 {
00125 $myConfig = $this->getConfig();
00126 $sQ = '';
00127 $blSep = false;
00128 $aVisiblecols = $this->_getVisibleColNames();
00129 foreach ( $aVisiblecols as $iCnt => $aCol ) {
00130 if ( $blSep )
00131 $sQ .= ', ';
00132 $sViewTable = getViewName( $aCol[1] );
00133
00134 $sCol = $aCol[3]?$aCol[0].oxLang::getInstance()->getLanguageTag():$aCol[0];
00135 if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00136 $sVarSelect = "$sViewTable.oxvarselect".oxLang::getInstance()->getLanguageTag();
00137 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00138 } else {
00139 $sQ .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00140 }
00141 $blSep = true;
00142 }
00143
00144 $aIdentCols = $this->_getIdentColNames();
00145 foreach ( $aIdentCols as $iCnt => $aCol ) {
00146 if ( $blSep )
00147 $sQ .= ', ';
00148
00149
00150 $sCol = $aCol[3]?$aCol[0].oxLang::getInstance()->getLanguageTag():$aCol[0];
00151 $sQ .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00152 }
00153
00154 return " $sQ ";
00155 }
00156
00157 }