<style>

.popup-form{
	margin:0px;
	border:2px solid #600;
	padding:5px;
}
.title{
  text-align: center;
  color: #fff;
  background-color: #1443BD;
  padding: 4px;
  border: 1px inset #1443BD;
  box-shadow: 0px 0px 10px #050101;
  border-radius: 5px;
}
.btn-new{
  background-color: #05967A;
  color: #fff;
  border: 2px outset #05967A;
  padding: 4px 15px;
  font-weight: 700;
  border-radius: 5px;
  box-shadow: 0px 2px #352E2E;
}
.btn-delete{
  background-color: #CA1A1A;
  border: 2px outset #CA1A1A;
  box-shadow: 1px 3px #322C2C;
  color: #fff;
  padding: 4px 15px;
  font-weight: 700;
  border-radius: 5px;
}
.select-text{
	padding: 3px;
  border: 2px solid #747171;
  color: #380303;
  font-weight: 600;
}
.level, .btn-new, .btn-delete{
	margin-left: 10px;
  margin-right: 5px;
}
</style>
<?php
if($_POST){
		$saveAry=array("idno"=>$_GET["id"],
						"notice"=>$_POST["notice"]);
						//if(isset($_POST["udate"]))$saveAry["date"]=$_POST["udate"];
		$db->insertAry("notes_detail",$saveAry);
		echo "Record Save Successfully<br>".$db->getErMsg();
}

$aryForm=$db->getRow("SELECT * FROM student WHERE school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$_GET['id']."'");
?>
<link rel="stylesheet" href="<?php echo URL_ROOT; ?>js/jquery-ui.css">
<script src="<?php echo URL_ROOT; ?>js/jquery-1.10.2.js"></script>
<script src="<?php echo URL_ROOT; ?>js/jquery-ui.js"></script>
<script>
var add_tr='<tr id="row_1"><td ><input type="text" class="st-forminput" style="width:86%;" name="attr_month[]" /></td><td ><textarea type="text" class="st-forminput" style="width:86%;" name="attr_name[]" ></textarea></td><td><input type="text" class="st-forminput" style="width:90%;" name="attr_value[]" /></td><td><a class="delete" href="javascript:;">X</a></td></tr>';
$(document).ready(function(){
	$("#add").click(function(){
		$("#tbody").append($(add_tr));
	
		$('#tbody td a.delete').on('click',function() { 
			var rowCount = $('#tbody tr').length;
			if(rowCount<=1){
				//alert("This item cannot deleted !!!");
			}else{
				$(this).parent().parent().remove(); 
			}
		});	
	});
});
function fetchDetail(ids){
	var values=$(ids).val();
	 $.getJSON("ajax.php?type=getValByRecepit&id="+values, function(field){
		 //alert(field.month)
		$("#month").val(field.month)
		$("#name").val(field.name)
		$("#value").val(field.value)
    });
}
$(function() {
	$(".datepicker").each(function(index, element) {
        var d = new Date(); // for now
		datetext=d.getHours()+": "+d.getMinutes()+": "+d.getSeconds();
		$( this ).datepicker({
		  changeMonth: true,
		  changeYear: true,
		  showOn: "button",
		  buttonImage: "<?php echo URL_ROOT ?>js/images/calendar.gif",
		  buttonImageOnly: true,
		  buttonText: "Select date",
		  dateFormat: 'yy-mm-dd ',
		  onSelect: function(datetext){
			var d = new Date(); // for now
			datetext=datetext+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
			$(this).val(datetext);
		  }
		});
    });
});
</script>


<div style="width:100%;float:left;border:solid 2px;">
<h2 class="title">Add Notes</h2>
<form method="post" action="">
    <table border="1" style="width:100%;" cellspacing="0">
        <tr>
            <th>Notes</th>
            <td><textarea  required type="text"  name="notice" rows="5" cols="80" value="<?php echo $_POST['number'] ?>"></textarea></td>
            <td colspan="2"><input type="submit" class="btn-delete" value="Save " ></td>
        </tr>
    </table>
</form>
    <br>
    <table border="2" style="width:100%;" cellspacing="0">
        <tr>
            <th>S.No.</th>
            <th>Date</th>
            <th>Notes Details</th>
            <th>Delete</th>
        </tr>
    	<?php
    	$cheque=$db->getRows("select * from notes_detail where  idno='".$_GET[id]."' ");
    	$i=0;
        foreach($cheque as $chequ){ $i++;
    	$id=$chequ['id'];
        ?>
            <tr>
                <td><?= $i; ?></td>
                <td><?= $chequ['udate'];?></td>
                <td><?= $chequ['notice'];?></td>
                <td><button style="background:crimson;color:white;width:50px;padding:0px;" onclick="deletenote(<?php echo $id; ?>)">Delete</button></td>
            </tr>
        <?php } ?>
    </table>

</div>


<script type="text/javascript">
	// update_back_dues start--------
    function update(id){
    	//alert(id);
    	var sta = $('#status'+id).val();
    
        $.post( "ajax.php", {type: "cheque_status" ,
    								cheque_s: sta,
    								id:id} , function( data ) {
    									alert(data);
    		});
    }
// update_back_dues end

function deletenote(id){

    // var status = $('#status'+id).val();

    var r = confirm("Do you really want to delete this note?");
        if (r == true) {
            $.post( "<?php echo URL_ROOT ?>print/ajax.php", {
        			type: "delete_note",
        			id: id,
        			idno: "<?php echo $_GET['id'] ?>",
        		} , function( data ) {
                    // alert(data);

        	});
        // 	location.reload();
        location.reload(true);
        }
location.reload();
}
</script>