feat: show collection balance in billing widget (#7454)
[openemr.git] / interface / forms_admin / forms_admin.php
bloba483bb55d3db6883bd45e651f4812666cf02917d
1 <?php
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
11 //INCLUDES, DO ANY ACTIONS, THEN GET OUR DATA
12 require_once("../globals.php");
13 require_once("$srcdir/registry.inc.php");
15 use OpenEMR\Common\Acl\AclMain;
16 use OpenEMR\Common\Acl\AclExtended;
17 use OpenEMR\Common\Csrf\CsrfUtils;
18 use OpenEMR\Common\Forms\CoreFormToPortalUtility;
19 use OpenEMR\Common\Twig\TwigContainer;
20 use OpenEMR\Core\Header;
22 if (!AclMain::aclCheckCore('admin', 'forms')) {
23 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Forms Administration")]);
24 exit;
27 if (!empty($_GET['method']) && ($_GET['method'] == "enable")) {
28 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
29 CsrfUtils::csrfNotVerified();
31 updateRegistered($_GET['id'], "state=1");
32 } elseif (!empty($_GET['method']) && ($_GET['method'] == "disable")) {
33 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
34 CsrfUtils::csrfNotVerified();
36 updateRegistered($_GET['id'], "state=0");
37 } elseif (!empty($_GET['method']) && ($_GET['method'] == "install_db")) {
38 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
39 CsrfUtils::csrfNotVerified();
41 $dir = getRegistryEntry($_GET['id'], "directory");
42 if (installSQL("$srcdir/../interface/forms/{$dir['directory']}")) {
43 updateRegistered($_GET['id'], "sql_run=1");
44 } else {
45 $err = xl('ERROR: could not open table.sql, broken form?');
47 } elseif (!empty($_GET['method']) && ($_GET['method'] == "register")) {
48 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
49 CsrfUtils::csrfNotVerified();
51 $newRegisteredFormId = registerForm($_GET['name']) or $err = xl('error while registering form!');
52 if (empty($err)) {
53 // below block of code will insert the patient portal template (if it has not yet already been added) if the
54 // form is patient portal compliant
55 CoreFormToPortalUtility::insertPatientPortalTemplate($newRegisteredFormId);
59 $bigdata = getRegistered("%") or $bigdata = false;
61 //START OUT OUR PAGE....
64 <html>
65 <head>
66 <?php Header::setupHeader(); ?>
67 </head>
68 <body class="body_top">
70 <div class="container-fluid">
71 <!-- Page header -->
72 <div class="row">
73 <div class="col-12">
74 <h2 class="title"><?php echo xlt('Forms Administration');?></h2>
75 </div>
76 </div>
77 <!-- Form table -->
78 <div class="row">
79 <div class="col-12 mt-3">
80 <?php
81 if (!empty($_POST)) {
82 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
83 CsrfUtils::csrfNotVerified();
85 foreach ($_POST as $key => $val) {
86 if (preg_match('/nickname_(\d+)/', $key, $matches)) {
87 sqlQuery("update registry set nickname = ? where id = ?", array($val, $matches[1]));
88 } elseif (preg_match('/category_(\d+)/', $key, $matches)) {
89 sqlQuery("update registry set category = ? where id = ?", array($val, $matches[1]));
90 } elseif (preg_match('/priority_(\d+)/', $key, $matches)) {
91 sqlQuery("update registry set priority = ? where id = ?", array($val, $matches[1]));
92 } elseif (preg_match('/aco_spec_(\d+)/', $key, $matches)) {
93 sqlQuery("update registry set aco_spec = ? where id = ?", array($val, $matches[1]));
99 <?php //ERROR REPORTING
100 if (!empty($err)) {
101 echo "<span>" . text($err) . "</span>\n";
105 <?php //REGISTERED SECTION ?>
106 <span class="font-weight-bold"><?php echo xlt('Registered');?></span>
107 <form method="post" action ='./forms_admin.php'>
108 <span class="font-italic">
109 <?php echo xlt('click here to update priority, category, nickname and access control settings'); ?>
110 </span>
111 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
112 <input class="btn btn-primary" type='submit' name='update' value='<?php echo xla('Save'); ?>'>
114 <div class="table-responsive mt-3">
115 <table class="table table-striped table-sm">
116 <thead>
117 <tr>
118 <th colspan="5"></th>
119 <th><?php echo xlt('Priority'); ?> </th>
120 <th><?php echo xlt('Category'); ?> </th>
121 <th><?php echo xlt('Nickname'); ?> </th>
122 <th><?php echo xlt('Access Control'); ?></th>
123 </tr>
124 </thead>
125 <?php
126 if ($bigdata != false) {
127 foreach ($bigdata as $registry) {
128 $priority_category = sqlQuery(
129 "select priority, category, nickname, aco_spec from registry where id = ?",
130 array($registry['id'])
132 $patientPortalCompliant = file_exists($GLOBALS['srcdir'] . "/../interface/forms/" . $registry['directory'] . "/patient_portal.php");
134 <tr>
135 <td>
136 <span class='text'><?php echo text($registry['id']); ?></span>
137 </td>
138 <td>
139 <?php
140 echo text(xl_form_title($registry['name']));
141 echo ($patientPortalCompliant) ? ' <i class="fas fa-cloud-arrow-up" title="' . xla('Patient Portal Compliant') . '"></i>' : '';
143 </td>
144 <?php
145 if ($registry['sql_run'] == 0) {
146 echo "<td><span class='text'>" . xlt('registered') . "</span>";
147 } elseif ($registry['state'] == "0") {
148 echo "<td><a class='link_submit text-danger' href='./forms_admin.php?id=" . attr_url($registry['id']) . "&method=enable&csrf_token_form=" . attr_url(CsrfUtils::collectCsrfToken()) . "'>" . xlt('disabled') . "</a>";
149 } else {
150 echo "<td><a class='link_submit text-success' href='./forms_admin.php?id=" . attr_url($registry['id']) . "&method=disable&csrf_token_form=" . attr_url(CsrfUtils::collectCsrfToken()) . "'>" . xlt('enabled') . "</a>";
153 </td>
154 <td>
155 <span class='text'><?php
156 if ($registry['unpackaged']) {
157 echo xlt('PHP extracted');
158 } else {
159 echo xlt('PHP compressed');
162 </span>
163 </td>
164 <td>
165 <?php
166 if ($registry['sql_run']) {
167 echo "<span class='text'>" . xlt('DB installed') . "</span>";
168 } else {
169 echo "<a class='link_submit' href='./forms_admin.php?id=" . attr_url($registry['id']) . "&method=install_db&csrf_token_form=" . attr_url(CsrfUtils::collectCsrfToken()) . "'>" . xlt('install DB') . "</a>";
172 </td>
173 <?php
174 echo "<td><input type='text' class='form-control form-control-sm' size='4' name='priority_" . attr($registry['id']) . "' value='" . attr($priority_category['priority']) . "'></td>";
175 echo "<td><input type='text' class='form-control form-control-sm' size='10' name='category_" . attr($registry['id']) . "' value='" . attr($priority_category['category']) . "'></td>";
176 echo "<td><input type='text' class='form-control form-control-sm' size='10' name='nickname_" . attr($registry['id']) . "' value='" . attr($priority_category['nickname']) . "'></td>";
177 echo "<td>";
178 echo "<select name='aco_spec_" . attr($registry['id']) . "' class='form-control form-control-sm'>";
179 echo "<option value=''></option>";
180 echo AclExtended::genAcoHtmlOptions($priority_category['aco_spec']);
181 echo "</select>";
182 echo "</td>";
184 </tr>
185 <?php
186 } //end of foreach
189 </table>
190 </div>
191 <hr>
193 <?php //UNREGISTERED SECTION ?>
194 <span class="font-weight-bold"><?php echo xlt('Unregistered'); ?></span>
195 <div class="table-responsive mt-3">
196 <table class="table table-striped table-sm">
197 <?php
198 $dpath = "$srcdir/../interface/forms/";
199 $dp = opendir($dpath);
201 for ($i = 0; false != ($fname = readdir($dp)); $i++) {
202 if (
203 $fname != "." && $fname != ".." && $fname != "CVS" && $fname != "LBF" &&
204 (is_dir($dpath . $fname) || stristr($fname, ".tar.gz") ||
205 stristr($fname, ".tar") || stristr($fname, ".zip") ||
206 stristr($fname, ".gz"))
208 $inDir[$i] = $fname;
212 // ballards 11/05/2005 fixed bug in removing registered form from the list
213 if ($bigdata != false) {
214 foreach ($bigdata as $registry) {
215 $key = array_search($registry['directory'], $inDir) ; /* returns integer or FALSE */
216 unset($inDir[$key]);
220 foreach ($inDir as $fname) {
221 if (stristr($fname, ".tar.gz") || stristr($fname, ".tar") || stristr($fname, ".zip") || stristr($fname, ".gz")) {
222 $phpState = "PHP compressed";
223 } else {
224 $phpState = "PHP extracted";
227 <tr>
228 <td colspan="2">
229 <?php
230 $form_title_file = @file($GLOBALS['srcdir'] . "/../interface/forms/$fname/info.txt");
231 if ($form_title_file) {
232 $form_title = $form_title_file[0];
233 } else {
234 $form_title = $fname;
236 $patientPortalCompliant = file_exists($GLOBALS['srcdir'] . "/../interface/forms/" . $fname . "/patient_portal.php");
238 <?php
239 echo text(xl_form_title($form_title));
240 echo ($patientPortalCompliant) ? ' <i class="fas fa-cloud-arrow-up" title="' . xla('Patient Portal Compliant') . '"></i>' : '';
242 </td>
243 <td>
244 <?php
245 if ($phpState == "PHP extracted") {
246 echo '<a class="link_submit" href="./forms_admin.php?name=' . attr_url($fname) . '&method=register&csrf_token_form=' . attr_url(CsrfUtils::collectCsrfToken()) . '">' . xlt('register') . '</a>';
247 } else {
248 echo '<span class="text">' . xlt('n/a') . '</span>';
251 </td>
252 <td>
253 <span class="text"><?php echo xlt($phpState); ?></span>
254 </td>
255 <td>
256 <span class="text"><?php echo xlt('n/a'); ?></span>
257 </td>
258 </tr>
259 <?php
260 flush();
261 }//end of foreach
263 </table>
264 </div>
265 </form>
266 </div>
267 </div>
268 </div>
269 </body>
270 </html>