order_list.php

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

Generated on Wed Apr 22 12:26:30 2009 for OXID eShop CE by  doxygen 1.5.5