0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 52.15.233.83


Current Path : /var/www/html/oums/
Upload File :
Current File : /var/www/html/oums/agents_save.php

<?php include("phpscript/sys_session.php"); ?>

<!DOCTYPE html>

<head>

    <link rel="shortcut icon" type="image/x-icon" href="images/logisys-icon.png" />
    <link rel="stylesheet" type="text/css" href="style.css" />
    <script src="jscript/mainpage.js" type="text/javascript"></script>
    <script src="jquery/jquery-3.1.0/jquery.min.js" type="text/javascript"></script>

    <SCRIPT TYPE="text/javascript">
        $(document).ready(function() {
            $("#sav").click(function() {
                if (document.getElementById("txtagencode").value == '') {
                    alert("Please enter agent code!");
                    txtagencode.focus();
                    return false;
                }

                if (document.getElementById("txtagenname").value == '') {
                    alert("Please enter agent name!");
                    txtagenname.focus();
                    return false;
                }
            });
        });
    </SCRIPT>
</head>

<body>
    <?php
    include("header.php");
    global $page_mode;
    include("sys_module.php");
    get_page_info(basename($_SERVER['PHP_SELF']));

    @$agen_code = "";
    if (isset($_GET['id'])) {
        $page_mode = "Edit";
        $agen_code = $_GET['id'];

        $mysql = "select * from massupplier where fagencode='$agen_code'";
        $myres = mysqli_query($mycon, $mysql);
        $i = 0;
        while ($row = @mysqli_fetch_assoc($myres)) {
            $agen_code = $row['fagencode'];
            $agen_name = $row['fagenname'];
            $agen_addr = $row['fagenaddr'];
            $agen_phon = $row['fagenphon'];
            $agen_mobl = $row['fagenmobl'];
            $agen_mail = $row['fagenmail'];
            $agen_faxs = $row['fagenfaxs'];
            $agen_remk = $row['fremarks'];
        }
    } elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
        @$page_mode = $_POST['txtpagemode'];
        @$agen_code = $_POST['txtagencode'];
        @$agen_name = $_POST['txtagenname'];
        @$agen_addr = $_POST['txtagenaddr'];
        @$agen_phon = $_POST['txtagenphon'];
        @$agen_mobl = $_POST['txtagenmobl'];
        @$agen_faxs = $_POST['txtagenfaxs'];
        @$agen_mail = $_POST['txtagenmail'];
        @$agen_remk = $_POST['txtaremarks'];
    } else {
        $page_mode = "Add";
        $agen_code = "<AUTO>";
        $agen_name = "";
        $agen_addr = "";
        $agen_phon = "";
        $agen_mobl = "";
        $agen_mail = "";
        $agen_faxs = "";
        $agen_remk = "";
    }

    ?>
    <form name="<?php echo @$link_name; ?>" id="<?php echo @$link_name; ?>" action="<?php echo @$link_path; ?>" method="post">
        <div id="page-middle">
            <div id="page_header">
                <div id="page-container-titl"><?php echo @$page_mode . " " . @$link_tit; ?></div>
                <div id="page_button"><?php echo @$link_but; ?></div>
            </div>

            <div id="page_content">
                <div id="page_content_form">
                    <input type="hidden" id="txtpagemode" name="txtpagemode" value="<?php echo @$page_mode; ?>" />
                    <table class="table_content" width="60%" height="10px" border="0" align="center">
                        <tr>
                            <td width="140px" align="left">Agent Code </td>
                            <td width="5px" align="center">: </td>
                            <td><input type="text" id="txtagencode" name="txtagencode" value="<?php echo $agen_code; ?>" readonly="readonly" style="width:80px; text-align:center;" /></td>
                        </tr>

                        <tr>
                            <td width="140px" align="left">Agent Name </td>
                            <td width="5px" align="center">: </td>
                            <td><input type="text" id="txtagenname" name="txtagenname" value="<?php echo $agen_name; ?>" maxlength="50" style="width:400px;" /></td>
                            <script>
                                document.getElementById('txtagenname').focus()
                            </script>
                        </tr>

                        <tr>
                            <td width="140px" align="left">Address </td>
                            <td width="5px" align="center">: </td>
                            <td><textarea id="txtagenaddr" name="txtagenaddr" style="width:400px; min-height:100px;" /><?php echo $agen_addr; ?></textarea></td>
                        </tr>

                        <tr>
                            <td width="140px" align="left">Phone </td>
                            <td width="5px" align="center">: </td>
                            <td><input type="text" id="txtagenphon" name="txtagenphon" value="<?php echo $agen_phon; ?>" maxlength="50" style="width:400px;" /></td>
                        </tr>

                        <tr>
                            <td width="140px" align="left">Mobile No.</td>
                            <td width="5px" align="center">: </td>
                            <td><input type="text" id="txtagenmobl" name="txtagenmobl" value="<?php echo $agen_mobl; ?>" maxlength="50" style="width:400px;" /></td>
                        </tr>

                        <tr>
                            <td width="140px" align="left">Fax No.</td>
                            <td width="5px" align="center">: </td>
                            <td><input type="text" id="txtagenfaxs" name="txtagenfaxs" value="<?php echo $agen_faxs; ?>" maxlength="50" style="width:400px;" /></td>
                        </tr>

                        <tr>
                            <td width="140px" align="left">Email ID </td>
                            <td width="5px" align="center">: </td>
                            <td><input type="text" id="txtagenmail" name="txtagenmail" value="<?php echo $agen_mail; ?>" maxlength="50" style="width:400px;" /></td>
                        </tr>

                        <tr>
                            <td width="140px" align="left">Remarks </td>
                            <td width="5px" align="center">: </td>
                            <td><input type="text" id="txtaremarks" name="txtaremarks" value="<?php echo $agen_remk; ?>" maxlength="100" style="width:400px;" /></td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </form>
