/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ZaprosPriceMessages::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]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Finds the ZaprosPriceMessages model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ZaprosPriceMessages the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ZaprosPriceMessages::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #3
0
 public function actionAdd_price_zapros_message($name, $email, $tel, $product_id)
 {
     $mail = EmailTo::findOne(['id' => 1]);
     $functions = new Functions();
     $tovar = Products::findOne(['id' => $product_id]);
     $model = new ZaprosPriceMessages();
     $model->name = $name;
     $model->email = empty($email) ? '' : $email;
     $model->tel = empty($tel) ? '' : $tel;
     $model->product_id = $product_id;
     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>Товар:<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;
 }