OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
deliveryset_payment_ajax.php
Go to the documentation of this file.
1 <?php
2 
7 {
13  protected $_aColumns = array( 'container1' => array( // field , table, visible, multilanguage, ident
14  array( 'oxdesc', 'oxpayments', 1, 1, 0 ),
15  array( 'oxaddsum', 'oxpayments', 1, 0, 0 ),
16  array( 'oxaddsumtype', 'oxpayments', 0, 0, 0 ),
17  array( 'oxid', 'oxpayments', 0, 0, 1 )
18  ),
19  'container2' => array(
20  array( 'oxdesc', 'oxpayments', 1, 1, 0 ),
21  array( 'oxaddsum', 'oxpayments', 1, 0, 0 ),
22  array( 'oxaddsumtype', 'oxpayments', 0, 0, 0 ),
23  array( 'oxid', 'oxobject2payment', 0, 0, 1 )
24  )
25  );
26 
32  protected function _getQuery()
33  {
34  $oDb = oxDb::getDb();
35  $sId = $this->getConfig()->getRequestParameter( 'oxid' );
36  $sSynchId = $this->getConfig()->getRequestParameter( 'synchoxid' );
37 
38  $sPayTable = $this->_getViewName('oxpayments');
39 
40  // category selected or not ?
41  if ( !$sId) {
42  $sQAdd = " from $sPayTable where 1 ";
43  } else {
44  $sQAdd = " from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = ".$oDb->quote( $sId );
45  $sQAdd .= " and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ";
46  }
47 
48  if ( $sSynchId && $sSynchId != $sId) {
49  $sQAdd .= "and $sPayTable.oxid not in ( select $sPayTable.oxid from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = ".$oDb->quote( $sSynchId );
50  $sQAdd .= "and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ) ";
51  }
52 
53  return $sQAdd;
54  }
55 
61  public function removePayFromSet()
62  {
63  $aChosenCntr = $this->_getActionIds( 'oxobject2payment.oxid' );
64  if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
65 
66  $sQ = $this->_addFilter( "delete oxobject2payment.* ".$this->_getQuery() );
67  oxDb::getDb()->Execute( $sQ );
68 
69  } elseif ( is_array( $aChosenCntr ) ) {
70  $sQ = "delete from oxobject2payment where oxobject2payment.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenCntr ) ) . ") ";
71  oxDb::getDb()->Execute( $sQ );
72  }
73  }
74 
80  public function addPayToSet()
81  {
82  $aChosenSets = $this->_getActionIds( 'oxpayments.oxid' );
83  $soxId = $this->getConfig()->getRequestParameter( 'synchoxid');
84 
85  // adding
86  if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
87  $sPayTable = $this->_getViewName('oxpayments');
88  $aChosenSets = $this->_getAll( $this->_addFilter( "select $sPayTable.oxid ".$this->_getQuery() ) );
89  }
90  if ( $soxId && $soxId != "-1" && is_array( $aChosenSets ) ) {
91  $oDb = oxDb::getDb();
92  foreach ( $aChosenSets as $sChosenSet) {
93  // check if we have this entry already in
94  $sID = $oDb->getOne("select oxid from oxobject2payment where oxpaymentid = " . $oDb->quote( $sChosenSet ) . " and oxobjectid = ".$oDb->quote( $soxId )." and oxtype = 'oxdelset'", false, false);
95  if ( !isset( $sID) || !$sID) {
96  $oObject = oxNew( 'oxbase' );
97  $oObject->init( 'oxobject2payment' );
98  $oObject->oxobject2payment__oxpaymentid = new oxField($sChosenSet);
99  $oObject->oxobject2payment__oxobjectid = new oxField($soxId);
100  $oObject->oxobject2payment__oxtype = new oxField("oxdelset");
101  $oObject->save();
102  }
103  }
104  }
105  }
106 }