delivery_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',     'oxobject2delivery', 0, 0, 1 )
00018                                         )
00019                     );
00020 
00024 class ajaxComponent extends ajaxListComponent
00025 {
00031     protected function _getQuery()
00032     {
00033         $myConfig = $this->getConfig();
00034 
00035         // looking for table/view
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         // category selected or not ?
00044         if ( !$sDelId) {
00045             // dodger performance
00046             $sQAdd  = " from $sArtTable where 1 ";
00047             $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':"and $sArtTable.oxparentid = '' ";
00048         } else {
00049             // selected category ?
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 
00074     public function removeartfromdel()
00075     {
00076         $aChosenArt = $this->_getActionIds( 'oxobject2delivery.oxid' );
00077         // removing all
00078         if ( oxConfig::getParameter( 'all' ) ) {
00079 
00080             $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
00081             oxDb::getDb()->Execute( $sQ );
00082 
00083         } elseif ( is_array( $aChosenArt ) ) {
00084             $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in ('" . implode( "', '", $aChosenArt ) . "') ";
00085             oxDb::getDb()->Execute( $sQ );
00086         }
00087     }
00088 
00094     public function addarttodel()
00095     {
00096         $aChosenArt = $this->_getActionIds( 'oxarticles.oxid' );
00097         $soxId      = oxConfig::getParameter( 'synchoxid');
00098 
00099         // adding
00100         if ( oxConfig::getParameter( 'all' ) ) {
00101             $sArtTable = getViewName('oxarticles');
00102             $aChosenArt = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00103         }
00104 
00105         if ( $soxId && $soxId != "-1" && is_array( $aChosenArt ) ) {
00106             foreach ( $aChosenArt as $sChosenArt) {
00107                 $oObject2Delivery = oxNew( 'oxbase' );
00108                 $oObject2Delivery->init( 'oxobject2delivery' );
00109                 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00110                 $oObject2Delivery->oxobject2delivery__oxobjectid   = new oxField($sChosenArt);
00111                 $oObject2Delivery->oxobject2delivery__oxtype       = new oxField("oxarticles");
00112                 $oObject2Delivery->save();
00113             }
00114         }
00115     }
00116 
00123     protected function _getQueryCols()
00124     {
00125         $myConfig = $this->getConfig();
00126         $sLangTag = oxLang::getInstance()->getLanguageTag();
00127 
00128         $sQ = '';
00129         $blSep = false;
00130         $aVisiblecols = $this->_getVisibleColNames();
00131         foreach ( $aVisiblecols as $iCnt => $aCol ) {
00132             if ( $blSep )
00133                 $sQ .= ', ';
00134             $sViewTable = getViewName( $aCol[1] );
00135             // multilanguage
00136             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00137             if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00138                 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00139                 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00140             } else {
00141                 $sQ  .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00142             }
00143             $blSep = true;
00144         }
00145 
00146         $aIdentCols = $this->_getIdentColNames();
00147         foreach ( $aIdentCols as $iCnt => $aCol ) {
00148             if ( $blSep )
00149                 $sQ .= ', ';
00150 
00151             // multilanguage
00152             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00153             $sQ  .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00154         }
00155 
00156         return " $sQ ";
00157     }
00158 
00159 }

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5