<?php

session_start();

include_once './connection_sql.php';

if ($_GET["Command"] == "pass_quot") {

    header('Content-Type: text/xml');
    echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";

    $ResponseXML = "";
    $ResponseXML .= "<salesdetails>";

    $cuscode = $_GET["custno"];
    
    $sql = "Select * from view_dag_received where REFNO='" . $cuscode . "' ";
  
    $sql = $conn->query($sql);
    if ($row = $sql->fetch()) {


        $ResponseXML .= "<id><![CDATA[" . $row['REFNO'] . "]]></id>";
        $ResponseXML .= "<str_customername><![CDATA[" . $row['SUP_CODE'] . "]]></str_customername>";
        $ResponseXML .= "<str_customername1><![CDATA[" . $row['SUP_NAME'] . "]]></str_customername1>";
        $ResponseXML .= "<str_customername2><![CDATA[" . $row['REMARK'] . "]]></str_customername2>";
        $ResponseXML .= "<str_customername3><![CDATA[" . $row['AMOUNT'] . "]]></str_customername3>";
        $ResponseXML .= "<str_customername4><![CDATA[" . $row['SDATE'] . "]]></str_customername4>";
        
    }
    
    
    $ResponseXML .= "<sales_table><![CDATA[<table class=\"table\">
					<tr>
						<td style=\"width: 90px;\">Item</td>
						<td>Description</td>
						<td style=\"width: 100px;\">Brand</td>
						<td style=\"width: 100px;\">Serial No</td>
						<td style=\"width: 100px;\">Rate</td>
						<td style=\"width: 10px;\"></td>
					</tr>";

    $i = 1;

   $sql1 = "select * from dag_received_item where REFNO ='" . $cuscode . "' ";
  
    foreach ($conn->query($sql1) as $row1) {

        $ResponseXML .= "<tr>                              
                             <td>" . $row1['STK_NO'] . "</td>
                             <td >" . $row1['DESCRIPT'] . "</td>
                             <td>" . $row1['RATE'] . "</td>
                             <td>" . $row1['serial_no'] . "</td>
                             <td>" . $row1['brand'] . "</td>
                        </tr>";

        $i = $i + 1;
    }

    $ResponseXML .= "   </table>]]></sales_table>";

    $ResponseXML .= "</salesdetails>";

    echo $ResponseXML;

}


?>
