<?php
// - nninfo.php
//add session_start to get _session variables. merickk
session_start();
require_once "main.php";
Logger::configure('log4php.xml');
$log = Logger::getLogger('nninfo');
global $db;
//added save gets for id and submittype. merickk
$lID = (!empty($_GET['id']) ? $_GET['id'] : null);
$lsubmitType = (!empty($_GET['submitType']) ? $_GET['submitType'] : null);
if ($_SESSION['access']<4){
    if ($lsubmitType=='Add') {
       
      //  $test = bill_insert_note($_SESSION['comnum'], date('Y-m-d', time()), $_GET['title'], $_GET['other']);
          $test = bill_insert_note($_GET['id'], date('Y-m-d', time()), $_GET['title'], $_GET['other']);
        if ($test) {
            $log->info($lsubmitType.' - user = '.$_SESSION['user'].' - '.$_SESSION['comnum'].' = '.$lID);
            echo "<script type=text/javascript> parent.location.href = parent.location.href;</script>";
        } else {
            $log->warn($lsubmitType.' - user = '.$_SESSION['user'].' - '.$_SESSION['comnum'].' = '.$lID);
            echo 'There was a database error';
        }
    }
?>
    <script>
        function setType(type)
        {
            //formName is the name of your form
            document.accinform.submitType.value = type;
        }
    </script>    
    <form name="accinform" action="#" onsubmit="jQuery.ajax({url:'<?php echo $defaultHomeLink ?>/includes/nninfo.php', data: jQuery(this).serialize(), cache: false, success: function(data){jQuery('#accinfo').html(data);}});return false;">
    <table border="1">
        <tr>
            <td><label for="title">Title</label></td>
            <td><input type="text" name="title" id="title" size="30"></td>
        </tr>
        <tr>
            <td><label for="other" >Note</label></td>
            <td><input type="text" size="200" name="other" id="other" ></td>
        </tr>
        <tr>
            <td><input type="hidden" name="submitType">
                <input type="hidden" name="id" value="<?php echo $lID ?>">
                <input type="submit" onclick="setType('Add')" value="Add"/>
            </td>
            <td><?php echo $lsubmitType . '--For Customer ID--' . $lID; ?></td>
        </tr>
    </table>
    </form>
<?php
} else {
?>
    <script>
        alert('You do not have a high enough access level to post payments\n\
               or charges!\n\
               Please see your administrator.');
    </script>
<?php    
} 
//added this closeing php tag. merickk. 
//this one right here lol ---->?>