예제 #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Keluarga();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Keluarga'])) {
         $model->attributes = $_POST['Keluarga'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->no_kk));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $data = Input::All();
     $data['tanggal_lahir'] = $this->formatDate($data['tanggal_lahir']);
     if (isset($data['tanggal_nikah'])) {
         $data['tanggal_nikah'] = $this->formatDate($data['tanggal_nikah']);
     }
     if (isset($data['tanggal_cerai_meninggal'])) {
         $data['tanggal_cerai_meninggal'] = $this->formatDate($data['tanggal_cerai_meninggal']);
     }
     $keluarga = new Keluarga($data);
     if ($keluarga->save()) {
         return Response::json(array('success' => TRUE));
     }
 }
예제 #3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Pendaftar();
     $model2 = new Keluarga();
     $model3 = new Ayah();
     $model4 = new Ibu();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Pendaftar'])) {
         $model3->attributes = $_POST['Ayah'];
         $model4->attributes = $_POST['Ibu'];
         $model2->attributes = $_POST['Keluarga'];
         $model2->nik_ayah = $_POST['Ayah']['nik_ayah'];
         $model2->nik_ibu = $_POST['Ibu']['nik_ibu'];
         $model->attributes = $_POST['Pendaftar'];
         $model->no_kk = $_POST['Keluarga']['no_kk'];
         $valid = $model->validate();
         $valid = $model2->validate() && $valid;
         $valid = $model3->validate() && $valid;
         $valid = $model4->validate() && $valid;
         $savefoto;
         if (strlen(trim(CUploadedFile::getInstance($model, 'foto'))) > 0) {
             $savefoto = CUploadedFile::getInstance($model, 'foto');
             $model->foto = $model->no_pendaftaran . '-' . $model->nama_panggilan . '.' . $savefoto->extensionName;
         }
         if ($valid) {
             if ($model3->save() && $model4->save()) {
                 if ($model2->save()) {
                     if ($model->save()) {
                         if (strlen(trim($model->foto)) > 0) {
                             $savefoto->saveAs(Yii::app()->basePath . '/../images/' . $model->foto);
                         }
                         $this->redirect(array('view', 'id' => $model->no_pendaftaran));
                     }
                 }
             }
         }
     }
     $this->render('create', array('model' => $model, 'model2' => $model2, 'model3' => $model3, 'model4' => $model4));
 }