<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$this->load->helper('url');
$this->load->helper('form');
$this->load->database();
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Job Card Details</title>
        <style type="text/css">
            #table_customer_details{
                border: solid 1px silver;
                border-collapse: collapse;
                margin-top: 20px;
                text-align: center;
            }
            #table_customer_details th{ 
                border: #000 solid 3px;
            }
        </style>
    </head>
    <body>
    <center>
        <table border="0">
            <tbody>
                <?php
                if (!isset($_GET["id_jc"])) {
                    ?>
                <script type="text/javascript">
                    alert("No Job card Selected.");
                </script>
                <?php
            } else if ($_GET["id_jc"] == "empty") {
                ?>
                <script type="text/javascript">
                    alert("No Job card Selected.");
                </script>
                <?php
            } else {
                $jobcard = $this->db->query("SELECT customer.customer_name as cusname,date,job_card_total,advanced_amount,balance_amount from job_card join customer on job_card.customer_customer_id = customer.customer_id where idjob_card='" . $_GET["id_jc"] . "'");
                foreach ($jobcard->result() as $jc) {
                    
                }
                ?>
                <tr>
                    <td>Date</td>
                    <td>:</td>
                    <td><?php echo $jc->date; ?></td>
                    <td style="width: 100px;"></td>
                    <td>Total Amount</td>
                    <td>:</td>
                    <td><?php echo $jc->job_card_total; ?></td>
                </tr>
                <tr>
                    <td>Customer</td>
                    <td>:</td>
                    <td><?php echo $jc->cusname; ?></td>
                    <td></td>
                    <td>Advanced Amount</td>
                    <td>:</td>
                    <td><?php echo $jc->advanced_amount; ?></td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>Balance Amount</td>
                    <td>:</td>
                    <td><?php echo $jc->balance_amount; ?></td>
                </tr>
                <?php
            }
            ?>
            </tbody>
        </table>

        <table cellpadding="10" border="1" id="table_customer_details">
            <thead style="border: #000 solid 3px; background-color: #f1f1f1;">
                <tr>
                    <th>Customer Print Code</th>
                    <th>Print Qty</th>
                    <th>Amount</th>
                </tr>
            </thead>
            <tbody>
                <?php
                if (!isset($_GET["id_jc"])) {
                    ?>
                <script type="text/javascript">
                    alert("No Job card Selected.");
                </script>
                <?php
            } else if ($_GET["id_jc"] == "empty") {
                ?>
                <script type="text/javascript">
                    alert("No Job card Selected.");
                </script>
                <?php
            } else {
                $jobcard_id = $_GET["id_jc"];
                $jobcard_data = $this->db->query("SELECT customers_product.customers_product_code AS pcode,job_card_qty,product_amount FROM job_card_details join customers_product on job_card_details.customers_product_product_id=customers_product.product_id WHERE job_card_idjob_card='" . $jobcard_id . "'");
                foreach ($jobcard_data->result() as $cpr) {
                    ?>
                    <tr>
                        <td><?php echo $cpr->pcode; ?></td>
                        <td><?php echo $cpr->job_card_qty; ?></td>
                        <td><?php echo $cpr->product_amount; ?></td>
                    </tr>
                    <?php
                }
            }
            ?>
            </tbody>
        </table>
    </center>
</body>
</html>
