pricealarm_list.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class PriceAlarm_List extends oxAdminList
00009 {
00015     protected $_sListClass = 'oxpricealarm';
00016 
00022     protected $_sDefSort = "oxpricealarm.oxuserid";
00023 
00031     protected function _buildSelectString( $oListObject = null )
00032     {
00033         $sSql  = "select oxpricealarm.*, oxarticles.oxtitle AS articletitle, ";
00034         $sSql .= "oxuser.oxlname as userlname, oxuser.oxfname as userfname ";
00035         $sSql .= "from oxpricealarm ";
00036         $sSql .= "left join oxarticles on oxarticles.oxid = oxpricealarm.oxartid ";
00037         $sSql .= "left join oxuser on oxuser.oxid = oxpricealarm.oxuserid WHERE 1 ";
00038 
00039         return $sSql;
00040     }
00041 
00048     public function render()
00049     {
00050         $myConfig = $this->getConfig();
00051 
00052         parent::render();
00053 
00054 
00055         $oDefCurr = $myConfig->getActShopCurrencyObject();
00056         $myUtils  = oxUtils::getInstance();
00057         $myLang   = oxLang::getInstance();
00058 
00059         foreach ( $this->_aViewData["mylist"] as $oListItem ) {
00060 
00061             $oArticle = oxNew( "oxarticle" );
00062             $oArticle->load($oListItem->oxpricealarm__oxartid->value);
00063 
00064             //$oListI = $this->_aViewData["mylist"][$sItemId];
00065             $oThisCurr = $myConfig->getCurrencyObject( $oListItem->oxpricealarm__oxcurrency->value );
00066 
00067             // #869A we should perform currency conversion
00068             // (older versions doesn't have currency info - assume as it is default - first in currency array)
00069             if ( !$oThisCurr ) {
00070                 $oThisCurr = $myConfig->getCurrencyObject( $oDefCurr->name );
00071                 $oListItem->oxpricealarm__oxcurrency->setValue($oDefCurr->name);
00072             }
00073 
00074             // #889C - Netto prices in Admin
00075             // (we have to call $oArticle->getPrice() to get price with VAT)
00076             $dArtPrice = $oArticle->getPrice()->getBruttoPrice() * $oThisCurr->rate;
00077             $dArtPrice = $myUtils->fRound( $dArtPrice );
00078 
00079             $oListItem->fprice = $myLang->formatCurrency( $dArtPrice, $oThisCurr );
00080 
00081             if ( $oArticle->oxarticles__oxparentid->value && !$oArticle->oxarticles__oxtitle->value) {
00082                 $oParent = oxNew( "oxarticle" );
00083                 $oParent->load($oArticle->oxarticles__oxparentid->value);
00084                 $oListItem->oxpricealarm__articletitle = new oxField( $oParent->oxarticles__oxtitle->value." ".$oArticle->oxarticles__oxvarselect->value );
00085             }
00086 
00087             $oListItem->fpricealarmprice = $myLang->formatCurrency( $oListItem->oxpricealarm__oxprice->value, $oThisCurr);
00088 
00089             // neutral status
00090             $oListItem->iStatus = 0;
00091 
00092             // shop price is less or equal
00093             if ( $oListItem->oxpricealarm__oxprice->value >= $dArtPrice)
00094                 $oListItem->iStatus = 1;
00095 
00096             // suggestion to user is sent
00097             if ( $oListItem->oxpricealarm__oxsended->value != "0000-00-00 00:00:00")
00098                 $oListItem->iStatus = 2;
00099         }
00100 
00101         return "pricealarm_list.tpl";
00102     }
00103 
00109     public function buildWhere()
00110     {
00111         $this->_aWhere = parent::buildWhere();
00112 
00113         if ( !is_array($this->_aWhere))
00114             $this->_aWhere = array();
00115 
00116         // updating price fields values for correct search in DB
00117         if ( $this->_aWhere['oxpricealarm.oxprice'] ) {
00118             $sPriceParam = (double) str_replace(array('%',','), array('', '.'), $this->_aWhere['oxpricealarm.oxprice']);
00119             $this->_aWhere['oxpricealarm.oxprice'] = '%'. $sPriceParam. '%';
00120         }
00121 
00122         if ( $this->_aWhere['oxarticles.oxprice'] ) {
00123             $sPriceParam = (double) str_replace(array('%',','), array('', '.'), $this->_aWhere['oxarticles.oxprice']);
00124             $this->_aWhere['oxarticles.oxprice'] = '%'. $sPriceParam. '%';
00125         }
00126 
00127         return $this->_aWhere;
00128     }
00129 
00130 }

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5