<?php if (!isset($_SESSION['FirstName'])) {
	session_start();
}
    include ('includes/db1config.php');
    include ('../includes/mysql_connect.php');
	include ('includes/admin-config.php');	//get site options
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?php 
include('title.php'); 
echo'<link href="css/'.$stylesheet.'" rel="stylesheet" type="text/css" media="screen" />';	
echo'<link href="css/print_style.css" rel="stylesheet" type="text/css" media="print" />';
?>

<link rel="stylesheet" type="text/css" href="css/cssverticalmenu.css" />
<link rel="stylesheet" href="includes/tinyaccordion/style.css" type="text/css" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> </script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>


<script type="text/javascript" src="../js/ddaccordion.js"></script>

<!-- for popup windows -->
<link href="css/popup-style.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="js/script.js"></script>
 <!-- end popup script-->

<style type="text/css">

.mainForm{
width: 700px;
margin: auto;
}
.leftForm {
float: left;
width: 300px;
}
.rightForm{
float: left;
width: 300px;
}
.saveButton{
margin: auto;
}
#save-button{
margin-right: 115px;
width: 150px;
}

.arrowlistmenu{
	width: 100%; /*width of accordion menu*/
	}

	.arrowlistmenu .menuheader{ /*CSS class for menu headers in general (expanding or not!)*/
	font:12px Verdana,Arial;width:95%; border:1px solid #467182; padding:7px; 
		font-weight:bold; margin-top:5px; cursor:pointer; 
	    -webkit-border-radius: 7px;
	    -moz-border-radius: 7px;
	    border-radius: 7px;
	    border: solid 1px #e8e8e8;
	    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
	    -webkit-transition-duration: 0.2s;
	    -moz-transition-duration: 0.2s;
	    transition-duration: 0.2s;
	    -webkit-user-select:none;
	    -moz-user-select:none;
	    -ms-user-select:none;
	    user-select:none;
		color:#fff;
		background-color:#2077a1;
		padding-left:.5em;padding-right:.5em;
	}

	.arrowlistmenu .openheader{ /*CSS class to apply to expandable header when it's expanded*/
	background-image: url(titlebar-active.png);
	}

	.arrowlistmenu ul{ /*CSS for UL of each sub menu*/
	list-style-type: none;
	margin: 0;
	padding: 0;
	margin-bottom: 0px; /*bottom spacing between each UL and rest of content*/
	background: none;
	}

	.arrowlistmenu ul li{
	padding-bottom: 0px; /*bottom spacing between menu items*/
	}

	.arrowlistmenu ul li .opensubheader{ /*Open state CSS for sub menu header*/
	background: lightblue !important;
	}

	.arrowlistmenu ul li .closedsubheader{ /*Closed state CSS for sub menu header*/
	background: lightgreen !important;
	}

	.arrowlistmenu ul li a{
	color: #81BEF7;
	background: url(arrowbullet.png) no-repeat center left; /*custom bullet list image*/
	display: block;
	padding: 0px 0;
	padding-left: 19px; /*link text is indented 19px*/
	text-decoration: none;
	font-weight: bold;
	border-bottom: 1px solid #dadada;
	font-size: 90%;
	}

	.arrowlistmenu ul li a:visited{
	color: #81BEF7;
	}

	.arrowlistmenu ul li a:hover{ /*hover state CSS*/
	color: #FA5858;
	background-color: #FA5858;
	}

	.arrowlistmenu ul li a.subexpandable:hover{ /*hover state CSS for sub menu header*/
	background: lightblue;
	}
	html {
	    overflow-y: scroll;
	}
	

</style>

<style type="text/css">
	body#pop-up-window {
		background:none;
		margin-top:5px;
	}
	
body#pop-up-window #content,
body#pop-up-window #main-content {
margin:0px;
padding:0px;
width:100%;
background:none;
	}
	
body#pop-up-window #content {
	}
	
	#wrapper.custom {
		-webkit-border-radius: none;
		-moz-border-radius: none;
	    border-radius: 0;
		border: none;
		background: none;
		width: 770px;
		padding:0px;
		margin:0px;
		margin:16px;
	}
</style>

</head>
<body id="pop-up-window">

<div id="wrapper" class="custom">



