public function onLoad($param) { parent::onLoad($param); $checkNewsletter = nNewsletterRecord::finder()->findByStatus(1); if ($checkNewsletter) { $layout = nLayoutRecord::finder()->findBy_nNewsletterID($checkNewsletter->ID); $mail = new PHPMailer(); $mail->isSendmail(); $mail->setFrom('*****@*****.**', 'First Last'); $mail->addReplyTo('*****@*****.**'); $lista = nSenderRecord::finder()->findAll('nLayoutID = ? AND Status = 0 LIMIT 25', $layout->ID); foreach ($lista as $person) { $mail->addAddress($person->Email); $mail->Subject = $checkNewsletter->Name; $mail->msgHTML($layout->HtmlText); if ($mail->send()) { $person->Status = 1; $person->save(); } else { $person->Status = 5; $person->save(); echo "Mailer Error: " . $mail->ErrorInfo; } } if (empty($lista)) { $checkNewsletter->Status = 0; $checkNewsletter->save(); } } die; }
public function editRow($sender, $param) { if ($this->IsValid) { $rows = new nNewsletterRecord(); $rows->Name = TPropertyValue::ensureString($this->Name->getSafeText()); $rows->Status = 0; $rows->save(); $lay = new nLayoutRecord(); //$lay->PlaneText = TPropertyValue::ensureString ( $this->PlaneText->getText () ); $lay->HtmlText = TPropertyValue::ensureString($this->HtmlText->getText()); $lay->nNewsletterID = $rows->ID; $lay->save(); $mailList = explode(";", $this->SendDescription->getText()); foreach ($mailList as $email) { if (filter_var(trim($email), FILTER_VALIDATE_EMAIL)) { if (!nSenderRecord::finder()->findBy_nLayoutID_AND_Email($lay->ID, trim($email))) { $send = new nSenderRecord(); $send->Email = trim($email); $send->Status = 0; $send->nLayoutID = $lay->ID; $send->save(); } } } $this->Response->redirect($this->Service->constructUrl("Newsletter.Data")); } }
public function deleteItem($sender, $param) { $nID = $this->DataGrid->DataKeys[$param->Item->ItemIndex]; $lID = nLayoutRecord::finder()->findBy_nNewsletterID($nID); if (isset($lID->ID)) { nSenderRecord::finder()->deleteAllBy_nLayoutID($lID->ID); nLayoutRecord::finder()->deleteBy_nNewsletterID($nID); } nNewsletterRecord::finder()->deleteBy_ID($nID); $this->populateData(); $this->Correct->Visible = true; $this->Alert->Visible = false; }