コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = BuyMessages::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'product_id' => $this->product_id, 'reg_date' => $this->reg_date]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'inn', $this->inn])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'comment', $this->comment]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Finds the BuyMessages model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BuyMessages the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BuyMessages::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #3
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;
 }