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 
00101             if (!$iLang) {
00102                 $iLang = 0;
00103             }
00104 
00105             $aLanguages = $oLang->getLanguageNames();
00106             $this->_aViewData["edit_lang"] = $aLanguages[$iLang];
00107             // rendering mail message text
00108             $oLetter = new oxStdClass();
00109             $aParams = oxConfig::getParameter( "editval");
00110             if ( isset( $aParams['oxpricealarm__oxlongdesc'] ) && $aParams['oxpricealarm__oxlongdesc'] ) {
00111                 $oLetter->oxpricealarm__oxlongdesc = new oxField( stripslashes( $aParams['oxpricealarm__oxlongdesc'] ), oxField::T_RAW );
00112             } else {
00113                 $old_iLang = $oLang->getTplLanguage();
00114                 $oLang->setTplLanguage( $iLang );
00115                 $smarty->fetch( "email_pricealarm_customer.tpl");
00116 
00117                 $oLetter->oxpricealarm__oxlongdesc = new oxField( $smarty->fetch( "email_pricealarm_customer.tpl"), oxField::T_RAW );
00118                 $oLang->setTplLanguage( $old_iLang );
00119             }
00120 
00121             $this->_aViewData["editor"]  = $this->_generateTextEditor( "100%", 300, $oLetter, "oxpricealarm__oxlongdesc", "details.tpl.css");
00122             $this->_aViewData["edit"] =  $oPricealarm;
00123             $this->_aViewData["oxid"] = $soxId;
00124             $this->_aViewData["actshop"] = $oShop->getShopId();
00125         }
00126 
00127         parent::render();
00128 
00129         return "pricealarm_main.tpl";
00130     }
00131 
00137     public function send()
00138     {
00139         // error
00140         if ( !oxConfig::getParameter( "oxid")) {
00141             $this->_aViewData["mail_err"] = 1;
00142             return;
00143         }
00144 
00145         $oPricealarm = oxNew( "oxpricealarm" );
00146         $oPricealarm->load( oxConfig::getParameter( "oxid"));
00147 
00148         // Send Email
00149         $oShop = oxNew( "oxshop" );
00150         $oShop->load( $oPricealarm->oxpricealarm__oxshopid->value );
00151 
00152         $oArticle = oxNew( "oxarticle" );
00153         $oArticle->load( $oPricealarm->oxpricealarm__oxartid->value);
00154 
00155         //arranging user email
00156         $oEmail = oxNew( "oxemail" );
00157         $oEmail->setFrom( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00158         $oEmail->setSmtp( $oShop );
00159 
00160         $aParams = oxConfig::getParameter( "editval" );
00161         $sContent = isset( $aParams['oxpricealarm__oxlongdesc'] ) ? stripslashes( $aParams['oxpricealarm__oxlongdesc'] ) : '';
00162         if ( $sContent ) {
00163             $sContent = oxUtilsView::getInstance()->parseThroughSmarty( $sContent, $oPricealarm->getId() );
00164         }
00165 
00166         $oEmail->setBody( $sContent );
00167         $oEmail->setSubject( $oShop->oxshops__oxname->getRawValue() );
00168         $oEmail->setRecipient( $oPricealarm->oxpricealarm__oxemail->value, $oPricealarm->oxpricealarm__oxemail->value );
00169         $oEmail->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00170 
00171         // setting result message
00172         if ( $oEmail->send() ) {
00173             $oPricealarm->oxpricealarm__oxsended->setValue( date( "Y-m-d H:i:s" ) );
00174             $oPricealarm->save();
00175             $this->_aViewData["mail_succ"] = 1;
00176         } else {
00177             $this->_aViewData["mail_err"] = 1;
00178         }
00179     }
00180 }

Generated on Mon Oct 26 20:07:16 2009 for OXID eShop CE by  doxygen 1.5.5