deliveryset_groups_ajax.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class deliveryset_groups_ajax extends ajaxListComponent
00007 {
00008 
00014     protected $_aColumns = array('container1' => array( // field , table,  visible, multilanguage, ident
00015         array('oxtitle', 'oxgroups', 1, 0, 0),
00016         array('oxid', 'oxgroups', 0, 0, 0),
00017         array('oxid', 'oxgroups', 0, 0, 1),
00018     ),
00019                                  'container2' => array(
00020                                      array('oxtitle', 'oxgroups', 1, 0, 0),
00021                                      array('oxid', 'oxgroups', 0, 0, 0),
00022                                      array('oxid', 'oxobject2delivery', 0, 0, 1),
00023                                  )
00024     );
00025 
00031     protected function _getQuery()
00032     {
00033         $oDb = oxDb::getDb();
00034         $sId = $this->getConfig()->getRequestParameter('oxid');
00035         $sSynchId = $this->getConfig()->getRequestParameter('synchoxid');
00036 
00037         $sgroupTable = $this->_getViewName('oxgroups');
00038 
00039         // category selected or not ?
00040         if (!$sId) {
00041             $sQAdd = " from $sgroupTable where 1 ";
00042         } else {
00043             $sQAdd = " from oxobject2delivery, {$sgroupTable} " .
00044                      "where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sId) .
00045                      " and oxobject2delivery.oxobjectid = {$sgroupTable}.oxid " .
00046                      "and oxobject2delivery.oxtype = 'oxdelsetg' ";
00047         }
00048 
00049         if ($sSynchId && $sSynchId != $sId) {
00050             $sQAdd .= " and {$sgroupTable}.oxid not in ( select {$sgroupTable}.oxid " .
00051                       "from oxobject2delivery, {$sgroupTable} " .
00052                       "where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sSynchId) .
00053                       " and oxobject2delivery.oxobjectid = $sgroupTable.oxid " .
00054                       "and oxobject2delivery.oxtype = 'oxdelsetg' ) ";
00055         }
00056 
00057         return $sQAdd;
00058     }
00059 
00063     public function removeGroupFromSet()
00064     {
00065         $aRemoveGroups = $this->_getActionIds('oxobject2delivery.oxid');
00066         if ($this->getConfig()->getRequestParameter('all')) {
00067 
00068             $sQ = $this->_addFilter("delete oxobject2delivery.* " . $this->_getQuery());
00069             oxDb::getDb()->Execute($sQ);
00070 
00071         } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
00072             $sRemoveGroups = implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups));
00073             $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . $sRemoveGroups . ") ";
00074             oxDb::getDb()->Execute($sQ);
00075         }
00076     }
00077 
00081     public function addGroupToSet()
00082     {
00083         $aChosenCat = $this->_getActionIds('oxgroups.oxid');
00084         $soxId = $this->getConfig()->getRequestParameter('synchoxid');
00085 
00086         // adding
00087         if ($this->getConfig()->getRequestParameter('all')) {
00088             $sGroupTable = $this->_getViewName('oxgroups');
00089             $aChosenCat = $this->_getAll($this->_addFilter("select $sGroupTable.oxid " . $this->_getQuery()));
00090         }
00091         if ($soxId && $soxId != "-1" && is_array($aChosenCat)) {
00092             foreach ($aChosenCat as $sChosenCat) {
00093                 $oObject2Delivery = oxNew('oxbase');
00094                 $oObject2Delivery->init('oxobject2delivery');
00095                 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00096                 $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenCat);
00097                 $oObject2Delivery->oxobject2delivery__oxtype = new oxField("oxdelsetg");
00098                 $oObject2Delivery->save();
00099             }
00100         }
00101     }
00102 }