Feat openemr fix 7480 7494 email prescription (#7495)
[openemr.git] / library / custom_template / add_template.php
blobc8894b9e391469ccec8421b400dc6c1b4ea201b5
1 <?php
3 // +-----------------------------------------------------------------------------+
4 // Copyright (C) 2011 Z&H Consultancy Services Private Limited <sam@zhservices.com>
5 //
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
19 // A copy of the GNU General Public License is included along with this program:
20 // openemr/interface/login/GnuGPL.html
21 // For more information write to the Free Software
22 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 // Author: Eldho Chacko <eldho@zhservices.com>
25 // Jacob T Paul <jacob@zhservices.com>
27 // +------------------------------------------------------------------------------+
31 require_once("../../interface/globals.php");
33 use OpenEMR\Core\Header;
35 $list_id = $_REQUEST['list_id'];
37 <html>
38 <head>
39 <?php Header::setupHeader('opener'); ?>
40 <script>
41 function add_template(){
42 top.restoreSession();
43 mainform=window.opener.opener.document;
44 if(document.getElementById('template_name').value){
45 len = document.getElementById('multi_context').options.length;
46 sel_len=0;
47 val="";
48 for(i=0;i<len;i++){
49 if(document.getElementById('multi_context').options[i].selected==true){
50 sel_len++;
51 val+=document.getElementById('multi_context').options[i].value+"|";
54 if(sel_len>0){
55 $.ajax({
56 type: "POST",
57 url: "ajax_code.php",
58 dataType: "html",
59 data: {
60 templateid: document.getElementById('template_name').value,
61 list_id: <?php echo js_escape($list_id);?>,
62 multi: val,
63 source: "add_template"
65 async: false,
66 success: function(thedata){
67 if(thedata=="Fail"){
68 alert(document.getElementById('template_name').value+" <?php echo addslashes(xl('already exists'));?>");
69 return false;
71 else{
72 mainform.getElementById('templateDD').innerHTML = thedata;
73 alert("<?php echo addslashes(xl('Successfully added category'));?> "+document.getElementById('template_name').value);
74 //window.opener.opener.location.reload();
75 dlgclose();
78 error:function(){
81 });
83 else{
84 alert("<?php echo addslashes(xl('You should select at least one context'));?>");
87 else{
88 alert("<?php echo addslashes(xl('Category name is empty'));?>");
89 return false;
92 </script>
93 </head>
94 <body class="body_top">
95 <form >
96 <table>
97 <tr class="text">
98 <td>
99 <select multiple name="multi_context[]" id="multi_context" size="5">
100 <?php
101 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
102 while ($row = sqlFetchArray($res)) {
103 echo "<option value='" . htmlspecialchars($row['cl_list_id'], ENT_QUOTES) . "'>" . htmlspecialchars($row['cl_list_item_long'], ENT_QUOTES) . "</option>";
106 </select>
107 </td>
108 <td>
109 <input type="text" name="template_name" id="template_name">
110 </td>
111 <td>
112 <a href="#" onclick="add_template()" class="btn btn-primary"><span><?php echo htmlspecialchars(xl('ADD'), ENT_QUOTES);?></span></a>
113 </td>
114 </tr>
115 </table>
116 </form>
117 </body>
118 </html>