<?php

session_start();



include_once './connection_sql.php';

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




    $_SESSION["custno"] = $_GET['custno'];

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

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

    $cuscode = $_GET["custno"];

    $sql = "Select * from dag_item_master where dag_no='" . $cuscode . "'";
//    echo $sql;
    $sql = $conn->query($sql);
    if ($row = $sql->fetch()) {
       

        $ResponseXML .= "<id1><![CDATA[" . $row['dag_no'] . "]]></id1>";
        $ResponseXML .= "<str_customername><![CDATA[" . $row['description'] . "]]></str_customername>";
        $ResponseXML .= "<str_amount><![CDATA[" . $row['price'] . "]]></str_amount>";
//        $ResponseXML .= "<str_name><![CDATA[" . $row['size'] . "]]></str_name>";
//        $ResponseXML .= "<str_remark><![CDATA[" . $row['remark'] . "]]></str_remark>";
    }


    $ResponseXML .= "</salesdetails>";
    echo $ResponseXML;
}


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


    $ResponseXML = "";




    $ResponseXML .= "<table   class=\"table table-bordered\">
                <tr>
                    <th>Code</th>
                    <th>Panalti Type Name</th>
                    <th>Amount</th>
                   

                </tr>";


    $sql = "Select * from dag_item_master where dag_no <>''";

    if ($_GET["cusno"] != "") {
        $sql .= " and dag_no = '" . $_GET["cusno"] . "'";
    }
    if ($_GET['customername'] != "") {
        $sql .= " and description like '%" . $_GET['customername'] . "%'";
    }
    if ($_GET['customername1'] != "") {
        $sql .= " and price like '%" . $_GET['customername1'] . "%'";
    }
    if ($_GET['customername2'] != "") {
        $sql .= " and size like '%" . $_GET['customername2'] . "%'";
    }
    $sql .= " order by  dag_no";

    foreach ($conn->query($sql) as $row) {
        $cuscode = $row['dag_no'];
        $stname = $_GET["stname"];

        $ResponseXML .= "<tr>               
                              <td onclick=\"custno('$cuscode', '$stname');\">" . $row['dag_no'] . "</a></td>
                                <td onclick=\"custno('$cuscode', '$stname');\">" . $row['description'] . "</a></td>
                                <td onclick=\"custno('$cuscode', '$stname');\">" . $row['price'] . "</a></td>
                                <td onclick=\"custno('$cuscode', '$stname');\">" . $row['size'] . "</a></td>
                            </tr>";
    }


    $ResponseXML .= "   </table>";


    echo $ResponseXML;
}
?>
