fix: fix no-mixed-spaces-and-tabs error (#6728)
[openemr.git] / interface / modules / zend_modules / public / js / installer / action.js
blob97e13b33eba9a2c80c53f7e41b99d5b47c347355
1 /**
2  * interface/modules/zend_modules/public/js/installer/action.js
3  *
4  * @package   OpenEMR
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 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
13  */
16 function register(status,title,name,method,type){
17         $.post("./Installer/register", { st: status, mod_title: title, mod_name: name, mod_method:method,mtype:type},
18                 function(data) {
19                         if(data == "Success") {
20                                 window.location.reload();
21                         } else {
22                                 var resultTranslated = js_xl(data);
23                                 $('#err').html(resultTranslated.msg).fadeIn().delay(2000).fadeOut();
24                         }
25                 }
26         );
29 function manage(id,action){
30     if (action == 'unregister') {
31         if (!confirm("Please Confirm with OK to Unregister this Module.")) {
32             return false;
33         }
34     }
35     install_upgrade_log = $("#install_upgrade_log");
36     install_upgrade_log.empty();
38         if(document.getElementById('mod_enc_menu'))
39                 modencmenu = document.getElementById('mod_enc_menu').value;
40         else
41                 modencmenu = '';
42         if(document.getElementById('mod_nick_name_'+id))
43                 modnickname = document.getElementById('mod_nick_name_'+id).value;
44         else
45                 modnickname = '';
46     $.ajax({
47         type: 'POST',
48         url: "./Installer/manage",
49         data: { modId: id, modAction: action,mod_enc_menu:modencmenu,mod_nick_name:modnickname},
50         beforeSend: function(){
51             $('.modal').show();
52         },
53         success: function(data){
54             try{
55                 var data_json = JSON.parse(data);
56                 if(data_json.status == "Success") {
57                     if(data_json.output != undefined && data_json.output.length > 1) {
58                         install_upgrade_log.empty()
59                                            .show()
60                                            .append(data_json.output);
62                         $(".show_hide_log").click(function(event) {
63                             $(event.target).next("div.spoiler").toggle("slow");
64                         });
65                     }
67                     if (parent.left_nav.location) {
68                         parent.left_nav.location.reload();
69                         parent.Title.location.reload();
70                         if(self.name=='RTop') {
71                             parent.RBot.location.reload();
72                         }
73                         else{
74                             parent.RTop.location.reload();
75                         }
76                         top.document.getElementById('fsright').rows = '*,*';
77                     }
78                     if(data_json.output == undefined || data_json.output.length <= 1) {
79                         window.location.reload();
80                     }
81                 }
82                 else{
83                     alert(data_json.status);
84                 }
85             } catch (e) {
86                     if (e instanceof SyntaxError) {
87                         install_upgrade_log.append(data);
88                     } else {
89                         console.log(e);
90                         install_upgrade_log.append(data);
91                     }
92             }
94         },
95         complete: function() {
96             $('.modal').hide();
97         }
98     });
101 var blockInput = function(element) {
102     $(element).prop('disabled', true);
103     $(element).css("background-color", "#c9c6c6");
104     $(element).closest("a").click(function(){return false;});
107 function configure(id,imgpath){
108         if($("#ConfigRow_"+id).css("display")!="none"){
109                 $(".config").hide();
110                 $("#ConfigRow_"+id).fadeOut();
111         }
112         else{
113                 $.post("./Installer/configure", {mod_id:id},
114                         function(data) {
115                                 $(".config").hide();
116                                 $("#ConfigRow_"+id).hide();
117                                 $("#ConfigRow_"+id).html('<td colspan="10" style="background: ghostwhite;">'+data+'</td>').fadeIn();
118                         }
119                 );
120         }
123 function custom_toggle(obj){
124         if($("#"+obj).css("display")!="none"){
125                 $("#"+obj).fadeOut();
126         }
127         else{
128                 $("#"+obj).fadeIn();
129         }
132 function SaveMe(frmId,mod_id){
133         var SelAccIndTab = $('#configaccord'+mod_id).accordion('getSelected');
134         if(SelAccIndTab)
135                 var Acctitle    = SelAccIndTab.panel('options').title;
137         var SelTab      = $('#tab'+mod_id).tabs('getSelected');
138         if(SelTab)
139                 var Tabtitle = SelTab.panel('options').title;
141         if(frmId == 'hooksform'){
142                 $.ajax({
143                         type: 'POST',
144                         url: "./Installer/SaveHooks",
145                         data: $('#'+frmId+mod_id).serialize(),
146                         success: function(data){
147                                 $.each(data, function(jsonIndex, jsonValue){
148                                         if (jsonValue['return'] == 1) {
149                                                 $("#hook_response"+mod_id).html(jsonValue['msg']).fadeIn().fadeOut(1000);
150                                                 $(function () {
151                                                 if(Tabtitle)
152                                                 $('#tab'+mod_id).tabs('select',Tabtitle);
153                                                 });
154                                         }
155                                 });
156                         }
157                 });
158         }
163 function DeleteACL(aclID,user,mod_id,msg){
164         var SelAccIndTab = $('#configaccord'+mod_id).accordion('getSelected');
165         if(SelAccIndTab)
166                 var Acctitle = SelAccIndTab.panel('options').title;
167         if(confirm(msg)){
168                 $.ajax({
169                         type: 'POST',
170                         url: "./Installer/DeleteAcl",
171                         data:{
172                                 aclID: aclID,
173                                 user: user
174                         },
175                         success: function(data){
176                                         $.each(data, function(jsonIndex, jsonValue){
177                                                 if (jsonValue['return'] == 1) {
178                                                         $("#ConfigRow_"+mod_id).hide();
179                                                         configure(mod_id,'');
180                                                         alert(jsonValue['msg']);
181                                                         $(function () {
182                                                                 if(Acctitle)
183                                                                         $('#configaccord'+mod_id).accordion('select',Acctitle);
184                                                         });
185                                                 }
186                                         });
187                         }
188                 });
189         }
192 function DeleteHooks(hooksID,mod_id,msg){
193   var SelTab = $('#tab'+mod_id).tabs('getSelected');
194   if(SelTab)
195   var Tabtitle = SelTab.panel('options').title;
196    if(confirm(msg)){
197    $.ajax({
198      type: 'POST',
199      url: "./Installer/DeleteHooks",
200      data:{
201      hooksID: hooksID
202      },
203      success: function(data){
204        $.each(data, function(jsonIndex, jsonValue){
205          if (jsonValue['return'] == 1) {
206            $("#ConfigRow_"+mod_id).hide();
207            configure(mod_id,'');
208            alert(jsonValue['msg']);
209            $(function () {
210            if(Tabtitle)
211            $('#tab'+mod_id).tabs('select',Tabtitle);
212            });
213          }
214        });
215      }
216    });
217    }
221 * Save Settings Tab Contents
223 * @param {string} frmId
224 * @param {int} mod_id
225 * @returns {undefined}
227 function saveConfig(frmId, mod_id) {
228   $.ajax({
229     type: 'POST',
230     url: "./Installer/saveConfig",
231     data: $('#' + frmId + mod_id).serialize(),
232     success: function(data){
233       var resultTranslated = js_xl('Configuration saved successfully');
234       $('#target' + data.modeId).html(resultTranslated.msg + ' ....').show().fadeOut(4000);
235     }
236   });
240 function validateNickName(modId) {
241         Nickname = $("#mod_nick_name_"+modId).val();
242         if($.trim(Nickname) != ""){
243                 $.ajax({
244                         type: 'POST',
245                         url: "./Installer/nickName",
246                         data:{
247                                 nickname : Nickname,
248                         },
249                         success: function(data){
250                                 if(data != 0){
251                                         $("#mod_nick_name_"+modId).css("background","#FFB9B5");
252                                         $("#mod_nick_name_message_"+modId).html("* Duplicate Nick Name");
253                                 }else{
254                                         $("#mod_nick_name_"+modId).css("background","");
255                                         $("#mod_nick_name_message_"+modId).html("");
256                                 }
257                         },
258                         error: function(){
259                                 alert("Ajax Error");
260                         }
261                 });
262         }else{
263                 $("#mod_nick_name_"+modId).css("background","");
264                 $("#mod_nick_name_message_"+modId).html("");
265         }