OXID eShop CE  4.9.7
 All Classes Files Functions Variables Pages
delivery_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  $myConfig = $this->getConfig();
34  $oDb = oxDb::getDb();
35 
36  // active AJAX component
37  $sGroupTable = $this->_getViewName('oxgroups');
38 
39  $sId = $myConfig->getRequestParameter('oxid');
40  $sSynchId = $myConfig->getRequestParameter('synchoxid');
41 
42  // category selected or not ?
43  if (!$sId) {
44  $sQAdd = " from {$sGroupTable} where 1 ";
45  } else {
46  $sQAdd = " from oxobject2delivery left join {$sGroupTable} " .
47  "on {$sGroupTable}.oxid=oxobject2delivery.oxobjectid " .
48  " where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sId) .
49  " and oxobject2delivery.oxtype = 'oxgroups' ";
50  }
51 
52  if ($sSynchId && $sSynchId != $sId) {
53  $sQAdd .= " and {$sGroupTable}.oxid not in ( select {$sGroupTable}.oxid " .
54  "from oxobject2delivery left join {$sGroupTable} " .
55  "on {$sGroupTable}.oxid=oxobject2delivery.oxobjectid " .
56  " where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sSynchId) .
57  " and oxobject2delivery.oxtype = 'oxgroups' ) ";
58  }
59 
60  return $sQAdd;
61  }
62 
66  public function removeGroupFromDel()
67  {
68  $aRemoveGroups = $this->_getActionIds('oxobject2delivery.oxid');
69  if ($this->getConfig()->getRequestParameter('all')) {
70 
71  $sQ = $this->_addFilter("delete oxobject2delivery.* " . $this->_getQuery());
72  oxDb::getDb()->Execute($sQ);
73 
74  } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
75  $sRemoveGroups = implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups));
76  $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . $sRemoveGroups . ") ";
77  oxDb::getDb()->Execute($sQ);
78  }
79  }
80 
84  public function addGroupToDel()
85  {
86  $aChosenCat = $this->_getActionIds('oxgroups.oxid');
87  $soxId = $this->getConfig()->getRequestParameter('synchoxid');
88 
89  // adding
90  if ($this->getConfig()->getRequestParameter('all')) {
91  $sGroupTable = $this->_getViewName('oxgroups');
92  $aChosenCat = $this->_getAll($this->_addFilter("select $sGroupTable.oxid " . $this->_getQuery()));
93  }
94 
95  if ($soxId && $soxId != "-1" && is_array($aChosenCat)) {
96  foreach ($aChosenCat as $sChosenCat) {
97  $oObject2Delivery = oxNew('oxbase');
98  $oObject2Delivery->init('oxobject2delivery');
99  $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
100  $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenCat);
101  $oObject2Delivery->oxobject2delivery__oxtype = new oxField('oxgroups');
102  $oObject2Delivery->save();
103  }
104  }
105  }
106 }