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( 'oxmpn',    'oxarticles', 0, 0, 0 ),
00008                                         array( 'oxprice',  'oxarticles', 0, 0, 0 ),
00009                                         array( 'oxstock',  'oxarticles', 0, 0, 0 ),
00010                                         array( 'oxid',     'oxarticles', 0, 0, 1 )
00011                                         ),
00012                      'container2' => array(
00013                                         array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00014                                         array( 'oxtitle',  'oxarticles', 1, 1, 0 ),
00015                                         array( 'oxean',    'oxarticles', 1, 0, 0 ),
00016                                         array( 'oxmpn',    'oxarticles', 0, 0, 0 ),
00017                                         array( 'oxprice',  'oxarticles', 0, 0, 0 ),
00018                                         array( 'oxstock',  'oxarticles', 0, 0, 0 ),
00019                                         array( 'oxid',     'oxobject2delivery', 0, 0, 1 )
00020                                         )
00021                     );
00022 
00026 class ajaxComponent extends ajaxListComponent
00027 {
00033     protected $_blAllowExtColumns = true;
00034 
00040     protected function _getQuery()
00041     {
00042         $myConfig = $this->getConfig();
00043         $oDb = oxDb::getDb();
00044 
00045         // looking for table/view
00046         $sArtTable = $this->_getViewName('oxarticles');
00047         $sCatTable = $this->_getViewName('oxcategories');
00048         $sO2CView  = $this->_getViewName('oxobject2category');
00049 
00050         $sDelId      = oxConfig::getParameter( 'oxid' );
00051         $sSynchDelId = oxConfig::getParameter( 'synchoxid' );
00052 
00053         // category selected or not ?
00054         if ( !$sDelId) {
00055             // dodger performance
00056             $sQAdd  = " from $sArtTable where 1 ";
00057             $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':"and $sArtTable.oxparentid = '' ";
00058         } else {
00059             // selected category ?
00060             if ( $sSynchDelId && $sDelId != $sSynchDelId ) {
00061                 $sQAdd  = " from $sO2CView left join $sArtTable on ";
00062                 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArtTable.oxid=$sO2CView.oxobjectid or $sArtTable.oxparentid=$sO2CView.oxobjectid)":" $sArtTable.oxid=$sO2CView.oxobjectid ";
00063                 $sQAdd .= "where $sO2CView.oxcatnid = ". $oDb->quote( $sDelId );
00064             } else {
00065                 $sQAdd  = ' from oxobject2delivery left join '.$sArtTable.' on '.$sArtTable.'.oxid=oxobject2delivery.oxobjectid ';
00066                 $sQAdd .= 'where oxobject2delivery.oxdeliveryid = '.$oDb->quote( $sDelId ).' and oxobject2delivery.oxtype = "oxarticles" ';
00067             }
00068         }
00069 
00070         if ( $sSynchDelId && $sSynchDelId != $sDelId) {
00071             $sQAdd .= 'and '.$sArtTable.'.oxid not in ( ';
00072             $sQAdd .= 'select oxobject2delivery.oxobjectid from oxobject2delivery ';
00073             $sQAdd .= 'where oxobject2delivery.oxdeliveryid = '.$oDb->quote( $sSynchDelId ).' and oxobject2delivery.oxtype = "oxarticles" ) ';
00074         }
00075 
00076         return $sQAdd;
00077     }
00078 
00086     /*protected function _addFilter( $sQ )
00087     {
00088         $sArtTable = $this->_getViewName('oxarticles');
00089         $sQ = parent::_addFilter( $sQ );
00090 
00091         // display variants or not ?
00092         $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00093         return $sQ;
00094     }*/
00095 
00101     public function removeartfromdel()
00102     {
00103         $aChosenArt = $this->_getActionIds( 'oxobject2delivery.oxid' );
00104         // removing all
00105         if ( oxConfig::getParameter( 'all' ) ) {
00106 
00107             $sQ = parent::_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
00108             oxDb::getDb()->Execute( $sQ );
00109 
00110         } elseif ( is_array( $aChosenArt ) ) {
00111             $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenArt ) ) . ") ";
00112             oxDb::getDb()->Execute( $sQ );
00113         }
00114     }
00115 
00121     public function addarttodel()
00122     {
00123         $aChosenArt = $this->_getActionIds( 'oxarticles.oxid' );
00124         $soxId      = oxConfig::getParameter( 'synchoxid');
00125 
00126         // adding
00127         if ( oxConfig::getParameter( 'all' ) ) {
00128             $sArtTable = $this->_getViewName('oxarticles');
00129             $aChosenArt = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00130         }
00131 
00132         if ( $soxId && $soxId != "-1" && is_array( $aChosenArt ) ) {
00133             foreach ( $aChosenArt as $sChosenArt) {
00134                 $oObject2Delivery = oxNew( 'oxbase' );
00135                 $oObject2Delivery->init( 'oxobject2delivery' );
00136                 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00137                 $oObject2Delivery->oxobject2delivery__oxobjectid   = new oxField($sChosenArt);
00138                 $oObject2Delivery->oxobject2delivery__oxtype       = new oxField("oxarticles");
00139                 $oObject2Delivery->save();
00140             }
00141         }
00142     }
00143 }