/** * Exchange all location data * @param User $data, Lokasi $lokasi * @return mixed */ public function exchangeDomisili($lokasi, $data) { $lokasi->kelurahan = Villages::findOne($data->kelurahan)->name; $lokasi->kecamatan = Districts::findOne(substr($data->kelurahan, 0, strlen($data->kelurahan) - 3))->name; $lokasi->kabupaten = Regencies::findOne(substr($data->kelurahan, 0, strlen($data->kelurahan) - 6))->name; $lokasi->provinsi = Provinces::findOne(substr($data->kelurahan, 0, strlen($data->kelurahan) - 8))->name; }
/** * Get kabupaten by id * @param string $id * @return string */ public function actionKabupaten($id) { $countRegencies = Regencies::find()->where(['province_id' => $id])->orderBy('name')->count(); $regencies = Regencies::find()->where(['province_id' => $id])->orderBy('name')->all(); if ($countRegencies > 0) { echo "<option selected disabled>Pilih Kabupaten</option>"; foreach ($regencies as $kabupaten) { echo "<option value='" . $kabupaten->id . "'>" . $kabupaten->name . "</option>"; } } else { echo "<option>-</option>"; } }
/** * 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; }
echo $form->field($updatable, 'foto')->input('button', ['class' => 'btn btn-primary', 'onclick' => 'take_snapshot()', 'value' => 'Ambil Foto', 'id' => 'foto']); ?> <div id="results"></div> <?php echo $form->field($updatable, 'agama')->dropdownList(['1' => 'Islam', '2' => 'Kristen', '3' => 'Katholik', '4' => 'Hindu', '5' => 'Budha', '6' => 'Konghucu', '7' => 'Lainnya'], ['prompt' => 'Pilih Agama']); ?> <?php $provinsi = ArrayHelper::map(Provinces::find()->orderBy('name')->all(), 'id', 'name'); echo $form->field($lokasi, 'provinsi')->widget(Select2::classname(), ['data' => $provinsi, 'language' => 'id', 'options' => ['prompt' => 'Pilih Provinsi', 'onchange' => '$.post( "' . Yii::$app->urlManager->createUrl('data/kabupaten?id=') . '"+$(this).val(), function( data ) {$( "select#kabupaten" ).html( data );});'], 'theme' => Select2::THEME_BOOTSTRAP]); ?> <?php $kabupaten = ArrayHelper::map(Regencies::find()->where(['province_id' => $lokasi->provinsi])->orderBy('name')->all(), 'id', 'name'); echo $form->field($lokasi, 'kabupaten')->widget(Select2::classname(), ['data' => $kabupaten, 'language' => 'id', 'options' => ['prompt' => 'Pilih Kabupaten', 'id' => 'kabupaten', 'onchange' => '$.post( "' . Yii::$app->urlManager->createUrl('data/kecamatan?id=') . '"+$(this).val(), function( data ) {$( "select#kecamatan" ).html( data );});'], 'theme' => Select2::THEME_BOOTSTRAP]); ?> <?php $kecamatan = ArrayHelper::map(Districts::find()->where(['regency_id' => $lokasi->kabupaten])->orderBy('name')->all(), 'id', 'name'); echo $form->field($lokasi, 'kecamatan')->widget(Select2::classname(), ['data' => $kecamatan, 'language' => 'id', 'options' => ['prompt' => 'Pilih Kecamatan', 'id' => 'kecamatan', 'onchange' => '$.post( "' . Yii::$app->urlManager->createUrl('data/kelurahan?id=') . '"+$(this).val(), function( data ) {$( "#kelurahan" ).html( data );});'], 'theme' => Select2::THEME_BOOTSTRAP]); ?> <?php $kelurahan = ArrayHelper::map(Villages::find()->where(['district_id' => $lokasi->kecamatan])->orderBy('name')->all(), 'id', 'name'); echo $form->field($lokasi, 'kelurahan')->widget(Select2::classname(), ['data' => $kelurahan, 'language' => 'id', 'options' => ['prompt' => 'Pilih Kelurahan', 'id' => 'kelurahan'], 'theme' => Select2::THEME_BOOTSTRAP]); ?> <?php echo $form->field($domisili, 'alamat')->textarea(['rows' => 3, 'maxlength' => true]);
/** * @return \yii\db\ActiveQuery */ public function getRegencies() { return $this->hasMany(Regencies::className(), ['province_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getRegency() { return $this->hasOne(Regencies::className(), ['id' => 'regency_id']); }
private function exportKeluarga() { $isi = Keluarga::find()->asArray()->all(); $filename = 'Data_Keluarga-' . date('YmdGis') . '.xls'; header("Content-type: application/vnd.ms-excel"); 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>Nomor KK</th> <th>Nama Kepala Keluarga</th> <th>Alamat</th> <th>RT</th> <th>RW</th> <th>Desa/Kelurahan</th> <th>Kecamatan</th> <th>Kabupaten/Kota</th> <th>Provinsi</th> <th>Dikeluarkan Tanggal</th> <th>Nama Lengkap</th> <th>NIK</th> <th>Jenis Kelamin</th> <th>Tempat Lahir</th> <th>Tanggal Lahir</th> <th>Agama</th> <th>Pendidikan Terakhir</th> <th>Pekerjaan</th> <th>Status Perkawinan</th> <th>Status Hubungan Dalam Keluarga</th> <th>Kewarganegaraan</th> <th>Nama Ayah</th> <th>Nama Ibu</th> </tr> </thead> <tbody>'; $i = 0; foreach ($isi as $data) { $subData = BaseUpdatable::find()->where('status_keluarga = "1" and no_kk = "' . $data['id'] . '"')->one(); $base = DataManagement::findOne($subData['nik']); $domisili = TabelDomisili::find()->where('nik = ' . $subData['nik'])->one(); //echo var_dump($subData->nik); //echo var_dump($subData); $rawNikKeluarga = BaseUpdatable::find()->where('no_kk = ' . $data['id'])->asArray()->all(); $nikKeluarga = ""; foreach ($rawNikKeluarga as $val) { if ($nikKeluarga != null) { $nikKeluarga .= ","; } $nikKeluarga .= $val['nik']; } $dataKeluarga = DataManagement::find()->joinWith('baseUpdatable')->where('base.nik in (' . $nikKeluarga . ')')->asArray()->all(); $count = count($dataKeluarga); echo ' <tr> <td class="str" rowspan="' . $count . '">' . $data['id'] . '</td> <td rowspan="' . $count . '">' . $base['nama'] . '</td> <td rowspan="' . $count . '">' . $domisili['alamat'] . '</td> <td rowspan="' . $count . '">' . $domisili['rt'] . '</td> <td rowspan="' . $count . '">' . $domisili['rw'] . '</td> <td rowspan="' . $count . '">' . Villages::findOne($domisili['kelurahan'])->name . '</td> <td rowspan="' . $count . '">' . Districts::findOne(substr($domisili['kelurahan'], 0, strlen($domisili['kelurahan']) - 3))->name . '</td> <td rowspan="' . $count . '">' . Regencies::findOne(substr($domisili['kelurahan'], 0, strlen($domisili['kelurahan']) - 6))->name . '</td> <td rowspan="' . $count . '">' . Provinces::findOne(substr($domisili['kelurahan'], 0, strlen($domisili['kelurahan']) - 8))->name . '</td> <td rowspan="' . $count . '">' . Keluarga::findOne($data['id'])->tanggal_terbit . '</td>'; foreach ($dataKeluarga as $value) { $jk = $value['jenis_kelamin'] == 1 ? 'Laki-laki' : 'Perempuan'; //echo var_dump($value['baseUpdatable']['agama']); switch ($value['baseUpdatable']['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; } switch ($value['baseUpdatable']['pendidikan_terakhir']) { case '1': $pend = 'SD'; break; case '2': $pend = 'SMP'; break; case '3': $pend = 'SMA'; break; case '4': $pend = 'D 1'; break; case '5': $pend = 'D 2'; break; case '6': $pend = 'D 3'; break; case '7': $pend = 'Sarjana S 1/D 4'; break; case '8': $pend = 'Pasca Sarjana S 2'; break; case '9': $pend = 'Pasca Sarjana S 3'; break; } if ($value['baseUpdatable']['status_perkawinan'] == 0) { $status_perkawinan = 'Belum Menikah'; } elseif ($value['baseUpdatable']['status_perkawinan'] == 1) { $status_perkawinan = 'Menikah'; } elseif ($value['baseUpdatable']['status_perkawinan'] == 2) { $status_perkawinan = 'Cerai'; } elseif ($value['baseUpdatable']['status_perkawinan'] == 3) { $status_perkawinan = 'Cerai Ditinggal Mati'; } $status_keluarga = $value['baseUpdatable']['status_keluarga']; //echo var_dump($status_keluarga); if ($status_keluarga == 1) { $statusKeluarga = 'Kepala Keluarga'; } elseif ($status_keluarga == 2) { $statusKeluarga = 'Istri'; } elseif ($status_keluarga == 3) { $statusKeluarga = 'Anak'; } if (TabelKewarganegaraan::findOne($value['nik']) !== null) { $kewarganegaraan = 'WNA'; } else { $kewarganegaraan = 'WNI'; } echo ' <td>' . $value['nama'] . '</td> <td>' . $value['nik'] . '</td> <td>' . $jk . '</td> <td>' . $value['tempat_lahir'] . '</td> <td>' . $value['tanggal_lahir'] . '</td> <td>' . $agama . '</td> <td>' . $pend . '</td> <td>' . $value['baseUpdatable']['pekerjaan'] . '</td> <td>' . $status_perkawinan . '</td> <td>' . $statusKeluarga . '</td> <td>' . $kewarganegaraan . '</td> <td>' . DataManagement::findOne(BaseUpdatable::findOne($value['nik'])->ayah)['nama'] . '</td> <td>' . DataManagement::findOne(BaseUpdatable::findOne($value['nik'])->ibu)['nama'] . '</td> '; if ($i < $count - 1) { echo '</tr><tr>'; } else { echo '</tr>'; } $i++; } echo '</tbody>'; } echo '</table>'; return true; }