Add Portal Two Features
[openemr.git] / library / custom_template / share_template.php
blob2a9348a01c834c99c8ac70eceaf073c5277dc3d5
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 $GLOBALS['assets_static_relative']; ?>/jquery/dist/jquery.min.js"></script>
37 <script type="text/javascript">
38 function add_template(){
39 top.restoreSession();
40 len = document.getElementById('provider').options.length;
41 sel_len=0;
42 val="";
43 for(i=0;i<len;i++){
44 if(document.getElementById('provider').options[i].selected==true){
45 sel_len++;
46 val+=document.getElementById('provider').options[i].value+"|";
49 if(sel_len>0){
50 $.ajax({
51 type: "POST",
52 url: "ajax_code.php",
53 dataType: "html",
54 data: {
55 list_id: <?php echo htmlspecialchars($list_id, ENT_QUOTES);?>,
56 multi: val,
57 source: "save_provider"
59 async: false,
60 success: function(thedata){
63 error:function(){
64 alert("fail");
66 });
67 dlgclose();
68 return;
70 else{
71 alert("<?php echo addslashes(xl('You should select at least one Provider'));?>");
75 </script>
76 </head>
77 <body class="body_top">
78 <form >
79 <table>
80 <tr class="text">
81 <td>
82 <select multiple name="provider[]" id="provider" size="5">
83 <?php
84 $query = "SELECT id, lname, fname FROM users WHERE authorized = 1 AND username != '' " .
85 "AND active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) ORDER BY lname, fname";
86 $res = sqlStatement($query);
87 $sel_query = "SELECT tu_user_id FROM template_users WHERE tu_template_id=?";
88 $row_sel =sqlQuery($sel_query, array($list_id));
89 while ($row = sqlFetchArray($res)) {
90 foreach ($row_sel as $key => $value) {
91 if ($value==$row['id']) {
92 $sel="selected";
93 } else {
94 $sel='';
97 echo "<option value='".htmlspecialchars($row['id'], ENT_QUOTES)."' $sel>".htmlspecialchars($row['lname'].",".$row['fname'], ENT_QUOTES)."</option>";
100 </select>
101 </td>
102 <td>
103 <a href="#" onclick="add_template()" class="css_button"><span><?php echo htmlspecialchars(xl('Save'), ENT_QUOTES);?></span></a>
104 </td>
105 </tr>
106 </table>
107 </form>
108 </body>
109 </html>