Wah.. pasti kalian langsung buka halaman ini ya?.. ngaku … kalian penasaran
dengan Mega Proyek 75 Juta??.. yukk.. penulis bahas secara gambling baik cara
membuat maupun cara penggunaannya.
Disini kita akan menggunakan smarty php dalam membangun aplikasi, untuk
tahu bagaimana penggunaan menggunakan smarty php dan apa itu smarty php,
penulis telah menyediakan FREE EBOOK yang bisa Anda temukan pada CD
terlampir.
Sebelum masuk ke dalam pembahasan membangun aplikasi mega proyek, buat
terlebih dahulu file dengan nama header.php yang skripnya sebagai berikut :
<?php
date_default_timezone_set('ASIA/JAKARTA');
error_reporting(0);
session_start();
// include all files are required
include "includes/connection.php";
include "includes/debug.php";
include "includes/page_function.php";
include "includes/fungsi_rupiah.php";
include "includes/fungsi_indotgl.php";
require('libs/Smarty.class.php');
$year = date('Y');
// staff detail
$queryUser = "SELECT lastLogin, photo FROM as_staffs WHERE staffID
= '$_SESSION[staffID]'";
$sqlUser = mysqli_query($connect, $queryUser);
// fetch data
$dtUser = mysqli_fetch_array($sqlUser);
1
$sqlAuthorize = mysqli_query($connect, $queryAuthorize);
Nah.. dalam file header.php banyak sekali perintah memanggil (include) file php
lainnya.. untuk hal tersebut Anda bisa temukan filenya pada cd terlampir, yaitu
pada folder Final Project/inventory/includes.
Selanjutnya kita langsung saja masuk ke dalam pembahasan inti.
5.1.1 Staff
Master data staff digunakan untuk menyimpan seluruh daftar staff perusahaan,
dari sini lah pengguna mendapatkan username dan password untuk masuk ke
dalam aplikasi inventory. Kita akan langsung membuat seluruh fungsi (create,
read, update, delete) dalam 1 file.
Buat file dengan nama staffs.php, adapun skripnya sebagai berikut :
<?php
// include header
include "header.php";
// set the tpl page
$page = "staffs.tpl";
2
$module = $_GET['module'];
$act = $_GET['act'];
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE
modulID = '1'";
$sqlAuthorizeStaff = mysqli_query($connect,
$queryAuthorizeStaff);
$dataAuthorizeStaff =
mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'],
$_SESSION['level']) === FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
// delete staff
$queryStaff = "DELETE FROM as_staffs WHERE staffID = '$staffID'";
$sqlStaff = mysqli_query($connect, $queryStaff);
if ($q != '')
{
$queryStaff = "SELECT * FROM as_staffs WHERE
staffCode LIKE '%$q%' OR staffName LIKE '%$q%' AND staffID != '1'
ORDER BY staffName ASC";
}
else
{
$queryStaff = "SELECT * FROM as_staffs WHERE
staffID != '' ORDER BY staffName ASC";
}
3
$sqlStaff = mysqli_query($connect, $queryStaff);
// fetch data
$i = 1;
while ($dtStaff = mysqli_fetch_array($sqlStaff))
{
if ($dtStaff['level'] == '1')
{
$level = "ADMINISTRATOR";
}
elseif ($dtStaff['level'] == '2')
{
$level = "SALES";
}
elseif ($dtStaff['level'] == '3')
{
$level = "KASIR";
}
elseif ($dtStaff['level'] == '4')
{
$level = "SPV";
}
elseif ($dtStaff['level'] == '5')
{
$level = "TOP";
}
else
{
$level = "-";
}
// assign
$smarty->assign("dataStaff", $dataStaff);
$smarty->assign("q", $q);
}
4
if ($sqlStaff)
{
unlink("img/staffs/".$photo);
unlink("img/staffs/thumb/small_".$photo);
}
else
{
// create new object pagination
$p = new PaginationStaff;
// limit 20 data for page
$limit = 20;
$position = $p->searchPosition($limit);
// fetch data
$i = 1 + $position;
while ($dtStaff = mysqli_fetch_array($sqlStaff))
{
if ($dtStaff['level'] == '1')
{
$level = "ADMINISTRATOR";
}
elseif ($dtStaff['level'] == '2')
{
$level = "SALES";
}
elseif ($dtStaff['level'] == '3')
{
$level = "KASIR";
}
elseif ($dtStaff['level'] == '4')
{
$level = "SPV";
}
elseif ($dtStaff['level'] == '5')
{
$level = "TOP";
}
else
{
$level = "-";
}
5
'phone' => $dtStaff['phone'],
'position' => $dtStaff['position'],
'status' => $dtStaff['status'],
'level' => $level,
'no' => $i);
$i++;
}
$smarty->assign("dataStaff", $dataStaff);
// count data
$queryCountStaff = "SELECT * FROM as_staffs";
$sqlCountStaff = mysqli_query($connect, $queryCountStaff);
$amountData = mysqli_num_rows($sqlCountStaff);
$smarty->assign("pageLink", $pageLink);
// set module
$queryModule = "SELECT * FROM as_modules WHERE status =
'Y' ORDER BY modulName ASC";
$sqlModule = mysqli_query($connect, $queryModule);
// fetch data
$k = 1;
while ($dtModule = mysqli_fetch_array($sqlModule))
{
$dataModule[] = array( 'moduleID' => $dtModule['modulID'],
'moduleName' => $dtModule['modulName'],
'no' => $k);
$k++;
}
$smarty->assign("dataModule", $dataModule);
}
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Manajemen Staff");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan pengolahan data master staff atau pegawai.");
$smarty->assign("breadcumbMenuName", "Master Data");
$smarty->assign("breadcumbMenuSubName", "Staff");
}
// include footer
include "footer.php";
?>
Selanjutnya buat file dengan nama staffs.tpl dan simpan dalam folder templates,
adapun skripnya sebagai berikut :
{include file="header.tpl"}
6
<link rel="stylesheet" type="text/css" media="all"
href="design/js/fancybox/jquery.fancybox.css">
<script type="text/javascript" src="design/js/fancybox/jquery.
fancybox.js?v=2.0.6"></script>
{literal}
<script>
$(document).ready(function() {
$('.dropdown-menu').on('click', function(e) {
if($(this).hasClass('dropdown-menu-form')) {
e.stopPropagation();
}
});
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
// Image 1
var btnUpload=$('#me');
var mestatus=$('#mestatus');
var files=$('#files');
new AjaxUpload(btnUpload, {
action: 'upload_staff.php',
name: 'uploadfile',
onSubmit: function(file, ext){
if (! (ext && /^(jpg|jpeg)$/.test(ext))){
// extension is not allowed
mestatus.text('Hanya ekstensi .JPG/JPEG yang diijinkan.');
return false;
}
//mestatus.html('<img src="images/ajax-loader.gif"
height="16" width="16">');
mestatus.html('');
},
onComplete: function(file, response){
//On completion clear the status
mestatus.text('');
//On completion clear the status
files.html('');
//Add uploaded file to list
if(response!=="error"){
7
$('<li></li>').appendTo('#files').html('<img
src="img/staffs/'+response+'" alt="" height="100"/><br
/>').addClass('success');
$('<li></li>').appendTo('#photostaff').html('<input
type="hidden" id="photo" name="photo"
value="'+response+'">').addClass('nameupload');
} else{
$('<li></li>').appendTo('#files').text(file).addClass('error');
}
}
});
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#send").on("click", function(){
var staffCode = $("#staffCode").val();
var staffName = $("#staffName").val();
var address = $("#address").val();
var address2 = $("#address2").val();
var village = $("#village").val();
var district = $("#district").val();
var city = $("#city").val();
var zipCode = $("#zipCode").val();
var province = $("#province").val();
var phone = $("#phone").val();
var position = $("#position").val();
var part = $("#part").val();
var statusStaff = $("#statusStaff").val();
var level = $("#level").val();
var photo = $("#photo").val();
var email = $("#email").val();
var password = $("#password").val();
$.ajax({
type: 'POST',
url: 'save_staff.php',
dataType: 'JSON',
data:{
staffCode: staffCode,
staffName: staffName,
address: address,
address2: address2,
village: village,
district: district,
city: city,
zipCode: zipCode,
province: province,
phone: phone,
8
position: position,
part: part,
statusStaff: statusStaff,
level: level,
photo: photo,
email: email,
password: password
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "staffs.php?msg=Data berhasil disimpan";
}
});
}
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
{include file="user_panel.tpl"}
{include file="side_menu.tpl"}
</section>
<!-- /.sidebar -->
</aside>
<!-- Right side column. Contains the navbar and content of the
page -->
<aside class="right-side">
{include file="breadcumb.tpl"}
9
<!-- TO DO List -->
<div class="box box-primary">
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Data Staff / Pegawai</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
</form>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>KODE <i class="fa fa-sort"></i></th>
<th>NAMA STAFF <i class="fa fa-sort"></i></th>
<th>TLP <i class="fa fa-sort"></i></th>
<th>POSITION <i class="fa fa-sort"></i></th>
<th>STATUS <i class="fa fa-sort"></i></th>
<th>LEVEL <i class="fa fa-sort"></i></th>
<th width="60">AKSI</th>
</tr>
</thead>
<tbody>
10
{section name=dataStaff loop=$dataStaff}
<tr>
<td>{$dataStaff[dataStaff].no}</td>
<td>{$dataStaff[dataStaff].staffCode}</td>
<td>{$dataStaff[dataStaff].staffName}</td>
<td>{$dataStaff[dataStaff].phone}</td>
<td>{$dataStaff[dataStaff].position}</td>
<td>{$dataStaff[dataStaff].status}</td>
<td>{$dataStaff[dataStaff].level}</td>
<td>
<a title="Edit" href="edit_staffs.php?module=staff&act=edit&
staffID={$dataStaff[dataStaff].staffID}" data-width="900" data-
height="420" class="various2 fancybox.iframe"><img
src="img/icons/edit.png" width="18"></a>
{/section}
</tbody>
</table>
</div>
<tbody>
{section name=dataStaff loop=$dataStaff}
<tr>
<td>{$dataStaff[dataStaff].no}</td>
<td>{$dataStaff[dataStaff].staffCode}</td>
<td>{$dataStaff[dataStaff].staffName}</td>
<td>{$dataStaff[dataStaff].phone}</td>
<td>{$dataStaff[dataStaff].position}</td>
<td>{$dataStaff[dataStaff].status}</td>
<td>{$dataStaff[dataStaff].level}</td>
11
<td>
<a title="Edit" href="edit_staffs.php?module=staff&act=edit&
staffID={$dataStaff[dataStaff].staffID}" data-width="900" data-
height="420" class="various2 fancybox.iframe"><img
src="img/icons/edit.png" width="18"></a>
<a title="Delete" href="staffs.php?module=staff&act=delete&
staffID={$dataStaff[dataStaff].staffID}" onclick="return
confirm('Anda Yakin ingin menghapus staff
{$dataStaff[dataStaff].staffName}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-left">
<ul class="pagination pagination-sm inline">
{$pageLink}
</ul>
</div>
</div><!-- /.box-header -->
<div id="inline">
<table width="95%" align="center">
<tr>
<td align="center"><h3><b>DATABASE STAFF</b></h3></td>
</tr>
<tr>
<td>
<form id="staff" name="staff" method="POST" action="#">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="170">Kode</td>
<td width="5">:</td>
<td><input type="text" id="staffCode"
name="staffCode" class="form-control" placeholder="Kode Staff"
style="width: 270px;" required></td>
<td width="50"></td>
<td colspan="3"></td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#999999"
style="border-left: 1px solid #000000; border-top: 1px solid
#000000; border-right: 1px solid #000000;"><span style="font-size:
16px;"><b>DATA PRIBADI</b></span></td>
<td></td>
<td colspan="3"><span style="font-size:
16px;"><b>DATA PERUSAHAAN</b></span></td>
</tr>
12
<tr>
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Nama Lengkap</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="text" id="staffName"
name="staffName" class="form-control" placeholder="Nama Staff"
style="width: 270px;" required></td>
<td></td>
<td>Jabatan</td>
<td>:</td>
<td><input type="text" id="position"
name="position" class="form-control" placeholder="Jabatan /
Posisi" style="width: 270px;"></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Alamat 1</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="text" id="address"
name="address" class="form-control" placeholder="Alamat 1"
style="width: 270px;"></td>
<td></td>
<td>Bagian</td>
<td>:</td>
<td><input type="text" id="part" name="part" class="form-
control" placeholder="Bagian" style="width: 270px;"></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Alamat 2</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="text" id="address2"
name="address2" class="form-control" placeholder="Alamat 2"
style="width: 270px;"></td>
<td></td>
<td>Level</td>
<td>:</td>
<td>
<select id="level" name="level" class="form-control"
style="width: 270px;" required>
<option value=""></option>
<option value="1">Administrator</option>
<option value="2">Sales</option>
<option value="3">Kasir</option>
<option value="4">SPV</option>
<option value="5">Top</option>
</select>
</td>
</tr>
<tr>
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Kelurahan</td>
<td style="background-color: #FFFFFF;">:</td>
13
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="text" id="village"
name="village" class="form-control" placeholder="Kelurahan"
style="width: 270px;"></td>
<td></td>
<td>Status</td>
<td>:</td>
<td>
<select id="statusStaff" name="statusStaff"
class="form-control" style="width: 270px;" required>
<option value=""></option>
<option value="Y">Y [Aktif]</option>
<option value="N">N [Tidak Aktif]</option>
</select>
</td>
</tr>
<tr valign="top">
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Kecamatan</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="text" id="district"
name="district" class="form-control" placeholder="Kecamatan"
style="width: 270px;"></td>
<td></td>
<td>Password</td>
<td>:</td>
<td><input type="text" value="123456" id="password"
name="password" class="form-control" placeholder="Password"
style="width: 270px;" required></td>
</tr>
<tr valign="top">
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Kota</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="city" name="city" class="form-
control" placeholder="Kota" style="width: 270px;"></td>
<td></td>
<td>Photo</td>
<td>:</td>
<td rowspan="4">
<div id="me" class="styleall" style="cursor:pointer;">
<label>
<button class="btn btn-warning">Browse</button>
</label>
</div>
<span id="mestatus"></span>
<div id="photostaff">
<li class="nameupload"></li>
</div>
<div id="files">
<li class="success"></li>
</div>
</td>
14
</tr>
<tr valign="top">
<td style="border-left: 1px solid #000000; background-
color: #FFFFFF;">Kode Pos</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="number" id="zipCode" name="zipCode"
class="form-control" placeholder="Kode Pos" style="width:
270px;"></td>
<td></td>
<td colspan="3"></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Propinsi</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="text" id="province"
name="province" class="form-control" placeholder="Propinsi"
style="width: 270px;"></td>
<td></td>
<td colspan="3"></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Telp / HP</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="phone" name="phone"
class="form-control" placeholder="Nomor Telepon Staff"
style="width: 270px;"></td>
<td></td>
<td colspan="3"></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000; border-bottom:
1px solid #000000; background-color: #FFFFFF;">Email</td>
<td style="border-bottom: 1px solid #000000; background-
color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; border-bottom:
1px solid #000000; background-color: #FFFFFF;"><input type="email"
id="email" name="email" class="form-control" placeholder="Email"
style="width: 270px;" required></td>
<td></td>
<td colspan="3"></td>
</tr>
</table>
<br>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
</div>
{/if}
</div><!-- /.box -->
</section><!-- /.Left col -->
15
</div><!-- /.row (main row) -->
</section><!-- /.content -->
</aside><!-- /.right-side -->
</div><!-- ./wrapper -->
{include file="footer.tpl"}
Proses simpan staff ini berjalan secara Ajax dan JSON, untuk itu kita buat file
untuk proses simpan, Buat file dengan nama save_staff.php, adapun skripnya
sebagai berikut :
<?php
// include header
include "header.php";
16
if ($staffCode != '' && $staffName != '' && $statusStaff != '' &&
$level != '' && $email != '' && $password != ''){
$thumbWidth = 70;
$thumbHeight = 100;
$thumbPic = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($thumbPic, $realPic, 0, 0, 0, 0, $thumbWidth,
$thumbHeight, $width, $height);
imagejpeg($thumbPic, "img/staffs/thumb/small_".$photo);
imagedestroy($realPic);
imagedestroy($thumbPic);
} // close bracket
17
'$level',
'$photo',
'$email',
'$password',
'',
'$createdDate',
'$staffID',
'',
'')";
if ($sqlStaff)
{
echo json_encode(OK);
}
}
exit();
?>
else
{
// get variable
$module = $_GET['module'];
$act = $_GET['act'];
18
// fetch data
$dataStaff = mysqli_fetch_array($sqlStaff);
} // close bracket
// include footer
include "footer.php";
?>
save_edit_staff.php
<?php
// include header
include "header.php";
19
$_POST['province']);
$phone = mysqli_real_escape_string($connect, $_POST['phone']);
$position = mysqli_real_escape_string($connect,
$_POST['position']);
$part = mysqli_real_escape_string($connect, $_POST['part']);
$statusStaff = $_POST['statusStaff'];
$level = $_POST['level'];
$photo = $_POST['photo'];
$foto = $_POST['foto'];
$email = mysqli_real_escape_string($connect, $_POST['email']);
$password = $_POST['password'];
$file = "img/staffs/".$photo;
$realPic = imagecreatefromjpeg($file);
$width = imagesx($realPic);
$height = imagesy($realPic);
$thumbWidth = 70;
$thumbHeight = 100;
imagejpeg($thumbPic, "img/staffs/thumb/small_".$photo);
imagedestroy($realPic);
imagedestroy($thumbPic);
if ($password != '')
{
$passwd = md5($password);
$queryStaff = "UPDATE as_staffs SET staffCode = '$staffCode',
staffName = '$staffName',
address = '$address',
address2 = '$address2',
village = '$village',
district = '$district',
city = '$city',
zipCode = '$zipCode',
province = '$province',
phone = '$phone',
position = '$position',
part = '$part',
status = '$statusStaff',
level = '$level',
photo = '$photo',
email = '$email',
20
password = '$passwd',
modifiedDate = '$modified_date',
modifiedUserID = '$staffID'
WHERE staffID = '$staffID2'";
}
else
{
$queryStaff = "UPDATE as_staffs SET staffCode = '$staffCode',
staffName = '$staffName',
address = '$address',
address2 = '$address2',
village = '$village',
district = '$district',
city = '$city',
zipCode = '$zipCode',
province = '$province',
phone = '$phone',
position = '$position',
part = '$part',
status = '$statusStaff',
level = '$level',
photo = '$photo',
email = '$email',
modifiedDate = '$modified_date',
modifiedUserID = '$staffID'
WHERE staffID = '$staffID2'";
}
}
else
{
if ($password != '')
{
$passwd = md5($password);
21
$queryStaff = "UPDATE as_staffs SET staffCode = '$staffCode',
staffName = '$staffName',
address = '$address',
address2 = '$address2',
village = '$village',
district = '$district',
city = '$city',
zipCode = '$zipCode',
province = '$province',
phone = '$phone',
position = '$position',
part = '$part',
status = '$statusStaff',
level = '$level',
email = '$email',
modifiedDate = '$modified_date',
modifiedUserID = '$staffID'
WHERE staffID = '$staffID2'";
}
}
if ($sqlStaff)
{
echo json_encode(OK);
}
}
exit();
?>
edit_staffs.tpl
22
$('.dropdown-menu').on('click', function(e) {
if($(this).hasClass('dropdown-menu-form')) {
e.stopPropagation();
}
});
// Image 1
var btnUpload=$('#me');
var mestatus=$('#mestatus');
var files=$('#files');
new AjaxUpload(btnUpload, {
action: 'upload_staff.php',
name: 'uploadfile',
onSubmit: function(file, ext){
if (! (ext && /^(jpg|jpeg)$/.test(ext))){
// extension is not allowed
mestatus.text('Hanya ekstensi .JPG/JPEG yang diijinkan.');
return false;
}
//mestatus.html('<img src="images/ajax-loader.gif" height="16"
width="16">');
mestatus.html('');
},
onComplete: function(file, response){
//On completion clear the status
mestatus.text('');
//On completion clear the status
files.html('');
//Add uploaded file to list
if(response!=="error"){
$('<li></li>').appendTo('#files').html('<img
src="img/staffs/'+response+'" alt="" height="100"/><br
/>').addClass('success');
$('<li></li>').appendTo('#photostaff').html('<input
type="hidden" id="photo" name="photo"
value="'+response+'">').addClass('nameupload');
} else{
$('<li></li>').appendTo('#files').text(file).addClass('error');
}
}
});
$("#deletephoto").on("click", function(){
parent.jQuery.fancybox.close();
});
$("#send").on("click", function(){
var staffID2 = $("#staffID2").val();
var staffCode = $("#staffCode").val();
var staffName = $("#staffName").val();
var address = $("#address").val();
var address2 = $("#address2").val();
var village = $("#village").val();
var district = $("#district").val();
23
var city = $("#city").val();
var zipCode = $("#zipCode").val();
var province = $("#province").val();
var phone = $("#phone").val();
var position = $("#position").val();
var part = $("#part").val();
var statusStaff = $("#statusStaff").val();
var level = $("#level").val();
var photo = $("#photo").val();
var email = $("#email").val();
var password = $("#password").val();
$.ajax({
type: 'POST',
url: 'save_edit_staff.php',
dataType: 'JSON',
data:{
staffID2: staffID2,
staffCode: staffCode,
staffName: staffName,
address: address,
address2: address2,
village: village,
district: district,
city: city,
zipCode: zipCode,
province: province,
phone: phone,
position: position,
part: part,
statusStaff: statusStaff,
level: level,
photo: photo,
email: email,
password: password
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
parent.jQuery.fancybox.close();
}
});
}
});
});
</script>
{/literal}
24
<tr>
<td>
<form id="staff" name="staff" method="POST" action="#">
<input type="hidden" id="staffID2" name="staffID2"
value="{$staffID}">
<input type="hidden" id="foto" name="foto" value="{$photo}">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="130" style="font-size: 14px;">Kode</td>
<td width="5" style="font-size: 14px;">:</td>
<td><input type="text" value="{$staffCode}"
id="staffCode" name="staffCode" class="form-control"
placeholder="Kode Customer" style="width: 270px;" required></td>
<td></td>
<td colspan="3"></td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#999999"
style="border-left: 1px solid #000000; border-top: 1px solid
#000000; border-right: 1px solid #000000;"><span style="font-size:
16px;"><b>DATA PRIBADI</b></span></td>
<td width="50"></td>
<td colspan="3"><span style="font-size:
16px;"><b>DATA PERUSAHAAN</b></span></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Nama Lengkap</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="text" id="staffName"
value="{$staffName}" name="staffName" class="form-control"
placeholder="Nama Staff" style="width: 270px;" required></td>
<td></td>
<td style="font-size: 14px;">Jabatan</td>
<td style="font-size: 14px;">:</td>
<td><input type="text" id="position"
value="{$position}" name="position" class="form-control"
placeholder="Jabatan / Posisi" style="width: 270px;"></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Alamat 1</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="address"
value="{$address}" name="address" class="form-control"
placeholder="Alamat 1" style="width: 270px;"></td>
<td></td>
<td style="font-size: 14px;">Bagian</td>
<td style="font-size: 14px;">:</td>
<td><input type="text" id="part" value="{$part}"
name="part" class="form-control" placeholder="Bagian"
style="width: 270px;"></td>
</tr>
<tr>
25
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Alamat 2</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="address2"
value="{$address2}" name="address2" class="form-control"
placeholder="Alamat 2" style="width: 270px;"></td>
<td></td>
<td style="font-size: 14px;">Level</td>
<td style="font-size: 14px;">:</td>
<td>
<select id="level" name="level" class="form-control"
style="width: 270px;" required>
<option value=""></option>
<option value="1" {if $level == '1'} SELECTED
{/if}>Administrator</option>
<option value="2" {if $level == '2'} SELECTED {/if}>Sales</option>
<option value="3" {if $level == '3'} SELECTED {/if}>Kasir</option>
<option value="4" {if $level == '4'} SELECTED {/if}>SPV</option>
<option value="5" {if $level == '5'} SELECTED {/if}>Top</option>
</select>
</td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Kelurahan</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="village" value="{$village}"
name="village" class="form-control" placeholder="Kelurahan"
style="width: 270px;"></td>
<td></td>
<td style="font-size: 14px;">Status</td>
<td style="font-size: 14px;">:</td>
<td>
<select id="statusStaff" name="statusStaff" class="form-
control" style="width: 270px;" required>
<option value=""></option>
<option value="Y" {if $statusStaff == 'Y'} SELECTED
{/if}>Y [Aktif]</option>
<option value="N" {if $statusStaff == 'N'} SELECTED
{/if}>N [Tidak Aktif]</option>
</select>
</td>
</tr>
<tr valign="top">
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Kecamatan</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" value="{$district}" id="district"
name="district" class="form-control" placeholder="Kecamatan"
style="width: 270px;"></td>
<td></td>
<td style="font-size: 14px;">Password</td>
<td style="font-size: 14px;">:</td>
26
<td><input type="text" id="password"
name="password" class="form-control" placeholder="Password"
style="width: 270px;"> <br> <span style="font-size: 10pt;">*)
Kosongkan, jika password tidak ingin diubah</span></td>
</tr>
<tr valign="top">
<td style="font-size: 14px; border-left:
1px solid #000000; background-color: #FFFFFF;">Kota</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="text" value="{$city}"
id="city" name="city" class="form-control" placeholder="Kota"
style="width: 270px;"></td>
<td></td>
<td style="font-size: 14px;">Photo</td>
<td style="font-size: 14px;">:</td>
<td rowspan="4">
<div id="me" class="styleall" style="cursor:pointer;">
<label>
<button class="btn btn-warning">Browse</button>
</label>
</div>
<span id="mestatus"></span>
<div id="photostaff">
<li class="nameupload"></li>
</div>
<div id="files">
<li class="success">
{if $photo != ''}
<img src="img/staffs/thumb/small_{$photo}"> <br><br>
<span style="font-size: 14px;"><a id="deletephoto"
href="staffs.php?module=staff&act=deletephoto&staffID={$staffID}&p
hoto={$photo}">Hapus Foto</a></span>
{/if}
</li>
</div>
</td>
</tr>
<tr valign="top">
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Kode Pos</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="number" id="zipCode"
value="{$zipCode}" name="zipCode" class="form-control"
placeholder="Kode Pos" style="width: 270px;"></td>
<td></td>
<td colspan="3"></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Propinsi</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="text" value="{$province}"
27
id="province" name="province" class="form-control"
placeholder="Propinsi" style="width: 270px;"></td>
<td></td>
<td
colspan="3"></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Telp / HP</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="text" id="phone"
value="{$phone}" name="phone" class="form-control"
placeholder="Nomor Telepon Staff" style="width: 270px;"></td>
<td></td>
<td colspan="3"></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; border-bottom: 1px solid #000000; background-color:
#FFFFFF;">Email</td>
<td style="font-size: 14px; background-color:
#FFFFFF; border-bottom: 1px solid #000000;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF; border-bottom: 1px solid
#000000;"><input type="email" id="email" value="{$email}"
name="email" class="form-control" placeholder="Email"
style="width: 270px;" required></td>
<td></td>
<td colspan="3"></td>
</tr>
</table>
<br>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
{/if}
</body>
Hasil skrip diatas akan menampilkan hasil seperti pada gambar berikut :
28
Gambar 5.2. Menambah data staff
29
5.1.2 Customer
Master data customer digunakan untuk menyimpan seluruh daftar customer
perusahaan.
Buat file dengan nama customers.php, adapun skripnya sebagai berikut :
<?php
// include header
include "header.php";
// set the tpl page
$page = "customers.tpl";
$module = $_GET['module'];
$act = $_GET['act'];
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE
modulID = '2'";
$sqlAuthorizeStaff = mysqli_query($connect,
$queryAuthorizeStaff);
$dataAuthorizeStaff = mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
// delete customer
$queryCustomer = "DELETE FROM as_customers WHERE
customerID = '$customerID'";
$sqlCustomer = mysqli_query($connect, $queryCustomer);
30
elseif ($module == 'customer' && $act == 'search')
{
$q = mysqli_real_escape_string($connect, $_GET['q']);
// fetch data
$i = 1;
while ($dtCustomer = mysqli_fetch_array($sqlCustomer))
{
$dataCustomer[] = array('customerID' => $dtCustomer['customerID'],
'customerCode' => $dtCustomer['customerCode'],
'customerName' => $dtCustomer['customerName'],
'contactPerson' => $dtCustomer['contactPerson'],
'city' => $dtCustomer['city'],
'phone1' => $dtCustomer['phone1'],
'limitBalance' => rupiah($dtCustomer['limitBalance']),
'disc1' => $dtCustomer['disc1'],
'disc2' => $dtCustomer['disc2'],
'disc3' => $dtCustomer['disc3'],
'note' => $dtCustomer['note'],
'npwp' => $dtCustomer['npwp'],
'pkpName' => $dtCustomer['pkpName'],
'no' => $i);
$i++;
}
// assign
$smarty->assign("dataCustomer", $dataCustomer);
$smarty->assign("q", $q);
}
else
{
// create new object pagination
$p = new PaginationCustomer;
// limit 20 data for page
$limit = 20;
$position = $p->searchPosition($limit);
// fetch data
$i = 1 + $position;
while ($dtCustomer = mysqli_fetch_array($sqlCustomer))
{
$dataCustomer[] = array('customerID' => $dtCustomer['customerID'],
'customerCode' => $dtCustomer['customerCode'],
'customerName' => $dtCustomer['customerName'],
'contactPerson' => $dtCustomer['contactPerson'],
'city' => $dtCustomer['city'],
'phone1' => $dtCustomer['phone1'],
31
'limitBalance' => rupiah($dtCustomer['limitBalance']),
'disc1' => $dtCustomer['disc1'],
'disc2' => $dtCustomer['disc2'],
'disc3' => $dtCustomer['disc3'],
'note' => $dtCustomer['note'],
'npwp' => $dtCustomer['npwp'],
'pkpName' => $dtCustomer['pkpName'],
'no' => $i);
$i++;
}
$smarty->assign("dataCustomer", $dataCustomer);
// count data
$queryCountCustomer = "SELECT * FROM as_customers";
$sqlCountCustomer = mysqli_query($connect, $queryCountCustomer);
$amountData = mysqli_num_rows($sqlCountCustomer);
$smarty->assign("pageLink", $pageLink);
$smarty->assign("page", $_GET['page']);
}
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Manajemen Customer");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk melakukan
pengolahan data master customer.");
$smarty->assign("breadcumbMenuName", "Master Data");
$smarty->assign("breadcumbMenuSubName", "Customer");
}
// include footer
include "footer.php";
?>
Selanjutnya buat file dengan nama customers.tpl dan simpan dalam folder
templates, adapun skripnya sebagai berikut :
{include file="header.tpl"}
{literal}
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
32
},
'afterClose':function () {
window.location.reload();
}
});
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#send").on("click", function(){
var customerCode = $("#customerCode").val();
var customerName = $("#customerName").val();
var contactPerson = $("#contactPerson").val();
var address = $("#address").val();
var address2 = $("#address2").val();
var village = $("#village").val();
var district = $("#district").val();
var city = $("#city").val();
var zipCode = $("#zipCode").val();
var province = $("#province").val();
var phone1 = $("#phone1").val();
var phone2 = $("#phone2").val();
var phone3 = $("#phone3").val();
var fax1 = $("#fax1").val();
var fax2 = $("#fax2").val();
var fax3 = $("#fax3").val();
var phonecp1 = $("#phonecp1").val();
var phonecp2 = $("#phonecp2").val();
var email = $("#email").val();
var limitBalance = $("#limitBalance").val();
var discount1 = $("#discount1").val();
var discount2 = $("#discount2").val();
var discount3 = $("#discount3").val();
var note = $("#note").val();
var npwp = $("#npwp").val();
var pkpName = $("#pkpName").val();
var staffCode = $("#staffCode").val();
$.ajax({
type: 'POST',
url: 'save_customer.php',
dataType: 'JSON',
data:{
customerCode: customerCode,
customerName: customerName,
contactPerson: contactPerson,
address: address,
address2: address2,
village: village,
district: district,
city: city,
zipCode: zipCode,
33
province: province,
phone1: phone1,
phone2: phone2,
phone3: phone3,
fax1: fax1,
fax2: fax2,
fax3: fax3,
phonecp1: phonecp1,
phonecp2: phonecp2,
email: email,
limitBalance: limitBalance,
discount1: discount1,
discount2: discount2,
discount3: discount3,
note: note,
npwp: npwp,
pkpName: pkpName,
staffCode: staffCode
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "customers.php?msg=Data berhasil disimpan";
}
});
}
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
{include file="user_panel.tpl"}
{include file="side_menu.tpl"}
</section>
</aside>
<aside class="right-side">
{include file="breadcumb.tpl"}
34
<!-- Main row -->
<div class="row">
<!-- Left col -->
<section class="col-lg-12 connectedSortable">
35
<td>{$dataCustomer[dataCustomer].contactPerson}</td>
<td>{$dataCustomer[dataCustomer].city}</td>
<td>{$dataCustomer[dataCustomer].phone1}</td>
<td>{$dataCustomer[dataCustomer].limitBalance}</td>
<td>
<a title="Edit" href="edit_customers.php?module=customer
&act=edit&customerID={$dataCustomer[dataCustomer].customerID}"
data-width="900" data-height="180" class="various2
fancybox.iframe"><img src="img/icons/edit.png" width="18"></a>
<a title="Delete" href="customers.php?module=customer
&act=delete&customerID={$dataCustomer[dataCustomer].customerID}&pa
ge={$page}" onclick="return confirm('Anda Yakin ingin menghapus
customer {$dataCustomer[dataCustomer].customerName}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
</div><!-- /.box-body -->
{else}
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>KODE <i class="fa fa-sort"></i></th>
<th>NAMA CUSTOMER <i class="fa fa-sort"></i></th>
<th>KONTAK PERSON <i class="fa fa-sort"></i></th>
<th>KOTA <i class="fa fa-sort"></i></th>
<th>TLP <i class="fa fa-sort"></i></th>
<th>LIMIT <i class="fa fa-sort"></i></th>
<th width="60">AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataCustomer loop=$dataCustomer}
<tr>
<td>{$dataCustomer[dataCustomer].no}</td>
<td>{$dataCustomer[dataCustomer].customerCode}</td>
<td>{$dataCustomer[dataCustomer].customerName}</td>
<td>{$dataCustomer[dataCustomer].contactPerson}</td>
<td>{$dataCustomer[dataCustomer].city}</td>
<td>{$dataCustomer[dataCustomer].phone1}</td>
<td>{$dataCustomer[dataCustomer].limitBalance}</td>
<td>
<a title="Edit" href="edit_customers.php?module=customer&
act=edit&customerID={$dataCustomer[dataCustomer].customerID}"
data-width="900" data-height="180" class="various2
fancybox.iframe"><img src="img/icons/edit.png" width="18"></a>
<a title="Delete" href="customers.php?module=customer&act=delete
&customerID={$dataCustomer[dataCustomer].customerID}&page={$page}"
onclick="return confirm('Anda Yakin ingin menghapus customer
36
{$dataCustomer[dataCustomer].customerName}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
<div id="inline">
<table width="95%" align="center">
<tr>
<td align="center"><h3><b>MASTER DATA CUSTOMER</b></h3></td>
</tr>
<tr>
<td>
<form id="customer" name="customer" method="POST" action="#">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="150">Kode Customer</td>
<td width="5">:</td>
<td><input type="text" id="customerCode"
name="customerCode" class="form-control" placeholder="Kode
Customer" style="width: 270px;" required></td>
<td colspan="4"></td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#999999"
style="border-left: 1px solid #000000; border-top: 1px solid
#000000; border-right: 1px solid #000000;"><span style="font-size:
16px;"><b>IDENTITAS CUSTOMER</b></span></td>
<td></td>
<td colspan="3" align="center" bgcolor="#999999"
style="border-left: 1px solid #000000; border-top: 1px solid
#000000; border-right: 1px solid #000000;"><span style="font-size:
16px;"><b>ORANG YANG DIHUBUNGI</b></span></td>
</tr>
<tr>
<td width="150" style="border-left: 1px solid
#000000; background-color: #FFFFFF;">Nama Customer</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="customerName"
name="customerName" class="form-control" placeholder="Nama
Customer" style="width: 270px;" required></td>
<td width="50"></td>
37
<td width="140" style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Nama Lengkap</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="contactPerson"
name="contactPerson" class="form-control" placeholder="Kontak
Person" style="width: 270px;"></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000; background-
color: #FFFFFF;">Alamat 1</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="address" name="address"
class="form-control" placeholder="Alamat" style="width:
270px;"></td><td></td>
<td style="border-left: 1px solid #000000; background-
color: #FFFFFF;">No. HP 1</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="phonecp1" name="phonecp1"
class="form-control" placeholder="No. Handphone 1" style="width:
270px;"></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Alamat 2</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="address2" name="address2"
class="form-control" placeholder="Alamat" style="width:
270px;"></td><td></td>
<td style="border-left: 1px solid #000000; background-
color: #FFFFFF;">No. HP 2</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="phonecp2" name="phonecp2"
class="form-control" placeholder="No. Handphone 2" style="width:
270px;"></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000; background-
color: #FFFFFF;">Kelurahan</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="village" name="village"
class="form-control" placeholder="Kelurahan" style="width:
270px;"></td><td></td>
<td style="border-bottom: 1px solid #000000; border-left: 1px
solid #000000; background-color: #FFFFFF;">Email</td>
<td style="border-bottom: 1px solid #000000; background-color:
#FFFFFF;">:</td>
<td style="border-bottom: 1px solid #000000; border-right:
1px solid #000000; background-color: #FFFFFF;"><input type="email"
id="email" name="email" class="form-control" placeholder="Email"
style="width: 270px;"></td>
</tr>
38
<tr>
<td style="border-left: 1px solid #000000; background-
color: #FFFFFF;">Kecamatan</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="district" name="district"
class="form-control" placeholder="Kecamatan" style="width:
270px;"></td>
<td colspan="4"></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000; background-
color: #FFFFFF;">Kota/Kode Pos</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="city" name="city"
class="form-control" placeholder="Kota" style="width: 160px;
float: left; margin-right: 5px;"> <input type="number"
id="zipCode" name="zipCode" class="form-control" placeholder="Kode
Pos" style="width: 105px;"></td><td></td>
<td align="center" style="border-left: 1px solid #000000;
border-right: 1px solid #000000; border-top: 1px solid #000000;
background-color: #999999;" colspan="3"><span style="font-size:
16px;"><b>IDENTITAS PAJAK</b></span></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Propinsi</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="province" name="province"
class="form-control" placeholder="Propinsi" style="width:
270px;"></td><td></td>
<td style="border-left: 1px solid #000000; background-
color: #FFFFFF;">Nomor NPWP</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="npwp" name="npwp"
class="form-control" placeholder="Nomor NPWP" style="width:
270px;"></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Telepon</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="phone1" name="phone1"
class="form-control" placeholder="Telepon 1" style="width: 85px;
float: left; margin-right: 5px;">
<input type="text" id="phone2" name="phone2" class="form-control"
placeholder="Telepon 2" style="width: 87px; float: left; margin-
right: 5px;">
<input type="text" id="phone3" name="phone3" class="form-control"
placeholder="Telepon 3" style="width: 87px;">
</td><td></td>
<td style="border-left: 1px solid #000000; background-
color: #FFFFFF;">Nama PKP</td>
39
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="pkpName" name="pkpName"
class="form-control" placeholder="Nama PKP" style="width:
270px;"></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000; background-
color: #FFFFFF;">Faksimile</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="fax1" name="fax1"
class="form-control" placeholder="Fax 1" style="width: 85px;
float: left; margin-right: 5px;">
<input type="text" id="fax2" name="fax2" class="form-
control" placeholder="Fax 2" style="width: 87px; float: left;
margin-right: 5px;">
<input type="text" id="fax3" name="fax3" class="form-
control" placeholder="Fax 3" style="width: 87px;">
</td><td></td>
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Note</td>
<td style="background-color: #FFFFFF;">:</td>
<td rowspan="2" style="border-bottom: 1px solid #000000;
border-right: 1px solid #000000; background-color:
#FFFFFF;"><textarea id="note" name="note" class="form-control"
placeholder="Keterangan" style="width: 270px; height:
72px;"></textarea></td>
</tr>
<tr valign="top">
<td style="border-left: 1px solid #000000;
background-color: #FFFFFF;">Diskon</td>
<td style="background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="number" id="discount1"
name="discount1" class="form-control" placeholder="Disc 1"
style="width: 85px; float: left; margin-right: 5px;">
<input type="number" id="discount2" name="discount2"
class="form-control" placeholder="Disc 2" style="width: 87px;
float: left; margin-right: 5px;">
<input type="number" id="discount3" name="discount3"
class="form-control" placeholder="Disc 3" style="width: 87px;">
</td>
<td></td>
<td colspan="2" style="background-color: #FFFFFF; border-
left: 1px solid #000000; border-bottom: 1px solid #000000;"></td>
</tr>
<tr>
<td style="border-bottom: 1px solid #000000; border-left: 1px
solid #000000; background-color: #FFFFFF;">Limit/Kode Sales</td>
<td style="border-bottom: 1px solid #000000; background-color:
#FFFFFF;">:</td>
<td style="border-bottom: 1px solid #000000; border-right: 1px
solid #000000; background-color: #FFFFFF;"><input type="number"
id="limitBalance" name="limitBalance" class="form-control"
placeholder="Limit" style="width: 165px; float: left; margin-
right: 5px;">
40
<input type="text" id="staffCode" name="staffCode" class="form-
control" placeholder="Kode Sales" style="width: 100px;">
</td>
<td colspan="4"></td>
</tr>
</table><br>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
</div>
{/if}
</div><!-- /.box -->
</section><!-- /.Left col -->
</div><!-- /.row (main row) -->
</section><!-- /.content -->
</aside><!-- /.right-side -->
</div><!-- ./wrapper -->
{include file="footer.tpl"}
Karena proses simpan ini berjalan secara ajax, maka kita buat file pemroses
simpannya, beri nama file tersebut save_customer.php, adapun skripnya
sebagai berikut :
<?php
// include header
include "header.php";
41
$_POST['phonecp1']);
$phonecp2 = mysqli_real_escape_string($connect,
$_POST['phonecp2']);
$limitBalance = mysqli_real_escape_string($connect,
$_POST['limitBalance']);
$email = mysqli_real_escape_string($connect, $_POST['email']);
$discount1 = mysqli_real_escape_string($connect,
$_POST['discount1']);
$discount2 = mysqli_real_escape_string($connect,
$_POST['discount2']);
$discount3 = mysqli_real_escape_string($connect,
$_POST['discount3']);
$note = mysqli_real_escape_string($connect, $_POST['note']);
$npwp = mysqli_real_escape_string($connect, $_POST['npwp']);
$pkpName = mysqli_real_escape_string($connect, $_POST['pkpName']);
$staffCode = mysqli_real_escape_string($connect,
$_POST['staffCode']);
42
'$city',
'$zipCode',
'$province',
'$phone1',
'$phone2',
'$phone3',
'$fax1',
'$fax2',
'$fax3',
'$phonecp1',
'$phonecp2',
'$email',
'$limitBalance',
'$discount1',
'$discount2',
'$discount3',
'$note',
'$npwp',
'$pkpName',
'$staffCode',
'$createdDate',
'$staffID',
'',
'')";
Jika skrip diatas adalah perintah untuk menampilkan dan menambah data
customer, maka berikut adalah perintah mengubah data customer, buat 2 buah
file, masing-masing dengan nama edit_customers.php dan edit_customer.tpl
yang masing-masing skripnya sebagai berikut :
edit_customers.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "edit_customers.tpl";
43
else
{
// get variable
$module = $_GET['module'];
$act = $_GET['act'];
// fetch data
$dataCustomer = mysqli_fetch_array($sqlCustomer);
} // close bracket
44
// include footer
include "footer.php";
?>
edit_customer.tpl
45
$.ajax({
type: 'POST',
url: 'save_edit_customer.php',
dataType: 'JSON',
data:{
customerID: customerID,
customerCode: customerCode,
customerName: customerName,
contactPerson: contactPerson,
address: address,
address2: address2,
village: village,
district: district,
city: city,
zipCode: zipCode,
province: province,
phone1: phone1,
phone2: phone2,
phone3: phone3,
fax1: fax1,
fax2: fax2,
fax3: fax3,
phonecp1: phonecp1,
phonecp2: phonecp2,
email: email,
limitBalance: limitBalance,
discount1: discount1,
discount2: discount2,
discount3: discount3,
note: note,
npwp: npwp,
pkpName: pkpName,
staffCode: staffCode
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
parent.jQuery.fancybox.close();
}
});
}
});
});
</script>
{/literal}
46
<table cellpadding="3" cellspacing="3">
<tr>
<td width="150" style="font-size: 14px;">Kode Customer</td>
<td width="5" style="font-size: 14px;">:</td>
<td><input type="text" value="{$customerCode}"
id="customerCode" name="customerCode" class="form-control"
placeholder="Kode Customer" style="width: 270px;" required></td>
<td colspan="4"></td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#999999"
style="border-left: 1px solid #000000; border-top: 1px solid
#000000; border-right: 1px solid #000000;"><span style="font-size:
16px;"><b>IDENTITAS CUSTOMER</b></span></td>
<td></td>
<td colspan="3" align="center" bgcolor="#999999"
style="border-left: 1px solid #000000; border-top: 1px solid
#000000; border-right: 1px solid #000000;"><span style="font-size:
16px;"><b>ORANG YANG DIHUBUNGI</b></span></td>
</tr>
<tr>
<td width="150" style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Nama Customer</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="font-size: 14px; border-right: 1px solid #000000;
background-color: #FFFFFF;"><input type="text"
value="{$customerName}" id="customerName" name="customerName"
class="form-control" placeholder="Nama Customer" style="width:
270px;" required></td>
<td width="50"></td>
<td width="140" style="font-size: 14px; border-left: 1px
solid #000000; background-color: #FFFFFF;">Nama Lengkap</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="contactPerson"
value="{$contactPerson}" name="contactPerson" class="form-control"
placeholder="Kontak Person" style="width: 270px;"></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Alamat 1</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="address" name="address"
value="{$address}" class="form-control" placeholder="Alamat"
style="width: 270px;"></td>
<td></td>
<td style="font-size: 14px; border-left: 1px solid #000000;
background-color: #FFFFFF;">No. HP 1</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="phonecp1" name="phonecp1"
value="{$phonecp1}" class="form-control" placeholder="No.
Handphone 1" style="width: 270px;"></td>
</tr>
<tr>
47
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Alamat 2</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="address2" name="address2"
value="{$address2}" class="form-control" placeholder="Alamat"
style="width: 270px;"></td>
<td></td>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">No. HP 2</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="phonecp2" name="phonecp2"
value="{$phonecp2}" class="form-control" placeholder="No.
Handphone 2" style="width: 270px;"></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Kelurahan</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="village" name="village"
value="{$village}" class="form-control" placeholder="Kelurahan"
style="width: 270px;"></td>
<td></td>
<td style="font-size: 14px; border-bottom: 1px solid #000000;
border-left: 1px solid #000000; background-color:
#FFFFFF;">Email</td>
<td style="font-size: 14px; border-bottom: 1px solid #000000;
background-color: #FFFFFF;">:</td>
<td style="border-bottom: 1px solid #000000; border-right: 1px
solid #000000; background-color: #FFFFFF;"><input type="email"
id="email" value="{$email}" name="email" class="form-control"
placeholder="Email" style="width: 270px;"></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid #000000;
background-color: #FFFFFF;">Kecamatan</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="district" name="district"
value="{$district}" class="form-control" placeholder="Kecamatan"
style="width: 270px;"></td>
<td colspan="4"></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Kota/Kode Pos</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="city" name="city" value="{$city}"
class="form-control" placeholder="Kota" style="width: 170px;
float: left;"> <input type="number" id="zipCode"
value="{$zipCode}" name="zipCode" class="form-control"
placeholder="Kode Pos" style="width: 100px;"></td>
<td></td>
48
<td align="center" style="border-left: 1px solid #000000;
border-right: 1px solid #000000; border-top: 1px solid #000000;
background-color: #999999;" colspan="3"><span style="font-size:
16px;"><b>IDENTITAS PAJAK</b></span></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Propinsi</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="province" name="province"
value="{$province}" class="form-control" placeholder="Propinsi"
style="width: 270px;"></td>
<td></td>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Nomor NPWP</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-
color: #FFFFFF;"><input type="text" id="npwp" name="npwp"
value="{$npwp}" class="form-control" placeholder="Nomor NPWP"
style="width: 270px;"></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Telepon</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="phone1" name="phone1"
value="{$phone1}" class="form-control" placeholder="Telepon 1"
style="width: 90px; float: left;">
<input type="text" value="{$phone2}" id="phone2" name="phone2"
class="form-control" placeholder="Telepon 2" style="width: 90px;
float: left;">
<input type="text" value="{$phone3}" id="phone3" name="phone3"
class="form-control" placeholder="Telepon 3" style="width: 90px;">
</td>
<td></td>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Nama PKP</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="pkpName" name="pkpName"
value="{$pkpName}" class="form-control" placeholder="Nama PKP"
style="width: 270px;"></td>
</tr>
<tr>
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Faksimile</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="text" id="fax1" name="fax1" value="{$fax1}"
class="form-control" placeholder="Fax 1" style="width: 90px;
float: left;">
<input type="text" id="fax2" value="{$fax2}" name="fax2"
class="form-control" placeholder="Fax 2" style="width: 90px;
float: left;">
49
<input type="text" id="fax3" name="fax3" value="{$fax3}"
class="form-control" placeholder="Fax 3" style="width: 90px;">
</td>
<td></td>
<td style="border-left: 1px solid #000000; background-
color: #FFFFFF;">Note</td>
<td style="background-color: #FFFFFF;">:</td>
<td rowspan="2" style="border-bottom: 1px solid #000000;
border-right: 1px solid #000000; background-color:
#FFFFFF;"><textarea id="note" value="{$note}" name="note"
class="form-control" placeholder="Keterangan" style="width: 270px;
height: 72px;">{$note}</textarea></td>
</tr>
<tr valign="top">
<td style="font-size: 14px; border-left: 1px solid
#000000; background-color: #FFFFFF;">Diskon</td>
<td style="font-size: 14px; background-color: #FFFFFF;">:</td>
<td style="border-right: 1px solid #000000; background-color:
#FFFFFF;"><input type="number" id="discount1" name="discount1"
value="{$disc1}" class="form-control" placeholder="Diskon 1"
style="width: 90px; float: left;">
<input type="number" id="discount2" value="{$disc2}"
name="discount2" class="form-control" placeholder="Diskon 2"
style="width: 90px; float: left;">
<input type="number" id="discount3" value="{$disc3}"
name="discount3" class="form-control" placeholder="Diskon 3"
style="width: 90px;">
</td>
<td></td>
<td colspan="2" style="background-color: #FFFFFF; border-left: 1px
solid #000000; border-bottom: 1px solid #000000;"></td>
</tr>
<tr>
<td style="font-size: 14px; border-bottom: 1px solid #000000;
border-left: 1px solid #000000; background-color:
#FFFFFF;">Limit/Kode Sales</td>
<td style="font-size: 14px; border-bottom: 1px solid #000000;
background-color: #FFFFFF;">:</td>
<td style="border-bottom: 1px solid #000000; border-right: 1px
solid #000000; background-color: #FFFFFF;"><input type="number"
value="{$limitBalance}" id="limitBalance" name="limitBalance"
class="form-control" placeholder="Limit" style="width: 170px;
float: left;">
<input type="text" id="staffCode" value="{$staffCode}"
name="staffCode" class="form-control" placeholder="Kode Sales"
style="width: 100px;">
</td>
<td colspan="4"></td>
</tr>
</table><br>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
{/if}
50
</body>
Sama halnya dengan proses tambah data, proses ubah data customer ini juga
berjalan secara ajax, oleh sebab itu buat file dengan nama
save_edit_customer.php yang skripnya sebagai berikut :
<?php
// include header
include "header.php";
51
''){
if ($sqlCustomer)
{
echo json_encode(OK);
}
}
exit();
?>
Hasil seluruh skrip diatas akan menghasilkan sebuah halaman master data
customer, yang bisa dilihat pada gambar-gambar berikut :
52
Gambar 5.4. Menampilkan data customer
53
Gambar 5.6. Mengubah data staff
5.1.3 Kategori
Master data kategori digunakan untuk menyimpan dan mengolah data-data
kategori terkait produk dalam perusahaan kita. Disini kita akan mengulas tuntas
pembuatan master data kategori.
Buat file dengan nama categories.php yang skripnya sebagai berikut :
<?php
// include header
include "header.php";
// set the tpl page
$page = "categories.tpl";
$module = $_GET['module'];
$act = $_GET['act'];
54
}
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE modulID =
'4'";
$sqlAuthorizeStaff = mysqli_query($connect,
$queryAuthorizeStaff);
$dataAuthorizeStaff =
mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
// delete categories
$queryCategory = "DELETE FROM as_categories WHERE categoryID =
'$categoryID'";
$sqlCategory = mysqli_query($connect, $queryCategory);
// fetch data
$i = 1;
while ($dtCategory = mysqli_fetch_array($sqlCategory))
{
$dataCategory[] = array('categoryID' => $dtCategory['categoryID'],
'categoryName' => $dtCategory['categoryName'],
'status' => $dtCategory['status'],
'no' => $i);
$i++;
}
// assign
$smarty->assign("dataCategory", $dataCategory);
$smarty->assign("q", $q);
}
55
else
{
// create new object pagination
$p = new PaginationCategory;
// limit 20 data for page
$limit = 20;
$position = $p->searchPosition($limit);
// fetch data
$i = 1 + $position;
while ($dtCategory = mysqli_fetch_array($sqlCategory))
{
$dataCategory[] = array('categoryID' => $dtCategory['categoryID'],
'categoryName' => $dtCategory['categoryName'],
'status' => $dtCategory['status'],
'no' => $i);
$i++;
}
$smarty->assign("dataCategory", $dataCategory);
// count data
$queryCountCategory = "SELECT * FROM as_categories";
$sqlCountCategory = mysqli_query($connect,
$queryCountCategory);
$amountData = mysqli_num_rows($sqlCountCategory);
$smarty->assign("pageLink", $pageLink);
}
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Manajemen Kategori");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan pengolahan data master kategori produk.");
$smarty->assign("breadcumbMenuName", "Master Data");
$smarty->assign("breadcumbMenuSubName", "Kategori");
}
// include footer
include "footer.php";
?>
Selanjutnya buat file dengan nama categories.tpl dan simpan dalam folder
templates, adapun skripnya sebagai berikut :
{include file="header.tpl"}
56
<link rel="stylesheet" type="text/css" media="all"
href="design/js/fancybox/jquery.fancybox.css">
<script type="text/javascript" src="design/js/fancybox/jquery
.fancybox.js?v=2.0.6"></script>
{literal}
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#send").on("click", function(){
var categoryName = $("#categoryName").val();
var categoryStatus = $("#categoryStatus").val();
if (categoryName != '' && categoryStatus != ''){
$.ajax({
type: 'POST',
url: 'save_category.php',
dataType: 'JSON',
data:{
categoryName: categoryName,
categoryStatus: categoryStatus
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "categories.php";
}
});
}
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
57
{include file="navigation.tpl"}
</header>
{include file="user_panel.tpl"}
{include file="side_menu.tpl"}
</section>
<!-- /.sidebar -->
</aside>
<aside class="right-side">
{include file="breadcumb.tpl"}
58
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NAMA KATEGORI <i class="fa fa-sort"></i></th>
<th>STATUS <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataCategory loop=$dataCategory}
<tr>
<td>{$dataCategory[dataCategory].no}</td>
<td>{$dataCategory[dataCategory].categoryName}</td>
<td>{$dataCategory[dataCategory].status}</td>
<td>
<a title="Edit" href="edit_categories.php?module=category&act=
edit&categoryID={$dataCategory[dataCategory].categoryID}" data-
width="450" data-height="180" class="various2 fancybox.iframe">
<img src="img/icons/edit.png" width="18"></a>
<a title="Delete" href="categories.php?module=category&act=delete&
categoryID={$dataCategory[dataCategory].categoryID}"
onclick="return confirm('Anda Yakin ingin menghapus kategori
{$dataCategory[dataCategory].categoryName}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
</div><!-- /.box-body -->
{else}
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NAMA KATEGORI <i class="fa fa-sort"></i></th>
<th>STATUS <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataCategory loop=$dataCategory}
<tr>
<td>{$dataCategory[dataCategory].no}</td>
<td>{$dataCategory[dataCategory].categoryName}</td>
<td>{$dataCategory[dataCategory].status}</td>
<td>
<a title="Edit"
href="edit_categories.php?module=category&act=edit&
59
categoryID={$dataCategory[dataCategory].categoryID}" data-
width="450" data-height="180" class="various2 fancybox.iframe">
<img src="img/icons/edit.png" width="18"></a>
<a title="Delete" href="categories.php?module=category&act=delete&
categoryID={$dataCategory[dataCategory].categoryID}"
onclick="return confirm('Anda Yakin ingin menghapus kategori
{$dataCategory[dataCategory].categoryName}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
</div><!-- /.box-body -->
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-left">
<ul class="pagination pagination-sm inline">
{$pageLink}
</ul>
</div>
</div><!-- /.box-header -->
<div id="inline">
<table width="95%" align="center">
<tr>
<td colspan="3"><h3>Tambah Kategori</h3></td>
</tr>
<tr>
<td>
<form id="category" name="category" method="POST" action="#">
<table cellpadding="7" cellspacing="7">
<tr>
<td width="140">Nama Kategori</td>
<td width="5">:</td>
<td><input type="text" id="categoryName"
name="categoryName" class="form-control" placeholder="Nama
kategori" style="width: 270px;" required></td>
</tr>
<tr>
<td>Status</td>
<td>:</td>
<td><select name="categoryStatus" id="categoryStatus"
class="form-control" required>
<option value="">- Pilih Status -</option>
<option value="Y">Y (Aktif)</option>
<option value="N">N (Tidak Aktif)</option>
</select></td>
</tr>
</table>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
</div>
60
{/if}
</div><!-- /.box -->
{include file="footer.tpl"}
Karena skrip tambah data diatas berjalan secara ajax, maka akan buat file untuk
proses simpannya, beri nama file tersebut save_category.php adapun skripnya
sebagai berikut :
<?php
// include header
include "header.php";
if ($sqlCategory)
{
echo json_encode(OK);
}
}
exit();
?>
Skrip diatas adalah skrip untuk menampilkan data kategori dan menambah data
kategori, selanjutnya kita akan buat 3 buah file yang akan digunakan untuk
61
mengubah data kategori, diantaranya edit_categories.php, edit_categories.tpl
dan save_edit_category.php, adapun masing-masing skripnya sebagai berikut :
edit_categories.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "edit_categories.tpl";
else
{
// get variable
$module = $_GET['module'];
$act = $_GET['act'];
// fetch data
$dataCategory = mysqli_fetch_array($sqlCategory);
} // close bracket
// include footer
include "footer.php";
?>
62
edit_categories.tpl
<script src="design/js/jquery-1.8.1.min.js" type="text/
javascript"></script>
<link href="design/css/bootstrap.min.css" rel="stylesheet"
type="text/css" />
<link href="design/css/AdminLTE.css" rel="stylesheet"
type="text/css" />
<script src="design/js/bootstrap.min.js" type="text/javascript">
</script>
$.ajax({
type: 'POST',
url: 'save_edit_category.php',
dataType: 'JSON',
data:{
categoryID: categoryID,
categoryName: categoryName,
categoryStatus: categoryStatus
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
parent.jQuery.fancybox.close();
}
});
}
});
});
</script>
{/literal}
63
<td>
<form id="category" name="category" method="POST" action="#">
<input type="hidden" id="categoryID" name="categoryID"
value="{$categoryID}">
<table cellpadding="7" cellspacing="7">
<tr>
<td width="140">Nama Kategori</td>
<td width="5">:</td>
<td><input type="text" id="categoryName"
name="categoryName" value="{$categoryName}" class="form-control"
placeholder="Nama kategori" style="width: 270px;" required></td>
</tr>
<tr>
<td>Status</td>
<td>:</td>
<td><select name="categoryStatus" id="categoryStatus" class="form-
control" placeholder="Nama kategori" required>
<option value="">- Pilih Status -</option>
<option value="Y" {if $categoryStatus == 'Y'} SELECTED {/if}>Y
(Aktif)</option>
<option value="N" {if $categoryStatus == 'N'}
SELECTED {/if}>N (Tidak Aktif)</option>
</select></td>
</tr>
</table>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
{/if}
</body>
save_edit_category.php
<?php
// include header
include "header.php";
64
$sqlCategory = mysqli_query($connect, $queryCategory);
if ($sqlCategory)
{
echo json_encode(OK);
}
}
exit();
?>
Hasil seluruh skrip diatas akan menampilkan master data kategori yang bisa
dilihat pada gambar-gambar berikut :
65
Gambar 5.9. Mengubah data kategori
5.1.4 Produk
Master data produk digunakan untuk menyimpan dan mengolah seluruh data
produk yang dimiliki perusahaan. Disini kita akan buat seluruh proses sekaligus
termasuk didalamnya ada proses upload gambar produk, semuanya akan
dilakukan secara ajax.. so ikuti saja.. buat beberapa file dengan masing-masing
nama file dan skrip sebagai berikut :
products.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "products.tpl";
$module = $_GET['module'];
$act = $_GET['act'];
else
{
66
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE
modulID = '5'";
$sqlAuthorizeStaff = mysqli_query($connect, $queryAuthorizeStaff);
$dataAuthorizeStaff = mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
// delete product
$queryProduct = "DELETE FROM as_products WHERE productID =
'$productID'";
$sqlProduct = mysqli_query($connect, $queryProduct);
if ($sqlProduct)
{
if ($pic != '')
{
unlink("img/products/".$pic);
unlink("img/products/thumb/small_".$pic);
}
}
// fetch data
$i = 1;
while ($dtProduct = mysqli_fetch_array($sqlProduct))
{
if ($dtProduct['unit'] == '1')
{
$unit = "SET";
}
else
{
$unit = "PCS";
}
67
// count stock total based on productID
$queryStock = "SELECT SUM(stock) as stockAmount FROM
as_stock_products WHERE productID = '$dtProduct[productID]'";
$sqlStock = mysqli_query($connect, $queryStock);
$dataStock = mysqli_fetch_array($sqlStock);
// assign
$smarty->assign("dataProduct", $dataProduct);
$smarty->assign("q", $q);
}
if ($sqlProduct)
{
unlink("img/products/".$picture);
unlink("img/products/thumb/small_".$picture);
}
else
{
// get last sort product number
$queryNoProduct = "SELECT productCode FROM as_products
ORDER BY productCode DESC LIMIT 1";
$sqlNoProduct = mysqli_query($connect, $queryNoProduct);
$numsNoProduct = mysqli_num_rows($sqlNoProduct);
$dataNoProduct = mysqli_fetch_array($sqlNoProduct);
68
$start = substr($dataNoProduct['productCode'],0-5);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoProduct == '0')
{
$productNo = "0000";
}
elseif ($tempNo == 1)
{
$productNo = "0000";
}
elseif ($tempNo == 2)
{
$productNo = "000";
}
elseif ($tempNo == 3)
{
$productNo = "00";
}
elseif ($tempNo == 4)
{
$productNo = "0";
}
elseif ($tempNo == 5)
{
$productNo = "";
}
$productCode = $productNo.$next;
$smarty->assign("productCode", $productCode);
// fetch data
$i = 1 + $position;
while ($dtProduct = mysqli_fetch_array($sqlProduct))
{
if ($dtProduct['unit'] == '1')
{
$unit = "SET";
}
else
{
$unit = "PCS";
}
// count stock total based on productID
69
$queryStock = "SELECT SUM(stock) as stockAmount
FROM as_stock_products WHERE productID = '$dtProduct[productID]'";
$sqlStock = mysqli_query($connect, $queryStock);
$dataStock = mysqli_fetch_array($sqlStock);
$smarty->assign("dataProduct", $dataProduct);
// count data
$queryCountProduct = "SELECT * FROM as_products";
$sqlCountProduct = mysqli_query($connect, $queryCountProduct);
$amountData = mysqli_num_rows($sqlCountProduct);
$smarty->assign("pageLink", $pageLink);
// fetch data
while ($dtCategory = mysqli_fetch_array($sqlCategory))
{
$dataCategory[] = array('categoryID' => $dtCategory['categoryID'],
'categoryName' => $dtCategory['categoryName']);
}
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Manajemen Produk");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan pengolahan data master produk.");
$smarty->assign("breadcumbMenuName", "Master Data");
$smarty->assign("breadcumbMenuSubName", "Produk");
70
}
// include footer
include "footer.php";
?>
{literal}
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$(".various3").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
// Image
var btnUpload=$('#me');
var mestatus=$('#mestatus');
var files=$('#files');
new AjaxUpload(btnUpload, {
action: 'upload_product.php',
name: 'uploadfile',
onSubmit: function(file, ext){
if (! (ext && /^(jpg|jpeg)$/.test(ext))){
// extension is not allowed
71
mestatus.text('Hanya ekstensi .JPG/JPEG yang diijinkan.');
return false;
}
mestatus.html('');
},
onComplete: function(file, response){
//On completion clear the status
mestatus.text('');
//On completion clear the status
files.html('');
//Add uploaded file to list
if(response!=="error"){
$('<li></li>').appendTo('#files').html('<img
src="img/products/'+response+'" alt="" height="70"/><br
/>').addClass('success');
$('<li></li>').appendTo('#photoproduct').html('<input
type="hidden" id="image" name="image"
value="'+response+'">').addClass('nameupload');
} else{
$('<li></li>').appendTo('#files').text(file).addClass('error');
}
}
});
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#send").on("click", function(){
var productCode = $("#productCode").val();
var productName = $("#productName").val();
var categoryID = $("#categoryID").val();
var unit = $("#unit").val();
var unitPrice1 = $("#unitPrice1").val();
var unitPrice2 = $("#unitPrice2").val();
var unitPrice3 = $("#unitPrice3").val();
var hpp = $("#hpp").val();
var purchasePrice = $("#purchasePrice").val();
var note = $("#note").val();
var image = $("#image").val();
var minimumStock = $("#minimumStock").val();
$.ajax({
type: 'POST',
url: 'save_product.php',
dataType: 'JSON',
data:{
productCode: productCode,
productName: productName,
72
categoryID: categoryID,
unit: unit,
unitPrice1: unitPrice1,
unitPrice2: unitPrice2,
unitPrice3: unitPrice3,
hpp: hpp,
purchasePrice: purchasePrice,
note: note,
image: image,
minimumStock: minimumStock
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "products.php";
}
});
}
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
<aside class="right-side">
{include file="breadcumb.tpl"}
73
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Data Produk</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
</div>
</div>
</div><!-- /.box-header -->
74
width="900" data-height="420" class="various3 fancybox.iframe">
<img src="img/icons/gudang.png" width="18"></a>
<a title="Edit" href="edit_products.php?module=product&act=edit
&productID={$dataProduct[dataProduct].productID}" data-width="900"
data-height="420" class="various2 fancybox.iframe"><img
src="img/icons/edit.png" width="18"></a>
<a title="Delete" href="products.php?module=product&act=delete&
productID={$dataProduct[dataProduct].productID}&pic={$dataProduct[
dataProduct].image}" onclick="return confirm('Anda Yakin ingin
menghapus produk {$dataProduct[dataProduct].productName}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
</div><!-- /.box-body -->
{else}
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>KODE - NAMA PRODUK <i class="fa fa-sort"></i></th>
<th>SATUAN <i class="fa fa-sort"></i></th>
<th>HARGA 1 <i class="fa fa-sort"></i></th>
<th>HARGA 2 <i class="fa fa-sort"></i></th>
<th>HARGA 3 <i class="fa fa-sort"></i></th>
<th>HPP <i class="fa fa-sort"></i></th>
<th>STOCK <i class="fa fa-sort"></i></th>
<th width="80">AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataProduct loop=$dataProduct}
<tr>
<td>{$dataProduct[dataProduct].no}</td>
<td>{$dataProduct[dataProduct].productName}</td>
<td align="center">{$dataProduct[dataProduct].unit}</td>
<td align="right">{$dataProduct[dataProduct].unitPrice1}</td>
<td align="right">{$dataProduct[dataProduct].unitPrice2}</td>
<td align="right">{$dataProduct[dataProduct].unitPrice3}</td>
<td align="right">{$dataProduct[dataProduct].hpp}</td>
<td align="center">{$dataProduct[dataProduct].stockAmount}</td>
<td>
<a title="Stok Gudang" href="edit_stock.php?module=
product&act=stock&productID={$dataProduct[dataProduct].productID}"
data-width="900" data-height="420" class="various3 fancybox
.iframe"><img src="img/icons/gudang.png" width="18"></a>
<a title="Edit" href="edit_products.php?module=product
&act=edit&productID={$dataProduct[dataProduct].productID}" data-
width="900" data-height="420" class="various2 fancybox.iframe">
<img src="img/icons/edit.png" width="18"></a>
75
<a title="Delete" href="products.php?module=product&act=delete&
productID={$dataProduct[dataProduct].productID}&pic={$dataProduct[
dataProduct].image}" onclick="return confirm('Anda Yakin ingin
menghapus produk {$dataProduct[dataProduct].productName}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
</div><!-- /.box-body -->
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-left">
<ul class="pagination pagination-sm inline">
{$pageLink}
</ul>
</div>
</div><!-- /.box-header -->
<div id="inline">
<table width="95%" align="center">
<tr>
<td colspan="3"><h3>Tambah Produk</h3></td>
</tr>
<tr>
<td>
<form id="product" name="product" method="POST" action="#">
<table cellpadding="7" cellspacing="7">
<tr valign="top">
<td width="130">Kode Produk</td>
<td width="5">:</td>
<td>
<input type="hidden" value="{$productCode}"
id="productCode" name="productCode">
<input type="text" value="{$productCode}"
id="productCode" name="productCode" class="form-control"
placeholder="Kode Produk" style="width: 270px;" DISABLED>
</td>
<td width="120">Harga Beli</td>
<td width="5">:</td>
<td><input type="number" id="purchasePrice"
name="purchasePrice" class="form-control" placeholder="Harga Beli"
style="width: 270px;" required></td>
</tr>
<tr>
<td>Nama Produk</td>
<td>:</td>
<td><input type="text" id="productName"
name="productName" class="form-control" placeholder="Nama Produk"
style="width: 270px;" required></td>
<td>Minimum Stok</td>
<td>:</td>
76
<td><input type="number" id="minimumStock"
name="minimumStock" class="form-control" placeholder="Minimum
Stok" style="width: 270px;" required></td>
</tr>
<tr valign="top">
<td>Kategori</td>
<td>:</td>
<td>
<select id="categoryID" name="categoryID" class="form-
control" style="width: 270px;" required>
<option value=""></option>
{section name=dataCategory loop=$dataCategory}
<option value="{$dataCategory[dataCategory].categoryID}">{$data
Category[dataCategory].categoryName}</option>
{/section}
</select>
</td>
<td>Note</td>
<td>:</td>
<td><input type="text" id="note" name="note" class="form-
control" placeholder="Note" style="width: 270px;"></td>
</tr>
<tr valign="top">
<td>Satuan</td>
<td>:</td>
<td>
<select id="unit" name="unit" class="form-control"
style="width: 270px;" required>
<option value=""></option>
<option value="1">SET</option>
<option value="2">PCS</option>
</select>
</td>
<td>Gambar</td>
<td>:</td>
<td rowspan="8">
<div id="me" class="styleall" style="cursor:pointer;">
<label>
<button class="btn btn-warning">Browse</button>
</label>
</div>
<span id="mestatus"></span>
<div id="photoproduct">
<li class="nameupload"></li>
</div>
<div id="files">
<li class="success"></li>
</div>
</td>
</tr>
<tr>
<td>Harga Unit 1</td>
<td>:</td>
77
<td><input type="number" id="unitPrice1"
name="unitPrice1" class="form-control" placeholder="Harga Satuan
1" style="width: 270px;" required></td>
</tr>
<tr>
<td>Harga Unit 2</td>
<td>:</td>
<td><input type="number" id="unitPrice2"
name="unitPrice2" class="form-control" placeholder="Harga Satuan
2" style="width: 270px;" required></td>
</tr>
<tr>
<td>Harga Unit 3</td>
<td>:</td>
<td><input type="number" id="unitPrice3"
name="unitPrice3" class="form-control" placeholder="Harga Satuan
3" style="width: 270px;" required></td>
</tr>
<tr>
<td>HPP</td>
<td>:</td>
<td><input type="number" id="hpp" name="hpp" class="form-control"
placeholder="HPP" style="width: 270px;" required></td>
</tr>
</table>
{include file="footer.tpl"}
upload_product.php
<?php
$uploaddir = 'img/products/';
$file = $uploaddir ."asfa_".date('Ymdhis').basename($_FILES
['uploadfile']['name']);
$file_name= "cmp_".date('Ymdhis').$_FILES['uploadfile']['name'];
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file))
{
echo "$file_name";
}
else {
78
echo "error";
}
?>
save_product.php
<?php
// include header
include "header.php";
$thumbWidth = 100;
$thumbHeight = 70;
imagejpeg($thumbPic, "img/products/thumb/small_".$image);
imagedestroy($realPic);
imagedestroy($thumbPic);
} // close bracket
79
$queryProduct = "INSERT INTO as_products( productCode,
productName,
categoryID,
unit,
unitPrice1,
unitPrice2,
unitPrice3,
hpp,
purchasePrice,
note,
image,
minimumStock,
createdDate,
createdUserID,
modifiedDate,
modifiedUserID)
VALUES( '$productCode',
'$productName',
'$categoryID',
'$unit',
'$unitPrice1',
'$unitPrice2',
'$unitPrice3',
'$hpp',
'$purchasePrice',
'$note',
'$image',
'$minimumStock',
'$createdDate',
'$staffID',
'',
'')";
if ($sqlProduct)
{
echo json_encode(OK);
}
}
exit();
?>
edit_products.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "edit_products.tpl";
80
exit();
}
else
{
// get variable
$module = $_GET['module'];
$act = $_GET['act'];
// fetch data
$dataProduct = mysqli_fetch_array($sqlProduct);
// fetch data
while ($dtCategory = mysqli_fetch_array($sqlCategory))
{
$dataCategory[] = array('categoryID' => $dtCategory['categoryID'],
'categoryName' => $dtCategory['categoryName']);
}
81
$smarty->assign("act", $_GET['act']);
} // close bracket
// include footer
include "footer.php";
?>
// Image
var btnUpload=$('#me');
var mestatus=$('#mestatus');
var files=$('#files');
new AjaxUpload(btnUpload, {
action: 'upload_product.php',
name: 'uploadfile',
onSubmit: function(file, ext){
if (! (ext && /^(jpg|jpeg)$/.test(ext))){
// extension is not allowed
mestatus.text('Hanya ekstensi .JPG/JPEG yang diijinkan.');
return false;
}
//mestatus.html('<img src="images/ajax-loader.gif" height="16"
width="16">');
mestatus.html('');
},
onComplete: function(file, response){
//On completion clear the status
mestatus.text('');
82
//On completion clear the status
files.html('');
//Add uploaded file to list
if(response!=="error"){
$('<li></li>').appendTo('#files').html('<img
src="img/products/'+response+'" alt="" height="100"/><br
/>').addClass('success');
$('<li></li>').appendTo('#photoproduct').html('<input
type="hidden" id="image" name="image"
value="'+response+'">').addClass('nameupload');
} else{
$('<li></li>').appendTo('#files').text(file).addClass('error');
}
}
});
$("#deleteimage").on("click", function(){
parent.jQuery.fancybox.close();
});
$("#send").on("click", function(){
var productID = $("#productID").val();
var productName = $("#productName").val();
var categoryID = $("#categoryID").val();
var unit = $("#unit").val();
var unitPrice1 = $("#unitPrice1").val();
var unitPrice2 = $("#unitPrice2").val();
var unitPrice3 = $("#unitPrice3").val();
var hpp = $("#hpp").val();
var purchasePrice = $("#purchasePrice").val();
var note = $("#note").val();
var image = $("#image").val();
var picture = $("#picture").val();
var minimumStock = $("#minimumStock").val();
$.ajax({
type: 'POST',
url: 'save_edit_product.php',
dataType: 'JSON',
data:{
productID: productID,
productName: productName,
categoryID: categoryID,
unit: unit,
unitPrice1: unitPrice1,
unitPrice2: unitPrice2,
unitPrice3: unitPrice3,
hpp: hpp,
purchasePrice: purchasePrice,
note: note,
image: image,
83
picture: picture,
minimumStock: minimumStock
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
parent.jQuery.fancybox.close();
}
});
}
});
});
</script>
{/literal}
84
<td><input type="text" value="{$productName}" id="productName"
name="productName" class="form-control" placeholder="Nama Produk"
style="width: 270px;" required></td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">Minimum Stok</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">:</td>
<td><input type="number" value="{$minimumStock}" id="minimumStock"
name="minimumStock" class="form-control" placeholder="Minimum
Stok" style="width: 270px;" required></td>
</tr>
<tr valign="top">
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">Kategori</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">:</td>
<td>
<select id="categoryID" name="categoryID"
class="form-control" style="width: 270px;" required>
<option value=""></option>
{section name=dataCategory loop=$dataCategory}
{if $categoryID == $dataCategory[dataCategory].categoryID}
<option value="{$dataCategory[dataCategory].categoryID}"
SELECTED>{$dataCategory[dataCategory].categoryName}</option>
{else}
<option value="{$dataCategory[dataCategory].categoryID}">
{$dataCategory[dataCategory].categoryName}</option>
{/if}
{/section}
</select>
</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">Note</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">:</td>
<td><input type="text" value="{$note}" id="note" name="note"
class="form-control" placeholder="Note" style="width:
270px;"></td>
</tr>
<tr valign="top">
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">Satuan</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">:</td>
<td>
<select id="unit" name="unit" class="form-control"
style="width: 270px;" required>
<option value=""></option>
<option value="1" {if $unit == '1'} SELECTED {/if}>SET</option>
<option value="2" {if $unit == '2'} SELECTED {/if}>PCS</option>
</select>
</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">Gambar</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">:</td>
<td rowspan="8">
85
<div id="me" class="styleall" style="cursor:pointer;">
<label>
<button class="btn btn-warning">Browse</button>
</label>
</div>
<span id="mestatus"></span>
<div id="photoproduct">
<li class="nameupload"></li>
</div>
<div id="files">
<li class="success">
{if $image != ''}
<img src="img/products/thumb/small_{$image}"><br>
<span style="font-size: 10pt;"><a id="deleteimage"
href="products.php?module=product&act=deleteimage&productID={$prod
uctID}&picture={$image}">Hapus Gambar</a></span>
{/if}
</li>
</div>
</td>
</tr>
<tr>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">Harga Unit 1</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">:</td>
<td><input type="number" value="{$unitPrice1}" id="unitPrice1"
name="unitPrice1" class="form-control" placeholder="Harga Satuan
1" style="width: 270px;" required></td>
</tr>
<tr>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">Harga Unit 2</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">:</td>
<td><input type="number" value="{$unitPrice2}" id="unitPrice2"
name="unitPrice2" class="form-control" placeholder="Harga Satuan
2" style="width: 270px;" required></td>
</tr>
<tr>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">Harga Unit 3</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">:</td>
<td><input type="number" value="{$unitPrice3}" id="unitPrice3"
name="unitPrice3" class="form-control" placeholder="Harga Satuan
3" style="width: 270px;" required></td>
</tr>
<tr>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">HPP</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-
serif; font-size: 14px;">:</td>
<td><input type="number" value="{$hpp}" id="hpp" name="hpp"
class="form-control" placeholder="HPP" style="width: 270px;"
required></td>
</tr>
86
</table>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
{/if}
</body>
save_edit_product.php
<?php
// include header
include "header.php";
$file = "img/products/".$image;
$realPic = imagecreatefromjpeg($file);
$width = imagesx($realPic);
$height = imagesy($realPic);
$thumbWidth = 100;
$thumbHeight = 70;
87
$thumbHeight, $width, $height);
imagejpeg($thumbPic, "img/products/thumb/small_".$image);
imagedestroy($realPic);
imagedestroy($thumbPic);
else
{
$queryProduct = "UPDATE as_products SET productName =
'$productName',
categoryID = '$categoryID',
unit = '$unit',
unitPrice1 = '$unitPrice1',
unitPrice2 = '$unitPrice2',
unitPrice3 = '$unitPrice3',
hpp = '$hpp',
purchasePrice = '$purchasePrice',
note = '$note',
minimumStock = '$minimumStock',
modifiedDate = '$modified_date',
modifiedUserID = '$staffID'
WHERE productID = '$productID'";
}
if ($sqlProduct)
{
echo json_encode(OK);
}
}
exit();
?>
Hasil seluruh skrip diatas akan menghasilkan master data produk yang bisa
dilihat melalui gambar-gambar berikut :
88
Gambar 5.10. Menampilkan data produk
89
Gambar 5.12. Mengubah data produk
5.1.5 Supplier
Master data supplier digunakan untuk menyimpan dan mengolah data-data
supplier atau pemasok perusahaan kita, disini penulis akan berikan tuntas skrip-
skrip yang dibutuhkan, buat beberapa file berikut, dimana masing-masing
skripnya bisa dilihat sebagai berikut :
suppliers.php
<?php
90
// include header
include "header.php";
// set the tpl page
$page = "suppliers.tpl";
$module = $_GET['module'];
$act = $_GET['act'];
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE modulID =
'6'";
$sqlAuthorizeStaff = mysqli_query($connect, $queryAuthorizeStaff);
$dataAuthorizeStaff = mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
// delete supplier
$querySupplier = "DELETE FROM as_suppliers WHERE supplierID =
'$supplierID'";
$sqlSupplier = mysqli_query($connect, $querySupplier);
// fetch data
$i = 1;
while ($dtSupplier = mysqli_fetch_array($sqlSupplier))
91
{
$dataSupplier[] = array('supplierID' => $dtSupplier['supplierID'],
'supplierCode' => $dtSupplier['supplierCode'],
'supplierName' => $dtSupplier['supplierName'],
'address' => $dtSupplier['address'],
'phone' => $dtSupplier['phone'],
'fax' => $dtSupplier['fax'],
'contactPerson' => $dtSupplier['contactPerson'],
'email' => $dtSupplier['email'],
'no' => $i);
$i++;
}
// assign
$smarty->assign("dataSupplier", $dataSupplier);
$smarty->assign("q", $q);
}
else
{
// get last sort supplier number
$queryNoSupplier = "SELECT supplierCode FROM as_suppliers
ORDER BY supplierCode DESC LIMIT 1";
$sqlNoSupplier = mysqli_query($connect, $queryNoSupplier);
$numsNoSupplier = mysqli_num_rows($sqlNoSupplier);
$dataNoSupplier = mysqli_fetch_array($sqlNoSupplier);
$start = substr($dataNoSupplier['supplierCode'],0-5);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoSupplier == '0')
{
$supplierNo = "0000";
}
elseif ($tempNo == 1)
{
$supplierNo = "0000";
}
elseif ($tempNo == 2)
{
$supplierNo = "000";
}
elseif ($tempNo == 3)
{
$supplierNo = "00";
}
elseif ($tempNo == 4)
{
$supplierNo = "0";
}
elseif ($tempNo == 5)
{
$supplierNo = "";
}
$supplierCode = $supplierNo.$next;
92
$smarty->assign("supplierCode", $supplierCode);
// fetch data
$i = 1 + $position;
while ($dtSupplier = mysqli_fetch_array($sqlSupplier))
{
$dataSupplier[] = array('supplierID' => $dtSupplier['supplierID'],
'supplierCode' => $dtSupplier['supplierCode'],
'supplierName' => $dtSupplier['supplierName'],
'address' => $dtSupplier['address'],
'phone' => $dtSupplier['phone'],
'fax' => $dtSupplier['fax'],
'contactPerson' => $dtSupplier['contactPerson'],
'email' => $dtSupplier['email'],
'no' => $i);
$i++;
}
$smarty->assign("dataSupplier", $dataSupplier);
// count data
$queryCountSupplier = "SELECT * FROM as_suppliers";
$sqlCountSupplier = mysqli_query($connect, $queryCountSupplier);
$amountData = mysqli_num_rows($sqlCountSupplier);
$smarty->assign("pageLink", $pageLink);
}
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Manajemen Supplier");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk melakukan
pengolahan data master supplier.");
$smarty->assign("breadcumbMenuName", "Master Data");
$smarty->assign("breadcumbMenuSubName", "Supplier");
}
// include footer
include "footer.php";
?>
93
suppliers.tpl (simpan didalam folder templates)
{include file="header.tpl"}
{literal}
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#send").on("click", function(){
var supplierCode = $("#supplierCode").val();
var supplierName = $("#supplierName").val();
var contactPerson = $("#contactPerson").val();
var address = $("#address").val();
var city = $("#city").val();
var phone = $("#phone").val();
var fax = $("#fax").val();
var email = $("#email").val();
$.ajax({
type: 'POST',
url: 'save_supplier.php',
dataType: 'JSON',
data:{
supplierCode: supplierCode,
supplierName: supplierName,
contactPerson: contactPerson,
address: address,
city: city,
phone: phone,
fax: fax,
email: email
},
94
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "suppliers.php";
}
});
}
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
<aside class="right-side">
{include file="breadcumb.tpl"}
95
<a href="#inline" class="modalbox" style="float: left;"><button
class="btn btn-default pull-right"><i class="fa fa-plus"></i>
Add</button></a>
<a href="print_suppliers.php?act=print&q={$q}" style="float:
left;" target="_blank"><button type="button" class="btn btn-
default pull-right"><i class="fa fa-print"></i> Print
PDF</button></a>
</form>
</div>
</div>
</div><!-- /.box-header -->
96
{else}
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>KODE <i class="fa fa-sort"></i></th>
<th>NAMA SUPPLIER <i class="fa fa-sort"></i></th>
<th>KONTAK PERSON <i class="fa fa-sort"></i></th>
<th>ALAMAT <i class="fa fa-sort"></i></th>
<th>TLP <i class="fa fa-sort"></i></th>
<th>FAX <i class="fa fa-sort"></i></th>
<th width="60">AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataSupplier loop=$dataSupplier}
<tr>
<td>{$dataSupplier[dataSupplier].no}</td>
<td>{$dataSupplier[dataSupplier].supplierCode}</td>
<td>{$dataSupplier[dataSupplier].supplierName}</td>
<td>{$dataSupplier[dataSupplier].contactPerson}</td>
<td>{$dataSupplier[dataSupplier].address}</td>
<td>{$dataSupplier[dataSupplier].phone}</td>
<td>{$dataSupplier[dataSupplier].fax}</td>
<td>
<a title="Edit" href="edit_suppliers.php?module=supplier&act=edit&
supplierID={$dataSupplier[dataSupplier].supplierID}" data-
width="450" data-height="180" class="various2 fancybox.iframe">
<img src="img/icons/edit.png" width="18"></a>
<a title="Delete" href="suppliers.php?module=supplier&act=delete&
supplierID={$dataSupplier[dataSupplier].supplierID}"
onclick="return confirm('Anda Yakin ingin menghapus supplier
{$dataSupplier[dataSupplier].supplierName}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
<div id="inline">
<table width="95%" align="center">
<tr>
<td colspan="3"><h3>Tambah Supplier</h3></td>
97
</tr>
<tr>
<td>
<form id="supplier" name="supplier" method="POST" action="#">
<table cellpadding="7" cellspacing="7">
<tr>
<td width="140">Kode</td>
<td width="5">:</td>
<td>
<input type="hidden" value="{$supplierCode}" id="supplierCode"
name="supplierCode">
<input type="text" value="{$supplierCode}" id="supplierCode"
name="supplierCode" class="form-control" placeholder="Kode
Supplier" style="width: 270px;" DISABLED>
</td>
</tr>
<tr>
<td>Nama Supplier</td>
<td>:</td>
<td><input type="text" id="supplierName"
name="supplierName" class="form-control" placeholder="Nama
Supplier" style="width: 270px;" required></td>
</tr>
<tr>
<td>Kontak Person</td>
<td>:</td>
<td><input type="text" id="contactPerson"
name="contactPerson" class="form-control" placeholder="Kontak
Person" style="width: 270px;"></td>
</tr>
<tr>
<td>Alamat</td>
<td>:</td>
<td><input type="text" id="address" name="address" class="form-
control" placeholder="Alamat" style="width: 270px;"></td>
</tr>
<tr>
<td>Kota</td>
<td>:</td>
<td><input type="text" id="city" name="city" class="form-control"
placeholder="Kota" style="width: 270px;"></td>
</tr>
<tr>
<td>Telepon</td>
<td>:</td>
<td><input type="text" id="phone" name="phone" class="form-
control" placeholder="Telepon" style="width: 270px;"></td>
</tr>
<tr>
<td>Fax</td>
<td>:</td>
<td><input type="text" id="fax" name="fax" class="form-
control" placeholder="Fax" style="width: 270px;"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
98
<td><input type="email" id="email" name="email" class="form-
control" placeholder="Email" style="width: 270px;"></td>
</tr>
</table>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
</div>
{/if}
</div><!-- /.box -->
{include file="footer.tpl"}
save_supplier.php
<?php
// include header
include "header.php";
99
VALUES( '$supplierCode',
'$supplierName',
'$address',
'$city',
'$phone',
'$fax',
'$contactPerson',
'$email',
'$createdDate',
'$staffID',
'',
'')";
if ($sqlSupplier)
{
echo json_encode(OK);
}
}
exit();
?>
edit_suppliers.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "edit_suppliers.tpl";
else
{
// get variable
$module = $_GET['module'];
$act = $_GET['act'];
// fetch data
100
$dataSupplier = mysqli_fetch_array($sqlSupplier);
} // close bracket
// include footer
include "footer.php";
?>
101
if (supplierID != '' && supplierName != ''){
$.ajax({
type: 'POST',
url: 'save_edit_supplier.php',
dataType: 'JSON',
data:{
supplierID: supplierID,
supplierName: supplierName,
contactPerson: contactPerson,
address: address,
city: city,
phone: phone,
fax: fax,
email: email
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
parent.jQuery.fancybox.close();
}
});
}
});
});
</script>
{/literal}
102
<td><input type="text" value="{$contactPerson}"
id="contactPerson" name="contactPerson" class="form-control"
placeholder="Kontak Person" style="width: 270px;"></td>
</tr>
<tr>
<td>Alamat</td>
<td>:</td>
<td><input type="text" value="{$address}" id="address"
name="address" class="form-control" placeholder="Alamat"
style="width: 270px;"></td>
</tr>
<tr>
<td>Kota</td>
<td>:</td>
<td><input type="text" value="{$city}" id="city" name="city"
class="form-control" placeholder="Kota" style="width:
270px;"></td>
</tr>
<tr>
<td>Telepon</td>
<td>:</td>
<td><input type="text" value="{$phone}" id="phone"
name="phone" class="form-control" placeholder="Telepon"
style="width: 270px;"></td>
</tr>
<tr>
<td>Fax</td>
<td>:</td>
<td><input type="text" value="{$fax}" id="fax" name="fax"
class="form-control" placeholder="Fax" style="width: 270px;"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input type="email" value="{$email}" id="email"
name="email" class="form-control" placeholder="Email"
style="width: 270px;"></td>
</tr>
</table>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
{/if}
</body>
save_edit_supplier.php
<?php
// include header
include "header.php";
103
$supplierID = $_POST['supplierID'];
$supplierName = mysqli_real_escape_string($connect,
$_POST['supplierName']);
$contactPerson = mysqli_real_escape_string($connect,
$_POST['contactPerson']);
$address = mysqli_real_escape_string($connect, $_POST['address']);
$city = mysqli_real_escape_string($connect, $_POST['city']);
$phone = mysqli_real_escape_string($connect, $_POST['phone']);
$fax = mysqli_real_escape_string($connect, $_POST['fax']);
$email = mysqli_real_escape_string($connect, $_POST['email']);
if ($sqlSupplier)
{
echo json_encode(OK);
}
}
exit();
?>
Hasil seluruh skrip diatas akan menghasilkan halaman master data supplier
dimana hasilnya bisa dilihat melalui gambar-gambar berikut :
104
Gambar 5.15. Menambah data supplier
105
Gambar 5.16. Mengubah data supplier
5.1.6 Gudang
Master data gudang digunakan untuk menyimpan dan mengolah gudang yang
ada di perusahaan kita. Disini kita akan membuat sekaligus proses aktifitas yang
ada di master data gudang.
Buat beberapa file dengan masing-masing skrip berikut :
106
factories.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "factories.tpl";
$module = $_GET['module'];
$act = $_GET['act'];
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE
modulID = '12'";
$sqlAuthorizeStaff = mysqli_query($connect, $queryAuthorizeStaff);
$dataAuthorizeStaff = mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
// delete factories
$queryFactory = "DELETE FROM as_factories WHERE factoryID
= '$factoryID'";
$sqlFactory = mysqli_query($connect, $queryFactory);
107
// fetch data
$i = 1;
while ($dtFactory = mysqli_fetch_array($sqlFactory))
{
if ($dtFactory['factoryType'] == '1')
{
$factoryType = "TETAP";
}
else
{
$factoryType = "SEMENTARA (SEWA)";
}
// assign
$smarty->assign("dataFactory", $dataFactory);
$smarty->assign("q", $q);
}
else
{
// get last sort factory number
$queryNoFactory = "SELECT factoryCode FROM as_factories ORDER BY
factoryCode DESC LIMIT 1";
$sqlNoFactory = mysqli_query($connect, $queryNoFactory);
$numsNoFactory = mysqli_num_rows($sqlNoFactory);
$dataNoFactory = mysqli_fetch_array($sqlNoFactory);
$start = substr($dataNoFactory['factoryCode'],0-5);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoFactory == '0')
{
$factoryNo = "0000";
}
elseif ($tempNo == 1)
{
$factoryNo = "0000";
}
elseif ($tempNo == 2)
{
$factoryNo = "000";
}
elseif ($tempNo == 3)
{
$factoryNo = "00";
}
108
elseif ($tempNo == 4)
{
$factoryNo = "0";
}
elseif ($tempNo == 5)
{
$factoryNo = "";
}
$factoryCode = $factoryNo.$next;
$smarty->assign("factoryCode", $factoryCode);
// fetch data
$i = 1 + $position;
while ($dtFactory = mysqli_fetch_array($sqlFactory))
{
if ($dtFactory['factoryType'] == '1')
{
$factoryType = "TETAP";
}
else
{
$factoryType = "SEMENTARA (SEWA)";
}
$smarty->assign("dataFactory", $dataFactory);
// count data
$queryCountFactory = "SELECT * FROM as_factories";
$sqlCountFactory = mysqli_query($connect, $queryCountFactory);
$amountData = mysqli_num_rows($sqlCountFactory);
109
$smarty->assign("pageLink", $pageLink);
}
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Manajemen Gudang / Pabrik");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk melakukan
pengolahan data master gudang atau pabrik.");
$smarty->assign("breadcumbMenuName", "Master Data");
$smarty->assign("breadcumbMenuSubName", "Gudang / Pabrik");
}
// include footer
include "footer.php";
?>
factories.tpl
{include file="header.tpl"}
{literal}
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#send").on("click", function(){
var factoryCode = $("#factoryCode").val();
var factoryName = $("#factoryName").val();
var factoryType = $("#factoryType").val();
var status = $("#status").val();
var note = $("#note").val();
110
$.ajax({
type: 'POST',
url: 'save_factory.php',
dataType: 'JSON',
data:{
factoryCode: factoryCode,
factoryName: factoryName,
factoryType: factoryType,
status: status,
note: note
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "factories.php";
}
});
}
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
<aside class="right-side">
{include file="breadcumb.tpl"}
111
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Data Gudang / Pabrik</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<form method="GET" action="factories.php">
<input type="hidden" name="module" value="factory">
<input type="hidden" name="act" value="search">
<button type="submit" class="btn btn-default pull-
right"><i class="fa fa-search"></i> Search</button>
<input type="text" value="{$q}" id="q" name="q"
class="form-control" placeholder="Pencarian : Kode atau Nama
Gudang" style="float: right; width: 270px;" required>
<a href="#inline" class="modalbox" style="float: left;"><button
class="btn btn-default pull-right"><i class="fa fa-plus"></i>
Add</button></a>
<a href="print_factories.php?act=print&q={$q}" style="float:
left;" target="_blank"><button class="btn btn-default pull-right"
type="button"><i class="fa fa-print"></i> Print PDF</button></a>
</form>
</div>
</div>
</div><!-- /.box-header -->
112
[dataFactory].factoryName}?');"><img src="img/icons/delete.png"
width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
{else}
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>KODE GUDANG <i class="fa fa-sort"></i></th>
<th>NAMA GUDANG <i class="fa fa-sort"></i></th>
<th>TIPE <i class="fa fa-sort"></i></th>
<th>STATUS <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataFactory loop=$dataFactory}
<tr>
<td>{$dataFactory[dataFactory].no}</td>
<td>{$dataFactory[dataFactory].factoryCode}</td>
<td>{$dataFactory[dataFactory].factoryName}</td>
<td>{$dataFactory[dataFactory].factoryType}</td>
<td>{$dataFactory[dataFactory].status}</td>
<td>
<a title="Edit" href="edit_factories.php?module=factory&act=edit&
factoryID={$dataFactory[dataFactory].factoryID}" data-width="450"
data-height="180" class="various2 fancybox.iframe"> <img
src="img/icons/edit.png" width="18"></a>
<a title="Delete" href="factories.php?module=factory&act=delete&
factoryID={$dataFactory[dataFactory].factoryID}" onclick="return
confirm('Anda Yakin ingin menghapus gudang
{$dataFactory[dataFactory].factoryName}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
</div><!-- /.box-body -->
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-left">
<ul class="pagination pagination-sm inline">
{$pageLink}
</ul>
113
</div>
</div><!-- /.box-header -->
<div id="inline">
<table width="95%" align="center">
<tr>
<td colspan="3"><h3>Tambah Gudang / Pabrik</h3></td>
</tr>
<tr>
<td>
<form id="factory" name="factory" method="POST" action="#">
<table cellpadding="7" cellspacing="7">
<tr>
<td width="140">Kode Gudang</td>
<td width="5">:</td>
<td><input type="hidden" value="{$factoryCode}" id="factoryCode"
name="factoryCode">
<input type="text" value="{$factoryCode}" id="factoryCode"
name="factoryCode" class="form-control" placeholder="Kode Gudang"
style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>Nama Gudang</td>
<td>:</td>
<td><input type="text" id="factoryName" name="factoryName"
class="form-control" placeholder="Nama Gudang" style="width:
270px;" required></td>
</tr>
<tr>
<td>Tipe</td>
<td>:</td>
<td><select name="factoryType" id="factoryType" class="form-
control" required>
<option value="">- Pilih Status -</option>
<option value="1">Tetap</option>
<option value="2">Sementara (Sewa)</option>
</select></td>
</tr>
<tr>
<td>Status</td>
<td>:</td>
<td><select name="status" id="status" class="form-control"
required>
<option value="">- Pilih Status -</option>
<option value="Y">Y (Aktif)</option>
<option value="N">N (Tidak Aktif)</option>
</select></td>
</tr>
<tr valign="top">
<td>Note</td>
<td>:</td>
<td><textarea class="textarea" name="note" id="note"
placeholder="Note" style="width: 100%; height: 125px; font-size:
14px; line-height: 18px; border: 1px solid #dddddd; padding:
10px;"></textarea></td>
</tr>
</table>
114
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
</div>
{/if}
</div><!-- /.box -->
{include file="footer.tpl"}
save_factory.php
<?php
// include header
include "header.php";
115
if ($sqlFactory)
{
echo json_encode(OK);
}
}
exit();
?>
edit_factory.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "edit_factories.tpl";
else
{
// get variable
$module = $_GET['module'];
$act = $_GET['act'];
// fetch data
$dataFactory = mysqli_fetch_array($sqlFactory);
116
} // close bracket
// include footer
include "footer.php";
?>
edit_factories.tpl
<script src="design/js/jquery-1.8.1.min.js" type="text/
javascript"></script>
<link href="design/css/bootstrap.min.css" rel="stylesheet"
type="text/css" />
<link href="design/css/AdminLTE.css" rel="stylesheet"
type="text/css" />
<script src="design/js/bootstrap.min.js" type="text/javascript">
</script>
$.ajax({
type: 'POST',
url: 'save_edit_factory.php',
dataType: 'JSON',
data:{
factoryID: factoryID,
factoryName: factoryName,
factoryType: factoryType,
status: status,
note: note
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
parent.jQuery.fancybox.close();
}
117
});
}
});
});
</script>
{/literal}
118
<td>Note</td>
<td>:</td>
<td><textarea class="textarea" name="note"
id="note" placeholder="Note" style="width: 100%; height: 125px;
font-size: 14px; line-height: 18px; border: 1px solid #dddddd;
padding: 10px;">{$note}</textarea></td>
</tr>
</table>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
{/if}
</body>
save_edit_factory.php
<?php
// include header
include "header.php";
if ($sqlFactory)
{
echo json_encode(OK);
}
}
exit();
?>
119
Hasil seluruh skrip diatas, akan menampilkan halaman master data gudang yang
dapat dilihat pada gambar-gambar berikut :
120
Gambar 5.19. Mengubah data gudang
121
authorize.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "authorize.tpl";
$module = $_GET['module'];
$act = $_GET['act'];
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE
modulID = '25'";
$sqlAuthorizeStaff = mysqli_query($connect, $queryAuthorizeStaff);
$dataAuthorizeStaff =
mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
// fetch data
$i = 1;
while ($dtModule = mysqli_fetch_array($sqlModule))
{
$a = str_replace("1", " Administrator", $dtModule['authorize']);
$b = str_replace("2", " Sales", $a);
$c = str_replace("3", " Kasir", $b);
$d = str_replace("4", " Spv", $c);
$e = str_replace("5", " Top", $d);
$f = str_replace("0", "", $e);
$g = str_replace(",,,", ",", $f);
$h = str_replace(",,", ",", $g);
122
$smarty->assign("dataModule", $dataModule);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Manajemen Level Authorize");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk melakukan
pengolahan data master otorisasi level.");
$smarty->assign("breadcumbMenuName", "Master Data");
$smarty->assign("breadcumbMenuSubName", "Level Authorize");
}
// include footer
include "footer.php";
?>
{literal}
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
123
<aside class="left-side sidebar-offcanvas">
<!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
{include file="user_panel.tpl"}
{include file="side_menu.tpl"}
</section>
<!-- /.sidebar -->
</aside>
<aside class="right-side">
{include file="breadcumb.tpl"}
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NAMA MODUL <i class="fa fa-sort"></i></th>
<th>STATUS <i class="fa fa-sort"></i></th>
<th>OTORISASI <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataModule loop=$dataModule}
<tr>
<td>{$dataModule[dataModule].no}</td>
<td>{$dataModule[dataModule].modulName}</td>
<td>{$dataModule[dataModule].status}</td>
<td>{$dataModule[dataModule].authorize}</td>
<td>
124
<a title="Edit" href="edit_authorize.php?module=authorize&act=
edit&modulID={$dataModule[dataModule].modulID}" data-width="450"
data-height="180" class="various2 fancybox.iframe"><img
src="img/icons/edit.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
</div><!-- /.box-body -->
{include file="footer.tpl"}
edit_authorize.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "edit_authorize.tpl";
else
{
// get variable
$module = $_GET['module'];
$act = $_GET['act'];
// fetch data
$dataModul = mysqli_fetch_array($sqlModul);
125
$authorize = explode(",", $dataModul['authorize']);
} // close bracket
// include footer
include "footer.php";
?>
$("#send").on("click", function(){
var modulID = $("#modulID").val();
var status = $("#status").val();
if ($("#authorize1").is(':checked')){
var authorize1 = "1,";
}
else{
var authorize1 = "0,";
}
126
if ($("#authorize2").is(':checked')){
var authorize2 = "2,";
}
else{
var authorize2 = "0,";
}
if ($("#authorize3").is(':checked')){
var authorize3 = "3,";
}
else{
var authorize3 = "0,";
}
if ($("#authorize4").is(':checked')){
var authorize4 = "4,";
}
else{
var authorize4 = "0,";
}
if ($("#authorize5").is(':checked')){
var authorize5 = "5";
}
else{
var authorize5 = "0";
}
if (modulID != ''){
$.ajax({
type: 'POST',
url: 'save_edit_authorize.php',
dataType: 'JSON',
data:{
modulID: modulID,
status: status,
authorize1: authorize1,
authorize2: authorize2,
authorize3: authorize3,
authorize4: authorize4,
authorize5: authorize5
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
parent.jQuery.fancybox.close();
}
});
}
});
});
</script>
{/literal}
127
<table width="95%" align="center">
<tr>
<td align="center"><h3><b>OTORISASI LEVEL</b></h3></td>
</tr>
<tr>
<td>
<form id="authorize" name="authorize" method="POST" action="#">
<input type="hidden" id="modulID" name="modulID"
value="{$modulID}">
<table cellpadding="7" cellspacing="7">
<tr>
<td width="140">Nama Modul</td>
<td width="5">:</td>
<td><input type="text" id="modulName" name="modulName"
value="{$modulName}" class="form-control" placeholder="Nama Modul"
style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>Status</td>
<td>:</td>
<td><select name="status" id="status" class="form-control"
required>
<option value="">- Pilih Status -</option>
<option value="Y" {if $status == 'Y'} SELECTED {/if}>Y
(Aktif)</option>
<option value="N" {if $status == 'N'} SELECTED {/if}>N
(Tidak Aktif)</option>
</select></td>
</tr>
<tr valign="top">
<td>Level</td>
<td>:</td>
<td> <input type="checkbox" id="authorize1" name="authorize1"
{if $adm == '1'} CHECKED {/if}> Administrator <br>
<input type="checkbox" id="authorize2" name="authorize2"
{if $sls == '2'} CHECKED {/if}> Sales <br>
<input type="checkbox" id="authorize3" name="authorize3"
{if $ksr == '3'} CHECKED {/if}> Kasir <br>
<input type="checkbox" id="authorize4" name="authorize4"
{if $spv == '4'} CHECKED {/if}> Spv <br>
<input type="checkbox" id="authorize5" name="authorize5"
{if $top == '5'} CHECKED {/if}> Top <br>
</td>
</tr>
</table>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
{/if}
</body>
save_edit_authorize.php
128
<?php
// include header
include "header.php";
$authorize = $authorize1.$authorize2.$authorize3.
$authorize4.$authorize5;
if ($sqlModul)
{
echo json_encode(OK);
}
}
exit();
?>
Hasil seluruh skrip diatas akan menghasilkan halaman master level authorize
dimana hasilnya bisa dilihat melalui gambar-gambar berikut :
129
Gambar 5.20. Menampilkan data level otorisasi
130
5.2 Transaksi Pembelian
Transaksi pembelian didalamnya mengandung proses purchase order,
penerimaan barang, transaksi pembelian (pembuatan faktur) dan pembayaran
transaksi. Digunakan apabila kita ingin memesan barang kepada supplier. Disini
kita membahas bagaimana membuat proses tersebut.
$module = $_GET['module'];
$act = $_GET['act'];
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE modulID =
'14'";
$sqlAuthorizeStaff = mysqli_query($connect, $queryAuthorizeStaff);
$dataAuthorizeStaff = mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
131
$spbNo = $_GET['spbNo'];
// delete spb
$querySpb = "DELETE FROM as_spb WHERE spbID = '$spbID' AND
spbFaktur = '$spbFaktur'";
$sqlSpb = mysqli_query($connect, $querySpb);
// fetch data
$i = 1;
while ($dtDetail = mysqli_fetch_array($sqlDetail))
{
$subtotal = $dtDetail['qty'] * $dtDetail['price'];
$dataDetail[] = array( 'detailID' => $dtDetail['detailID'],
'productID' => $dtDetail['productID'],
'productName' => $dtDetail['productName'],
'price' => rupiah($dtDetail['price']),
'subtotal' => rupiah($subtotal),
'qty' => $dtDetail['qty'],
132
'note' => $dtDetail['note'],
'no' => $i
);
$grandtotal += $subtotal;
$i++;
}
$q = mysqli_real_escape_string($connect, $_GET['q']);
// fetch data
$i = 1;
while ($dtDetail = mysqli_fetch_array($sqlDetail))
{
$subtotal = $dtDetail['qty'] * $dtDetail['price'];
$dataDetail[] = array( 'detailID' => $dtDetail['detailID'],
133
'productID' => $dtDetail['productID'],
'productName' => $dtDetail['productName'],
'price' => rupiah($dtDetail['price']),
'subtotal' => rupiah($subtotal),
'qty' => $dtDetail['qty'],
'note' => $dtDetail['note'],
'no' => $i
);
$grandtotal += $subtotal;
$i++;
}
$smarty->assign("q", $q);
// update spb
$querySpb = "UPDATE as_spb SET note = '$note' WHERE
spbFaktur = '$spbFaktur' AND spbNo = '$spbNo'";
mysqli_query($connect, $querySpb);
134
createdDate,
createdUserID,
modifiedDate,
modifiedUserID)
VALUES( '$dataSpb[spbNo]',
'$dataSpb[spbFaktur]',
'$dataSpb[productID]',
'$dataSpb[productName]',
'$dataSpb[price]',
'$dataSpb[qty]',
'$dataSpb[note]',
'$dataSpb[createdDate]',
'$dataSpb[createdUserID]',
'',
'')";
$save = mysqli_query($connect, $querySaveSpb);
}
// delete data
$querySpb = "DELETE FROM as_temp_detail_spb WHERE
detailID = '$detailID'";
$sqlSpb = mysqli_query($connect, $querySpb);
if ($sqlDetail)
{
$querySpb = "DELETE FROM as_spb WHERE spbFaktur = '$spbFaktur'";
$sqlSpb = mysqli_query($connect, $querySpb);
}
135
// redirect to the spb page
header("Location: spb.php");
}
$start = substr($dataNoSpb['spbNo'],0-5);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoSpb == '0')
{
$spbNo = "00000";
}
elseif ($tempNo == 1)
{
$spbNo = "00000";
}
elseif ($tempNo == 2)
{
$spbNo = "0000";
}
elseif ($tempNo == 3)
{
$spbNo = "000";
}
elseif ($tempNo == 4)
{
$spbNo = "00";
}
elseif ($tempNo == 5)
{
$spbNo = "0";
}
elseif ($tempNo == 6)
{
$spbNo = "";
}
$spbCode = "PO".$spbNo.$next;
136
$smarty->assign("breadcumbMenuSubName", "Tambah Transaksi
Purchase Order");
$smarty->assign("dataSupplier", $dataSupplier);
if ($numsSpb == 0)
{
$orderDate = date('Y-m-d');
$sName = $_SESSION['staffCode']." ".$_SESSION['staffName'];
$querySpb = "INSERT INTO as_spb(spbNo,
spbFaktur,
supplierID,
supplierName,
staffID,
staffName,
orderDate,
needDate,
note,
status,
createdDate,
createdUserID,
modifiedDate,
modifiedUserID)
VALUES( '$spbCode',
'$_SESSION[spbFaktur]',
'',
'',
'$_SESSION[staffID]',
'$sName',
'$orderDate',
'$orderDate',
'',
'',
'$createdDate',
'$staffID',
'',
'')";
137
mysqli_query($connect, $querySpb);
}
$smarty->assign("supplierID", $dataSpb['supplierID']);
if ($dataSpb['needDate'] == '0000-00-00')
{
$needDate = tgl_indo2(date('Y-m-d'));
}
else
{
$needDate = tgl_indo2($dataSpb['needDate']);
}
if ($dataSpb['orderDate'] == '0000-00-00')
{
$orderDate = tgl_indo2(date('Y-m-d'));
}
else
{
$orderDate = tgl_indo2($dataSpb['orderDate']);
}
$smarty->assign("spbNo", $spbCode);
$smarty->assign("orderDateIndo", $orderDate);
$smarty->assign("needDateIndo", $needDate);
$smarty->assign("spbFaktur", $_SESSION['spbFaktur']);
$smarty->assign("note", $dataSpb['note']);
// fetch data
$i = 1;
while ($dtDetilSpb = mysqli_fetch_array($sqlDetilSpb))
{
$subtotal = $dtDetilSpb['price'] * $dtDetilSpb['qty'];
$dataDetilSpb[] = array( 'detailID' =>
$dtDetilSpb['detailID'],
'productName' => $dtDetilSpb['productName'],
'price' => rupiah($dtDetilSpb['price']),
'qty' => $dtDetilSpb['qty'],
'note' => $dtDetilSpb['note'],
'subtotal' => rupiah($subtotal),
'no' => $i);
$i++;
138
}
$q = mysqli_real_escape_string($connect, $_GET['q']);
$sDate = mysqli_real_escape_string($connect, $_GET['startDate']);
$eDate = mysqli_real_escape_string($connect, $_GET['endDate']);
$smarty->assign("startDate", $sDate);
$smarty->assign("endDate", $eDate);
$startDate = $s2Date[2]."-".$s2Date[1]."-".$s2Date[0];
$endDate = $e2Date[2]."-".$e2Date[1]."-".$e2Date[0];
// fetch data
$i = 1 + $position;
while ($dtSpb = mysqli_fetch_array($sqlSpb))
{
$dataSpb[] = array( 'spbID' => $dtSpb['spbID'],
'spbNo' => $dtSpb['spbNo'],
'spbFaktur' => $dtSpb['spbFaktur'],
'supplierName' => $dtSpb['supplierName'],
'staffName' => $dtSpb['staffName'],
'orderDate' => tgl_indo2($dtSpb['orderDate']),
'needDate' => tgl_indo2($dtSpb['needDate']),
'total' => rupiah($dtSpb['total']),
'status' => $dtSpb['status'],
'no' => $i);
$i++;
}
139
$smarty->assign("dataSpb", $dataSpb);
$smarty->assign("page", $_GET['page']);
$smarty->assign("q", $q);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Purchase Order");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi purchase order.");
$smarty->assign("breadcumbMenuName", "Purchase Order");
$smarty->assign("breadcumbMenuSubName", "Purchase Order");
}
else
{
$_SESSION['spbFaktur'] = date('Ymdhis');
$smarty->assign("spbFaktur", $_SESSION['spbFaktur']);
// create new object pagination
$p = new PaginationSpb;
// limit 20 data for page
$limit = 30;
$position = $p->searchPosition($limit);
// fetch data
$i = 1 + $position;
while ($dtSpb = mysqli_fetch_array($sqlSpb))
{
$dataSpb[] = array( 'spbID' => $dtSpb['spbID'],
'spbNo' => $dtSpb['spbNo'],
'spbFaktur' => $dtSpb['spbFaktur'],
'supplierName' => $dtSpb['supplierName'],
'staffName' => $dtSpb['staffName'],
'orderDate' => tgl_indo2($dtSpb['orderDate']),
'needDate' => tgl_indo2($dtSpb['needDate']),
'total' => rupiah($dtSpb['total']),
'status' => $dtSpb['status'],
'no' => $i);
$i++;
}
$smarty->assign("dataSpb", $dataSpb);
// count data
$queryCountSpb = "SELECT * FROM as_spb";
$sqlCountSpb = mysqli_query($connect, $queryCountSpb);
$amountData = mysqli_num_rows($sqlCountSpb);
$smarty->assign("pageLink", $pageLink);
140
$smarty->assign("page", $_GET['page']);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Purchase Order");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi purchase order.");
$smarty->assign("breadcumbMenuName", "Purchase Order");
$smarty->assign("breadcumbMenuSubName", "Purchase Order");
}
$smarty->assign("module", $module);
$smarty->assign("act", $act);
}
// include footer
include "footer.php";
?>
<style>
div.ui-datepicker{
font-size:14px;
}
</style>
{literal}
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$( "#orderDate" ).datepicker({
changeMonth: true,
changeYear: true,
141
dateFormat: "dd-mm-yy",
yearRange: 'c-1:c-0'
});
$( "#startDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$( "#endDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$('#needDate').change(function () {
var spbNo = $("#spbNo").val();
var needDate = $("#needDate").val();
$.ajax({
type: 'POST',
url: 'save_spb_needdate.php',
dataType: 'JSON',
data:{
spbNo: spbNo,
needDate: needDate
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "spb.php?module=spb&act=add";
}
});
});
$('#orderDate').change(function () {
var spbNo = $("#spbNo").val();
var orderDate = $("#orderDate").val();
$.ajax({
type: 'POST',
url: 'save_spb_orderdate.php',
dataType: 'JSON',
data:{
spbNo: spbNo,
orderDate: orderDate
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "spb.php?module=spb&act=add";
}
});
});
$('#note').change(function () {
142
var spbNo = $("#spbNo").val();
var note = $("#note").val();
$.ajax({
type: 'POST',
url: 'save_spb_note.php',
dataType: 'JSON',
data:{
spbNo: spbNo,
note: note
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "spb.php?module=spb&act=add";
}
});
});
$( "#needDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c-1:c+1'
});
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#productBarcode").autocomplete("product_spb_autocomplete.php",
{
width: 310
}).result(function(event, item, a) {
var myarr = item[0].split(" # ");
document.getElementById('productBarcode').value = myarr[0];
document.getElementById('productName1').value = myarr[1];
document.getElementById('productName').value = myarr[1];
document.getElementById('productID').value = myarr[2];
document.getElementById('price').value = myarr[3];
});
$("#supplierID").change(function(e){
var supplierID = $("#supplierID").val();
$.ajax({
type: 'POST',
url: 'save_spb_supplier.php',
dataType: 'JSON',
data:{
supplierID: supplierID
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "spb.php?module=spb&act=add";
}
143
});
});
$("#send2").on("click", function(){
var spbNo = $("#spbNo").val();
var productID = $("#productID").val();
var productName1 = $("#productName1").val();
var qty = parseInt($("#qty").val());
var price = parseInt($("#price").val());
var desc = $("#desc").val();
if (qty != '' && spbNo != '' && productID != '' && price != ''){
$.ajax({
type: 'POST',
url: 'save_spb.php',
dataType: 'JSON',
data:{
qty: qty,
price: price,
spbNo: spbNo,
productID: productID,
productName1: productName1,
desc: desc
},
beforeSend: function (data) {
$('#send2').hide();
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "spb.php?module=spb&act=add";
}
});
}
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
<aside class="right-side">
144
{include file="breadcumb.tpl"}
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Tambah Purchase Order</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="spb.php?module=spb&act=cancel" onclick="return
confirm('Anda Yakin ingin membatalkan PO ini?');"><button
class="btn btn-default pull-right">Batal Trx</button></a>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<form method="POST" action="spb.php?module=spb&act=input">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="130">NO PO / TGL</td>
<td width="5">:</td>
<td><input type="hidden" id="spbNo" name="spbNo" value="{$spbNo}">
<input type="text" id="spbNo" name="spbNo" value="{$spbNo}"
class="form-control" placeholder="NO PO" style="width: 110px;
float: left" DISABLED>
<input type="text" id="orderDate" name="orderDate"
value="{$orderDateIndo}" class="form-control" placeholder="Tanggal
PO" style="width: 160px;" required>
</td>
</tr>
<tr>
145
<td>TGL DIBUTUHKAN</td>
<td>:</td>
<td><input type="text" id="needDate" name="needDate"
value="{$needDateIndo}" class="form-control" placeholder="Tanggal
Dibutuhkan" style="width: 270px;" required></td>
</tr>
<tr>
<td>SUPPLIER</td>
<td>:</td>
<td>
<select id="supplierID" name="supplierID" class="form-control"
style="width: 270px;" required>
<option value=""></option>
{section name=dataSupplier loop=$dataSupplier}
{if $dataSupplier[dataSupplier].supplierID == $supplierID}
<option value="{$dataSupplier[dataSupplier].supplierID}"
SELECTED>{$dataSupplier[dataSupplier].supplierName}
[{$dataSupplier[dataSupplier].supplierCode}]</option>
{else}
<option value="{$dataSupplier[dataSupplier].supplierID}">
{$dataSupplier[dataSupplier].supplierName}
[{$dataSupplier[dataSupplier].supplierCode}]</option>
{/if}
{/section}
</select>
</td>
</tr>
<tr>
<td>NOTE</td>
<td>:</td>
<td><input type="text" value="{$note}" id="note" name="note"
class="form-control" placeholder="Note" style="width:
270px;"></td>
</tr>
<tr>
<td colspan="3">
<br>
{if $numsDetilSpb < 10}
<a href="#inline" class="modalbox"><button class="btn btn-
default pull-left"><i class="fa fa-plus"></i> Add</button></a>
{/if}
</td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>HARGA SATUAN</th>
<th>QTY</th>
<th>SUBTOTAL</th>
<th>NOTE</th>
<th>AKSI</th>
</tr>
146
</thead>
<tbody>
{section name=dataDetilSpb loop=$dataDetilSpb}
<tr>
<td>{$dataDetilSpb[dataDetilSpb].no}</td>
<td>{$dataDetilSpb[dataDetilSpb].productName}</td>
<td style='text-align: right;'>{$dataDetilSpb[dataDetil
Spb].price}</td>
<td style='text-align: center;'>{$dataDetilSpb[dataDetil
Spb].qty}</td>
<td style='text-align: right;'>{$dataDetilSpb[dataDetil
Spb].subtotal}</td>
<td>{$dataDetilSpb[dataDetilSpb].note}</td>
<td>
<a title="Edit" href="edit_spb.php?module=spb&act=edit&detailID=
{$dataDetilSpb[dataDetilSpb].detailID}" data-width="450" data-
height="180" class="various2 fancybox.iframe"><img
src="img/icons/edit.png" width="18"></a>
<a title="Delete" href="spb.php?module=spb&act=deletedetail&
detailID={$dataDetilSpb[dataDetilSpb].detailID}" onclick="return
confirm('Anda Yakin ingin menghapus item produk
{$dataDetilSpb[dataDetilSpb].productName}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
<br>
<br>
{if $numsDetilSpb > 0}
<button type="submit" class="btn btn-
primary">Simpan</button>
{else}
<button type="button" class="btn btn-
primary">Simpan</button>
{/if}
</form>
147
</tr>
<tr>
<td colspan="2"></td>
<td><input type="hidden" id="productID" name="productID">
<input type="hidden" id="productName1" name="productName1">
<input type="text" id="productName" name="productName"
class="form-control" placeholder="Nama Produk" style="width:
270px;" DISABLED>
</td>
</tr>
<tr>
<td>Harga Satuan</td>
<td>:</td>
<td><input type="number" id="price" name="price" class="form-
control" placeholder="Harga Satuan" style="width: 270px;"
required></td>
</tr>
<tr>
<td>Qty</td>
<td>:</td>
<td><input type="number" id="qty" name="qty" class="form-control"
placeholder="Qty Produk" style="width: 270px;" required></td>
</tr>
<tr>
<td>Note</td>
<td>:</td>
<td><input type="text" id="desc" name="desc" class="form-
control" placeholder="Note" style="width: 270px;"></td>
</tr>
</table>
<button id="send2" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
</div>
148
<div class="box-body">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="130">ID TRX / TGL</td>
<td width="5">:</td>
<td>{$spbNo} / {$orderDate}</td>
</tr>
<tr>
<td>TGL DIBUTUHKAN</td>
<td>:</td>
<td>{$needDate}</td>
</tr>
<tr>
<td>SUPPLIER</td>
<td>:</td>
<td>{$supplierName}</td>
</tr>
<tr>
<td>NOTE</td>
<td>:</td>
<td>{$note}</td>
</tr>
<tr>
<td colspan="3"><br></td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>HARGA SATUAN</th>
<th>QTY</th>
<th>SUBTOTAL</th>
<th>NOTE</th>
</tr>
</thead>
<tbody>
{section name=dataDetail loop=$dataDetail}
<tr>
<td>{$dataDetail[dataDetail].no}</td>
<td>{$dataDetail[dataDetail].productName}</td>
<td style="text-align: right;">{$dataDetail[dataDetail]
.price}</td>
<td style="text-align: center;">{$dataDetail[dataDetail]
.qty}</td>
<td style="text-align: right;">{$dataDetail[dataDetail].
subtotal}</td>
<td>{$dataDetail[dataDetail].note}</td>
</tr>
{/section}
<tr>
<td colspan="4"></td>
<td style="text-align: right;">{$grandtotal}</td>
<td></td>
</tr>
149
</tbody>
</table>
</div>
</div><!-- /.box-body -->
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Detail Purchase Order</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="print_unit_spb.php?module=spb&act=print&spbID={$spbID}&
spbFaktur={$spbFaktur}" target="_blank"><button class="btn btn-
default pull-right">Print</button></a>
<a href="spb.php"><button class="btn btn-default pull-
right">Close</button></a>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="130">ID TRX / TGL</td>
<td width="5">:</td>
<td>{$spbNo} / {$orderDate}</td>
</tr>
<tr>
<td>TGL DIBUTUHKAN</td>
<td>:</td>
<td>{$needDate}</td>
</tr>
<tr>
<td>SUPPLIER</td>
<td>:</td>
<td>{$supplierName}</td>
</tr>
<tr>
<td>NOTE</td>
<td>:</td>
<td>{$note}</td>
</tr>
150
<tr>
<td colspan="3"><br></td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>HARGA SATUAN</th>
<th>QTY</th>
<th>SUBTOTAL</th>
<th>NOTE</th>
</tr>
</thead>
<tbody>
{section name=dataDetail loop=$dataDetail}
<tr>
<td>{$dataDetail[dataDetail].no}</td>
<td>{$dataDetail[dataDetail].productName}</td>
<td style="text-align: right;">{$dataDetail[dataDetail].
price}</td>
<td style="text-align: center;">{$dataDetail[dataDetail].
qty}</td>
<td style="text-align: right;">{$dataDetail[dataDetail].
subtotal}</td>
<td>{$dataDetail[dataDetail].note}</td>
</tr>
{/section}
<tr>
<td colspan="4"></td>
<td style="text-align: right;">{$grandtotal}</td>
<td></td>
</tr>
</tbody>
</table>
</div>
151
<input type="text" id="startDate" name="startDate"
value="{$startDate}" class="form-control" placeholder="Periode
Awal" style="float: right; width: 115px;">
<input type="text" id="q" name="q" value="{$q}" class="form-
control" placeholder="Pencarian : Nomor PO" style="float: right;
width: 270px;" required>
<a href="spb.php?module=spb&act=add" style="float: left;"><button
type="button" class="btn btn-default pull-right"><i class="fa fa-
plus"></i> Add</button></a>
<a href="print_spb.php?act=print&q={$q}&startDate={$startDate}&
endDate={$endDate}" style="float: left;" target="_blank"><button
type="button" class="btn btn-default pull-right"><i class="fa fa-
print"></i> Print PDF</button></a>
</form>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NO PO <i class="fa fa-sort"></i></th>
<th>TGL PO <i class="fa fa-sort"></i></th>
<th>TGL DIBUTUHKAN <i class="fa fa-sort"></i></th>
<th>SUPPLIER <i class="fa fa-sort"></i></th>
<th>STATUS <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataSpb loop=$dataSpb}
<tr>
<td>{$dataSpb[dataSpb].no}</td>
<td>{$dataSpb[dataSpb].spbNo}</td>
<td>{$dataSpb[dataSpb].orderDate}</td>
<td>{$dataSpb[dataSpb].needDate}</td>
<td>{$dataSpb[dataSpb].supplierName}</td>
<td>{$dataSpb[dataSpb].status}</td>
<td>{$dataSpb[dataSpb].staffName}</td>
<td>
<a title="Detail" href="spb.php?module=spb&act=detailtrf&spbID={
$dataSpb[dataSpb].spbID}&spbFaktur={$dataSpb[dataSpb].spbFaktur}&q
={$q}&page={$page}"><img src="img/icons/view.png" width="18"></a>
<a title="Delete" href="spb.php?module=spb&act=delete&spbID={
$dataSpb[dataSpb].spbID}&spbFaktur={$dataSpb[dataSpb].spbFaktur}&s
pbNo={$dataSpb[dataSpb].spbNo}" onclick="return confirm('Anda
Yakin ingin menghapus transaksi {$dataSpb[dataSpb].spbNo}?');">
<img src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
152
</div>
</div><!-- /.box-body -->
{else}
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<form method="GET" action="spb.php">
<input type="hidden" name="module" value="spb">
<input type="hidden" name="act" value="search">
<button type="submit" class="btn btn-default pull-
right"><i class="fa fa-search"></i> Search</button>
<input type="text" id="endDate" name="endDate" value="{$endDate}"
class="form-control" placeholder="Periode Akhir" style="float:
right; width: 115px;">
<input type="text" id="startDate" name="startDate"
value="{$startDate}" class="form-control" placeholder="Periode
Awal" style="float: right; width: 115px;">
<input type="text" id="q" name="q" value="{$q}" class="form-
control" placeholder="Pencarian : Nomor PO" style="float: right;
width: 270px;">
<a href="spb.php?module=spb&act=add" style="float: left;"><button
type="button" class="btn btn-default pull-right"><i class="fa fa-
plus"></i> Add</button></a>
<a href="print_spb.php?act=print&q={$q}" style="float: left;"
target="_blank"><button type="button" class="btn btn-default pull-
right"><i class="fa fa-print"></i> Print PDF</button></a>
</form>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NO PO <i class="fa fa-sort"></i></th>
<th>TGL PO <i class="fa fa-sort"></i></th>
<th>TGL DIBUTUHKAN <i class="fa fa-sort"></i></th>
<th>SUPPLIER <i class="fa fa-sort"></i></th>
<th>STATUS <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataSpb loop=$dataSpb}
<tr>
<td>{$dataSpb[dataSpb].no}</td>
<td>{$dataSpb[dataSpb].spbNo}</td>
<td>{$dataSpb[dataSpb].orderDate}</td>
<td>{$dataSpb[dataSpb].needDate}</td>
<td>{$dataSpb[dataSpb].supplierName}</td>
<td>{$dataSpb[dataSpb].status}</td>
153
<td>{$dataSpb[dataSpb].staffName}</td>
<td>
<a title="Detail" href="spb.php?module=spb&act=detailtrf&spbID={
$dataSpb[dataSpb].spbID}&spbFaktur={$dataSpb[dataSpb].spbFaktur}&p
age={$page}"><img src="img/icons/view.png" width="18"></a>
<a title="Delete" href="spb.php?module=spb&act=delete&spbID={
$dataSpb[dataSpb].spbID}&spbFaktur={$dataSpb[dataSpb].spbFaktur}&s
pbNo={$dataSpb[dataSpb].spbNo}" onclick="return confirm('Anda
Yakin ingin menghapus transaksi {$dataSpb[dataSpb].spbNo}?');">
<img src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-left">
<ul class="pagination pagination-sm inline">
{$pageLink}
</ul>
</div>
</div><!-- /.box-header -->
{/if}
{include file="footer.tpl"}
save_spb.php
<?php
// include header
include "header.php";
$productID = $_POST['productID'];
$spbNo = $_POST['spbNo'];
$productName = mysqli_real_escape_string($connect,
$_POST['productName1']);
$qty = $_POST['qty'];
$price = $_POST['price'];
$note = mysqli_real_escape_string($connect, $_POST['desc']);
$spbFaktur = $_SESSION['spbFaktur'];
154
if ($productID != '' && $spbNo != '' && $qty != ''){
if ($sqlSpb)
{
echo json_encode(OK);
}
}
exit();
?>
edit_spb.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "edit_spb.tpl";
else
{
// get variable
$module = $_GET['module'];
$act = $_GET['act'];
155
if ($module == 'spb' && $act == 'edit')
{
// insert method into a variable
$detailID = $_GET['detailID'];
// fetch data
$dataSpb = mysqli_fetch_array($sqlSpb);
} // close bracket
// include footer
include "footer.php";
?>
156
<script type="text/javascript" src="design/js/fancybox/jquery
.fancybox.js?v=2.0.6"></script>
$.ajax({
type: 'POST',
url: 'save_edit_spb.php',
dataType: 'JSON',
data:{
detailID: detailID,
qty: qty,
price: price,
desc: desc
},
beforeSend: function (data) {
$('#send').hide();
},
success: function(data) {
parent.jQuery.fancybox.close();
}
});
}
});
});
</script>
{/literal}
157
<td><input type="text" id="productBarcode"
value="{$productID}" name="productBarcode" class="form-control"
style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td colspan="2"></td>
<td><input type="text" value="{$productName}"
id="productName" name="productName" class="form-control"
placeholder="Nama Produk" style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>Harga Satuan</td>
<td>:</td>
<td><input type="number" value="{$price}"
id="price" name="price" class="form-control" placeholder="Harga
Satuan" style="width: 270px;" required></td>
</tr>
<tr>
<td>Qty</td>
<td>:</td>
<td><input type="number" value="{$qty}" id="qty"
name="qty" class="form-control" placeholder="Qty Produk"
style="width: 270px;" required></td>
</tr>
<tr>
<td>Note</td>
<td>:</td>
<td><input type="text" value="{$note}" id="desc" name="desc"
class="form-control" placeholder="Note" style="width:
270px;"></td>
</tr>
</table>
<button id="send" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
{/if}
</body>
save_edit_spb.php
<?php
// include header
include "header.php";
158
'$price',
qty = '$qty',
note = '$note',
modifiedDate = '$modified_date',
modifiedUserID = '$staffID'
WHERE detailID = '$detailID'";
if ($sqlSpb)
{
echo json_encode(OK);
}
}
exit();
?>
Hasil skrip diatas akan menghasilkan proses purchase order yang bisa dilihat
pada gambar-gambar berikut :
159
Gambar 5.23. Menambah barang purchase order
$module = $_GET['module'];
$act = $_GET['act'];
160
{
// show up the text and exit
echo "Anda tidak berhak akses modul ini.";
exit();
}
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE modulID =
'13'";
$sqlAuthorizeStaff = mysqli_query($connect, $queryAuthorizeStaff);
$dataAuthorizeStaff = mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
// fetch data
while ($dataBD = mysqli_fetch_array($sqlBD))
{
$querySP = "UPDATE as_stock_products SET stock=stock-
$dataBD[receiveQty] WHERE productID = '$dataBD[productID]' AND
factoryID = '$dataBD[factoryID]'";
mysqli_query($connect, $querySP);
}
// delete bbm
$queryBbm = "DELETE FROM as_bbm WHERE bbmID = '$bbmID' AND
bbmNo = '$bbmNo' AND bbmFaktur = '$bbmFaktur'";
$sqlBbm = mysqli_query($connect, $queryBbm);
161
$bbmFaktur = $_SESSION['bbmFaktur'];
$modifiedDate = date('Y-m-d H:i:s');
$staffID = $_SESSION['staffID'];
$sName = $_SESSION['staffCode']." ".$_SESSION['staffName'];
$bbmNo = $_POST['bbmNo'];
$bbmID = $_POST['bbmID'];
$spbNo = $_POST['spbNo'];
$supplierID = $_POST['supplierID'];
$supplierName = $_POST['supplierName'];
$supplierAddress = mysqli_real_escape_string($connect,
$_POST['supplierAddress']);
$rDate = explode("-", $_POST['receiveDate']);
$receiveDate = $rDate[2]."-".$rDate[1]."-".$rDate[0];
$oDate = explode("-", $_POST['orderDate']);
$orderDate = $oDate[2]."-".$oDate[1]."-".$oDate[0];
$nDate = explode("-", $_POST['needDate']);
$needDate = $nDate[2]."-".$nDate[1]."-".$nDate[0];
$note = mysqli_real_escape_string($connect, $_POST['note']);
$detailID = $_POST['detailID'];
$countDetailID = COUNT($detailID);
$productID = $_POST['productID'];
$productName = $_POST['productName'];
$price = $_POST['price'];
$qty = $_POST['qty'];
$receiveQty = $_POST['receiveQty'];
$status = $_POST['status'];
$factory = $_POST['factory'];
$notedetail = $_POST['notedetail'];
$dataSpb = mysqli_fetch_array(mysqli_query($connect,
"SELECT spbID FROM as_spb WHERE spbNo = '$spbNo'"));
162
'$productID[$i]',
'$productNm',
'$price[$i]',
'$qty[$i]',
'$receiveQty[$i]',
'$status[$i]',
'$factoryID',
'$factoryName',
'$notedet',
'$modifiedDate',
'$staffID')";
mysqli_query($connect, $queryInsert);
$queryStock = "UPDATE as_stock_products SET
stock=stock+$receiveQty[$i] WHERE factoryID = '$factoryID' AND
productID = '$productID[$i]'";
mysqli_query($connect, $queryStock);
$grandtotal += $total;
}
// update bbm
$queryBbm = "UPDATE as_bbm SET spbID = '$dataSpb[spbID]',
spbNo = '$spbNo',
supplierID = '$supplierID',
supplierName = '$supplierName',
supplierAddress = '$supplierAddress',
staffID = '$staffID',
staffName = '$sName',
receiveDate = '$receiveDate',
orderDate = '$orderDate',
needDate = '$needDate',
total = '$grandtotal',
note = '$note',
modifiedDate = '$modifiedDate',
modifiedUserID = '$staffID'
WHERE bbmID = '$bbmID' AND bbmFaktur = '$bbmFaktur'";
$sqlBbm = mysqli_query($connect, $queryBbm);
$_SESSION['bbmFaktur'] = "";
header("Location: bbm.php?module=bbm&act=finish&bbmNo=".
$bbmNo."&bbmFaktur=".$bbmFaktur);
}
163
$smarty->assign("bbmFaktur", $dataBbm['bbmFaktur']);
$smarty->assign("bbmID", $dataBbm['bbmID']);
$smarty->assign("bbmNo", $dataBbm['bbmNo']);
$smarty->assign("spbID", $dataBbm['spbID']);
$smarty->assign("spbNo", $dataBbm['spbNo']);
$smarty->assign("supplierID", $dataBbm['supplierID']);
$smarty->assign("supplierName", $dataBbm['supplierName']);
$smarty->assign("supplierAddress", $dataBbm['supplierAddress']);
$smarty->assign("staffID", $dataBbm['staffID']);
$smarty->assign("staffName", $dataBbm['staffName']);
$smarty->assign("receiveDate",
tgl_indo2($dataBbm['receiveDate']));
$smarty->assign("orderDate", tgl_indo2($dataBbm['orderDate']));
$smarty->assign("needDate", tgl_indo2($dataBbm['needDate']));
$smarty->assign("note", $dataBbm['note']);
$i = 1;
while ($dtBbmDetail = mysqli_fetch_array($sqlBbmDetail))
{
$dataBbmDetail[] = array( 'detailID' =>
$dtBbmDetail['detailID'],
'bbmNo' => $dtBbmDetail['bbmNo'],
'bbmFaktur' => $dtBbmDetail['bbmFaktur'],
'productID' => $dtBbmDetail['productID'],
'productName' => $dtBbmDetail['productName'],
'price' => $dtBbmDetail['price'],
'qty' => $dtBbmDetail['qty'],
'receiveQty' => $dtBbmDetail['receiveQty'],
'status' => $dtBbmDetail['receiveStatus'],
'factoryID' => $dtBbmDetail['factoryID'],
'factoryName' => $dtBbmDetail['factoryName'],
'note' => $dtBbmDetail['note'],
'no' => $i
);
$i++;
}
$smarty->assign("dataBbmDetail", $dataBbmDetail);
$smarty->assign("page", $_GET['page']);
$smarty->assign("q", $_GET['q']);
164
// delete bbm
$queryBbm = "DELETE FROM as_bbm WHERE bbmFaktur = '$bbmFaktur'";
$sqlBbm = mysqli_query($connect, $queryBbm);
$_SESSION['bbmFaktur'] = "";
header("Location: bbm.php");
}
$smarty->assign("bbmID", $dataBbm['bbmID']);
$smarty->assign("bbmNo", $dataBbm['bbmNo']);
$smarty->assign("bbmFaktur", $dataBbm['bbmFaktur']);
$smarty->assign("spbID", $dataBbm['spbID']);
$smarty->assign("spbNo", $dataBbm['spbNo']);
$smarty->assign("supplierID", $dataBbm['supplierID']);
$smarty->assign("supplierName", $dataBbm['supplierName']);
$smarty->assign("staffID", $dataBbm['staffID']);
$smarty->assign("staffName", $dataBbm['staffName']);
$smarty->assign("receiveDate",
tgl_indo2($dataBbm['receiveDate']));
$smarty->assign("orderDate", tgl_indo2($dataBbm['orderDate']));
$smarty->assign("needDate", tgl_indo2($dataBbm['needDate']));
$smarty->assign("note", $dataBbm['note']);
// fetch data
$k = 1;
while ($dtBbmDetail = mysqli_fetch_array($sqlBbmDetail))
{
if ($dtBbmDetail['receiveStatus'] == 'Y')
{
$status = "Y";
}
else
{
$status = "N";
}
165
'productName' => $dtBbmDetail['productName'],
'price' => rupiah($dtBbmDetail['price']),
'qty' => $dtBbmDetail['qty'],
'receiveQty' => $dtBbmDetail['receiveQty'],
'status' => $status,
'factoryName' => $dtBbmDetail['factoryName'],
'note' => $dtBbmDetail['note'],
'no' => $k
);
$k++;
}
$smarty->assign("dataBbmDetail", $dataBbmDetail);
$smarty->assign("breadcumbTitle", "Bukti Barang Masuk");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi penerimaan barang / bukti barang masuk.");
$smarty->assign("breadcumbMenuName", "Bukti Barang Masuk");
$smarty->assign("breadcumbMenuSubName", "Bukti Barang Masuk");
}
$start = substr($dataNoBbm['bbmNo'],0-5);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoBbm == '0')
{
$bbmNo = "00000";
}
elseif ($tempNo == 1)
{
$bbmNo = "00000";
}
elseif ($tempNo == 2)
{
$bbmNo = "0000";
}
elseif ($tempNo == 3)
{
$bbmNo = "000";
}
elseif ($tempNo == 4)
{
$bbmNo = "00";
}
elseif ($tempNo == 5)
166
{
$bbmNo = "0";
}
elseif ($tempNo == 6)
{
$bbmNo = "";
}
$bbmCode = "BB".$bbmNo.$next;
if ($numsBbm == 0)
{
$receiveDate = date('Y-m-d');
$sName = $_SESSION['staffCode']." ".$_SESSION['staffName'];
$queryBbm = "INSERT INTO as_bbm(bbmFaktur,
bbmNo,
spbID,
spbNo,
supplierID,
supplierName,
staffID,
staffName,
receiveDate,
orderDate,
needDate,
total,
note,
createdDate,
createdUserID,
modifiedDate,
modifiedUserID)
VALUES( '$bbmFaktur',
'$bbmCode',
'',
'',
'',
'',
'$_SESSION[staffID]',
'$sName',
'$receiveDate',
'',
'',
'',
'',
'$createdDate',
'$staffID',
'',
'')";
mysqli_query($connect, $queryBbm);
}
167
$showBbm = "SELECT * FROM as_bbm WHERE bbmFaktur = '$bbmFaktur'";
$sqlBbm = mysqli_query($connect, $showBbm);
$dataBbm = mysqli_fetch_array($sqlBbm);
$smarty->assign("bbmNo", $dataBbm['bbmNo']);
$smarty->assign("bbmID", $dataBbm['bbmID']);
if ($dataBbm['receiveDate'] == '0000-00-00')
{
$receiveDate = date('Y-m-d');
}
else
{
$receiveDate = $dataBbm['receiveDate'];
}
$smarty->assign("receiveDate", tgl_indo2($receiveDate));
$smarty->assign("note", $dataBbm['note']);
$smarty->assign("numsSpb", $numsSpb);
$smarty->assign("numsBbm", $numsBbm);
168
'price' => $dataSpbDetail['price'],
'qty' => $dataSpbDetail['qty'],
'subtotal' => $subtotal,
'note' => $dataSpbDetail['note'],
'no' => $i
);
$i++;
}
$smarty->assign("dataFactory", $dataFactory);
$smarty->assign("startDate", $sDate);
$smarty->assign("endDate", $eDate);
$startDate = $s2Date[2]."-".$s2Date[1]."-".$s2Date[0];
$endDate = $e2Date[2]."-".$e2Date[1]."-".$e2Date[0];
169
else
{
$queryBbm = "SELECT * FROM as_bbm WHERE bbmNo LIKE
'%$q%' ORDER BY bbmID DESC";
}
$sqlBbm = mysqli_query($connect, $queryBbm);
// fetch data
$i = 1 + $position;
while ($dtBbm = mysqli_fetch_array($sqlBbm))
{
$dataBbm[] = array( 'bbmID' => $dtBbm['bbmID'],
'bbmNo' => $dtBbm['bbmNo'],
'bbmFaktur' => $dtBbm['bbmFaktur'],
'spbID' => $dtBbm['spdID'],
'spbNo' => $dtBbm['spbNo'],
'supplierID' => $dtBbm['supplierID'],
'supplierName' => $dtBbm['supplierName'],
'staffID' => $dtBbm['staffID'],
'staffName' => $dtBbm['staffName'],
'receiveDate' => tgl_indo2($dtBbm['receiveDate']),
'note' => $dtBbm['note'],
'no' => $i);
$i++;
}
$smarty->assign("dataBbm", $dataBbm);
$smarty->assign("page", $_GET['page']);
$smarty->assign("q", $q);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Bukti Barang Masuk");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi penerimaan barang / bukti barang masuk.");
$smarty->assign("breadcumbMenuName", "Bukti Barang Masuk");
$smarty->assign("breadcumbMenuSubName", "Bukti Barang Masuk");
}
else
{
$bbmFaktur = date('Ymdhis');
$_SESSION['bbmFaktur'] = $bbmFaktur;
// fetch data
$i = 1 + $position;
170
while ($dtBbm = mysqli_fetch_array($sqlBbm))
{
$dataBbm[] = array( 'bbmID' => $dtBbm['bbmID'],
'bbmNo' => $dtBbm['bbmNo'],
'bbmFaktur' => $dtBbm['bbmFaktur'],
'spbID' => $dtBbm['spdID'],
'spbNo' => $dtBbm['spbNo'],
'supplierID' => $dtBbm['supplierID'],
'supplierName' => $dtBbm['supplierName'],
'staffID' => $dtBbm['staffID'],
'staffName' => $dtBbm['staffName'],
'receiveDate' => tgl_indo2($dtBbm['receiveDate']),
'note' => $dtBbm['note'],
'no' => $i);
$i++;
}
$smarty->assign("dataBbm", $dataBbm);
// count data
$queryCountBbm = "SELECT * FROM as_bbm";
$sqlCountBbm = mysqli_query($connect, $queryCountBbm);
$amountData = mysqli_num_rows($sqlCountBbm);
$smarty->assign("pageLink", $pageLink);
$smarty->assign("page", $_GET['page']);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Bukti Barang Masuk");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi penerimaan barang / bukti barang masuk.");
$smarty->assign("breadcumbMenuName", "Bukti Barang Masuk");
$smarty->assign("breadcumbMenuSubName", "Bukti Barang Masuk");
}
$smarty->assign("module", $module);
$smarty->assign("act", $act);
}
// include footer
include "footer.php";
?>
<style>
div.ui-datepicker{
font-size:14px;
}
</style>
171
<link rel="stylesheet" type="text/css" media="all"
href="design/js/fancybox/jquery.fancybox.css">
<script type="text/javascript" src="design/js/fancybox/jquery
.fancybox.js?v=2.0.6"></script>
<script type='text/javascript' src="design/js/jquery
.autocomplete.js"></script>
<link rel="stylesheet" type="text/css"
href="design/css/jquery.autocomplete.css" />
{literal}
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$( "#receiveDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c-1:c-0'
});
$( "#startDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$( "#endDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$('#receiveDate').change(function () {
var bbmNo = $("#bbmNo").val();
var bbmID = $("#bbmID").val();
var spbNo = $("#spbNo").val();
var receiveDate = $("#receiveDate").val();
$.ajax({
type: 'POST',
url: 'save_bbm_receivedate.php',
dataType: 'JSON',
data:{
172
bbmNo: bbmNo,
bbmID: bbmID,
receiveDate: receiveDate
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "bbm.php?module=bbm&act=add&spbNo=" +
spbNo;
}
});
});
$('#note').change(function () {
var bbmNo = $("#bbmNo").val();
var bbmID = $("#bbmID").val();
var spbNo = $("#spbNo").val();
var note = $("#note").val();
$.ajax({
type: 'POST',
url: 'save_bbm_note.php',
dataType: 'JSON',
data:{
bbmNo: bbmNo,
bbmID: bbmID,
spbNo: spbNo,
note: note
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "bbm.php?module=bbm&act=add&spbNo=" +
spbNo;
}
});
});
$('#spbNo').change(function () {
var spbNo = $("#spbNo").val();
window.location.href = "bbm.php?module=bbm&act=add&spbNo=" +
spbNo;
});
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#send2").on("click", function(){
var bbmNo = $("#bbmNo").val();
var productID = $("#productID").val();
var productName1 = $("#productName1").val();
var qty = parseInt($("#qty").val());
var price = parseInt($("#price").val());
var desc = $("#desc").val();
173
if (qty != '' && spbNo != '' && productID != '' && price != ''){
$.ajax({
type: 'POST',
url: 'save_spb.php',
dataType: 'JSON',
data:{
qty: qty,
price: price,
spbNo: spbNo,
productID: productID,
productName1: productName1,
desc: desc
},
beforeSend: function (data) {
$('#send2').hide();
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "spb.php?module=spb&act=add";
}
});
}
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
{include file="user_panel.tpl"}
{include file="side_menu.tpl"}
</section>
<!-- /.sidebar -->
</aside>
<aside class="right-side">
{include file="breadcumb.tpl"}
174
<!-- TO DO List -->
<div class="box box-primary">
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Tambah Penerimaan Barang</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="bbm.php?module=bbm&act=cancel" onclick="return
confirm('Anda Yakin ingin membatalkan bukti barang masuk
ini?');"><button class="btn btn-default pull-right">Batal
Trx</button></a>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<form method="POST" action="bbm.php?module=bbm&act=input">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="150">ID / TGL PENERIMAAN</td>
<td width="5">:</td>
<td><input type="hidden" id="bbmNo" name="bbmNo" value="{$bbmNo}">
<input type="hidden" id="bbmID" name="bbmID" value="{$bbmID}">
<input type="text" id="bbmNo" name="bbmNo" value="{$bbmNo}"
class="form-control" placeholder="ID BBM" style="width: 110px;
float: left" DISABLED>
<input type="text" id="receiveDate" name="receiveDate"
value="{$receiveDate}" class="form-control" placeholder="Tanggal
Penerimaan" style="width: 160px;" required>
</td>
</tr>
<tr valign="top">
<td>NO PO</td>
<td>:</td>
<td><input type="text" id="spbNo" name="spbNo"
value="{$spbNo}" class="form-control" placeholder="Nomor PO"
style="width: 270px;" required>
{if $numsSpb == '0' AND $spbNo != ''}
175
<font color="#f56954">Nomor PO tidak ditemukan.</font>
{/if}
176
{else}
<input type="text" id="note" name="note" class="form-control"
placeholder="Note" style="width: 270px;">
{/if}</td>
</tr>
<tr>
<td colspan="3">
<br>
</td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>NOTE</th>
<th>JML ORDER</th>
<th>JML DITERIMA</th>
<th>TERIMA</th>
<th>GUDANG</th>
</tr>
</thead>
<tbody>
{if $numsBbm == '0' AND $spbNo != ''}
{section name=dataDetail loop=$dataDetail}
<tr>
<td>{$dataDetail[dataDetail].no} <input type="hidden"
name="detailID[]" id="detailID" value="{$dataDetail[dataDetail]
.detailID}"></td>
<td>{$dataDetail[dataDetail].productName} <input type="hidden"
name="productName[]" id="productName"
value="{$dataDetail[dataDetail].productName}"> <input
type="hidden" name="productID[]" id="productID"
value="{$dataDetail[dataDetail].productID}"></td>
<td>{$dataDetail[dataDetail].note} <input type="hidden"
name="notedetail[]" id="notedetail" value="{$dataDetail[data
Detail].note}"></td>
<td style='text-align: center;'>{$dataDetail[dataDetail].qty}
<input type="hidden" name="qty[]" id="qty"
value="{$dataDetail[dataDetail].qty}"> <input type="hidden"
name="price[]" id="price" value="{$dataDetail[dataDetail].price}">
</td>
<td><input type="number" value="0" id="receiveQty"
name="receiveQty[]" class="form-control" placeholder="Jml"
style="width: 100px;" required></td>
<td>
<select id="status" name="status[]" class="form-control"
style="width: 100px;" required>
<option value=""></option>
<option value="Y">YA</option>
<option value="N">TIDAK</option>
</select>
</td>
<td>
177
<select id="factory" name="factory[]" class="form-control"
style="width: 180px;" required>
<option value=""></option>
{section name=dataFactory loop=$dataFactory}
<option value="{$dataFactory[dataFactory].factoryID}#{$dataFactory
[dataFactory].factoryCode}#{$dataFactory[dataFactory].factoryName}
">{$dataFactory[dataFactory].factoryCode} {$dataFactory[data
Factory].factoryName}</option>
{/section}
</select>
</td>
</tr>
{/section}
{/if}
</tbody>
</table>
</div>
<br><br>
{if $numsSpb > 0}
{if $numsBbm > 0 AND $spbNo != ''}
{else}
<button type="submit" class="btn btn-primary">Simpan</button>
{/if}
{/if}
</form>
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Bukti Penerimaan Barang</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="print_unit_bbm.php?module=bbm&act=print&bbmID={$bbmID}
&bbmNo={$bbmNo}&bbmFaktur={$bbmFaktur}" target="_blank"><button
class="btn btn-default pull-right">Print</button></a>
<a href="bbm.php"><button class="btn btn-default pull-
right">Close</button></a>
</div>
</div>
</div><!-- /.box-header -->
178
<div class="box-body">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="150">ID / TGL PENERIMAAN</td>
<td width="5">:</td>
<td><input type="text" id="bbmNo" name="bbmNo"
value="{$bbmNo}" class="form-control" placeholder="ID BBM"
style="width: 110px; float: left" DISABLED>
<input type="text" id="receiveDate" name="receiveDate"
value="{$receiveDate}" class="form-control" placeholder="Tanggal
Penerimaan" style="width: 160px;" DISABLED>
</td>
</tr>
<tr valign="top">
<td>NO PO</td>
<td>:</td>
<td><input type="text" id="spbNo" name="spbNo"
value="{$spbNo}" class="form-control" placeholder="Nomor PO"
style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>SUPPLIER</td>
<td>:</td>
<td><input type="text" id="supplierName"
name="supplierName" value="{$supplierName}" class="form-control"
placeholder="Supplier" style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>TGL PO/DIBUTUHKAN</td>
<td>:</td>
<td><input type="text" id="orderDate" name="orderDate"
value="{$orderDate}" class="form-control" placeholder="Tgl Order"
style="float: left; width: 135px;" DISABLED><input type="text"
id="orderDate" name="needDate" value="{$needDate}" class="form-
control" placeholder="Tgl Dibutuhkan" style="width: 135px;"
DISABLED></td>
</tr>
<tr>
<td>NOTE</td>
<td>:</td>
<td><input type="text" value="{$note}" id="note"
name="note" class="form-control" placeholder="Note" style="width:
270px;" DISABLED></td>
</tr>
<tr>
<td colspan="3">
<br>
</td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
179
<th>NOTE</th>
<th>JML ORDER</th>
<th>JML DITERIMA</th>
<th>TERIMA</th>
<th>GUDANG</th>
</tr>
</thead>
<tbody>
{section name=dataBbmDetail loop=$dataBbmDetail}
<tr>
<td>{$dataBbmDetail[dataBbmDetail].no}</td>
<td>{$dataBbmDetail[dataBbmDetail].productName}</td>
<td>{$dataBbmDetail[dataBbmDetail].note}</td>
<td style='text-align: center;'>{$dataBbmDetail[dataBbmDetail]
.qty}</td>
<td style='text-align: center;'>{$dataBbmDetail[dataBbmDetail]
.receiveQty}</td>
<td style='text-align: center;'>{$dataBbmDetail[dataBbmDetail]
.status}</td>
<td>{$dataBbmDetail[dataBbmDetail].factoryName}</td>
</tr>
{/section}
</tbody>
</table>
</div>
<div class="box-body">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="150">ID / TGL PENERIMAAN</td>
<td width="5">:</td>
<td><input type="text" id="bbmNo" name="bbmNo"
value="{$bbmNo}" class="form-control" placeholder="ID BBM"
style="width: 110px; float: left" DISABLED>
180
<input type="text" id="receiveDate" name="receiveDate"
value="{$receiveDate}" class="form-control" placeholder="Tanggal
Penerimaan" style="width: 160px;" DISABLED>
</td>
</tr>
<tr valign="top">
<td>NO PO</td>
<td>:</td>
<td><input type="text" id="spbNo" name="spbNo"
value="{$spbNo}" class="form-control" placeholder="Nomor PO"
style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>SUPPLIER</td>
<td>:</td>
<td><input type="text" id="supplierName"
name="supplierName" value="{$supplierName}" class="form-control"
placeholder="Supplier" style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>TGL PO/DIBUTUHKAN</td>
<td>:</td>
<td><input type="text" id="orderDate" name="orderDate"
value="{$orderDate}" class="form-control" placeholder="Tgl Order"
style="float: left; width: 135px;" DISABLED><input type="text"
id="orderDate" name="needDate" value="{$needDate}" class="form-
control" placeholder="Tgl Dibutuhkan" style="width: 135px;"
DISABLED></td>
</tr>
<tr>
<td>NOTE</td>
<td>:</td>
<td><input type="text" value="{$note}" id="note" name="note"
class="form-control" placeholder="Note" style="width: 270px;"
DISABLED></td>
</tr>
<tr>
<td colspan="3">
<br>
</td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>NOTE</th>
<th>JML ORDER</th>
<th>JML DITERIMA</th>
<th>TERIMA</th>
<th>GUDANG</th>
</tr>
</thead>
<tbody>
181
{section name=dataBbmDetail loop=$dataBbmDetail}
<tr>
<td>{$dataBbmDetail[dataBbmDetail].no}</td>
<td>{$dataBbmDetail[dataBbmDetail].productName}</td>
<td>{$dataBbmDetail[dataBbmDetail].note}</td>
<td style='text-align: center;'>{$dataBbmDetail[dataBbmDetail]
.qty}</td>
<td style='text-align: center;'>{$dataBbmDetail[dataBbmDetail]
.receiveQty}</td>
<td style='text-align: center;'>{$dataBbmDetail[dataBbmDetail]
.status}</td>
<td>{$dataBbmDetail[dataBbmDetail].factoryName}</td>
</tr>
{/section}
</tbody>
</table>
</div>
</div><!-- /.box-body -->
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NO BBM <i class="fa fa-sort"></i></th>
182
<th>NO PO <i class="fa fa-sort"></i></th>
<th>SUPPLIER <i class="fa fa-sort"></i></th>
<th>TGL PENERIMAAN <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataBbm loop=$dataBbm}
<tr>
<td>{$dataBbm[dataBbm].no}</td>
<td>{$dataBbm[dataBbm].bbmNo}</td>
<td>{$dataBbm[dataBbm].spbNo}</td>
<td>{$dataBbm[dataBbm].supplierName}</td>
<td>{$dataBbm[dataBbm].receiveDate}</td>
<td>{$dataBbm[dataBbm].staffName}</td>
<td>
<a title="Detail" href="bbm.php?module=bbm&act=detailbbm&bbmID=
{$dataBbm[dataBbm].bbmID}&bbmNo={$dataBbm[dataBbm].bbmNo}&bbmFaktu
r={$dataBbm[dataBbm].bbmFaktur}&q={$q}&page={$page}"><img
src="img/icons/view.png" width="18"></a>
<a title="Delete" href="bbm.php?module=bbm&act=delete&bbmID=
{$dataBbm[dataBbm].bbmID}&bbmFaktur={$dataBbm[dataBbm].bbmFaktur}&
bbmNo={$dataBbm[dataBbm].bbmNo}" onclick="return confirm('Anda
Yakin ingin membatalkan transaksi {$dataBbm[dataBbm].bbmNo}?');">
<img src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
183
<a href="print_bbm.php?act=print&q={$q}&startDate={$startDate}
&endDate={$endDate}" style="float: left;" target="_blank"><button
type="button" class="btn btn-default pull-right"><i class="fa fa-
print"></i> Print PDF</button></a>
</form>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NO BBM <i class="fa fa-sort"></i></th>
<th>NO PO <i class="fa fa-sort"></i></th>
<th>SUPPLIER <i class="fa fa-sort"></i></th>
<th>TGL PENERIMAAN <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataBbm loop=$dataBbm}
<tr>
<td>{$dataBbm[dataBbm].no}</td>
<td>{$dataBbm[dataBbm].bbmNo}</td>
<td>{$dataBbm[dataBbm].spbNo}</td>
<td>{$dataBbm[dataBbm].supplierName}</td>
<td>{$dataBbm[dataBbm].receiveDate}</td>
<td>{$dataBbm[dataBbm].staffName}</td>
<td>
<a title="Detail" href="bbm.php?module=bbm&act=detailbbm&bbmID=
{$dataBbm[dataBbm].bbmID}&bbmNo={$dataBbm[dataBbm].bbmNo}&bbmFaktu
r={$dataBbm[dataBbm].bbmFaktur}&page={$page}"><img
src="img/icons/view.png" width="18"></a>
<a title="Delete" href="bbm.php?module=bbm&act=delete&bbmID=
{$dataBbm[dataBbm].bbmID}&bbmFaktur={$dataBbm[dataBbm].bbmFaktur}&
bbmNo={$dataBbm[dataBbm].bbmNo}" onclick="return confirm('Anda
Yakin ingin membatalkan transaksi {$dataBbm[dataBbm].bbmNo}?');">
<img src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-left">
<ul class="pagination pagination-sm inline">
{$pageLink}
</ul>
184
</div>
</div><!-- /.box-header -->
{/if}
{include file="footer.tpl"}
Hasil seluruh skrip diatas akan menghasilkan halaman penerimaan barang yang
bisa dilihat pada gambar-gambar berikut :
185
Gambar 5.25. Cetak bukti penerimaan barang
$module = $_GET['module'];
$act = $_GET['act'];
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE modulID =
'8'";
$sqlAuthorizeStaff = mysqli_query($connect, $queryAuthorizeStaff);
$dataAuthorizeStaff = mysqli_fetch_array($sqlAuthorizeStaff);
186
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
// delete invoice
$queryInvoice = "DELETE FROM as_buy_transactions WHERE
invoiceID = '$inID' AND invoiceNo = '$inNo'";
$sqlInvoice = mysqli_query($connect, $queryInvoice);
// delete debt
$queryDebt = "DELETE FROM as_debts WHERE invoiceID =
'$inID' AND invoiceNo = '$inNo'";
$sqlDebt = mysqli_query($connect, $queryDebt);
187
// redirect to the in page
header("Location: in.php");
}
$start = substr($dataNoDebt['debtNo'],2-7);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoDebt == '0')
{
$deNo = "00000";
}
elseif ($tempNo == 1)
{
$deNo = "00000";
}
elseif ($tempNo == 2)
{
$deNo = "0000";
}
elseif ($tempNo == 3)
188
{
$deNo = "000";
}
elseif ($tempNo == 4)
{
$deNo = "00";
}
elseif ($tempNo == 5)
{
$deNo = "0";
}
elseif ($tempNo == 6)
{
$deNo = "";
}
$debtNo = "DB".$deNo.$next;
189
'$staffID',
'',
'')";
$invoiceID = mysqli_insert_id($connect);
if ($sqlBuy)
{
VALUES( '$debtNo',
'$invoiceID',
'$invoiceNo',
'$supplierID',
'$supplierName',
'$supplierAddress',
'$grandtotal',
'0',
'1',
'$staffID',
'$sName',
'$createdDate',
'$staffID',
'',
'')";
mysqli_query($connect, $queryDebt);
190
}
header("Location:
in.php?module=in&act=finish&bbmNo=".$bbmNo."&invoiceNo=".$invoiceN
o."&invoiceID=".$invoiceID);
}
if ($dataBuy['paymentType'] == '1')
{
$paymentType = "TUNAI";
$expiredPayment = "";
}
else
{
$paymentType = "TERMIN";
$expiredPayment = tgl_indo2($dataBuy['expiredPayment']);
}
if ($dataBuy['ppnType'] == '1')
{
$ppnType = "PPN";
$ppn = rupiah($dataBuy['ppn']);
}
else
{
$ppnType = "NO PPN";
$ppn = rupiah(0);
}
191
$smarty->assign("grandtotal", rupiah($dataBuy['grandtotal']));
$smarty->assign("pay", rupiah($dataBuy['pay']));
$smarty->assign("supplierID", $dataBuy['supplierID']);
$smarty->assign("supplierName", $dataBuy['supplierName']);
$smarty->assign("supplierAddress", $dataBuy['supplierAddress']);
$smarty->assign("staffID", $dataBuy['staffID']);
$smarty->assign("staffName", $dataBuy['staffName']);
// show debt
$queryDebt = "SELECT debtTotal FROM as_debts WHERE invoiceNo =
'$_GET[invoiceNo]' AND invoiceID = '$_GET[invoiceID]'";
$sqlDebt = mysqli_query($connect, $queryDebt);
$dataDebt = mysqli_fetch_array($sqlDebt);
$smarty->assign("debt", rupiah($dataDebt['debtTotal']));
$i = 1;
while ($dtBbmDetail = mysqli_fetch_array($sqlBbmDetail))
{
$subtotal = rupiah($dtBbmDetail['receiveQty'] *
$dtBbmDetail['price']);
$dataBbmDetail[] = array( 'detailID' =>
$dtBbmDetail['detailID'],
'bbmNo' => $dtBbmDetail['bbmNo'],
'bbmFaktur' => $dtBbmDetail['bbmFaktur'],
'productID' => $dtBbmDetail['productID'],
'productName' => $dtBbmDetail['productName'],
'pricerp' => rupiah($dtBbmDetail['price']),
'qty' => $dtBbmDetail['qty'],
'receiveQty' => $dtBbmDetail['receiveQty'],
'subtotal' => $subtotal,
'no' => $i
);
$i++;
}
$smarty->assign("dataBbmDetail", $dataBbmDetail);
$smarty->assign("page", $_GET['page']);
$smarty->assign("q", $q);
192
$invoiceID = $_GET['invoiceID'];
$invoiceNo = $_GET['invoiceNo'];
if ($dataBuy['paymentType'] == '1')
{
$paymentType = "TUNAI";
$expiredPayment = "";
}
else
{
$paymentType = "TERMIN";
$expiredPayment = tgl_indo2($dataBuy['expiredPayment']);
}
if ($dataBuy['ppnType'] == '1')
{
$ppnType = "PPN";
$ppn = rupiah($dataBuy['ppn']);
}
else
{
$ppnType = "NO PPN";
$ppn = rupiah(0);
}
// show debt
$queryDebt = "SELECT debtTotal FROM as_debts WHERE invoiceNo =
'$_GET[invoiceNo]' AND invoiceID = '$_GET[invoiceID]'";
$sqlDebt = mysqli_query($connect, $queryDebt);
193
$dataDebt = mysqli_fetch_array($sqlDebt);
$smarty->assign("debt", rupiah($dataDebt['debtTotal']));
$i = 1;
while ($dtBbmDetail = mysqli_fetch_array($sqlBbmDetail))
{
$subtotal = rupiah($dtBbmDetail['receiveQty'] *
$dtBbmDetail['price']);
$dataBbmDetail[] = array( 'detailID' =>
$dtBbmDetail['detailID'],
'bbmNo' => $dtBbmDetail['bbmNo'],
'bbmFaktur' => $dtBbmDetail['bbmFaktur'],
'productID' => $dtBbmDetail['productID'],
'productName' => $dtBbmDetail['productName'],
'pricerp' => rupiah($dtBbmDetail['price']),
'qty' => $dtBbmDetail['qty'],
'receiveQty' => $dtBbmDetail['receiveQty'],
'subtotal' => $subtotal,
'no' => $i
);
$i++;
}
$smarty->assign("dataBbmDetail", $dataBbmDetail);
$smarty->assign("page", $_GET['page']);
$smarty->assign("breadcumbTitle", "Transaksi Pembelian");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi pembelian, faktur pembelian.");
$smarty->assign("breadcumbMenuName", "Transaksi Pembelian");
$smarty->assign("breadcumbMenuSubName", "Transaksi Pembelian");
}
$start = substr($dataNoIn['invoiceNo'],2-7);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoIn == '0')
{
$inNo = "00000";
}
elseif ($tempNo == 1)
194
{
$inNo = "00000";
}
elseif ($tempNo == 2)
{
$inNo = "0000";
}
elseif ($tempNo == 3)
{
$inNo = "000";
}
elseif ($tempNo == 4)
{
$inNo = "00";
}
elseif ($tempNo == 5)
{
$inNo = "0";
}
elseif ($tempNo == 6)
{
$inNo = "";
}
$invoiceNo = $inNo.$next;
$smarty->assign("invoiceNo", $invoiceNo);
$smarty->assign("invoiceDate", tgl_indo2(date('Y-m-d')));
$bbmNo = $_GET['bbmNo'];
$smarty->assign("numsBbm", $numsBbm);
$smarty->assign("numsBBuy", $numsBBuy);
195
$smarty->assign("receiveDate",
tgl_indo2($dataBbm['receiveDate']));
$smarty->assign("orderDate", tgl_indo2($dataBbm['orderDate']));
$smarty->assign("needDate", tgl_indo2($dataBbm['needDate']));
$smarty->assign("total", number_format($dataBbm['total'],
2, '.', ''));
$smarty->assign("totalrp", rupiah($dataBbm['total']));
$smarty->assign("note", $dataBbm['note']);
$i = 1;
while ($dtBbmDetail = mysqli_fetch_array($sqlBbmDetail))
{
$subtotal = $dtBbmDetail['receiveQty'] * $dtBbmDetail['price'];
$dataBbmDetail[] = array( 'detailID' =>
$dtBbmDetail['detailID'],
'bbmNo' => $dtBbmDetail['bbmNo'],
'bbmFaktur' => $dtBbmDetail['bbmFaktur'],
'productID' => $dtBbmDetail['productID'],
'productName' => $dtBbmDetail['productName'],
'price' => $dtBbmDetail['price'],
'pricerp' => rupiah($dtBbmDetail['price']),
'qty' => $dtBbmDetail['qty'],
'receiveQty' => $dtBbmDetail['receiveQty'],
'status' => $dtBbmDetail['receiveStatus'],
'factoryID' => $dtBbmDetail['factoryID'],
'factoryName' => $dtBbmDetail['factoryName'],
'subtotal' => rupiah($subtotal),
'note' => $dtBbmDetail['note'],
'no' => $i
);
$i++;
}
$smarty->assign("dataBbmDetail", $dataBbmDetail);
$smarty->assign("startDate", $sDate);
$smarty->assign("endDate", $eDate);
196
$e2Date = explode("-", $eDate);
$startDate = $s2Date[2]."-".$s2Date[1]."-".$s2Date[0];
$endDate = $e2Date[2]."-".$e2Date[1]."-".$e2Date[0];
// fetch data
$i = 1 + $position;
while ($dtBuy = mysqli_fetch_array($sqlBuy))
{
if ($dtBuy['paymentType'] == '1')
{
$paymentType = "TUNAI";
$expiredPayment = "";
}
else
{
$paymentType = "TERMIN";
$expiredPayment = tgl_indo2($dtBuy['expiredPayment']);
}
if ($dtBuy['ppnType'] == '1')
{
$ppnType = "PPN";
$ppn = rupiah($dtBuy['ppn']);
}
else
{
$ppnType = "NO PPN";
$ppn = "";
}
197
'staffID' => $dtBuy['staffID'],
'staffName' => $dtBuy['staffName'],
'no' => $i);
$i++;
}
$smarty->assign("dataBuy", $dataBuy);
$smarty->assign("page", $_GET['page']);
$smarty->assign("q", $q);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Transaksi Pembelian");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi pembelian, faktur pembelian.");
$smarty->assign("breadcumbMenuName", "Transaksi Pembelian");
$smarty->assign("breadcumbMenuSubName", "Transaksi Pembelian");
}
else
{
// create new object pagination
$p = new PaginationIn;
// limit 20 data for page
$limit = 30;
$position = $p->searchPosition($limit);
// fetch data
$i = 1 + $position;
while ($dtBuy = mysqli_fetch_array($sqlBuy))
{
if ($dtBuy['paymentType'] == '1')
{
$paymentType = "TUNAI";
$expiredPayment = "";
}
else
{
$paymentType = "TERMIN";
$expiredPayment =
tgl_indo2($dtBuy['expiredPayment']);
}
if ($dtBuy['ppnType'] == '1')
{
$ppnType = "PPN";
$ppn = rupiah($dtBuy['ppn']);
}
else
{
$ppnType = "NO PPN";
$ppn = "";
}
198
$dataBuy[] = array( 'invoiceID' => $dtBuy['invoiceID'],
'invoiceNo' => $dtBuy['invoiceNo'],
'invoiceDate' => tgl_indo2($dtBuy['invoiceDate']),
'bbmNo' => $dtBuy['bbmNo'],
'spbNo' => $dtBuy['spbNo'],
'paymentType' => $paymentType,
'expiredPayment' => $expiredPayment,
'ppnType' => $ppnType,
'ppn' => $ppn,
'total' => rupiah($dtBuy['total']),
'grandtotal' => rupiah($dtBuy['grandtotal']),
'pay' => rupiah($dtBuy['pay']),
'staffID' => $dtBuy['staffID'],
'staffName' => $dtBuy['staffName'],
'no' => $i);
$i++;
}
$smarty->assign("dataBuy", $dataBuy);
// count data
$queryCountBuy = "SELECT * FROM as_buy_transactions";
$sqlCountBuy = mysqli_query($connect, $queryCountBuy);
$amountData = mysqli_num_rows($sqlCountBuy);
$smarty->assign("pageLink", $pageLink);
$smarty->assign("page", $_GET['page']);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Transaksi Pembelian");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi pembelian, faktur pembelian.");
$smarty->assign("breadcumbMenuName", "Transaksi Pembelian");
$smarty->assign("breadcumbMenuSubName", "Transaksi Pembelian");
}
$smarty->assign("module", $module);
$smarty->assign("act", $act);
}
// include footer
include "footer.php";
?>
<style>
div.ui-datepicker{
font-size:14px;
}
199
</style>
{literal}
<script>
function toRp(amount, decimalSeparator, thousandsSeparator,
nDecimalDigits){
var num = parseFloat( amount ); //convert to float
//default values
decimalSeparator = decimalSeparator || ',';
thousandsSeparator = thousandsSeparator || ',';
nDecimalDigits = nDecimalDigits == null? 2 : nDecimalDigits;
function sum() {
var total = eval($("#total").val());
var ppn = eval($("#ppn").val());
var discount = eval($("#discount").val());
var basic = eval($("#basic").val());
var grandtotal = eval($("#grandtotal").val());
var ppnType = $("#ppnType").val();
// ppn
if (ppnType == '1') {
// dasar pengenaan pajak
var basicproccess = eval(total - discount);
var basicproccessrp = toRp(basicproccess);
var ppnproccess = eval(0.1 * basicproccess);
var ppnproccessrp = toRp(ppnproccess);
// grandtotal
var grandtotalproccess = eval(basicproccess + ppnproccess);
var grandtotalproccessrp = toRp(grandtotalproccess);
document.getElementById('ppn').value = ppnproccess.toFixed(2);
document.getElementById('ppnrp').value = ppnproccessrp;
document.getElementById('basic').value = basicproccess.toFixed(2);
200
document.getElementById('basicrp').value = basicproccessrp;
document.getElementById('grandtotal').value =
grandtotalproccess.toFixed(2);
document.getElementById('grandtotalrp').value =
grandtotalproccessrp;
}
else{
// dasar pengenaan pajak
var basicproccess = eval(total - discount);
var basicproccessrp = toRp(basicproccess);
var ppnproccess = 0;
// grandtotal
var grandtotalproccess = eval(basicproccess + ppnproccess);
var grandtotalproccessrp = toRp(grandtotalproccess);
var ppnproccessrp = toRp(ppnproccess);
document.getElementById('ppn').value = 0;
document.getElementById('ppnrp').value = 0;
document.getElementById('basic').value = basicproccess.toFixed(2);
document.getElementById('basicrp').value = basicproccessrp;
document.getElementById('grandtotal').value =
grandtotalproccess.toFixed(2);
document.getElementById('grandtotalrp').value =
grandtotalproccessrp;
}
}
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$("#paymentType").change(function(e){
var paymentType = $("#paymentType").val();
$("#searchStatus").empty();
if (paymentType == '2'){
newinput3.appendTo('#searchStatus').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c-0:c+1'
});
201
}
});
$("#ppnType").change(function(e){
var ppnType = $("#ppnType").val();
var discount = eval($("#discount").val());
var total = eval($("#total").val());
document.getElementById("ppn").value = 0;
document.getElementById("ppnrp").value = 0;
if (ppnType == '1'){
var sisatotal = eval(total - discount);
var ppnValue = eval(0.1 * sisatotal);
var grandtotal = eval(sisatotal + ppnValue);
var ppnrp = toRp(ppnValue);
var basicrp = toRp(sisatotal);
var grandtotalrp = toRp(grandtotal);
document.getElementById("ppn").value = ppnValue.toFixed(2);
document.getElementById("ppnrp").value = ppnrp;
document.getElementById("basic").value = sisatotal.toFixed(2);
document.getElementById("basicrp").value = basicrp;
document.getElementById("grandtotalrp").value = grandtotalrp;
document.getElementById("grandtotal").value =
grandtotal.toFixed(2);
}
else {
var sisagrand = eval(total - discount);
var sisagrandrp = toRp(sisagrand);
document.getElementById("ppn").value = 0;
document.getElementById("ppnrp").value = 0;
document.getElementById("basic").value = sisagrand.toFixed(2);
document.getElementById("basicrp").value = sisagrandrp;
document.getElementById("grandtotalrp").value = sisagrandrp;
document.getElementById("grandtotal").value =
sisagrand.toFixed(2);
}
});
$( "#invoiceDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c-1:c-0'
});
$( "#startDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$( "#endDate" ).datepicker({
changeMonth: true,
changeYear: true,
202
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$('#bbmNo').change(function () {
var bbmNo = $("#bbmNo").val();
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#send2").on("click", function(){
var bbmNo = $("#bbmNo").val();
var productID = $("#productID").val();
var productName1 = $("#productName1").val();
var qty = parseInt($("#qty").val());
var price = parseInt($("#price").val());
var desc = $("#desc").val();
if (qty != '' && spbNo != '' && productID != '' && price != ''){
$.ajax({
type: 'POST',
url: 'save_spb.php',
dataType: 'JSON',
data:{
qty: qty,
price: price,
spbNo: spbNo,
productID: productID,
productName1: productName1,
desc: desc
},
beforeSend: function (data) {
$('#send2').hide();
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "spb.php?module=spb&act=add";
}
});
}
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
203
</header>
<aside class="right-side">
{include file="breadcumb.tpl"}
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Tambah Transaksi Pembelian</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="in.php?module=in&act=cancel&bbmNo={$bbmNo}"
onclick="return confirm('Anda Yakin ingin membatalkan transaksi
pembelian ini?');"><button class="btn btn-default pull-
right">Batal Trx</button></a>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
204
<form method="POST" action="in.php?module=in&act=input">
<input type="hidden" id="supplierID" name="supplierID"
value="{$supplierID}">
<input type="hidden" id="supplierName" name="supplierName"
value="{$supplierName}">
<input type="hidden" id="supplierAddress" name="supplierAddress"
value="{$supplierAddress}">
<input type="hidden" id="spbNo" name="spbNo" value="{$spbNo}">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="150">NO FAKTUR / TGL</td>
<td width="5">:</td>
<td><input type="hidden" id="invoiceNo" name="invoiceNo"
value="TB{$invoiceNo}">
<input type="text" id="invoiceNo" name="invoiceNo"
value="TB{$invoiceNo}" class="form-control" placeholder="ID BBM"
style="width: 110px; float: left" DISABLED>
<input type="text" id="invoiceDate" name="invoiceDate"
value="{$invoiceDate}" class="form-control" placeholder="Tanggal
Transaksi Pembelian" style="width: 160px;" required>
</td>
</tr>
<tr valign="top">
<td>NO BBM</td>
<td>:</td>
<td><input type="text" id="bbmNo" name="bbmNo"
value="{$bbmNo}" class="form-control" placeholder="Nomor BBM"
style="width: 270px;" required>
{if $numsBbm == '0' AND $bbmNo != ''}
<font color="#f56954">Nomor bukti barang masuk tidak
ditemukan.</font>
{/if}
{if $numsBBuy > 0 AND $bbmNo != ''}
<font color="#f56954">Nomor bukti barang masuk sudah
digunakan.</font>
{/if}
</td>
</tr>
<tr>
<td>TIPE BAYAR</td>
<td>:</td>
<td><select id="paymentType" name="paymentType"
class="form-control" style="width: 100px; float: left;" required>
<option value=""></option>
<option value="1">Tunai</option>
<option value="2">Termin</option>
</select>
<div id="searchStatus"></div>
</td>
</tr>
<tr>
<td>PPN</td>
<td>:</td>
<td><select id="ppnType" name="ppnType" class="form-
control" style="width: 100px; float: left;" required>
<option value=""></option>
<option value="1">PPN</option>
205
<option value="2">No PPN</option>
</select>
</td>
</tr>
<tr>
<td colspan="3">
<br>
</td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>HARGA</th>
<th>QTY</th>
<th>SUBTOTAL</th>
<th>KOREKSI HARGA</th>
</tr>
</thead>
<tbody>
{if $numsBbm > 0 AND $bbmNo != ''}
{if $numsBBuy == '0' AND $bbmNo != ''}
{section name=dataBbmDetail loop=$dataBbmDetail}
<tr>
<td>{$dataBbmDetail[dataBbmDetail].no}</td>
<td>{$dataBbmDetail[dataBbmDetail].productName}</td>
<td style='text-align: right;'>{$dataBbmDetail[dataBbmDetail]
.pricerp}</td>
<td style='text-align: center;'>{$dataBbmDetail[dataBbmDetail]
.receiveQty}</td>
<td style='text-align: right;'>{$dataBbmDetail[dataBbmDetail]
.subtotal}</td>
<td><a title="Koreksi Harga" href="edit_in.php?module=in&act=edit
&detailID={$dataBbmDetail[dataBbmDetail].detailID}&bbmNo={$bbmNo}"
data-width="450" data-height="180" class="various2 fancybox
.iframe"><img src="img/icons/edit.png" width="18"></a></td>
</tr>
{/section}
{/if}
{/if}
</tbody>
</table>
</div>
<br>
{if $numsBbm > 0 AND $bbmNo != ''}
{if $numsBBuy == '0' AND $bbmNo != ''}
<table cellpadding="3" cellspacing="3">
<tr>
<td width="190">JUMLAH HARGA BELI</td>
<td width="5">:</td>
<td><input type="hidden" id="total" name="total" value="{$total}">
<input type="text" id="total" name="total" value="{$totalrp}"
class="form-control" style="width: 270px;" DISABLED>
</td>
206
</tr>
<tr>
<td>POTONGAN</td>
<td>:</td>
<td><input type="text" id="discount" name="discount"
value="0" class="form-control" style="width: 270px;"
onkeyup="sum();" required></td>
</tr>
<tr>
<td>DASAR PENGENAAN PAJAK</td>
<td>:</td>
<td><input type="hidden" id="basic" name="basic" value="{$total}">
<input type="text" id="basicrp" name="basicrp" value="{$totalrp}"
class="form-control" style="width: 270px;" DISABLED>
</td>
</tr>
<tr>
<td>PPN (10%)</td>
<td>:</td>
<td><input type="hidden" id="ppn" name="ppn" value="0">
<input type="text" id="ppnrp" name="ppnrp" value="0"
class="form-control" style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>GRANDTOTAL</td>
<td>:</td>
<td><input type="hidden" id="grandtotal" name="grandtotal"
value="{$total}">
<input type="text" id="grandtotalrp" name="grandtotalrp"
value="{$totalrp}" class="form-control" style="width: 270px;"
DISABLED>
</td>
</tr>
</table>
<br>
<button type="submit" class="btn btn-primary">Simpan</button>
{/if}
{/if}
</form>
</div><!-- /.box-body -->
207
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Faktur Transaksi Pembelian</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="print_unit_in.php?module=in&act=print&invoiceID=
{$invoiceID}&bbmNo={$bbmNo}&invoiceNo={$invoiceNo}"
target="_blank"><button class="btn btn-default pull-
right">Print</button></a>
<a href="in.php"><button class="btn btn-default pull-
right">Close</button></a>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="150">NO FAKTUR / TGL</td>
<td width="5">:</td>
<td><input type="text" id="invoiceNo" name="invoiceNo"
value="{$invoiceNo}" class="form-control" placeholder="Nomor
Faktur" style="width: 110px; float: left" DISABLED>
<input type="text" id="invoiceDate" name="invoiceDate"
value="{$invoiceDate}" class="form-control" placeholder="Tanggal
Penerimaan" style="width: 160px;" DISABLED>
</td>
</tr>
<tr valign="top">
<td>NO BBM</td>
<td>:</td>
<td><input type="text" id="bbmNo" name="bbmNo"
value="{$bbmNo}" class="form-control" placeholder="Nomor PO"
style="width: 270px;" DISABLED></td>
</tr>
<tr valign="top">
<td>TIPE BAYAR</td>
<td>:</td>
<td><input type="text" id="paymentType" name="paymentType"
value="{$paymentType}" class="form-control" placeholder="Tipe
Bayar" style="width: 135px; float: left;" DISABLED>
<input type="text" id="expiredDate" name="expiredDate"
value="{$expiredPayment}" class="form-control" placeholder="Jatuh
Tempo" style="width: 135px;" DISABLED>
</td>
</tr>
<tr valign="top">
<td>PPN /</td>
<td>:</td>
<td><input type="text" id="ppnType" name="ppnType"
value="{$ppnType}" class="form-control" placeholder="PPN"
style="width: 80px; float: left;" DISABLED>
</td>
</tr>
<tr>
<td colspan="3">
<br>
208
</td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>HARGA</th>
<th>QTY</th>
<th>SUBTOTAL</th>
</tr>
</thead>
<tbody>
{section name=dataBbmDetail loop=$dataBbmDetail}
<tr>
<td>{$dataBbmDetail[dataBbmDetail].no}</td>
<td>{$dataBbmDetail[dataBbmDetail].productName}</td>
<td style='text-align: right;'>{$dataBbmDetail[dataBbmDetail]
.pricerp}</td>
<td style='text-align: center;'>{$dataBbmDetail[dataBbmDetail]
.receiveQty}</td>
<td style='text-align: right;'>{$dataBbmDetail[dataBbmDetail]
.subtotal}</td>
</tr>
{/section}
</tbody>
</table>
</div>
<br>
<table cellpadding="3" cellspacing="3">
<tr>
<td width="190">JUMLAH HARGA BELI</td>
<td width="5">:</td>
<td><input type="text" id="total" name="total" value="{$total}"
class="form-control" style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>POTONGAN</td>
<td>:</td>
<td><input type="text" id="discount" name="discount"
value="{$discount}" class="form-control" style="width: 270px;"
DISABLED></td>
</tr>
<tr>
<td>DASAR PENGENAAN PAJAK</td>
<td>:</td>
<td><input type="text" id="basicrp" name="basicrp"
value="{$basic}" class="form-control" style="width: 270px;"
DISABLED></td>
</tr>
<tr>
<td>PPN (10%)</td>
<td>:</td>
209
<td><input type="text" id="ppnrp" name="ppnrp"
value="{$ppn}" class="form-control" style="width: 270px;"
DISABLED></td>
</tr>
<tr>
<td>GRANDTOTAL</td>
<td>:</td>
<td><input type="text" id="grandtotalrp"
name="grandtotalrp" value="{$grandtotal}" class="form-control"
style="width: 270px;" DISABLED></td>
</tr>
</table>
</div><!-- /.box-body -->
<div class="box-body">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="150">NO FAKTUR / TGL</td>
<td width="5">:</td>
<td><input type="text" id="invoiceNo" name="invoiceNo"
value="{$invoiceNo}" class="form-control" placeholder="Nomor
Faktur" style="width: 110px; float: left" DISABLED>
<input type="text" id="invoiceDate" name="invoiceDate"
value="{$invoiceDate}" class="form-control" placeholder="Tanggal
Penerimaan" style="width: 160px;" DISABLED>
</td>
</tr>
<tr valign="top">
<td>NO BBM</td>
<td>:</td>
<td><input type="text" id="bbmNo" name="bbmNo"
value="{$bbmNo}" class="form-control" placeholder="Nomor PO"
style="width: 270px;" DISABLED></td>
</tr>
<tr valign="top">
<td>TIPE BAYAR</td>
210
<td>:</td>
<td><input type="text" id="paymentType" name="paymentType"
value="{$paymentType}" class="form-control" placeholder="Tipe
Bayar" style="width: 135px; float: left;" DISABLED>
<input type="text" id="expiredDate" name="expiredDate"
value="{$expiredPayment}" class="form-control" placeholder="Jatuh
Tempo" style="width: 135px;" DISABLED>
</td>
</tr>
<tr valign="top">
<td>PPN</td>
<td>:</td>
<td><input type="text" id="ppnType" name="ppnType"
value="{$ppnType}" class="form-control" placeholder="PPN"
style="width: 80px; float: left;" DISABLED>
</td>
</tr>
<tr>
<td colspan="3">
<br>
</td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>HARGA</th>
<th>QTY</th>
<th>SUBTOTAL</th>
</tr>
</thead>
<tbody>
{section name=dataBbmDetail loop=$dataBbmDetail}
<tr>
<td>{$dataBbmDetail[dataBbmDetail].no}</td>
<td>{$dataBbmDetail[dataBbmDetail].productName}</td>
<td style='text-align: right;'>{$dataBbmDetail[dataBbmDetail]
.pricerp}</td>
<td style='text-align: center;'>{$dataBbmDetail[dataBbmDetail]
.receiveQty}</td>
<td style='text-align: right;'>{$dataBbmDetail[dataBbmDetail]
.subtotal}</td>
</tr>
{/section}
</tbody>
</table>
</div>
<br>
<table cellpadding="3" cellspacing="3">
<tr>
<td width="190">JUMLAH HARGA BELI</td>
<td width="5">:</td>
211
<td><input type="text" id="total" name="total" value="{$total}"
class="form-control" style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>POTONGAN</td>
<td>:</td>
<td><input type="text" id="discount" name="discount"
value="{$discount}" class="form-control" style="width: 270px;"
DISABLED></td>
</tr>
<tr>
<td>DASAR PENGENAAN PAJAK</td>
<td>:</td>
<td><input type="text" id="basicrp" name="basicrp"
value="{$basic}" class="form-control" style="width: 270px;"
DISABLED></td>
</tr>
<tr>
<td>PPN (10%)</td>
<td>:</td>
<td><input type="text" id="ppnrp" name="ppnrp" value="{$ppn}"
class="form-control" style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>GRANDTOTAL</td>
<td>:</td>
<td><input type="text" id="grandtotalrp"
name="grandtotalrp" value="{$grandtotal}" class="form-control"
style="width: 270px;" DISABLED></td>
</tr>
</table>
212
<a href="print_in.php?act=print&q={$q}&startDate={$startDate}&
endDate={$endDate}" style="float: left;" target="_blank"><button
type="button" class="btn btn-default pull-right"><i class="fa fa-
print"></i> Print PDF</button></a>
</form>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NO INVOICE <i class="fa fa-sort"></i></th>
<th>TGL <i class="fa fa-sort"></i></th>
<th>NO BBM <i class="fa fa-sort"></i></th>
<th>GRANDTOTAL <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataBuy loop=$dataBuy}
<tr>
<td>{$dataBuy[dataBuy].no}</td>
<td>{$dataBuy[dataBuy].invoiceNo}</td>
<td>{$dataBuy[dataBuy].invoiceDate}</td>
<td>{$dataBuy[dataBuy].bbmNo}</td>
<td>{$dataBuy[dataBuy].grandtotal}</td>
<td>{$dataBuy[dataBuy].staffName}</td>
<td>
<a title="Detail" href="in.php?module=in&act=detailin&invoiceID=
{$dataBuy[dataBuy].invoiceID}&invoiceNo={$dataBuy[dataBuy].invoice
No}&bbmNo={$dataBuy[dataBuy].bbmNo}&q={$q}&page={$page}"><img
src="img/icons/view.png" width="18"></a>
<a title="Delete" href="in.php?module=in&act=delete&invoiceID=
{$dataBuy[dataBuy].invoiceID}&invoiceNo={$dataBuy[dataBuy].invoice
No}&bbmNo={$dataBuy[dataBuy].bbmNo}&" onclick="return
confirm('Anda Yakin ingin membatalkan transaksi
{$dataBuy[dataBuy].invoiceNo}? penghapusan ini akan membatalkan
seluruh hutang dan pembayaran terkait transaksi ini.');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
213
<div class="box-footer clearfix no-border">
<form method="GET" action="in.php">
<input type="hidden" name="module" value="in">
<input type="hidden" name="act" value="search">
<button type="submit" class="btn btn-default pull-
right"><i class="fa fa-search"></i> Search</button>
<input type="text" value="{$endDate}" id="endDate"
name="endDate" class="form-control" placeholder="Periode Akhir"
style="float: right; width: 115px;">
<input type="text" value="{$startDate}" id="startDate"
name="startDate" class="form-control" placeholder="Periode Awal"
style="float: right; width: 115px;">
<input type="text" value="{$q}" id="q" name="q"
class="form-control" placeholder="Pencarian : Nomor Faktur
Pembelian" style="float: right; width: 270px;">
<a href="in.php?module=in&act=add" style="float:
left;"><button type="button" class="btn btn-default pull-right"><i
class="fa fa-plus"></i> Add</button></a>
<a href="print_in.php?act=print&q={$q}" style="float: left;"
target="_blank"><button type="button" class="btn btn-default pull-
right"><i class="fa fa-print"></i> Print PDF</button></a>
</form>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NO INVOICE <i class="fa fa-sort"></i></th>
<th>TGL <i class="fa fa-sort"></i></th>
<th>NO BBM <i class="fa fa-sort"></i></th>
<th>GRANDTOTAL <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataBuy loop=$dataBuy}
<tr>
<td>{$dataBuy[dataBuy].no}</td>
<td>{$dataBuy[dataBuy].invoiceNo}</td>
<td>{$dataBuy[dataBuy].invoiceDate}</td>
<td>{$dataBuy[dataBuy].bbmNo}</td>
<td>{$dataBuy[dataBuy].grandtotal}</td>
<td>{$dataBuy[dataBuy].staffName}</td>
<td>
<a title="Detail" href="in.php?module=in&act=detailin&invoiceID=
{$dataBuy[dataBuy].invoiceID}&invoiceNo={$dataBuy[dataBuy].invoice
No}&bbmNo={$dataBuy[dataBuy].bbmNo}&page={$page}"><img
src="img/icons/view.png" width="18"></a>
<a title="Delete" href="in.php?module=in&act=delete&invoiceID=
{$dataBuy[dataBuy].invoiceID}&invoiceNo={$dataBuy[dataBuy].invoice
214
No}&bbmNo={$dataBuy[dataBuy].bbmNo}&" onclick="return
confirm('Anda Yakin ingin membatalkan transaksi
{$dataBuy[dataBuy].invoiceNo}? penghapusan ini akan membatalkan
seluruh hutang dan pembayaran terkait transaksi ini.');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
{include file="footer.tpl"}
215
Gambar 5.27. Cetak transaksi pembelian
$module = $_GET['module'];
$act = $_GET['act'];
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE
modulID = '26'";
$sqlAuthorizeStaff = mysqli_query($connect, $queryAuthorizeStaff);
216
$dataAuthorizeStaff = mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
$total = $dataPayment['total'];
if ($sqlUpdate)
{
$queryPay = "DELETE FROM as_buy_payments WHERE
paymentID = '$paymentID' AND paymentNo = '$paymentNo'";
$sqlPay = mysqli_query($connect, $queryPay);
}
217
{
$queryProduct = "SELECT hpp FROM as_products WHERE productID =
'$dataBbm[productID]'";
$sqlProduct = mysqli_query($connect, $queryProduct);
$dataProduct = mysqli_fetch_array($sqlProduct);
$paymentNo = $_POST['paymentNo'];
$pDate = explode("-", $_POST['paymentDate']);
$paymentDate = $pDate[2]."-".$pDate[1]."-".$pDate[0];
$invoiceID = $_POST['invoiceID'];
$invoiceNo = mysqli_real_escape_string($connect,
$_POST['invoiceNo']);
$spbNo = $_POST['spbNo'];
$payType = $_POST['payType'];
$bankNo = mysqli_real_escape_string($connect, $_POST['bankNo']);
$bankName = mysqli_real_escape_string($connect,
$_POST['bankName']);
$bankAC = mysqli_real_escape_string($connect, $_POST['bankAC']);
$eDate = explode("-", $_POST['effectiveDate']);
$effectiveDate = $eDate[2]."-".$eDate[1]."-".$eDate[0];
$total = mysqli_real_escape_string($connect, $_POST['total']);
$supplierID = $_POST['supplierID'];
$supplierName = mysqli_real_escape_string($connect,
$_POST['supplierName']);
$supplierAddress = mysqli_real_escape_string($connect,
$_POST['supplierAddress']);
$ref = mysqli_real_escape_string($connect, $_POST['ref']);
$note = mysqli_real_escape_string($connect, $_POST['note']);
218
spbNo,
paymentDate,
payType,
bankNo,
bankName,
bankAC,
effectiveDate,
total,
supplierID,
supplierName,
supplierAddress,
ref,
note,
staffID,
staffName,
createdDate,
createdUserID,
modifiedDate,
modifiedUserID)
VALUES( '$paymentNo',
'$invoiceID',
'$invoiceNo',
'$spbNo',
'$paymentDate',
'$payType',
'$bankNo',
'$bankName',
'$bankAC',
'$effectiveDate',
'$total',
'$supplierID',
'$supplierName',
'$supplierAddress',
'$ref',
'$note',
'$staffID',
'$sName',
'$createdDate',
'$staffID',
'',
'')";
$paymentID = mysqli_insert_id($connect);
if ($sqlPay)
{
$queryUpdate = "UPDATE as_debts SET
incomingTotal=incomingTotal+$total WHERE invoiceNo = '$invoiceNo'
AND invoiceID = '$invoiceID'";
$sqlUpdate = mysqli_query($connect, $queryUpdate);
}
header("Location:
pay_in.php?module=payin&act=finish&paymentNo=".$paymentNo."&paymen
tID=".$paymentID."&invoiceNo=".$invoiceNo);
219
}
// debt
$debt = $dataTotal['total'] - $dataBuy['grandtotal'];
if ($dataPay['payType'] == '1')
{
$payType = "TUNAI";
}
elseif ($dataPay['payType'] == '2')
{
$payType = "TRANSFER";
}
elseif ($dataPay['payType'] == '3')
{
$payType = "CEK";
}
else
{
$payType = "GIRO";
}
if ($dataPay['effectiveDate'] == '0000-00-00')
{
$effectiveDate = "-";
220
}
else
{
$effectiveDate = tgl_indo2($dataPay['effectiveDate']);
}
// assign
$smarty->assign("q", $q);
$smarty->assign("paymentNo", $dataPay['paymentNo']);
$smarty->assign("paymentID", $dataPay['paymentID']);
$smarty->assign("paymentDate",
tgl_indo2($dataPay['paymentDate']));
$smarty->assign("invoiceNo", $dataPay['invoiceNo']);
$smarty->assign("pay", rupiah($total));
$smarty->assign("total", rupiah($dataPay['total']));
$smarty->assign("debt", rupiah($debt));
$smarty->assign("supplierName", $dataBuy['supplierName']);
$smarty->assign("supplierAddress", $dataBuy['supplierAddress']);
$smarty->assign("payType", $payType);
$smarty->assign("bankNo", $dataPay['bankNo']);
$smarty->assign("bankName", $dataPay['bankName']);
$smarty->assign("effectiveDate", $effectiveDate);
$smarty->assign("bankAC", $dataPay['bankAC']);
$smarty->assign("total", rupiah($dataPay['total']));
$smarty->assign("ref", $dataPay['ref']);
$smarty->assign("note", $dataPay['note']);
221
$queryPay = "SELECT * FROM as_buy_payments WHERE paymentNo =
'$paymentNo' AND paymentID = '$paymentID' AND invoiceNo =
'$invoiceNo'";
$sqlPay = mysqli_query($connect, $queryPay);
$dataPay = mysqli_fetch_array($sqlPay);
// debt
$debt = $dataBuy['grandtotal'] - $dataTotal['total'];
if ($dataPay['payType'] == '1')
{
$payType = "TUNAI";
}
elseif ($dataPay['payType'] == '2')
{
$payType = "TRANSFER";
}
elseif ($dataPay['payType'] == '3')
{
$payType = "CEK";
}
else
{
$payType = "GIRO";
}
if ($dataPay['effectiveDate'] == '0000-00-00')
{
$effectiveDate = "-";
}
else
{
$effectiveDate = tgl_indo2($dataPay['effectiveDate']);
}
// assign
$smarty->assign("paymentNo", $dataPay['paymentNo']);
$smarty->assign("paymentID", $dataPay['paymentID']);
$smarty->assign("paymentDate",
tgl_indo2($dataPay['paymentDate']));
$smarty->assign("invoiceNo", $dataPay['invoiceNo']);
$smarty->assign("pay", rupiah($total));
$smarty->assign("total", rupiah($dataPay['total']));
$smarty->assign("debt", rupiah($debt));
$smarty->assign("supplierName", $dataBuy['supplierName']);
$smarty->assign("supplierAddress", $dataBuy['supplierAddress']);
$smarty->assign("payType", $payType);
$smarty->assign("bankNo", $dataPay['bankNo']);
$smarty->assign("bankName", $dataPay['bankName']);
$smarty->assign("effectiveDate", $effectiveDate);
$smarty->assign("bankAC", $dataPay['bankAC']);
$smarty->assign("total", rupiah($dataPay['total']));
222
$smarty->assign("ref", $dataPay['ref']);
$smarty->assign("note", $dataPay['note']);
$start = substr($dataNoPayIn['paymentNo'],2-7);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoPayIn == '0')
{
$inNo = "00000";
}
elseif ($tempNo == 1)
{
$inNo = "00000";
}
elseif ($tempNo == 2)
{
$inNo = "0000";
}
elseif ($tempNo == 3)
{
$inNo = "000";
}
elseif ($tempNo == 4)
{
$inNo = "00";
}
elseif ($tempNo == 5)
{
$inNo = "0";
}
elseif ($tempNo == 6)
{
$inNo = "";
}
223
$payInNo = "PP".$inNo.$next;
// total grandtotal
$queryTotal = "SELECT grandtotal, invoiceID, spbNo,
supplierID, supplierName, supplierAddress FROM as_buy_transactions
WHERE invoiceNo = '$invoiceNo'";
$sqlTotal = mysqli_query($connect, $queryTotal);
$numsTotal = mysqli_num_rows($sqlTotal);
$dataTotal = mysqli_fetch_array($sqlTotal);
// count payment
$queryPay = "SELECT SUM(total) as total FROM
as_buy_payments WHERE invoiceNo = '$invoiceNo'";
$sqlPay = mysqli_query($connect, $queryPay);
$dataPay = mysqli_fetch_array($sqlPay);
$smarty->assign("payInNo", $payInNo);
$smarty->assign("payInDate", tgl_indo2(date('Y-m-d')));
$smarty->assign("invoiceNo", $invoiceNo);
$smarty->assign("invoiceID", $dataTotal['invoiceID']);
$smarty->assign("numsTotal", $numsTotal);
$smarty->assign("spbNo", $dataTotal['spbNo']);
$smarty->assign("debt", rupiah($debt));
$smarty->assign("debto", $debt);
$smarty->assign("supplierID", $dataTotal['supplierID']);
$smarty->assign("supplierName", $dataTotal['supplierName']);
$smarty->assign("supplierAddress", $dataTotal['supplierAddress']);
$smarty->assign("startDate", $sDate);
$smarty->assign("endDate", $eDate);
$startDate = $s2Date[2]."-".$s2Date[1]."-".$s2Date[0];
$endDate = $e2Date[2]."-".$e2Date[1]."-".$e2Date[0];
224
$queryPay = "SELECT * FROM as_buy_payments WHERE
paymentNo LIKE '%$q%' AND paymentDate BETWEEN '$startDate' AND
'$endDate' ORDER BY paymentDate DESC";
}
else
{
$queryPay = "SELECT * FROM as_buy_payments WHERE
paymentNo LIKE '%$q%' ORDER BY paymentDate DESC";
}
// fetch data
$i = 1 + $position;
while ($dtPay = mysqli_fetch_array($sqlPay))
{
if ($dtPay['payType'] == '1')
{
$payType = "TUNAI";
$effectiveDate = "";
}
else
{
$payType = "CEK";
$effectiveDate = tgl_indo2($dtPay['effectiveDate']);
}
$smarty->assign("dataPay", $dataPay);
$smarty->assign("q", $q);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Pembayaran Transaksi
Pembelian");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk melakukan
pembayaran transaksi pembelian.");
$smarty->assign("breadcumbMenuName", "Transaksi Pembelian");
$smarty->assign("breadcumbMenuSubName", "Pembayaran Transaksi");
}
else
{
225
// create new object pagination
$p = new PaginationPayIn;
// limit 20 data for page
$limit = 30;
$position = $p->searchPosition($limit);
// fetch data
$i = 1 + $position;
while ($dtPay = mysqli_fetch_array($sqlPay))
{
if ($dtPay['payType'] == '1')
{
$payType = "TUNAI";
$effectiveDate = "";
}
else
{
$payType = "CEK";
$effectiveDate = tgl_indo2($dtPay['effectiveDate']);
}
$smarty->assign("dataPay", $dataPay);
// count data
$queryCountPay = "SELECT * FROM as_buy_payments";
$sqlCountPay = mysqli_query($connect, $queryCountPay);
$amountData = mysqli_num_rows($sqlCountPay);
$smarty->assign("pageLink", $pageLink);
$smarty->assign("page", $_GET['page']);
$smarty->assign("msg", $_GET['msg']);
226
$smarty->assign("breadcumbTitle", "Pembayaran Transaksi
Pembelian");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk melakukan
pembayaran transaksi pembelian.");
$smarty->assign("breadcumbMenuName", "Transaksi Pembelian");
$smarty->assign("breadcumbMenuSubName", "Pembayaran Transaksi");
}
$smarty->assign("module", $module);
$smarty->assign("act", $act);
}
// include footer
include "footer.php";
?>
<style>
div.ui-datepicker{
font-size:14px;
}
</style>
{literal}
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$( "#paymentDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c-1:c-0'
227
});
$( "#startDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$( "#endDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$( "#effectiveDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c:c+1'
});
$('#invoiceNo').change(function () {
var invoiceNo = $("#invoiceNo").val();
window.location.href =
"pay_in.php?module=payin&act=add&invoiceNo=" + invoiceNo;
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
<aside class="right-side">
{include file="breadcumb.tpl"}
228
<!-- Main row -->
<div class="row">
<!-- Left col -->
<section class="col-lg-12 connectedSortable">
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Pembayaran Transaksi Pembelian</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="pay_in.php" onclick="return confirm('Anda Yakin
ingin membatalkan pembayaran transaksi pembelian ini?');"><button
type="button" class="btn btn-default pull-right">Batal
Trx</button></a>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
{if $numsTotal == '0' && $invoiceNo != ''}
<span style="color: #f56954;">Nomor Faktur tidak ditemukan.</span>
{/if}
{if $numsTotal > 0}
{if $debto <= '0'}
<span style="color: green;">Nomor Faktur ini telah lunas
dibayarkan.</span>
{/if}
{/if}
<form method="POST" action="pay_in.php?module=payin&act=input">
<input type="hidden" id="supplierID" name="supplierID"
value="{$supplierID}">
<input type="hidden" id="supplierName" name="supplierName"
value="{$supplierName}">
<input type="hidden" id="supplierAddress" name="supplierAddress"
value="{$supplierAddress}">
<input type="hidden" id="spbNo" name="spbNo" value="{$spbNo}">
<input type="hidden" id="invoiceID" name="invoiceID"
value="{$invoiceID}">
229
<table cellpadding="3" cellspacing="3" width="100%">
<tr>
<td width="150">NO PAYMENT / TGL</td>
<td width="5">:</td>
<td><input type="hidden" id="paymentNo" name="paymentNo"
value="{$payInNo}">
<input type="text" id="paymentNo" name="paymentNo"
value="{$payInNo}" class="form-control" placeholder="NOMOR
PAYMENT" style="width: 110px; float: left" DISABLED>
<input type="text" id="paymentDate" name="paymentDate"
value="{$payInDate}" class="form-control" placeholder="Tanggal
Payment" style="width: 190px;" required>
</td>
</tr>
<tr valign="top">
<td>NOMOR FAKTUR</td>
<td>:</td>
<td><input type="text" id="invoiceNo" name="invoiceNo"
value="{$invoiceNo}" class="form-control" placeholder="Nomor
Faktur" style="width: 300px;" required></td>
</tr>
<tr valign="top">
<td>TERHUTANG</td>
<td>:</td>
<td><input type="text" id="debt" name="debt"
value="{$valas} {$debt}" class="form-control" placeholder="Total
Terhutang" style="width: 300px;" DISABLED></td>
</tr>
<tr>
<td>DIBAYARKAN KEPADA</td>
<td>:</td>
<td>
<input type="text" id="supplierName" name="supplierName"
value="{$supplierName}" class="form-control" placeholder="Nama
Supplier" style="width: 300px;" DISABLED>
</td>
</tr>
<tr>
<td>PEMBAYARAN</td>
<td>:</td>
<td><select id="payType" name="payType" class="form-
control" style="width: 125px; float: left;" required>
<option value=""></option>
<option value="1">Tunai</option>
<option value="2">Transfer</option>
<option value="3">Cek</option>
<option value="4">Giro</option>
</select>
<input type="text" id="bankNo" name="bankNo" class="form-control"
placeholder="Nomor Rek / Cek / Giro" style="width: 175px;
float:left;">
</td>
</tr>
<tr>
<td>NAMA BANK</td>
<td>:</td>
<td>
230
<input type="text" id="bankName" name="bankName" class="form-
control" placeholder="Nama Bank" style="width: 175px; float:
left;">
<input type="text" id="effectiveDate" name="effectiveDate"
class="form-control" placeholder="Tanggal Efektif" style="width:
125px;">
</td>
</tr>
<tr>
<td>NAMA AKUN</td>
<td>:</td>
<td>
<input type="text" id="bankAC" name="bankAC" class="form-control"
placeholder="Nama Akun (Pemegang)" style="width:300px;
float:left;">
</td>
</tr>
<tr>
<td>JUMLAH</td>
<td>:</td>
<td>
<input type="text" id="total" name="total" class="form-control"
placeholder="Jumlah" style="width: 300px;" required>
</td>
</tr>
<tr>
<td>REFERENSI</td>
<td>:</td>
<td>
<input type="text" id="ref" name="ref" class="form-control"
placeholder="Referensi" style="width: 300px;">
</td>
</tr>
<tr valign="top">
<td>NOTE</td>
<td>:</td>
<td>
<textarea id="note" name="note" class="form-control"
placeholder="Note" style="width: 300px;"></textarea>
</td>
</tr>
</table>
{if $numsTotal > 0}
{if $debto > 0}
<button type="submit" class="btn btn-primary">Simpan</button>
{/if}
{/if}
</form>
231
window.onhashchange=function(){window.location.hash="no-
back-button";}
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Pembayaran Transaksi Pembelian</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="print_unit_payin.php?module=payin&act=print&invoiceNo
={$invoiceNo}&paymentNo={$paymentNo}&paymentID={$paymentID}"
target="_blank"><button class="btn btn-default pull-
right">Print</button></a>
<a href="pay_in.php"><button class="btn btn-default pull-
right">Close</button></a>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<table cellpadding="3" cellspacing="3" width="100%">
<tr>
<td width="150">NO PAYMENT / TGL</td>
<td width="5">:</td>
<td>{$paymentNo} / {$paymentDate}</td>
</tr>
<tr valign="top">
<td>NOMOR FAKTUR</td>
<td>:</td>
<td>{$invoiceNo}</td>
</tr>
<tr valign="top">
<td>TERHUTANG</td>
<td>:</td>
<td>{$debt}</td>
</tr>
<tr>
<td>DIBAYARKAN KEPADA</td>
<td>:</td>
<td>{$supplierName}</td>
</tr>
<tr>
<td></td>
<td></td>
<td>{$supplierAddress}</td>
</tr>
<tr>
<td>PEMBAYARAN</td>
<td>:</td>
<td>{$payType}</td>
232
</tr>
<tr>
<td>NO REK/CEK/GIRO</td>
<td>:</td>
<td>{$bankNo}</td>
</tr>
<tr>
<td>NAMA BANK</td>
<td>:</td>
<td>{$bankName}</td>
</tr>
<tr>
<td>TGL EFEKTIF</td>
<td>:</td>
<td>{$effectiveDate}</td>
</tr>
<tr>
<td>NAMA AKUN</td>
<td>:</td>
<td>{$bankAC}</td>
</tr>
<tr>
<td>JUMLAH</td>
<td>:</td>
<td>{$total}</td>
</tr>
<tr>
<td>REFERENSI</td>
<td>:</td>
<td>{$ref}</td>
</tr>
<tr valign="top">
<td>NOTE</td>
<td>:</td>
<td>{$note}</td>
</tr>
</table>
</div><!-- /.box-body -->
233
</div>
</div><!-- /.box-header -->
<div class="box-body">
<table cellpadding="3" cellspacing="3" width="100%">
<tr>
<td width="150">NO PAYMENT / TGL</td>
<td width="5">:</td>
<td>{$paymentNo} / {$paymentDate}</td>
</tr>
<tr valign="top">
<td>NOMOR FAKTUR</td>
<td>:</td>
<td>{$invoiceNo}</td>
</tr>
<tr valign="top">
<td>TERHUTANG</td>
<td>:</td>
<td>{$debt}</td>
</tr>
<tr>
<td>DIBAYARKAN KEPADA</td>
<td>:</td>
<td>{$supplierName}</td>
</tr>
<tr>
<td></td>
<td></td>
<td>{$supplierAddress}</td>
</tr>
<tr>
<td>PEMBAYARAN</td>
<td>:</td>
<td>{$payType}</td>
</tr>
<tr>
<td>NO REK/CEK/GIRO</td>
<td>:</td>
<td>{$bankNo}</td>
</tr>
<tr>
<td>NAMA BANK</td>
<td>:</td>
<td>{$bankName}</td>
</tr>
<tr>
<td>TGL EFEKTIF</td>
<td>:</td>
<td>{$effectiveDate}</td>
</tr>
<tr>
<td>NAMA AKUN</td>
<td>:</td>
<td>{$bankAC}</td>
</tr>
<tr>
<td>JUMLAH</td>
234
<td>:</td>
<td>{$total}</td>
</tr>
<tr>
<td>REFERENSI</td>
<td>:</td>
<td>{$ref}</td>
</tr>
<tr valign="top">
<td>NOTE</td>
<td>:</td>
<td>{$note}</td>
</tr>
</table>
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<form method="GET" action="pay_in.php">
<input type="hidden" name="module" value="payin">
<input type="hidden" name="act" value="search">
<button type="submit" class="btn btn-default pull-right"><i
class="fa fa-search"></i> Search</button>
<input type="text" value="{$endDate}" id="endDate" name="endDate"
class="form-control" placeholder="Periode Akhir" style="float:
right; width: 115px;">
<input type="text" value="{$startDate}" id="startDate"
name="startDate" class="form-control" placeholder="Periode Awal"
style="float: right; width: 115px;">
<input type="text" value="{$q}" id="q" name="q" class="form-
control" placeholder="Pencarian : Nomor Bukti Pembayaran"
style="float: right; width: 270px;" required>
<a href="pay_in.php?module=payin&act=add" style="float:
left;"><button type="button" class="btn btn-default pull-right"><i
class="fa fa-plus"></i> Add</button></a>
<a href="print_pay_in.php?act=print&q={$q}&startDate={$startDate}&
endDate={$endDate}" style="float: left;" target="_blank"><button
type="button" class="btn btn-default pull-right"><i class="fa fa-
print"></i> Print PDF</button></a>
</form>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NO PAYMENT <i class="fa fa-sort"></i></th>
<th>TGL <i class="fa fa-sort"></i></th>
235
<th>NO INVOICE <i class="fa fa-sort"></i></th>
<th>NO PO <i class="fa fa-sort"></i></th>
<th>VIA <i class="fa fa-sort"></i></th>
<th>TOTAL <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataPay loop=$dataPay}
<tr>
<td>{$dataPay[dataPay].no}</td>
<td>{$dataPay[dataPay].paymentNo}</td>
<td>{$dataPay[dataPay].paymentDate}</td>
<td>{$dataPay[dataPay].invoiceNo}</td>
<td>{$dataPay[dataPay].spbNo}</td>
<td>{$dataPay[dataPay].payType}</td>
<td>{$dataPay[dataPay].total}</td>
<td>{$dataPay[dataPay].staffName}</td>
<td>
<a title="Detail" href="pay_in.php?module=payin&act=detailpayin
&paymentID={$dataPay[dataPay].paymentID}&invoiceNo={$dataPay[dataP
ay].invoiceNo}&paymentNo={$dataPay[dataPay].paymentNo}&q={$q}&page
={$page}"><img src="img/icons/view.png" width="18"></a>
<a title="Delete" href="pay_in.php?module=payin&act=delete&
invoiceNo={$dataPay[dataPay].invoiceNo}&paymentNo={$dataPay[dataPa
y].paymentNo}&paymentID={$dataPay[dataPay].paymentID}&q={$q}"
onclick="return confirm('Anda Yakin ingin membatalkan nomor
pembayaran {$dataPay[dataPay].paymentNo}? penghapusan ini akan
membatalkan pembayaran transaksi ini.');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
{else}
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<form method="GET" action="pay_in.php">
<input type="hidden" name="module" value="payin">
<input type="hidden" name="act" value="search">
<button type="submit" class="btn btn-default pull-right"><i
class="fa fa-search"></i> Search</button>
<input type="text" value="{$endDate}" id="endDate" name="endDate"
class="form-control" placeholder="Periode Akhir" style="float:
right; width: 115px;">
<input type="text" value="{$startDate}" id="startDate"
name="startDate" class="form-control" placeholder="Periode Awal"
style="float: right; width: 115px;">
236
<input type="text" value="{$q}" id="q" name="q" class="form-
control" placeholder="Pencarian : Nomor Bukti Pembayaran"
style="float: right; width: 270px;">
<a href="pay_in.php?module=payin&act=add" style="float:
left;"><button type="button" class="btn btn-default pull-right"><i
class="fa fa-plus"></i> Add</button></a>
<a href="print_pay_in.php?act=print&q={$q}&startDate={$startDate}
&endDate={$endDate}" style="float: left;" target="_blank"><button
type="button" class="btn btn-default pull-right"><i class="fa fa-
print"></i> Print PDF</button></a>
</form>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NO PAYMENT <i class="fa fa-sort"></i></th>
<th>TGL <i class="fa fa-sort"></i></th>
<th>NO INVOICE <i class="fa fa-sort"></i></th>
<th>NO PO <i class="fa fa-sort"></i></th>
<th>VIA <i class="fa fa-sort"></i></th>
<th>TOTAL <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataPay loop=$dataPay}
<tr>
<td>{$dataPay[dataPay].no}</td>
<td>{$dataPay[dataPay].paymentNo}</td>
<td>{$dataPay[dataPay].paymentDate}</td>
<td>{$dataPay[dataPay].invoiceNo}</td>
<td>{$dataPay[dataPay].spbNo}</td>
<td>{$dataPay[dataPay].payType}</td>
<td>{$dataPay[dataPay].total}</td>
<td>{$dataPay[dataPay].staffName}</td>
<td>
<a title="Detail" href="pay_in.php?module=payin&act=detailpayin
&paymentID={$dataPay[dataPay].paymentID}&invoiceNo={$dataPay[dataP
ay].invoiceNo}&paymentNo={$dataPay[dataPay].paymentNo}&page={$page
}"><img src="img/icons/view.png" width="18"></a>
<a title="Delete" href="pay_in.php?module=payin&act=delete
&invoiceNo={$dataPay[dataPay].invoiceNo}&paymentNo={$dataPay[dataP
ay].paymentNo}&paymentID={$dataPay[dataPay].paymentID}"
onclick="return confirm('Anda Yakin ingin membatalkan nomor
pembayaran {$dataPay[dataPay].paymentNo}? penghapusan ini akan
membatalkan pembayaran transaksi ini.');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
237
</tbody>
</table>
</div>
</div><!-- /.box-body -->
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-left">
<ul class="pagination pagination-sm inline">
{$pageLink}
</ul>
</div>
</div><!-- /.box-header -->
{/if}
{include file="footer.tpl"}
238
Gambar 5.29. Bukti pembayaran transaksi pembelian
$module = $_GET['module'];
$act = $_GET['act'];
239
echo "Anda tidak berhak akses modul ini.";
exit();
}
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE
modulID = '28'";
$sqlAuthorizeStaff = mysqli_query($connect, $queryAuthorizeStaff);
$dataAuthorizeStaff = mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
240
$smarty->assign("staffID", $dataSo['staffID']);
$smarty->assign("staffName", $dataSo['staffName']);
$smarty->assign("orderDate", tgl_indo2($dataSo['orderDate']));
$smarty->assign("needDate", tgl_indo2($dataSo['needDate']));
$smarty->assign("status", $dataSo['status']);
$smarty->assign("note", $dataSo['note']);
$smarty->assign("soFaktur", $soFaktur);
// fetch data
$i = 1;
while ($dtDetail = mysqli_fetch_array($sqlDetail))
{
$subtotal = $dtDetail['qty'] * $dtDetail['price'];
$dataDetail[] = array( 'detailID' => $dtDetail['detailID'],
'productID' => $dtDetail['productID'],
'productName' => $dtDetail['productName'],
'price' => rupiah($dtDetail['price']),
'subtotal' => rupiah($subtotal),
'qty' => $dtDetail['qty'],
'note' => $dtDetail['note'],
'no' => $i
);
$grandtotal += $subtotal;
$i++;
}
$q = mysqli_real_escape_string($connect, $_GET['q']);
241
// assign to the tpl
$smarty->assign("soID", $dataSo['soID']);
$smarty->assign("soNo", $dataSo['soNo']);
$smarty->assign("customerID", $dataSo['supplierID']);
$smarty->assign("customerName", $dataSo['customerName']);
$smarty->assign("customerAddress", $dataSo['customerAddress']);
$smarty->assign("staffID", $dataSo['staffID']);
$smarty->assign("staffName", $dataSo['staffName']);
$smarty->assign("orderDate", tgl_indo2($dataSo['orderDate']));
$smarty->assign("needDate", tgl_indo2($dataSo['needDate']));
$smarty->assign("status", $dataSo['status']);
$smarty->assign("note", $dataSo['note']);
$smarty->assign("soFaktur", $soFaktur);
// fetch data
$i = 1;
while ($dtDetail = mysqli_fetch_array($sqlDetail))
{
$subtotal = $dtDetail['qty'] * $dtDetail['price'];
$dataDetail[] = array( 'detailID' => $dtDetail['detailID'],
'productID' => $dtDetail['productID'],
'productName' => $dtDetail['productName'],
'price' => rupiah($dtDetail['price']),
'subtotal' => rupiah($subtotal),
'qty' => $dtDetail['qty'],
'note' => $dtDetail['note'],
'no' => $i
);
$grandtotal += $subtotal;
$i++;
}
$smarty->assign("q", $q);
242
$nDate = explode("-", $_POST['needDate']);
$oDate = explode("-", $_POST['orderDate']);
$needDate = $nDate[2]."-".$nDate[1]."-".$nDate[0];
$orderDate = $oDate[2]."-".$oDate[1]."-".$oDate[0];
// update so
$querySo = "UPDATE as_sales_order SET note = '$note' WHERE
soFaktur = '$soFaktur' AND soNo = '$soNo'";
mysqli_query($connect, $querySo);
243
// delete data
$querySo = "DELETE FROM as_temp_detail_so WHERE detailID =
'$detailID'";
$sqlSo = mysqli_query($connect, $querySo);
if ($sqlDetail)
{
$querySo = "DELETE FROM as_sales_order WHERE soFaktur =
'$soFaktur'";
$sqlSo = mysqli_query($connect, $querySo);
}
$start = substr($dataNoSo['soNo'],0-5);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoSo == '0')
{
$sNo = "00000";
}
elseif ($tempNo == 1)
{
$sNo = "00000";
}
elseif ($tempNo == 2)
{
$sNo = "0000";
244
}
elseif ($tempNo == 3)
{
$sNo = "000";
}
elseif ($tempNo == 4)
{
$sNo = "00";
}
elseif ($tempNo == 5)
{
$sNo = "0";
}
elseif ($tempNo == 6)
{
$sNo = "";
}
$soNo = "SO".$sNo.$next;
$smarty->assign("dataCustomer", $dataCustomer);
if ($numsSo == 0)
{
$orderDate = date('Y-m-d');
$sName = $_SESSION['staffCode']." ".$_SESSION['staffName'];
$querySo = "INSERT INTO as_sales_order( soNo,
soFaktur,
customerID,
customerName,
245
customerAddress,
staffID,
staffName,
orderDate,
needDate,
note,
status,
createdDate,
createdUserID,
modifiedDate,
modifiedUserID)
VALUES( '$soNo',
'$_SESSION[soFaktur]',
'',
'',
'',
'$_SESSION[staffID]',
'$sName',
'$orderDate',
'$orderDate',
'',
'',
'$createdDate',
'$staffID',
'',
'')";
mysqli_query($connect, $querySo);
}
$smarty->assign("customerID", $dataSo['customerID']);
if ($dataSo['needDate'] == '0000-00-00')
{
$needDate = tgl_indo2(date('Y-m-d'));
}
else
{
$needDate = tgl_indo2($dataSo['needDate']);
}
if ($dataSo['orderDate'] == '0000-00-00')
{
$orderDate = tgl_indo2(date('Y-m-d'));
}
else
{
$orderDate = tgl_indo2($dataSo['orderDate']);
}
$smarty->assign("soNo", $soNo);
246
$smarty->assign("orderDateIndo", $orderDate);
$smarty->assign("needDateIndo", $needDate);
$smarty->assign("soFaktur", $_SESSION['soFaktur']);
$smarty->assign("note", $dataSo['note']);
// fetch data
$i = 1;
while ($dtDetilSo = mysqli_fetch_array($sqlDetilSo))
{
$subtotal = $dtDetilSo['price'] * $dtDetilSo['qty'];
$dataDetilSo[] = array('detailID' => $dtDetilSo['detailID'],
'productName' => $dtDetilSo['productName'],
'price' => rupiah($dtDetilSo['price']),
'qty' => $dtDetilSo['qty'],
'note' => $dtDetilSo['note'],
'subtotal' => rupiah($subtotal),
'no' => $i);
$i++;
}
$q = mysqli_real_escape_string($connect, $_GET['q']);
$sDate = mysqli_real_escape_string($connect, $_GET['startDate']);
$eDate = mysqli_real_escape_string($connect, $_GET['endDate']);
$smarty->assign("startDate", $sDate);
$smarty->assign("endDate", $eDate);
$startDate = $s2Date[2]."-".$s2Date[1]."-".$s2Date[0];
$endDate = $e2Date[2]."-".$e2Date[1]."-".$e2Date[0];
247
else
{
$querySo = "SELECT * FROM as_sales_order WHERE soNo LIKE '%$q%'
ORDER BY soID DESC";
}
// fetch data
$i = 1 + $position;
while ($dtSo = mysqli_fetch_array($sqlSo))
{
$dataSo[] = array( 'soID' => $dtSo['soID'],
'soNo' => $dtSo['soNo'],
'soFaktur' => $dtSo['soFaktur'],
'customerName' => $dtSo['customerName'],
'staffName' => $dtSo['staffName'],
'orderDate' => tgl_indo2($dtSo['orderDate']),
'needDate' => tgl_indo2($dtSo['needDate']),
'total' => rupiah($dtSo['total']),
'status' => $dtSo['status'],
'no' => $i);
$i++;
}
$smarty->assign("dataSo", $dataSo);
$smarty->assign("page", $_GET['page']);
$smarty->assign("q", $q);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Sales Order");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi sales order.");
$smarty->assign("breadcumbMenuName", "Sales Order");
$smarty->assign("breadcumbMenuSubName", "Sales Order");
}
else
{
$_SESSION['soFaktur'] = date('Ymdhis');
$smarty->assign("soFaktur", $_SESSION['soFaktur']);
// create new object pagination
$p = new PaginationSo;
// limit 20 data for page
$limit = 30;
$position = $p->searchPosition($limit);
// fetch data
$i = 1 + $position;
while ($dtSo = mysqli_fetch_array($sqlSo))
{
248
$dataSo[] = array( 'soID' => $dtSo['soID'],
'soNo' => $dtSo['soNo'],
'soFaktur' => $dtSo['soFaktur'],
'customerName' => $dtSo['customerName'],
'staffName' => $dtSo['staffName'],
'orderDate' => tgl_indo2($dtSo['orderDate']),
'needDate' => tgl_indo2($dtSo['needDate']),
'total' => rupiah($dtSo['total']),
'status' => $dtSo['status'],
'no' => $i);
$i++;
}
$smarty->assign("dataSo", $dataSo);
// count data
$queryCountSo = "SELECT * FROM as_sales_order";
$sqlCountSo = mysqli_query($connect, $queryCountSo);
$amountData = mysqli_num_rows($sqlCountSo);
$smarty->assign("pageLink", $pageLink);
$smarty->assign("page", $_GET['page']);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Sales Order");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi sales order.");
$smarty->assign("breadcumbMenuName", "Sales Order");
$smarty->assign("breadcumbMenuSubName", "Sales Order");
}
$smarty->assign("module", $module);
$smarty->assign("act", $act);
}
// include footer
include "footer.php";
?>
<style>
div.ui-datepicker{
font-size:14px;
}
</style>
249
<script type='text/javascript'
src="design/js/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css"
href="design/css/jquery.autocomplete.css" />
{literal}
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$( "#orderDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c-1:c-0'
});
$( "#startDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$( "#endDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$('#needDate').change(function () {
var soNo = $("#soNo").val();
var needDate = $("#needDate").val();
$.ajax({
type: 'POST',
url: 'save_so_needdate.php',
dataType: 'JSON',
data:{
soNo: soNo,
needDate: needDate
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "so.php?module=so&act=add";
250
}
});
});
$('#orderDate').change(function () {
var soNo = $("#soNo").val();
var orderDate = $("#orderDate").val();
$.ajax({
type: 'POST',
url: 'save_so_orderdate.php',
dataType: 'JSON',
data:{
soNo: soNo,
orderDate: orderDate
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "so.php?module=so&act=add";
}
});
});
$('#note').change(function () {
var soNo = $("#soNo").val();
var note = $("#note").val();
$.ajax({
type: 'POST',
url: 'save_so_note.php',
dataType: 'JSON',
data:{
soNo: soNo,
note: note
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "so.php?module=so&act=add";
}
});
});
$( "#needDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c-1:c+1'
});
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#productBarcode").autocomplete("product_so_autocomplete.php", {
width: 310
251
}).result(function(event, item, a) {
var myarr = item[0].split(" # ");
document.getElementById('productBarcode').value = myarr[0];
document.getElementById('productName1').value = myarr[1];
document.getElementById('productName').value = myarr[1];
document.getElementById('productID').value = myarr[2];
document.getElementById('unitPrice1').value = myarr[3];
document.getElementById('unitPrice2').value = myarr[4];
document.getElementById('unitPrice3').value = myarr[5];
document.getElementById('price').value = myarr[6];
});
$("#customerID").change(function(e){
var customerID = $("#customerID").val();
$.ajax({
type: 'POST',
url: 'save_so_customer.php',
dataType: 'JSON',
data:{
customerID: customerID
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "so.php?module=so&act=add";
}
});
});
$("#send2").on("click", function(){
var soNo = $("#soNo").val();
var productID = $("#productID").val();
var productName1 = $("#productName1").val();
var qty = parseInt($("#qty").val());
var price = parseInt($("#price").val());
var desc = $("#desc").val();
if (qty != '' && soNo != '' && productID != '' && price != ''){
$.ajax({
type: 'POST',
url: 'save_so.php',
dataType: 'JSON',
data:{
qty: qty,
price: price,
soNo: soNo,
productID: productID,
productName1: productName1,
desc: desc
},
beforeSend: function (data) {
$('#send2').hide();
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "so.php?module=so&act=add";
252
}
});
}
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
<aside class="right-side">
{include file="breadcumb.tpl"}
<div class="box-header">
<i class="ion ion-clipboard"></i>
253
<h3 class="box-title">Tambah Sales Order</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="so.php?module=so&act=cancel" onclick="return
confirm('Anda Yakin ingin membatalkan SO ini?');"><button
class="btn btn-default pull-right">Batal Trx</button></a>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<form method="POST" action="so.php?module=so&act=input">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="130">NO SO / TGL</td>
<td width="5">:</td>
<td><input type="hidden" id="soNo" name="soNo" value="{$soNo}">
<input type="text" id="soNo" name="soNo" value="{$soNo}"
class="form-control" placeholder="NO SO" style="width: 110px;
float: left" DISABLED>
<input type="text" id="orderDate" name="orderDate"
value="{$orderDateIndo}" class="form-control" placeholder="Tanggal
PO" style="width: 160px;" required>
</td>
</tr>
<tr>
<td>TGL DIBUTUHKAN</td>
<td>:</td>
<td><input type="text" id="needDate" name="needDate"
value="{$needDateIndo}" class="form-control" placeholder="Tanggal
Dibutuhkan" style="width: 270px;" required></td>
</tr>
<tr>
<td>CUSTOMER</td>
<td>:</td>
<td>
<select id="customerID" name="customerID" class="form-control"
style="width: 270px;" required>
<option value=""></option>
{section name=dataCustomer loop=$dataCustomer}
{if $dataCustomer[dataCustomer].customerID == $customerID}
<option value="{$dataCustomer[dataCustomer].customerID}"
SELECTED>{$dataCustomer[dataCustomer].customerName}
[{$dataCustomer[dataCustomer].customerCode}]</option>
{else}
<option value="{$dataCustomer[dataCustomer].customerID}">
{$dataCustomer[dataCustomer].customerName}
[{$dataCustomer[dataCustomer].customerCode}]</option>
{/if}
{/section}
</select>
</td>
</tr>
<tr>
<td>NOTE</td>
<td>:</td>
254
<td><input type="text" value="{$note}" id="note" name="note"
class="form-control" placeholder="Note" style="width:
270px;"></td>
</tr>
<tr>
<td colspan="3">
<br>
{if $numsDetilSo < 10}
<a href="#inline" class="modalbox"><button class="btn btn-default
pull-left"><i class="fa fa-plus"></i> Add</button></a>
{/if}
</td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>HARGA SATUAN</th>
<th>QTY</th>
<th>SUBTOTAL</th>
<th>NOTE</th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataDetilSo loop=$dataDetilSo}
<tr>
<td>{$dataDetilSo[dataDetilSo].no}</td>
<td>{$dataDetilSo[dataDetilSo].productName}</td>
<td style='text-align: right;'>{$dataDetilSo[dataDetilSo]
.price}</td>
<td style='text-align: center;'>{$dataDetilSo[dataDetilSo]
.qty}</td>
<td style='text-align: right;'>{$dataDetilSo[dataDetilSo]
.subtotal}</td>
<td>{$dataDetilSo[dataDetilSo].note}</td>
<td>
<a title="Edit" href="edit_so.php?module=so&act=edit&detailID
={$dataDetilSo[dataDetilSo].detailID}" data-width="550" data-
height="230" class="various2 fancybox.iframe"><img
src="img/icons/edit.png" width="18"></a>
<a title="Delete" href="so.php?module=so&act=deletedetail&detailID
={$dataDetilSo[dataDetilSo].detailID}" onclick="return
confirm('Anda Yakin ingin menghapus item produk
{$dataDetilSo[dataDetilSo].productName}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
<br>
255
<br>
{if $numsDetilSo > 0}
<button type="submit" class="btn btn-primary">Simpan</button>
{else}
<button type="button" class="btn btn-primary">Simpan</button>
{/if}
</form>
<div id="inline">
<table width="95%" align="center">
<tr>
<td colspan="3"><h3>Tambah Item</h3></td>
</tr>
<tr>
<td>
<form id="so" name="so" method="POST" action="#">
<input type="hidden" id="soNo" name="soNo" value="{$soNo}">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="140">Kode Produk</td>
<td width="5">:</td>
<td><input type="text" id="productBarcode"
name="productBarcode" class="form-control" placeholder="Kode atau
Nama Produk" style="width: 360px;" required></td>
</tr>
<tr>
<td colspan="2"></td>
<td><input type="hidden" id="productID" name="productID">
<input type="hidden" id="productName1" name="productName1">
<input type="text" id="productName" name="productName"
class="form-control" placeholder="Nama Produk" style="width:
360px;" DISABLED>
</td>
</tr>
<tr>
<td>Harga Satuan</td>
<td>:</td>
<td><input id="unitPrice1" name="unitPrice1" class="form-control"
placeholder="Harga 1" style="width: 120px; float: left;" DISABLED>
<input id="unitPrice2" name="unitPrice2" class="form-control"
placeholder="Harga 2" style="width: 120px; float: left;" DISABLED>
<input id="unitPrice3" name="unitPrice3" class="form-control"
placeholder="Harga 3" style="width: 120px;;" DISABLED>
</td>
</tr>
<tr>
<td>Masukan Harga</td>
<td>:</td>
<td><input type="number" id="price" name="price"
class="form-control" placeholder="Harga Satuan" style="width:
360px;" required></td>
</tr>
<tr>
<td>Qty</td>
<td>:</td>
256
<td><input type="number" id="qty" name="qty" class="form-control"
placeholder="Qty Produk" style="width: 360px;" required></td>
</tr>
<tr>
<td>Note</td>
<td>:</td>
<td><input type="text" id="desc" name="desc" class="form-
control" placeholder="Note" style="width: 360px;"></td>
</tr>
</table>
<button id="send2" class="btn btn-primary">Simpan</button>
</form>
</td>
</tr>
</table>
</div>
<div class="box-body">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="130">NO SO / TGL</td>
<td width="5">:</td>
<td>{$soNo} / {$orderDate}</td>
</tr>
<tr>
<td>TGL DIBUTUHKAN</td>
<td>:</td>
<td>{$needDate}</td>
</tr>
<tr>
<td>CUSTOMER</td>
<td>:</td>
<td>{$customerName}</td>
</tr>
<tr>
<td>NOTE</td>
<td>:</td>
257
<td>{$note}</td>
</tr>
<tr>
<td colspan="3"><br></td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>HARGA SATUAN</th>
<th>QTY</th>
<th>SUBTOTAL</th>
<th>NOTE</th>
</tr>
</thead>
<tbody>
{section name=dataDetail loop=$dataDetail}
<tr>
<td>{$dataDetail[dataDetail].no}</td>
<td>{$dataDetail[dataDetail].productName}</td>
<td style="text-align: right;">{$dataDetail[dataDetail]
.price}</td>
<td style="text-align: center;">{$dataDetail[dataDetail]
.qty}</td>
<td style="text-align: right;">{$dataDetail[dataDetail]
.subtotal}</td>
<td>{$dataDetail[dataDetail].note}</td>
</tr>
{/section}
<tr>
<td colspan="4"></td>
<td style="text-align: right;">{$grandtotal}</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div><!-- /.box-body -->
258
{/literal}
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Detail Sales Order</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="print_unit_so.php?module=so&act=print&soID={$soID}&
soFaktur={$soFaktur}" target="_blank"><button class="btn btn-
default pull-right">Print</button></a>
<a href="so.php"><button class="btn btn-default pull-right
">Close</button></a>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="130">NO SO / TGL</td>
<td width="5">:</td>
<td>{$soNo} / {$orderDate}</td>
</tr>
<tr>
<td>TGL DIBUTUHKAN</td>
<td>:</td>
<td>{$needDate}</td>
</tr>
<tr>
<td>CUSTOMER</td>
<td>:</td>
<td>{$customerName}</td>
</tr>
<tr>
<td>NOTE</td>
<td>:</td>
<td>{$note}</td>
</tr>
<tr>
<td colspan="3"><br></td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>HARGA SATUAN</th>
<th>QTY</th>
<th>SUBTOTAL</th>
<th>NOTE</th>
</tr>
</thead>
<tbody>
{section name=dataDetail loop=$dataDetail}
259
<tr>
<td>{$dataDetail[dataDetail].no}</td>
<td>{$dataDetail[dataDetail].productName}</td>
<td style="text-align: right;">{$dataDetail[dataDetail]
.price}</td>
<td style="text-align: center;">{$dataDetail[dataDetail].qty}</td>
<td style="text-align: right;">{$dataDetail[dataDetail]
.subtotal}</td>
<td>{$dataDetail[dataDetail].note}</td>
</tr>
{/section}
<tr>
<td colspan="4"></td>
<td style="text-align: right;">{$grandtotal}</td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
260
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NO SO <i class="fa fa-sort"></i></th>
<th>TGL SO <i class="fa fa-sort"></i></th>
<th>TGL DIBUTUHKAN <i class="fa fa-sort"></i></th>
<th>SUPPLIER <i class="fa fa-sort"></i></th>
<th>STATUS <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataSo loop=$dataSo}
<tr>
<td>{$dataSo[dataSo].no}</td>
<td>{$dataSo[dataSo].soNo}</td>
<td>{$dataSo[dataSo].orderDate}</td>
<td>{$dataSo[dataSo].needDate}</td>
<td>{$dataSo[dataSo].customerName}</td>
<td>{$dataSo[dataSo].status}</td>
<td>{$dataSo[dataSo].staffName}</td>
<td>
<a title="Detail" href="so.php?module=so&act=detailso&soID=
{$dataSo[dataSo].soID}&soFaktur={$dataSo[dataSo].soFaktur}&q={$q}&
page={$page}"><img src="img/icons/view.png" width="18"></a>
<a title="Delete" href="so.php?module=so&act=delete&soID=
{$dataSo[dataSo].soID}&soFaktur={$dataSo[dataSo].soFaktur}&soNo={$
dataSo[dataSo].soNo}" onclick="return confirm('Anda Yakin ingin
menghapus transaksi {$dataSo[dataSo].soNo}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
{else}
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<form method="GET" action="so.php">
<input type="hidden" name="module" value="so">
<input type="hidden" name="act" value="search">
<button type="submit" class="btn btn-default pull-right"><i
class="fa fa-search"></i> Search</button>
<input type="text" id="endDate" name="endDate" value="{$endDate}"
class="form-control" placeholder="Periode Akhir" style="float:
right; width: 115px;">
<input type="text" id="startDate" name="startDate"
value="{$startDate}" class="form-control" placeholder="Periode
Awal" style="float: right; width: 115px;">
261
<input type="text" id="q" name="q" value="{$q}" class="form-
control" placeholder="Pencarian : Nomor SO" style="float: right;
width: 270px;">
<a href="so.php?module=so&act=add" style="float: left;"><button
type="button" class="btn btn-default pull-right"><i class="fa fa-
plus"></i> Add</button></a>
<a href="print_so.php?act=print&q={$q}" style="float: left;"
target="_blank"><button type="button" class="btn btn-default pull-
right"><i class="fa fa-print"></i> Print PDF</button></a>
</form>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NO SO <i class="fa fa-sort"></i></th>
<th>TGL SO <i class="fa fa-sort"></i></th>
<th>TGL DIBUTUHKAN <i class="fa fa-sort"></i></th>
<th>CUSTOMER <i class="fa fa-sort"></i></th>
<th>STATUS <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataSo loop=$dataSo}
<tr>
<td>{$dataSo[dataSo].no}</td>
<td>{$dataSo[dataSo].soNo}</td>
<td>{$dataSo[dataSo].orderDate}</td>
<td>{$dataSo[dataSo].needDate}</td>
<td>{$dataSo[dataSo].customerName}</td>
<td>{$dataSo[dataSo].status}</td>
<td>{$dataSo[dataSo].staffName}</td>
<td>
<a title="Detail" href="so.php?module=so&act=detailso&soID=
{$dataSo[dataSo].soID}&soFaktur={$dataSo[dataSo].soFaktur}&page={$
page}"><img src="img/icons/view.png" width="18"></a>
<a title="Delete" href="so.php?module=so&act=delete&soID=
{$dataSo[dataSo].soID}&soFaktur={$dataSo[dataSo].soFaktur}&soNo={$
dataSo[dataSo].soNo}" onclick="return confirm('Anda Yakin ingin
menghapus transaksi {$dataSo[dataSo].soNo}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
262
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-left">
<ul class="pagination pagination-sm inline">
{$pageLink}
</ul>
</div>
</div><!-- /.box-header -->
{/if}
{include file="footer.tpl"}
Hasil skrip diatas akan menghasilkan halaman sales oder yang bisa dilihat pada
gambar-gambar berikut :
263
Gambar 5.31. Tambah item sales order
264
Setelah kita menerima sales order, kemudian kita siapkan barang sesuai dengan
apa yang dipesan maka selanjutnya kita akan mengirimkan barang tersebut ke
customer, nah dibutuhkan surat delivery order atau istilah kerennya adalah surat
jalan. Halaman ini digunakan untuk membuat delivery order.
Buat beberapa file dengan masing-masing skrip berikut :
do.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "do.tpl";
$module = $_GET['module'];
$act = $_GET['act'];
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE modulID =
'29'";
$sqlAuthorizeStaff = mysqli_query($connect, $queryAuthorizeStaff);
$dataAuthorizeStaff = mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'], $_SESSION['level'])
=== FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
// fetch data
while ($dataDo = mysqli_fetch_array($sqlDo))
{
265
$querySP = "UPDATE as_stock_products SET
stock=stock+$dataDo[deliveredQty] WHERE productID =
'$dataDo[productID]' AND factoryID = '$dataDo[factoryID]'";
mysqli_query($connect, $querySP);
}
// delete do
$queryDo2 = "DELETE FROM as_delivery_order WHERE doID =
'$doID' AND doNo = '$doNo' AND doFaktur = '$doFaktur'";
$sqlDo2 = mysqli_query($connect, $queryDo2);
$dataSo = mysqli_fetch_array(mysqli_query($connect,
"SELECT soID FROM as_sales_order WHERE soNo = '$soNo'"));
266
$f = explode("#", $factory[$i]);
$factoryID = $f[0];
$factoryName = $f[1]." ".$f[2];
$productNm = mysqli_real_escape_string($connect,
$productName[$i]);
$notedet = mysqli_real_escape_string($connect, $notedetail[$i]);
$total = $price[$i] * $deliveredQty[$i];
if ($status[$i] == 'Y')
{
$queryInsert = "INSERT INTO as_detail_do ( doNo,
doFaktur,
productID,
productName,
price,
qty,
deliveredQty,
deliveredStatus,
factoryID,
factoryName,
note,
createdDate,
createdUserID)
VALUES( '$doNo',
'$doFaktur',
'$productID[$i]',
'$productNm',
'$price[$i]',
'$qty[$i]',
'$deliveredQty[$i]',
'$status[$i]',
'$factoryID',
'$factoryName',
'$notedet',
'$modifiedDate',
'$staffID')";
mysqli_query($connect, $queryInsert);
$grandtotal += $total;
}
}
267
orderDate = '$orderDate',
needDate = '$needDate',
total = '$grandtotal',
note = '$note',
modifiedDate = '$modifiedDate',
modifiedUserID = '$staffID'
WHERE doID = '$doID' AND doFaktur = '$doFaktur'";
$sqlDo = mysqli_query($connect, $queryDo);
$_SESSION['doFaktur'] = "";
header("Location:
do.php?module=do&act=finish&doNo=".$doNo."&doFaktur=".$doFaktur);
}
$i = 1;
while ($dtDoDetail = mysqli_fetch_array($sqlDoDetail))
{
$dataDoDetail[] = array( 'detailID' =>
$dtDoDetail['detailID'],
'doNo' => $dtDoDetail['doNo'],
'doFaktur' => $dtDoDetail['doFaktur'],
268
'productID' => $dtDoDetail['productID'],
'productName' => $dtDoDetail['productName'],
'price' => $dtDoDetail['price'],
'qty' => $dtDoDetail['qty'],
'deliveredQty' => $dtDoDetail['deliveredQty'],
'status' => $dtDoDetail['deliveredStatus'],
'factoryID' => $dtDoDetail['factoryID'],
'factoryName' => $dtDoDetail['factoryName'],
'note' => $dtDoDetail['note'],
'no' => $i
);
$i++;
}
$smarty->assign("dataDoDetail", $dataDoDetail);
$smarty->assign("page", $_GET['page']);
$smarty->assign("q", $_GET['q']);
$_SESSION['doFaktur'] = "";
header("Location: do.php");
}
$smarty->assign("doID", $dataDo['doID']);
$smarty->assign("doNo", $dataDo['doNo']);
$smarty->assign("doFaktur", $dataDo['doFaktur']);
$smarty->assign("soID", $dataDo['soID']);
$smarty->assign("soNo", $dataDo['soNo']);
$smarty->assign("customerID", $dataDo['customerID']);
269
$smarty->assign("customerName", $dataDo['customerName']);
$smarty->assign("staffID", $dataDo['staffID']);
$smarty->assign("staffName", $dataDo['staffName']);
$smarty->assign("deliveredDate",
tgl_indo2($dataDo['deliveredDate']));
$smarty->assign("orderDate", tgl_indo2($dataDo['orderDate']));
$smarty->assign("needDate", tgl_indo2($dataDo['needDate']));
$smarty->assign("note", $dataDo['note']);
// fetch data
$k = 1;
while ($dtDoDetail = mysqli_fetch_array($sqlDoDetail))
{
if ($dtDoDetail['deliveredStatus'] == 'Y')
{
$status = "Y";
}
else
{
$status = "N";
}
$smarty->assign("dataDoDetail", $dataDoDetail);
$smarty->assign("breadcumbTitle", "Delivery Order");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk melakukan
transaksi delivery order.");
$smarty->assign("breadcumbMenuName", "Delivery Order");
$smarty->assign("breadcumbMenuSubName", "Delivery Order");
}
270
$queryNoDo = "SELECT doNo FROM as_delivery_order ORDER BY doNo
DESC LIMIT 1";
$sqlNoDo = mysqli_query($connect, $queryNoDo);
$numsNoDo = mysqli_num_rows($sqlNoDo);
$dataNoDo = mysqli_fetch_array($sqlNoDo);
$start = substr($dataNoDo['doNo'],2-7);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoDo == '0')
{
$dNo = "00000";
}
elseif ($tempNo == 1)
{
$dNo = "00000";
}
elseif ($tempNo == 2)
{
$dNo = "0000";
}
elseif ($tempNo == 3)
{
$dNo = "000";
}
elseif ($tempNo == 4)
{
$dNo = "00";
}
elseif ($tempNo == 5)
{
$dNo = "0";
}
elseif ($tempNo == 6)
{
$dNo = "";
}
$doNo = "DO".$dNo.$next;
if ($numsDo == 0)
{
$deliveredDate = date('Y-m-d');
$sName = $_SESSION['staffCode']." ".$_SESSION['staffName'];
$queryDo = "INSERT INTO as_delivery_order ( doFaktur,
doNo,
soID,
soNo,
customerID,
customerName,
271
staffID,
staffName,
deliveredDate,
orderDate,
needDate,
total,
note,
createdDate,
createdUserID,
modifiedDate,
modifiedUserID)
VALUES( '$doFaktur',
'$doNo',
'',
'',
'',
'',
'$_SESSION[staffID]',
'$sName',
'$deliveredDate',
'',
'',
'',
'',
'$createdDate',
'$staffID',
'',
'')";
mysqli_query($connect, $queryDo);
}
$smarty->assign("doNo", $dataDo['doNo']);
$smarty->assign("doID", $dataDo['doID']);
if ($dataDo['deliveredDate'] == '0000-00-00')
{
$deliveredDate = date('Y-m-d');
}
else
{
$deliveredDate = $dataDo['deliveredDate'];
}
$smarty->assign("deliveredDate", tgl_indo2($deliveredDate));
$smarty->assign("note", $dataDo['note']);
272
$numsSo = mysqli_num_rows($sqlSo);
$smarty->assign("numsSo", $numsSo);
$smarty->assign("numsDo", $numsDo);
$dataFactory = array();
273
'no' => $i
);
$i++;
}
//$smarty->assign("dataFactory", $dataFactory);
$smarty->assign("startDate", $sDate);
$smarty->assign("endDate", $eDate);
$startDate = $s2Date[2]."-".$s2Date[1]."-".$s2Date[0];
$endDate = $e2Date[2]."-".$e2Date[1]."-".$e2Date[0];
// fetch data
$i = 1 + $position;
while ($dtDo = mysqli_fetch_array($sqlDo))
{
$dataDo[] = array( 'doID' => $dtDo['doID'],
'doNo' => $dtDo['doNo'],
'doFaktur' => $dtDo['doFaktur'],
'soID' => $dtDo['soID'],
274
'soNo' => $dtDo['soNo'],
'customerID' => $dtDo['customerID'],
'customerName' => $dtDo['customerName'],
'staffID' => $dtDo['staffID'],
'staffName' => $dtDo['staffName'],
'deliveredDate' => tgl_indo2($dtDo['deliveredDate']),
'note' => $dtDo['note'],
'no' => $i);
$i++;
}
$smarty->assign("dataDo", $dataDo);
$smarty->assign("page", $_GET['page']);
$smarty->assign("q", $q);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Delivery Order");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi delivery order.");
$smarty->assign("breadcumbMenuName", "Delivery Order");
$smarty->assign("breadcumbMenuSubName", "Delivery Order");
}
else
{
$doFaktur = date('Ymdhis');
$_SESSION['doFaktur'] = $doFaktur;
// fetch data
$i = 1 + $position;
while ($dtDo = mysqli_fetch_array($sqlDo))
{
$dataDo[] = array( 'doID' => $dtDo['doID'],
'doNo' => $dtDo['doNo'],
'doFaktur' => $dtDo['doFaktur'],
'soID' => $dtDo['soID'],
'soNo' => $dtDo['soNo'],
'customerID' => $dtDo['customerID'],
'customerName' => $dtDo['customerName'],
'staffID' => $dtDo['staffID'],
'staffName' => $dtDo['staffName'],
'deliveredDate' => tgl_indo2($dtDo['deliveredDate']),
'note' => $dtDo['note'],
'no' => $i);
$i++;
275
}
$smarty->assign("dataDo", $dataDo);
// count data
$queryCountDo = "SELECT * FROM as_delivery_order";
$sqlCountDo = mysqli_query($connect, $queryCountDo);
$amountData = mysqli_num_rows($sqlCountDo);
$smarty->assign("pageLink", $pageLink);
$smarty->assign("page", $_GET['page']);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Delivery Order");
$smarty->assign("breadcumbTitleSmall", "Halaman untuk
melakukan transaksi delivery order.");
$smarty->assign("breadcumbMenuName", "Delivery Order");
$smarty->assign("breadcumbMenuSubName", "Delivery Order");
}
$smarty->assign("module", $module);
$smarty->assign("act", $act);
}
// include footer
include "footer.php";
?>
<style>
div.ui-datepicker{
font-size:14px;
}
</style>
{literal}
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
276
scrolling: 'no',
afterLoad: function(){
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$( "#deliveredDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c-1:c-0'
});
$( "#startDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$( "#endDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$('#deliveredDate').change(function () {
var doNo = $("#doNo").val();
var doID = $("#doID").val();
var soNo = $("#soNo").val();
var deliveredDate = $("#deliveredDate").val();
$.ajax({
type: 'POST',
url: 'save_do_delivereddate.php',
dataType: 'JSON',
data:{
doNo: doNo,
doID: doID,
deliveredDate: deliveredDate
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "do.php?module=do&act=add&soNo=" + soNo;
}
});
});
$('#note').change(function () {
var doNo = $("#doNo").val();
var doID = $("#doID").val();
var soNo = $("#soNo").val();
277
var note = $("#note").val();
$.ajax({
type: 'POST',
url: 'save_do_note.php',
dataType: 'JSON',
data:{
doNo: doNo,
doID: doID,
soNo: soNo,
note: note
},
success: function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "do.php?module=do&act=add&soNo=" + soNo;
}
});
});
$('#soNo').change(function () {
var soNo = $("#soNo").val();
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#send2").on("click", function(){
var doNo = $("#doNo").val();
var productID = $("#productID").val();
var productName1 = $("#productName1").val();
var qty = parseInt($("#qty").val());
var price = parseInt($("#price").val());
var desc = $("#desc").val();
if (qty != '' && soNo != '' && productID != '' && price != ''){
$.ajax({
type: 'POST',
url: 'save_so.php',
dataType: 'JSON',
data:{
qty: qty,
price: price,
soNo: soNo,
productID: productID,
productName1: productName1,
desc: desc
},
beforeSend: function (data) {
$('#send2').hide();
},
success: function(data) {
278
setTimeout("$.fancybox.close()", 1000);
window.location.href = "so.php?module=so&act=add";
}
});
}
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
{include file="user_panel.tpl"}
{include file="side_menu.tpl"}
</section>
<!-- /.sidebar -->
</aside>
<aside class="right-side">
{include file="breadcumb.tpl"}
279
</script>
{/literal}
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Tambah Surat Jalan</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="do.php?module=do&act=cancel" onclick="return
confirm('Anda Yakin ingin membatalkan surat jalan ini?');"><button
class="btn btn-default pull-right">Batal Trx</button></a>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<form method="POST" action="do.php?module=do&act=input">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="150">NO DO / TGL</td>
<td width="5">:</td>
<td><input type="hidden" id="doNo" name="doNo" value="{$doNo}">
<input type="hidden" id="doID" name="doID" value="{$doID}">
<input type="text" id="doNo" name="doNo" value="{$doNo}"
class="form-control" placeholder="NO DO" style="width: 110px;
float: left" DISABLED>
<input type="text" id="deliveredDate" name="deliveredDate"
value="{$deliveredDate}" class="form-control" placeholder="Tanggal
DO" style="width: 160px;" required>
</td>
</tr>
<tr valign="top">
<td>NO SO</td>
<td>:</td>
<td><input type="text" id="soNo" name="soNo"
value="{$soNo}" class="form-control" placeholder="Nomor SO"
style="width: 270px;" required>
{if $numsSo == '0' AND $soNo != ''}
<font color="#f56954">Nomor SO tidak ditemukan.</font>
{/if}
{if $numsDo > 0 AND $soNo != ''}
<font color="#f56954">Nomor SO sudah digunakan.</font>
{/if}
</td>
</tr>
<tr>
<td>CUSTOMER</td>
<td>:</td>
<td>{if $numsDo == '0' AND $soNo != ''}
<input type="hidden" id="customerID" name="customerID"
value="{$customerID}">
<input type="hidden" id="customerName" name="customerName"
value="{$customerName}">
<input type="hidden" id="customerAddress" name="customerAddress"
value="{$customerAddress}">
280
<input type="text" id="customerName" name="customerName"
value="{$customerName}" class="form-control"
placeholder="Customer" style="width: 270px;" DISABLED>
{else}
<input type="text" id="customerName" name="customerName"
class="form-control" placeholder="Customer" style="width: 270px;"
DISABLED>
{/if}
</td>
</tr>
<tr>
<td>TGL SO/DIBUTUHKAN</td>
<td>:</td>
<td><input type="hidden" id="orderDate" name="orderDate"
value="{$orderDate}"><input type="hidden" id="needDate"
name="needDate" value="{$needDate}">
{if $numsDo == '0' AND $soNo != ''}
<input type="text" id="orderDate" name="orderDate"
value="{$orderDate}" class="form-control" placeholder="Tgl Order"
style="float: left; width: 135px;" DISABLED><input type="text"
id="orderDate" name="needDate" value="{$needDate}" class="form-
control" placeholder="Tgl Dibutuhkan" style="width: 135px;"
DISABLED></td>
{else}
<input type="text" id="orderDate" name="orderDate" class="form-
control" placeholder="Tgl Order" style="float: left; width:
135px;" DISABLED><input type="text" id="orderDate" name="needDate"
class="form-control" placeholder="Tgl Dibutuhkan" style="width:
135px;" DISABLED></td>
{/if}
</tr>
<tr>
<td>NOTE</td>
<td>:</td>
<td>{if $numsDo == '0' AND $soNo != ''}
<input type="text" value="{$note}" id="note" name="note"
class="form-control" placeholder="Note" style="width: 270px;">
{else}
<input type="text" id="note" name="note" class="form-control"
placeholder="Note" style="width: 270px;">
{/if}</td>
</tr>
<tr>
<td colspan="3">
<br>
</td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>NOTE</th>
<th>JML ORDER</th>
281
<th>JML DIKIRIM</th>
<th>KIRIM</th>
<th>DARI GUDANG</th>
</tr>
</thead>
<tbody>
{if $numsDo == '0' AND $soNo != ''}
{section name=dataDetail loop=$dataDetail}
<tr>
<td>{$dataDetail[dataDetail].no} <input type="hidden"
name="detailID[]" id="detailID"
value="{$dataDetail[dataDetail].detailID}"></td>
<td>{$dataDetail[dataDetail].productName} <input type="hidden"
name="productName[]" id="productName"
value="{$dataDetail[dataDetail].productName}"> <input
type="hidden" name="productID[]" id="productID"
value="{$dataDetail[dataDetail].productID}"></td>
<td>{$dataDetail[dataDetail].note} <input type="hidden"
name="notedetail[]" id="notedetail"
value="{$dataDetail[dataDetail].note}"></td>
<td style='text-align: center;'>{$dataDetail[dataDetail].qty}
<input type="hidden" name="qty[]" id="qty"
value="{$dataDetail[dataDetail].qty}"> <input type="hidden"
name="price[]" id="price"
value="{$dataDetail[dataDetail].price}"></td>
<td><input type="number" value="0" id="deliveredQty"
name="deliveredQty[]" class="form-control" placeholder="Jml"
style="width: 100px;" required></td>
<td>
<select id="status" name="status[]" class="form-control"
style="width: 100px;" required>
<option value=""></option>
<option value="Y">YA</option>
<option value="N">TIDAK</option>
</select>
</td>
<td>
<select id="factory" name="factory[]" class="form-control"
style="width: 180px;" required>
<option value=""></option>
{section name=dataFactory
loop=$dataDetail[dataDetail].dataFactory}
<option value="{$dataDetail[dataDetail].dataFactory[dataFactory]
.factoryID}#{$dataDetail[dataDetail].dataFactory[dataFactory].fact
oryCode}#{$dataDetail[dataDetail].dataFactory[dataFactory].factory
Name}">{$dataDetail[dataDetail].dataFactory[dataFactory].factoryCo
de} {$dataDetail[dataDetail].dataFactory[dataFactory].factoryName}
[Stok : {$dataDetail[dataDetail].dataFactory[dataFactory].stock}]
</option>
{/section}
</select>
</td>
</tr>
{/section}
{/if}
</tbody>
</table>
282
</div>
<br><br>
{if $numsSo > 0}
{if $numsDo > 0 AND $soNo != ''}
{else}
<button type="submit" class="btn btn-primary">Simpan</button>
{/if}
{/if}
</form>
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">Delivery Order</h3>
<div class="box-tools pull-right">
<div class="box-footer clearfix no-border">
<a href="print_unit_do.php?module=do&act=print&doID={$doID}&doNo=
{$doNo}&doFaktur={$doFaktur}" target="_blank"><button class="btn
btn-default pull-right">Print</button></a>
<a href="do.php"><button class="btn btn-default pull-
right">Close</button></a>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="150">NO DO / TGL</td>
<td width="5">:</td>
<td><input type="text" id="doNo" name="doNo"
value="{$doNo}" class="form-control" placeholder="ID BBM"
style="width: 110px; float: left" DISABLED>
<input type="text" id="deliveredDate" name="deliveredDate"
value="{$deliveredDate}" class="form-control" placeholder="Tanggal
DO" style="width: 160px;" DISABLED>
</td>
</tr>
<tr valign="top">
<td>NO SO</td>
283
<td>:</td>
<td><input type="text" id="soNo" name="soNo"
value="{$soNo}" class="form-control" placeholder="Nomor SO"
style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>CUSTOMER</td>
<td>:</td>
<td><input type="text" id="customerName"
name="customerName" value="{$customerName}" class="form-control"
placeholder="Customer" style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>TGL SO/DIBUTUHKAN</td>
<td>:</td>
<td><input type="text" id="orderDate" name="orderDate"
value="{$orderDate}" class="form-control" placeholder="Tgl Order"
style="float: left; width: 135px;" DISABLED><input type="text"
id="orderDate" name="needDate" value="{$needDate}" class="form-
control" placeholder="Tgl Dibutuhkan" style="width: 135px;"
DISABLED></td>
</tr>
<tr>
<td>NOTE</td>
<td>:</td>
<td><input type="text" value="{$note}" id="note"
name="note" class="form-control" placeholder="Note" style="width:
270px;" DISABLED></td>
</tr>
<tr>
<td colspan="3">
<br>
</td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>NOTE</th>
<th>JML ORDER</th>
<th>JML DIKIRIM</th>
<th>KIRIM</th>
<th>DARI GUDANG</th>
</tr>
</thead>
<tbody>
{section name=dataDoDetail loop=$dataDoDetail}
<tr>
<td>{$dataDoDetail[dataDoDetail].no}</td>
<td>{$dataDoDetail[dataDoDetail].productName}</td>
<td>{$dataDoDetail[dataDoDetail].note}</td>
<td style='text-align: center;'>{$dataDoDetail[dataDoDetail]
.qty}</td>
284
<td style='text-align: center;'>{$dataDoDetail[dataDoDetail]
.deliveredQty}</td>
<td style='text-align: center;'>{$dataDoDetail[dataDoDetail]
.status}</td>
<td>{$dataDoDetail[dataDoDetail].factoryName}</td>
</tr>
{/section}
</tbody>
</table>
</div>
<div class="box-body">
<table cellpadding="3" cellspacing="3">
<tr>
<td width="150">NO DO / TGL</td>
<td width="5">:</td>
<td><input type="text" id="doNo" name="doNo"
value="{$doNo}" class="form-control" placeholder="NO DO"
style="width: 110px; float: left" DISABLED>
<input type="text" id="deliveredDate" name="deliveredDate"
value="{$deliveredDate}" class="form-control" placeholder="Tanggal
DO" style="width: 160px;" DISABLED>
</td>
</tr>
<tr valign="top">
<td>NO SO</td>
<td>:</td>
<td><input type="text" id="soNo" name="soNo"
value="{$soNo}" class="form-control" placeholder="Nomor SO"
style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>CUSTOMER</td>
<td>:</td>
285
<td><input type="text" id="customerName"
name="customerName" value="{$customerName}" class="form-control"
placeholder="Customer" style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>TGL SO/DIBUTUHKAN</td>
<td>:</td>
<td><input type="text" id="orderDate" name="orderDate"
value="{$orderDate}" class="form-control" placeholder="Tgl Order"
style="float: left; width: 135px;" DISABLED><input type="text"
id="orderDate" name="needDate" value="{$needDate}" class="form-
control" placeholder="Tgl Dibutuhkan" style="width: 135px;"
DISABLED></td>
</tr>
<tr>
<td>NOTE</td>
<td>:</td>
<td><input type="text" value="{$note}" id="note"
name="note" class="form-control" placeholder="Note" style="width:
270px;" DISABLED></td>
</tr>
<tr>
<td colspan="3">
<br>
</td>
</tr>
</table>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>NOTE</th>
<th>JML ORDER</th>
<th>JML DIKIRIM</th>
<th>TERIMA</th>
<th>GUDANG</th>
</tr>
</thead>
<tbody>
{section name=dataDoDetail loop=$dataBbmDetail}
<tr>
<td>{$dataDoDetail[dataDoDetail].no}</td>
<td>{$dataDoDetail[dataDoDetail].productName}</td>
<td>{$dataDoDetail[dataDoetail].note}</td>
<td style='text-align: center;'>{$dataDoDetail[dataDoDetail]
.qty}</td>
<td style='text-align: center;'>{$dataDoDetail[dataDoDetail]
.receiveQty}</td>
<td style='text-align: center;'>{$dataDoDetail[dataDoDetail]
.status}</td>
<td>{$dataDoDetail[dataDoDetail].factoryName}</td>
</tr>
{/section}
</tbody>
286
</table>
</div>
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO <i class="fa fa-sort"></i></th>
<th>NO DO <i class="fa fa-sort"></i></th>
<th>NO SO <i class="fa fa-sort"></i></th>
<th>CUSTOMER <i class="fa fa-sort"></i></th>
<th>TGL PENGIRIMAN <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataDo loop=$dataDo}
<tr>
<td>{$dataDo[dataDo].no}</td>
<td>{$dataDo[dataDo].doNo}</td>
<td>{$dataDo[dataDo].soNo}</td>
<td>{$dataDo[dataDo].customerName}</td>
287
<td>{$dataDo[dataDo].deliveredDate}</td>
<td>{$dataDo[dataDo].staffName}</td>
<td>
<a title="Detail" href="do.php?module=do&act=detaildo&doID=
{$dataDo[dataDo].doID}&doNo={$dataDo[dataDo].doNo}&doFaktur={$data
Do[dataDo].doFaktur}&q={$q}&page={$page}"><img
src="img/icons/view.png" width="18"></a>
<a title="Delete" href="do.php?module=do&act=delete&doID=
{$dataDo[dataDo].doID}&doFaktur={$dataDo[dataDo].doFaktur}&doNo={$
dataDo[dataDo].doNo}" onclick="return confirm('Anda Yakin ingin
membatalkan transaksi {$dataDo[dataDo].doNo}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
</div>
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
288
<th>NO <i class="fa fa-sort"></i></th>
<th>NO DO <i class="fa fa-sort"></i></th>
<th>NO SO <i class="fa fa-sort"></i></th>
<th>CUSTOMER <i class="fa fa-sort"></i></th>
<th>TGL PENGIRIMAN <i class="fa fa-sort"></i></th>
<th>DIBUAT OLEH <i class="fa fa-sort"></i></th>
<th>AKSI</th>
</tr>
</thead>
<tbody>
{section name=dataDo loop=$dataDo}
<tr>
<td>{$dataDo[dataDo].no}</td>
<td>{$dataDo[dataDo].doNo}</td>
<td>{$dataDo[dataDo].soNo}</td>
<td>{$dataDo[dataDo].customerName}</td>
<td>{$dataDo[dataDo].deliveredDate}</td>
<td>{$dataDo[dataDo].staffName}</td>
<td>
<a title="Detail" href="do.php?module=do&act=detaildo&bbmID=
{$dataDo[dataDo].doID}&doNo={$dataDo[dataDo].doNo}&doFaktur={$data
Do[dataDo].doFaktur}&page={$page}"><img src="img/icons/view.png"
width="18"></a>
<a title="Delete" href="do.php?module=do&act=delete&doID=
{$dataDo[dataDo].doID}&doFaktur={$dataDo[dataDo].doFaktur}&doNo={$
dataDo[dataDo].doNo}" onclick="return confirm('Anda Yakin ingin
membatalkan transaksi {$dataDo[dataDo].doNo}?');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
<div class="box-header">
<i class="ion ion-clipboard"></i>
<div class="box-tools pull-left">
<ul class="pagination pagination-sm inline">
{$pageLink}
</ul>
</div>
</div><!-- /.box-header -->
{/if}
{include file="footer.tpl"}
289
Hasil seluruh skrip diatas akan menghasilkan delivery order yang bisa dilihat
pada gambar-gambar berikut :
290
Buat beberapa file dengan masing-masing skrip berikut :
out.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "out.tpl";
$module = $_GET['module'];
$act = $_GET['act'];
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE
modulID = '9'";
$sqlAuthorizeStaff = mysqli_query($connect,
$queryAuthorizeStaff);
$dataAuthorizeStaff =
mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'],
$_SESSION['level']) === FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
// delete invoice
$queryInvoice = "DELETE FROM as_sales_transactions
WHERE invoiceID = '$inID' AND invoiceNo = '$inNo'";
$sqlInvoice = mysqli_query($connect,
$queryInvoice);
// delete receive
$queryReceive = "DELETE FROM as_receivables WHERE
invoiceID = '$inID' AND invoiceNo = '$inNo'";
$sqlReceive = mysqli_query($connect,
$queryReceive);
291
header("Location: out.php?msg=Data transaksi
penjualan berhasil dihapus");
} // close bracket
$total = $dataProduct['hpp'] *
$dataDo['deliveredQty'];
$settotal += $total;
}
292
$customerID = $_POST['customerID'];
$customerName = mysqli_real_escape_string($connect,
$_POST['customerName']);
$customerAddress =
mysqli_real_escape_string($connect, $_POST['customerAddress']);
$paymentType = $_POST['paymentType'];
$xDate = explode("-", $_POST['expiredDate']);
$expiredDate = $xDate[2]."-".$xDate[1]."-
".$xDate[0];
$ppnType = $_POST['ppnType'];
$ppn = $_POST['ppn'];
$total = $_POST['total'];
$basic = $_POST['basic'];
$grandtotal = $_POST['grandtotal'];
//$pay = $_POST['pay'];
//$debt = $_POST['debt'];
$discount = $_POST['discount'];
$start = substr($dataNoReceive['receiveNo'],2-7);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoReceive == '0')
{
$reNo = "00000";
}
elseif ($tempNo == 1)
{
$reNo = "00000";
}
elseif ($tempNo == 2)
{
$reNo = "0000";
}
elseif ($tempNo == 3)
{
$reNo = "000";
}
elseif ($tempNo == 4)
{
$reNo = "00";
}
elseif ($tempNo == 5)
{
$reNo = "0";
}
elseif ($tempNo == 6)
{
$reNo = "";
293
}
$receiveNo = "DB".$reNo.$next;
invoiceDate,
doNo,
soNo,
paymentType,
expiredPayment,
ppnType,
ppn,
total,
basic,
discount,
grandtotal,
customerID,
customerName,
customerAddress,
staffID,
staffName,
createdDate,
createdUserID,
modifiedDate,
modifiedUserID)
VALUES( '$invoiceNo',
'$invoiceDate',
294
'$doNo',
'$soNo',
'$paymentType',
'$expiredDate',
'$ppnType',
'$ppn',
'$total',
'$basic',
'$discount',
'$grandtotal',
'$customerID',
'$customerName',
'$customerAddress',
'$staffID',
'$sName',
'$createdDate',
'$staffID',
'',
'')";
$invoiceID = mysqli_insert_id($connect);
if ($sqlSales)
{
//if ($paymentType == '2')
//{
$queryReceive = "INSERT INTO
as_receivables(receiveNo,
295
invoiceID,
invoiceNo,
customerID,
customerName,
customerAddress,
receiveTotal,
incomingTotal,
status,
staffID,
staffName,
createdDate,
createdUserID,
modifiedDate,
modifiedUserID)
VALUES( '$receiveNo',
'$invoiceID',
'$invoiceNo',
'$customerID',
'$customerName',
'$customerAddress',
'$grandtotal',
'0',
296
'1',
'$staffID',
'$sName',
'$createdDate',
'$staffID',
'',
'')";
mysqli_query($connect,
$queryReceive);
//}
}
header("Location:
out.php?module=out&act=finish&doNo=".$doNo."&invoiceNo=".$invoiceN
o."&invoiceID=".$invoiceID);
}
if ($dataSales['paymentType'] == '1')
{
$paymentType = "TUNAI";
$expiredPayment = "";
}
else
{
$paymentType = "TERMIN";
$expiredPayment =
tgl_indo2($dataSales['expiredPayment']);
}
if ($dataSales['ppnType'] == '1')
{
$ppnType = "PPN";
297
$ppn = rupiah($dataSales['ppn']);
}
else
{
$ppnType = "NO PPN";
$ppn = rupiah(0);
}
// show receivable
$queryReceive = "SELECT receiveTotal FROM
as_receivables WHERE invoiceNo = '$_GET[invoiceNo]' AND invoiceID
= '$_GET[invoiceID]'";
$sqlReceive = mysqli_query($connect,
$queryReceive);
$dataReceive = mysqli_fetch_array($sqlReceive);
$smarty->assign("receive",
rupiah($dataReceive['receiveTotal']));
298
$i = 1;
while ($dtDoDetail =
mysqli_fetch_array($sqlDoDetail))
{
$subtotal =
rupiah($dtDoDetail['deliveredQty'] * $dtDoDetail['price']);
'no' => $i
);
$i++;
}
$smarty->assign("dataDoDetail", $dataDoDetail);
$smarty->assign("page", $_GET['page']);
$smarty->assign("q", $q);
$smarty->assign("breadcumbTitle", "Transaksi
Penjualan");
$smarty->assign("breadcumbTitleSmall", "Halaman
untuk melakukan transaksi penjualan, faktur penjualan.");
$smarty->assign("breadcumbMenuName", "Transaksi
Penjualan");
$smarty->assign("breadcumbMenuSubName", "Transaksi
Penjualan");
}
299
$dataSales = mysqli_fetch_array($sqlSales);
if ($dataSales['paymentType'] == '1')
{
$paymentType = "TUNAI";
$expiredPayment = "";
}
else
{
$paymentType = "TERMIN";
$expiredPayment =
tgl_indo2($dataSales['expiredPayment']);
}
if ($dataSales['ppnType'] == '1')
{
$ppnType = "PPN";
$ppn = rupiah($dataSales['ppn']);
}
else
{
$ppnType = "NO PPN";
$ppn = rupiah(0);
}
300
// show receive
$queryReceive = "SELECT receiveTotal FROM
as_receivables WHERE invoiceNo = '$_GET[invoiceNo]' AND invoiceID
= '$_GET[invoiceID]'";
$sqlReceive = mysqli_query($connect,
$queryReceive);
$dataReceive = mysqli_fetch_array($sqlReceive);
$smarty->assign("receive",
rupiah($dataReceive['receiveTotal']));
$i = 1;
while ($dtDoDetail =
mysqli_fetch_array($sqlDoDetail))
{
$subtotal =
rupiah($dtDoDetail['deliveredQty'] * $dtDoDetail['price']);
'no' => $i
);
$i++;
}
$smarty->assign("dataDoDetail", $dataDoDetail);
$smarty->assign("page", $_GET['page']);
$smarty->assign("breadcumbTitle", "Transaksi
Penjualan");
$smarty->assign("breadcumbTitleSmall", "Halaman
untuk melakukan transaksi penjualan, faktur penjualan.");
301
$smarty->assign("breadcumbMenuName", "Transaksi
Penjualan");
$smarty->assign("breadcumbMenuSubName", "Transaksi
Penjualan");
}
$start = substr($dataNoOut['invoiceNo'],2-7);
$next = $start + 1;
$tempNo = strlen($next);
if ($numsNoOut == '0')
{
$outNo = "00000";
}
elseif ($tempNo == 1)
{
$outNo = "00000";
}
elseif ($tempNo == 2)
{
$outNo = "0000";
}
elseif ($tempNo == 3)
{
$outNo = "000";
}
elseif ($tempNo == 4)
{
$outNo = "00";
}
elseif ($tempNo == 5)
{
$outNo = "0";
}
elseif ($tempNo == 6)
{
$outNo = "";
}
$invoiceNo = "TJ".$outNo.$next;
$smarty->assign("invoiceNo", $invoiceNo);
$smarty->assign("invoiceDate", tgl_indo2(date('Y-m-
d')));
$doNo = $_GET['doNo'];
302
// show the bbm
$queryDo = "SELECT * FROM as_delivery_order WHERE
doNo = '$doNo'";
$sqlDo = mysqli_query($connect, $queryDo);
$dataDo = mysqli_fetch_array($sqlDo);
$numsDo = mysqli_num_rows($sqlDo);
$smarty->assign("numsDo", $numsDo);
$smarty->assign("numsSSales", $numsSSales);
$i = 1;
while ($dtDoDetail =
mysqli_fetch_array($sqlDoDetail))
{
$subtotal = $dtDoDetail['deliveredQty'] *
$dtDoDetail['price'];
303
$dataDoDetail[] = array( 'detailID'
=> $dtDoDetail['doID'],
'no' => $i
);
$i++;
}
$smarty->assign("dataDoDetail", $dataDoDetail);
$smarty->assign("breadcumbTitle", "Transaksi
Penjualan");
$smarty->assign("breadcumbTitleSmall", "Halaman
untuk melakukan transaksi penjualan, faktur penjualan.");
$smarty->assign("breadcumbMenuName", "Transaksi
Penjualan");
$smarty->assign("breadcumbMenuSubName", "Transaksi
Penjualan");
}
$smarty->assign("startDate", $sDate);
304
$smarty->assign("endDate", $eDate);
$startDate = $s2Date[2]."-".$s2Date[1]."-
".$s2Date[0];
$endDate = $e2Date[2]."-".$e2Date[1]."-
".$e2Date[0];
// fetch data
$i = 1 + $position;
while ($dtSales = mysqli_fetch_array($sqlSales))
{
if ($dtSales['paymentType'] == '1')
{
$paymentType = "TUNAI";
$expiredPayment = "";
}
else
{
$paymentType = "TERMIN";
$expiredPayment =
tgl_indo2($dtSales['expiredPayment']);
}
if ($dtSales['ppnType'] == '1')
{
$ppnType = "PPN";
$ppn = rupiah($dtSales['ppn']);
}
else
{
$ppnType = "NO PPN";
$ppn = "";
}
305
'invoiceDate' => tgl_indo2($dtSales['invoiceDate']),
$smarty->assign("dataSales", $dataSales);
$smarty->assign("page", $_GET['page']);
$smarty->assign("q", $q);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Transaksi
Penjualan");
$smarty->assign("breadcumbTitleSmall", "Halaman
untuk melakukan transaksi penjualan, faktur penjualan.");
$smarty->assign("breadcumbMenuName", "Transaksi
Penjualan");
$smarty->assign("breadcumbMenuSubName", "Transaksi
Penjualan");
}
else
{
// create new object pagination
$p = new PaginationOut;
// limit 20 data for page
$limit = 30;
$position = $p->searchPosition($limit);
306
// fetch data
$i = 1 + $position;
while ($dtSales = mysqli_fetch_array($sqlSales))
{
if ($dtSales['paymentType'] == '1')
{
$paymentType = "TUNAI";
$expiredPayment = "";
}
else
{
$paymentType = "TERMIN";
$expiredPayment =
tgl_indo2($dtSales['expiredPayment']);
}
if ($dtSales['ppnType'] == '1')
{
$ppnType = "PPN";
$ppn = rupiah($dtSales['ppn']);
}
else
{
$ppnType = "NO PPN";
$ppn = "";
}
307
$i++;
}
$smarty->assign("dataSales", $dataSales);
// count data
$queryCountSales = "SELECT * FROM
as_sales_transactions";
$sqlCountSales = mysqli_query($connect,
$queryCountSales);
$amountData = mysqli_num_rows($sqlCountSales);
$smarty->assign("pageLink", $pageLink);
$smarty->assign("page", $_GET['page']);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Transaksi
Penjualan");
$smarty->assign("breadcumbTitleSmall", "Halaman
untuk melakukan transaksi penjualan, faktur penjualan.");
$smarty->assign("breadcumbMenuName", "Transaksi
Penjualan");
$smarty->assign("breadcumbMenuSubName", "Transaksi
Penjualan");
}
$smarty->assign("module", $module);
$smarty->assign("act", $act);
}
// include footer
include "footer.php";
?>
<style>
div.ui-datepicker{
font-size:14px;
}
</style>
308
{literal}
<script>
function toRp(amount, decimalSeparator,
thousandsSeparator, nDecimalDigits){
var num = parseFloat( amount ); //convert
to float
//default values
decimalSeparator = decimalSeparator || ',';
thousandsSeparator = thousandsSeparator ||
',';
nDecimalDigits = nDecimalDigits == null? 2
: nDecimalDigits;
function sum() {
var total = eval($("#total").val());
var ppn = eval($("#ppn").val());
var discount = eval($("#discount").val());
var basic = eval($("#basic").val());
var grandtotal =
eval($("#grandtotal").val());
//var pay = eval($("#pay").val());
var ppnType = $("#ppnType").val();
// ppn
if (ppnType == '1') {
// dasar pengenaan pajak
var basicproccess = eval(total -
discount);
var basicproccessrp =
toRp(basicproccess);
var ppnproccess = eval(0.1 *
basicproccess);
var ppnproccessrp =
toRp(ppnproccess);
// grandtotal
var grandtotalproccess =
eval(basicproccess + ppnproccess);
309
var grandtotalproccessrp =
toRp(grandtotalproccess);
// piutang
//var receiveproccess =
eval(grandtotalproccess - pay);
//var receiveproccessrp =
toRp(receiveproccess);
document.getElementById('ppn').value =
ppnproccess.toFixed(2);
document.getElementById('ppnrp').value = ppnproccessrp;
document.getElementById('basic').value =
basicproccess.toFixed(2);
document.getElementById('basicrp').value =
basicproccessrp;
document.getElementById('grandtotal').value =
grandtotalproccess.toFixed(2);
document.getElementById('grandtotalrp').value =
grandtotalproccessrp;
//document.getElementById('receive').value =
receiveproccess.toFixed(2);
//document.getElementById('receiverp').value =
receiveproccessrp;
}
else{
// dasar pengenaan pajak
var basicproccess = eval(total -
discount);
var basicproccessrp =
toRp(basicproccess);
var ppnproccess = 0;
// grandtotal
var grandtotalproccess =
eval(basicproccess + ppnproccess);
var grandtotalproccessrp =
toRp(grandtotalproccess);
// terhutang
//var receiveproccess =
eval(grandtotalproccess - pay);
//var receiveproccessrp =
toRp(receiveproccess);
var ppnproccessrp =
toRp(ppnproccess);
document.getElementById('ppn').value = 0;
document.getElementById('ppnrp').value = 0;
310
document.getElementById('basic').value =
basicproccess.toFixed(2);
document.getElementById('basicrp').value =
basicproccessrp;
document.getElementById('grandtotal').value =
grandtotalproccess.toFixed(2);
document.getElementById('grandtotalrp').value =
grandtotalproccessrp;
//document.getElementById('receive').value =
receiveproccess.toFixed(2);
//document.getElementById('receiverp').value =
receiveproccessrp;
}
}
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width =
$(this.element).data("width");
this.height =
$(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$("#paymentType").change(function(e){
var paymentType =
$("#paymentType").val();
$("#searchStatus").empty();
if (paymentType == '2'){
newinput3.appendTo('#searchStatus').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-
yy",
yearRange: 'c-0:c+1'
311
});
}
});
$("#ppnType").change(function(e){
var ppnType = $("#ppnType").val();
var discount =
eval($("#discount").val());
var total =
eval($("#total").val());
//var pay = eval($("#pay").val());
document.getElementById("ppn").value = 0;
document.getElementById("ppnrp").value = 0;
if (ppnType == '1'){
var sisatotal = eval(total -
discount);
var ppnValue = eval(0.1 *
sisatotal);
var grandtotal =
eval(sisatotal + ppnValue);
//var receive =
eval(grandtotal - pay);
document.getElementById("ppn").value =
ppnValue.toFixed(2);
document.getElementById("ppnrp").value = ppnrp;
document.getElementById("basic").value =
sisatotal.toFixed(2);
document.getElementById("basicrp").value = basicrp;
document.getElementById("grandtotalrp").value =
grandtotalrp;
document.getElementById("grandtotal").value =
grandtotal.toFixed(2);
//document.getElementById("receiverp").value = receiverp;
//document.getElementById("receive").value =
receive.toFixed(2);
}
312
else {
var sisagrand = eval(total -
discount);
var sisagrandrp =
toRp(sisagrand);
//var receive =
eval(sisagrand - pay);
//var receiverp =
toRp(receive);
document.getElementById("ppn").value = 0;
document.getElementById("ppnrp").value = 0;
document.getElementById("basic").value =
sisagrand.toFixed(2);
document.getElementById("basicrp").value = sisagrandrp;
document.getElementById("grandtotalrp").value =
sisagrandrp;
document.getElementById("grandtotal").value =
sisagrand.toFixed(2);
//document.getElementById("receiverp").value = receiverp;
//document.getElementById("receive").value =
receive.toFixed(2);
}
});
$( "#invoiceDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c-1:c-0'
});
$( "#startDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$( "#endDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$('#doNo').change(function () {
var doNo = $("#doNo").val();
313
window.location.href =
"out.php?module=out&act=add&doNo=" + doNo;
});
$(".modalbox").fancybox();
$(".modalbox2").fancybox();
$("#send2").on("click", function(){
var doNo = $("#doNo").val();
var productID =
$("#productID").val();
var productName1 =
$("#productName1").val();
var qty =
parseInt($("#qty").val());
var price =
parseInt($("#price").val());
var desc = $("#desc").val();
$.ajax({
type: 'POST',
url: 'save_so.php',
dataType: 'JSON',
data:{
qty: qty,
price:
price,
soNo: soNo,
productID:
productID,
productName1: productName1,
desc: desc
},
beforeSend: function
(data) {
$('#send2').hide();
},
success:
function(data) {
setTimeout("$.fancybox.close()", 1000);
window.location.href = "so.php?module=so&act=add&msg=Data
berhasil disimpan";
}
});
}
314
});
});
</script>
{/literal}
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
{include file="user_panel.tpl"}
{include file="side_menu.tpl"}
</section>
<!-- /.sidebar -->
</aside>
{include file="breadcumb.tpl"}
<script>
window.location.hash="no-back-button";
window.location.hash="Again-No-back-button";//again
because google chrome don't insert first hash into history
315
window.onhashchange=function(){window.location.hash="no-
back-button";}
return false;
};
</script>
{/literal}
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<h3
class="box-title">Tambah Transaksi Penjualan</h3>
<div
class="box-tools pull-right">
<a
href="out.php?module=out&act=cancel&doNo={$doNo}" onclick="return
confirm('Anda Yakin ingin membatalkan transaksi penjualan
ini?');"><button class="btn btn-default pull-right">Batal
Trx</button></a>
</div>
</div>
</div><!--
/.box-header -->
<div
class="box-body">
<form
method="POST" action="out.php?module=out&act=input">
316
<input type="hidden" id="soNo" name="soNo"
value="{$soNo}">
<tr>
<td width="5">:</td>
</td>
</tr>
<tr valign="top">
<td>NO DO</td>
<td>:</td>
<font color="#f56954">Nomor
delivery order tidak ditemukan.</font>
{/if}
<font color="#f56954">Nomor
delivery order sudah digunakan.</font>
{/if}
</td>
</tr>
<tr>
317
<td>TIPE BAYAR</td>
<td>:</td>
<option value=""></option>
<option value="1">Tunai</option>
<option value="2">Termin</option>
</select>
<div id="searchStatus"></div>
</td>
</tr>
<tr>
<td>PPN</td>
<td>:</td>
<option value=""></option>
<option value="1">PPN</option>
</select>
</td>
</tr>
<tr>
<td colspan="3">
<br>
</td>
</tr>
</table>
<div
class="table-responsive">
318
<table id="example1" class="table table-bordered table-
striped">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>HARGA</th>
<th>QTY</th>
<th>SUBTOTAL</th>
<th>KOREKSI HARGA</th>
</tr>
</thead>
<tbody>
{section name=dataDoDetail
loop=$dataDoDetail}
<tr>
<td>{$dataDoDetail[dataDoDetail].no}</td>
<td>{$dataDoDetail[dataDoDetail].productName}</td>
<td
style='text-align:
right;'>{$dataDoDetail[dataDoDetail].pricerp}</td>
<td
style='text-align:
center;'>{$dataDoDetail[dataDoDetail].deliveredQty}</td>
<td
style='text-align:
right;'>{$dataDoDetail[dataDoDetail].subtotal}</td>
<td><a
title="Koreksi Harga"
href="edit_out.php?module=out&act=edit&detailID={$dataDoDetail[dat
319
aDoDetail].detailID}&doNo={$doNo}" data-width="450" data-
height="180" class="various2 fancybox.iframe"><img
src="img/icons/edit.png" width="18"></a></td>
</tr>
{/section}
{/if}
{/if}
</tbody>
</table>
</div>
<br>
{if
$numsDo > 0 AND $doNo != ''}
<tr>
<td width="5">:</td>
<input type="text"
id="total" name="total" value="{$totalrp}" class="form-control"
style="width: 270px;" DISABLED>
</td>
</tr>
<tr>
<td>POTONGAN</td>
<td>:</td>
<td><input type="text"
id="discount" name="discount" value="0" class="form-control"
style="width: 270px;" onkeyup="sum();" required></td>
</tr>
<tr>
320
<td>DASAR PENGENAAN PAJAK</td>
<td>:</td>
<input type="text"
id="basicrp" name="basicrp" value="{$totalrp}" class="form-
control" style="width: 270px;" DISABLED>
</td>
</tr>
<tr>
<td>PPN (10%)</td>
<td>:</td>
<input type="text"
id="ppnrp" name="ppnrp" value="0" class="form-control"
style="width: 270px;" DISABLED></td>
</tr>
<tr>
<td>GRANDTOTAL</td>
<td>:</td>
<td><input type="hidden"
id="grandtotal" name="grandtotal" value="{$total}">
<input type="text"
id="grandtotalrp" name="grandtotalrp" value="{$totalrp}"
class="form-control" style="width: 270px;" DISABLED>
</td>
</tr>
<!--<tr>
<td>TITIP BAYAR</td>
<td>:</td>
321
</tr>
<tr>
<td>TERHUTANG</td>
<td>:</td>
<td><input type="hidden"
id="receive" name="receive" value="0">
<input type="text"
id="receiverp" name="receiverp" value="0" class="form-control"
style="width: 270px;" DISABLED></td>
</tr>-->
</table>
<br>
{/if}
{/if}
</form>
</div><!--
/.box-body -->
{elseif $module ==
'out' AND $act == 'finish'}
{literal}
<script>
window.location.hash="no-back-button";
window.location.hash="Again-No-back-button";//again
because google chrome don't insert first hash into history
window.onhashchange=function(){window.location.hash="no-
back-button";}
return false;
322
};
</script>
{/literal}
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<h3
class="box-title">Faktur Transaksi Penjualan</h3>
<div
class="box-tools pull-right">
<a
href="print_unit_out.php?module=out&act=print&invoiceID={$invoiceI
D}&doNo={$doNo}&invoiceNo={$invoiceNo}" target="_blank"><button
class="btn btn-default pull-right">Print</button></a>
</div>
</div>
</div><!--
/.box-header -->
<div
class="box-body">
<tr>
<td width="5">:</td>
</td>
</tr>
<tr valign="top">
323
<td>NO DO</td>
<td>:</td>
</tr>
<tr valign="top">
<td>TIPE BAYAR</td>
<td>:</td>
</td>
</tr>
<tr valign="top">
<td>PPN</td>
<td>:</td>
</td>
</tr>
<tr>
<td colspan="3">
<br>
</td>
</tr>
</table>
324
<div
class="table-responsive">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
<th>HARGA</th>
<th>QTY</th>
<th>SUBTOTAL</th>
</tr>
</thead>
<tbody>
{section name=dataDoDetail
loop=$dataDoDetail}
<tr>
<td>{$dataDoDetail[dataDoDetail].no}</td>
<td>{$dataDoDetail[dataDoDetail].productName}</td>
<td style='text-align:
right;'>{$dataDoDetail[dataDoDetail].pricerp}</td>
<td style='text-align:
center;'>{$dataDoDetail[dataDoDetail].deliveredQty}</td>
<td style='text-align:
right;'>{$dataDoDetail[dataDoDetail].subtotal}</td>
</tr>
{/section}
</tbody>
</table>
</div>
<br>
325
<table cellpadding="3" cellspacing="3">
<tr>
<td width="5">:</td>
</tr>
<tr>
<td>POTONGAN</td>
<td>:</td>
</tr>
<tr>
<td>:</td>
</tr>
<tr>
<td>PPN (10%)</td>
<td>:</td>
</tr>
<tr>
<td>GRANDTOTAL</td>
<td>:</td>
326
<td><input type="text" id="grandtotalrp"
name="grandtotalrp" value="{$grandtotal}" class="form-control"
style="width: 270px;" DISABLED></td>
</tr>
<!--<tr>
<td>TITIP BAYAR</td>
<td>:</td>
</tr>
<tr>
<td>TERHUTANG</td>
<td>:</td>
</tr>-->
</table>
</div><!--
/.box-body -->
{elseif $module ==
'out' AND $act == 'detailout'}
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<h3
class="box-title">Faktur Transaksi Penjualan</h3>
<div
class="box-tools pull-right">
<a
href="print_unit_out.php?module=out&act=print&invoiceID={$invoiceI
D}&doNo={$doNo}&invoiceNo={$invoiceNo}" target="_blank"><button
class="btn btn-default pull-right">Print</button></a>
{if $q != ''}
327
<a
href="out.php?module=out&act=search&q={$q}"><button class="btn
btn-default pull-right">Back</button></a>
{else}
<a href="out.php?page={$page}"><button
class="btn btn-default pull-right">Back</button></a>
{/if}
</div>
</div>
</div><!--
/.box-header -->
<div
class="box-body">
<tr>
<td width="5">:</td>
</td>
</tr>
<tr valign="top">
<td>NO DO</td>
<td>:</td>
</tr>
<tr valign="top">
<td>TIPE BAYAR</td>
328
<td>:</td>
</td>
</tr>
<tr valign="top">
<td>PPN</td>
<td>:</td>
</td>
</tr>
<tr>
<td colspan="3">
<br>
</td>
</tr>
</table>
<div
class="table-responsive">
<thead>
<tr>
<th>NO</th>
<th>NAMA PRODUK</th>
329
<th>HARGA</th>
<th>QTY</th>
<th>SUBTOTAL</th>
</tr>
</thead>
<tbody>
{section name=dataDoDetail
loop=$dataDoDetail}
<tr>
<td>{$dataDoDetail[dataDoDetail].no}</td>
<td>{$dataDoDetail[dataDoDetail].productName}</td>
<td style='text-align:
right;'>{$dataDoDetail[dataDoDetail].pricerp}</td>
<td style='text-align:
center;'>{$dataDoDetail[dataDoDetail].deliveredQty}</td>
<td style='text-align:
right;'>{$dataDoDetail[dataDoDetail].subtotal}</td>
</tr>
{/section}
</tbody>
</table>
</div>
<br>
<tr>
<td width="5">:</td>
</tr>
330
<tr>
<td>POTONGAN</td>
<td>:</td>
</tr>
<tr>
<td>:</td>
</tr>
<tr>
<td>PPN (10%)</td>
<td>:</td>
</tr>
<tr>
<td>GRANDTOTAL</td>
<td>:</td>
</tr>
<!--<tr>
<td>TITIP BAYAR</td>
<td>:</td>
331
value="{$pay}" class="form-control" style="width: 270px;"
DISABLED></td>
</tr>
<tr>
<td>TERHUTANG</td>
<td>:</td>
</tr>-->
</table>
</div><!--
/.box-body -->
{elseif $module ==
'out' AND $act == 'search'}
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<div
class="box-tools pull-right">
332
name="q" class="form-control" placeholder="Pencarian : Nomor
Faktur Penjualan" style="float: right; width: 270px;" required>
<a href="out.php?module=out&act=add"
style="float: left;"><button type="button" class="btn btn-default
pull-right"><i class="fa fa-plus"></i> Add</button></a>
<a
href="print_out.php?act=print&q={$q}&startDate={$startDate}&endDat
e={$endDate}" style="float: left;" target="_blank"><button
type="button" class="btn btn-default pull-right"><i class="fa fa-
print"></i> Print PDF</button></a>
</form>
</div>
</div>
</div><!--
/.box-header -->
<div
class="box-body">
<div
class="table-responsive">
<thead>
<tr>
<th>AKSI</th>
</tr>
333
</thead>
<tbody>
<tr>
<td>{$dataSales[dataSales].no}</td>
<td>{$dataSales[dataSales].invoiceNo}</td>
<td>{$dataSales[dataSales].invoiceDate}</td>
<td>{$dataSales[dataSales].doNo}</td>
<td>{$dataSales[dataSales].grandtotal}</td>
<td>{$dataSales[dataSales].staffName}</td>
<td>
<a title="Detail"
href="out.php?module=out&act=detailout&invoiceID={$dataSales[dataS
ales].invoiceID}&invoiceNo={$dataSales[dataSales].invoiceNo}&doNo=
{$dataSales[dataSales].doNo}&q={$q}&page={$page}"><img
src="img/icons/view.png" width="18"></a>
<a title="Delete"
href="out.php?module=out&act=delete&invoiceID={$dataSales[dataSale
s].invoiceID}&invoiceNo={$dataSales[dataSales].invoiceNo}&doNo={$d
ataSales[dataSales].doNo}&" onclick="return confirm('Anda Yakin
ingin membatalkan transaksi {$dataSales[dataSales].invoiceNo}?
penghapusan ini akan membatalkan seluruh hutang dan pembayaran
konsumen terkait transaksi ini.');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
334
</div><!--
/.box-body -->
{else}
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<div
class="box-tools pull-right">
<a href="out.php?module=out&act=add"
style="float: left;"><button type="button" class="btn btn-default
pull-right"><i class="fa fa-plus"></i> Add</button></a>
<a href="print_out.php?act=print&q={$q}"
style="float: left;" target="_blank"><button type="button"
class="btn btn-default pull-right"><i class="fa fa-print"></i>
Print PDF</button></a>
</form>
</div>
</div>
</div><!--
/.box-header -->
335
<div
class="box-body">
<div
class="table-responsive">
<thead>
<tr>
<th>AKSI</th>
</tr>
</thead>
<tbody>
<tr>
<td>{$dataSales[dataSales].no}</td>
<td>{$dataSales[dataSales].invoiceNo}</td>
<td>{$dataSales[dataSales].invoiceDate}</td>
<td>{$dataSales[dataSales].doNo}</td>
336
<td>{$dataSales[dataSales].grandtotal}</td>
<td>{$dataSales[dataSales].staffName}</td>
<td>
<a title="Detail"
href="out.php?module=out&act=detailout&invoiceID={$dataSales[dataS
ales].invoiceID}&invoiceNo={$dataSales[dataSales].invoiceNo}&doNo=
{$dataSales[dataSales].doNo}&page={$page}"><img
src="img/icons/view.png" width="18"></a>
<a title="Delete"
href="out.php?module=out&act=delete&invoiceID={$dataSales[dataSale
s].invoiceID}&invoiceNo={$dataSales[dataSales].invoiceNo}&doNo={$d
ataSales[dataSales].doNo}&" onclick="return confirm('Anda Yakin
ingin membatalkan transaksi {$dataSales[dataSales].invoiceNo}?
penghapusan ini akan membatalkan seluruh hutang dan pembayaran
konsumen terkait transaksi ini.');"><img
src="img/icons/delete.png" width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
</div><!--
/.box-body -->
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<div
class="box-tools pull-left">
{$pageLink}
</ul>
</div>
</div><!--
/.box-header -->
{/if}
337
</div><!-- /.box -->
{include file="footer.tpl"}
Hasil skrip diatas akan menghasilkan halaman transaksi penjualan yang hasilnya
bisa dilihat pada gambar-gambar berikut :
338
5.3.4 Pembayaran Transaksi Penjualan
Halaman ini digunakan untuk membayar transaksi penjualan yang telah
dilakukan. Kita juga akan bahas file apa saja yang diperlukan untuk membuat
pembayaran transaksi penjualan ini.
Buat beberapa file dengan masing-masing skrip berikut :
pay_out.php
<?php
// include header
include "header.php";
// set the tpl page
$page = "pay_out.tpl";
$module = $_GET['module'];
$act = $_GET['act'];
else
{
$queryAuthorizeStaff = "SELECT * FROM as_modules WHERE
modulID = '27'";
$sqlAuthorizeStaff = mysqli_query($connect,
$queryAuthorizeStaff);
$dataAuthorizeStaff =
mysqli_fetch_array($sqlAuthorizeStaff);
if (strpos($dataAuthorizeStaff['authorize'],
$_SESSION['level']) === FALSE){
echo "Anda tidak berhak akses modul ini.";
exit();
}
339
$sqlPayment = mysqli_query($connect,
$queryPayment);
$dataPayment = mysqli_fetch_array($sqlPayment);
$total = $dataPayment['total'];
if ($sqlUpdate)
{
$queryPay = "DELETE FROM as_sales_payments
WHERE paymentID = '$paymentID' AND paymentNo = '$paymentNo'";
$sqlPay = mysqli_query($connect,
$queryPay);
}
$paymentNo = $_POST['paymentNo'];
$pDate = explode("-", $_POST['paymentDate']);
$paymentDate = $pDate[2]."-".$pDate[1]."-
".$pDate[0];
$invoiceID = $_POST['invoiceID'];
$invoiceNo = mysqli_real_escape_string($connect,
$_POST['invoiceNo']);
$soNo = $_POST['soNo'];
$payType = $_POST['payType'];
$bankNo = mysqli_real_escape_string($connect,
$_POST['bankNo']);
$bankName = mysqli_real_escape_string($connect,
$_POST['bankName']);
$bankAC = mysqli_real_escape_string($connect,
$_POST['bankAC']);
$eDate = explode("-", $_POST['effectiveDate']);
340
$effectiveDate = $eDate[2]."-".$eDate[1]."-
".$eDate[0];
$total = mysqli_real_escape_string($connect,
$_POST['total']);
$customerID = $_POST['customerID'];
$customerName = mysqli_real_escape_string($connect,
$_POST['customerName']);
$customerAddress =
mysqli_real_escape_string($connect, $_POST['customerAddress']);
$ref = mysqli_real_escape_string($connect,
$_POST['ref']);
$note = mysqli_real_escape_string($connect,
$_POST['note']);
invoiceID,
invoiceNo,
soNo,
paymentDate,
payType,
bankNo,
bankName,
bankAC,
effectiveDate,
total,
customerID,
customerName,
customerAddress,
ref,
note,
staffID,
staffName,
createdDate,
createdUserID,
modifiedDate,
341
modifiedUserID)
VALUES( '$paymentNo',
'$invoiceID',
'$invoiceNo',
'$soNo',
'$paymentDate',
'$payType',
'$bankNo',
'$bankName',
'$bankAC',
'$effectiveDate',
'$total',
'$customerID',
'$customerName',
'$customerAddress',
'$ref',
'$note',
'$staffID',
'$sName',
'$createdDate',
'$staffID',
'',
'')";
$paymentID = mysqli_insert_id($connect);
if ($sqlPay)
{
$queryUpdate = "UPDATE as_receivables SET
incomingTotal=incomingTotal+$total WHERE invoiceNo = '$invoiceNo'
AND invoiceID = '$invoiceID'";
342
$sqlUpdate = mysqli_query($connect,
$queryUpdate);
}
header("Location:
pay_out.php?module=payout&act=finish&paymentNo=".$paymentNo."&paym
entID=".$paymentID."&invoiceNo=".$invoiceNo);
}
// receive
$receive = $dataTotal['total'] -
$dataSales['grandtotal'];
if ($dataPay['payType'] == '1')
{
$payType = "TUNAI";
}
elseif ($dataPay['payType'] == '2')
{
$payType = "TRANSFER";
}
elseif ($dataPay['payType'] == '3')
{
343
$payType = "CEK";
}
else
{
$payType = "GIRO";
}
if ($dataPay['effectiveDate'] == '0000-00-00')
{
$effectiveDate = "-";
}
else
{
$effectiveDate =
tgl_indo2($dataPay['effectiveDate']);
}
// assign
$smarty->assign("q", $q);
$smarty->assign("paymentNo",
$dataPay['paymentNo']);
$smarty->assign("paymentID",
$dataPay['paymentID']);
$smarty->assign("paymentDate",
tgl_indo2($dataPay['paymentDate']));
$smarty->assign("invoiceNo",
$dataPay['invoiceNo']);
$smarty->assign("pay", rupiah($total));
$smarty->assign("total",
rupiah($dataPay['total']));
$smarty->assign("receive", rupiah($receive));
$smarty->assign("customerName",
$dataSales['customerName']);
$smarty->assign("customerAddress",
$dataSales['customerAddress']);
$smarty->assign("payType", $payType);
$smarty->assign("bankNo", $dataPay['bankNo']);
$smarty->assign("bankName", $dataPay['bankName']);
$smarty->assign("effectiveDate", $effectiveDate);
$smarty->assign("bankAC", $dataPay['bankAC']);
$smarty->assign("total",
rupiah($dataPay['total']));
$smarty->assign("ref", $dataPay['ref']);
$smarty->assign("note", $dataPay['note']);
$smarty->assign("breadcumbTitle", "Pembayaran
Transaksi Penjualan");
$smarty->assign("breadcumbTitleSmall", "Halaman
untuk melakukan pembayaran transaksi penjualan.");
$smarty->assign("breadcumbMenuName", "Transaksi
Penjualan");
$smarty->assign("breadcumbMenuSubName", "Pembayaran
Transaksi");
}
344
{
$paymentNo = $_GET['paymentNo'];
$paymentID = $_GET['paymentID'];
$invoiceNo = $_GET['invoiceNo'];
// receive
$receive = $dataSales['grandtotal'] -
$dataTotal['total'];
if ($dataPay['payType'] == '1')
{
$payType = "TUNAI";
}
elseif ($dataPay['payType'] == '2')
{
$payType = "TRANSFER";
}
elseif ($dataPay['payType'] == '3')
{
$payType = "CEK";
}
else
{
$payType = "GIRO";
}
if ($dataPay['effectiveDate'] == '0000-00-00')
{
$effectiveDate = "-";
}
else
{
345
$effectiveDate =
tgl_indo2($dataPay['effectiveDate']);
}
// assign
$smarty->assign("paymentNo",
$dataPay['paymentNo']);
$smarty->assign("paymentID",
$dataPay['paymentID']);
$smarty->assign("paymentDate",
tgl_indo2($dataPay['paymentDate']));
$smarty->assign("invoiceNo",
$dataPay['invoiceNo']);
$smarty->assign("pay", rupiah($total));
$smarty->assign("total",
rupiah($dataPay['total']));
$smarty->assign("receive", rupiah($receive));
$smarty->assign("customerName",
$dataSales['customerName']);
$smarty->assign("customerAddress",
$dataSales['customerAddress']);
$smarty->assign("payType", $payType);
$smarty->assign("bankNo", $dataPay['bankNo']);
$smarty->assign("bankName", $dataPay['bankName']);
$smarty->assign("effectiveDate", $effectiveDate);
$smarty->assign("bankAC", $dataPay['bankAC']);
$smarty->assign("total",
rupiah($dataPay['total']));
$smarty->assign("ref", $dataPay['ref']);
$smarty->assign("note", $dataPay['note']);
$smarty->assign("breadcumbTitle", "Pembayaran
Transaksi Penjualan");
$smarty->assign("breadcumbTitleSmall", "Halaman
untuk melakukan pembayaran transaksi penjualan.");
$smarty->assign("breadcumbMenuName", "Transaksi
Penjualan");
$smarty->assign("breadcumbMenuSubName", "Pembayaran
Transaksi");
}
$start = substr($dataNoPayOut['paymentNo'],2-7);
$next = $start + 1;
346
$tempNo = strlen($next);
if ($numsNoPayOut == '0')
{
$outNo = "00000";
}
elseif ($tempNo == 1)
{
$outNo = "00000";
}
elseif ($tempNo == 2)
{
$outNo = "0000";
}
elseif ($tempNo == 3)
{
$outNo = "000";
}
elseif ($tempNo == 4)
{
$outNo = "00";
}
elseif ($tempNo == 5)
{
$outNo = "0";
}
elseif ($tempNo == 6)
{
$outNo = "";
}
$payOutNo = "PJ".$outNo.$next;
// total grandtotal
$queryTotal = "SELECT grandtotal, invoiceID, soNo,
customerID, customerName, customerAddress FROM
as_sales_transactions WHERE invoiceNo = '$invoiceNo'";
$sqlTotal = mysqli_query($connect, $queryTotal);
$numsTotal = mysqli_num_rows($sqlTotal);
$dataTotal = mysqli_fetch_array($sqlTotal);
// count payment
$queryPay = "SELECT SUM(total) as total FROM
as_sales_payments WHERE invoiceNo = '$invoiceNo'";
$sqlPay = mysqli_query($connect, $queryPay);
$dataPay = mysqli_fetch_array($sqlPay);
$receive = $dataTotal['grandtotal'] -
$dataPay['total'];
$smarty->assign("payOutNo", $payOutNo);
$smarty->assign("payOutDate", tgl_indo2(date('Y-m-
d')));
$smarty->assign("invoiceNo", $invoiceNo);
$smarty->assign("invoiceID",
$dataTotal['invoiceID']);
$smarty->assign("numsTotal", $numsTotal);
347
$smarty->assign("soNo", $dataTotal['soNo']);
$smarty->assign("receive", rupiah($receive));
$smarty->assign("receiveo", $receive);
$smarty->assign("customerID",
$dataTotal['customerID']);
$smarty->assign("customerName",
$dataTotal['customerName']);
$smarty->assign("customerAddress",
$dataTotal['customerAddress']);
$smarty->assign("breadcumbTitle", "Transaksi
Penjualan");
$smarty->assign("breadcumbTitleSmall", "Halaman
untuk melakukan transaksi penjualan, faktur penjualan.");
$smarty->assign("breadcumbMenuName", "Transaksi
Penjualan");
$smarty->assign("breadcumbMenuSubName", "Transaksi
Penjualan");
}
$smarty->assign("startDate", $sDate);
$smarty->assign("endDate", $eDate);
$startDate = $s2Date[2]."-".$s2Date[1]."-
".$s2Date[0];
$endDate = $e2Date[2]."-".$e2Date[1]."-
".$e2Date[0];
// fetch data
348
$i = 1 + $position;
while ($dtPay = mysqli_fetch_array($sqlPay))
{
if ($dtPay['payType'] == '1')
{
$payType = "TUNAI";
$effectiveDate = "";
}
else
{
$payType = "CEK";
$effectiveDate =
tgl_indo2($dtPay['effectiveDate']);
}
$smarty->assign("dataPay", $dataPay);
$smarty->assign("q", $q);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Pembayaran
Transaksi Penjualan");
$smarty->assign("breadcumbTitleSmall", "Halaman
untuk melakukan pembayaran transaksi penjualan.");
$smarty->assign("breadcumbMenuName", "Transaksi
Penjualan");
$smarty->assign("breadcumbMenuSubName", "Pembayaran
Transaksi");
}
349
else
{
// create new object pagination
$p = new PaginationPayOut;
// limit 20 data for page
$limit = 30;
$position = $p->searchPosition($limit);
// fetch data
$i = 1 + $position;
while ($dtPay = mysqli_fetch_array($sqlPay))
{
if ($dtPay['payType'] == '1')
{
$payType = "TUNAI";
$effectiveDate = "";
}
else
{
$payType = "CEK";
$effectiveDate =
tgl_indo2($dtPay['effectiveDate']);
}
350
}
$smarty->assign("dataPay", $dataPay);
// count data
$queryCountPay = "SELECT * FROM as_sales_payments";
$sqlCountPay = mysqli_query($connect,
$queryCountPay);
$amountData = mysqli_num_rows($sqlCountPay);
$smarty->assign("pageLink", $pageLink);
$smarty->assign("page", $_GET['page']);
$smarty->assign("msg", $_GET['msg']);
$smarty->assign("breadcumbTitle", "Pembayaran
Transaksi Penjualan");
$smarty->assign("breadcumbTitleSmall", "Halaman
untuk melakukan pembayaran transaksi penjualan.");
$smarty->assign("breadcumbMenuName", "Transaksi
Penjualan");
$smarty->assign("breadcumbMenuSubName", "Pembayaran
Transaksi");
}
$smarty->assign("module", $module);
$smarty->assign("act", $act);
}
// include footer
include "footer.php";
?>
<style>
div.ui-datepicker{
font-size:14px;
}
</style>
{literal}
351
<script>
$(document).ready(function() {
$(".various2").fancybox({
fitToView: false,
scrolling: 'no',
afterLoad: function(){
this.width =
$(this.element).data("width");
this.height =
$(this.element).data("height");
},
'afterClose':function () {
window.location.reload();
}
});
$( "#paymentDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c-1:c-0'
});
$( "#startDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$( "#endDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '2014:c-0'
});
$( "#effectiveDate" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: 'c:c+1'
});
$('#invoiceNo').change(function () {
var invoiceNo =
$("#invoiceNo").val();
window.location.href =
"pay_out.php?module=payout&act=add&invoiceNo=" + invoiceNo;
});
});
</script>
{/literal}
352
<header class="header">
{include file="logo.tpl"}
{include file="navigation.tpl"}
</header>
{include file="user_panel.tpl"}
{include file="side_menu.tpl"}
</section>
<!-- /.sidebar -->
</aside>
{include file="breadcumb.tpl"}
{if $module ==
'payout' AND $act == 'add'}
{literal}
<script>
window.location.hash="no-back-button";
window.location.hash="Again-No-back-button";//again
because google chrome don't insert first hash into history
window.onhashchange=function(){window.location.hash="no-
back-button";}
353
document.onkeydown = function (e) {
return false;
};
</script>
{/literal}
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<h3
class="box-title">Pembayaran Transaksi Penjualan</h3>
<div
class="box-tools pull-right">
</div>
</div>
</div><!--
/.box-header -->
<div
class="box-body">
{if
$numsTotal == '0' && $invoiceNo != ''}
{/if}
{/if}
<form
method="POST" action="pay_out.php?module=payout&act=input">
354
<input type="hidden" id="customerID" name="customerID"
value="{$customerID}">
<tr>
<td width="5">:</td>
</td>
</tr>
<tr valign="top">
<td>NOMOR FAKTUR</td>
<td>:</td>
</tr>
<tr valign="top">
<td>TERHUTANG</td>
<td>:</td>
355
<td><input type="text" id="receive" name="receive"
value="{$receive}" class="form-control" placeholder="Total
Piutang" style="width: 300px;" DISABLED></td>
</tr>
<tr>
<td>DIBAYARKAN KEPADA</td>
<td>:</td>
<td>
</td>
</tr>
<tr>
<td>PEMBAYARAN</td>
<td>:</td>
<option value=""></option>
<option value="1">Tunai</option>
<option value="2">Transfer</option>
<option value="3">Cek</option>
<option value="4">Giro</option>
</select>
</td>
</tr>
<tr>
<td>NAMA BANK</td>
<td>:</td>
356
<td>
</td>
</tr>
<tr>
<td>NAMA AKUN</td>
<td>:</td>
<td>
</td>
</tr>
<tr>
<td>JUMLAH</td>
<td>:</td>
<td>
</td>
</tr>
<tr>
<td>REFERENSI</td>
<td>:</td>
<td>
357
class="form-control" placeholder="Referensi" style="width:
300px;">
</td>
</tr>
<tr valign="top">
<td>NOTE</td>
<td>:</td>
<td>
</td>
</tr>
</table>
{if
$numsTotal > 0}
{/if}
{/if}
</form>
</div><!--
/.box-body -->
{elseif $module ==
'payout' AND $act == 'finish'}
{literal}
<script>
window.location.hash="no-back-button";
window.location.hash="Again-No-back-button";//again
because google chrome don't insert first hash into history
window.onhashchange=function(){window.location.hash="no-
back-button";}
358
if (e.keyCode === 116) {
return false;
};
</script>
{/literal}
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<h3
class="box-title">Pembayaran Transaksi Penjualan</h3>
<div
class="box-tools pull-right">
<a
href="print_unit_payout.php?module=payout&act=print&invoiceNo={$in
voiceNo}&paymentNo={$paymentNo}&paymentID={$paymentID}"
target="_blank"><button class="btn btn-default pull-
right">Print</button></a>
</div>
</div>
</div><!--
/.box-header -->
<div
class="box-body">
<tr>
<td width="5">:</td>
<td>{$paymentNo} / {$paymentDate}</td>
</tr>
<tr valign="top">
<td>NOMOR FAKTUR</td>
359
<td>:</td>
<td>{$invoiceNo}</td>
</tr>
<tr valign="top">
<td>PIUTANG</td>
<td>:</td>
<td>{$receive}</td>
</tr>
<tr>
<td>DIBAYARKAN KEPADA</td>
<td>:</td>
<td>{$customerName}</td>
</tr>
<tr>
<td></td>
<td></td>
<td>{$customerAddress}</td>
</tr>
<tr>
<td>PEMBAYARAN</td>
<td>:</td>
<td>{$payType}</td>
</tr>
<tr>
<td>NO REK/CEK/GIRO</td>
<td>:</td>
<td>{$bankNo}</td>
</tr>
360
<tr>
<td>NAMA BANK</td>
<td>:</td>
<td>{$bankName}</td>
</tr>
<tr>
<td>TGL EFEKTIF</td>
<td>:</td>
<td>{$effectiveDate}</td>
</tr>
<tr>
<td>NAMA AKUN</td>
<td>:</td>
<td>{$bankAC}</td>
</tr>
<tr>
<td>JUMLAH</td>
<td>:</td>
<td>{$total}</td>
</tr>
<tr>
<td>REFERENSI</td>
<td>:</td>
<td>{$ref}</td>
</tr>
<tr valign="top">
<td>NOTE</td>
<td>:</td>
361
<td>{$note}</td>
</tr>
</table>
</div><!--
/.box-body -->
{elseif $module ==
'payout' AND $act == 'detailpayout'}
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<h3
class="box-title">Pembayaran Transaksi Penjualan</h3>
<div
class="box-tools pull-right">
<a
href="print_unit_payout.php?module=payout&act=print&invoiceNo={$in
voiceNo}&paymentNo={$paymentNo}&paymentID={$paymentID}"
target="_blank"><button class="btn btn-default pull-
right">Print</button></a>
{if $q != ''}
<a
href="pay_out.php?module=payout&act=search&q={$q}"><button
class="btn btn-default pull-right">Back</button></a>
{else}
<a href="pay_out.php?page={$page}"><button
class="btn btn-default pull-right">Back</button></a>
{/if}
</div>
</div>
</div><!--
/.box-header -->
<div
class="box-body">
<tr>
362
<td width="5">:</td>
<td>{$paymentNo} / {$paymentDate}</td>
</tr>
<tr valign="top">
<td>NOMOR FAKTUR</td>
<td>:</td>
<td>{$invoiceNo}</td>
</tr>
<tr valign="top">
<td>PIUTANG</td>
<td>:</td>
<td>{$receive}</td>
</tr>
<tr>
<td>DIBAYARKAN KEPADA</td>
<td>:</td>
<td>{$customerName}</td>
</tr>
<tr>
<td></td>
<td></td>
<td>{$customerAddress}</td>
</tr>
<tr>
<td>PEMBAYARAN</td>
<td>:</td>
<td>{$payType}</td>
</tr>
363
<tr>
<td>NO REK/CEK/GIRO</td>
<td>:</td>
<td>{$bankNo}</td>
</tr>
<tr>
<td>NAMA BANK</td>
<td>:</td>
<td>{$bankName}</td>
</tr>
<tr>
<td>TGL EFEKTIF</td>
<td>:</td>
<td>{$effectiveDate}</td>
</tr>
<tr>
<td>NAMA AKUN</td>
<td>:</td>
<td>{$bankAC}</td>
</tr>
<tr>
<td>JUMLAH</td>
<td>:</td>
<td>{$total}</td>
</tr>
<tr>
<td>REFERENSI</td>
<td>:</td>
364
<td>{$ref}</td>
</tr>
<tr valign="top">
<td>NOTE</td>
<td>:</td>
<td>{$note}</td>
</tr>
</table>
</div><!--
/.box-body -->
{elseif $module ==
'payout' AND $act == 'search'}
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<div
class="box-tools pull-right">
365
<a href="pay_out.php?module=payout&act=add"
style="float: left;"><button type="button" class="btn btn-default
pull-right"><i class="fa fa-plus"></i> Add</button></a>
<a
href="print_pay_out.php?act=print&q={$q}&startDate={$startDate}&en
dDate={$endDate}" style="float: left;" target="_blank"><button
type="button" class="btn btn-default pull-right"><i class="fa fa-
print"></i> Print PDF</button></a>
</form>
</div>
</div>
</div><!--
/.box-header -->
<div
class="box-body">
<div
class="table-responsive">
<thead>
<tr>
366
<th>AKSI</th>
</tr>
</thead>
<tbody>
<tr>
<td>{$dataPay[dataPay].no}</td>
<td>{$dataPay[dataPay].paymentNo}</td>
<td>{$dataPay[dataPay].paymentDate}</td>
<td>{$dataPay[dataPay].invoiceNo}</td>
<td>{$dataPay[dataPay].soNo}</td>
<td>{$dataPay[dataPay].payType}</td>
<td>{$dataPay[dataPay].total}</td>
<td>{$dataPay[dataPay].staffName}</td>
<td>
<a title="Detail"
href="pay_out.php?module=payout&act=detailpayout&paymentID={$dataP
ay[dataPay].paymentID}&invoiceNo={$dataPay[dataPay].invoiceNo}&pay
mentNo={$dataPay[dataPay].paymentNo}&q={$q}&page={$page}"><img
src="img/icons/view.png" width="18"></a>
<a title="Delete"
href="pay_out.php?module=payout&act=delete&invoiceNo={$dataPay[dat
aPay].invoiceNo}&paymentNo={$dataPay[dataPay].paymentNo}&paymentID
={$dataPay[dataPay].paymentID}&q={$q}" onclick="return
confirm('Anda Yakin ingin membatalkan nomor pembayaran
{$dataPay[dataPay].paymentNo}? penghapusan ini akan membatalkan
pembayaran transaksi ini.');"><img src="img/icons/delete.png"
width="18"></a>
</td>
</tr>
367
{/section}
</tbody>
</table>
</div>
</div><!--
/.box-body -->
{else}
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<div
class="box-tools pull-right">
<a href="pay_out.php?module=payout&act=add"
style="float: left;"><button type="button" class="btn btn-default
pull-right"><i class="fa fa-plus"></i> Add</button></a>
<a
href="print_pay_out.php?act=print&q={$q}" style="float: left;"
target="_blank"><button type="button" class="btn btn-default pull-
right"><i class="fa fa-print"></i> Print PDF</button></a>
368
</form>
</div>
</div>
</div><!--
/.box-header -->
<div
class="box-body">
<div
class="table-responsive">
<thead>
<tr>
<th>AKSI</th>
</tr>
</thead>
<tbody>
369
<tr>
<td>{$dataPay[dataPay].no}</td>
<td>{$dataPay[dataPay].paymentNo}</td>
<td>{$dataPay[dataPay].paymentDate}</td>
<td>{$dataPay[dataPay].invoiceNo}</td>
<td>{$dataPay[dataPay].soNo}</td>
<td>{$dataPay[dataPay].payType}</td>
<td>{$dataPay[dataPay].total}</td>
<td>{$dataPay[dataPay].staffName}</td>
<td>
<a title="Detail"
href="pay_out.php?module=payout&act=detailpayout&paymentID={$dataP
ay[dataPay].paymentID}&invoiceNo={$dataPay[dataPay].invoiceNo}&pay
mentNo={$dataPay[dataPay].paymentNo}&page={$page}"><img
src="img/icons/view.png" width="18"></a>
<a title="Delete"
href="pay_out.php?module=payout&act=delete&invoiceNo={$dataPay[dat
aPay].invoiceNo}&paymentNo={$dataPay[dataPay].paymentNo}&paymentID
={$dataPay[dataPay].paymentID}" onclick="return confirm('Anda
Yakin ingin membatalkan nomor pembayaran
{$dataPay[dataPay].paymentNo}? penghapusan ini akan membatalkan
pembayaran transaksi ini.');"><img src="img/icons/delete.png"
width="18"></a>
</td>
</tr>
{/section}
</tbody>
</table>
</div>
370
</div><!--
/.box-body -->
<div
class="box-header">
<i
class="ion ion-clipboard"></i>
<div
class="box-tools pull-left">
{$pageLink}
</ul>
</div>
</div><!--
/.box-header -->
{/if}
{include file="footer.tpl"}
371
Gambar 5.37. Pembayaran transaksi penjualan
372