<div class="modal fade" id="viewe<?= $row['idraxips']; ?>" 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['idraxips'];
                            $sqle = mysqli_query($konek, "SELECT r.idraxips,p.nama_pic,c.telp,c.email,c.bu,c.alamat,r.nofile_raxips,r.checker,c.nama_customer,r.tgl_raxips,r.status_checkraxips FROM raxi_ps r INNER JOIN customer c ON r.idcustomer = c.idcustomer INNER JOIN pic p ON p.idcustomer = c.idcustomer WHERE idraxips='$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_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_raxips'];
                                    $cridrps = mysqli_query($konek, "select idraxips from raxi_ps where nofile_raxips='$nofile'");
                                    $cridrps = mysqli_fetch_array($cridrps);
                                    $idraxips = $cridrps["idraxips"] ?? "";

                                    $no = 1;
                                    $sqldamod = mysqli_query($konek, "SELECT d.iddetail_raxips,u.nama_unit,d.no_unit,d.wo_unit FROM detail_raxips d INNER JOIN unit u ON d.idunit=u.idunit WHERE idraxips='$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_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 uraianraxips_service j INNER JOIN jenis_service s ON j.idjenis_service=s.idjenis_service WHERE j.iddetail_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 uraianraxips_barang ub INNER JOIN barang b ON ub.idbarang=b.idbarang WHERE ub.iddetail_raxips = '$iddraxips'"
                                        );
                                        $damodb = mysqli_num_rows($querygabung);

                                        if ($damodb == 0) {
                                    ?>
                                            <tr style="text-align:center;">
                                                <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>
                                            </tr>
                                        <?php
                                            $no++;
                                            continue;
                                        }
                                        $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:center; 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 uraianraxips_service
                                                                WHERE iddetail_raxips = '$iddraxips'

                                                                UNION ALL

                                                                SELECT totalbarang_raxi AS total
                                                                FROM uraianraxips_barang
                                                                WHERE iddetail_raxips = '$iddraxips'
                                                            ) AS total_all
                                                        ");

                                        $totald = mysqli_fetch_assoc($query_total);
                                        ?>
                                        <tr style="text-align: center;">
                                            <td colspan="3" style="font-weight: 700;">Subtotal</td>
                                            <th><?= number_format($tuotald = $totald['grand_total'], 0, ',', '.') ?></th>
                                        </tr>
                                        <tr style="text-align: center;">
                                            <td colspan="3" style="font-weight: 700;">PPN 11%</td>
                                            <th><?= number_format($ppnd = $totald['grand_total'] * 0.11, 0, ',', '.') ?></th>
                                        </tr>
                                        <tr style="text-align: center;">
                                            <td colspan="3" style="font-weight: 700;">TOTAL</td>
                                            <th><?= number_format($kabehd = $ppnd + $tuotald, 0, ',', '.') ?></th>
                                        </tr>
                                    <?php
                                    }
                                    ?>
                                </tbody>
                            </table>
                        </div>
                    </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="cetakword-raxips.php?nofile=<?php echo $nofile ?>" type="button" class="btn btn-primary"><i class="bi bi-filetype-doc"></i></a>
                    <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="printe<?= $row['idraxips']; ?>" 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.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>