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