public function actionJson() { $obj = $_POST['MailTemplate']['obj']; $type = $_POST['MailTemplate']['type']; $id = $_POST['MailTemplate']['id']; $model = MailTemplate::find()->where(['entity_type' => $obj, 'entity_id' => $type])->one(); if (!$model) { $model = new MailTemplate(); } $data = $obj::findOne($id); $model->templateRplc($data); echo \yii\helpers\Json::encode(array($model)); /* return $this->render('view', array( 'model' => $model, )); */ }
public static function mailDoc($model) { $file = PrintDoc::pdfDoc($model); $temp = MailTemplate::find()->where(['entity_type' => 'app\\models\\Docs', 'entity_id' => $model->doctype])->one(); if (!$temp) { $temp = new MailTemplate(); } $temp->templateRplc($model); $mail = new Mail(); $mail->to = $model->account->email; $mail->bcc = $temp->bcc; $mail->files = $file->id; $mail->subject = $temp->subject; $mail->body = $temp->body; $mail->send(); return true; }