Code type module improvements:
[openemr.git] / interface / patient_file / encounter / delete_form.php
blob912e2f72a57f79dad83f315c9cde3395cad8b9d2
1 <?php
2 include_once("../../globals.php");
4 // allow a custom 'delete' form
5 $deleteform = $incdir . "/forms/" . $_REQUEST["formname"]."/delete.php";
7 check_file_dir_name($_REQUEST["formname"]);
9 if (file_exists($deleteform)) {
10 include_once($deleteform);
11 exit;
14 // if no custom 'delete' form, then use a generic one
16 // when the Cancel button is pressed, where do we go?
17 $returnurl = $GLOBALS['concurrent_layout'] ? 'encounter_top.php' : 'patient_encounter.php';
19 if ($_POST['confirm']) {
20 // set the deleted flag of the indicated form
21 $sql = "update forms set deleted=1 where id=".$_POST['id'];
22 if ($_POST['id'] != "*" && $_POST['id'] != '') sqlInsert($sql);
23 // log the event
24 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "Form ".$_POST['formname']." deleted from Encounter ".$_POST['encounter']);
26 // redirect back to the encounter
27 $address = "{$GLOBALS['rootdir']}/patient_file/encounter/$returnurl";
28 echo "\n<script language='Javascript'>top.restoreSession();window.location='$address';</script>\n";
29 exit;
32 <html>
34 <head>
35 <?php html_header_show();?>
36 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
38 <!-- supporting javascript code -->
39 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
41 </head>
43 <body class="body_top">
45 <span class="title">Delete Encounter Form</span>
47 <form method="post" action="<?php echo $rootdir;?>/patient_file/encounter/delete_form.php" name="my_form" id="my_form">
48 <?php
49 // output each GET variable as a hidden form input
50 foreach ($_GET as $key => $value) {
51 echo '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'"/>'."\n";
54 <input type="hidden" id="confirm" name="confirm" value="1"/>
55 <p>
56 You are about to delete the form '<?php echo $_GET['formname']; ?>' from <?php xl('This Encounter','e'); ?>.
57 </p>
58 <input type="button" id="confirmbtn" name="confirmbtn" value="Yes, Delete this form">
59 <input type="button" id="cancel" name="cancel" value="Cancel">
60 </form>
62 </body>
64 <script language="javascript">
65 // jQuery stuff to make the page a little easier to use
67 $(document).ready(function(){
68 $("#confirmbtn").click(function() { return ConfirmDelete(); });
69 $("#cancel").click(function() { location.href='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
70 });
72 function ConfirmDelete() {
73 if (confirm("This action cannot be undone. Are you sure you wish to delete this form?")) {
74 top.restoreSession();
75 $("#my_form").submit();
76 return true;
78 return false;
81 </script>
83 </html>