deliveryset_main_ajax.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class deliveryset_main_ajax extends ajaxListComponent
00007 {
00008 
00014     protected $_aColumns = array('container1' => array( // field , table,         visible, multilanguage, ident
00015         array('oxtitle', 'oxdelivery', 1, 1, 0),
00016         array('oxaddsum', 'oxdelivery', 1, 0, 0),
00017         array('oxaddsumtype', 'oxdelivery', 1, 0, 0),
00018         array('oxid', 'oxdelivery', 0, 0, 1)
00019     ),
00020                                  'container2' => array(
00021                                      array('oxtitle', 'oxdelivery', 1, 1, 0),
00022                                      array('oxaddsum', 'oxdelivery', 1, 0, 0),
00023                                      array('oxaddsumtype', 'oxdelivery', 1, 0, 0),
00024                                      array('oxid', 'oxdel2delset', 0, 0, 1)
00025                                  )
00026     );
00027 
00033     protected function _getQuery()
00034     {
00035         $sId = $this->getConfig()->getRequestParameter('oxid');
00036         $sSynchId = $this->getConfig()->getRequestParameter('synchoxid');
00037         $oDb = oxDb::getDb();
00038 
00039         $sDeliveryViewName = $this->_getViewName('oxdelivery');
00040 
00041         // category selected or not ?
00042         if (!$sId) {
00043             $sQAdd = " from $sDeliveryViewName where 1 ";
00044         } else {
00045             $sQAdd = " from $sDeliveryViewName left join oxdel2delset on oxdel2delset.oxdelid=$sDeliveryViewName.oxid ";
00046             $sQAdd .= "where oxdel2delset.oxdelsetid = " . $oDb->quote($sId);
00047         }
00048 
00049         if ($sSynchId && $sSynchId != $sId) {
00050             $sQAdd .= "and $sDeliveryViewName.oxid not in ( select $sDeliveryViewName.oxid from $sDeliveryViewName left join oxdel2delset on oxdel2delset.oxdelid=$sDeliveryViewName.oxid ";
00051             $sQAdd .= "where oxdel2delset.oxdelsetid = " . $oDb->quote($sSynchId) . " ) ";
00052         }
00053 
00054         return $sQAdd;
00055     }
00056 
00060     public function removeFromSet()
00061     {
00062         $aRemoveGroups = $this->_getActionIds('oxdel2delset.oxid');
00063         if ($this->getConfig()->getRequestParameter('all')) {
00064 
00065             $sQ = $this->_addFilter("delete oxdel2delset.* " . $this->_getQuery());
00066             oxDb::getDb()->Execute($sQ);
00067 
00068         } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
00069             $sQ = "delete from oxdel2delset where oxdel2delset.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups)) . ") ";
00070             oxDb::getDb()->Execute($sQ);
00071         }
00072     }
00073 
00077     public function addToSet()
00078     {
00079         $aChosenSets = $this->_getActionIds('oxdelivery.oxid');
00080         $soxId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
00081 
00082         // adding
00083         if ($this->getConfig()->getRequestParameter('all')) {
00084             $sDeliveryViewName = $this->_getViewName('oxdelivery');
00085             $aChosenSets = $this->_getAll($this->_addFilter("select $sDeliveryViewName.oxid " . $this->_getQuery()));
00086         }
00087         if ($soxId && $soxId != "-1" && is_array($aChosenSets)) {
00088             $oDb = oxDb::getDb();
00089             foreach ($aChosenSets as $sChosenSet) {
00090                 // check if we have this entry already in
00091                 $sID = $oDb->getOne("select oxid from oxdel2delset where oxdelid =  " . $oDb->quote($sChosenSet) . " and oxdelsetid = " . $oDb->quote($soxId), false, false);
00092                 if (!isset($sID) || !$sID) {
00093                     $oDel2delset = oxNew('oxbase');
00094                     $oDel2delset->init('oxdel2delset');
00095                     $oDel2delset->oxdel2delset__oxdelid = new oxField($sChosenSet);
00096                     $oDel2delset->oxdel2delset__oxdelsetid = new oxField($soxId);
00097                     $oDel2delset->save();
00098                 }
00099             }
00100         }
00101     }
00102 }