donnykurnia

Untitled

Mar 8th, 2017
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. public function getKartuPiutang()
  4. {
  5.   $tgl      = $this->input->post('tgl');
  6.   $supplier = $this->input->post('id');
  7.   $pecah    = explode(" - ",$tgl);
  8.   $tglawal  = date_format(date_create($pecah[0]),"Y-m-d");
  9.   $tglakhir = date_format(date_create($pecah[1]),"Y-m-d");
  10.   $data     = $this->M_pempers->kartupiutang($supplier,$tglawal,$tglakhir)->result();
  11.  
  12.   $array_hasil = [];
  13.   foreach ($data as $a) {
  14.     $rowspan_key = "{$a->invoice_date}-{$a->invoice_no}-{$a->invoice_value}";
  15.     if ( !isset( $array_hasil[$rowspan_key] ) ) {
  16.       $array_hasil[$rowspan_key] = [];
  17.     }
  18.     $array_hasil[$rowspan_key][] = $a;
  19.   }
  20.   $this->load->view('tabel', ['array_hasil' => $array_hasil]);
  21. }
  22.  
  23.  
  24. <!-- view tabel -->
  25. <table>
  26.   <thead>
  27.     <tr>
  28.       <th colspan="2" class="center">INVOICE</th>
  29.       <th colspan="2" class="center">BUKTI</th>
  30.       <th colspan="2"></th>
  31.     </tr>
  32.     <tr class="success">
  33.       <th class="center">TGL</th>
  34.       <th class="center">NO</th>
  35.       <th class="center">TGL</th>
  36.       <th class="center">NO</th>
  37.       <th class="center">PIUTANG</th>
  38.       <th class="center">BAYAR</th>
  39.     </tr>
  40.   </thead>
  41.   <tbody>
  42.     <?php foreach ($array_hasil as $rowspan_key => $baris_invoice_date): ?>
  43.       <?php if( count($baris_invoice_date) > 0 ): ?>
  44.         <?php
  45.           $data_baris_pertama = $baris_invoice_date[0];
  46.           //perhitungan $piutang disini
  47.         ?>
  48.         <!-- baris pertama -->
  49.         <tr>
  50.           <td rowspan="<?= count($baris_invoice_date) ?>"><?= $data_baris_pertama->invoice_date ?></td>
  51.           <td rowspan="<?= count($baris_invoice_date) ?>"><?= $data_baris_pertama->invoice_no ?></td>
  52.           <td><?= $data_baris_pertama->payment_date ?></td>
  53.           <td><?= $data_baris_pertama->reference_no ?></td>
  54.           <td rowspan="<?= count($baris_invoice_date) ?>">Rp. <?= number_format($piutang) ?></td>
  55.           <td>Rp. <?= number_format($data_baris_pertama->payment_invoice) ?></td>
  56.         </tr>
  57.         <!-- baris berikutnya -->
  58.         <?php $data_baris_sisa = array_slice($baris_invoice_date, 1) ?>
  59.         <?php if( count($data_baris_sisa) > 0 ): ?>
  60.           <?php foreach ( $data_baris_sisa as $baris ): ?>
  61.             <tr>
  62.               <td><?= $baris->payment_date ?></td>
  63.               <td><?= $baris->reference_no ?></td>
  64.               <td>Rp. <?= number_format($baris->payment_invoice) ?></td>
  65.             </tr>
  66.           <?php endforeach ?>
  67.         <?php endif ?>
  68.       <?php endif ?>
  69.     <?php endforeach ?>
  70.   </tbody>
  71. </table>
Add Comment
Please, Sign In to add comment