</body>

</html>
<?php
if (isset($_POST['sav'])) {
    @$agen_code = $_POST['txtagencode'];
    @$agen_name = $_POST['txtagenname'];
    @$agen_addr = $_POST['txtagenaddr'];
    @$agen_phon = $_POST['txtagenphon'];
    @$agen_mobl = $_POST['txtagenmobl'];
    @$agen_faxs = $_POST['txtagenfaxs'];
    @$agen_mail = $_POST['txtagenmail'];
    @$agen_remk = $_POST['txtaremarks'];

    if (strtolower($page_mode) == "add") {
        @$mysql1 = "select * from control";
        @$myres1 = mysqli_query($mycon, $mysql1);
        @$row1 = @mysqli_fetch_assoc($myres1);
        @$agen_slno = $row1["fagenslno"] + 1;
        @$agen_code = "A" . str_pad($agen_slno, 3, '0', STR_PAD_LEFT);

        $mysql = "update control set fagenslno='$agen_slno'";
        $myres = mysqli_query($mycon, $mysql);

        $mysql = "insert into massupplier (fagencode,fagenname,fagenaddr,fagenphon,fagenmobl,fagenfaxs,fagenmail,fremarks) values('$agen_code','$agen_name','$agen_addr','$agen_phon','$agen_mobl','$agen_faxs','$agen_mail','$agen_remk')";
        $myres = mysqli_query($mycon, $mysql);



        echo ("<script language=\"JavaScript\" type=\"text/JavaScript\">\n");
        echo ("alert('Agent  '+\"$agen_code\"+' inserted successfully!');\n");
        echo ("window.location='agents.php';\n");
        echo ("</script>\n");
    } elseif (strtolower($page_mode) == "edit") {
        $mysql = "update massupplier set fagencode='$agen_code', fagenname='$agen_name', fagenaddr='$agen_addr', fagenphon='$agen_phon', fagenmobl='$agen_mobl', fagenfaxs='$agen_faxs', fagenmail='$agen_mail', fremarks='$agen_remk' where fagencode='$agen_code'";
        $myres = mysqli_query($mycon, $mysql);

        echo ("<script language=\"JavaScript\" type=\"text/JavaScript\">\n");
        echo ("alert('Agent '+\"$agen_code\"+' updated successfully!');\n");
        echo ("window.location='agents.php';\n");
        echo ("</script>\n");
    }
}
?>