first commit
This commit is contained in:
@@ -0,0 +1,519 @@
|
||||
/*******************************************************************
|
||||
|
||||
PHP Class : /Controller/Table/ProdukController
|
||||
Description : Master Barang
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : May 19th, 2010.
|
||||
Last Modified : August 27th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
var ProdukJS = {
|
||||
PHP: '',
|
||||
KODE: '',
|
||||
|
||||
index: function(){
|
||||
this.data_query('tabel-produk');
|
||||
$('#butPrint').click(() => this.print_show());
|
||||
$('#butFilter').click(() => this.filter_show());
|
||||
$('#Cari_Produk').keydown((e) => {
|
||||
var key = e.keyCode || e.which || 0;
|
||||
if (key==13 && e.target.value!='') this.data_query('tabel-produk');
|
||||
});
|
||||
$('#butSearch').click((e) => this.data_query('tabel-produk'));
|
||||
$('#butAll').click(() => {
|
||||
$('#Cari_Produk').val('');
|
||||
this.data_query('tabel-produk');
|
||||
});
|
||||
FoniaJS.setFocus('#Cari_Produk');
|
||||
},
|
||||
|
||||
print_show: function(){
|
||||
new Request({
|
||||
url: this.PHP + '/detail_print',
|
||||
onSuccess: (ajson) => {
|
||||
this.winDPrint = FoniaJS.showWindow('DPrint', 'Cetak Daftar Barang', ajson.html, 'lg', [{},{"i":"butWCetak","v":"Cetak","c":"info"},{"i":"butWPreview","v":"Pratinjau","c":"secondary"}], () => {
|
||||
$('#winDPrint')
|
||||
.find('#butWCetak').click(() => this.print_produk(true)).end()
|
||||
.find('#butWPreview').click(() => this.print_produk());
|
||||
});
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
print_produk: function(prt){
|
||||
var cetak = new Printer(this.PHP + '/print_barang');
|
||||
cetak.add_param("SupID");
|
||||
cetak.add_param("Grup_InvID");
|
||||
cetak.add_param("Grup_MemberID");
|
||||
cetak.add_param("Tgl_Cetak");
|
||||
if (prt) cetak.doPrint(); else cetak.doPreview();
|
||||
FoniaJS.closeWindow(this.winDPrint);
|
||||
},
|
||||
|
||||
filter_show: function(){
|
||||
new Request({
|
||||
url: this.PHP + '/detail_filter',
|
||||
sendParam: ['Filter_Produk'],
|
||||
onSuccess: (ajson) => {
|
||||
this.winFilter = FoniaJS.showWindow('Filter', 'Filter Produk Sesuai Grup', ajson.html, 400, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], () => {
|
||||
$('#winFilter').find('#butWSimpan').click(() => this.filter_simpan());
|
||||
});
|
||||
$('#Fi_Produk').focus();
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
filter_simpan: function(){
|
||||
$('#Filter_Produk').val($('#Fi_Produk').val());
|
||||
FoniaJS.closeWindow(this.winFilter);
|
||||
this.data_query('tabel-produk');
|
||||
},
|
||||
|
||||
produk_show: function(mode, ID){
|
||||
new Request({
|
||||
url: this.PHP + '/detail_produk',
|
||||
sendParam: ['mode='+mode,'InvID='+ID],
|
||||
onSuccess: (ajson) => {
|
||||
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Barang', ajson.html, 'xl', [{},{i:'butWBtl',v:'Batal',c:'danger'},{i:'butWSimpan',v:'Simpan',c:'success'}], () => {
|
||||
$('#winDetail')
|
||||
.find('#butWSimpan').click(() => this.produk_simpan()).end()
|
||||
.find('#butWBtl').click(() => this.produk_batal());
|
||||
this.data_query('tabel-kemasan');
|
||||
this.data_query('tabel-varian');
|
||||
this.data_query('tabel-harga');
|
||||
});
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
produk_restore: function(acell){
|
||||
new Request({
|
||||
url: this.PHP + '/detail_restore',
|
||||
sendParam: ['InvID='+acell[0]],
|
||||
onSuccess: (ajson) => {
|
||||
this.winBRest = FoniaJS.showWindow('BRest', 'Informasi Backup Barang', ajson.html, 'xl', [], () => this.data_query('tabel-restore'));
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
produk_restore_select: function(acell){
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan restore data Barang ke versi tanggal : <b>"'+acell[0]+'"</b> ?<br><br><span class="text-danger fw-bold">HARAP KONFIRMASI KEMBALI, TERIMA KASIH!</span>', () => {
|
||||
new Request({
|
||||
url: this.PHP + '/proses_restore',
|
||||
sendParam: ['InvID','MD5Key='+acell[1]],
|
||||
onSuccess: (adata) => {
|
||||
FoniaJS.showInfo('Sukses restore Data Barang ini!');
|
||||
}
|
||||
}).send();
|
||||
}, 'danger');
|
||||
},
|
||||
|
||||
produk_restore_form: function(acell, div){
|
||||
new Request({
|
||||
url: this.PHP + '/form_restore',
|
||||
sendParam: ['InvID','MD5Key='+acell[1]],
|
||||
onSuccess: (adata) => $(div).html(adata.html)
|
||||
}).send();
|
||||
},
|
||||
|
||||
produk_tambah: function(){
|
||||
this.produk_show('add', 0);
|
||||
},
|
||||
|
||||
produk_ubah: function(acell){
|
||||
this.produk_show('edit', acell[0]);
|
||||
},
|
||||
|
||||
produk_hapus: function(acell){
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <b>"'+acell[1]+'"</b> ?', () => {
|
||||
FoniaJS.showAuth(() => {
|
||||
new Request({
|
||||
url: this.PHP + '/proses_simpan',
|
||||
sendParam: ['mode=del','InvID='+acell[0]],
|
||||
onSuccess: (adata) => {
|
||||
if (adata.status==true){
|
||||
this.data_query('tabel-produk');
|
||||
FoniaJS.showInfo('Proses hapus data sukses!');
|
||||
} else {
|
||||
FoniaJS.showInfo('Ada masalah dalam proses hapus data!');
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
}, this, 'HAPUS BARANG : '+acell[1]);
|
||||
}, 'danger');
|
||||
},
|
||||
|
||||
produk_simpan: function(){
|
||||
new Request({
|
||||
url: this.PHP + '/proses_simpan',
|
||||
sendParam: ['mode','InvID','Grup_InvID','Nama_Produk='+encodeURIComponent($('#Nama_Produk').val()),'StokID','NormalID','PPN','Harga_Beli','Harga_Tambah','Stok_Min','Stok_Max','Aktif'],
|
||||
onSuccess: (adata) => {
|
||||
if (adata.status==true){
|
||||
this.data_query('tabel-produk');
|
||||
FoniaJS.showInfo('Proses simpan data sukses!');
|
||||
} else {
|
||||
FoniaJS.showInfo('Ada masalah dalam proses simpan data!');
|
||||
}
|
||||
FoniaJS.closeWindow(this.winDetail);
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
produk_batal: function(){
|
||||
if ($('#mode').val()=='add'){
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan batalkan Penambahan Barang ?', () => {
|
||||
new Request({
|
||||
url: this.PHP + '/proses_simpan',
|
||||
sendParam: ['mode=cancel','InvID','mode_before=add'],
|
||||
onSuccess: () => {
|
||||
this.data_query('tabel-produk');
|
||||
FoniaJS.closeWindow(this.winDetail);
|
||||
}
|
||||
}).send();
|
||||
}, 'danger');
|
||||
return false;
|
||||
}
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan batalkan Perubahan Detail Barang ?', () => {
|
||||
new Request({
|
||||
url: this.PHP + '/proses_simpan',
|
||||
sendParam: ['mode=cancel','InvID'],
|
||||
onSuccess: () => FoniaJS.closeWindow(this.winDetail)
|
||||
}).send();
|
||||
}, 'danger');
|
||||
},
|
||||
|
||||
brow_produk: function(){
|
||||
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Produk2" placeholder="Kunci Pencarian" type="text"><button class="btn btn-info shadow-none" type="button" id="butSearch">Cari</button><button class="btn btn-secondary shadow-none" type="button" id="butAll">Semua</button></div></div></div><div id="divBrowProduk"> </div>');
|
||||
this.winBProduk = FoniaJS.showWindow('BProduk', 'Daftar Barang', _isi, 'xl', '', () => {
|
||||
$('#winBProduk').find('#Cari_Produk2').keydown((e) => {
|
||||
var key = e.keyCode || e.which || 0;
|
||||
if (key==13 && e.target.value!='') this.data_query('brow-produk');
|
||||
});
|
||||
$('#winBProduk').find('#butSearch').click((e) => this.data_query('brow-produk'));
|
||||
$('#winBProduk').find('#butAll').click(() => {
|
||||
$('#winBProduk').find('#Cari_Produk2').val('');
|
||||
this.data_query('brow-produk');
|
||||
});
|
||||
this.data_query('brow-produk');
|
||||
FoniaJS.setFocus('#Cari_Produk2');
|
||||
});
|
||||
},
|
||||
|
||||
produk_select: function(acell){
|
||||
FoniaJS.closeWindow(this.winBProduk);
|
||||
new Request({
|
||||
url: this.PHP + '/proses_copy',
|
||||
sendParam: ['InvID','InvBaruID='+acell[0]],
|
||||
onSuccess: (adata) => {
|
||||
if (adata.status==true){
|
||||
this.data_query('tabel-kemasan');
|
||||
this.data_query('tabel-varian');
|
||||
this.data_query('tabel-harga');
|
||||
FoniaJS.showInfo('Salin data Kemasan & Harga dari barang lain telah selesai.');
|
||||
}else{
|
||||
FoniaJS.showInfo('Ada masalah dalam proses salin data!');
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
kemasan_copy: function(){
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan salin data dari barang lain ?<br><br><span class="text-danger fw-bold">KEMASAN & HARGA YANG ADA<br>SEKARANG AKAN DIHAPUS!</span>', () => this.brow_produk(), 'warning');
|
||||
},
|
||||
|
||||
kemasan_batal: function(){
|
||||
var dt = $('#divKemasanTabel').DataTable(), tr, l_row;
|
||||
tr = $('#butBatalKemasan').closest('tr');
|
||||
l_row = dt.row(tr.prev('tr'));
|
||||
if (l_row.child.isShown()) l_row.nodes().to$().find('.fon-tabel-dt').click();
|
||||
if (l_row.data()[0]=='0') l_row.remove().draw(true);
|
||||
},
|
||||
|
||||
kemasan_add: function(){
|
||||
var dt = $('#divKemasanTabel').DataTable(), l_row;
|
||||
dt.order([0,'desc']);
|
||||
l_row = dt.row(':last');
|
||||
if (!dt.data().count() || l_row.data()[0]!=='0'){
|
||||
dt.row.add(['0','','','<a class="table-icon fon-tabel-dt" tabindex="-1" title="Detail"><i class="bi-pencil"></i></a>']).draw(true);
|
||||
l_row = dt.row(':last');
|
||||
}
|
||||
if (!l_row.child.isShown()) l_row.nodes().to$().find('.fon-tabel-dt').click();
|
||||
},
|
||||
|
||||
kemasan_form: function(acell, div){
|
||||
new Request({
|
||||
url: this.PHP + '/form_kemasan',
|
||||
sendParam: ['InvID','InvKemasanID='+acell[0],'Satuan_Stok='+$('#StokID').find(':selected').text()],
|
||||
onSuccess: (adata) => {
|
||||
$(div).html(adata.html);
|
||||
$(div)
|
||||
.find('#butBatalKemasan').click((e) => this.kemasan_batal()).end()
|
||||
.find('#butSimpanKemasan').click((e) => this.kemasan_check());
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
kemasan_del: function(acell){
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <b>"'+acell[2]+'"</b> ?', () => {
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/tabel_kemasan',
|
||||
sendParam: ['mode','mode_detail=delete','InvID','InvKemasanID='+acell[0],'SatuanLamaID='+acell[1],'Satuan_Stok='+$('#StokID').find(":selected").text()],
|
||||
onSuccess: () => {
|
||||
FoniaJS.showInfo('Proses hapus data sukses!');
|
||||
var _obtn = $('button:contains("Salin Kemasan")');
|
||||
if (_obtn) _obtn.removeClass('btn-info').addClass('btn-warning');
|
||||
}
|
||||
}).send();
|
||||
}, 'danger');
|
||||
},
|
||||
|
||||
kemasan_save: function(){
|
||||
if ($('#Qty').val()==0){
|
||||
FoniaJS.showInfo('Mohon isi jumlah Qty / Kemasan !');
|
||||
return false;
|
||||
}
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/tabel_kemasan',
|
||||
sendParam: ['mode','mode_detail=update','InvID','InvKemasanID','SatuanID','SatuanLamaID','Qty','Satuan_Stok='+$('#StokID').find(":selected").text()],
|
||||
onSuccess: () => {
|
||||
FoniaJS.showInfo('Sukses menyimpan kemasan produk.');
|
||||
this.data_query('tabel-varian');
|
||||
this.data_query('tabel-harga');
|
||||
var _obtn = $('button:contains("Salin Kemasan")');
|
||||
if (_obtn) _obtn.removeClass('btn-info').addClass('btn-warning');
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
kemasan_check: function(){
|
||||
if ($('#SatuanID').val()==$('#SatuanLamaID').val()) {
|
||||
this.kemasan_save();
|
||||
return;
|
||||
}
|
||||
new Request({
|
||||
url: this.PHP + '/check_kemasan',
|
||||
sendParam: ['InvID','SatuanID'],
|
||||
onSuccess: (adata) => {
|
||||
if (adata.ada==true) {
|
||||
FoniaJS.showInfo("Nama kemasan telah ada dalam sistem!");
|
||||
} else {
|
||||
this.kemasan_save();
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
varian_batal: function(){
|
||||
var dt = $('#divVarianTabel').DataTable(), tr, l_row;
|
||||
tr = $('#butBatalVarian').closest('tr');
|
||||
l_row = dt.row(tr.prev('tr'));
|
||||
if (l_row.child.isShown()) l_row.nodes().to$().find('.fon-tabel-dt').click();
|
||||
if (l_row.data()[0]=='0') l_row.remove().draw(true);
|
||||
},
|
||||
|
||||
varian_add: function(){
|
||||
var dt = $('#divVarianTabel').DataTable(), l_row;
|
||||
dt.order([0,'desc']);
|
||||
l_row = dt.row(':last');
|
||||
if (!dt.data().count() || l_row.data()[0]!=='0'){
|
||||
dt.row.add(['0','SKU_BARU','','','','<a class="table-icon fon-tabel-dt" tabindex="-1" title="Detail"><i class="bi-pencil"></i></a>']).draw(true);
|
||||
l_row = dt.row(':last');
|
||||
}
|
||||
if (!l_row.child.isShown()) l_row.nodes().to$().find('.fon-tabel-dt').click();
|
||||
},
|
||||
|
||||
varian_form: function(acell, div){
|
||||
new Request({
|
||||
url: this.PHP + '/form_varian',
|
||||
sendParam: ['InvID','InvVarianID='+acell[0]],
|
||||
onSuccess: (adata) => {
|
||||
$(div).html(adata.html);
|
||||
$(div)
|
||||
.find('#butBatalVarian').click((e) => this.varian_batal()).end()
|
||||
.find('#butSimpanVarian').click((e) => this.varian_check());
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
varian_del: function(acell){
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <b>"'+acell[4]+'"</b> ?', () => {
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/tabel_varian',
|
||||
sendParam: ['mode','mode_detail=delete','InvID','InvVarianID='+acell[0]],
|
||||
onSuccess: () => FoniaJS.showInfo('Proses hapus data sukses!')
|
||||
}).send();
|
||||
}, 'danger');
|
||||
},
|
||||
|
||||
varian_save: function(){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/tabel_varian',
|
||||
sendParam: ['mode','mode_detail=update','InvID','InvVarianID','SatuanID','VarianID','Kode_Barcode'],
|
||||
onSuccess: () => FoniaJS.showInfo('Sukses menyimpan varian produk.')
|
||||
}).send();
|
||||
},
|
||||
|
||||
varian_check: function(){
|
||||
if (($('#SatuanID').val()==$('#SatuanLamaID').val()) && ($('#VarianID').val()==$('#VarianLamaID').val()) && ($('#Kode_Barcode').val()==$('#Kode_BarcodeLama').val())) {
|
||||
this.varian_save();
|
||||
return;
|
||||
}
|
||||
new Request({
|
||||
url: this.PHP + '/check_varian',
|
||||
sendParam: ['InvID','SatuanID','VarianID','Kode_Barcode'],
|
||||
onSuccess: (adata) => {
|
||||
if (adata.ada==true) {
|
||||
FoniaJS.showInfo("Nama varian telah ada dalam sistem!");
|
||||
} else {
|
||||
this.varian_save();
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
harga_batal: function(){
|
||||
var dt = $('#divHargaTabel').DataTable(), tr, l_row;
|
||||
tr = $('#butBatalHarga').closest('tr');
|
||||
l_row = dt.row(tr.prev('tr'));
|
||||
if (l_row.child.isShown()) l_row.nodes().to$().find('.fon-tabel-dt').click();
|
||||
if (l_row.data()[0]=='0') l_row.remove().draw(true);
|
||||
},
|
||||
|
||||
harga_add: function(){
|
||||
var dt = $('#divHargaTabel').DataTable(), l_row;
|
||||
dt.order([0,'desc']);
|
||||
l_row = dt.row(':last');
|
||||
if (!dt.data().count() || l_row.data()[0]!=='0'){
|
||||
if (FoniaJS.user_level(2)) {
|
||||
dt.row.add(['0','','',0,0,0,0,'<a class="table-icon fon-tabel-dt" tabindex="-1" title="Detail"><i class="bi-pencil"></i></a>']).draw(true);
|
||||
} else dt.row.add(['0','','',0,'<a class="table-icon fon-tabel-dt" tabindex="-1" title="Detail"><i class="bi-pencil"></i></a>']).draw(true);
|
||||
l_row = dt.row(':last');
|
||||
}
|
||||
if (!l_row.child.isShown()) l_row.nodes().to$().find('.fon-tabel-dt').click();
|
||||
},
|
||||
|
||||
harga_form: function(acell, div){
|
||||
new Request({
|
||||
url: this.PHP + '/form_harga',
|
||||
sendParam: ['InvID','InvHargaID='+acell[0]],
|
||||
onSuccess: (adata) => {
|
||||
$(div).html(adata.html);
|
||||
$(div)
|
||||
.find('#butBatalHarga').click((e) => this.harga_batal()).end()
|
||||
.find('#butSimpanHarga').click((e) => this.harga_check());
|
||||
this.calc_Modal();
|
||||
this.calc_Harga(1);
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
harga_del: function(acell){
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <b>"'+acell[1]+' - '+acell[2]+'"</b> ?', () => {
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/tabel_harga',
|
||||
sendParam: ['mode','mode_detail=delete','InvID','InvHargaID='+acell[0]],
|
||||
onSuccess: () => FoniaJS.showInfo('Proses hapus data sukses!')
|
||||
}).send();
|
||||
}, 'danger');
|
||||
},
|
||||
|
||||
harga_save: function(){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/tabel_harga',
|
||||
sendParam: ['mode','mode_detail=update','InvID','InvHargaID','SatuanID','Grup_MemberID','Harga_Jual'],
|
||||
onSuccess: () => FoniaJS.showInfo('Sukses menyimpan harga produk.')
|
||||
}).send();
|
||||
},
|
||||
|
||||
harga_check: function(){
|
||||
if (($('#SatuanID').val()==$('#SatuanLamaID').val()) && ($('#Grup_MemberID').val()==$('#GrupLamaID').val())) {
|
||||
this.harga_save();
|
||||
return;
|
||||
}
|
||||
new Request({
|
||||
url: this.PHP + '/check_harga',
|
||||
sendParam: ['InvID','SatuanID','Grup_MemberID'],
|
||||
onSuccess: (adata) => {
|
||||
if (adata.ada==true) {
|
||||
FoniaJS.showInfo("Harga jual per member telah ada dalam sistem!");
|
||||
} else {
|
||||
this.harga_save();
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
data_query: function(tipe, mode){
|
||||
if (tipe=="tabel-produk"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/tabel_produk',
|
||||
sendParam: ['Cari_Produk','Filter_Produk']
|
||||
}).send();
|
||||
} else if (tipe=="tabel-kemasan"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/tabel_kemasan',
|
||||
sendParam: ['mode','InvID','Satuan_Stok='+$('#StokID').find(":selected").text()],
|
||||
onSuccess: () => {
|
||||
var _obtn = $('button:contains("Salin Kemasan")');
|
||||
if (_obtn) _obtn.removeClass('btn-info').addClass('btn-warning');
|
||||
}
|
||||
}).send();
|
||||
} else if (tipe=="tabel-varian"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/tabel_varian',
|
||||
sendParam: ['mode','InvID']
|
||||
}).send();
|
||||
} else if (tipe=="tabel-harga"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/tabel_harga',
|
||||
sendParam: ['mode','InvID']
|
||||
}).send();
|
||||
} else if (tipe=="tabel-restore"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/tabel_restore',
|
||||
sendParam: ['InvID']
|
||||
}).send();
|
||||
} else if (tipe=="brow-produk"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/brow_produk',
|
||||
sendParam: ['Cari_Produk2'],
|
||||
onSuccess: () => FoniaJS.setFocus('#Cari_Produk2')
|
||||
}).send();
|
||||
}
|
||||
},
|
||||
|
||||
hitung_HPP: function(){
|
||||
$('#Harga_Pokok').val(FoniaJS.FloatToStr(FoniaJS.StrToFloat($('#Harga_Beli').val()) + FoniaJS.StrToFloat($('#Harga_Tambah').val()), 0));
|
||||
},
|
||||
|
||||
calc_Modal: function(){
|
||||
new Request({
|
||||
url: this.PHP + '/check_modal',
|
||||
sendParam: ['InvID','SatuanID'],
|
||||
onSuccess: (ajson) => {
|
||||
if (ajson) {
|
||||
$('#Harga_Modal').val(FoniaJS.FloatToStr(FoniaJS.StrToFloat($('#Harga_Pokok').val()) * ajson.Qty));
|
||||
this.calc_Harga(1);
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
calc_Harga: function(tipe){
|
||||
var harga = FoniaJS.StrToFloat($('#Harga_Jual').val());
|
||||
var pjual = FoniaJS.StrToFloat($('#Persen_Jual').val());
|
||||
var hmodal = FoniaJS.StrToFloat($('#Harga_Modal').val());
|
||||
if (tipe == 1){
|
||||
$('#Persen_Jual').val(FoniaJS.FloatToStr((harga == 0 ? 0 : (harga - hmodal) / harga * 100), 2));
|
||||
} else {
|
||||
$('#Harga_Jual').val(FoniaJS.FloatToStr(hmodal / (100 - pjual) * 100));
|
||||
}
|
||||
},
|
||||
|
||||
calc_Harga1: () => ProdukJS.calc_Harga(1),
|
||||
calc_Harga2: () => ProdukJS.calc_Harga(2),
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user