deliveryset_main.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',      'oxdelivery', 1, 1, 0 ),
00005                                         array( 'oxaddsum',     'oxdelivery', 1, 0, 0 ),
00006                                         array( 'oxaddsumtype', 'oxdelivery', 1, 0, 0 ),
00007                                         array( 'oxid',         'oxdelivery', 0, 0, 1 )
00008                                         ),
00009                      'container2' => array(
00010                                         array( 'oxtitle',      'oxdelivery', 1, 1, 0 ),
00011                                         array( 'oxaddsum',     'oxdelivery', 1, 0, 0 ),
00012                                         array( 'oxaddsumtype', 'oxdelivery', 1, 0, 0 ),
00013                                         array( 'oxid',  'oxdel2delset', 0, 0, 1 )
00014                                         )
00015                     );
00019 class ajaxComponent extends ajaxListComponent
00020 {
00026     protected function _getQuery()
00027     {
00028         $sId = oxConfig::getParameter( 'oxid' );
00029         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00030         $oDb = oxDb::getDb();
00031 
00032         $sDeliveryViewName = $this->_getViewName('oxdelivery');
00033 
00034         // category selected or not ?
00035         if ( !$sId) {
00036             $sQAdd  = " from $sDeliveryViewName where 1 ";
00037         } else {
00038             $sQAdd  = " from $sDeliveryViewName left join oxdel2delset on oxdel2delset.oxdelid=$sDeliveryViewName.oxid ";
00039             $sQAdd .= "where oxdel2delset.oxdelsetid = ".$oDb->quote( $sId );
00040         }
00041 
00042         if ( $sSynchId && $sSynchId != $sId ) {
00043             $sQAdd .= "and $sDeliveryViewName.oxid not in ( select $sDeliveryViewName.oxid from $sDeliveryViewName left join oxdel2delset on oxdel2delset.oxdelid=$sDeliveryViewName.oxid ";
00044             $sQAdd .= "where oxdel2delset.oxdelsetid = ".$oDb->quote( $sSynchId ) ." ) ";
00045         }
00046 
00047         return $sQAdd;
00048     }
00049 
00055     public function removefromset()
00056     {
00057         $aRemoveGroups = $this->_getActionIds( 'oxdel2delset.oxid' );
00058         if ( oxConfig::getParameter( 'all' ) ) {
00059 
00060             $sQ = $this->_addFilter( "delete oxdel2delset.* ".$this->_getQuery() );
00061             oxDb::getDb()->Execute( $sQ );
00062 
00063         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00064             $sQ = "delete from oxdel2delset where oxdel2delset.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
00065             oxDb::getDb()->Execute( $sQ );
00066         }
00067     }
00068 
00074     public function addtoset()
00075     {
00076         $aChosenSets = $this->_getActionIds( 'oxdelivery.oxid' );
00077         $soxId       = oxConfig::getParameter( 'synchoxid');
00078 
00079         // adding
00080         if ( oxConfig::getParameter( 'all' ) ) {
00081             $sDeliveryViewName = $this->_getViewName('oxdelivery');
00082             $aChosenSets = $this->_getAll( $this->_addFilter( "select $sDeliveryViewName.oxid ".$this->_getQuery() ) );
00083         }
00084         if ( $soxId && $soxId != "-1" && is_array( $aChosenSets ) ) {
00085             $oDb = oxDb::getDb();
00086             foreach ( $aChosenSets as $sChosenSet) {
00087                 // check if we have this entry already in
00088                 $sID = $oDb->GetOne("select oxid from oxdel2delset where oxdelid =  " . $oDb->quote( $sChosenSet ) . " and oxdelsetid = ".$oDb->quote( $soxId ) );
00089                 if ( !isset( $sID) || !$sID) {
00090                     $oDel2delset = oxNew( 'oxbase' );
00091                     $oDel2delset->init( 'oxdel2delset' );
00092                     $oDel2delset->oxdel2delset__oxdelid    = new oxField($sChosenSet);
00093                     $oDel2delset->oxdel2delset__oxdelsetid = new oxField($soxId);
00094                     $oDel2delset->save();
00095                 }
00096             }
00097         }
00098     }
00099 }