public function actionKabupaten()
 {
     //untuk id provinsi
     $id = $_POST['id'];
     //get kabupaten by id_provinsi
     $KABUPATENS = Kabupaten::model()->findAll(array('condition' => 'id_provinsi=:id_provinsi', 'params' => array(':id_provinsi' => $id)));
     //variable kabupatens
     $kabupatens = array();
     //if kabupaten tidak kosong
     if (!empty($KABUPATENS)) {
         //foreach
         foreach ($KABUPATENS as $kabupaten) {
             //set attribute value ke $kabupatens dalam bentuk array
             $kabupatens[] = $kabupaten->attributes;
         }
     }
     //exit dengan data kabupaten dalam bentuk json.
     exit(json_encode(!empty($kabupatens) ? $kabupatens : array()));
 }
Exemplo n.º 2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Kabupaten::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 3
0
?>
		<?php 
echo $form->error($model, 'kode_provinsi');
?>
	</div>

	<div class="form-row row">
		<?php 
echo $form->labelEx($model, 'kode_kabkot');
?>
		<?php 
if ($model->kode_provinsi != '') {
    if (Yii::app()->user->getState('role') == 1) {
        echo $form->dropDownList($model, 'kode_kabkot', KabupatenController::getListKab($model->kode_provinsi), array('empty' => 'Pilih Kabupaten'));
    } else {
        $kab = Kabupaten::model()->findByPk($model['kode_kabkot']);
        echo CHtml::textField('kode_kabkot', $kab['nama'], array('disabled' => 'disabled'));
    }
} else {
    echo $form->dropDownList($model, 'kode_kabkot', array(), array('empty' => 'Pilih Kabupaten'));
}
?>
		<?php 
echo $form->error($model, 'kode_kabkot');
?>
	</div>

	<div class="form-row row">
		<?php 
echo CHtml::submitButton($model->isNewRecord ? 'Buat Akun' : 'Save', array('class' => 'btn green push170'));
?>
Exemplo n.º 4
0
 public function getKabupatenByName($name)
 {
     $pro = \Kabupaten::select(array(DB::raw('nama as label')))->where('nama', 'like', '%' . $name . '%')->get();
     return $pro;
 }
Exemplo n.º 5
0
		$(document).ready(function(){
			$('#status').change(function(){
			sel = $(this);
			console.log(sel.val());
				if(sel.val() == 'Kandung' ){
					$('#nik_wali').attr('disabled', 'disabled');
				}else{
					$('#nik_wali').removeAttr('disabled');
				}
			});
		});
	");*/
?>
	
	<?php 
$tempat_lahirArray = CHtml::listData(Kabupaten::model()->findAll(array('order' => 'nama_kab ASC', 'distinct' => true)), 'nama_kab', 'nama_kab');
?>
	
	<?php 
$kecamatanArray = CHtml::listData(Kecamatan::model()->findAll(array('order' => 'nama_kec ASC', 'distinct' => true)), 'idkec', 'nama_kec');
?>
	
	
	<?php 
echo $form->errorSummary($model);
?>
	
	<?php 
echo $form->textFieldRow($model, 'nis', array('class' => 'span4'));
?>
	
Exemplo n.º 6
0
 public function getKabupaten($id)
 {
     $data = Kabupaten::model()->findByPk($id);
     return empty($data) ? null : $data->nama_kabupaten;
 }
Exemplo n.º 7
0
	<?php 
echo $form->errorSummary($model);
?>
<p>   
<?php 
echo CHtml::dropDownList('idprop', '', CHtml::listData(Propinsi::model()->getPropinsi(), 'idprop', 'nama_prop'), array('empty' => 'Pilih Prop', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('kabupaten/dinamis2'), 'data' => 'js:"idprop="+jQuery(this).val()', 'update' => '#idkab')));
?>
  
   
</p>

<p>   
    <?php 
$idprop = Yii::app()->db->createCommand("select idprop from kabupaten;")->queryScalar();
echo $form->dropDownList($model, 'idkab', Kabupaten::model()->getStateOptions($idprop), array('id' => 'idkab', 'empty' => 'Pilih Kab', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('kecamatan/dinamis'), 'data' => 'js:"idkab="+jQuery(this).val()', 'update' => '#idkec')));
?>
  
   
</p>  
  
<p>    
    <?php 
echo $form->dropDownList($model, 'idkec', Kecamatan::model()->getCityOptionsByState($model->idkab), array('id' => 'idkec'));
?>
 
</p> 

	<div class="form-actions">
		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Create' : 'Save'));
Exemplo n.º 8
0
    ?>
/kanal_prov/<?php 
    echo $prov->id_provinsi;
    ?>
"><span class="number"></span><?php 
    echo $no_prov;
    ?>
<span class="text"><?php 
    echo $prov->provinsi;
    ?>
