00001 <?php
00002
00006 class delivery_articles_ajax extends ajaxListComponent
00007 {
00013 protected $_aColumns = array( 'container1' => array(
00014 array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00015 array( 'oxtitle', 'oxarticles', 1, 1, 0 ),
00016 array( 'oxean', 'oxarticles', 1, 0, 0 ),
00017 array( 'oxmpn', 'oxarticles', 0, 0, 0 ),
00018 array( 'oxprice', 'oxarticles', 0, 0, 0 ),
00019 array( 'oxstock', 'oxarticles', 0, 0, 0 ),
00020 array( 'oxid', 'oxarticles', 0, 0, 1 )
00021 ),
00022 'container2' => array(
00023 array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00024 array( 'oxtitle', 'oxarticles', 1, 1, 0 ),
00025 array( 'oxean', 'oxarticles', 1, 0, 0 ),
00026 array( 'oxmpn', 'oxarticles', 0, 0, 0 ),
00027 array( 'oxprice', 'oxarticles', 0, 0, 0 ),
00028 array( 'oxstock', 'oxarticles', 0, 0, 0 ),
00029 array( 'oxid', 'oxobject2delivery', 0, 0, 1 )
00030 )
00031 );
00032
00038 protected $_blAllowExtColumns = true;
00039
00045 protected function _getQuery()
00046 {
00047 $myConfig = $this->getConfig();
00048 $oDb = oxDb::getDb();
00049
00050
00051 $sArtTable = $this->_getViewName('oxarticles');
00052 $sCatTable = $this->_getViewName('oxcategories');
00053 $sO2CView = $this->_getViewName('oxobject2category');
00054
00055 $sDelId = $this->getConfig()->getRequestParameter( 'oxid' );
00056 $sSynchDelId = $this->getConfig()->getRequestParameter( 'synchoxid' );
00057
00058
00059 if ( !$sDelId) {
00060
00061 $sQAdd = " from $sArtTable where 1 ";
00062 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':"and $sArtTable.oxparentid = '' ";
00063 } else {
00064
00065 if ( $sSynchDelId && $sDelId != $sSynchDelId ) {
00066 $sQAdd = " from $sO2CView left join $sArtTable on ";
00067 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArtTable.oxid=$sO2CView.oxobjectid or $sArtTable.oxparentid=$sO2CView.oxobjectid)":" $sArtTable.oxid=$sO2CView.oxobjectid ";
00068 $sQAdd .= "where $sO2CView.oxcatnid = ". $oDb->quote( $sDelId );
00069 } else {
00070 $sQAdd = ' from oxobject2delivery left join '.$sArtTable.' on '.$sArtTable.'.oxid=oxobject2delivery.oxobjectid ';
00071 $sQAdd .= 'where oxobject2delivery.oxdeliveryid = '.$oDb->quote( $sDelId ).' and oxobject2delivery.oxtype = "oxarticles" ';
00072 }
00073 }
00074
00075 if ( $sSynchDelId && $sSynchDelId != $sDelId) {
00076 $sQAdd .= 'and '.$sArtTable.'.oxid not in ( ';
00077 $sQAdd .= 'select oxobject2delivery.oxobjectid from oxobject2delivery ';
00078 $sQAdd .= 'where oxobject2delivery.oxdeliveryid = '.$oDb->quote( $sSynchDelId ).' and oxobject2delivery.oxtype = "oxarticles" ) ';
00079 }
00080
00081 return $sQAdd;
00082 }
00083
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00106 public function removeArtFromDel()
00107 {
00108 $aChosenArt = $this->_getActionIds( 'oxobject2delivery.oxid' );
00109
00110 if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
00111
00112 $sQ = parent::_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
00113 oxDb::getDb()->Execute( $sQ );
00114
00115 } elseif ( is_array( $aChosenArt ) ) {
00116 $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenArt ) ) . ") ";
00117 oxDb::getDb()->Execute( $sQ );
00118 }
00119 }
00120
00126 public function addArtToDel()
00127 {
00128 $aChosenArt = $this->_getActionIds( 'oxarticles.oxid' );
00129 $soxId = $this->getConfig()->getRequestParameter( 'synchoxid');
00130
00131
00132 if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
00133 $sArtTable = $this->_getViewName('oxarticles');
00134 $aChosenArt = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00135 }
00136
00137 if ( $soxId && $soxId != "-1" && is_array( $aChosenArt ) ) {
00138 foreach ( $aChosenArt as $sChosenArt) {
00139 $oObject2Delivery = oxNew( 'oxbase' );
00140 $oObject2Delivery->init( 'oxobject2delivery' );
00141 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00142 $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenArt);
00143 $oObject2Delivery->oxobject2delivery__oxtype = new oxField("oxarticles");
00144 $oObject2Delivery->save();
00145 }
00146 }
00147 }
00148 }