Exemplo n.º 1
0
 public static function update($ti, $anak = null)
 {
     $tindak = TindakLanjut::find($ti['other']['id']);
     if (isset($ti['other']['check'])) {
         $tindak = TindakLanjutDAO::exchangeArray($tindak, $ti);
         $tindak->update();
         if (!is_null($anak)) {
             $tindak->Anak()->attach($anak->id);
         }
     } else {
         if (!is_null($anak)) {
             $tindak->Anak()->detach($anak->id);
         }
     }
     return $tindak;
 }
Exemplo n.º 2
0
 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');
 }