OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
deliveryset_groups_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', 'oxgroups', 1, 0, 0 ),
15  array( 'oxid', 'oxgroups', 0, 0, 0 ),
16  array( 'oxid', 'oxgroups', 0, 0, 1 ),
17  ),
18  'container2' => array(
19  array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
20  array( 'oxid', 'oxgroups', 0, 0, 0 ),
21  array( 'oxid', 'oxobject2delivery', 0, 0, 1 ),
22  )
23  );
24 
30  protected function _getQuery()
31  {
32  $oDb = oxDb::getDb();
33  $sId = $this->getConfig()->getRequestParameter( 'oxid' );
34  $sSynchId = $this->getConfig()->getRequestParameter( 'synchoxid' );
35 
36  $sgroupTable = $this->_getViewName('oxgroups');
37 
38  // category selected or not ?
39  if ( !$sId) {
40  $sQAdd = " from $sgroupTable where 1 ";
41  } else {
42  $sQAdd = " from oxobject2delivery, $sgroupTable where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sId );
43  $sQAdd .= " and oxobject2delivery.oxobjectid = $sgroupTable.oxid and oxobject2delivery.oxtype = 'oxdelsetg' ";
44  }
45 
46  if ( $sSynchId && $sSynchId != $sId ) {
47  $sQAdd .= " and $sgroupTable.oxid not in ( select $sgroupTable.oxid from oxobject2delivery, $sgroupTable where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sSynchId );
48  $sQAdd .= " and oxobject2delivery.oxobjectid = $sgroupTable.oxid and oxobject2delivery.oxtype = 'oxdelsetg' ) ";
49  }
50 
51  return $sQAdd;
52  }
53 
59  public function removeGroupFromSet()
60  {
61  $aRemoveGroups = $this->_getActionIds( 'oxobject2delivery.oxid' );
62  if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
63 
64  $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
65  oxDb::getDb()->Execute( $sQ );
66 
67  } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
68  $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
69  oxDb::getDb()->Execute( $sQ );
70  }
71  }
72 
78  public function addGroupToSet()
79  {
80  $aChosenCat = $this->_getActionIds( 'oxgroups.oxid' );
81  $soxId = $this->getConfig()->getRequestParameter( 'synchoxid' );
82 
83  // adding
84  if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
85  $sGroupTable = $this->_getViewName('oxgroups');
86  $aChosenCat = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
87  }
88  if ( $soxId && $soxId != "-1" && is_array( $aChosenCat ) ) {
89  foreach ( $aChosenCat as $sChosenCat) {
90  $oObject2Delivery = oxNew( 'oxbase' );
91  $oObject2Delivery->init( 'oxobject2delivery' );
92  $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
93  $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenCat);
94  $oObject2Delivery->oxobject2delivery__oxtype = new oxField("oxdelsetg");
95  $oObject2Delivery->save();
96  }
97  }
98  }
99 }