/******************************************************************* Module : /assets/js/pdf.js Desc. : JS - Cetak Laporan PDF Created By : Siau Pheng (siaupheng@3fonia.com). Created Date : April 6th, 2015. Last Modified : October 18th, 2020. (c) 3FONIA Software; WWW.3FONIA.COM. *******************************************************************/ var Pdf = function(options){ var vars = { 'url': '', 'zoom': 80, 'param': [] }; this.construct = function(options){ if (typeof options == 'object') { $.extend(vars, options); } else vars.url = options; }; this.set_url = function (url){ vars.url = url; }; this.set_zoom = function (zoom){ if (zoom) vars.zoom = zoom; }, this.add_param = function (par_id, par_val){ var _getvalue = (par_val) ? par_id + "=" + escape(par_val) : par_id; vars.param.push(_getvalue); }, this.downloadPDF = function(){ if (!vars.url) { console.warn(vars.param + ", cek url php!"); return false; } $.ajax({ type: 'POST', url: vars.url, data: FoniaJS.RequestParam(vars.param), success: (typeof vars.onSuccess === "function") ? vars.onSuccess : null, error: (typeof vars.onFailure === "function") ? vars.onFailure : null, }).always(FoniaJS.FormDecorated); return this; }; this.showPDF = function(){ var _proto = window.location.protocol + '//'; var _src = _proto + FoniaJS.WEB_HOST + vars.url + '?' + $.param(FoniaJS.RequestParam(vars.param)) + '#zoom='+vars.zoom+',0,0&page=1'; var _wtxt = ''; if ($('#winAPPPDF')) $('#winAPPPDF').modal('dispose').remove(); $(_wtxt).on('shown.bs.modal', function(e){ FoniaJS.FormDecorated(); }).on('hidden.bs.modal', function(e){ $(this).remove(); }).modal('show'); }; this.construct(options); };