00001 <?php
00002
00006 class deliveryset_payment_ajax extends ajaxListComponent
00007 {
00008
00014 protected $_aColumns = array('container1' => array(
00015 array('oxdesc', 'oxpayments', 1, 1, 0),
00016 array('oxaddsum', 'oxpayments', 1, 0, 0),
00017 array('oxaddsumtype', 'oxpayments', 0, 0, 0),
00018 array('oxid', 'oxpayments', 0, 0, 1)
00019 ),
00020 'container2' => array(
00021 array('oxdesc', 'oxpayments', 1, 1, 0),
00022 array('oxaddsum', 'oxpayments', 1, 0, 0),
00023 array('oxaddsumtype', 'oxpayments', 0, 0, 0),
00024 array('oxid', 'oxobject2payment', 0, 0, 1)
00025 )
00026 );
00027
00033 protected function _getQuery()
00034 {
00035 $oDb = oxDb::getDb();
00036 $sId = $this->getConfig()->getRequestParameter('oxid');
00037 $sSynchId = $this->getConfig()->getRequestParameter('synchoxid');
00038
00039 $sPayTable = $this->_getViewName('oxpayments');
00040
00041
00042 if (!$sId) {
00043 $sQAdd = " from $sPayTable where 1 ";
00044 } else {
00045 $sQAdd = " from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = " . $oDb->quote($sId);
00046 $sQAdd .= " and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ";
00047 }
00048
00049 if ($sSynchId && $sSynchId != $sId) {
00050 $sQAdd .= "and $sPayTable.oxid not in ( select $sPayTable.oxid from oxobject2payment, $sPayTable where oxobject2payment.oxobjectid = " . $oDb->quote($sSynchId);
00051 $sQAdd .= "and oxobject2payment.oxpaymentid = $sPayTable.oxid and oxobject2payment.oxtype = 'oxdelset' ) ";
00052 }
00053
00054 return $sQAdd;
00055 }
00056
00060 public function removePayFromSet()
00061 {
00062 $aChosenCntr = $this->_getActionIds('oxobject2payment.oxid');
00063 if ($this->getConfig()->getRequestParameter('all')) {
00064
00065 $sQ = $this->_addFilter("delete oxobject2payment.* " . $this->_getQuery());
00066 oxDb::getDb()->Execute($sQ);
00067
00068 } elseif (is_array($aChosenCntr)) {
00069 $sQ = "delete from oxobject2payment where oxobject2payment.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aChosenCntr)) . ") ";
00070 oxDb::getDb()->Execute($sQ);
00071 }
00072 }
00073
00077 public function addPayToSet()
00078 {
00079 $aChosenSets = $this->_getActionIds('oxpayments.oxid');
00080 $soxId = $this->getConfig()->getRequestParameter('synchoxid');
00081
00082
00083 if ($this->getConfig()->getRequestParameter('all')) {
00084 $sPayTable = $this->_getViewName('oxpayments');
00085 $aChosenSets = $this->_getAll($this->_addFilter("select $sPayTable.oxid " . $this->_getQuery()));
00086 }
00087 if ($soxId && $soxId != "-1" && is_array($aChosenSets)) {
00088 $oDb = oxDb::getDb();
00089 foreach ($aChosenSets as $sChosenSet) {
00090
00091 $sID = $oDb->getOne("select oxid from oxobject2payment where oxpaymentid = " . $oDb->quote($sChosenSet) . " and oxobjectid = " . $oDb->quote($soxId) . " and oxtype = 'oxdelset'", false, false);
00092 if (!isset($sID) || !$sID) {
00093 $oObject = oxNew('oxbase');
00094 $oObject->init('oxobject2payment');
00095 $oObject->oxobject2payment__oxpaymentid = new oxField($sChosenSet);
00096 $oObject->oxobject2payment__oxobjectid = new oxField($soxId);
00097 $oObject->oxobject2payment__oxtype = new oxField("oxdelset");
00098 $oObject->save();
00099 }
00100 }
00101 }
00102 }
00103 }