Go to the documentation of this file.00001 <?php
00002
00007 class PriceAlarm_Send extends oxAdminList
00008 {
00014 protected $_iDefEdit = 1;
00022 public function render()
00023 {
00024 parent::render();
00025
00026 $myConfig = $this->getConfig();
00027 $oDB = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
00028
00029 ini_set("session.gc_maxlifetime", 36000);
00030
00031 $iStart = oxConfig::getParameter( "iStart");
00032 $iAllCnt = oxConfig::getParameter( "iAllCnt");
00033
00034 $sSelect = "select oxpricealarm.oxid, oxpricealarm.oxemail, oxpricealarm.oxartid, oxpricealarm.oxprice from oxpricealarm, oxarticles where oxarticles.oxid = oxpricealarm.oxartid and oxpricealarm.oxsended = '0000-00-00 00:00:00'";
00035 if (isset($iStart)) {
00036 $rs = $oDB->SelectLimit( $sSelect, $myConfig->getConfigParam( 'iCntofMails' ), $iStart);
00037 } else {
00038 $rs = $oDB->Execute( $sSelect);
00039 }
00040
00041 $iAllCntTmp=0;
00042
00043 if ($rs != false && $rs->recordCount() > 0) {
00044 while (!$rs->EOF) {
00045 $oArticle = oxNew("oxarticle" );
00046 $oArticle->load($rs->fields['oxid']);
00047 if ($oArticle->getPrice()->getBruttoPrice() <= $rs->fields['oxprice']) {
00048 $this->sendeMail( $rs->fields['oxemail'], $rs->fields['oxartid'], $rs->fields['oxid'], $rs->fields['oxprice']);
00049 $iAllCntTmp++;
00050 }
00051 $rs->moveNext();
00052 }
00053 }
00054 if ( !isset( $iStart)) {
00055
00056 $iStart = 0;
00057 $iAllCnt = $iAllCntTmp;
00058 }
00059
00060
00061
00062 $iStart += $myConfig->getConfigParam( 'iCntofMails' );
00063
00064 $this->_aViewData["iStart"] = $iStart;
00065 $this->_aViewData["iAllCnt"] = $iAllCnt;
00066 $this->_aViewData["actlang"] = oxRegistry::getLang()->getBaseLanguage();
00067
00068
00069 if ( $iStart < $iAllCnt)
00070 $sPage = "pricealarm_send.tpl";
00071 else
00072 $sPage = "pricealarm_done.tpl";
00073
00074 return $sPage;
00075 }
00076
00084 protected function _setupNavigation( $sId )
00085 {
00086 parent::_setupNavigation( 'pricealarm_list' );
00087 }
00088
00099 public function sendeMail( $sEMail, $sProductID, $sPricealarmID, $sBidPrice )
00100 {
00101 $myConfig = $this->getConfig();
00102 $oAlarm = oxNew( "oxpricealarm" );
00103 $oAlarm->load( $sPricealarmID );
00104
00105 $oLang = oxRegistry::getLang();
00106 $iLang = (int) $oAlarm->oxpricealarm__oxlang->value;
00107
00108 $iOldLangId = $oLang->getTplLanguage();
00109 $oLang->setTplLanguage( $iLang );
00110
00111 $oEmail = oxNew( 'oxemail' );
00112 $blSuccess = (int) $oEmail->sendPricealarmToCustomer( $sEMail, $oAlarm );
00113
00114 $oLang->setTplLanguage( $iOldLangId );
00115
00116 if ( $blSuccess ) {
00117 $oAlarm->oxpricealarm__oxsended = new oxField( date( "Y-m-d H:i:s" ) );
00118 $oAlarm->save();
00119 }
00120
00121 }
00122 }