LBF custom template (nation notes) fancybox replace.
[openemr.git] / library / custom_template / add_template.php
blob8f64a9eec18d86580081084b47526b91641eb945
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2011 Z&H Consultancy Services Private Limited <sam@zhservices.com>
4 //
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Jacob T Paul <jacob@zhservices.com>
26 // +------------------------------------------------------------------------------+
30 require_once("../../interface/globals.php");
31 $list_id = $_REQUEST['list_id'];
33 <html>
34 <head>
35 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
36 <script type="text/javascript" src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js?v=<?php echo $v_js_includes; ?>"></script>
37 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
38 <script type="text/javascript">
39 function add_template(){
40 top.restoreSession();
41 mainform=window.opener.opener.document;
42 if(document.getElementById('template_name').value){
43 len = document.getElementById('multi_context').options.length;
44 sel_len=0;
45 val="";
46 for(i=0;i<len;i++){
47 if(document.getElementById('multi_context').options[i].selected==true){
48 sel_len++;
49 val+=document.getElementById('multi_context').options[i].value+"|";
52 if(sel_len>0){
53 $.ajax({
54 type: "POST",
55 url: "ajax_code.php",
56 dataType: "html",
57 data: {
58 templateid: document.getElementById('template_name').value,
59 list_id: <?php echo $list_id;?>,
60 multi: val,
61 source: "add_template"
63 async: false,
64 success: function(thedata){
65 if(thedata=="Fail"){
66 alert(document.getElementById('template_name').value+" <?php echo addslashes(xl('already exists'));?>");
67 return false;
69 else{
70 mainform.getElementById('templateDD').innerHTML = thedata;
71 alert("<?php echo addslashes(xl('Successfully added category'));?> "+document.getElementById('template_name').value);
72 //window.opener.opener.location.reload();
73 dlgclose();
76 error:function(){
79 });
81 else{
82 alert("<?php echo addslashes(xl('You should select at least one context'));?>");
85 else{
86 alert("<?php echo addslashes(xl('Category name is empty'));?>");
87 return false;
90 </script>
91 </head>
92 <body class="body_top">
93 <form >
94 <table>
95 <tr class="text">
96 <td>
97 <select multiple name="multi_context[]" id="multi_context" size="5">
98 <?php
99 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
100 while ($row=sqlFetchArray($res)) {
101 echo "<option value='".htmlspecialchars($row['cl_list_id'], ENT_QUOTES)."'>".htmlspecialchars($row['cl_list_item_long'], ENT_QUOTES)."</option>";
104 </select>
105 </td>
106 <td>
107 <input type="text" name="template_name" id="template_name">
108 </td>
109 <td>
110 <a href="#" onclick="add_template()" class="css_button"><span><?php echo htmlspecialchars(xl('ADD'), ENT_QUOTES);?></span></a>
111 </td>
112 </tr>
113 </table>
114 </form>
115 </body>
116 </html>