public function actionUpdate($new = false) { $model = $new === true ? new TplMail() : TplMail::model()->findByPk($_GET['id']); if (isset($model)) { $this->pageName = Yii::t('app', 'TPLMAIL'); $this->breadcrumbs = array($this->pageName => Yii::app()->createUrl('admin/core/tplmail'), $new === true ? Yii::t('app', 'CREATE', 1) : Yii::t('app', 'UPDATE', 1)); if (isset($_POST['TplMail'])) { $model->attributes = $_POST['TplMail']; if ($model->validate()) { $model->save(); } } $this->render('update', array('model' => $model)); } else { throw new CHttpException(404); } }
public function actionSend() { $record = ProductNotifications::model()->findAllByAttributes(array('product_id' => $_GET['product_id'])); $tplMail = TplMail::model()->findByAttributes(array('formkey' => 'PRODUCT_NOTIFY')); if (!$tplMail) { throw new CHttpException(404, 'Не могу найти шаблон письма.'); } foreach ($record as $row) { if (!$row->product) { continue; } $tplMail->setEmails($row->email); $tplMail->sendEmail($this->replaceArray($row->product), $this->replaceArray($row->product)); $row->delete(); } Yii::app()->user->setFlash('success', Yii::t('CartModule.admin', 'Сообщения успешно отправлены.')); $this->redirect('index'); }
<?php $tpl = TplMail::model()->findByPk(1); $tpl->setOptions = $tpl->getModelByPk(1, 'User'); $res = $tpl->getBody(); echo $res; $ss = $tpl->getModelByPk(1, 'User'); print_r($ss); Yii::app()->tpl->openWidget(array('title' => $this->pageName)); $this->widget('ext.adminList.GridView', array('dataProvider' => $model->search(), 'selectableRows' => false, 'enableHeader' => false, 'autoColumns' => false, 'columns' => array('formkey', array('class' => 'ButtonColumn', 'template' => '{update}{delete}', 'hidden' => array('delete' => array(1)))))); Yii::app()->tpl->closeWidget();