MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0750) :  /home2/imyrqtmy/public_html/builty/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/builty/search_result.php
<?php
include("vendor/inc/config.php");
?>
<!DOCTYPE html>
<html>
<head>
    <title>Search GRNO</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            padding: 30px;
            background-color: #f9f9f9;
        }

        h2 {
            text-align: center;
            color: #333;
        }

        .center-table {
            display: flex;
            justify-content: center;
            margin-top: 30px;
        }

        table {
            border-collapse: collapse;
            width: 95%;
            max-width: 1000px;
            background-color: #fff;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }

        th, td {
            padding: 12px 15px;
            border: 1px solid #ccc;
            text-align: center;
        }

        th {
            background-color: #f1f1f1;
        }

        .no-result {
            text-align: center;
            color: red;
            margin-top: 50px;
            font-size: 18px;
        }

        .btn {
            padding: 6px 12px;
            text-decoration: none;
            border-radius: 4px;
            font-size: 14px;
        }

        .btn-primary { 
            background-color: #007bff; 
            color: #fff; 
               display: block !important;
        }
        .btn-warning { background-color: #ffc107; color: #000; }
    </style>
</head>
<body>

<?php
if (isset($_GET['grno']) && !empty($_GET['grno'])) {
    $grno = $_GET['grno'];

    $sql = "SELECT * FROM builties WHERE grno = ?";
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("s", $grno);
    $stmt->execute();
    $result = $stmt->get_result();

    echo "<h2>Search Result for GRNO: $grno</h2>";

    if ($result->num_rows > 0) {
        echo "<div class='center-table'>
                <table>
                    <tr>
                        <th>GRNO</th>
                        <th>GR File</th>
                        <th>Invoice File</th>
                        <th>Recieving Gr</th>
                        <th>Recieving Invoice</th>
                        <th>Uploaded Suplier File</th>
                        <th>Origin</th>
                        <th>Destination</th>
                        <th>Status</th>
                        <th>Remark</th>
                    </tr>";

                    while ($row = $result->fetch_assoc()) {
                        $gr_file_link = "vendor/generate_pdf.php?id=" . $row['id'];
                        $invoice_file_path = "vendor/invoices/invoice_" . $row['id'] . ".pdf";
                        $invoice_exists = file_exists($invoice_file_path);
                    
                        $gr_upload = !empty($row['varify_gr']) ? "vendor/buimg/" . $row['varify_gr'] : '';
                        $inv_upload = !empty($row['verify_image']) ? "vendor/buimg/" . $row['verify_image'] : '';
                        $sup_upload = !empty($row['supplier_file']) ? "vendor/sublier/" . $row['supplier_file'] : '';
                    
                        echo "<tr>
                            <td>{$row['grno']}</td>
                    
                            <!-- GR File -->
                            <td><a class='btn btn-primary' href='{$gr_file_link}' target='_blank'>View GR</a></td>
                    
                            <!-- Invoice File -->
                            <td>";
                                if ($invoice_exists) {
                                    echo "<a class='btn btn-primary' href='{$invoice_file_path}' target='_blank'>View Invoice</a>";
                                } else {
                                    echo "<span style='color:red;'>Not Generated</span><br>
                                          <a class='btn btn-warning' href='../vendor/invoice.php?id={$row['id']}'>Generate</a>";
                                }
                            echo "</td>";
                    
                            // Upload GR (Preview)
                            echo "<td>";
                            if ($gr_upload && file_exists($gr_upload)) {
                                $ext = strtolower(pathinfo($gr_upload, PATHINFO_EXTENSION));
                                if ($ext === 'pdf') {
                                    echo "<a href='$gr_upload' target='_blank' class='btn btn-secondary btn-sm'>View GR PDF</a>";
                                } else {
                                    echo "<a href='$gr_upload' target='_blank'><img src='$gr_upload' width='50' height='50'></a>";
                                }
                            } else {
                                echo "<span style='color:gray;'>No File</span>";
                            }
                            echo "</td>";
                    
                            // Upload Invoice (Preview)
                            echo "<td>";
                            if ($inv_upload && file_exists($inv_upload)) {
                                $ext = strtolower(pathinfo($inv_upload, PATHINFO_EXTENSION));
                                if ($ext === 'pdf') {
                                    echo "<a href='$inv_upload' target='_blank' class='btn btn-secondary btn-sm'>View Invoice PDF</a>";
                                } else {
                                    echo "<a href='$inv_upload' target='_blank'><img src='$inv_upload' width='50' height='50'></a>";
                                }
                            } else {
                                echo "<span style='color:gray;'>No File</span>";
                            }
                            echo "</td>";
                    
                            // Upload Supplier File (Preview)
                            echo "<td>";
                            if ($sup_upload && file_exists($sup_upload)) {
                                $ext = strtolower(pathinfo($sup_upload, PATHINFO_EXTENSION));
                                if ($ext === 'pdf') {
                                    echo "<a href='$sup_upload' target='_blank' class='btn btn-secondary btn-sm'>View Supplier PDF</a>";
                                } else {
                                    echo "<a href='$sup_upload' target='_blank'><img src='$sup_upload' width='50' height='50'></a>";
                                }
                            } else {
                                echo "<span style='color:gray;'>No File</span>";
                            }
                            echo "</td>";
                    
                            // Remaining fields
                            echo "<td>{$row['origin']}</td>
                                  <td>{$row['destination']}</td>
                                  <td>{$row['status']}</td>
                                  <td>{$row['remark']}</td>
                        </tr>";
                    }
                    

        echo "</table></div>";
    } else {
        echo "<div class='no-result'>No record found for GRNO: $grno</div>";
    }

    $stmt->close();
    $conn->close();
} else {
    echo "<div class='no-result'>No GRNO provided in the query string.</div>";
}
?>

</body>
</html>

MMCT - 2023