/******************************************************************* Module : /apps/js/disp/promo.js Desc. : JS - Konfigurasi Display Promo POS Created By : Siau Pheng (siaupheng@3fonia.com). Created Date : January 15th, 2015. Last Modified : December 8th, 2025. (c) 2015 - 2025, 3FONIA Software; WWW.3FONIA.COM. *******************************************************************/ var DISPPromoJS = { PHP: '', KODE: '', loading: function(){ this.data_query('detail'); $('#Cari_Promo').keydown(function(e){ var key = e.keyCode || e.which || 0; if (key==13 && e.target.value!='') this.data_query('detail'); }.bind(this)); $('#butSearch').click(function(e){ this.data_query('detail'); }.bind(this)); $('#butAll').click(function(){ $('#Cari_Promo').val(''); this.data_query('detail'); }.bind(this)); FoniaJS.setFocus('#Cari_Promo'); }, detail_show: function(mode, ID){ new Request.JSON({ url: this.PHP, sendParam: ['data=promo-detail','mode_detail='+mode,'PromoID='+ID], onSuccess: function(ajson){ this.winDetail = FoniaJS.showWindow('Detail', 'Detail Informasi Promo', ajson.html, 900, [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], function(){ $('#winDetail') .find('#butWSimpan').click(function(){this.detail_save();}.bind(this)).end() .find('#FileGambar').off('change').change(function(){ var fd = new FormData(), files = $('#FileGambar')[0].files[0]; fd.append('Gambar1', files); $.ajax({ url: this.PHP+'?'+(FoniaJS.RequestParam(['data=upload-gambar','PromoID']).join('&')), type: 'post', data: fd, contentType: false, processData: false, success: function(ares){ if (ares.result != 0){ FoniaJS.showInfo('Sukses upload file Gambar !'); $('#PromoID').val(ares.PromoID); $('#imgPhoto').attr('src', this.PHP + '?data=image&PromoID=' + ares.PromoID + '&cq=' + $.now()); } else { FoniaJS.showError(ares.message); } }.bind(this) }); }.bind(this)); $('#imgPhoto').attr('src', this.PHP + '?data=image&PromoID=' + $('#PromoID').val() + '&cq=' + $.now()); }.bind(this)); }.bind(this) }).send(); }, detail_tambah: function(){ this.detail_show('insert', 0); }, detail_ubah: function(acell){ this.detail_show('update', acell[0]); }, detail_hapus: function(acell){ FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus "'+acell[2]+'" ?', function(){ new Request.JSONF({ url: this.PHP, sendParam: ['data=detail','mode_detail=delete','PromoID='+acell[0],'Cari_Promo'], onSuccess: function(){ FoniaJS.showInfo('Proses hapus data sukses!'); }.bind(this) }).send(); }.bind(this), 'danger'); }, detail_save: function(){ new Request.JSONF({ url: this.PHP, sendParam: ['data=detail','mode_detail','PromoID','Tanggal','Info','Warna','Font','Aktif','Cari_Promo'], onSuccess: function(){ FoniaJS.showInfo('Proses simpan data sukses!'); FoniaJS.closeWindow(this.winDetail); }.bind(this) }).send(); }, data_query: function(tipe, mode){ if (tipe=="detail"){ new Request.JSONF({ url: this.PHP, sendParam: ['data=detail','Cari_Promo'] }).send(); } } };