Advertisement
jamboljack

Array Slip

Aug 20th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.09 KB | None | 0 0
  1. $anggota_id   = $r->anggota_id;
  2.     $listPinjaman = $this->db->get_where('v_bulk', array('MONTH(angsur_tmp)' => $bulan, 'YEAR(angsur_tmp)' => $tahun, 'anggota_id' => $anggota_id, 'angsur_status' => 1))->result();
  3.  
  4.     if (count($listPinjaman) == 0) {
  5.         $arr_pinjaman = array(
  6.             'no'           => '',
  7.             'namapinjaman' => '',
  8.             'kedr'         => '',
  9.             'pokok'        => '',
  10.             'bunga'        => '',
  11.             'total'        => '',
  12.             'sisa'         => '',
  13.         );
  14.     } else {
  15.         $arr_pinjaman = array();
  16.         $no = 1;
  17.         foreach ($listPinjaman as $p) {
  18.             $arr_pinjaman[] = array(
  19.                 'no'           => $no,
  20.                 'namapinjaman' => $p->jenis_name,
  21.                 'kedr'         => $p->angsur_ke . '/' . $p->pinjaman_jk,
  22.                 'pokok'        => number_format($p->angsur_pokok, 0, '', ','),
  23.                 'bunga'        => number_format($p->angsur_bunga, 0, '', ','),
  24.                 'total'        => number_format($p->angsur_total, 0, '', ','),
  25.                 'sisa'         => number_format($p->angsur_sisa, 0, '', ','),
  26.             );
  27.             $no++;
  28.         }
  29.     }
  30.  
  31.     $listSimpanan = $this->db->get_where('v_transaksi', array('MONTH(trtab_date)' => $bulan, 'YEAR(trtab_date)' => $tahun, 'anggota_id' => $anggota_id))->result();
  32.  
  33.     if (count($listSimpanan) == 0) {
  34.         $arr_simpanan = array(
  35.             'nox'          => '',
  36.             'namasimpanan' => '',
  37.             'jumlah'       => '',
  38.             'saldo'        => '',
  39.         );
  40.     } else {
  41.         $arr_simpanan = array();
  42.         $nox = 1;
  43.         foreach ($listSimpanan as $s) {
  44.             $arr_simpanan[] = array(
  45.                 'nox'          => $nox,
  46.                 'namasimpanan' => $s->jenis_name,
  47.                 'jumlah'       => number_format($s->trtab_value, 0, '', ','),
  48.                 'saldo'        => number_format($s->tab_total, 0, '', ','),
  49.             );
  50.             $nox++;
  51.         }
  52.     }
  53.  
  54.     $res = array_merge($arr_pinjaman, $arr_simpanan);
  55.     print_r($res);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement