/** * Create new anak. * * @param Request $request * @return void */ public function createAnak(Request $request) { $input = $request->input(); $anak = new Anak(); $anak->nama = $request->has('nama') ? $input['nama'] : ''; $anak->id_type = $request->has('id_type') ? $input['id_type'] : 'kk'; $anak->id_value = $request->has('id_value') ? $input['id_value'] : ''; $anak->sekolah_terakhir = $request->has('sekolah_terakhir') ? $input['sekolah_terakhir'] : ''; $anak->desa_id = $request->has('desa_id') ? $input['desa_id'] : ''; $anak->kec_id = $request->has('kec_id') ? $input['kec_id'] : ''; $anak->kab_id = $request->has('kab_id') ? $input['kab_id'] : ''; $anak->prov_id = $request->has('prov_id') ? $input['prov_id'] : ''; $anak->alamat = $request->has('alamat') ? $input['alamat'] : ''; $anak->cp = $request->has('cp') ? $input['cp'] : ''; $anak->status = 0; $anak->alasan = $request->has('alasan') ? $input['alasan'] : ''; $anak->tanggal_lahir = $request->has('tanggal_lahir') ? $input['tanggal_lahir'] : ''; $anak->gambar = ""; // Upload handler if ($request->hasFile('gambar')) { $gambar = $request->file('gambar'); $destination = base_path('public/uploads/anak/'); $fileName = date('dmyhis') . $gambar->getClientOriginalName(); $gambar->move($destination, $fileName); $anak->gambar = url('uploads/anak/' . $fileName); } if ($anak->save()) { return $anak; } return ['error' => true]; }
public function printPreview($anak_id) { $anak = Anak::find($anak_id); $form = $anak->form->first(); $pendampingan = Pendampingan::where('anak_id', '=', $anak->id)->paginate(100); $data = ['page_title' => 'Kasus Anak 6 (KA6) - Pendampingan', 'panel_title' => 'Pendampingan Table View', 'location' => 'view', 'table' => $pendampingan, 'form' => $form, 'anak' => $anak, 'form_id' => $form->id]; return View::make('formka6.pendampingan.printpreview', $data); }
public function update() { $files = Input::get('files'); $anak = Anak::find(Input::get('anak')['id']); FilesDAO::saveOrUpdate($files, $anak); Session::flash('message', "Informasi file berhasil di ubah!"); return Redirect::to('/dash/anak/files/view/' . $anak->id); }
public static function delete($id) { $anak = Anak::find($id); if (!is_null($anak->first())) { return $anak->delete(); } else { return false; } }
public static function formDelete($form_id) { $user_from_id = Auth::user()->id; $form = Form::find($form_id); $fa = $form->anak->first(); $anak = Anak::find($fa->id); $formLKA = $anak->form->first(); $user = $formLKA->user->first(); $uf_id = $user_from_id; $ut_id = $user->id; NotifikasiFormHelper::formDelete($uf_id, $ut_id, $form_id); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Anak::find(); $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; } $query->andFilterWhere(['id' => $this->id, 'IdPasangan' => $this->IdPasangan, 'NoKTP' => $this->NoKTP, 'TglLahir' => $this->TglLahir, 'ExpKtp' => $this->ExpKtp]); $query->andFilterWhere(['like', 'Nama', $this->Nama])->andFilterWhere(['like', 'TmptLahir', $this->TmptLahir])->andFilterWhere(['like', 'Alamat', $this->Alamat])->andFilterWhere(['like', 'AlamatTinggal', $this->AlamatTinggal])->andFilterWhere(['like', 'Agama', $this->Agama])->andFilterWhere(['like', 'Status', $this->Status])->andFilterWhere(['like', 'Pekerjaan', $this->Pekerjaan])->andFilterWhere(['like', 'Kewarganegaraan', $this->Kewarganegaraan])->andFilterWhere(['like', 'GolDar', $this->GolDar]); return $dataProvider; }
public function update() { $fm = Input::get('form'); $an = Input::get('anak'); $jk = Input::get('jenis_kasus'); $ti = Input::get('tindak_lanjut'); $dis = Input::get('disposisi'); $user = Auth::user(); $sign = ['penerima' => $user]; $sign = json_encode($sign); $fm['sign'] = $sign; // inject lka if not set if (!isset($fm['no_lka'])) { $form = Anak::find($an['id'])->form->first(); $fm['no_lka'] = $form->no_lka; } // inject tanggal if not set if (!isset($fm['tanggal'])) { $form = Form::find($fm['id']); $fm['tanggal'] = $form->tanggal; } $form = FormDAO::saveOrUpdate($fm); $disposisi = DisposisiDAO::saveOrUpdate($dis, $form); $anak = Anak::find($an['id']); TindakLanjutDAO::attachAll($ti, $anak); //this part must be write after TindakLanjutDAO::attachAll //and cannot befote TindakLanjutDAO::attahcAll //otherwise it will detach other tindak lanjut if (isset($ti['other']['check'])) { if ($ti['other']['check'] == 1) { TindakLanjutDAO::saveOrUpdate($ti, $anak); } } //this part must be write after JenisKasusDAO::attachAll //and cannot befote JenisKasusDAO::attahcAll //otherwise it will detach other jenis kasus JenisKasusDAO::attachAll($jk, $anak); if (isset($jk['other']['check'])) { if ($jk['other']['check'] == 1) { JenisKasusDAO::saveOrUpdate($jk, $anak); } } $form = Form::find($form->id); //notifikasi NotifikasiDisposisiHelper::disposisiUpdate($form->id); Session::flash('message', "Form with No LKA {$form->no_lka} has been updated!"); return Redirect::to('/dash/formka3'); }
public static function getDisposisiKA5($form_id) { $form = Form::find($form_id); //ambil form id $fa = $form->anak->first(); //ambil data anak dari form ini $anak = Anak::find($fa->id); //ambil data anak berdasarkan id anak pada form ka4 $formAll = $anak->form; //ambil data banyak form dari anak $formDis = null; foreach ($formAll as $fm) { if ($fm->nama == "ka5") { //jika form sama dengan form ka3 maka $formDis = $fm; //simpan data from ka3 ke $formDis } } //ambil data disposisi $disposisi = json_decode($formDis->disposisi->first()->kepada); return $disposisi; }
public function anakQueryNama($q) { $anak = Anak::where('nama', 'LIKE', '%' . $q . '%')->get(); $anak[0]->form->first(); return $anak->toJSON(); }
public function update() { $fm = Input::get('form'); $an = Input::get('anak'); $jk = Input::get('jenis_kasus'); // inject lka if not set if (!isset($fm['no_lka'])) { $form = Anak::find($an['id'])->form->first(); $fm['no_lka'] = $form->no_lka; } // inject tanggal if not set if (!isset($fm['tanggal'])) { $fm['tanggal'] = date('Y-m-d'); } $form = FormDAO::saveOrUpdate($fm); $anak = Anak::find($an['id']); // //save many to many $form = Form::find($form->id); JenisKasusDAO::attachAll($jk, $anak); //this part must be write after JenisKasusDAO::attachAll //and cannot befote JenisKasusDAO::attahcAll //otherwise it will detach other jenis kasus if (isset($jk['other']['check'])) { if ($jk['other']['check'] == 1) { JenisKasusDAO::saveOrUpdate($jk, $anak); } } //notifikasi FormKA7DisposisiHelper::updateNotif($form->id); Session::flash('message', "Form with No LKA {$form->no_lka} has been updated!"); return Redirect::to('/dash/formka7'); }
/** * @return \yii\db\ActiveQuery */ public function getAnaks() { return $this->hasMany(Anak::className(), ['IdPasangan' => 'id']); }
public function search() { $keyword = Input::get('keyword'); $filter = Input::get('filter'); $result = Anak::orderBy('created_at', 'desc'); if ($keyword != NULL) { if ($filter == "kode" || $filter == NULL) { $result = $result->where('id', '=', $keyword); } else { if ($filter == "anak") { $result = $result->where('nama', 'LIKE', '%' . $keyword . '%'); } else { if ($filter == "gender") { $result = $result->where('gender', 'LIKE', '%' . $keyword . '%'); } else { if ($filter == "jenis") { $result = $result->whereHas('jeniskasus', function ($qp) use($keyword) { $qp->where('jenis_kasus.jenis', 'LIKE', '%' . $keyword . '%'); }); } } } } } $data = ['title' => '', 'page_title' => 'Anak', 'panel_title' => 'Search View', 'location' => 'search', 'table' => $result->paginate(10)]; return View::make('anak.view', $data); }
public function update() { $fm = Input::get('form'); $an = Input::get('anak'); $jk = Input::get('jenis_kasus'); $int = Input::get('intervensi'); $dis = Input::get('disposisi'); // inject lka if not set if (!isset($fm['no_lka'])) { $form = Anak::find($an['id'])->form->first(); $fm['no_lka'] = $form->no_lka; } // inject tanggal if not set if (!isset($fm['tanggal'])) { $fm['tanggal'] = date('Y-m-d'); } $form = FormDAO::saveOrUpdate($fm); DisposisiDAO::saveOrUpdate($dis, $form); $anak = Anak::find($an['id']); JenisKasusDAO::attachAll($jk, $anak); if ($jk['other']['check'] == 1) { JenisKasusDAO::saveOrUpdate($jk, $anak); } IntervensiDAO::attachAll($int, $anak); if ($int['other']['check'] == 1) { IntervensiDAO::saveOrUpdate($int, $anak); } //save many to many $form = Form::find($form->id); //notifikasi NotifikasiDisposisiHelper::disposisiUpdate($form->id); Session::flash('message', "Form with No LKA {$form->no_lka} has been updated!"); return Redirect::to('dash/formka5'); }
public function delete($id) { //notifikasi FormKA4DisposisiHelper::deleteNotif($id); $fm = Form::find($id); $anakId = 64; $anak = Anak::find($anakId); $forms = $anak->form; //delete semua form yang berkaitan foreach ($forms as $form) { if ($form->nama == "ka4" || $form->nama == "ka5" || $form->nama == "ka6" || $form->nama == "ka7") { FormDAO::delete($form->id); } } //delete data pendampingan $pendamping = $anak->Pendampingan()->get(); foreach ($pendamping as $pd) { PendampinganDAO::delete($pd->id); } $gf = $anak->GambaranFisik()->get(); foreach ($gf as $val) { GambaranFisikDAO::delete($val->id); } $kp = $anak->KondisiPsikososial()->get(); foreach ($kp as $val) { KondisiPsikososialDAO::delete($val->id); } $im = $anak->IdentifikasiMasalah()->get(); foreach ($im as $val) { IdentifikasiMasalahDAO::delete($val->id); } $kel = $anak->Keluarga()->get(); foreach ($kel as $val) { KeluargaDAO::delete($val->id); } if ($fm) { Session::flash('message', "Form with {$id} has been deleted!"); } else { Session::flash('message', "Error, Form with {$id} not found!"); } return Redirect::to('/dash/formka4'); }
/** * Finds the Anak model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Anak the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Anak::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * * @param string $start example 1998-12-25 * @param string $end example 1999-12-25 * @return boolean | Anak */ public static function getAnakBetween($start = null, $end = null) { if (!is_null($start)) { if (!is_null($end)) { $start = date("Y-m-d", strtotime($start)); $end = date("Y-m-d", strtotime($end)); return Anak::where('created_at', '>=', $start)->where('created_at', '<=', $end)->get(); } else { return false; } } else { return Anak::all(); } }