<!-- start page -->



<!-- start content -->
<div id="content">
<div id="main-content">
   
		<div class="post">
		  <div class="entry">

<h1>Add Invoice</h1>
                
<?php 
if($_SESSION['adminkey']=="security"){
	include "invoicesub.php"; 
} else {
	echo '<font color="red"><div align="center">You are not authorized to view this page. <br>Please <a href="index.php"><font color="blue">login here</font></a>.</div></font>';
}
?>
            
 <br />

</div><!-- end entry-->

<br />

</div><!-- end post-->

</div><!-- end main-content-->

</div><!-- end content -->


<div style="clear: both;">&nbsp;</div>
<div id="page-bg-btm">
</div><!-- end page-bg-btm div -->





</div><!-- end wrapper div-->

<!-- end page -->


<!--footer-->

<script type="text/javascript">
    
    	var rowNum = 1;
        function addRow() {

			rowNum ++;

			var row = '<tr class=rowNum'+rowNum+' ><td width=10%><input required type="text" name="itemdesc[]" class="itemdesc" id="itemdesc'+rowNum+'" size="10" ></td><td width=10%><input required type="text" name="quantity[]" class="quantity" onkeypress="return isNumberKey(event)" data-id="'+rowNum+'" id="quantity'+rowNum+'" size="10" ></td><td width=10%><input required type="text" name="itemcharge[]" class="itemcharge" onkeypress="return isNumberKey(event)" data-id="'+rowNum+'" id="itemcharge'+rowNum+'" size="10" ></td><td width=10%><input required type="text" class="extendedcharge" id="extendedcharge'+rowNum+'" name="extendedcharge[]" readonly onkeypress="return isNumberKey(event)" id="Item" size="10" ></td><td  width=10%><a onclick="removeRow('+rowNum+');" id="save-button" href="javascript:void(0);" title="">Remove Row</a></td></tr>';

		  	jQuery('.addfunc').after(row);

		}

		function removeRow(rnum) {

	        jQuery('.rowNum'+rnum).remove();
		}

		$(document).ready(function() {
			
			$('#datepicker1').datepicker({ dateFormat: 'yy-mm-dd' });
			$('#datepicker1').datepicker('setDate', 'today');
			$('#datepicker2').datepicker({ dateFormat: 'yy-mm-dd' });

			$(document).on('keyup', '.itemcharge', function(event) {
				event.preventDefault();
				/* Act on the event */
				var id    		= $(this).attr('data-id') ;
				var qty   		= $('#quantity'+id+'').val();
				var price 		= $(this).val();
				var Totalprice  = qty * price;

 				$('#extendedcharge'+id+'').val(Totalprice.toFixed(2));

 				$('#invoicetotal').val( getSum() );

			});

			$(document).on('keyup', '.quantity', function(event) {
				event.preventDefault();
				/* Act on the event */
				var id    		= $(this).attr('data-id') ;
				var price   	= $('#itemcharge'+id+'').val();
				var qty 		= $(this).val();
				var Totalprice  = qty * price;

 				$('#extendedcharge'+id+'').val(Totalprice.toFixed(2));

 				$('#invoicetotal').val( getSum() );

			});

		});


		function getSum() {

		    var sum = 0;
		    
		    $('.extendedcharge').each(function() {
		        sum += parseFloat( $(this).val() );
		    });

		    return sum.toFixed(2);

		}

		function isNumberKey(evt){

   //     		var charCode = (evt.which) ? evt.which : event.keyCode
	  //       	if (charCode > 31 && (charCode < 48 || charCode > 57) || $(this).val().indexOf('.') != -1)  )
			// // if ((eve.which != 46 || $(this).val().indexOf('.') != -1) && (eve.which < 48 || eve.which > 57) )
	  //           return false;
	  //       return true;
		  	var charCode = (evt.which) ? evt.which : evt.keyCode;
        	if (charCode != 46 && charCode > 31 
	            && (charCode < 48 || charCode > 57))
	            return false;

	        return true;

	    }

	    $('form').submit(function(event) {
	    	var id ='<?php echo $_GET["id"];?>';
			window.top.location.href = "/cmsadmin/index.php?admin-page=13&custid="+id+""; 
	    });

</script>

</body>
</html>
