public function actionHome() { $model = new Newsme(); $connection = \Yii::$app->db; $arrreg = array(); $arrfield = array(); $arrwitel = array(); $qregional = $connection->createCommand("SELECT DISTINCT UCS AS REGIONAL FROM NEW_SME WHERE UCS IS NOT NULL ORDER BY UCS ASC")->queryall(); $query = $connection->createCommand("SELECT column_name AS FIELDS FROM USER_TAB_COLS WHERE TABLE_NAME = 'NEW_SME' ORDER BY column_id ASC")->queryall(); $qwitel = $connection->createCommand("SELECT DISTINCT WITEL AS WITEL FROM NEW_SME WHERE WITEL IS NOT NULL ORDER BY WITEL ASC")->queryall(); foreach ($qregional as $row) { $regional = $row['REGIONAL']; array_push($arrreg, array("regional" => $regional)); } foreach ($query as $rows) { $fields = $rows['FIELDS']; array_push($arrfield, array("fields" => $fields)); } foreach ($qwitel as $rows) { $witel = $rows['WITEL']; array_push($arrwitel, array("witel" => $witel)); } $session = Yii::$app->session; $session->set('regional', $qregional); $session->set('witel', $qwitel); $session->set('fields', $query); $countall = $model->find()->count(); $speedo = ""; foreach ($qregional as $key => $row) { $regional = $row['REGIONAL']; $qagree = $model->find()->select(['REASON_CALL'])->where(['LIKE', 'REASON_CALL', 'AGREE'])->andwhere(['UCS' => $regional])->count(); $no = $key + 1; $percentage = $qagree / $countall * 100; /*if($percentage == 100) $agree = number_format($percentage, 0, '.', '.'); else $agree = number_format($percentage, 2, '.', '.');*/ $agree = number_format($percentage, 0, '.', '.'); $speedo .= "<div class='wrapp-spedo'>\n <div id='speedo" . $no . "'>\n " . $agree . "\n </div>\n <h4 align='center'>DIVRE " . $no . "</h4>\n </div>"; } return $this->render('index', ['speedo' => $speedo]); }
public function actionTrunkdetailemail($regwitel) { ini_set("memory_limit", "2048M"); $title = "Detail Perusahaan"; $data = Newsme::find()->select(['ID', 'NAMA_PERUSAHAAN', 'ALAMAT', 'KOTA', 'PROVINSI', 'WITEL', 'BIDANG_USAHA', 'PEMILIK', 'EMAIL_PIC'])->where(['UCS' => $regwitel])->andwhere(['!=', 'EMAIL_PIC', 'NULL'])->all(); header("Content-Type: application/vnd.ms-excel; charset=utf-8"); header("Content-Disposition: attachment; filename=DATA_TRUNK_EMAIL.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="9"><div style="font-weight:bold;font-size:17px;">' . $title . ' </div></th></tr> <tr id="headbottom"> <th>No</th> <th>Nama Perusahaan</th> <th>Alamat</th> <th>Kota</th> <th>Provinsi</th> <th>Witel</th> <th>Bidang Usaha</th> <th>Pemilik</th> <th>Email</th> </tr>'; if (isset($data)) { $result = ""; $no = 1; foreach ($data as $row) { // print_r($row); $id = $row['ID']; $nama = $row['NAMA_PERUSAHAAN']; $alamat = $row['ALAMAT']; $kota = $row['KOTA']; $provinsi = $row['PROVINSI']; $witel = $row['WITEL']; $bussiness = $row['BIDANG_USAHA']; $pemilik = $row['PEMILIK']; $result .= "<tr>"; $result .= "<td>" . $no . ".</td>"; $result .= "<td>" . $nama . "</td>"; $result .= "<td>" . $alamat . "</td>"; $result .= "<td>" . $kota . "</td>"; $result .= "<td>" . $provinsi . "</td>"; $result .= "<td>" . $witel . "</td>"; $result .= "<td>" . $bussiness . "</td>"; $result .= "<td>" . $pemilik . "</td>"; $result .= "<td>" . $row['EMAIL_PIC'] . "</td>"; $result .= "</tr>"; $no++; } echo $result; } echo '</table>'; }