</span></a>
                            <ul>
                                <?php 
    $criteria_kab = new CDbCriteria();
    $criteria_kab->condition = 'id_provinsi = "' . $prov->id_provinsi . '" ';
    $kabupaten = Kabupaten::model()->findAll($criteria_kab);
    foreach ($kabupaten as $kab) {
        ?>
                                            <li><a href="<?php 
        echo Yii::app()->baseUrl;
        ?>
/kanal_kab/<?php 
        echo $kab->id_kabupaten;
        ?>
"><span class="text"><i class="fa fa-database"></i> <?php 
        echo $kab->kabupaten;
        ?>
</span></a>
                                                <ul>
                                                    <?php 
        $criteria_kec = new CDbCriteria();
Exemplo n.º 9
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $model2 = User::model()->findByPk($model->kode_guru);
     $model3 = Kabupaten::model()->findByPk($model->idkec);
     if (isset($_POST['Guru'])) {
         $model->attributes = $_POST['Guru'];
         if (md5('isims' . $_POST['User']['password']) === $model2->password) {
             $model2->setScenario('changePassword');
             $model2->attributes = $_POST['User'];
             $model2->password = md5('isims' . $_POST['User']['password']);
         }
         $savefoto;
         if (strlen(trim(CUploadedFile::getInstance($model, 'foto'))) > 0) {
             $savefoto = CUploadedFile::getInstance($model, 'foto');
             try {
                 if ($savefoto->extensionName == 'png' || $savefoto->extensionName == 'jpg' || $savefoto->extensionName == 'jpeg') {
                     $val = 1;
                     $model->foto = 'isims-' . $model->nip . '.' . $savefoto->extensionName;
                 } else {
                     $val = 0;
                     Yii::app()->user->setFlash('warning', 'Foto diset Default karena ekstensi anda bukan png/jpg/jpeg.');
                 }
             } catch (CDbException $e) {
                 Yii::app()->user->setFlash('warning', 'Foto anda salah. Ekstensi harus png/jpg/jpeg.');
                 $model->addError(null, "Foto anda salah. Ekstensi harus png/jpg/jpeg.");
             }
         } else {
             $val = 0;
         }
         $valid = $model->validate();
         $valid = $model2->validate() && $valid;
         if ($valid) {
             if (strlen(trim($model->foto)) > 0 && $val == 1) {
                 if ($savefoto->extensionName == 'png' || $savefoto->extensionName == 'jpg' || $savefoto->extensionName == 'jpeg') {
                     $savefoto->saveAs(Yii::app()->basePath . '/../images/' . $model->foto);
                     Yii::app()->user->setFlash('success', 'Data <strong>berhasil</strong> diperbarui. Terima kasih');
                 }
             }
             if (md5('isims' . $_POST['User']['password']) === $model2->password) {
                 $model->save();
                 $model2->save();
                 Yii::app()->user->setFlash('success', 'Data <strong>berhasil</strong> diperbarui. Terima kasih');
                 $this->redirect(array('view', 'id' => $model->kode_guru));
             } else {
                 $model->addError(null, "Silahkan masukan password anda!");
                 Yii::app()->user->setFlash('error', 'Silahkan masukan password anda!');
             }
         }
     }
     $this->render('update', array('model' => $model, 'model2' => $model2, 'model3' => $model3));
 }
Exemplo n.º 10
0
 public function actionDinamis2()
 {
     $data2 = Kabupaten::model()->getStateOptions($_POST['idprop']);
     foreach ($data2 as $value2 => $name2) {
         echo CHtml::tag('option', array('value' => $value2), CHtml::encode($name2), true);
     }
 }
Exemplo n.º 11
0
    public function run()
    {
        /*$provinsi = new Provinsi();
        		$no_prov = 1;
        		foreach($provinsi->findAll() as $prov)
        		{
        		  ?>
        		      <li><a href="<?php echo Yii::app()->baseUrl; ?>/kanal_prov/<?php echo $prov->id_provinsi; ?>"><i class="fa fa-globe"></i> Provinsi <?php echo $prov->provinsi; ?></a>
        		          <ul>
        		              <?php */
        $criteria_kab = new CDbCriteria();
        //$criteria_kab->condition ='id_provinsi = "'.$prov->id_provinsi.'" ';
        $criteria_kab->condition = 'id_provinsi = "1" ';
        $kabupaten = Kabupaten::model()->findAll($criteria_kab);
        foreach ($kabupaten as $kab) {
            ?>
		                          <li><a href="<?php 
            echo Yii::app()->baseUrl;
            ?>
/kanal_kab/<?php 
            echo $kab->id_kabupaten;
            ?>
"><span class="texts"><i class="fa fa-list"></i> Kabupaten <?php 
            echo $kab->kabupaten;
            ?>
</span></a>
		                              <ul>
		                                  <?php 
            $criteria_kec = new CDbCriteria();
            $criteria_kec->condition = 'id_kabupaten = "' . $kab->id_kabupaten . '" ';
            $kecamatan = Kecamatan::model()->findAll($criteria_kec);
            foreach ($kecamatan as $kec) {
                ?>
		                                              <li><a href="<?php 
                echo Yii::app()->baseUrl;
                ?>
/kanal_kec/<?php 
                echo $kec->id_kecamatan;
                ?>
"><span class="text"><i class="fa fa-list-alt"></i> Kecamatan <?php 
                echo $kec->kecamatan;
                ?>
</span></a>

		                                              <ul>
		                                                  <?php 
                $criteria_des = new CDbCriteria();
                $criteria_des->condition = 'id_kecamatan = "' . $kec->id_kecamatan . '" ';
                $desa = DesaKelurahan::model()->findAll($criteria_des);
                foreach ($desa as $des) {
                    ?>
		                                                              <li><a href="<?php 
                    echo Yii::app()->baseUrl;
                    ?>
/kanal_desa/<?php 
                    echo $des->id_desa_kelurahan;
                    ?>
"><span class="text"><i class="fa fa-tags"></i> Desa/Kelurahan <?php 
                    echo $des->desa_kelurahan;
                    ?>
</span></a>

		                                                              

		                                                              </li>
		                                                          <?php 
                }
                ?>
		                                              </ul>

		                                              </li>
		                                          <?php 
            }
            ?>
		                              </ul>
		                          </li>
		                      <?php 
        }
        /*
        		              ?>
        		          </ul>
        		      </li>
        		  <?php
        		   $no_prov++;
        		}*/
    }