OXID eShop CE  4.9.10
 All Classes Files Functions Variables Pages
pricealarm_send.php
Go to the documentation of this file.
1 <?php
2 
8 {
9 
15  protected $_iDefEdit = 1;
16 
24  public function render()
25  {
27 
28  $myConfig = $this->getConfig();
30 
31  ini_set("session.gc_maxlifetime", 36000);
32 
33  $iStart = oxRegistry::getConfig()->getRequestParameter("iStart");
34  $iAllCnt = oxRegistry::getConfig()->getRequestParameter("iAllCnt");
35  // #1140 R
36  $sSelect = "select oxpricealarm.oxid, oxpricealarm.oxemail, oxpricealarm.oxartid, oxpricealarm.oxprice " .
37  "from oxpricealarm, oxarticles where oxarticles.oxid = oxpricealarm.oxartid " .
38  "and oxpricealarm.oxsended = '0000-00-00 00:00:00'";
39  if (isset($iStart)) {
40  $rs = $oDB->SelectLimit($sSelect, $myConfig->getConfigParam('iCntofMails'), $iStart);
41  } else {
42  $rs = $oDB->Execute($sSelect);
43  }
44 
45  $iAllCntTmp = 0;
46 
47  if ($rs != false && $rs->recordCount() > 0) {
48  while (!$rs->EOF) {
49  $oArticle = oxNew("oxarticle");
50  $oArticle->load($rs->fields['oxid']);
51  if ($oArticle->getPrice()->getBruttoPrice() <= $rs->fields['oxprice']) {
52  $this->sendeMail(
53  $rs->fields['oxemail'],
54  $rs->fields['oxartid'],
55  $rs->fields['oxid'],
56  $rs->fields['oxprice']
57  );
58  $iAllCntTmp++;
59  }
60  $rs->moveNext();
61  }
62  }
63  if (!isset($iStart)) {
64  // first call
65  $iStart = 0;
66  $iAllCnt = $iAllCntTmp;
67  }
68 
69 
70  // adavance mail pointer and set parameter
71  $iStart += $myConfig->getConfigParam('iCntofMails');
72 
73  $this->_aViewData["iStart"] = $iStart;
74  $this->_aViewData["iAllCnt"] = $iAllCnt;
75  $this->_aViewData["actlang"] = oxRegistry::getLang()->getBaseLanguage();
76 
77  // end ?
78  if ($iStart < $iAllCnt) {
79  $sPage = "pricealarm_send.tpl";
80  } else {
81  $sPage = "pricealarm_done.tpl";
82  }
83 
84  return $sPage;
85  }
86 
92  protected function _setupNavigation($sId)
93  {
94  parent::_setupNavigation('pricealarm_list');
95  }
96 
105  public function sendeMail($sEMail, $sProductID, $sPricealarmID, $sBidPrice)
106  {
107  $myConfig = $this->getConfig();
108  $oAlarm = oxNew("oxpricealarm");
109  $oAlarm->load($sPricealarmID);
110 
111  $oLang = oxRegistry::getLang();
112  $iLang = (int) $oAlarm->oxpricealarm__oxlang->value;
113 
114  $iOldLangId = $oLang->getTplLanguage();
115  $oLang->setTplLanguage($iLang);
116 
117  $oEmail = oxNew('oxemail');
118  $blSuccess = (int) $oEmail->sendPricealarmToCustomer($sEMail, $oAlarm);
119 
120  $oLang->setTplLanguage($iOldLangId);
121 
122  if ($blSuccess) {
123  $oAlarm->oxpricealarm__oxsended = new oxField(date("Y-m-d H:i:s"));
124  $oAlarm->save();
125  }
126 
127  }
128 }