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
00065 $oThisCurr = $myConfig->getCurrencyObject( $oListItem->oxpricealarm__oxcurrency->value );
00066
00067
00068
00069 if ( !$oThisCurr ) {
00070 $oThisCurr = $myConfig->getCurrencyObject( $oDefCurr->name );
00071 $oListItem->oxpricealarm__oxcurrency->setValue($oDefCurr->name);
00072 }
00073
00074
00075
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
00090 $oListItem->iStatus = 0;
00091
00092
00093 if ( $oListItem->oxpricealarm__oxprice->value >= $dArtPrice)
00094 $oListItem->iStatus = 1;
00095
00096
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
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 }