delivery_categories.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', 'oxcategories', 1, 1, 0 ),
00005                                         array( 'oxdesc',  'oxcategories', 1, 1, 0 ),
00006                                         array( 'oxid',    'oxcategories', 0, 0, 1 )
00007                                         ),
00008                      'container2' => array(
00009                                         array( 'oxtitle', 'oxcategories', 1, 1, 0 ),
00010                                         array( 'oxdesc',  'oxcategories', 1, 1, 0 ),
00011                                         array( 'oxid',    'oxobject2delivery', 0, 0, 1 ),
00012                                         array( 'oxid',    'oxcategories',      0, 0, 1 )
00013                                         ),
00014                    );
00018 class ajaxComponent extends ajaxListComponent
00019 {
00025     protected function _getQuery()
00026     {
00027         $myConfig = $this->getConfig();
00028 
00029         // looking for table/view
00030         $sCatTable = getViewName('oxcategories');
00031 
00032         $sDelId      = oxConfig::getParameter( 'oxid' );
00033         $sSynchDelId = oxConfig::getParameter( 'synchoxid' );
00034 
00035         // category selected or not ?
00036         if ( !$sDelId) {
00037             $sQAdd  = " from $sCatTable where $sCatTable.oxshopid = '".$myConfig->getShopId()."' ";
00038         } else {
00039             $sQAdd  = " from oxobject2delivery left join $sCatTable on $sCatTable.oxid=oxobject2delivery.oxobjectid ";
00040             $sQAdd .= " where oxobject2delivery.oxdeliveryid = '$sDelId' and oxobject2delivery.oxtype = 'oxcategories' ";
00041         }
00042 
00043         if ( $sSynchDelId && $sSynchDelId != $sDelId) {
00044             $sQAdd .= " and $sCatTable.oxid not in ( select $sCatTable.oxid from oxobject2delivery left join $sCatTable on $sCatTable.oxid=oxobject2delivery.oxobjectid ";
00045             $sQAdd .= " where oxobject2delivery.oxdeliveryid = '$sSynchDelId' and oxobject2delivery.oxtype = 'oxcategories' ) ";
00046         }
00047 
00048         return $sQAdd;
00049     }
00050 
00056     public function removecatfromdel()
00057     {
00058         $aChosenCat = $this->_getActionIds( 'oxobject2delivery.oxid' );
00059 
00060         // removing all
00061         if ( oxConfig::getParameter( 'all' ) ) {
00062 
00063             $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
00064             oxDb::getDb()->Execute( $sQ );
00065 
00066         } elseif ( is_array( $aChosenCat ) ) {
00067             $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in ('" . implode( "', '", $aChosenCat ) . "') ";
00068             oxDb::getDb()->Execute( $sQ );
00069         }
00070     }
00071 
00077     public function addcattodel()
00078     {
00079         $aChosenCat = $this->_getActionIds( 'oxcategories.oxid' );
00080         $soxId      = oxConfig::getParameter( 'synchoxid');
00081 
00082         // adding
00083         if ( oxConfig::getParameter( 'all' ) ) {
00084             $sCatTable = getViewName('oxcategories');
00085             $aChosenCat = $this->_getAll( $this->_addFilter( "select $sCatTable.oxid ".$this->_getQuery() ) );
00086         }
00087 
00088         if ( isset( $soxId) && $soxId != "-1" && isset( $aChosenCat) && $aChosenCat) {
00089             foreach ( $aChosenCat as $sChosenCat) {
00090                 $oObject2Delivery = oxNew( 'oxbase' );
00091                 $oObject2Delivery->init( 'oxobject2delivery' );
00092                 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00093                 $oObject2Delivery->oxobject2delivery__oxobjectid   = new oxField($sChosenCat);
00094                 $oObject2Delivery->oxobject2delivery__oxtype       = new oxField("oxcategories");
00095                 $oObject2Delivery->save();
00096             }
00097         }
00098     }
00099 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5