OXID eShop CE  4.9.6
 All Classes Files Functions Variables Pages
deliveryset_groups_ajax.php
Go to the documentation of this file.
1 <?php
2 
7 {
8 
14  protected $_aColumns = array('container1' => array( // field , table, visible, multilanguage, ident
15  array('oxtitle', 'oxgroups', 1, 0, 0),
16  array('oxid', 'oxgroups', 0, 0, 0),
17  array('oxid', 'oxgroups', 0, 0, 1),
18  ),
19  'container2' => array(
20  array('oxtitle', 'oxgroups', 1, 0, 0),
21  array('oxid', 'oxgroups', 0, 0, 0),
22  array('oxid', 'oxobject2delivery', 0, 0, 1),
23  )
24  );
25 
31  protected function _getQuery()
32  {
33  $oDb = oxDb::getDb();
34  $sId = $this->getConfig()->getRequestParameter('oxid');
35  $sSynchId = $this->getConfig()->getRequestParameter('synchoxid');
36 
37  $sgroupTable = $this->_getViewName('oxgroups');
38 
39  // category selected or not ?
40  if (!$sId) {
41  $sQAdd = " from $sgroupTable where 1 ";
42  } else {
43  $sQAdd = " from oxobject2delivery, {$sgroupTable} " .
44  "where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sId) .
45  " and oxobject2delivery.oxobjectid = {$sgroupTable}.oxid " .
46  "and oxobject2delivery.oxtype = 'oxdelsetg' ";
47  }
48 
49  if ($sSynchId && $sSynchId != $sId) {
50  $sQAdd .= " and {$sgroupTable}.oxid not in ( select {$sgroupTable}.oxid " .
51  "from oxobject2delivery, {$sgroupTable} " .
52  "where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sSynchId) .
53  " and oxobject2delivery.oxobjectid = $sgroupTable.oxid " .
54  "and oxobject2delivery.oxtype = 'oxdelsetg' ) ";
55  }
56 
57  return $sQAdd;
58  }
59 
63  public function removeGroupFromSet()
64  {
65  $aRemoveGroups = $this->_getActionIds('oxobject2delivery.oxid');
66  if ($this->getConfig()->getRequestParameter('all')) {
67 
68  $sQ = $this->_addFilter("delete oxobject2delivery.* " . $this->_getQuery());
69  oxDb::getDb()->Execute($sQ);
70 
71  } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
72  $sRemoveGroups = implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups));
73  $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . $sRemoveGroups . ") ";
74  oxDb::getDb()->Execute($sQ);
75  }
76  }
77 
81  public function addGroupToSet()
82  {
83  $aChosenCat = $this->_getActionIds('oxgroups.oxid');
84  $soxId = $this->getConfig()->getRequestParameter('synchoxid');
85 
86  // adding
87  if ($this->getConfig()->getRequestParameter('all')) {
88  $sGroupTable = $this->_getViewName('oxgroups');
89  $aChosenCat = $this->_getAll($this->_addFilter("select $sGroupTable.oxid " . $this->_getQuery()));
90  }
91  if ($soxId && $soxId != "-1" && is_array($aChosenCat)) {
92  foreach ($aChosenCat as $sChosenCat) {
93  $oObject2Delivery = oxNew('oxbase');
94  $oObject2Delivery->init('oxobject2delivery');
95  $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
96  $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenCat);
97  $oObject2Delivery->oxobject2delivery__oxtype = new oxField("oxdelsetg");
98  $oObject2Delivery->save();
99  }
100  }
101  }
102 }