OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
pricealarm_send.php
Go to the documentation of this file.
1 <?php
2 
8 {
14  protected $_iDefEdit = 1;
22  public function render()
23  {
25 
26  $myConfig = $this->getConfig();
28 
29  ini_set("session.gc_maxlifetime", 36000);
30 
31  $iStart = oxConfig::getParameter( "iStart");
32  $iAllCnt = oxConfig::getParameter( "iAllCnt");
33  // #1140 R
34  $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'";
35  if (isset($iStart)) {
36  $rs = $oDB->SelectLimit( $sSelect, $myConfig->getConfigParam( 'iCntofMails' ), $iStart);
37  } else {
38  $rs = $oDB->Execute( $sSelect);
39  }
40 
41  $iAllCntTmp=0;
42 
43  if ($rs != false && $rs->recordCount() > 0) {
44  while (!$rs->EOF) {
45  $oArticle = oxNew("oxarticle" );
46  $oArticle->load($rs->fields['oxid']);
47  if ($oArticle->getPrice()->getBruttoPrice() <= $rs->fields['oxprice']) {
48  $this->sendeMail( $rs->fields['oxemail'], $rs->fields['oxartid'], $rs->fields['oxid'], $rs->fields['oxprice']);
49  $iAllCntTmp++;
50  }
51  $rs->moveNext();
52  }
53  }
54  if ( !isset( $iStart)) {
55  // first call
56  $iStart = 0;
57  $iAllCnt = $iAllCntTmp;
58  }
59 
60 
61  // adavance mail pointer and set parameter
62  $iStart += $myConfig->getConfigParam( 'iCntofMails' );
63 
64  $this->_aViewData["iStart"] = $iStart;
65  $this->_aViewData["iAllCnt"] = $iAllCnt;
66  $this->_aViewData["actlang"] = oxRegistry::getLang()->getBaseLanguage();
67 
68  // end ?
69  if ( $iStart < $iAllCnt)
70  $sPage = "pricealarm_send.tpl";
71  else
72  $sPage = "pricealarm_done.tpl";
73 
74  return $sPage;
75  }
76 
84  protected function _setupNavigation( $sId )
85  {
86  parent::_setupNavigation( 'pricealarm_list' );
87  }
88 
99  public function sendeMail( $sEMail, $sProductID, $sPricealarmID, $sBidPrice )
100  {
101  $myConfig = $this->getConfig();
102  $oAlarm = oxNew( "oxpricealarm" );
103  $oAlarm->load( $sPricealarmID );
104 
105  $oLang = oxRegistry::getLang();
106  $iLang = (int) $oAlarm->oxpricealarm__oxlang->value;
107 
108  $iOldLangId = $oLang->getTplLanguage();
109  $oLang->setTplLanguage( $iLang );
110 
111  $oEmail = oxNew( 'oxemail' );
112  $blSuccess = (int) $oEmail->sendPricealarmToCustomer( $sEMail, $oAlarm );
113 
114  $oLang->setTplLanguage( $iOldLangId );
115 
116  if ( $blSuccess ) {
117  $oAlarm->oxpricealarm__oxsended = new oxField( date( "Y-m-d H:i:s" ) );
118  $oAlarm->save();
119  }
120 
121  }
122 }