/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { /*$tabelMeninggal = TabelKematian::find()->asArray->all(); $meninggal = ""; foreach($tabelMeninggal as $satuan){ $meninggal = $meninggal.",".$satuan['nik']; }*/ $query = DataManagement::find()->joinWith(['tabelKematian', 'tabelKewarganegaraan'])->where('tabel_kematian.tanggal_kematian is null and tabel_kewarganegaraan.tanggal_imigrasi is null'); // add conditions that should always apply here $cache = Yii::$app->cache; $totalCount = $cache->get('countData'); if ($totalCount === false) { $dependency = new \yii\caching\DbDependency(['sql' => 'SELECT MAX(nik) FROM base']); $cache->set('countData', $query->count(), 0, $dependency); $totalCount = $cache->get('countData'); } $dataProvider = new ActiveDataProvider(['query' => $query, 'totalCount' => (int) $totalCount, 'pagination' => ['pageSize' => 20]]); $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; } // grid filtering conditions $query->andFilterWhere(['tanggal_lahir' => $this->tanggal_lahir, 'jenis_kelamin' => $this->jenis_kelamin, 'tanggal_diterbitkan' => $this->tanggal_diterbitkan, 'nik_pencatat' => $this->nik_pencatat]); $query->andFilterWhere(['like', 'base.nik', $this->nik])->andFilterWhere(['like', 'nama', $this->nama])->andFilterWhere(['like', 'tempat_lahir', $this->tempat_lahir])->andFilterWhere(['like', 'golongan_darah', $this->golongan_darah]); return $dataProvider; }
/** * Finds the UserActivity model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UserActivity the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = DataManagement::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DataManagement::find()->joinWith(['tabelKematian', 'tabelKewarganegaraan'])->where('tanggal_imigrasi is not null or tanggal_kematian is not null'); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['nik' => $this->nik, 'tanggal_lahir' => $this->tanggal_lahir, 'jenis_kelamin' => $this->jenis_kelamin, 'tanggal_diterbitkan' => $this->tanggal_diterbitkan, 'nik_pencatat' => $this->nik_pencatat]); $query->andFilterWhere(['like', 'nama', $this->nama])->andFilterWhere(['like', 'tempat_lahir', $this->tempat_lahir])->andFilterWhere(['like', 'golongan_darah', $this->golongan_darah]); return $dataProvider; }
<div class="row"> <!-- Left col --> <div class="col-lg-6"> <!-- Custom tabs (Charts with tabs)--> <div class="box box-info"> <div class="box-header with-border"> <h3 class="box-title">User Profil</h3> </div><!-- /.box-header --> <div class="box-body"> <div class="row"> <div class="col-md-3"> <label class="control-label pull-right">Nama</label> </div> <div class="col-md-9"> <?php echo DataManagement::find()->select('nama')->where(['nik' => $user->id])->one()->nama; ?> </div> </div> <div class="row"> <div class="col-md-3"> <label class="control-label pull-right">NIK</label> </div> <div class="col-md-9"> <?php echo $user->id; ?> </div> </div> <div class="row"> <div class="col-md-3">
/** * Nomalize requested civil data to be human readable * @param array $data civil data * @return array normalized civil data */ public static function exchangeData($data) { if (isset($data['jenis_kelamin'])) { $data['jenis_kelamin'] = DataManagement::getJenisKelamin($data['jenis_kelamin']); } if (isset($data['kewarganegaraan'])) { switch ($data['kewarganegaraan']) { case 1: $data['kewarganegaraan'] = 'WNI'; break; case 2: $data['kewarganegaraan'] = 'WNA'; break; } } if (isset($data['provinsi'])) { $data['provinsi'] = Provinces::findOne($data['provinsi'])->name; } if (isset($data['kabupaten'])) { $data['kabupaten'] = Regencies::findOne($data['kabupaten'])->name; } if (isset($data['kecamatan'])) { $data['kecamatan'] = Districts::findOne($data['kecamatan'])->name; } if (isset($data['kelurahan'])) { $data['kelurahan'] = Villages::findOne($data['kelurahan'])->name; } if (isset($data['agama'])) { switch ($data['agama']) { case '1': $agama = 'Islam'; break; case '2': $agama = 'Kristen'; break; case '3': $agama = 'Katholik'; break; case '4': $agama = 'Hindu'; break; case '5': $agama = 'Budha'; break; case '6': $agama = 'Konghucu'; break; case '7': $agama = 'Lainnya'; break; } $data['agama'] = $agama; } if (isset($data['status_perkawinan'])) { switch ($data['status_perkawinan']) { case '0': $status_perkawinan = 'Belum Menikah'; break; case '1': $status_perkawinan = 'Menikah'; break; case '2': $status_perkawinan = 'Cerai'; break; case '3': $status_perkawinan = 'Cerai ditinggal mati'; break; } $data['status_perkawinan'] = $status_perkawinan; } if (isset($data['pekerjaan'])) { if ($data['pekerjaan'] == 'NULL') { $data['pekerjaan'] = '-'; } } if (isset($data['pendidikan_terakhir'])) { switch ($data['pendidikan_terakhir']) { case '1': $pend_terakhir = 'SD'; break; case '2': $pend_terakhir = 'SMP'; break; case '3': $pend_terakhir = 'SMA'; break; case '4': $pend_terakhir = 'D 1'; break; case '5': $pend_terakhir = 'D 2'; break; case '6': $pend_terakhir = 'D 3'; break; case '7': $pend_terakhir = 'D 4 / Sarjana (S 1)'; break; case '8': $pend_terakhir = 'Pasca Sarjana (S 2)'; break; case '9': $pend_terakhir = 'Pasca Sarjana (S 3)'; break; } $data['pendidikan_terakhir'] = $pend_terakhir; } if (isset($data['tanggal_lahir'])) { $data['tanggal_lahir'] = date("d-m-Y", strtotime($data['tanggal_lahir'])); } return $data; }
$this->title = 'OCFA System Admin'; ?> <div class="site-index"> <!-- Main content --> <section class="content col-lg-11"> <!-- Small boxes (Stat box) --> <div class="row "> <div class="col-lg-4 col-xs-6"> <!-- small box --> <a href="admin/data"> <div class="small-box bg-aqua"> <div class="inner"> <p>Jumlah Penduduk</p> <h3><?php echo DataManagement::find()->count(); ?> </h3> </div> <div class="icon"> <i class="fa fa-users"></i> </div> </div> </a> </div><!-- ./col --> <div class="col-lg-4 col-xs-6"> <!-- small box --> <a href="admin/user"> <div class="small-box bg-green"> <div class="inner"> <p>Jumlah User</p>
<?php echo $form->field($updatable, 'status_keluarga')->dropdownList(['2' => 'Istri', '3' => 'Anak'], ['prompt' => 'Pilih Status Keluarga', 'id' => 'status_keluarga']); ?> <div class="form-group"> <div class="col-md-3"></div> <div class="col-md-8"> <p><strong>Catatan : </strong>Untuk mengganti Kepala Keluarga, silakan diganti di menu Data Keluarga</p> </div> </div> <?php if (!$model->isNewRecord) { $ayah = ArrayHelper::map(DataManagement::find()->select(['nik'])->where('nik != ' . $model->nik . ' and jenis_kelamin = 1')->all(), 'nik', 'nik'); $ibu = ArrayHelper::map(DataManagement::find()->select(['nik'])->where('nik != ' . $model->nik . ' and jenis_kelamin = 2')->all(), 'nik', 'nik'); } ?> <?php $urlAyah = \yii\helpers\Url::to(['nik-ayah-list']); ?> <?php echo $form->field($updatable, 'ayah')->widget(Select2::classname(), ['language' => 'id', 'options' => ['prompt' => 'Masukkan NIK Ayah', 'options' => ['placeholder' => 'Cari NIK Ayah ...']], 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 3, 'ajax' => ['url' => $urlAyah, 'dataType' => 'json', 'data' => new JsExpression('function(arg) { return {q:arg.term}; }')], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('function(ayah) { return ayah.text; }'), 'templateSelection' => new JsExpression('function (ayah) { return ayah.text; }')]])->label('NIK Ayah'); ?> <?php $urlIbu = \yii\helpers\Url::to(['nik-ibu-list']); ?> <?php echo $form->field($updatable, 'ibu')->widget(Select2::classname(), ['language' => 'id', 'options' => ['prompt' => 'Masukkan NIK Ibu', 'options' => ['placeholder' => 'Cari NIK Ibu ...']], 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 3, 'ajax' => ['url' => $urlIbu, 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }')], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('function(ibu) { return ibu.text; }'), 'templateSelection' => new JsExpression('function (ibu) { return ibu.text; }')]])->label('NIK Ibu');
$data = BaseUpdatable::find()->select('nik')->where(['no_kk' => $model->id, 'status_keluarga' => 3])->asArray()->all(); $istri = BaseUpdatable::find()->select('nik')->where(['no_kk' => $model->id, 'status_keluarga' => 2])->one()['nik']; $nik = ""; foreach ($data as $val) { if ($nik != "") { $nik .= ","; } $nik .= $val['nik']; } if (!empty($nik)) { $dataNama = DataManagement::find()->select('nama')->where('nik in (' . $nik . ')')->asArray()->all(); } else { $dataNama = []; } $namaIstri = DataManagement::findOne($istri)['nama']; $nama = ""; foreach ($dataNama as $val) { if ($nama != "") { $nama .= ", "; } $nama .= $val['nama']; } ?> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'kepala_keluarga', 'value' => DataManagement::findOne($model->kepala_keluarga)->nama], 'tanggal_terbit', 'tanggal_pembaruan', ['label' => 'Status', 'value' => $model->status == 1 ? 'Aktif' : 'Tidak Aktif'], ['label' => 'Anak', 'value' => $nama], ['label' => 'Istri', 'value' => $namaIstri]]]); ?> </div><!--box footer--> </div><!--box--> </div> </div>
<div class="navbar-custom-menu"> <ul class="nav navbar-nav"> <?php if (Yii::$app->user->isGuest) { ?> <li class=""> <?php echo Html::a('Log In', ['/login'], ['data-method' => 'post', 'class' => 'btn btn-flat']); ?> </li> <?php } else { $base = DataManagement::findOne(['nik' => Yii::$app->user->getId()]); $user = User::findOne(['id' => Yii::$app->user->getId()]); if (!empty($base)) { $name = $base->nama; } else { $name = $user->username; } ?> <li class="dropdown user user-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <span class="hidden-xs"> <?php echo $name; ?> </span> </a>
private function exportAktivitasUser() { $isi = UserActivity::find()->orderBy('timestamp desc')->asArray()->all(); //VarDumper::dump($isi,5678); $filename = 'Data_Aktivitas_User-' . Date('YmdGis') . '.xls'; header("Content-type: application/msexcel"); header("Content-Disposition: attachment; filename=" . $filename); header("Pragma: no-cache"); header("Expires: 0"); echo "<style> .str{ mso-number-format:\\@; } </style>"; echo '<table border="1" width="100%"> <thead> <tr> <th>NIK</th> <th>Nama</th> <th>Aksi</th> <th>Timestamp</th> </tr> </thead>'; foreach ($isi as $data) { $nama = DataManagement::findOne($data['nik'])->nama; echo ' <tr> <td>' . $data['nik'] . '</td> <td>' . $nama . '</td> <td>' . $data['action'] . '</td> <td>' . $data['timestamp'] . '</td> </tr> '; } }