public function payment($id)
 {
     $tg01 = tg01::find($id);
     $check = new tg01();
     // update hutang
     $idph = $check->checkExistHutangKaryawan($tg01->tgltg, $tg01->idkar);
     if ($idph != -1) {
         $th02 = th02::find($idph);
         $th02->idtg = $id;
         $th02->status = 'Y';
         $th02->save();
         $mk01 = mk01::find($tg01->idkar);
         $mk01->htsld = $mk01->htsld + $th02->nilhut;
         $mk01->save();
         //            echo "- ada hutang <br>";
     }
     // update tabungan
     $idtb = $check->checkExistTabunganKaryawan($tg01->tgltg, $tg01->idkar);
     if ($idtb != -1) {
         $tt01 = tt01::find($idtb);
         $tt01->idtg = $id;
         $tt01->save();
         $mk01 = mk01::find($tt01->idkar);
         $mk01->tbsld = $mk01->tbsld + $tt01->niltb;
         $mk01->save();
         //            echo "- ada tabungan <br>";
     }
     // Update hutang, kasbon dan tabungan sesuai pembayaran gaji
     $check->updateHutangTabunganLunas($idph, $idtb);
     // update status gaji
     $check->updateStatusGaji($id, "Y");
     Session::flash('tg01_success', 'Gaji Telah Di Transfer!');
     // Redirect ke url + menuju div tertentu
     $url = URL::action("TransaksiTransferController@index");
     return Redirect::to($url);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $th01 = new th01();
     $dethuts = $th01->getDetailHutang($id);
     foreach ($dethuts as $dethut) {
         $th02 = th02::find($dethut->idph);
         $th02->delete();
     }
     $th01 = th01::find($id);
     $th01->delete();
     Session::flash('th01_success', 'Data Telah DiHapus!');
     return Redirect::to('inputdata/hutang');
 }
示例#3
0
 function updateHutangTabunganLunas($idph, $idtb)
 {
     if ($idph != -1) {
         $idhut = th02::find($idph)->idhut;
         $sql = "SELECT COUNT(idtg) as c_idtg\n                    FROM th02 \n                    WHERE idhut = {$idhut} AND idtg = 0;";
         $count = DB::select(DB::raw($sql));
         $flaglunas = $count[0]->c_idtg;
         if ($flaglunas == 0) {
             $th01 = th01::find($idhut);
             $th01->flglns = "Y";
             $th01->save();
         }
     }
 }