OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
selectlist_main_ajax.php
Go to the documentation of this file.
1 <?php
2 
7 {
13  protected $_blAllowExtColumns = true;
14 
20  protected $_aColumns = array( 'container1' => array( // field , table, visible, multilanguage, ident
21  array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
22  array( 'oxtitle', 'oxarticles', 1, 1, 0 ),
23  array( 'oxean', 'oxarticles', 0, 0, 0 ),
24  array( 'oxmpn', 'oxarticles', 0, 0, 0 ),
25  array( 'oxprice', 'oxarticles', 0, 0, 0 ),
26  array( 'oxstock', 'oxarticles', 0, 0, 0 ),
27  array( 'oxid', 'oxarticles', 0, 0, 1 )
28  ),
29  'container2' => array(
30  array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
31  array( 'oxtitle', 'oxarticles', 1, 1, 0 ),
32  array( 'oxean', 'oxarticles', 0, 0, 0 ),
33  array( 'oxmpn', 'oxarticles', 0, 0, 0 ),
34  array( 'oxprice', 'oxarticles', 0, 0, 0 ),
35  array( 'oxstock', 'oxarticles', 0, 0, 0 ),
36  array( 'oxid', 'oxobject2selectlist', 0, 0, 1 ),
37  array( 'oxid', 'oxarticles', 0, 0, 1 )
38  ),
39  'container3' => array(
40  array( 'oxtitle', 'oxselectlist', 1, 1, 0 ),
41  array( 'oxsort', 'oxobject2selectlist', 1, 0, 0 ),
42  array( 'oxident', 'oxselectlist', 0, 0, 0 ),
43  array( 'oxvaldesc', 'oxselectlist', 0, 0, 0 ),
44  array( 'oxid', 'oxselectlist', 0, 0, 1 )
45  )
46  );
47 
53  protected function _getQuery()
54  {
55  $myConfig = $this->getConfig();
56 
57  // looking for table/view
58  $sArtTable = $this->_getViewName('oxarticles');
59  $sCatTable = $this->_getViewName('oxcategories');
60  $sO2CView = $this->_getViewName('oxobject2category');
61  $oDb = oxDb::getDb();
62  $sSelId = oxConfig::getParameter( 'oxid' );
63  $sSynchSelId = oxConfig::getParameter( 'synchoxid' );
64 
65  // category selected or not ?
66  if ( !$sSelId) {
67  // dodger performance
68  $sQAdd = " from $sArtTable where 1 ";
69  $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
70  } else {
71  // selected category ?
72  if ( $sSynchSelId && $sSelId != $sSynchSelId ) {
73  $sQAdd = " from $sO2CView as oxobject2category left join $sArtTable on ";
74  $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArtTable.oxid=oxobject2category.oxobjectid or $sArtTable.oxparentid=oxobject2category.oxobjectid ) ":" $sArtTable.oxid=oxobject2category.oxobjectid ";
75  $sQAdd .= " where oxobject2category.oxcatnid = ".$oDb->quote( $sSelId );
76  } else {
77  $sQAdd = " from $sArtTable left join oxobject2selectlist on $sArtTable.oxid=oxobject2selectlist.oxobjectid ";
78  $sQAdd .= " where oxobject2selectlist.oxselnid = ".$oDb->quote( $sSelId );
79  }
80  }
81 
82  if ( $sSynchSelId && $sSynchSelId != $sSelId ) {
83  // dodger performance
84  $sQAdd .= " and $sArtTable.oxid not in ( select oxobject2selectlist.oxobjectid from oxobject2selectlist ";
85  $sQAdd .= " where oxobject2selectlist.oxselnid = ".$oDb->quote( $sSynchSelId )." ) ";
86  }
87 
88  return $sQAdd;
89  }
90 
96  public function removeArtFromSel()
97  {
98  $aChosenArt = $this->_getActionIds( 'oxobject2selectlist.oxid' );
99 
100 
101 
102 
103  if ( oxConfig::getParameter( 'all' ) ) {
104 
105  $sQ = parent::_addFilter( "delete oxobject2selectlist.* ".$this->_getQuery() );
106  oxDb::getDb()->Execute( $sQ );
107 
108  } elseif ( is_array( $aChosenArt ) ) {
109  $sQ = "delete from oxobject2selectlist where oxobject2selectlist.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenArt ) ) . ") ";
110  oxDb::getDb()->Execute( $sQ );
111  }
112  }
113 
119  public function addArtToSel()
120  {
121  $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
122  $soxId = oxConfig::getParameter( 'synchoxid');
123 
124  if ( oxConfig::getParameter( 'all' ) ) {
125  $sArtTable = $this->_getViewName('oxarticles');
126  $aAddArticle = $this->_getAll( parent::_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
127  }
128 
129  if ( $soxId && $soxId != "-1" && is_array( $aAddArticle ) ) {
130  $oDb = oxDb::getDb();
131  foreach ($aAddArticle as $sAdd) {
132  $oNewGroup = oxNew( "oxbase" );
133  $oNewGroup->init( "oxobject2selectlist" );
134  $oNewGroup->oxobject2selectlist__oxobjectid = new oxField( $sAdd );
135  $oNewGroup->oxobject2selectlist__oxselnid = new oxField( $soxId );
136  $oNewGroup->oxobject2selectlist__oxsort = new oxField( ( int ) $oDb->getOne( "select max(oxsort) + 1 from oxobject2selectlist where oxobjectid = " . $oDb->quote( $sAdd ) . " ", false, false ) );
137  $oNewGroup->save();
138 
139  }
140  }
141 
142 
143 
144  }
145 }