<div class="modal fade" id="views<?= $row['idrevisi_raxips']; ?>" tabindex="-1">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <form action="edit-gadspen.php" method="post">
                <div class="modal-header">
                    <h5 class="modal-title">Detail Data Penawaran Raxi</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row" style="text-align: left;">
                            <?php
                            $idraxips = $row['idrevisi_raxips'];
                            $sqle = mysqli_query($konek, "SELECT r.idraxips,p.nama_pic,p.telp_pic,c.telp,c.email,c.bu,c.alamat,rv.nofile_revisi_raxips,r.checker,c.nama_customer,r.tgl_raxips,r.status_checkraxips 
                            FROM revisi_raxi_ps rv INNER JOIN raxi_ps r ON rv.idraxips = r.idraxips
                            INNER JOIN customer c ON r.idcustomer = c.idcustomer 
                            INNER JOIN pic p ON p.idcustomer = c.idcustomer 
                            WHERE idrevisi_raxips='$idraxips'");
                            $damod = mysqli_fetch_assoc($sqle);
                            ?>
                            <div class="col">
                                <div class="row-inpo">
                                    <span class="label">No File</span>
                                    <span class="t2">:</span>
                                    <span class="isian"><?php echo $damod['nofile_revisi_raxips'] ?></span>
                                </div>
                                <div class="row-inpo">
                                    <span class="label">Kepada</span>
                                    <span class="t2">:</span>
                                    <span class="isian"><?php echo $damod['bu'] . " " . $damod['nama_customer'] ?></span>
                                </div>
                                <div class="row-inpo">
                                    <span class="label">Alamat</span>
                                    <span class="t2">:</span>
                                    <span class="isian"><?php echo $damod['alamat'] ?></span>
                                </div>
                            </div>
                            <div class="col">
                                <div class="row-inpo">
                                    <span class="label">PIC</span>
                                    <span class="t2">:</span>
                                    <span class="isian"><?php echo $damod['nama_pic'] ?></span>
                                </div>
                                <div class="row-inpo">
                                    <span class="label">Telp / HP</span>
                                    <span class="t2">:</span>
                                    <span class="isian"><?php echo $damod['telp'] ?></span>
                                </div>
                                <div class="row-inpo">
                                    <span class="label">Email</span>
                                    <span class="t2">:</span>
                                    <span class="isian"><?php echo $damod['email'] ?></span>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <table class="table table-hover">
                                <thead>
                                    <tr style="text-align: center;">
                                        <th scope="col">Uraian</th>
                                        <th scope="col">QTY</th>
                                        <th scope="col">Keterangan</th>
                                        <th scope="col">Harga Satuan</th>
                                        <th scope="col">Harga</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    $nofile = $damod['nofile_revisi_raxips'];
                                    $cridrps = mysqli_query($konek, "select idrevisi_raxips from revisi_raxi_ps where nofile_revisi_raxips='$nofile'");
                                    $cridrps = mysqli_fetch_array($cridrps);
                                    $idraxips = $cridrps["idrevisi_raxips"] ?? "";
                                    $no = 1;
                                    $sqldamod = mysqli_query($konek, "SELECT d.iddetail_revisi_raxips ,u.nama_unit,d.no_unit,d.wo_unit FROM revisi_detail_raxips d INNER JOIN unit u ON d.idunit=u.idunit WHERE idrevisi_raxips='$idraxips'");
                                    while ($damode = mysqli_fetch_array($sqldamod)) {
                                        // echo $ddr = $row['iddetail_raxips'];
                                        // $cridrpsd = mysqli_query($konek, "select iddetail_raxips from detail_raxips where idraxips='$idraxips'");
                                        // $cridrpsd = mysqli_fetch_assoc($cridrpsd);
                                        // $iddraxips = $cridrpsd["iddetail_raxips"] ?? "";
                                        $iddraxips = $damode['iddetail_revisi_raxips'];
                                        $querygabung = mysqli_query(
                                            $konek,
                                            "SELECT s.jenis_service AS keterangan,j.harga_serviceraxi AS harga,j.qty_service AS kuota,j.totalservice_raxi AS total,j.keterangan AS kete FROM revisi_uraianraxips_service j INNER JOIN jenis_service s ON j.idjenis_service=s.idjenis_service WHERE j.iddetail_revisi_raxips = '$iddraxips'
                                                                    UNION ALL
                                                                    SELECT b.nama_barang AS keterangan,ub.harga_barangraxi AS harga,ub.qty AS kuota,ub.totalbarang_raxi AS total,ub.keterangan AS kete FROM revisi_uraianraxips_barang ub INNER JOIN barang b ON ub.idbarang=b.idbarang WHERE ub.iddetail_revisi_raxips = '$iddraxips'"
                                        );
                                        $damodb = mysqli_num_rows($querygabung);

                                        if ($damodb == 0) {
                                    ?>
                                            <tr style="text-align:left;">
                                                <th>
                                                    <?php
                                                    echo $damode['nama_unit'];
                                                    echo "<br>";
                                                    echo !empty($damode['no_unit']) ? " ({$damode['no_unit']})" : "";
                                                    echo "<br>";
                                                    echo !empty($damode['wo_unit']) ? " ({$damode['wo_unit']})" : "";
                                                    ?>
                                                </th>
                                                <td>-</td>
                                                <td><i>Belum ada uraian</i></td>
                                                <td>-</td>
                                                <td>-</td>
                                                <td>
                                                    <button
                                                        class="btn btn-primary btn-sm"
                                                        data-bs-toggle="modal"
                                                        data-bs-target="#tmbs<?= $damode['iddetail_revisi_raxips']; ?>">
                                                        + Service
                                                    </button>
                                                    <button
                                                        class="btn btn-primary btn-sm"
                                                        data-bs-toggle="modal"
                                                        data-bs-target="#tmbb<?= $damode['iddetail_revisi_raxips']; ?>">
                                                        + Sparepart
                                                    </button>
                                                </td>
                                            </tr>
                                        <?php
                                            $no++;
                                            continue; // lanjut ke unit berikutnya
                                        }

                                        // if ($damod == 0) continue;
                                        // echo $damod;
                                        $noe = 0;
                                        while ($damods = mysqli_fetch_array($querygabung)) {
                                        ?>
                                            <tr style="text-align: center;">
                                                <?php
                                                if ($noe == 0) {
                                                ?>
                                                    <th rowspan="<?php echo $damodb + 3 ?>">
                                                        <?php
                                                        echo $damode['nama_unit'];
                                                        echo "<br>";
                                                        echo !empty($damode['no_unit']) ? " ({$damode['no_unit']})" : "";
                                                        echo "<br>";
                                                        echo !empty($damode['wo_unit']) ? " ({$damode['wo_unit']})" : "";

                                                        ?>
                                                    </th>
                                                <?php
                                                }
                                                ?>
                                                <td><?php echo $damods['kuota'] ?></td>
                                                <td style="text-align: left;">
                                                    <div style="text-align:left; font-weight:600;">
                                                        <?= htmlspecialchars($damods['keterangan']) ?>
                                                    </div>
                                                    <?php if (!empty($damods['kete'])): ?>
                                                        <div style="text-align:left; margin-top:6px; line-height:1.5;">
                                                            <?= nl2br(htmlspecialchars($damods['kete'])) ?>
                                                        </div>
                                                    <?php endif; ?>
                                                </td>
                                                <td style="text-align: center;"><?php echo number_format($damods['harga'],0,',','.') ?></td>
                                                <td style="text-align: center;"><?php echo number_format($damods['total'],0,',','.') ?></td>
                                            </tr>
                                        <?php
                                            $noe++;
                                        }
                                        $query_total = mysqli_query($konek, "
                                                            SELECT SUM(total) AS grand_total
                                                            FROM (
                                                                SELECT totalservice_raxi AS total
                                                                FROM revisi_uraianraxips_service
                                                                WHERE iddetail_revisi_raxips = '$iddraxips'

                                                                UNION ALL

                                                                SELECT totalbarang_raxi AS total
                                                                FROM revisi_uraianraxips_barang
                                                                WHERE iddetail_revisi_raxips = '$iddraxips'
                                                            ) AS total_all
                                                        ");

                                        $total = mysqli_fetch_assoc($query_total);
                                        ?>
                                        <tr style="text-align: center;">
                                            <td colspan="3" style="font-weight: 700;">Subtotal</td>
                                            <th><?= number_format($tuotal = $total['grand_total'], 0, ',', '.') ?></th>
                                        </tr>
                                        <tr style="text-align: center;">
                                            <td colspan="3" style="font-weight: 700;">PPN 11%</td>
                                            <th><?= number_format($ppn = $total['grand_total'] * 0.11, 0, ',', '.') ?></th>
                                        </tr>
                                        <tr style="text-align: center;">
                                            <td colspan="3" style="font-weight: 700;">TOTAL</td>
                                            <th><?= number_format($kabeh = $ppn + $tuotal, 0, ',', '.') ?></th>
                                        </tr>
                                    <?php
                                    }
                                    ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <!-- <button type="submit" class="btn tmbdata">Update</button> -->
                    <a class="btn btn-danger" href="asset/export_pdf.php?nofile=<?= $nofile ?>">
                        <i class="bi bi-filetype-pdf"></i>
                    </a>
                    <button type="button" class="btn btn-primary"><i class="bi bi-filetype-doc"></i></button>
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><i class="bi bi-x-lg"></i></button>
                </div>
            </form>

        </div>
    </div>
</div>
<div class="modal fade" id="prints<?= $row['idrevisi_raxips']; ?>" tabindex="-1">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Print Data Penawaran Raxi</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <form action="print-raxips-revisi.php?nofile=<?php echo $row['nofile'] ?>" target="_blank" method="post">
                <div class="modal-body">
                    <div class="modalisine" style="text-align:left">

                        <!-- PILIHAN DEFAULT -->
                        <label style="font-weight:bold">
                            <input type="checkbox" class="default_keterangan">
                            Default Keterangan
                        </label>
                        <br><br>

                        <!-- PILIHAN CUSTOM -->
                        <p><b>Custom Keterangan</b></p>

                        <label>
                            <input type="checkbox" class="catatan" name="catatan[]" value="Gratis biaya pengiriman ke Surabaya, Sidoarjo, dan Jabodetabek">
                            Gratis biaya pengiriman ke Surabaya, Sidoarjo, dan Jabodetabek
                        </label><br>

                        <label>
                            <input type="checkbox" class="catatan" name="catatan[]" value="Total harga sudah termasuk PPN">
                            Total harga sudah termasuk PPN
                        </label><br>

                        <label>
                            <input type="checkbox" class="catatan" name="catatan[]" value="Pengerjaan service dimulai setelah PO dan/atau konfirmasi diterima">
                            Pengerjaan service dimulai setelah PO dan/atau konfirmasi diterima
                        </label><br>

                        <label>
                            <input type="checkbox" class="catatan" name="catatan[]" value="Sistem pembayaran Cash On Delivery">
                            Sistem pembayaran Cash On Delivery
                        </label><br>

                        <label>
                            <input type="checkbox" class="catatan" name="catatan[]" value="Surat penawaran ini berlaku 1 minggu">
                            Surat penawaran ini berlaku 1 minggu
                        </label><br>

                        <label>
                            <input type="checkbox" class="catatan" name="catatan[]" value="Kunjungi www.materialhandling.com untuk info produk material handling lainnya dan www.servicehandpallet.com untuk service handlift segala merk">
                            Kunjungi www.materialhandling.com untuk info produk material handling lainnya dan www.servicehandpallet.com untuk service handlift segala merk
                        </label>

                    </div>
                </div>
                <div class="modal-footer">
                    <!-- <button type="submit" class="btn tmbdata">Update</button> -->
                    <!-- <a type="button" class="btn btn-danger"><i class="bi bi-filetype-pdf"></i></a> -->
                    <!-- <a href="print-raxips.php?nofile=<?php echo $row['nofile'] ?>" type="button" class="btn btn-primary"><i class="bi bi-printer-fill"></i></a> -->
                    <button type="submit" class="btn btn-danger"><i class="bi bi-printer-fill"></i> Cetak</button>
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><i class="bi bi-x-lg"></i></button>
                </div>
            </form>

        </div>
    </div>
</div>