Example #1
0
 /**
  * Creates a new BuyMessages model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new BuyMessages();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #2
0
 public function actionAdd_buy_message($name, $email, $tel, $product_id, $inn, $gorod, $comment)
 {
     $mail = EmailTo::findOne(['id' => 1]);
     $functions = new Functions();
     $tovar = Products::findOne(['id' => $product_id]);
     $model = new BuyMessages();
     $model->name = $name;
     $model->email = empty($email) ? '' : $email;
     $model->tel = empty($tel) ? '' : $tel;
     $model->product_id = $product_id;
     $model->inn = $inn;
     $model->city = $gorod;
     $model->comment = $comment;
     if ($model->save()) {
         $to = $mail->email_to;
         $subject = "Новый запрос счета на оплату";
         $message = '
             <html>
                 <head>
                     <title>Поступила новая заявка на запрос счета на оплату!</title>
                 </head>
                 <body>
                     <p>Только что поступила новая заявка на запрос счета на оплату!</p>
                     <p>Имя:' . $name . '</p>
                     <p>Телефон:' . (empty($tel) ? 'не указано' : $tel) . '</p>
                     <p>Email:' . (empty($email) ? 'не указано' : $email) . '</p>
                     <p>ИНН:' . (empty($inn) ? 'не указано' : $inn) . '</p>
                     <p>Город:' . (empty($gorod) ? 'не указано' : $gorod) . '</p>
                     <p>Комментарий:' . (empty($comment) ? 'не указано' : $comment) . '</p>
                     <p>Товар:<a href="' . $functions->get_tovar_url($product_id) . '">' . $tovar->name . '</a></p>
                 </body>
             </html>';
         $headers = "Content-type: text/html; charset=windows-utf-8 \r\n";
         $headers .= "From: TEST\r\n";
         $headers .= "Bcc:TEST1\r\n";
         mail($to, $subject, $message, $headers);
         return 'success';
     }
     return false;
 }