SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | - | {
|
| 2 | + | |
| 3 | - | $tgl = $this->input->post('tgl');
|
| 3 | + | |
| 4 | - | $supplier = $this->input->post('id');
|
| 4 | + | {
|
| 5 | $tgl = $this->input->post('tgl');
| |
| 6 | - | $pecah = explode(" - ",$tgl);
|
| 6 | + | $supplier = $this->input->post('id');
|
| 7 | - | $tglawal = date_format(date_create($pecah[0]),"Y-m-d"); |
| 7 | + | $pecah = explode(" - ",$tgl);
|
| 8 | - | $tglakhir = date_format(date_create($pecah[1]),"Y-m-d"); |
| 8 | + | $tglawal = date_format(date_create($pecah[0]),"Y-m-d"); |
| 9 | - | $data = $this->M_pempers->kartupiutang($supplier,$tglawal,$tglakhir)->result(); |
| 9 | + | $tglakhir = date_format(date_create($pecah[1]),"Y-m-d"); |
| 10 | - | ?> |
| 10 | + | $data = $this->M_pempers->kartupiutang($supplier,$tglawal,$tglakhir)->result(); |
| 11 | - | <thead> |
| 11 | + | |
| 12 | - | <tr> |
| 12 | + | $array_hasil = []; |
| 13 | - | <th colspan="2"><center>INVOICE</center></th><th colspan="2"><center>BUKTI</center></th><th colspan="2"></th> |
| 13 | + | foreach ($data as $a) {
|
| 14 | - | </tr> |
| 14 | + | $rowspan_key = "{$a->invoice_date}-{$a->invoice_no}-{$a->invoice_value}";
|
| 15 | - | <tr class="success"> |
| 15 | + | if ( !isset( $array_hasil[$rowspan_key] ) ) {
|
| 16 | - | <th><center>TGL</center></th><th><center>NO</center></th><th><center>TGL</center></th><th><center>NO</center></th> |
| 16 | + | $array_hasil[$rowspan_key] = []; |
| 17 | - | <th><center>PIUTANG</center></th><th><center>BAYAR</center></th> |
| 17 | + | } |
| 18 | - | </tr> |
| 18 | + | $array_hasil[$rowspan_key][] = $a; |
| 19 | - | </thead> |
| 19 | + | } |
| 20 | - | <tbody> |
| 20 | + | $this->load->view('tabel', ['array_hasil' => $array_hasil]);
|
| 21 | - | <?php |
| 21 | + | } |
| 22 | - | $dpp = 0; |
| 22 | + | |
| 23 | - | $diskon = 0; |
| 23 | + | |
| 24 | - | $ppn = 0; |
| 24 | + | <!-- view tabel --> |
| 25 | - | $invoice = 0; |
| 25 | + | <table> |
| 26 | - | $piutang =0; |
| 26 | + | <thead> |
| 27 | - | foreach($data as $a) |
| 27 | + | <tr> |
| 28 | - | {
|
| 28 | + | <th colspan="2" class="center">INVOICE</th> |
| 29 | - | $invoice = $a->invoice_value; |
| 29 | + | <th colspan="2" class="center">BUKTI</th> |
| 30 | - | $diskon = $invoice * $a->discount_value/100; |
| 30 | + | <th colspan="2"></th> |
| 31 | - | $ppn = $invoice *$a->ppn/100; |
| 31 | + | </tr> |
| 32 | - | $dpp = $invoice - $disc; |
| 32 | + | <tr class="success"> |
| 33 | - | $piutang = $dpp+$ppn; |
| 33 | + | <th class="center">TGL</th> |
| 34 | - | ?> |
| 34 | + | <th class="center">NO</th> |
| 35 | - | <tr> |
| 35 | + | <th class="center">TGL</th> |
| 36 | - | <td><?php echo $a->invoice_date;?></td> |
| 36 | + | <th class="center">NO</th> |
| 37 | - | <td><?php echo $a->invoice_no;?></td> |
| 37 | + | <th class="center">PIUTANG</th> |
| 38 | - | <td><?php echo $a->payment_date;?></td> |
| 38 | + | <th class="center">BAYAR</th> |
| 39 | - | <td><?php echo $a->reference_no;?></td> |
| 39 | + | </tr> |
| 40 | - | <td>Rp. <?php echo number_format($piutang);?></td> |
| 40 | + | </thead> |
| 41 | - | <td>Rp. <?php echo number_format($a->payment_invoice);?></td> |
| 41 | + | <tbody> |
| 42 | - | </tr> |
| 42 | + | <?php foreach ($array_hasil as $rowspan_key => $baris_invoice_date): ?> |
| 43 | - | <?php |
| 43 | + | <?php if( count($baris_invoice_date) > 0 ): ?> |
| 44 | - | }?> |
| 44 | + | <?php |
| 45 | - | </tbody> |
| 45 | + | $data_baris_pertama = $baris_invoice_date[0]; |
| 46 | //perhitungan $piutang disini | |
| 47 | - | <?php |
| 47 | + | ?> |
| 48 | - | } |
| 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> |