public function actionSendmail() { $models = DataKerja::find()->where(['status' => 1])->all(); $messages = []; foreach ($models as $model) { $programmer = strtoupper($model->programmer); $marketing = strtoupper($model->marketing); $judul = strtoupper($model->judul); $reminder = explode(',', $model->reminder_email); foreach ($reminder as $mail) { $messages[] = Yii::$app->mailer->compose()->setSubject($marketing . ' dan ' . $programmer . ' Ingat ' . $judul)->setHtmlBody('Hai ' . $marketing . ' dan ' . $programmer . ' Ini adalah pesan pengingat dari job <b>' . $judul . '</b>, untuk menonaktifkannya silakan login pada panel kerja dan ubah status menjadi tidak aktif. <br><br><br> <b>JOB : </b> ' . $judul . '<br> <b>STATUS : </b> ' . $model->status_pekerjaan . '<br> <b>TIPE : </b> ' . $model->tipe . ' <br><br> SELAMAT BEKERJA !!!')->setTo($mail); } } if (Yii::$app->mailer->sendMultiple($messages)) { echo "sukses send mail"; } else { echo "Failed send mail"; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DataKerja::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['status' => SORT_DESC, 'modified_at' => SORT_DESC]]]); $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, 'status' => $this->status, 'created_at' => $this->created_at, 'modified_at' => $this->modified_at]); $query->andFilterWhere(['like', 'judul', $this->judul])->andFilterWhere(['like', 'tipe', $this->tipe])->andFilterWhere(['like', 'klien', $this->klien])->andFilterWhere(['like', 'marketing', $this->marketing])->andFilterWhere(['like', 'programmer', $this->programmer])->andFilterWhere(['like', 'reminder_email', $this->reminder_email])->andFilterWhere(['like', 'informasi', $this->informasi]); return $dataProvider; }