예제 #1
0
 public function saldo()
 {
     $data = array();
     $data['saldo'] = \App\Keuangan::selectRaw('(sum(masuk)-sum(keluar)) as jumlah')->where('id_koperasi', Auth::user()->assigned_koperasi)->first();
     $data['saldo_bulan_lalu'] = \App\Keuangan::selectRaw('(sum(masuk)-sum(keluar)) as jumlah')->where('created_at', 'like', date("Y-m-", strtotime("-1 month")) . "%")->where('id_koperasi', Auth::user()->assigned_koperasi)->first();
     $data['saldo_tahun_lalu'] = \App\Keuangan::selectRaw('(sum(masuk)-sum(keluar)) as jumlah')->where('created_at', 'like', date("Y-", strtotime("-1 year")) . "%")->where('id_koperasi', Auth::user()->assigned_koperasi)->first();
     return view('laporan.saldo')->with($data);
 }
예제 #2
0
 public function get_anggota($nama)
 {
     $data = \App\Anggota::where('nama', 'like', '%' . $nama . '%')->where('id_koperasi', Auth::user()->assigned_koperasi)->get();
     $kirim = array();
     foreach ($data as $key) {
         $saldo = \App\Keuangan::selectRaw('(sum(keluar)-sum(masuk)) as tabungan')->where('id_koperasi', Auth::user()->assigned_koperasi)->where('jenis', 'tabungan')->where('id_anggota', $key->id)->first();
         $kirim[] = array('id' => $key['id'], 'value' => $key['nama'], 'label' => $key['no_anggota'] . " - " . $key['nama'], 'saldo' => $saldo->tabungan);
     }
     echo json_encode($kirim);
 }
예제 #3
0
    public function rekapexport()
    {
        //$data = \App\Keuangan::selectRaw('created_at as "Waktu",no_nota as "No. Nota", jenis as "Jenis",info as "Keterangan",masuk as "Pemasukan",keluar as "Pengeluaran"')->get();
        $tgl[0] = session('tgl0');
        $tgl[1] = session('tgl1');
        $id_anggota = session('id_anggota');
        $lama = \App\Keuangan::selectRaw('created_at as "Waktu",
											no_nota as "No. Nota", 
											id_anggota, 
											jenis as "Jenis",
											info as "Keterangan",
											masuk as "Pemasukan",
											keluar as "Pengeluaran"')->whereRaw('DATE_FORMAT(created_at,"%Y-%m-%d") between "' . $tgl[0] . '" and "' . $tgl[1] . '"')->where('id_koperasi', Auth::user()->assigned_koperasi)->where('id_anggota', 'like', '%' . $id_anggota . '%')->get();
        $data = array();
        foreach ($lama as $key) {
            $data[] = array('Waktu' => $key['Waktu'], 'No. Nota' => $key['No. Nota'], 'Jenis' => $key['Jenis'], 'Anggota' => \App\Anggota::find($key['id_anggota'])['nama'], 'Keterangan' => $key['Keterangan'], 'Pemasukan' => (int) $key['Pemasukan'], 'Pengeluaran' => (int) $key['Pengeluaran']);
        }
        Excel::create('Laporan Keuangan', function ($excel) use($data) {
            $excel->sheet('Laporan Keuangan', function ($sheet) use($data) {
                $sheet->fromArray($data);
            });
        })->download('xls');
    }