delivery_groups_ajax.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class delivery_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         $myConfig = $this->getConfig();
00034         $oDb = oxDb::getDb();
00035 
00036         // active AJAX component
00037         $sGroupTable = $this->_getViewName('oxgroups');
00038 
00039         $sId = $myConfig->getRequestParameter('oxid');
00040         $sSynchId = $myConfig->getRequestParameter('synchoxid');
00041 
00042         // category selected or not ?
00043         if (!$sId) {
00044             $sQAdd = " from {$sGroupTable} where 1 ";
00045         } else {
00046             $sQAdd = " from oxobject2delivery left join {$sGroupTable} " .
00047                      "on {$sGroupTable}.oxid=oxobject2delivery.oxobjectid " .
00048                      " where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sId) .
00049                      " and oxobject2delivery.oxtype = 'oxgroups' ";
00050         }
00051 
00052         if ($sSynchId && $sSynchId != $sId) {
00053             $sQAdd .= " and {$sGroupTable}.oxid not in ( select {$sGroupTable}.oxid " .
00054                       "from oxobject2delivery left join {$sGroupTable} " .
00055                       "on {$sGroupTable}.oxid=oxobject2delivery.oxobjectid " .
00056                       " where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sSynchId) .
00057                       " and oxobject2delivery.oxtype = 'oxgroups' ) ";
00058         }
00059 
00060         return $sQAdd;
00061     }
00062 
00066     public function removeGroupFromDel()
00067     {
00068         $aRemoveGroups = $this->_getActionIds('oxobject2delivery.oxid');
00069         if ($this->getConfig()->getRequestParameter('all')) {
00070 
00071             $sQ = $this->_addFilter("delete oxobject2delivery.* " . $this->_getQuery());
00072             oxDb::getDb()->Execute($sQ);
00073 
00074         } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
00075             $sRemoveGroups = implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups));
00076             $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . $sRemoveGroups . ") ";
00077             oxDb::getDb()->Execute($sQ);
00078         }
00079     }
00080 
00084     public function addGroupToDel()
00085     {
00086         $aChosenCat = $this->_getActionIds('oxgroups.oxid');
00087         $soxId = $this->getConfig()->getRequestParameter('synchoxid');
00088 
00089         // adding
00090         if ($this->getConfig()->getRequestParameter('all')) {
00091             $sGroupTable = $this->_getViewName('oxgroups');
00092             $aChosenCat = $this->_getAll($this->_addFilter("select $sGroupTable.oxid " . $this->_getQuery()));
00093         }
00094 
00095         if ($soxId && $soxId != "-1" && is_array($aChosenCat)) {
00096             foreach ($aChosenCat as $sChosenCat) {
00097                 $oObject2Delivery = oxNew('oxbase');
00098                 $oObject2Delivery->init('oxobject2delivery');
00099                 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00100                 $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenCat);
00101                 $oObject2Delivery->oxobject2delivery__oxtype = new oxField('oxgroups');
00102                 $oObject2Delivery->save();
00103             }
00104         }
00105     }
00106 }