<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"],
						"amount"=>$_POST["amount"],
						"type"=>$_POST["name"],
						"date"=>$_POST["udate"],
						"detail"=>$_POST["detail"],
						"session"=>$_SESSION["admin"]["session"],
						"school_id"=>$_SESSION["admin"]["school_id"],
						"added_by"=>$_SESSION["admin"]["uid"]);
						//if(isset($_POST["udate"]))$saveAry["date"]=$_POST["udate"];
		$db->insertAry("extra_amount",$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>
<!--<h2>User Detail</h2>
<table class="table">
    <tr style="border-right: 5px solid #f00;border-left: 5px solid #f00;">
        <td><strong class="st">Name:</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["name"] ?></td>
        <td><strong class="st">Class:</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["class"] ?></td>
        <td><strong class="st">id no:</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["idno"] ?></td>
        <td><strong class="st">Medium:</strong></td><td><?php echo $aryForm["medium"] ?></td>
    </tr>
    <tr style="border-right: 5px solid #f00;border-left: 5px solid #f00;">
        <td><strong class="st">DOB:</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["dob"] ?></td>
        <td><strong class="st">Father:</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["fname"] ?></td>
        <td><strong class="st">DOA:</strong></td><td style="border-right:5px solid #f00"><?php echo $aryForm["doa"] ?></td>
        <td><strong class="st">Contact:</strong></td><td><?php echo $aryForm["mobile"] ?></li></td>
    </tr>
</table>-->
<h2 class="title">Add Amount Detail</h2>
<form method="post" action="">
<table>
    <tr>
        <th>Name</th><td><select required class="select-text" name="name" style="width:100%">
        <option>Select Mode</option>
        <?php $all=$db->getRows("Select id,name from extra_mode where session='".$_SESSION["admin"]["session"]."'");
		foreach($all as $al){?>
        <option value="<?php echo $al['id'] ?>"><?php echo $al['name'] ?></option>
        <?php }?></select></td>
    </tr>
    <tr>
        <th>Cheque Date</th><td><input type="datetime" class="datepicker select-text" name="udate" style="width:100%"></td>
    </tr>
    <tr>
        <th>Amount</th><td><input required type="text" class="select-text" name="amount" style="width:100%"></td>
    </tr>
    <tr>
        <th>Detail</th><td><input type="text" class="select-text" name="detail" style="width:100%"></td>
    </tr>
    <tr>
        <td>&nbsp;</td><td><input type="submit" class="btn-delete" value="Save Detail" ></td>
    </tr>
</table>
</form>