public function transfer($id) { $book = Booking::where('id_alat', $id)->first(); $transaksi = new Transaksi(); $transaksi->id_alat = $book->id_alat; $transaksi->id_pengguna = $book->id_pengguna; $transaksi->dipinjam = $book->mulai; $transaksi->save(); $book->delete(); return redirect('/dipinjam'); }
public function simpan_kirim(Request $request) { $this->validate($request, ['nama' => 'required|max:200', 'email' => 'required|max:200', 'telp' => 'required|max:200', 'alamat' => 'required|max:200']); $kode = str_random(10); $data['nama'] = $request->nama; $data['telp'] = $request->telp; $data['email'] = $request->email; $data['alamat'] = $request->alamat; $data['kode_transaksi'] = $kode; $data['tujuan'] = $request->kota; $data['via'] = $request->pengiriman; $data['total'] = Cart::total(); $data['paket'] = $request->paket; $data['ongkir'] = $request->biaya; $transaksi = Transaksi::create($data); if ($transaksi) { foreach (Cart::content() as $d_transaksi) { $nilai['id_transaksi'] = intval($transaksi->id_transaksi); $nilai['id_product'] = $d_transaksi->id; $nilai['qty'] = $d_transaksi->qty; $nilai['sub_total'] = $d_transaksi->subtotal; Dtransaksi::create($nilai); Cart::remove($d_transaksi->rowid); } return redirect('result/' . intval($transaksi->id_transaksi)); } else { \Flash::info('Maaf Gagal'); } }
public function get_angsuran_data($id_transaksi) { $data = \App\Transaksi::where('id_koperasi', Auth::user()->assigned_koperasi)->find($id_transaksi); $days = (strtotime(date_format($data->created_at, "Y-m-d")) - strtotime(date("Y-m-d"))) / (60 * 60 * 24); $data_induk = \App\Transaksi::where('id_koperasi', Auth::user()->assigned_koperasi)->find($data->id_induk)['jumlah_asli']; $json = array('bunga' => $data->jumlah_bunga, 'admin' => $data->biaya_admin, 'asuransi' => $data->biaya_asuransi, 'materai' => $data->biaya_materai, 'jumlah_asli' => $data->jumlah_asli, 'total_tabungan' => $data->total_tabungan, 'jumlah_total' => $data->jumlah_total, 'jatuh_tempo' => date_format($data->created_at, "d M Y"), 'terlambat' => $days, 'denda' => number_format(($days < -2 ? $days * -1 : 0) * (\App\Koperasi::find(Auth::user()->assigned_koperasi)['denda'] * $data_induk), 2, ".", ""), 'total_pembayaran' => number_format($data->jumlah_asli + $data->total_tabungan + ($days < -2 ? $days * -1 : 0) * (\App\Koperasi::find(Auth::user()->assigned_koperasi)['denda'] * $data_induk), 2, ".", "")); echo json_encode($json); }
public function show($id) { $transaksi = Transaksi::getTransaksi($id); $tujuan = json_decode(Ongkir::getCityById($transaksi['tujuan'])); $tujuan = $tujuan->rajaongkir->results; $tujuan = $tujuan->type . " " . $tujuan->city_name . " Provinsi " . $tujuan->province; $data = array('barang' => $transaksi, 'tujuan' => $tujuan); return view('admin.show_transaksi', compact('data')); }
public function laporansimpananexport($bulan, $tahun) { $data = array(); $data = \App\Transaksi::where('id_koperasi', Auth::user()->assigned_koperasi)->where('created_at', 'like', $tahun . "-%" . $bulan . "-%")->where('jenis_transaksi', 'Simpanan')->get(); $export = array(); foreach ($data as $key) { $export[] = array('Tanggal' => date_format(date_create($key->created_at), "d") . " " . \App\Bulan::where('bulan', date_format(date_create($key->created_at), "m"))->first()['nama'] . " " . date_format(date_create($key->created_at), "Y"), 'Nama' => \App\Anggota::where('id_koperasi', Auth::user()->assigned_koperasi)->find($key->id_anggota)['nama'], 'Jenis' => \App\Simpanan::where('id_koperasi', Auth::user()->assigned_koperasi)->find($key->id_jenis)['nama'], 'Jumlah' => (int) $key->jumlah_total); } Excel::create('Laporan Simpanan', function ($excel) use($export) { $excel->sheet('Laporan Simpanan', function ($sheet) use($export) { $sheet->fromArray($export); }); })->download('xls'); }
public function add($id) { $check = 0; /* Cek apakah barang sedang dipinjam oleh orang lain */ $check += Transaksi::where('id_alat', $id)->where('dikembalikan', '0000-00-00 00:00:00')->count(); /* Cek apakah barang sudah dibooking oleh orang lain, kalo dibooking orang tersebut, boleh */ $check += Booking::where('id_alat', $id)->where('mulai', '<=', date('Y-m-d H:i:s', time()))->where('selesai', '>=', date('Y-m-d H:i:s', time()))->count(); /* Cek apakah barang sedang dipelihara */ $check += Pemeliharaan::where('id_alat', $id)->where('mulai', '<=', date('Y-m-d H:i:s', time()))->where('selesai', '0000-00-00 00:00:00')->count(); if ($check == 0) { $pemeliharaan = new Pemeliharaan(); $pemeliharaan->id_alat = $id; $pemeliharaan->mulai = date('Y-m-d H:i:s', time()); $pemeliharaan->save(); //return $this->success(); return redirect('/dipelihara'); } else { return view('error'); } }
public function statistik_user() { $input = Request::all(); $peminjaman = NULL; if ($input["type"] == "all") { // statistik penggunaan semua barang $peminjaman = Transaksi::join('alat', 'transaksi.id_alat', '=', 'alat.id')->where('transaksi.id_pengguna', '=', $input['id'])->select(DB::raw('count(*) as y, alat.nama as name'))->groupBy('alat.nama')->get(); } else { if (is_numeric($input["type"])) { // statistik penggunaan per item $peminjaman = Transaksi::join('alat', 'transaksi.id_alat', '=', 'alat.id')->where('transaksi.id_pengguna', '=', $input['id'])->where('alat.id', '=', $input['type'])->select(DB::raw('count(*) as y, alat.id as name'))->groupBy('alat.id')->get(); } else { // statistik penggunaan per kategori $peminjaman = Transaksi::join('alat', 'transaksi.id_alat', '=', 'alat.id')->where('transaksi.id_pengguna', '=', $input['id'])->where('alat.nama', '=', $input['type'])->select(DB::raw('count(*) as y, alat.id as name'))->groupBy('alat.id')->get(); } } return view('statistik', ['statistik_all' => $peminjaman]); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { \App\Transaksi::where('id_koperasi', Auth::user()->assigned_koperasi)->find($id)->delete(); \App\Keuangan::where('id_koperasi', Auth::user()->assigned_koperasi)->where('tabel', 'transaksis')->where('id_transaksi', $id)->delete(); return redirect(url('transaksi/simpanan')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $pengguna = Pengguna::find($id); if (!$pengguna) { return "Not Found"; } $inBooking = Booking::where('id_pembooking', '=', $id)->count(); $inTransaksi = Transaksi::where('id_peminjam', '=', $id)->count(); if ($inBooking > 0 || $inTransaksi > 0) { return "Tidak dapat menghapus"; } else { $pengguna->delete(); return 1; } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $transaksi = Transaksi::find($id); if (!$transaksi) { return "Not Found"; } $now = Carbon::now()->addHours(7)->toDateTimeString(); $curDateTime = strtotime($now); $pinjam = strtotime($transaksi->waktu_pinjam); $rencana_kembali = strtotime($transaksi->waktu_rencana_kembali); if ($curDateTime > $pinjam && $curDateTime < $rencana_kembali) { return "Tidak dapat menghapus"; } else { $transaksi->delete(); return 1; } }
public function del($id) { Transaksi::where('id_alat', $id)->where('dikembalikan', '0000-00-00 00:00:00')->update(['dikembalikan' => date('Y-m-d H:i:s', time())]); return redirect('/dipinjam'); }
public function livebuktimanual($id_induk, $id_transaksi, $id_anggota, $arrIDKeu) { $data['keuangan'] = \App\Keuangan::where('id_koperasi', Auth::user()->assigned_koperasi)->whereIn('id', explode(",", $arrIDKeu))->get(); $data['koperasi'] = \App\Koperasi::find(Auth::user()->assigned_koperasi); $jumlah = 0; foreach ($data['keuangan'] as $key) { $jumlah += $key->masuk; } $data['total'] = $jumlah; $data['transaksi'] = \App\Transaksi::where('id_koperasi', Auth::user()->assigned_koperasi)->where('id', $id_transaksi)->first(); $data['anggota'] = \App\Anggota::where('id_koperasi', Auth::user()->assigned_koperasi)->find($data['transaksi']->id_anggota); $data['induk'] = \App\Transaksi::where('id_koperasi', Auth::user()->assigned_koperasi)->where('id', $id_induk)->first(); // $pdf = \App::make('dompdf.wrapper'); //$pdf->loadView('transaksi.printpembayaran',$data); $pdf = PDF::loadView('transaksi.printpembayaran', $data); $pdf->setPaper(array(0, 0, 612, 379)); return $pdf->stream('download.pdf'); //return view('transaksi.printpembayaran')->with($data); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $rules = array('jenis_barang' => 'required', 'id_pembooking' => 'required|integer', 'waktu_booking_mulai' => 'required', 'waktu_booking_selesai' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return $validator->messages()->toJson(); } else { if (!checkDateTime(Input::get('waktu_booking_mulai'))) { return "Waktu booking mulai tidak valid"; } if (!checkDateTime(Input::get('waktu_booking_selesai'))) { return "Waktu booking selesai tidak valid"; } if (strtotime(Input::get('waktu_booking_mulai')) >= strtotime(Input::get('waktu_booking_selesai'))) { return "Waktu booking mulai > waktu booking selesai"; } /* cek id pembooking */ $pengguna = Pengguna::find(Input::get('id_pembooking')); if (!$pengguna) { return "ID pengguna tidak ditemukan"; } $booking = Booking::find($id); if (!$booking) { return "Not Found"; } /* cek apakah jenis peralatan berubah * jika berubah, cari alat baru */ $id_barang_old = $booking->id_barang; $barang_old = Peralatan::find($id_barang_old); $jenis_barang_old = $barang_old->jenis; $selected_id = -1; if (strcmp(Input::get('jenis_barang'), $jenis_barang_old) == 0) { $selected_id = $id_barang_old; } else { //cari peralatan baru jika jenis berubah $alat_sesuai_jenis = Peralatan::where('jenis', '=', Input::get('jenis_barang'))->get(); $input_booking_mulai_time = strtotime(Input::get('waktu_booking_mulai')); $input_booking_selesai_time = strtotime(Input::get('waktu_booking_selesai')); foreach ($alat_sesuai_jenis as $alat) { $available = true; /* Cek di tabel booking */ $booking_of_alat = Booking::where('id_barang', '=', $alat->id)->get(); foreach ($booking_of_alat as $booking) { $booking_mulai_time = strtotime($booking->waktu_booking_mulai); $booking_selesai_time = strtotime($booking->waktu_booking_selesai); if ($input_booking_mulai_time > $booking_mulai_time && $input_booking_mulai_time < $booking_selesai_time || $input_booking_selesai_time > $booking_mulai_time && $input_booking_selesai_time < $booking_selesai_time || $booking_mulai_time > $input_booking_mulai_time && $booking_mulai_time < $input_booking_selesai_time || $booking_selesai_time > $input_booking_mulai_time && $booking_selesai_time < $input_booking_selesai_time) { $available = false; } } /* Cek di tabel transaksi */ if ($available) { $transaksi_of_alat = Transaksi::where('id_barang', '=', $alat->id)->get(); foreach ($transaksi_of_alat as $transaksi) { $transaksi_pinjam_time = $transaksi->waktu_pinjam; $transaksi_rencana_kembali_time = $transaksi->waktu_rencana_kembali; if ($input_booking_mulai_time > $transaksi_pinjam_time && $input_booking_mulai_time < $transaksi_rencana_kembali_time || $input_booking_selesai_time > $transaksi_pinjam_time && $input_booking_selesai_time < $transaksi_rencana_kembali_time || $transaksi_pinjam_time > $input_booking_mulai_time && $transaksi_pinjam_time < $input_booking_selesai_time || $transaksi_rencana_kembali_time > $input_booking_mulai_time && $transaksi_rencana_kembali_time < $input_booking_selesai_time) { $available = false; } } } if ($available) { $selected_id = $alat->id; } } } if ($selected_id < 1) { return "Tidak ada alat tersedia"; } else { /* cek tanggal */ if (strtotime(Input::get('waktu_booking_selesai')) <= strtotime(Input::get('waktu_booking_mulai'))) { return "Tanggal tidak valid"; } else { // store $booking->id_barang = $selected_id; $booking->id_pembooking = Input::get('id_pembooking'); $booking->waktu_booking_mulai = Input::get('waktu_booking_mulai'); $booking->waktu_booking_selesai = Input::get('waktu_booking_selesai'); $booking->save(); return $booking->id; } } } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $peralatan = Peralatan::find($id); if (!$peralatan) { return "Not Found"; } $inBooking = Booking::where('id_barang', '=', $id)->count(); $inTransaksi = Transaksi::where('id_barang', '=', $id)->count(); $inPerbaakan = Perbaikan::where('id_barang', '=', $id)->count(); if ($inBooking > 0 || $inTransaksi > 0 || $inPerbaakan > 0) { return "Tidak dapat menghapus"; } else { $peralatan->delete(); return 1; } }