You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
4.0 KiB
JavaScript
126 lines
4.0 KiB
JavaScript
$(document).ready(function() {
|
|
$('#fshasil').invisibleEl();
|
|
/* dialog */
|
|
$('#dialogcaristrip').jqm({
|
|
modal: true,
|
|
trigger: '#btncarinama',
|
|
overlay: 30,
|
|
overlayClass: 'whiteOverlay',
|
|
onShow : function(hash){
|
|
hash.w.fadeIn(50);
|
|
},
|
|
onHide : function(hash){
|
|
hash.w.fadeOut(50, function(){if(hash.o) hash.o.remove();});
|
|
$('input[name="txtcari"]').val('');
|
|
$('#hasil').empty();
|
|
}
|
|
});
|
|
|
|
$('#btncarinama').live('click', function(){
|
|
$('#dialogcaristrip').jqmShow();
|
|
return false;
|
|
});
|
|
|
|
// Close Button Highlighting. IE doesn't support :hover. Surprise?
|
|
$('input.jqmdX')
|
|
.hover(
|
|
function(){ $(this).addClass('jqmdXFocus'); },
|
|
function(){ $(this).removeClass('jqmdXFocus'); })
|
|
.focus(
|
|
function(){ this.hideFocus=true; $(this).addClass('jqmdXFocus'); })
|
|
.blur(
|
|
function(){ $(this).removeClass('jqmdXFocus'); });
|
|
|
|
// ambil data
|
|
$('form[name="fcaristrip"]').submit(function(){
|
|
var postvars = {
|
|
txtcari: $("input[name='txtcari']").val(),
|
|
operation: "caristrip",
|
|
status: "ok"
|
|
};
|
|
$.post('ajaxstrip.php', postvars, function(data) {
|
|
var strip = eval('('+data+')');
|
|
var hasil;//[pelanggan.length];
|
|
var tabel = "<table width=100% border='0' style='background-color:#ccc;'>";
|
|
tabel += "<tr style=' background-color:#FFF; font-weight:bold; text-align:center'; color:#000;>";
|
|
tabel += "<td>Kode</td><td>Nama</td><td>Kategori</td><td>Hapus</td></tr>";
|
|
for(i in strip) {
|
|
tabel += "<tr style='background-color:#FFF;'><td align='center'> <a href=\"javascript:setNilai('"+strip[i].kd_strip+"')\"> "+strip[i].kd_strip+" </a></td>";
|
|
tabel += "<td> " + strip[i].nama_strip + " </td><td align='center'> " + strip[i].kel_jns + " </td><td align='center'><a href=\"javascript:setDelete('"+strip[i].kd_strip+"')\"> HAPUS </a></td></tr>";
|
|
}
|
|
tabel += "</table>";
|
|
$("#hasil").html(tabel);
|
|
$('#fshasil').visibleEl();
|
|
});
|
|
return false;
|
|
});
|
|
|
|
// simpan strip
|
|
$('form[name="fstrip"]').submit(function(){
|
|
var postvars = $('form[name="fstrip"]').formToArray();
|
|
$.post('ajaxstrip.php', postvars, function(data) {
|
|
var hasil = eval('('+data+')');
|
|
if(hasil[0] == 1){
|
|
alert("Berhasil");
|
|
$('form[name="fstrip"]').resetForm();
|
|
ambilKodestrip();
|
|
} else {
|
|
alert("Gagal");
|
|
}
|
|
});
|
|
return false;
|
|
});
|
|
});
|
|
|
|
function ambilKodestrip() {
|
|
var postvars = { operation: 'ambilKode', status: 'ok'};
|
|
$.post('ajaxstrip.php', postvars, function(data){
|
|
var kodestrip = eval('('+data+')');
|
|
$('input[name="kodestrip"]').val(kodestrip);
|
|
});
|
|
}
|
|
|
|
function setNilai(strip) {
|
|
var postvars = {id_strip: strip,
|
|
operation: 'ambilstrip',
|
|
status: 'ok'
|
|
};
|
|
$.post('ajaxstrip.php', postvars, function(data){
|
|
var strip = eval('('+data+')');
|
|
$('input[name="kodestrip"]').val(strip[0].kd_strip);
|
|
$('input[name="namastrip"]').val(strip[0].nama_strip);
|
|
$('input[name="murah1"]').val(strip[0].murah1);
|
|
$('input[name="murah2"]').val(strip[0].murah2);
|
|
$('input[name="sedang1"]').val(strip[0].sedang1);
|
|
$('input[name="sedang2"]').val(strip[0].sedang2);
|
|
$('input[name="mahal1"]').val(strip[0].mahal1);
|
|
$('input[name="mahal2"]').val(strip[0].mahal2);
|
|
$('input[name="benikmurah"]').val(strip[0].benik_murah);
|
|
$('input[name="beniksedang"]').val(strip[0].benik_sedang);
|
|
$('input[name="benikmahal"]').val(strip[0].benik_mahal);
|
|
$('input[name="kelbrg"]').val(strip[0].kel_brg);
|
|
$('input[name="keljns"]').val(strip[0].kel_jns);
|
|
$('input[name="thiwul"]').val(strip[0].persen_thiwul);
|
|
$('#dialogcaristrip').jqmHide();
|
|
});
|
|
}
|
|
|
|
function setDelete(strip) {
|
|
var postvars = {id_strip: strip,
|
|
operation: 'hapusstrip',
|
|
status: 'ok'
|
|
};
|
|
var answer = confirm ("Yakin hapus data?")
|
|
if (answer)
|
|
$.post('ajaxstrip.php', postvars, function(data){
|
|
var kary = eval('('+data+')');
|
|
if(kary[0] == 1){
|
|
alert("Hapus Berhasil");
|
|
$('#dialogcaristrip').jqmHide();
|
|
$('form[name="fstrip"]').resetForm();
|
|
} else {
|
|
alert("Hapus Gagal");
|
|
}
|
|
});
|
|
}
|