2 * interface/modules/zend_modules/public/js/installer/action.js
5 * @link https://www.open-emr.org
6 * @author Jacob T.Paul <jacob@zhservices.com>
7 * @author Vipin Kumar <vipink@zhservices.com>
8 * @author Jerry Padgett <sjpadgett@gmail.com>
9 * @copyright Copyright (c) 2020-2024 Jerry Padgett <sjpadgett@gmail.com>
10 * @author Remesh Babu S <remesh@zhservices.com>
11 * @copyright Copyright (c) 2013 Z&H Consultancy Services Private Limited <sam@zhservices.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 function register(status, title, name, method, type) {
16 $.post("./Installer/register", {st: status, mod_title: title, mod_name: name, mod_method: method, mtype: type},
18 if (data == "Success") {
19 window.location.reload();
21 const resultTranslated = js_xl(data);
22 $('#err').html(resultTranslated.msg).fadeIn().delay(2000).fadeOut();
28 function manage(id, action) {
29 if (action === 'unregister') {
30 if (!confirm("Please Confirm with OK to Unregister this Module.")) {
34 if (action === 'reset_module') {
35 if (!confirm("Please Confirm with OK to Reset Module!\nThis action may possibly remove database dependencies that are only related to this module.")) {
39 let install_upgrade_log = $("#install_upgrade_log");
40 install_upgrade_log.empty();
42 if (document.getElementById('mod_enc_menu'))
43 modencmenu = document.getElementById('mod_enc_menu').value;
46 if (document.getElementById('mod_nick_name_' + id))
47 modnickname = document.getElementById('mod_nick_name_' + id).value;
52 url: "./Installer/manage",
53 data: {modId: id, modAction: action, mod_enc_menu: modencmenu, mod_nick_name: modnickname},
54 beforeSend: function () {
57 success: function (data) {
59 var data_json = JSON.parse(data);
60 if (data_json.status.toUpperCase() === "SUCCESS") {
61 if (data_json.output != undefined && data_json.output.length > 1) {
62 install_upgrade_log.empty().show().append(data_json.output);
64 $(".show_hide_log").click(function (event) {
65 $(event.target).next("div.spoiler").toggle("slow");
69 if (parent.left_nav.location) {
70 parent.left_nav.location.reload();
71 parent.Title.location.reload();
72 if (self.name == 'RTop') {
73 parent.RBot.location.reload();
75 parent.RTop.location.reload();
77 top.document.getElementById('fsright').rows = '*,*';
79 if (data_json.output == undefined || data_json.output.length <= 1) {
80 window.location.reload();
83 alert(data_json.status);
84 window.location.reload();
87 if (e instanceof SyntaxError) {
88 install_upgrade_log.append(data);
91 install_upgrade_log.append(data);
96 complete: function () {
102 var blockInput = function (element) {
103 $(element).prop('disabled', true);
104 $(element).css("background-color", "#c9c6c6");
105 $(element).closest("a").click(function () {
110 function configure(id, imgpath) {
111 if ($("#ConfigRow_" + id).css("display") != "none") {
113 $("#ConfigRow_" + id).fadeOut();
115 $.post("./Installer/configure", {mod_id: id},
118 $("#ConfigRow_" + id).hide();
119 $("#ConfigRow_" + id).html('<td colspan="10" style="background-color: var(--light);">' + data + '</td>').fadeIn();
125 function custom_toggle(obj) {
126 if ($("#" + obj).css("display") != "none") {
127 $("#" + obj).fadeOut();
129 $("#" + obj).fadeIn();
133 function SaveMe(frmId, mod_id) {
134 var SelAccIndTab = $('#configaccord' + mod_id).accordion('getSelected');
136 var Acctitle = SelAccIndTab.panel('options').title;
138 var SelTab = $('#tab' + mod_id).tabs('getSelected');
140 var Tabtitle = SelTab.panel('options').title;
142 if (frmId == 'hooksform') {
145 url: "./Installer/SaveHooks",
146 data: $('#' + frmId + mod_id).serialize(),
147 success: function (data) {
148 $.each(data, function (jsonIndex, jsonValue) {
149 if (jsonValue['return'] == 1) {
150 $("#hook_response" + mod_id).html(jsonValue['msg']).fadeIn().fadeOut(1000);
153 $('#tab' + mod_id).tabs('select', Tabtitle);
162 function DeleteACL(aclID, user, mod_id, msg) {
163 var SelAccIndTab = $('#configaccord' + mod_id).accordion('getSelected');
165 var Acctitle = SelAccIndTab.panel('options').title;
169 url: "./Installer/DeleteAcl",
174 success: function (data) {
175 $.each(data, function (jsonIndex, jsonValue) {
176 if (jsonValue['return'] == 1) {
177 $("#ConfigRow_" + mod_id).hide();
178 configure(mod_id, '');
179 alert(jsonValue['msg']);
182 $('#configaccord' + mod_id).accordion('select', Acctitle);
191 function DeleteHooks(hooksID, mod_id, msg) {
192 var SelTab = $('#tab' + mod_id).tabs('getSelected');
194 var Tabtitle = SelTab.panel('options').title;
198 url: "./Installer/DeleteHooks",
202 success: function (data) {
203 $.each(data, function (jsonIndex, jsonValue) {
204 if (jsonValue['return'] == 1) {
205 $("#ConfigRow_" + mod_id).hide();
206 configure(mod_id, '');
207 alert(jsonValue['msg']);
210 $('#tab' + mod_id).tabs('select', Tabtitle);
220 * Save Settings Tab Contents
222 * @param {string} frmId
223 * @param {int} mod_id
224 * @returns {undefined}
226 function saveConfig(frmId, mod_id) {
229 url: "./Installer/saveConfig",
230 data: $('#' + frmId + mod_id).serialize(),
231 success: function (data) {
232 var resultTranslated = js_xl('Configuration saved successfully');
233 $('#target' + data.modeId).html(resultTranslated.msg + ' ....').show().fadeOut(4000);
239 function validateNickName(modId) {
240 Nickname = $("#mod_nick_name_" + modId).val();
241 if ($.trim(Nickname) != "") {
244 url: "./Installer/nickName",
248 success: function (data) {
250 $("#mod_nick_name_" + modId).css("background", "#FFB9B5");
251 $("#mod_nick_name_message_" + modId).html("* Duplicate Nick Name");
253 $("#mod_nick_name_" + modId).css("background", "");
254 $("#mod_nick_name_message_" + modId).html("");
262 $("#mod_nick_name_" + modId).css("background", "");
263 $("#mod_nick_name_message_" + modId).html("");