OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
deliveryset_main_ajax.php
Go to the documentation of this file.
1 <?php
2 
7 {
13  protected $_aColumns = array( 'container1' => array( // field , table, visible, multilanguage, ident
14  array( 'oxtitle', 'oxdelivery', 1, 1, 0 ),
15  array( 'oxaddsum', 'oxdelivery', 1, 0, 0 ),
16  array( 'oxaddsumtype', 'oxdelivery', 1, 0, 0 ),
17  array( 'oxid', 'oxdelivery', 0, 0, 1 )
18  ),
19  'container2' => array(
20  array( 'oxtitle', 'oxdelivery', 1, 1, 0 ),
21  array( 'oxaddsum', 'oxdelivery', 1, 0, 0 ),
22  array( 'oxaddsumtype', 'oxdelivery', 1, 0, 0 ),
23  array( 'oxid', 'oxdel2delset', 0, 0, 1 )
24  )
25  );
26 
32  protected function _getQuery()
33  {
34  $sId = $this->getConfig()->getRequestParameter( 'oxid' );
35  $sSynchId = $this->getConfig()->getRequestParameter( 'synchoxid' );
36  $oDb = oxDb::getDb();
37 
38  $sDeliveryViewName = $this->_getViewName('oxdelivery');
39 
40  // category selected or not ?
41  if ( !$sId) {
42  $sQAdd = " from $sDeliveryViewName where 1 ";
43  } else {
44  $sQAdd = " from $sDeliveryViewName left join oxdel2delset on oxdel2delset.oxdelid=$sDeliveryViewName.oxid ";
45  $sQAdd .= "where oxdel2delset.oxdelsetid = ".$oDb->quote( $sId );
46  }
47 
48  if ( $sSynchId && $sSynchId != $sId ) {
49  $sQAdd .= "and $sDeliveryViewName.oxid not in ( select $sDeliveryViewName.oxid from $sDeliveryViewName left join oxdel2delset on oxdel2delset.oxdelid=$sDeliveryViewName.oxid ";
50  $sQAdd .= "where oxdel2delset.oxdelsetid = ".$oDb->quote( $sSynchId ) ." ) ";
51  }
52 
53  return $sQAdd;
54  }
55 
61  public function removeFromSet()
62  {
63  $aRemoveGroups = $this->_getActionIds( 'oxdel2delset.oxid' );
64  if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
65 
66  $sQ = $this->_addFilter( "delete oxdel2delset.* ".$this->_getQuery() );
67  oxDb::getDb()->Execute( $sQ );
68 
69  } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
70  $sQ = "delete from oxdel2delset where oxdel2delset.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
71  oxDb::getDb()->Execute( $sQ );
72  }
73  }
74 
80  public function addToSet()
81  {
82  $aChosenSets = $this->_getActionIds( 'oxdelivery.oxid' );
83  $soxId = oxConfig::getParameter( 'synchoxid');
84 
85  // adding
86  if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
87  $sDeliveryViewName = $this->_getViewName('oxdelivery');
88  $aChosenSets = $this->_getAll( $this->_addFilter( "select $sDeliveryViewName.oxid ".$this->_getQuery() ) );
89  }
90  if ( $soxId && $soxId != "-1" && is_array( $aChosenSets ) ) {
91  $oDb = oxDb::getDb();
92  foreach ( $aChosenSets as $sChosenSet) {
93  // check if we have this entry already in
94  $sID = $oDb->getOne("select oxid from oxdel2delset where oxdelid = " . $oDb->quote( $sChosenSet ) . " and oxdelsetid = ".$oDb->quote( $soxId ), false, false );
95  if ( !isset( $sID) || !$sID) {
96  $oDel2delset = oxNew( 'oxbase' );
97  $oDel2delset->init( 'oxdel2delset' );
98  $oDel2delset->oxdel2delset__oxdelid = new oxField($sChosenSet);
99  $oDel2delset->oxdel2delset__oxdelsetid = new oxField($soxId);
100  $oDel2delset->save();
101  }
102  }
103  }
104  }
105 }