<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>

<script type="text/javascript" src="<?php echo URL_ROOT ?>js/jquery-1.9.1.js"></script>

<script type="text/javascript" src="<?php echo URL_ROOT ?>js/custom.js"></script>
<?php
if($_POST){
	//if(is_array($_POST["attr_name"]) && count($_POST["attr_name"])>0)
	//{
		$attr='<table border="0" cellpadding="0" cellspacing="0"> <thead> <tr> <th class="titleh">Month</th> <th class="titleh">Name</th> <th class="titleh" >Value</th> </tr> </thead> <tbody id="tbody">';
		/*for($i=0; $i<=count($_POST['attr_name'])-1; $i++)
		{
			if($_POST["attr_name"][$i]!="" && $_POST['attr_value'][$i]!=""){
				$attr.='<tr><td>'.$_POST['attr_month'][$i].'</td><td>'.$_POST['attr_name'][$i].'</td><td>'.$_POST['attr_value'][$i].'</td></tr>';
			}
		}*/
		//$attr.='</tbody></table>';
		$saveAry=array("idno"=>$_GET["id"],
						"number"=>$_POST["number"],
						"udate"=>$_POST["udate"],
						"amount"=>$_POST["amount"],
						//"rid"=>$_POST["rid"],
						"bankname"=>$_POST["bankname"],
						//"bankno"=>$_POST["bankno"],
						"session"=>$_SESSION["admin"]["session"],
						"school_id"=>$_SESSION["admin"]["school_id"],
						"added_by"=>$_SESSION["admin"]["uid"],
						//"detail"=>$attr
						);print_r($saveAry);
		$d=$db->insertAry("chequefee",$saveAry);
		$rno = mysql_insert_id();
		//echo "Record Save Successfully<br>".$db->getErMsg();
		//$rno=$db->LAST_INSERT_ID();
		
		if($d){
				
		header("Location:addcheque_receiptNew.php?id=".$_GET[id]."&amt=".$_POST[amount]."&ch_no=".$_POST[number]."&rno=".$rno);
		}
	//}
	/*else{
		echo "Please enter Detail<br>";
	}*/
}


$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>-->
<div style="width:100%;  border: 4px solid black;background: #C1CCD8;">
<h2 class="title">Cheque Detail</h2>
<form method="post" action="" id='printMe'>
<table>
    <tr>
        <th>Cheque No</th><td><input required type="text" class="select-text" name="number" style="width:100%" value="<?php echo $_POST['number'] ?>"></td>
    </tr>
    <tr>
        <th>Cheque Date</th><td><input type="datetime" class="datepicker select-text" name="udate" style="width:100%" value="<?php echo $_POST['udate'] ?>"></td>
    </tr>
    <tr>
        <th>Cheque Amount</th><td><input required type="text" class="select-text" name="amount" style="width:100%" value="<?php echo $_POST['amount'] ?>"></td>
    </tr>
    <tr>
        <th>Bank Name</th><td><input type="text" class="select-text" name="bankname" style="width:100%" value="<?php echo $_POST['bankname'] ?>"></td>
    </tr>
    <!--<tr>
        <th>Branch Name</th><td><input type="text" class="select-text" name="bankno" style="width:100%" value="<?php echo $_POST['bankname'] ?>"></td>
    </tr>
    <tr>
        <th>Receipt No</th><td><input type="text" class="select-text" name="rid" onblur="fetchDetail(this)" style="width:100%" value="<?php echo $_POST['rid'] ?>"></td>
    </tr>
    <tr>
        <th>Detail</th><td>
        <table border="0" cellpadding="0" id="total_rows" cellspacing="0" class="table table-bordered popup-form">
                      <thead>
                      <tr>
                      	<th class="titleh">Date</th>
                        <th class="titleh">Detail</th>
                        <th class="titleh" >Amount</th>
                        <th style="width:10px"></th>
                      </tr>
                    </thead>
                     <tbody id="tbody">
                      <tr id="row_1">
                      	<td width="25%"><input type="text" id="month" class="st-forminput select-text" style="width:95%" name="attr_month[]"   /></td>
                        <td width="50%"><textarea type="text" id="name" class="st-forminput select-text" style="width:95%" name="attr_name[]" rows="3" ></textarea></td>
                        <td width="20%"><input type="text" id="value" class="st-forminput select-text" style="width:95%" name="attr_value[]"    /></td>
                        <td width="5%"><a class="delete" href="javascript:;"> X </a></td>
                      </tr>
                      </tbody>
                      <tfoot>
                      
                      <tr id="add_row">
                        <td colspan="2">
                          <span style="float:left;"><a id="add" style="cursor:pointer;color:blue;">Add Row</a></span>
                        </td>
                        <td width="15%"></td>
                      </tr>
                    </tfoot>
                  </table>
        </td>
    </tr>-->
    <tr>
        <td>&nbsp;</td><td><input type="submit" class="btn-delete" value="Save Detail" ></td>
		
        <td>&nbsp;</td><td>
		<!--<input style="background: firebrick;color: white;height: 26px;width: 53px;border: 2px inset snow;border-radius: 10px;" type="button"  onclick="window.print();" value="Print">-->
		</td>
    </tr>
</table>
</form>
</div>

