pricealarm_main.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class PriceAlarm_Main extends oxAdminDetails
00009 {
00017     public function render()
00018     {   $myConfig = $this->getConfig();
00019 
00020             // #1140 R - price must be checked from the object.
00021             $sql = "select oxarticles.oxid, oxpricealarm.oxprice from oxpricealarm, oxarticles where oxarticles.oxid = oxpricealarm.oxartid and oxpricealarm.oxsended = '000-00-00 00:00:00'";
00022             $rs = oxDb::getDb()->Execute( $sql);
00023             $iAllCnt_counting = 0;
00024             if ($rs != false && $rs->recordCount() > 0) {
00025                 while (!$rs->EOF) {
00026                     $oArticle = oxNew("oxarticle" );
00027                     $oArticle->load($rs->fields[0]);
00028                     if ($oArticle->getPrice()->getBruttoPrice() <= $rs->fields[1])
00029                         $iAllCnt_counting++;
00030                     $rs->moveNext();
00031                 }
00032             }
00033             $this->_aViewData['iAllCnt'] = $iAllCnt_counting;
00034 
00035         $soxId = oxConfig::getParameter( "oxid");
00036         // check if we right now saved a new entry
00037         $sSavedID = oxConfig::getParameter( "saved_oxid");
00038         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00039             $soxId = $sSavedID;
00040             oxSession::deleteVar( "saved_oxid");
00041             $this->_aViewData["oxid"] =  $soxId;
00042             // for reloading upper frame
00043             $this->_aViewData["updatelist"] =  "1";
00044         }
00045 
00046         if ( $soxId != "-1" && isset( $soxId)) {
00047             // load object
00048             $oPricealarm = oxNew( "oxpricealarm" );
00049             $oPricealarm->load( $soxId);
00050 
00051             $oDefCurr = $myConfig->getActShopCurrencyObject();
00052             $oArticle = oxNew( "oxarticle" );
00053             $oArticle->load($oPricealarm->oxpricealarm__oxartid->value);
00054 
00055             if ( $oArticle->oxarticles__oxparentid->value && !$oArticle->oxarticles__oxtitle->value) {
00056                 $oParent = oxNew( "oxarticle" );
00057                 $oParent->load($oArticle->oxarticles__oxparentid->value);
00058                 $oArticle->oxarticles__oxtitle->setValue($oParent->oxarticles__oxtitle->value." ".$oArticle->oxarticles__oxvarselect->value);
00059             }
00060 
00061 
00062             $oThisCurr = $myConfig->getCurrencyObject( $oPricealarm->oxpricealarm__oxcurrency->value);
00063 
00064             if ( !$oThisCurr ) {
00065                 $oThisCurr = $oDefCurr;
00066                 $oPricealarm->oxpricealarm__oxcurrency->setValue($oDefCurr->name);
00067             }
00068 
00069             // #889C - Netto prices in Admin
00070             // (we have to call $oArticle->getPrice() to get price with VAT)
00071             $oLang = oxLang::getInstance();
00072             $oArticle->oxarticles__oxprice->setValue($oArticle->getPrice()->getBruttoPrice() * $oThisCurr->rate);
00073             $oArticle->fprice = $oLang->formatCurrency( $oArticle->oxarticles__oxprice->value, $oThisCurr);
00074 
00075             $oPricealarm->oxpricealarm__oxprice->setValue( $oLang->formatCurrency( $oPricealarm->oxpricealarm__oxprice->value, $oThisCurr));
00076 
00077             $oPricealarm->oArticle = $oArticle;
00078             $oCur = $myConfig->getCurrencyObject( $oPricealarm->oxpricealarm__oxcurrency->value);
00079 
00080             // customer info
00081             $oUser = null;
00082             if ( $oPricealarm->oxpricealarm__oxuserid->value) {
00083                 $oUser = oxNew( "oxuser" );
00084                 $oUser->load($oPricealarm->oxpricealarm__oxuserid->value);
00085                 $oPricealarm->oUser = $oUser;
00086             }
00087             //
00088             $oShop = oxNew( "oxshop" );
00089             $oShop->load( $myConfig->getShopId());
00090             $oShop = $this->addGlobalParams( $oShop);
00091 
00092             $smarty = oxUtilsView::getInstance()->getSmarty();
00093             $smarty->assign( "shop", $oShop );
00094             $smarty->assign( "product", $oArticle );
00095             $smarty->assign( "bidprice", $oPricealarm->oxpricealarm__oxprice->value);
00096             $smarty->assign( "shopImageDir", $myConfig->getImageUrl( false , false ) );
00097             $smarty->assign( "currency", $oCur );
00098 
00099             $iLang = @$oPricealarm->oxpricealarm__oxlang->value;
00100             if (!$iLang)
00101                 $iLang = 0;
00102             $aLanguages = $oLang->getLanguageNames();
00103             $this->_aViewData["edit_lang"] = $aLanguages[$iLang];
00104             // rendering mail message text
00105             $oLetter = new oxStdClass();
00106             $aParams = oxConfig::getParameter( "editval");
00107             if ( isset( $aParams['oxpricealarm__oxlongdesc'] ) && $aParams['oxpricealarm__oxlongdesc'] ) {
00108                 $oLetter->oxpricealarm__oxlongdesc = new oxField( stripslashes( $aParams['oxpricealarm__oxlongdesc'] ), oxField::T_RAW );
00109             } else {
00110                 $old_iLang = $oLang->getTplLanguage();
00111                 $oLang->setTplLanguage( $iLang );
00112                 $smarty->fetch( "email_pricealarm_customer.tpl");
00113 
00114                 $oLetter->oxpricealarm__oxlongdesc = new oxField( $smarty->fetch( "email_pricealarm_customer.tpl"), oxField::T_RAW );
00115                 $oLang->setTplLanguage( $old_iLang );
00116             }
00117 
00118             $this->_aViewData["editor"]  = $this->_generateTextEditor( "100%", 300, $oLetter, "oxpricealarm__oxlongdesc", "details.tpl.css");
00119             $this->_aViewData["edit"] =  $oPricealarm;
00120             $this->_aViewData["oxid"] = $soxId;
00121             $this->_aViewData["actshop"] = $oShop->getShopId();
00122         }
00123 
00124         parent::render();
00125 
00126         return "pricealarm_main.tpl";
00127     }
00128 
00134     public function send()
00135     {
00136         // error
00137         if ( !oxConfig::getParameter( "oxid")) {
00138             $this->_aViewData["mail_err"] = 1;
00139             return;
00140         }
00141 
00142         $oPricealarm = oxNew( "oxpricealarm" );
00143         $oPricealarm->load( oxConfig::getParameter( "oxid"));
00144 
00145         // Send Email
00146         $oShop = oxNew( "oxshop" );
00147         $oShop->load( $oPricealarm->oxpricealarm__oxshopid->value );
00148 
00149         $oArticle = oxNew( "oxarticle" );
00150         $oArticle->load( $oPricealarm->oxpricealarm__oxartid->value);
00151 
00152         //arranging user email
00153         $oEmail = oxNew( "oxemail" );
00154         $oEmail->setFrom( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00155         $oEmail->setSmtp( $oShop );
00156 
00157         $aParams = oxConfig::getParameter( "editval" );
00158         $sContent = isset( $aParams['oxpricealarm__oxlongdesc'] ) ? stripslashes( $aParams['oxpricealarm__oxlongdesc'] ) : '';
00159         if ( $sContent ) {
00160             $sContent = oxUtilsView::getInstance()->parseThroughSmarty( $sContent, $oPricealarm->getId() );
00161         }
00162 
00163         $oEmail->setBody( $sContent );
00164         $oEmail->setSubject( $oShop->oxshops__oxname->getRawValue() );
00165         $oEmail->setRecipient( $oPricealarm->oxpricealarm__oxemail->value, $oPricealarm->oxpricealarm__oxemail->value );
00166         $oEmail->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00167 
00168         // setting result message
00169         if ( $oEmail->send() ) {
00170             $oPricealarm->oxpricealarm__oxsended->setValue( date( "Y-m-d H:i:s" ) );
00171             $oPricealarm->save();
00172             $this->_aViewData["mail_succ"] = 1;
00173         } else {
00174             $this->_aViewData["mail_err"] = 1;
00175         }
00176     }
00177 }

Generated on Tue Apr 21 15:45:44 2009 for OXID eShop CE by  doxygen 1.5.5