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', 'oxobject2delivery', 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 $sCatTable = getViewName('oxcategories');
00038 $sO2CView = getViewName('oxobject2category');
00039
00040 $sDelId = oxConfig::getParameter( 'oxid' );
00041 $sSynchDelId = oxConfig::getParameter( 'synchoxid' );
00042
00043
00044 if ( !$sDelId) {
00045
00046 $sQAdd = " from $sArtTable where 1 ";
00047 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':"and $sArtTable.oxparentid = '' ";
00048 } else {
00049
00050 if ( $sSynchDelId && $sDelId != $sSynchDelId ) {
00051 $sQAdd = " from $sO2CView left join $sArtTable on ";
00052 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArtTable.oxid=$sO2CView.oxobjectid or $sArtTable.oxparentid=$sO2CView.oxobjectid)":" $sArtTable.oxid=$sO2CView.oxobjectid ";
00053 $sQAdd .= "where $sO2CView.oxcatnid = '$sDelId' ";
00054 } else {
00055 $sQAdd = ' from oxobject2delivery left join '.$sArtTable.' on '.$sArtTable.'.oxid=oxobject2delivery.oxobjectid ';
00056 $sQAdd .= 'where oxobject2delivery.oxdeliveryid = "'.$sDelId.'" and oxobject2delivery.oxtype = "oxarticles" ';
00057 }
00058 }
00059
00060 if ( $sSynchDelId && $sSynchDelId != $sDelId) {
00061 $sQAdd .= 'and '.$sArtTable.'.oxid not in ( ';
00062 $sQAdd .= 'select '.$sArtTable.'.oxid from oxobject2delivery left join '.$sArtTable.' on '.$sArtTable.'.oxid=oxobject2delivery.oxobjectid ';
00063 $sQAdd .= 'where oxobject2delivery.oxdeliveryid = "'.$sSynchDelId.'" and oxobject2delivery.oxtype = "oxarticles" ) ';
00064 }
00065
00066 return $sQAdd;
00067 }
00068
00076 protected function _getDataQuery( $sQ )
00077 {
00078 $sArtTable = getViewName('oxarticles');
00079 $sQ = parent::_getDataQuery( $sQ );
00080
00081
00082 $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00083 return $sQ;
00084 }
00085
00091 public function removeartfromdel()
00092 {
00093 $aChosenArt = $this->_getActionIds( 'oxobject2delivery.oxid' );
00094
00095 if ( oxConfig::getParameter( 'all' ) ) {
00096
00097 $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
00098 oxDb::getDb()->Execute( $sQ );
00099
00100 } elseif ( is_array( $aChosenArt ) ) {
00101 $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenArt ) ) . ") ";
00102 oxDb::getDb()->Execute( $sQ );
00103 }
00104 }
00105
00111 public function addarttodel()
00112 {
00113 $aChosenArt = $this->_getActionIds( 'oxarticles.oxid' );
00114 $soxId = oxConfig::getParameter( 'synchoxid');
00115
00116
00117 if ( oxConfig::getParameter( 'all' ) ) {
00118 $sArtTable = getViewName('oxarticles');
00119 $aChosenArt = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00120 }
00121
00122 if ( $soxId && $soxId != "-1" && is_array( $aChosenArt ) ) {
00123 foreach ( $aChosenArt as $sChosenArt) {
00124 $oObject2Delivery = oxNew( 'oxbase' );
00125 $oObject2Delivery->init( 'oxobject2delivery' );
00126 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00127 $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenArt);
00128 $oObject2Delivery->oxobject2delivery__oxtype = new oxField("oxarticles");
00129 $oObject2Delivery->save();
00130 }
00131 }
00132 }
00133
00140 protected function _getQueryCols()
00141 {
00142 $myConfig = $this->getConfig();
00143 $sLangTag = oxLang::getInstance()->getLanguageTag();
00144
00145 $sQ = '';
00146 $blSep = false;
00147 $aVisiblecols = $this->_getVisibleColNames();
00148 foreach ( $aVisiblecols as $iCnt => $aCol ) {
00149 if ( $blSep )
00150 $sQ .= ', ';
00151 $sViewTable = getViewName( $aCol[1] );
00152
00153 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00154 if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00155 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00156 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00157 } else {
00158 $sQ .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00159 }
00160 $blSep = true;
00161 }
00162
00163 $aIdentCols = $this->_getIdentColNames();
00164 foreach ( $aIdentCols as $iCnt => $aCol ) {
00165 if ( $blSep )
00166 $sQ .= ', ';
00167
00168
00169 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00170 $sQ .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00171 }
00172
00173 return " $sQ ";
00174 }
00175
00176 }