ko, cara menampilkan/pindah halmn dr so.php k print.php gmn y ko???
thx
so.php
<?php error_reporting (E_ALL ^ E_NOTICE); ?>
<script type="text/javascript">
$(function() {
$("#cust_name" ).autocomplete({
source: "app/searchCustomer.php?keyword="+$("#cust_name" ).val(),
minLength: 2,
select: function( event, ui ) {
$("#cust_name").val(ui.item.label);
$("#cust_id").val(ui.item.value);
return false;
}
});
$( "#tgl_kirim" ).datepicker();
});
</script>
<?php
$keyword = (isset($_REQUEST['keyword']))?trim(addslashes($_REQUEST['keyword'])):"";
$error = "";
if (isset($_REQUEST['delete'])){
$sql = "DELETE FROM salesorder WHERE md5(id)='".trim(addslashes($_REQUEST['id']))."'";
queryDb($sql);
}
?>
<div class='filter ui-corner-all'>
<div align='right' class='subTitle'>SalesOrder</div>
<table width='100%' border='0' cellpadding='2'>
<tr>
<td align='left'>
<form method='post' action='../salesorder_/?cmd=salesorder'>
<table border='0' cellpadding='2'>
<tr>
<td align='left'>Keyword</td>
<td align='left'><input type='text' name='keyword' value='<?php echo stripslashes($keyword) ?>'></td>
<td align='left'><button type='submit' name='cari'>Cari</button></td>
</tr>
</table>
</form>
</td>
<td align='right'><button type='button' onclick="location.href='?cmd=salesorder&add'">Tambah SalesOrder</button></td>
</tr>
</table>
</div>
<?php
if(isset($_REQUEST['edits']))
{
//test
$id = $_POST['id'];
$kode = $_POST['kode'];
$tgl = $_POST['tgl'];
$tgl_kirim = $_POST['tgl_kirim'];
$description = $_POST['description'];
$cust_id = $_POST['cust_id'];
$sql="UPDATE salesorder SET
kode='$kode',
cust_id='$cust_id',
tgl_kirim='$tgl_kirim',
description='$description'
where id='$id'";
$res = queryDb($sql);
//end of test
for ($v=1;$v<=5;$v++)
{
// $total = $_POST['total_'];
$total = 0;
$ids = $_POST['id_'.$v];
$kode_brg = $_POST['kode_brg_'.$v];
$sales_code= $_POST['sales_code_'.$v];
$prod_code = $_POST['prod_code_'.$v];
$nama_produk = $_POST['nama_produk_'.$v];
//$np_detail = $_POST['np_detail_'.$u];
$qty = $_POST['qty_'.$v];
$unit = $_POST['unit_'.$v];
$harga = $_POST['harga_'.$v];
//$total += $harga * $qty;
if($kode_brg == ''):
//
else:
$sqlupd = "UPDATE salesorderdetail SET kode_brg='$kode_brg', sales_code='$sales_code',
prod_code='$prod_code',
nama_produk='$nama_produk',
qty='$qty',
unit='$unit',
harga='$harga' WHERE id='$ids'";
$resupd = queryDb($sqlupd);
endif;
}
/* $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo '<a href="'.$url.'">Klik disini untuk melanjutkan</a>';*/
echo "<script>location.href='?cmd=salesorder'</script>";
}
elseif (!isset($_REQUEST['add']) && !isset($_REQUEST['edit'])){
$filter = ($keyword!="")?" AND (kode_client LIKE '%$keyword%' OR nama_client LIKE '%$keyword%' OR nama_alias LIKE '%$keyword%')":"";
$sql = "SELECT a.id, b.kode_brg,b.nama_produk,b.unit,c.nama_client
FROM salesorder a, salesorderdetail b,client c
WHERE a.id=b.id_so and a.cust_id=c.id ORDER BY a.id ASC";
$res = queryDb($sql);
$num = @mysql_num_rows($res);
if ($num==0){
echo "<div class='emptyData'>Data kosong</div>";
} else {
?>
<table width='100%' border='1' class='tableData'>
<tr>
<th width="54">No</th>
<th width="201">Nama Client</th>
<th width="143">Kode Barang</th>
<th width="158">Nama Produk</th>
<th width='136'></th>
</tr>
<?php
$i = 0;
while ($row = @mysql_fetch_assoc($res)){
/*$cp = "CP : $row[cp1] $row[cp2]<br>";
$telp = "Telp : $row[no_telp] $row[no_telp2] $row[no_telp3]";*/
?>
<tr>
<td align='center'><?php echo ++$i; ?></td>
<td><?php echo stripslashes($row['nama_client']) ?></td>
<td><?php echo stripslashes($row['kode_brg']) ?></td>
<td><?php echo stripslashes($row['nama_produk']) ?></td>
<td align='center'><a href="print.php?id=<?php echo $row['id'];?>"><img src='images/ico/print.png' /></a><a href="?cmd=so&print.php?id=<?php echo $row['id'];?>"></a>
<a href="javascript:print('<?php echo $row['id'];?>')"><img src='images/ico/print.png'></a>
<a href="?cmd=so&edit=1&id=<?php echo $row['id'];?>"><img src='images/ico/ubah.png'></a>
<a href="?cmd=so&delete=1&id=<?php echo md5($row['id']);?>" onclick="return confirm ('Apakah Anda yakin akan menghapus data ini?')"><img src='images/ico/hapus.png'></a> </td>
</tr>
<?php
}
?>
</table>
<?php
}
} else {//Kalo tambah atau Ubah
$id = (isset($_REQUEST['id']))?trim($_REQUEST['id']):'';
if ($id!="" && !isset($_REQUEST['save'])){
$sql = "SELECT a.id,a.kode,a.tgl,a.tgl_kirim,a.description, b.id AS Upil,
b.kode_brg, b.nama_produk,b.np_detail,b.sales_code,b.prod_code,b.qty,b.unit,b.harga,c.nama_client
FROM client c , salesorderdetail b,salesorder a
WHERE c.id=a.cust_id and a.id=b.id_so
and a.id='$id'";//id_so='".$album['id']."'"
$data = fetchRow($sql);
$kode = stripslashes($data[1]);
$tgl = stripslashes($data[2]);
$tgl_kirim = stripslashes($data[3]);
$description = stripslashes($data[4]);
$kode_brg = stripslashes($data[5]);
$nama_produk = stripslashes($data[6]);
$np_detail = stripslashes($data[7]);
$sales_code = stripslashes($data[8]);
$prod_code = stripslashes($data[9]);
$qty = stripslashes($data[10]);
$unit = stripslashes($data[11]);
$harga = stripslashes($data[12]);
$cust_id = stripslashes($data[14]);
} else {
$kode = isset($_REQUEST['kode'])?addslashes($_REQUEST['kode']):'';
$tgl = isset($_REQUEST['tgl'])?addslashes($_REQUEST['tgl']):date('Y-m-d');
$tgl_kirim = isset($_REQUEST['tgl_kirim'])?addslashes($_REQUEST['tgl_kirim']):'';
$description = isset($_REQUEST['description'])?addslashes($_REQUEST['description']):'';
$kode_brg = isset($_REQUEST['kode_brg'])?addslashes($_REQUEST['kode_brg']):'';
$nama_produk = isset($_REQUEST['nama_produk'])?addslashes($_REQUEST['nama_produk']):'';
$np_detail = isset($_REQUEST['np_detail'])?addslashes($_REQUEST['np_detail']):'';
$sales_code = isset($_REQUEST['sales_code'])?addslashes($_REQUEST['sales_code']):'';
$prod_code = isset($_REQUEST['prod_code'])?addslashes($_REQUEST['prod_code']):'';
$qty = isset($_REQUEST['qty'])?addslashes($_REQUEST['qty']):'';
$unit = isset($_REQUEST['unit'])?addslashes($_REQUEST['unit']):'';
$harga = isset($_REQUEST['harga'])?addslashes($_REQUEST['harga']):'';
$cust_id = isset($_REQUEST['cust_id'])?addslashes($_REQUEST['cust_id']):'';
if (isset($_REQUEST['save'])){
if ($kode!=""){
if ($id==""){//Add new
$sql = "INSERT INTO salesorder SET
kode='$kode',cust_id='$cust_id',tgl='$tgl',tgl_kirim='$tgl_kirim',description='$description'";
$res = queryDb($sql);
//sql2="":
$sql2="select last_insert_id(id) from salesorder order by id desc limit 1";
$res2=queryDb($sql2);
$row=mysql_fetch_row($res2);
$id_so=$row[0];
$u = 1;
for ($v=1;$v<=5;$v++)
{
// $total = $_POST['total_'];
$total = 0;
$kode_brg = $_POST['kode_brg_'.$v];
$sales_code= $_POST['sales_code_'.$v];
$prod_code = $_POST['prod_code_'.$v];
$nama_produk = $_POST['nama_produk_'.$v];
//$np_detail = $_POST['np_detail_'.$u];
$qty = $_POST['qty_'.$v];
$unit = $_POST['unit_'.$v];
$harga = $_POST['harga_'.$v];
//$total += $harga * $qty;
if($kode_brg == ''):
//
else:
$sql3 = "INSERT INTO salesorderdetail SET
kode_brg='$kode_brg',
sales_code='$sales_code',
prod_code='$prod_code',
nama_produk='$nama_produk',
qty='$qty',
unit='$unit',
harga='$harga',
id_so='$id_so'";
$res3 = queryDb($sql3);
endif;
$u++;
}
$error = ($res)?"":"Gagal menyimpan Data";
if ($res3)
echo "<script>location.href='?cmd=salesorder'</script>";
}
} else {
$error = "Kode harus diisi";
}
}
elseif(isset($_REQUEST['edits']))
{
?>
<script type="text/javascript">alert('wew')</script>
<?php
}
else
{
echo "wew";
}
}
?>
<?php
echo ($error!="")?"<div class='ui-state-error errorMsg'>$error</div>":"";
?>
<form method='post'>
<input type='hidden' name='id' value='<?php echo $id ?>'>
<table border="0" cellspacing="0" cellpadding="1" style="padding-left:20px">
<tr>
<td class="require"> Code</td>
<td>:</td>
<td><input type="text" name="kode" value="<?php echo $kode ?>" /></td>
<td width="200" align="right">Date : <?php echo date("d/m/Y", strtotime("$tgl"))?></td>
</tr>
<tr>
<td class="require">Customer</td>
<td>:</td>
<td colspan="2"><input type="text" id="cust_name" name="cust_name" value="<?php echo $cust_id?>"/><input type="hidden" name="cust_id" id="cust_id" /> </td>
</tr>
<tr>
<td>Tanggal Kirim</td>
<td>:</td>
<td colspan="2"><input type="text" name="tgl_kirim" id="tgl_kirim" class="text_box" value="<?php echo $tgl_kirim; ?>"/>
</td>
</tr>
<tr>
<td colspan="4"><div style="font-size:16px; border-bottom:1px dashed #000; margin-bottom:3px">Order Detail</div></td>
</tr>
<tr>
<td colspan="4"><table width="75%" border="1" align="center" cellpadding="1" style="border:solid 1px #000; border-collapse:collapse">
<tr bordercolor="#999999" bordercolordark="#333333">
<th width="218" rowspan="2">Kode Barang</th>
<th colspan="2" align="center">Kode</th>
<th width="360" rowspan="2">Nama Produk</th>
<th width="76" rowspan="2" >Qty</th>
<th width="62" rowspan="2" >Units</th>
<th width="156" rowspan="2">Harga</th>
</tr>
<tr><th width="62">Sales</th>
<th width="62">Prod</th>
<?php
$u = 1;
if(isset($_REQUEST['edit'])) :
$korong = queryDb($sql);
while($kutil= mysql_fetch_array($korong)):
?>
</tr>
<tr>
<input type="hidden" name="id_<?php echo $u ?>" value="<?php echo $kutil['Upil']; ?>"/>
<td valign="top"><input type="text" name="kode_brg_<?php echo $u ?>" value="<?php echo $kutil['kode_brg']; ?>" size="15"/></td>
<td valign="top"><input type="text" name="sales_code_<?php echo $u ?>" size="5" value="<?php echo $kutil['sales_code']; ?>" /></td>
<td valign="top"><input type="text" name="prod_code_<?php echo $u ?>" size="5" value="<?php echo $kutil['prod_code']; ?>" /></td>
<td align="center"><input type="text" name="nama_produk_<?php echo $u?>" size="50" value="<?php echo $kutil['nama_produk']; ?>"/></td>
<td align="center"><input type="text" name="qty_<?php echo $u ?>" size="5" value="<?php echo $kutil['qty']; ?>" /></td>
<td align="center"><input type="text" name="unit_<?php echo $u ?>" size="5" value="<?php echo $kutil['unit']; ?>" /></td>
<td align="center"><input type="text" name="harga_<?php echo $u ?>" size="10" value="<?php echo $kutil['harga']; ?>" /></td>
</tr>
<?php $u++;
endwhile;
elseif(isset($_REQUEST['add'])):
$z = 1;
for ($i=1;$i<=5;$i++)
{
?>
<tr>
<td valign="top"><input type="text" name="kode_brg_<?php echo $z ?>" value="<?php echo $kode_brg; ?>" size="15"/></td>
<td valign="top"><input type="text" name="sales_code_<?php echo $z ?>" size="5" value="<?php echo $sales_code; ?>" /></td>
<td valign="top"><input type="text" name="prod_code_<?php echo $z ?>" size="5" value="<?php echo $prod_code; ?>" /></td>
<td align="center"><input type="text" name="nama_produk_<?php echo $z?>" size="50" value="<?php echo $nama_produk; ?>"/></td>
<td align="center"><input type="text" name="qty_<?php echo $z ?>" size="5" value="<?php echo $qty; ?>" /></td>
<td align="center"><input type="text" name="unit_<?php echo $z ?>" size="5" value="<?php echo $unit; ?>" /></td>
<td align="center"><input type="text" name="harga_<?php echo $z ?>" size="10" value="<?php echo $harga; ?>" /></td>
</tr>
<?php
$z++;
}
else:
echo 'korong';
endif;
?><?php //}?>
</table></td>
</tr>
<tr>
<td>Keterangan</td>
<td> </td>
<td colspan="2" rowspan="2"><textarea style='font-size:12px' name='description' rows="3" cols="30"><?php echo $description; ?></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="4">
<?php
if(isset($_REQUEST['edit'])):
echo '<button type="submit" name="edits">Update</button>';
else:
echo '<button type="submit" name="save">Save</button>';
endif;
?> Â
<button type="button" onclick="location.href='?cmd=salesorder&keyword=<?php echo $keyword ?>'">Cancel</button> </td>
</tr>
</table>
</form>
<?php
}
?>
print.php
<?php
require_once('library/init.php');
require_once('library/dbFunctions.php');
require_once('library/functions.php');
openDb();
?>
<?php
$id = isset($_REQUEST['id'])?$_REQUEST['id']:'';
$sql1 = "SELECT i.kode,i.description, DATE_FORMAT(i.tgl,'%e %b %Y'),
DATE_FORMAT(i.tgl,'%d'),c.nama_client,c.alamat1,c.kota,DATE_FORMAT(i.tgl_kirim,'%e %b %Y')
FROM salesorder i, t_client c
WHERE c.id=i.cust_id AND i.id='$id'";
$res1 = mysql_query($sql1) or die(mysql_error());
$row1 = mysql_fetch_row($res1);
$tgl = stripslashes($row1[2]);
$thn = stripslashes($row1[3]);
$nama = stripslashes($row1[4]);
$alamat = stripslashes($row1[5]);
$kota = stripslashes($row1[6]);
$tgl_kirim= stripslashes($row1[7]);
$description = stripslashes($row1[1]);
$sql = "SELECT kode_brg,qty,unit,harga,sales_code,prod_code,nama_produk,np_detail FROM salesorderdetail WHERE id_so='$id'";
$res = mysql_query($sql) or die (mysql_error());
$data= array();
$i = 0;
while ($row = mysql_fetch_array($res)){
$data[$i] = $row;
$i++;
}
//print_r($data);
?>
<script language="javascript">
function print(){
var select=document.getElementById('select').value;
if (select == 1 || select==2)
{
window.open('print4.php?id=<?php echo $id ?>&select='+select,'windowName','width=780,height=400');
}else {
window.open('print3.php?id=<?php echo $id ?>&select='+select,'windowName','width=780,height=400');
}
}
</script>
<form action='' method='post'>
<table width="80%" border="0" align="center" cellpadding="1" bordercolor="#CCCCCC" bgcolor="#FFFFFF" style="border-collapse:collapse; border-bottom-color:#000000; border-bottom-style:inherit; border:double">
<tr>
<td width="10%" height='100' align='center' valign='middle'>
<select name="select" id="select">
<option value="1">Asli</option>
<option value="2">Copy</option>
<option value="3">Produksi</option>
</select>
<button type='button' value="Print" onclick="print()"><img src='../salesorder/images/ico/print.png' align='left' /> Cetak<br />
Sekarang</button><?php // <input type="button" value="Print Popup" onclick="if (window.print) winref.print()">
?></td>
<td width="90%" height='100' align='right' valign='top'>
<table width='300' border='0' cellpadding='1' cellspacing='1'>
<tr height='23'><td>Bandung, <?php echo $tgl; ?></td></tr>
<tr height='23'>
<td style='padding-right:10px'>Kepada Yth : <?php echo $nama; ?></td>
</tr>
<tr height='23'>
<td style='padding-right:10px'><?php echo $alamat; ?></td>
</tr>
<tr height='23'>
<td style='padding-right:10px'><?php echo $kota; ?></td>
</tr>
</table> </td>
</tr>
<tr>
<td align='left' colspan='2'>
<table width='1008' border='1' align="center" cellpadding='0' cellspacing='0' style="border-collapse:collapse; border:solid 1px #000">
<tr height='25'>
<th rowspan="2" bgcolor="#999999"><span class="style1">No</span></th>
<th rowspan="2" bgcolor="#999999"><span class="style1">Kode Barang</span></th>
<th colspan="2" bgcolor="#999999"><span class="style1">Code</span></th>
<th rowspan="2" bgcolor="#999999"><span class="style1">Nama Produk</span></th>
<th rowspan="2" bgcolor="#999999"><span class="style1">Qty</span></th>
<th rowspan="2" bgcolor="#999999"><span class="style1">Units</span></th>
<th rowspan="2" bgcolor="#999999"><span class="style1">Harga</span></th>
<th rowspan="2" bgcolor="#999999"><span class="style1">Subtotal</span></th>
</tr>
<tr height='25'>
<th bgcolor="#999999"><span class="style1">Sales</span></th>
<th bgcolor="#999999"><span class="style1">Prod</span></th>
</tr>
<?php
$sub = 0;
foreach($data as $row)
//for ($i=0;$i<soListNumber;$i++)
{
?>
<tr height='25'>
<td width='37' align="center"><?php echo $i++; ?></td>
<td width='188'><?php echo ($row['kode_brg']); ?><br /></td>
<td width='48' align='center'><?php echo $row['sales_code']; ?><br /></td>
<td width='66' align='center'><?php echo $row['prod_code']; ?><br /></td>
<td width='171' align='right'><?php echo $row['nama_produk']; ?><br /><?php echo $row['np_detail']; ?></td>
<td width='57' align='right'><?php echo $row['qty']; ?><br /></td>
<td align='center' width='81'><?php echo $row['unit']; ?><br /></td>
<td align='right' width='170' style='padding-right:5px'><?php echo "Rp. ".number_format($row['harga'],2 , ',' , '.'); ?> <br /></td>
<td align='right' width='170' style='padding-right:5px'><?php echo "Rp. ".number_format($row['harga']*$row['qty'],2 , ',' , '.'); ?><br /></td>
</tr>
<?php
$sub += ($row[1]*$row[3]);
}
?>
</table>
<br>
<table width='891' border='0' align="center" cellpadding='0' cellspacing='0'>
<tr height='25'>
<td colspan='4' rowspan='3'>
<table border='0'>
<tr height='70'>
<td width="78" align='center' valign='bottom'>
Marketing<br>
<br><br><br />(............) </td>
<td width="48" align='center' valign='bottom'> </td>
<td width="96" align='center' valign='bottom'>
Menyetujui<br>
<br><br>
<br />(...........) </td>
</tr>
</table> </td>
<td width="236"> </td>
<td width="251" align='right' style='padding-right:5px'>Total</td>
<td width="168" align='right' style='padding-right:5px'><?php echo "Rp. ".number_format($sub,2 , ',' , '.'); ?></td>
</tr>
<tr height='25'>
<td> </td>
<td align='right' style='padding-right:5px'>Tgl Kirim</td>
<td align='right' style='padding-right:5px'><?php echo $tgl_kirim; ?></td>
</tr>
</table> </td>
</tr>
<tr>
<td align='left' colspan='2'> </td>
</tr>
</table>
</form>