OXID eShop CE  4.10.2
 All Classes Namespaces Files Functions Variables Pages
payment_country_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', 'oxobject2payment', 0, 0, 1)
27  )
28  );
29 
35  protected function _getQuery()
36  {
37  // looking for table/view
38  $sCountryTable = $this->_getViewName('oxcountry');
39  $oDb = oxDb::getDb();
40  $sCountryId = $this->getConfig()->getRequestParameter('oxid');
41  $sSynchCountryId = $this->getConfig()->getRequestParameter('synchoxid');
42 
43  // category selected or not ?
44  if (!$sCountryId) {
45  // which fields to load ?
46  $sQAdd = " from $sCountryTable where $sCountryTable.oxactive = '1' ";
47  } else {
48 
49  $sQAdd = " from oxobject2payment left join $sCountryTable on $sCountryTable.oxid=oxobject2payment.oxobjectid ";
50  $sQAdd .= "where $sCountryTable.oxactive = '1' and oxobject2payment.oxpaymentid = " . $oDb->quote($sCountryId) . " and oxobject2payment.oxtype = 'oxcountry' ";
51  }
52 
53  if ($sSynchCountryId && $sSynchCountryId != $sCountryId) {
54  $sQAdd .= "and $sCountryTable.oxid not in ( ";
55  $sQAdd .= "select $sCountryTable.oxid from oxobject2payment left join $sCountryTable on $sCountryTable.oxid=oxobject2payment.oxobjectid ";
56  $sQAdd .= "where oxobject2payment.oxpaymentid = " . $oDb->quote($sSynchCountryId) . " and oxobject2payment.oxtype = 'oxcountry' ) ";
57  }
58 
59  return $sQAdd;
60  }
61 
65  public function addPayCountry()
66  {
67  $aChosenCntr = $this->_getActionIds('oxcountry.oxid');
68  $soxId = $this->getConfig()->getRequestParameter('synchoxid');
69 
70  if ($this->getConfig()->getRequestParameter('all')) {
71  $sCountryTable = $this->_getViewName('oxcountry');
72  $aChosenCntr = $this->_getAll($this->_addFilter("select $sCountryTable.oxid " . $this->_getQuery()));
73  }
74  if ($soxId && $soxId != "-1" && is_array($aChosenCntr)) {
75  foreach ($aChosenCntr as $sChosenCntr) {
76  $oObject2Payment = oxNew('oxbase');
77  $oObject2Payment->init('oxobject2payment');
78  $oObject2Payment->oxobject2payment__oxpaymentid = new oxField($soxId);
79  $oObject2Payment->oxobject2payment__oxobjectid = new oxField($sChosenCntr);
80  $oObject2Payment->oxobject2payment__oxtype = new oxField("oxcountry");
81  $oObject2Payment->save();
82  }
83  }
84  }
85 
89  public function removePayCountry()
90  {
91  $aChosenCntr = $this->_getActionIds('oxobject2payment.oxid');
92  if ($this->getConfig()->getRequestParameter('all')) {
93 
94  $sQ = $this->_addFilter("delete oxobject2payment.* " . $this->_getQuery());
95  oxDb::getDb()->Execute($sQ);
96 
97  } elseif (is_array($aChosenCntr)) {
98  $sQ = "delete from oxobject2payment where oxobject2payment.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aChosenCntr)) . ") ";
99  oxDb::getDb()->Execute($sQ);
100  }
101  }
102 }