order_list.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Order_List extends oxAdminList
00010 {
00016     protected $_sListClass = 'oxorder';
00017 
00023     protected $_blDesc = true;
00024 
00030     protected $_sDefSort = "oxorder.oxorderdate";
00031 
00038     public function render()
00039     {
00040         parent::render();
00041 
00042         $aFolders = $this->getConfig()->getConfigParam( 'aOrderfolder' );
00043         $sFolder  = oxConfig::getParameter( "folder" );
00044         // first display new orders
00045         if ( !$sFolder && is_array( $aFolders )) {
00046             $aNames = array_keys( $aFolders );
00047             $sFolder = $aNames[0];
00048         }
00049 
00050         $aSearch    = array( 'oxorderarticles' => 'ARTID', 'oxpayments' => 'PAYMENT');
00051         $sSearch    = oxConfig::getParameter( "addsearch" );
00052         $sSearchfld = oxConfig::getParameter( "addsearchfld" );
00053 
00054         $this->_aViewData["folder"]       = $sFolder ? $sFolder : -1;
00055         $this->_aViewData["addsearchfld"] = $sSearchfld ? $sSearchfld : -1;
00056         $this->_aViewData["asearch"]      = $aSearch;
00057         $this->_aViewData["addsearch"]    = $sSearch;
00058         $this->_aViewData["afolder"]      = $aFolders;
00059 
00060         return "order_list.tpl";
00061     }
00062 
00068     function buildWhere()
00069     {
00070         $myConfig = $this->getConfig();
00071         $aFolders = $myConfig->getConfigParam( 'aOrderfolder' );
00072 
00073         $this->_aWhere = parent::buildWhere();
00074         if ( !is_array($this->_aWhere))
00075             $this->_aWhere = array();
00076 
00077         $sFolder = oxConfig::getParameter( 'folder' );
00078         if ( $sFolder && $sFolder != '-1' ) {
00079             $this->_aWhere["oxorder.oxfolder"] = $sFolder;
00080         } elseif ( !$sFolder && is_array( $aFolders ) ) {
00081             $aFolderNames = array_keys( $aFolders );
00082             $this->_aWhere["oxorder.oxfolder"] = $aFolderNames[0];
00083         }
00084         return $this->_aWhere;
00085     }
00086 
00094     protected function _buildSelectString( $oListObject = null )
00095     {
00096         $sSql = parent::_buildSelectString( $oListObject );
00097 
00098         $sSearch      = oxConfig::getParameter( 'addsearch' );
00099         $sSearch      = trim( $sSearch );
00100         $sSearchField = oxConfig::getParameter( 'addsearchfld' );
00101 
00102         if ( $sSearch ) {
00103             switch ($sSearchField) {
00104             case 'oxorderarticles':
00105                 $sQ = "oxorder left join oxorderarticles on oxorderarticles.oxorderid=oxorder.oxid where ( oxorderarticles.oxartnum like '%{$sSearch}%' or oxorderarticles.oxtitle like '%{$sSearch}%' ) and ";
00106                 break;
00107             case 'oxpayments':
00108                 $sQ = "oxorder left join oxpayments on oxpayments.oxid=oxorder.oxpaymenttype where oxpayments.oxdesc like '%{$sSearch}%' and ";
00109                 break;
00110             default:
00111                 $sQ = "oxorder where oxorder.oxpaid like '%{$sSearch}%' and ";
00112                 break;
00113             }
00114             $sSql = str_replace( 'oxorder where', $sQ, $sSql);
00115         }
00116 
00117         return $sSql;
00118     }
00119 
00124     public function storno()
00125     {
00126         $myConfig = $this->getConfig();
00127         $soxId    = oxConfig::getParameter( "oxid");
00128 
00129         $oOrder = oxNew( "oxorder" );
00130         $oOrder->load( $soxId);
00131         $oOrder->oxorder__oxstorno->setValue(1);
00132         $oOrder->save();
00133 
00134         // stock information
00135         $blUseStock = $myConfig->getConfigParam( 'blUseStock' );
00136         $blAllowNegativeStock = $myConfig->getConfigParam('blAllowNegativeStock');
00137         $oDB = oxDb::getDb();
00138         foreach ( $oOrder->getOrderArticles() as $oArticle) {
00139             if ( $oArticle->oxorderarticles__oxstorno->value == 0) {
00140                 if ( $blUseStock )
00141                     $oArticle->updateArticleStock($oArticle->oxorderarticles__oxamount->value, $blAllowNegativeStock );
00142                 $oDB->execute( "update oxorderarticles set oxorderarticles.oxstorno = '1' where oxorderarticles.oxid = '".$oArticle->oxorderarticles__oxid->value."' ");
00143             }
00144         }
00145 
00146 
00147         //we call init() here to loads list items after sorno()
00148         $this->init();
00149     }
00150 
00158     protected function _prepareOrderByQuery( $sSql = null )
00159     {
00160         $sSortParam = oxConfig::getParameter( 'sort' );
00161 
00162         //setting sort order as ASC for oxbilllname column
00163         if ( $sSortParam && $sSortParam == 'oxorder.oxbilllname' )
00164            $this->_blDesc = false;
00165 
00166         return parent::_prepareOrderByQuery( $sSql );
00167     }
00168 }

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