Exemple #1
0
 public function actionMailvznos()
 {
     $all_name = "";
     $n = 0;
     $kvaratal = Vznos::getKvartal();
     $year = date('Y');
     $vznos = Vznos::find()->select('ur_id')->where(['year' => $year])->andWhere(['kvartal' => $kvaratal])->column();
     //Убрать лиимит
     $ur_array = Ur::find()->where(['not in', 'id', $vznos])->andWhere(['plat' => 1])->orderBy('name')->all();
     //->limit(1)
     print "<h4>" . count($ur_array) . "</h4>";
     foreach ($ur_array as $ur) {
         //     print $ur['id'];
         print $ur['name'];
         //  print "<br>";
         Vznos::greatePDF($ur);
         // $ur['contact_mail']="*****@*****.**";
         $file = \Yii::$app->basePath . '/temp/vznos/' . $ur['id'] . '.pdf';
         $Subject = 'Оплата взносов ' . $kvaratal . " квартал " . $year . ' г.';
         if (strpos($ur['contact_mail'], "@") !== false) {
             \Yii::$app->mail->compose('vznos', ['name' => $ur['name']])->setFrom([\Yii::$app->params['infoEmail'] => 'ААУ "СоюзФарма-ТМ"'])->setTo($ur['contact_mail'])->setSubject($Subject)->attach($file)->send();
             sleep(1);
             $all_name .= $ur['name'] . " " . $ur['contact_mail'] . "\n<br>";
             $n++;
         }
     }
     // $pdf = Vznos::greatePDF('Пукась Анна Андреевич');
     \Yii::$app->mail->compose('infovznos', ['info' => $all_name, 'n' => $n])->setFrom([\Yii::$app->params['infoEmail'] => 'СоюзФарма'])->setTo("*****@*****.**")->setSubject('Рассылка произведена')->send();
     \Yii::$app->mail->compose('infovznos', ['info' => $all_name, 'n' => $n])->setFrom([\Yii::$app->params['infoEmail'] => 'СоюзФарма'])->setTo("*****@*****.**")->setSubject('Рассылка произведена')->send();
 }