OXID eShop CE  4.10.2
 All Classes Namespaces Files Functions Variables Pages
delivery_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', 'oxcountry', 1, 1, 0),
16  array('oxisoalpha2', 'oxcountry', 1, 0, 0),
17  array('oxisoalpha3', 'oxcountry', 0, 0, 0),
18  array('oxunnum3', 'oxcountry', 0, 0, 0),
19  array('oxid', 'oxcountry', 0, 0, 1)
20  ),
21  'container2' => array(
22  array('oxtitle', 'oxcountry', 1, 1, 0),
23  array('oxisoalpha2', 'oxcountry', 1, 0, 0),
24  array('oxisoalpha3', 'oxcountry', 0, 0, 0),
25  array('oxunnum3', 'oxcountry', 0, 0, 0),
26  array('oxid', 'oxobject2delivery', 0, 0, 1)
27  )
28  );
29 
35  protected function _getQuery()
36  {
37  $sCountryTable = $this->_getViewName('oxcountry');
38  $oDb = oxDb::getDb();
39  $sId = $this->getConfig()->getRequestParameter('oxid');
40  $sSynchId = $this->getConfig()->getRequestParameter('synchoxid');
41 
42  // category selected or not ?
43  if (!$sId) {
44  $sQAdd = " from {$sCountryTable} where {$sCountryTable}.oxactive = '1' ";
45  } else {
46  $sQAdd = " from oxobject2delivery left join {$sCountryTable} " .
47  "on {$sCountryTable}.oxid=oxobject2delivery.oxobjectid " .
48  " where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sId) .
49  " and oxobject2delivery.oxtype = 'oxcountry' ";
50  }
51 
52  if ($sSynchId && $sSynchId != $sId) {
53  $sQAdd .= " and {$sCountryTable}.oxid not in ( select {$sCountryTable}.oxid " .
54  "from oxobject2delivery left join {$sCountryTable} " .
55  "on {$sCountryTable}.oxid=oxobject2delivery.oxobjectid " .
56  " where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sSynchId) .
57  " and oxobject2delivery.oxtype = 'oxcountry' ) ";
58  }
59 
60  return $sQAdd;
61  }
62 
66  public function removeCountryFromDel()
67  {
68  $aChosenCntr = $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 (is_array($aChosenCntr)) {
75  $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aChosenCntr)) . ") ";
76  oxDb::getDb()->Execute($sQ);
77  }
78  }
79 
83  public function addCountryToDel()
84  {
85  $aChosenCntr = $this->_getActionIds('oxcountry.oxid');
86  $soxId = $this->getConfig()->getRequestParameter('synchoxid');
87 
88  // adding
89  if ($this->getConfig()->getRequestParameter('all')) {
90  $sCountryTable = $this->_getViewName('oxcountry');
91  $aChosenCntr = $this->_getAll($this->_addFilter("select $sCountryTable.oxid " . $this->_getQuery()));
92  }
93 
94  if ($soxId && $soxId != "-1" && is_array($aChosenCntr)) {
95  foreach ($aChosenCntr as $sChosenCntr) {
96  $oObject2Delivery = oxNew('oxbase');
97  $oObject2Delivery->init('oxobject2delivery');
98  $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
99  $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenCntr);
100  $oObject2Delivery->oxobject2delivery__oxtype = new oxField('oxcountry');
101  $oObject2Delivery->save();
102  }
103  }
104  }
105 }