delivery_groups.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,  visible, multilanguage, ident
00004                                         array( 'oxtitle',  'oxgroups', 1, 0, 0 ),
00005                                         array( 'oxid',     'oxgroups', 0, 0, 0 ),
00006                                         array( 'oxid',     'oxgroups', 0, 0, 1 ),
00007                                         ),
00008                      'container2' => array(
00009                                         array( 'oxtitle',  'oxgroups', 1, 0, 0 ),
00010                                         array( 'oxid',     'oxgroups', 0, 0, 0 ),
00011                                         array( 'oxid',     'oxobject2delivery', 0, 0, 1 ),
00012                                         )
00013                     );
00017 class ajaxComponent extends ajaxListComponent
00018 {
00024     protected function _getQuery()
00025     {
00026         $myConfig = $this->getConfig();
00027         $oDb = oxDb::getDb();
00028 
00029         // active AJAX component
00030         $sGroupTable = $this->_getViewName('oxgroups');
00031 
00032         $sId      = oxConfig::getParameter( 'oxid' );
00033         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00034 
00035         // category selected or not ?
00036         if ( !$sId ) {
00037             $sQAdd  = " from $sGroupTable where 1 ";
00038         } else {
00039             $sQAdd  = " from oxobject2delivery left join $sGroupTable on $sGroupTable.oxid=oxobject2delivery.oxobjectid ";
00040             $sQAdd .= " where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sId )." and oxobject2delivery.oxtype = 'oxgroups' ";
00041         }
00042 
00043         if ( $sSynchId && $sSynchId != $sId ) {
00044             $sQAdd .= " and $sGroupTable.oxid not in ( select $sGroupTable.oxid from oxobject2delivery left join $sGroupTable on $sGroupTable.oxid=oxobject2delivery.oxobjectid ";
00045             $sQAdd .= " where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sSynchId )." and oxobject2delivery.oxtype = 'oxgroups' ) ";
00046         }
00047 
00048         return $sQAdd;
00049     }
00050 
00056     public function removegroupfromdel()
00057     {
00058         $aRemoveGroups = $this->_getActionIds( 'oxobject2delivery.oxid' );
00059         if ( oxConfig::getParameter( 'all' ) ) {
00060 
00061             $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
00062             oxDb::getDb()->Execute( $sQ );
00063 
00064         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00065             $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
00066             oxDb::getDb()->Execute( $sQ );
00067         }
00068     }
00069 
00075     public function addgrouptodel()
00076     {
00077         $aChosenCat = $this->_getActionIds( 'oxgroups.oxid' );
00078         $soxId      = oxConfig::getParameter( 'synchoxid' );
00079 
00080         // adding
00081         if ( oxConfig::getParameter( 'all' ) ) {
00082             $sGroupTable = $this->_getViewName('oxgroups');
00083             $aChosenCat = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
00084         }
00085 
00086         if ( $soxId && $soxId != "-1" && is_array( $aChosenCat ) ) {
00087             foreach ( $aChosenCat as $sChosenCat) {
00088                 $oObject2Delivery = oxNew( 'oxbase' );
00089                 $oObject2Delivery->init( 'oxobject2delivery' );
00090                 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00091                 $oObject2Delivery->oxobject2delivery__oxobjectid   = new oxField($sChosenCat);
00092                 $oObject2Delivery->oxobject2delivery__oxtype       = new oxField('oxgroups');
00093                 $oObject2Delivery->save();
00094             }
00095         }
00096     }
00097 }