public function actionCreport() { $connection = \Yii::$app->db; $query = Sendmail::find(); $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]); $lengkap = Sendmail::find()->select(['CLIENT_NAME', 'TGL_SEND', 'EMAIL', 'JUDUL', 'STATUS_SEND'])->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('campaign_report', ['lengkap' => $lengkap, 'pagination' => $pagination, 'offset' => $pagination->offset]); }
public function actionPerfdetailemailrespon($regional, $witel, $postreg) { ini_set("memory_limit", "2048M"); $model = new Sendmail(); $divre = $model->find()->select(['REGIONAL'])->distinct(true)->all(); $fields = array("NO", "NAMA", "REGIONAL"); $title = "Detail EMAIL Blast"; if ($regional != "" && $witel == "") { $query = $model->find()->where('REGIONAL = :regional')->andWhere('RESPON IS NULL')->addParams([':regional' => $regional]); } else { if ($regional != "" && ($witel = "all")) { $query = $model->find()->where('REGIONAL = :regional')->andWhere('RESPON IS NULL')->addParams([':regional' => $postreg]); } else { if ($regional == "all" && $witel == "all") { $query = $model->find()->where('WITEL = :witel')->andWhere('RESPON IS NULL')->addParams([':witel' => $postreg]); } else { $query = $model->find()->where('WITEL = :witel')->andWhere('RESPON IS NULL')->addParams([':witel' => $witel]); } } } $data = $query->all(); header("Content-Type: application/vnd.ms-excel; charset=utf-8"); header("Content-Disposition: attachment; filename=PERFORMANCE_DETAIL_EMAIL_RESPONS.xls"); //File name extension was wrong header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); echo '<table border="1"> <tr id="headtop"><th colspan="3">' . $title . '</th></tr> <tr id="headbottom">'; if (isset($fields)) { for ($i = 0; $i < count($fields); $i++) { echo '<th style="text-align: center">' . $fields[$i] . '</th>'; } } echo '</tr>'; if (isset($data)) { $result = ""; if ($data) { $no = 1; foreach ($data as $row) { // print_r($row); $nama = $row['CLIENT_NAME']; $regional = $row['REGIONAL']; $result .= "<tr><td>" . $no . "</td><td>" . $nama . "</td><td>" . $regional . "</td></tr>"; $no++; } } else { $result .= "<tr><td colspan='3' align='center'> Data tidak di temukan ! </td></tr>"; } echo $result; } echo "</table>"; }