public function destroy($id) { $issues = Issue::where('registration_id', '=', $id)->delete(); $placements = Placement::where('registration_id', '=', $id)->delete(); $receivables = Receivable::where('registration_id', '=', $id)->get(); foreach ($receivables as $receivable) { $installments = Installment::where('receivable_id', '=', $receivable->id)->get(); foreach ($installments as $installment) { $earnings = Earning::where('earnable_type', '=', 'Installment')->where('earnable_id', '=', $installment->id)->get(); foreach ($earnings as $earning) { $earning->delete(); } $installment->delete(); } $earnings = Earning::where('earnable_type', '=', 'Receivable')->where('earnable_id', '=', $receivable->id)->delete(); $reductions = Reduction::where('receivable_id', '=', $receivable->id)->delete(); $receivable->delete(); } Registration::destroy($id); Session::flash('message', 'Sukses membatalkan Pendaftaran!, Semua Data terkait pendaftaran ini telah dihapus!'); }
public function makeCash($id) { $receivable = Receivable::find($id); $receivable->payment = 'Cash'; $receivable->save(); $installments = Installment::where('receivable_id', '=', $receivable->id)->get(); foreach ($installments as $installment) { $installment->delete(); } Session::flash('message', 'Pembayaran Tagihan menjadi Tunai (Tanpa Angsuran)!'); }
public function store() { $receivable = Receivable::find(Input::get('receivable_id')); $curr_month = date('m', strtotime(Input::get('first_installment'))); $curr_year = date('Y', strtotime(Input::get('first_installment'))); $schedule = Input::get('first_installment'); $counts = Input::get('counts'); if ($receivable->installments->count() > 0) { $total_installments = 0.0; $installments = Installment::where('receivable_id', '=', $receivable->id)->get(); foreach ($installments as $installment) { $total_installments += $installment->total; } $rest_billable = $receivable->billable - $total_installments; for ($i = 0; $i < $counts; $i++) { $installment = new Installment(); $installment->project_id = Auth::user()->curr_project_id; $installment->location_id = Auth::user()->location_id; $installment->receivable_id = $receivable->id; $installment->schedule = $schedule; $installment->total = $rest_billable / $counts; $installment->balance = $rest_billable / $counts; $installment->save(); $curr_month += 1; if ($curr_month > 12) { $curr_month -= 12; $curr_year += 1; } $schedule = $curr_year . '-' . $curr_month . '-' . '05'; } } else { for ($i = 0; $i < $counts; $i++) { $installment = new Installment(); $installment->project_id = Auth::user()->curr_project_id; $installment->location_id = Auth::user()->location_id; $installment->receivable_id = $receivable->id; $installment->schedule = $schedule; $installment->total = $receivable->billable / $counts; $installment->balance = $receivable->billable / $counts; $installment->save(); $curr_month += 1; if ($curr_month > 12) { $curr_month -= 12; $curr_year += 1; } $schedule = $curr_year . '-' . $curr_month . '-' . '05'; } $receivable->payment = 'Installment'; $receivable->save(); Session::flash('message', 'Sukses membuat jadwal angsuran!!'); } }
public function latesFilter($month, $year) { $curr_month = $month; $curr_year = $year; $installments = Installment::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where(DB::raw('year(schedule)'), '=', $curr_year)->where(DB::raw('month(schedule)'), '=', $curr_month)->where('paid', '=', 0)->get(); $menu = 'report'; return View::make('reports.lates', compact('installments', 'curr_year', 'curr_month', 'menu')); }