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