OXID eShop CE  4.10.0
 All Classes Namespaces Files Functions Variables Pages
deliveryset_payment_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('oxdesc', 'oxpayments', 1, 1, 0),
16  array('oxaddsum', 'oxpayments', 1, 0, 0),
17  array('oxaddsumtype', 'oxpayments', 0, 0, 0),
18  array('oxid', 'oxpayments', 0, 0, 1)
19  ),
20  'container2' => array(
21  array('oxdesc', 'oxpayments', 1, 1, 0),
22  array('oxaddsum', 'oxpayments', 1, 0, 0),
23  array('oxaddsumtype', 'oxpayments', 0, 0, 0),
24  array('oxid', 'oxobject2payment', 0, 0, 1)
25  )
26  );
27 
33  protected function _getQuery()
34  {
35  $oDb = oxDb::getDb();
36  $sId = $this->getConfig()->getRequestParameter('oxid');
37  $sSynchId = $this->getConfig()->getRequestParameter('synchoxid');
38 
39  $sPayTable = $this->_getViewName('oxpayments');
40 
41  // category selected or not ?
42  if (!$sId) {
43  $sQAdd = " from $sPayTable where 1 ";
44  } else {
45  $sQAdd = " from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = " . $oDb->quote($sId);
46  $sQAdd .= " and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ";
47  }
48 
49  if ($sSynchId && $sSynchId != $sId) {
50  $sQAdd .= "and $sPayTable.oxid not in ( select $sPayTable.oxid from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = " . $oDb->quote($sSynchId);
51  $sQAdd .= "and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ) ";
52  }
53 
54  return $sQAdd;
55  }
56 
60  public function removePayFromSet()
61  {
62  $aChosenCntr = $this->_getActionIds('oxobject2payment.oxid');
63  if ($this->getConfig()->getRequestParameter('all')) {
64 
65  $sQ = $this->_addFilter("delete oxobject2payment.* " . $this->_getQuery());
66  oxDb::getDb()->Execute($sQ);
67 
68  } elseif (is_array($aChosenCntr)) {
69  $sQ = "delete from oxobject2payment where oxobject2payment.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aChosenCntr)) . ") ";
70  oxDb::getDb()->Execute($sQ);
71  }
72  }
73 
77  public function addPayToSet()
78  {
79  $aChosenSets = $this->_getActionIds('oxpayments.oxid');
80  $soxId = $this->getConfig()->getRequestParameter('synchoxid');
81 
82  // adding
83  if ($this->getConfig()->getRequestParameter('all')) {
84  $sPayTable = $this->_getViewName('oxpayments');
85  $aChosenSets = $this->_getAll($this->_addFilter("select $sPayTable.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 oxobject2payment where oxpaymentid = " . $oDb->quote($sChosenSet) . " and oxobjectid = " . $oDb->quote($soxId) . " and oxtype = 'oxdelset'", false, false);
92  if (!isset($sID) || !$sID) {
93  $oObject = oxNew('oxbase');
94  $oObject->init('oxobject2payment');
95  $oObject->oxobject2payment__oxpaymentid = new oxField($sChosenSet);
96  $oObject->oxobject2payment__oxobjectid = new oxField($soxId);
97  $oObject->oxobject2payment__oxtype = new oxField("oxdelset");
98  $oObject->save();
99  }
100  }
101  }
102  }
103 }