Ini saya kasih full scriptnya mas:
<?php
ob_start();
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<!--[if IE 9]>
<link rel="stylesheet" media="screen" href="css/ie9.css"/>
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" media="screen" href="css/ie8.css"/>
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" media="screen" href="css/ie7.css"/>
<![endif]-->
<script type="text/javascript" src="js/plugins/jquery-1.7.min.js"></script>
<script type="text/javascript" src="js/plugins/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="js/plugins/jquery.validate.min.js"></script>
<script type="text/javascript" src="js/plugins/ui.spinner.js"></script>
<script type="text/javascript" src="js/custom/general.js"></script>
<script type="text/javascript" src="js/custom/form.js"></script>
<script type="text/javascript" src="js/custom/tables.js"></script>
<!--[if lt IE 9]
<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->
<script src="src/js/jscal2.js"></script>
<script src="src/js/lang/en.js"></script>
<link rel="stylesheet" type="text/css" href="src/css/jscal2.css" />
<link rel="stylesheet" type="text/css" href="src/css/border-radius.css" />
<link rel="stylesheet" type="text/css" href="src/css/steel/steel.css" />
</head>
<body>
<ul class="maintabmenu multipletabmenu">
<li class="current"><a href="">Add Purchase order (po)</a></li>
<li><a href="">PO this mounth</a></li>
</ul><!--maintabmenu-->
<div class="content">
<div class="contenttitle">
<h2 class="form"><span>PO Input</span></h2>
</div><!--contenttitle-->
<?php
include ("mis/config.php");
if ($_POST){
$code=$_POST['po_code'];
$date=$_POST['date'];
$sup=$_POST['supplier'];
$port=$_POST['port'];
$notify=$_POST['notify'];
$cur=$_POST['currency'];
$note=$_POST['note'];
$oc=$_POST['oc_number'];
$ocdate=$_POST['oc_date'];
$load=$_POST['loading_date'];
$ship=$_POST['shipment_date'];
$eta=$_POST['eta_date'];
$lc=$_POST['lc'];
$status=$_POST['status'];
$tqty=$_POST['total_qty'];
$grand=$_POST['grand_total'];
$sql= "insert into purchase_order set po_code='$code', date='$date', supplier='$sup',port='$port',notify='$notify',currency='$cur',note='$note',oc_number='$oc',oc_date='$ocdate',loading_date='$load',shipment_date='$ship',eta_date='$eta',lc='$lc',status='$status',total_qty='$tqty',grand_total='$grand' ";
echo "<br><br><br><br><br><br><br>";
mysql_query($sql) or die
("<div class='notification msgerror' style='margin-top:-140px;'>
<a class='close'></a>
<p><b>SAVING FAILED ! </b> </p>
</div> <a href='javascript:history.go(-1)'>Back</a> <br> The reason is ".mysql_error());
?>
<script language="javascript">
var time_left = 3;
var cinterval;
function time_dec(){
time_left--;
document.getElementById('countdown').innerHTML = time_left;
if(time_left == 0){
clearInterval(cinterval);
document.location.href="home.php?source=add-po";
}
}
cinterval = setInterval('time_dec()', 1000);
</script>
<div style="margin-top:-140px;" class="notification msgsuccess">
<a class="close"></a>
<p><strong>Saving Data Success !</strong>
Redirecting In <span id="countdown">3</span></p>
</div><!-- notification msgsuccess -->
<?php
//isian update pruchase detail
//count
//$sql5="select count(*) as totrows from purchase_detail where po_code='$po'";
//$query5=mysql_query($sql5);
//$data=mysql_fetch_array($query5);
//$totalData = $data['totrows'];
//for($i = 1; $i <= $totalData; $i++)
//{
//$price=$_POST['price'.$i];
//$qty=$_POST['qty'.$i];
//$total=$_POST['total'.$i];
//if (!empty($price))
//{
//$sql2="update purchase_detail set price='$price',qty='$qty',total='$total' where po_code='$code'";
//mysql_query($sql2);
//}
//}
?>
<?php
}
?>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
<br />
<?php
$today=date("Ymd");
$query = "SELECT max(po_code) AS last FROM purchase_order WHERE po_code LIKE '$today%'";
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
$lastNoTransaksi = $data['last'];
$lastNoUrut = substr($lastNoTransaksi, 8, 4);
$nextNoUrut = $lastNoUrut + 1;
$nextNoTransaksi = $today.sprintf('%04s', $nextNoUrut);
?>
<form id="formpo" class="stdform" method="post" action="">
<table width="100%" border="1">
<tr>
<td width="15%"><strong>PO #</strong></td>
<td width="35%"><input type="text" name="po_code" id="po_code" value="<?php echo $nextNoTransaksi;?>" readonly="po_code" class="longinput" /></td>
<td colspan="2"><strong>Supplementary data :</strong></td>
</tr>
<tr>
<td><strong>Date</strong></td>
<td>
<input name='date' size="10" id="f_date1" class="mediuminput" readonly="tgl2_event" /><button id="f_btn1">...</button><br />
<script type="text/javascript">//<![CDATA[
Calendar.setup({
inputField : "f_date1",
trigger : "f_btn1",
onSelect : function() { this.hide() },
dateFormat : "%Y-%m-%d"
});
//]]></script>
</td>
<td><strong>OC #</strong></td>
<td><input type="text" name="oc_number" id="oc_number" class="longinput" /></td>
</tr>
<tr>
<script type="text/javascript">
function supp()
{
window.open("mis/purchase order/popup_supplier.php","mywindow","menubar=0,top=50, left=300, scrollbars=yes, resizable=1,width=650,height=650");
}
</script>
<td><strong>Supplier</strong></td>
<td><a href="javascript:supp();"><input type="text" name="supplier" id="supplier" style=" text-transform:capitalize" class="longinput" />
<img src="images/icons/search.png" style="height:25px; width:25px; vertical-align:middle;" title="Search Category"/>
</td>
<td><strong>OC Date</strong></td>
<td>
<input name='oc_date' size="10" id="f_date2" class="yellowBGField" readonly="tgl2_event" /><button id="f_btn2">...</button><br />
<script type="text/javascript">//<![CDATA[
Calendar.setup({
inputField : "f_date2",
trigger : "f_btn2",
onSelect : function() { this.hide() },
dateFormat : "%Y-%m-%d"
});
//]]></script>
</td>
</tr>
<tr>
<td><strong>Destination Port </strong></td>
<td style="text-transform:capitalize;">
<select name="port">
<option value="0" selected="selected"> -- Choose One --</option>
<?php
include "mis/config.php";
$sql= "select * from port";
$query=mysql_query($sql);
while($r=mysql_fetch_array($query)) {
echo "<option value= '$r[port_name]'>$r[port_name]</option>";
}
?>
</select>
</td>
<td><strong>Loading Date </strong></td>
<td>
<input name='loading_date' size="10" id="f_date3" readonly="loading_date" /><button id="f_btn3">...</button><br />
<script type="text/javascript">//<![CDATA[
Calendar.setup
({
inputField : "f_date3",
trigger : "f_btn3",
onSelect : function() { this.hide() },
dateFormat : "%Y-%m-%d"
});
//]]></script>
</td>
</tr>
<tr>
<td><strong>Notify Party </strong></td>
<td>
<select name="notify">
<option value="0" selected="selected"> -- Choose One --</option>
<?php
include "mis/config.php";
$sql= "select * from notify_party";
$query=mysql_query($sql);
while($r=mysql_fetch_array($query)) {
echo "<option value= '$r[company]'>$r[company]</option>";
}
?>
</select>
</td>
<td><strong>Shipment Date </strong></td>
<td>
<input name="shipment_date" size="10" id="f_date4" readonly="shipment_date" /><button id="f_btn4">...</button><br />
<script type="text/javascript">//<![CDATA[
Calendar.setup({
inputField : "f_date4",
trigger : "f_btn4",
onSelect : function() { this.hide() },
dateFormat : "%Y-%m-%d"
});
//]]></script>
</td>
</tr>
<tr>
<td><strong>Currency</strong></td>
<td>
<input type="radio" name="currency" value="IDR"/> Rp (IDR)
<input type="radio" name="currency" value="US Dollar"/> $ (US Dollar)
</td>
<td><strong>ETA Date </strong></td>
<td>
<input name='eta_date' size="10" id="f_date5" readonly="eta_date" /><button id="f_btn5">...</button><br />
<script type="text/javascript">//<![CDATA[
Calendar.setup({
inputField : "f_date5",
trigger : "f_btn5",
onSelect : function() { this.hide() },
dateFormat : "%Y-%m-%d"
});
//]]></script>
</td>
</tr>
<tr>
<td><strong>Note</strong></td>
<td><input type="text" name="note" id="note" class="longinput" /></td>
<td><strong>LC / TT </strong></td>
<td><input type="text" name="lc" id="lc" class="longinput" /></td>
</tr>
<tr style="visibility:hidden">
<td></td>
<td><input type="text" name="status" value="Pending" /></td>
</tr>
</table>
<br />
<script type="text/javascript">
function oc(){
window.open("mis/purchaseOrder/attachment_oc.php?PONumber=<?php echo $nextNoTransaksi; ?>","mywindow","menubar=0,top=50, left=300, scrollbars=yes, resizable=1,width=650,height=450");
}
function shipment(){
window.open("mis/purchaseOrder/attachment_shipment.php?PONumber=<?php echo $nextNoTransaksi; ?>","mywindow","menubar=0,top=50, left=300, scrollbars=yes, resizable=1,width=650,height=450");
}
</script>
<h2>Upload Attachment</h2>
<table width="30%">
<tr>
<td><a href="javascript:oc();">Upload File OC</a></td>
<td><a href="javascript:shipment();">Upload File Shipment</a></td>
</tr>
</table>
<br />
<h2>Item Purchase Order <a href="javascript:openwindow();" style="text-decoration:none;"><img src="images/add.jpg" style="width:35px; height:35px;" title="Add Item" /></a></h2>
<script type="text/javascript">
function openwindow()
{
window.open("mis/purchaseOrder/po_popup.php?PONumber=<?php echo $nextNoTransaksi; ?>","mywindow","menubar=0,top=50, left=300, scrollbars=yes, resizable=1,width=850,height=650");
}
</script>
<table cellpadding="0" cellspacing="0" border="0" class="stdtable">
<colgroup>
<col class="con1" />
<col class="con0" />
<col class="con1" />
<col class="con0" />
<col class="con1" />
<col class="con0" />
<col class="con1" />
<col class="con0" />
<col class="con1" />
<col class="con0" />
<col class="con1" />
</colgroup>
<thead>
<tr>
<th class="head1">ID</th>
<th class="head0">PO #</th>
<th class="head1">Product Name</th>
<th class="head0">Product #</th>
<th class="head1">Design Name</th>
<th class="head0">Description</th>
<th colspan="2" class="head1">Price</th>
<th class="head0">Qty</th>
<th class="head1">Total</th>
<th class="head0">Act</th>
</tr>
</thead>
<tfoot>
<tr>
<th colspan="8" class="head1">GRAND TOTAL</th>
<th class="head0"><input type="text" name="total_qty" value="0" id="small" readonly="" /></th>
<th class="head1"><input type="text" name="grand_total" value="0" id="fixed" readonly="" /></th>
<th class="head0"></th>
</tr>
</tfoot>
<?php
$po= $nextNoTransaksi;
$no=1;
$sql="select * from purchase_detail where po_code = '$po'";
$query=mysql_query($sql);
while ($r=mysql_fetch_array($query)){
$id=$r['id'];
?>
<tbody>
<tr>
<td><input type="text" name="id" value="<?php echo "$id"; ?>" id="small" readonly="id"></input> </td>
<td><?php echo $r['po_code']; ?> </td>
<td style="text-transform:capitalize;"><?php echo $r['product_name']; ?></td>
<td style="text-transform:uppercase;"><?php echo $r['product_code']; ?></td>
<td style="text-transform:capitalize;"><?php echo $r['design']; ?></td>
<td><?php echo $r['description']; ?></td>
<td><input type="text" name="price[<?php echo $no ?>]" value='<?php echo $r['price']; ?>' onkeyup="grandTotal()" id="fixed" class="price" /></td>
<td style="text-align: center;">x</td>
<td><input type="text" name="qty[<?php echo $no?>]" value='0' id="small" onkeyup="grandTotal()" class="qty"/></td>
<td align="right"><input type="text" name="total[<?php echo $no?>]" value="0" onkeyup="grandTotal()" id="fixed" class="total" readonly="total[<?php echo $no?>]" /></td>
<td><a href="home.php?source=delete-cart-po&code=<?php echo $r['product_code'];?>&PONumber=<?php echo $nextNoTransaksi; ?>" onclick='return confirm("Are you sure to delete this data?");'><img src="images/icons/default/trash.png" title="Delete Data" /></a></td>
</tr>
<?php
$no++;
?>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('.price').live('keyup',function(){
var total = $(this).parent().next().next().next().find('.total');
var qty = $(this).parent().next().next().find('.qty');
$(total).val($(this).val() * $(qty).val());
});
$('.qty').live('keyup',function(){
var total = $(this).parent().next().find('.total');
var price = $(this).parent().prev().prev().find('.price');
$(total).val($(this).val() * $(price).val());
});
});
function grandTotal(){
var total = 0;
var qty = 0;
$('.total').each(function(){
total += parseFloat($(this).val());
});
$('input[name="grand_total"]').val(total);
$('.qty').each(function(){
qty += parseFloat($(this).val());
});
$('input[name="total_qty"]').val(qty);
}
</script>
<?php }?>
</tbody>
</table>
<div align="right" style="padding-top:20px;"><button type="reset" class="stdbtn btn_black">Reset</button> <button type="submit" class="stdbtn btn_black">Save to Pending PO</button></div>
</form>
<br clear="all" /><br />
</div>
</body>
</html>